I've been trying to get it to work for several hours now and nothing seems to make the output to come out in either one or two lines. I've taken the second loop I had before with a string, changed a's to b's and even switched the order little by little.
Code:
[org 0x7c00]
mov ah, 0x0e
mov bx, varName
printString:
mov al, [bx]
cmp al, 0
je end
int 0x10
inc bx
jmp printString
end:
jmp $
varName:
db "Hello World", 0
mov bh, 0x0e
mov bl, 'Z'
int 0x10
loop:
dec bl
cmp bl, 'A' - 1
je exit
int 0x10
jmp loop
exit:
jmp $
times 510-($-$$) db 0
dw 0xaa55
current output: Hello World
I tried removing both, one at a time, and it works as intended ran separately.
Note: I'm using qemu, asm, vim and have been using vscode to help with any writing misspellings
CodePudding user response:
changed a's to b's
Don't do this! If an api states that it expects the function number in the AH
register, then it will surely not help to try passing it in the BH
register.
In a sense you got lucky with that jmp $
not letting you execute that bogus second part.
To execute both parts of the code, you could replace that jmp $
(which is an endless loop), with a normal jump to the first instruction of the second part:
...
end:
jmp Part2
varName:
db "Hello World", 0
Part2:
mov ah, 0x0E ; BIOS.Teletype
mov al, 'Z'
...
Alternatively, move the data to below the second part. That way no jump is needed:
...
end:
mov ah, 0x0E ; BIOS.Teletype
mov al, 'Z'
...
varName:
db "Hello World", 0
...
Since this is a bootsector program you might take a look at Disk Read Error while loading sectors into memory where I have listed some things that are important in bootsector programs and that your current program is still missing. e.g. You don't setup any segment registers and you are omiting the DisplayPage parameter for the BIOS.Teletype function.