假设您使用 Intel 语法的 BIOS 中断:
要打印单个字符:
mov al, 'G' ;Copy the char's value to al. Replace G with the char you want to print
mov ah, 0x0e ;Copy the function number, in this case 0Eh, to ah.
int 0x10 ;Call the BIOS video service
获取输入并打印它(用 echo 读取字符):
xor ax, ax ;Make ax zero (faster than mov)
int 0x16 ;Raise the interrupt. Returns character code in al
mov ah, 0x0e ;Start Writing. Set AH to 0xe.
int 0x10 ; Call BIOS video service. Prints char.
在第一个示例的第二行中,我将功能编号复制到 ah,这样当 BIOS 检查寄存器的值时,它就知道该做什么了。有关常见中断类和函数的列表,请查看此处。
如果汇编代码无法在您的计算机上编译,您可能正在使用 AT&T 语法汇编,但根据您提供的示例,我认为您不是。