0

I have the following code:

[org 0x7c00]
string : db "hello", 0

mov ah , 0x0e  
mov al , "j"
int 0x10 
jmp $

times 510-($-$$) db 0
db 0x55 , 0xaa 

For some reason the character is not printed. When I define the string after the interrupt, the program works fine.

What is the matter with this?

I'm using the following commands:

nasm -fbin boot2.asm -o boot2.iso && qemu-system-x86_64 -drive format=raw,file=boot2.iso
zx485
  • 28,498
  • 28
  • 50
  • 59
  • 6
    Do not put data in the execution path. To the cpu bytes are bytes, if you put them in the way, the cpu will try to execute them as instructions. – Jester Dec 15 '21 at 21:37
  • 2
    The first problem is thinking of this as anything so fancy as a "declaration". Assembly is simpler and more brutal than higher-level languages. `db` means "put these bytes in the output, right here, right now". – Nate Eldredge Dec 16 '21 at 00:20
  • i guess then those bites cause some malfunction . i thought of it more like this: the cpu will execute some irrelevant code , and then will proceed executing the mov ah , 0xe etc ... but probably was really not good setting those bits in that place . thanks :) – Νίκος Αντωνετσής Dec 16 '21 at 08:19

0 Answers0