Thanks guys I really appreciate your feedback. I totally agree with
kscguru about the overkill and that's why I started this post.
Ok, so, I've created flat disk image with
bximage utility as
XenOS suggested. Please have a look at current state:
1. Bochs config
Code: Select all
#----------------------------------------------------------------------------------------------------
# BIOS
#----------------------------------------------------------------------------------------------------
romimage: file=BIOS-bochs-latest, address=f0000 #0xdffff
vgaromimage: file=VGABIOS-lgpl-latest
#----------------------------------------------------------------------------------------------------
# Hard Drive
#----------------------------------------------------------------------------------------------------
ata0-master: type=disk, path="MyOS.img", mode=flat, cylinders=8, heads=16, spt=63
#----------------------------------------------------------------------------------------------------
# Boot
#----------------------------------------------------------------------------------------------------
boot: disk
#----------------------------------------------------------------------------------------------------
# Logging
#----------------------------------------------------------------------------------------------------
log: MyOS.log
error: action=report
info: action=report
2. Boot loader
Code: Select all
msg db "Welcome to My Operating System!", 0
;***************************************
; Prints a string
; DS=>SI: 0 terminated string
;***************************************
Print:
lodsb
or al, al ; al=current character
jz PrintDone ; null terminator found
mov ah, 0eh ; get next character
int 10h
jmp Print
PrintDone:
ret
;*************************************************;
; Bootloader Entry Point
;*************************************************;
loader:
xor ax, ax ; Setup segments to insure they are 0. Remember that
mov ds, ax ; we have ORG 0x7c00. This means all addresses are based
mov es, ax ; from 0x7c00:0. Because the data segments are within the same
; code segment, null em.
mov si, msg
call Print
cli ; Clear all Interrupts
hlt ; halt the system
times 510 - ($-$$) db 0 ; We have to be 512 bytes. Clear the rest of the bytes with 0
dw 0xAA55 ; Boot Signiture
Compiled with NASM into binary file of 512 bytes.
Then I've wrote a simple Java utility to copy raw bytes from one file to another and used it to copy from compiled boot file to the first 512 bytes of MyOS.img file. Still no string output:
Am I doing something wrong? Maybe some problem with endianess? Should I write boot loader in little-endian or big-endian style into MyOS.img?
P. S. I've just found out that when I give Bochs empty (zeroed) MyOS.img - he quits with something like "No bootable device". But when I give him MyOS.img with boot loader (written by my Java utility) - he does not quit but shows "Booting from hard disk..." - like on the screenshot. So it seems like I'm on the right way, but still why the string does not output?