Zhane
October 31st, 2009, 09:35 PM
I am able to put values into AL and print using 'CALL PrintCharacter'
but I couldnt print 'msg' with 'Call PrintString'
am I missing anything here? please help
----------------------
cpu 686
use16
segment .text
%define TC_BIOS_KEY_ENTER 1ch
GLOBAL Logger
GLOBAL g_uLoggerCodeSize
GLOBAL g_uCallAskPasswordDeltaOffset
push ax
push es
push ds
pop es ; put ds into es
MOV ESI, msg
Call PrintString
.keypress:
;wait for keypress
mov ah,0
int 16h
pop es
pop ax
.exit:
pop bp
ret ; cdecl
;----------- Procedures --------------
PrintCharacter: ;Procedure to print character on screen
;Assume that ASCII value is in register AL
PUSHA
MOV AH, 0x0E ;Tell BIOS that we need to print one charater on screen.
MOV BH, 0x00 ;Page no.
MOV BL, 0x07 ;Text attribute 0x07 is lightgrey font on black background
INT 0x10 ;Call video interrupt
POPA
RET ;Return to calling procedure
; ---- Dont work ----
PrintString: ;Procedure to print string on screen
;Assume that string starting pointer is in register SI
PUSHA
next_character: ;Lable to fetch next character from string
MOV AL, 88 ; X
CALL PrintCharacter
MOV AX, [ESI] ;Get a byte from string and store in AL register
INC ESI ;Increment SI pointer
OR AX, AX ;Check if value in AL is zero (end of string)
JZ exit_function ;If end then return
CALL PrintCharacter ;Else print the character which is in AL register
JMP next_character ;Fetch next character from string
exit_function: ;End label
MOV AL, 87 ; W
CALL PrintCharacter
POPA
RET ;Return from procedure
msg dw 'Hello, world!',0xa ;our dear string
but I couldnt print 'msg' with 'Call PrintString'
am I missing anything here? please help
----------------------
cpu 686
use16
segment .text
%define TC_BIOS_KEY_ENTER 1ch
GLOBAL Logger
GLOBAL g_uLoggerCodeSize
GLOBAL g_uCallAskPasswordDeltaOffset
push ax
push es
push ds
pop es ; put ds into es
MOV ESI, msg
Call PrintString
.keypress:
;wait for keypress
mov ah,0
int 16h
pop es
pop ax
.exit:
pop bp
ret ; cdecl
;----------- Procedures --------------
PrintCharacter: ;Procedure to print character on screen
;Assume that ASCII value is in register AL
PUSHA
MOV AH, 0x0E ;Tell BIOS that we need to print one charater on screen.
MOV BH, 0x00 ;Page no.
MOV BL, 0x07 ;Text attribute 0x07 is lightgrey font on black background
INT 0x10 ;Call video interrupt
POPA
RET ;Return to calling procedure
; ---- Dont work ----
PrintString: ;Procedure to print string on screen
;Assume that string starting pointer is in register SI
PUSHA
next_character: ;Lable to fetch next character from string
MOV AL, 88 ; X
CALL PrintCharacter
MOV AX, [ESI] ;Get a byte from string and store in AL register
INC ESI ;Increment SI pointer
OR AX, AX ;Check if value in AL is zero (end of string)
JZ exit_function ;If end then return
CALL PrintCharacter ;Else print the character which is in AL register
JMP next_character ;Fetch next character from string
exit_function: ;End label
MOV AL, 87 ; W
CALL PrintCharacter
POPA
RET ;Return from procedure
msg dw 'Hello, world!',0xa ;our dear string