Reputation: 83
Does somebody know what's wrong with the following code?
I cannot make it to work the way I want it. I just want to print a single character of a variable (the letter 'h').
To do that I just copy contents using indirect addressing via the square brackets
[]
; Set BIOS print screen settings
mov ah, 0x0e ; Teletype
mov bh, 0 ; Page number
mov bl, 4 ; Red on black (00000100 - High 0000 is black, low 0100 is red)
mov cx, 1 ; Writes one character
; Printing to screen
mov al, [msg] ; Copy the contents of 'H' into 'al'; IT SEEMS THIS IS NOT WORKING!!!
jmp print_char ; Jump to executable code and do not let CPU step on DATA SECTION
; [BEG DATA SECTION]
msg: db 'HELLO', 0
; [END DATA SECTION]
print_char:
int 0x10 ; Call BIOS routine to print the char located at 'al'
infinite_loop:
jmp $
times 510 -($-$$) db 0 ; Pad with 0 until byte 510
dw 0xAA55 ; MBR Boot code signature
What I get is a screen that prints "nothing" (Probably an ASCII non-printable character:
Upvotes: 2
Views: 1863
Reputation: 83
The problem was that it was lacking the following instruction at the top:
org 0x7c00
More info regarding this in the answer of @Michael Petch.
Upvotes: 6