I am trying to print string in my program. When i put my instructions
mov ah,9h
mov dx,poruka
int 21h
before call _inst_09 it prints well. But when i print inside my code like shown below it prints weird stuff and characters.
This is picture of working program. String is printed well
This is picture of program not working when i print my string inside the code
This is my TSR code
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"
Here is the deal with code. This is a TSR program, so it terminates and stays resident when i run it. When i press esc button it should print my string on the screen(it jumps on .krj label) but it will show something like you see on the 2nd picture. When i put my instructions before call _inst09 like i said before it will print my string lik in the 1st picture.
I think that somehow my string address has changed and that is why it is not working but i cannot figure it out.
I would appreciate if you could give me a direct answer regarding to my code.