Reputation: 6547
I am trying to make my own bootloader written in 16 bit assembly. I am able to print text to a screen using int 10h, AH = 0Eh
.
If I run
MOV AL, 65
MOV AH, 0Eh
int 10h
HLT
I am successfully able to print A
to the screen.
However, if I am to do
MOV AL, 65
CALL printc
HLT
printc:
MOV AH, 0Eh
int 10h
RET
I end up getting AA
displayed on the screen instead.
Why is this and how would I fix it?
Here is my full code:
BITS 16
ORG 0x7C00
MOV DS, AX
MOV SI, 0x7C00
MOV AL, 65
CALL printc
HLT
printc:
MOV AH, 0Eh
int 10h
RET
times 510-($-$$) db 0x90
dw 0xAA55
Upvotes: 2
Views: 91
Reputation: 58762
To quote the instruction set reference:
HLT Stops instruction execution and places the processor in a HALT state. An enabled interrupt (including NMI and SMI), a debug exception, the BINIT# signal, the INIT# signal, or the RESET# signal will resume execution.
As you can see, an interrupt will resume execution and at least the timer interrupt is usually running, along with other possible sources such as key presses.
Thus, you should add a loop around the HLT
to make it go back to sleep.
Upvotes: 3