注意,在bochsrcSDL.bxrc不需要這兩句,否則就會做成video framebuffer 0xb8000不能使用
範例代碼
bits 16
%define ONE 1
org 0x7c00
mov ax, 0xb800
mov es, ax
mov byte [es:0], 'P'
mov byte [es:1], 4
mov byte [es:2], 'e'
mov byte [es:3], 3
loop1:
jmp loop1
times 512-($-$$)-2 db 0
signature dw 0xaa55
###############################################################
# bochsrc.txt file for DLX Linux disk image.
###############################################################
# how much memory the emulated machine will have
megs: 16
# hard disk
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=disk, path="hd.img", mode=flat, cylinders=40, heads=16, spt=63
# choose the boot disk.
boot: c
#display_library: term
# other choices: win32 sdl wx carbon amigaos beos macintosh nogui rfb term svga
display_library: sdl2
# where do we send log messages?
log: bochsout.txt
# disable the mouse, since DLX is text only
mouse: enabled=0
magic_break: enabled=1
#debug: action=report
info: action=report
error: action=report
panic: action=report
#!/bin/bash
if [ $# != 4 ]; then
echo "Usage : insertData.sh source dest <source skip position> <dest seek position>"
exit;
fi
source_size=$(ls -l $1 | awk {'print $5'})
#dest_size=$(ls -l $2 | awk {'print $5'})
total_seek_size=$((source_size + $4))
#dd if=$2 of=insertData_temp skip=$total_seek_size ibs=1 obs=1MB > /dev/null
if [ $4 = 0 ]; then
rm -fr first
touch first
else
echo "dd if=$2 of=first bs=$4 count=1";
dd if=$2 of=first bs=$4 count=1
fi
#### back #####
echo "dd if=$2 of=back skip=1 bs=$total_seek_size";
dd if=$2 of=back skip=1 bs=$total_seek_size
cat first $1 back > $2
rm -fr first back
編譯指令
nasm a.asm -l a.lst
./insertData.sh a hd.img 0 0
bochs -f bochsrcSDL.bxrc