I'm trying to call the BIOS 10h interrupt function 0Eh (teletype output) to print a string on real mode (testing with QEMU). In NASM I have no problem, program prints string correctly:
bits 16 ; Use 16 bit code
section .text
boot:
xor ax, ax ; Clear AX register
mov ds, ax ; Clear DS register
mov es, ax ; Clear ES register
mov ss, ax ; Clear SS register
mov si, hello ; Set SI to string
mov ah, 0x0E ; Set function
.loop:
lodsb ; Store character into AL
or al, al ; Check for NULL end
jz halt ; On NULL end
int 0x10 ; Call 10h interrupt
jmp .loop ; Continue with next character
halt:
cli
hlt
hello: db "Hello, World!", 0
times 510 - ($-$$) db 0
dw 0xAA55
I produce the floppy image with the following orders:
nasm -f elf64 boot.asm -o boot.o
ld -Ttext 0x7c00 boot.o -o boot.out
objcopy -O binary -j .text boot.out boot.bin
dd if=/dev/zero of=floppy.img bs=1024 count=720
dd if=boot.bin of=floppy.img conv=notrunc
But in FASMemphasized text doesn't prints the string correctly:
format elf64
use16
section '.text'
org 0x0
boot:
cld ; Clear direction flag
xor ax, ax ; Clear AX register
mov ds, ax ; Clear DS register
mov es, ax ; Clear ES register
mov ss, ax ; Clear SS register
mov si, hello ; Set SI to string
mov ah, 0x0E ; Set function
puts:
lodsb ; Store character into AL
or al, al ; Check for NULL end
jz halt ; On NULL end
int 0x10 ; Call 10h interrupt
jmp puts ; Continue with next character
halt:
cli
hlt
hello: db "Hello, World!", 0
times 510 - ($-$$) db 0
dw 0xAA55
And to produce the floppy image:
fasm boot.asm boot.o
ld -Ttext 0x7c00 boot.o -o boot.out
objcopy -O binary -j .text boot.out boot.bin
dd if=/dev/zero of=floppy.img bs=1024 count=720
dd if=boot.bin of=floppy.img conv=notrunc
What I'm missing?