参考链接:DOS Interrupts
开发环境:dosbox,windows
01 从标准输入(STDIN)读取字符
说明:返回值 AL = 读取的字符
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ; read char from stdin ; 01.asm ; masm.exe 01.asm ; link.exe 01.obj ; 01.exe code segment assume cs:code main: mov ah, 01h ; read char from stdin int 21h mov ah, 4ch int 21h code ends end main |
测试结果
02 写字符到标准输出(STDOUT)
说明:DL = 要写的字符
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ; write char from stdin ; 02.asm ; masm.exe 02.asm ; link.exe 02.obj ; 02.exe code segment assume cs:code main: mov dl, 'c' mov ah, 02h int 21h mov ah, 4ch int 21h code ends end main |
测试结果
06 直接控制台输出
说明:DL = 输出字符
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ; direct console output ; 06.asm ; masm.exe 06.asm ; link.exe 06.obj ; 06.exe code segment assume cs:code main: mov dl, 'c' mov ah, 06h int 21h mov ah, 4ch int 21h code ends end main |
测试结果