So i have two files namely boot.asm and data.asm.I ran some NASM commands to appends the two assembly files(512 bytes sectors) to create a 1024 bytes virtual hard disk.But after running on an emulator , i saw that the simple 'hello world ' string on my data.asm file is not appearing on the screen.
the boot.asm file is-
ORG 0
BITS 16
start:
cli ;disables interrupts
mov ax,0x7c0
mov ds,ax
mov es, ax
mov ax,0x00
mov ss,ax
sti ;enables interrupts
;setup registers to read from disk
mov bh,0x0200
mov ah, 0x02
mov al, 0x01
mov ch ,0x00
mov cl,0x02
mov dh,0x00
mov dl,0x80
int 0x13 ;reads disk
mov si,0x200
call print ;calls print function
jmp $
print:
mov bx,0 ;clears bx register
.loop
lodsb ;load byte at address si into al and increment si
cmp al,0 ;compare value in al to 0
je .done ;is al is 0 , end of string
call print_char ;prints charcatar in al
.done
ret ;return from print function
print_char:
mov ah,0eh ;move 0eh into ah
int 0x10 ;handles screen operations
ret
times 510 -($-$$) db 0
dw 0xAA55
data.asm file is-
message: db 'hello world',0
times 512 -($-$$) db 0 ;fills rest of sector with zeros upto 510 bytes
dw 0xAA55
The commands i used were-
nasm -f bin boot.asm -o boot.bin
nasm -f bin data.asm -o data.bin
dd if=./boot.bin of=./os.bin
I ran this -
dd if=./data.bin conv=notrunc oflag=append of=os.bin
instead of
dd if=./data.bin conv=notrunc oflag=append of=./os.bin.
Then i ran-
qemu-system-x86_64 -hda os.bin.
So the string 'Hello world' defined in data.asm file is not running properly.