Non-functional PrintString? [Solved]
Posted: Fri Apr 03, 2009 5:07 am
Hi all,
First off - an apology. I'm sorry to be yet another stuck newbie coming and asking for your time, but I've been working at this for awhile now and I don't appear to be going anywhere so I could really do with a second opinion.
I'm attempting to write a real mode bootstrap. I've made a few boot sectors before and got to the point of reading keyboard input but in those effects I must admit I had used copy and pasted code. Code that I understood but c&p'd not the less.
Currently my code sits as follows:
The output of this is a cleared screen and the cursor underscore, nothing else.
Editing the code to test the PRINTCHAR function results in a correctly printed character, giving the impression the fault is not with that but with the PRINTSTRING function.
Any ideas would be greatfully received, thanks
Sam
EDIT:
Forgot to mention it's nasm code, compiled with:
nasm BOOTSTRAP.asm -f bin -o boot.bin
Then virtualized with VirtualBox. Thanks.
First off - an apology. I'm sorry to be yet another stuck newbie coming and asking for your time, but I've been working at this for awhile now and I don't appear to be going anywhere so I could really do with a second opinion.
I'm attempting to write a real mode bootstrap. I've made a few boot sectors before and got to the point of reading keyboard input but in those effects I must admit I had used copy and pasted code. Code that I understood but c&p'd not the less.
Currently my code sits as follows:
Code: Select all
[BITS 16]
ORG 0 ;Setup at start of memory
MOV AH, 07h
INT 10h ;Clear Screen
MOV SI, WELCOME
MOV BL, 07h ;Colour set 7
MOV BH, 00h ;Page 0
CALL PRINTSTRING ;Print it!
JMP $
PRINTCHAR: ;AL=CHAR, BL=COLOUR, BH=PAGE#
MOV AH, 09h
MOV CX, 1h
INT 10h
RET
PRINTSTRING: ;SI=STRING, BL=COLOUR, BH=PAGE#
MOV AL, [SI] ;Move current character of string into AL
CMP AL, 0 ;Is it 0?
JNZ .EXIT ;If so, exit
CALL PRINTCHAR ;Print current Char
INC SI ;Move the pointer one character forward in the string
JMP PRINTSTRING ;Repeat
.EXIT:
RET ;Leave procedure
WELCOME db 'Hello World', 0
TIMES 510-($-$$) db 0 ;fill the rest with 0s
DW 0xAA55 ;Bootsector stamp
Editing the code to test the PRINTCHAR function results in a correctly printed character, giving the impression the fault is not with that but with the PRINTSTRING function.
Any ideas would be greatfully received, thanks
Sam
EDIT:
Forgot to mention it's nasm code, compiled with:
nasm BOOTSTRAP.asm -f bin -o boot.bin
Then virtualized with VirtualBox. Thanks.