I’ve tried using some of the assembly tutorials around the web, and most of them don’t work for me. I’m using NASM, and VirtualBox (Couldn’t get Bochs to work either), and stuff like this works:
[BITS 16]
[ORG 0x7C00]
push 0xB800
pop es
mov byte [es:0],'A'
mov byte [es:1],0x1F
jmp $
times 510-($-$$) db 0
dw 0xAA55
but this doesn’t:
[BITS 16]
[ORG 0x7C00]
mov ah,0x09
mov al,'A'
mov bh,0
mov bl,0x1F
mov cx,1
int 0x10
jmp $
times 510-($-$$) db 0
dw 0xAA55
I’m using this batch script I made:
:: Compile with NASM ::
@echo off
echo Compiling boot.asm to boot.bin
cd C:/Users/Christian/Desktop/Assembly
C:/nasm/nasm -f bin boot.asm -o boot.bin
:: Copy to a floppy image with bfi ::
echo Creating boot.img
cd C:/Users/Christian/Desktop/Assembly
timeout 1 >nul
C:/Users/Christian/Desktop/Assembly/bfi -b=boot.bin -t=4 -l="Boot" -f=boot.img
:: Start Virtual Machine ::
echo Starting Virtual Machine "Test"
timeout 1 >nul
"C:\Program Files\Oracle\VirtualBox\VBoxManage" controlvm "Test" poweroff
"C:\Program Files\Oracle\VirtualBox\VBoxManage" startvm "Test"
Any ideas as to why this isn’t working?
I also tried ndisasm -b 16 boot.img, as suggested, but it just repeatedly outputs div dh? (this is on the working version)
As a bootloader, you won’t have a valid stack, you’ll need to set that up yourself. Any stack ops (which you’re invoking with the INT) are fraught with peril if you don’t know you have a good stack!