如何在emu 8086 hello world代码中将21h转换为13h或10h中断使用

时间:2015-03-13 11:52:06

标签: assembly emulation interrupt x86-16

; emu8086 version 4.00-Beta-12 or better is required! 
; put file named "input.txt" to c:\emu8086\vdrive\c\ 
; (it's possible to copy "ReadMe.txt" and rename it or use any other 


org 100h ; .com memory layout 

mov dx, offset db; address of file to dx 
mov al,0 ; open file (read-only) 
mov ah,3dh 
int 21h ; call the interupt 
jc terminate ; if error occurs, terminate program 
mov bx,ax ; put handler to file in bx 

mov cx,1 ; read one character at a time 
print: 
lea dx, BUF 
mov ah,3fh ; read from the opened file (its handler in bx) 
int 21h 
CMP AX, 0 ; how many bytes transfered? 
JZ terminate ; end program if end of file is reached (no bytes 

mov al, BUF ; char is in BUF, send to ax for printing (char is 

mov ah,0eh ; print character (teletype). 
int 10h 
jmp print ; repeat if not end of file. 


terminate: 
mov ah, 0 ; wait for any key... 
int 16h 
ret 

db " Hello World! ", 0 
BUF db ? 


END

0 个答案:

没有答案