2014-11-04 36 views
0

我想在我的程序中打印字符串。當我把我的指示納斯姆在TSR程序中打印字符串

mov ah,9h 
mov dx,poruka 
int 21h 

之前call _inst_09它打印好。但是當我在我的代碼裏面打印如下所示時,它會打印怪異的東西和字符。 This is picture of program working.這是工作程序的圖片。串印也

asdd這不是工作程序的照片時,我打印的代碼

在我的字符串這是我的TSR代碼

org 100h 

NULL   equ 000h 
ESC   equ 001h   
KBD   equ 060h   

EOI   equ 020h   
Master_8259 equ 020h 
zelena equ 02h        

main: 
    mov ah,9h 
mov dx,poruka 
int 21h 
call _inst_09 

_inst_09: 
cli 
xor  ax, ax 
mov  es, ax 

;mov ax, [stari_int09_off] 

mov  bx, [es:09h*4] 
mov  [stari_int09_off], bx 
mov  [es:60h*4], bx ; U int60h ubacujemo off od int9h  
mov  bx, [es:09h*4+2] 
mov  [stari_int09_seg], bx 
mov  [es:60h*4+2], bx ; U int60h ubacujemo seg od int9h 

mov  dx, tastatura 
mov  [es:09h*4], dx 
mov  ax, cs 
mov  [es:09h*4+2], ax 
sti 

mov ax,3100h 
mov dx,500 
int 21h 
ret 

tastatura: 
push ax 
in  al, KBD    
mov [kbdata], al 
cmp byte[kbdata],20h 
je .lup 
cmp byte[kbdata],ESC 
je .krj 
mov  al, EOI    
out  Master_8259, al  
pop  ax 
int 60h ; Vracamo stari interupt 9h 
iret 
.lup: 
mov ax,0b800h ;dont forget 0 before b 
mov es,ax 
mov bx,word[video] 
mov ah, 02h 
int 1ah 

mov al,dh 
mov byte [es:100+bx],al ;also dont forget the byte thing 
;inc byte[video] 
;inc byte[video] 
mov  al, EOI    
out  Master_8259, al  
pop  ax 
iret 
.krj: 
mov ah,9h 
mov dx,poruka 
int 21h 
ret 

stari_int09_seg: dw 0 
stari_int09_off: dw 0 


kbdata: db 0        
key: db 0 
video: dw 100 

poruka: db 'Poruka.$' 

%include "ekran.asm" 

下面是處理代碼。這是一個TSR程序,所以它在我運行時終止並保持常駐狀態。當我按Esc按鈕時,它應該在屏幕上打印我的字符串(它跳上.krj標籤),但它會顯示像你在第二張圖片上看到的東西。當我在打電話給_inst09之前,像我之前說過的那樣,我會在第一張照片中打印我的字符串。
我認爲,不知何故,我的字符串地址已經改變,這就是爲什麼它不工作,但我不明白。
如果你能給我一個關於我的代碼的直接回答,我將不勝感激。

回答

0

如果我們跳轉到.krj,那麼我們也必須通過發送EOI,彈出斧頭並以iret結束來終止ISR。最後的「ret」指令是錯誤的。

1

With je .krj您跳轉到調用DOS服務進行打印的例程。您不能在中斷處理程序中使用DOS服務,因爲在觸發中斷時DOS可能已被佔用。
這裏最簡單的解決方案是使用BIOS teletype函數0Eh輸出到屏幕。爲什麼不寫信給0B800h段的屏幕呢?因爲你已經在其他地方做了它?