Hi,
I'm new on this board and still new to assembly. So forgive my newbness if this seems a straightforward thing to fix but I don't know how to get around it.
Basically, I am writing a 16 bit boot sector to a floppy (code stating at 0x00, padded with 0xAA55 at 510) and it works fine. The bios boots it up and runs the code. But because I am not using DOS, I am using BIOS commands directly, I am having a problem printing a simple string.
I can use 10h to print a constant character, but not to print a character in a variable, and not print a string in memory.
Here is my code below... If anyone has any explanations, they would be much appreciated.
-----------------------------------------------
[BITS 16] ; 16 bit code generation
mymsg db 'B' ; A single byte char variable
main: ; Main program label
;Call the bios interrupt 10h to print a char to screen...(Works OK)
mov bh,0x00 ; Page number
mov bl,0x07 ; Text attribute (white)
mov al,'A' ; Print an 'A'
mov ah,0x0e ; Print char function of 10h
int 0x10 ; Execute 10h
;Call the bios interrupt 10h to print a char to screen from memory...(Not working?)
; PS, I know that I don't need to repeat a lot of these instructions, this is just for example.
mov bh,0x00 ; Page number
mov bl,0x07 ; Text attribute (white)
mov al,[mymsg] ; Print a 'B'from variable - Does nothing or prints garbage
mov ah,0x0e ; Print char function of 10h
int 0x10 ; Execute 10h
; So, I tried this....
mov bh,0x00 ; Page number
mov bl,0x07 ; Text attribute (white)
mov al,byte [mymsg] ; Print an 'B' - Does nothing or prints garbage
mov ah,0x0e ; Print char function of 10h
int 0x10 ; Execute 10h
; And this....
mov bh,0x00 ; Page number
mov bl,0x07 ; Text attribute (white)
mov al,[byte mymsg] ; Print an 'B' - Does nothing or prints garbage
mov ah,0x0e ; Print char function of 10h
int 0x10 ; Execute 10h
; And even this....
mov bh,0x00 ; Page number
mov bl,0x07 ; Text attribute (white)
mov si,[mymsg] ;
mov al,[si] ; Print an 'B' - Does nothing or prints garbage
mov ah,0x0e ; Print char function of 10h
int 0x10 ; Execute 10h
; It only work when a constant is moved into al. Confused.
; Keep looping here to keep things on screen...
infiniteloop:
jmp infiniteloop
times 510-($-$$) db 0 ; Fill the rest of the sector with zeros
dw 0xAA55 ; Boot signature at 511-512
times 1474560-($-$$) db 0 ; Pad rest with 0's to create 1.44mb bootable floppy image