Hi! Readers. I hope you have stored in your mind previous topics from Previous lessons. I am Just using simple method to learn even the readers are new. If you are already have knowledge please skip these topics. Now I am going to tell How to print a string to your 16 bit operating system. The commands are here below
;Stringprint.asm
mov ax, 0x07c0
mov ds, ax
mov si, msg
ch_loopmain:
lodsb
cmp al, 0 ;
je hangmain ; if char is Null then finish this loop
mov ah, 0x0E
int 0x10
jmp ch_loopmain
hangmain:
msg dw 'ManiCMD>'
times 510-($-$$) db 0
db 0x55
db 0xAA
See the above example. This program will show your string in your operating system screen.
The statements in green colors are already explained. Now I am going to explain the unknown statements.
msg dw 'ManiCMD>'
This statement tells compiler make define word for msg variable and store the string "ManiCMD> " in that string variable.
mov si, msg
This statement used for move your stack index to msg string. Stack index is used as source index in string operations. So source Index is in msg string now.
lodsb
This statement is used to load the string to stack.
Load byte at address DS:SI into AL so the character will print where the index is pointing.
cmp al, 0 ;
je hangmain
Compare the character is Null(cmp al,0) if Null finish that loop. If NOT NULL print the character and do again that loop.
I hope you understood our previous program.
You can save this program any .asm file separately and compile and make any .img file.
Thank you for Reading.....
No comments:
Post a Comment