News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Help Making an Operating System.

Started by AeroASM, April 16, 2005, 01:26:16 PM

Previous topic - Next topic

AeroASM

I got Bochs, but I do not think I will use it. Is there no simple way to just load a flat .bin file into memory and execute it?

thomasantony

Yes there is. Rename the file to .COM and put an ORG 100h instead of any other ORG instruction in the source. And go into DOS  mode (not DOS shell, select Restart in MSDOS mode in Shutdown menu). Go to whatever directory you have the program and run it. I think making a Bochs image file and running it is much easier than this. Making an image is very simple. If you use NASM put the following in a file (empty.asm, dummy.asm bullsh*t.asm anything..)

times 1474560-(your_bin_file_size) db 0

Now assemble the file to get dummy.bin
Now do the following DOS command

copy /B your_bin_file.bin+dummy.bin a.img

There you have your image file. You can put all the assembling and other things into a batch file to make it easy

Thomas
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

roticv

For OS coding, I use fasm which can output binary. I use winimage to create the floppy disk image and use vmware/virtual pc to test it.

Farabi

I have the code for set flat real mode, but unfortunately this computer cannot open a .zip file. Maybe you can get use of it. Or if you can, please check my post titled "Courious about Opcode?".
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

pbrennick

AeroASM,

http://www.emu8086.com/ is a nice Visual Microprocessor Emulator.  It also has its own Assembler as well as sample code for creating a tiny OS.  When you load the source code you can copy it to a virtual floppy (memory) and test it there.  It is a nifty tool as it can emulate a lot of stuff.

Paul

AeroASM

I have got that but it is no use for Protected Mode

thomasantony

Hi roticv,
     Isn't it a pain in the a** if you have to use WinImage every time you have to check out a small change you made to the prog. I use the following batch file for tesing my FAT12 OS. It copies the files and copies some 100k into an image file so that it contains the FAT structures, the file data etc. Then I add a dummy file at the end.

@echo off
nasm -fbin -o boot.com boot.asm
if errorlevel 1 goto exit
nasm -fbin -o oskernel.com oskernel.asm
if errorlevel 1 goto exit
nasm -fbin -o dummy.bin dummy.asm
copy logo.txt a:
debug boot.com < debugops.ini
copy oskernel.com a:
:partcopy -f0 0 3E800 os.bin
partcopy -f0 0 19000 os.bin
copy /b os.bin+dummy.bin a.img
\bochs\bochs -q
:\bochs\bochsdbg -q
del dummy.bin
del os.bin
:exit

debugops.ini contians:

w 100 0 0 1
q

  So I can test my OS simply by running this batch file.
Thomas :U
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

rea

#22
By the way, there is a way that you can "delete" a step in your work ;) or a workaround..

Files:

1) boot.asm
1) kernel.asm
2) img.asm

img.asm:

incbin "boot.bin"
incbin  "kernel.bin"
;%assign addition FSIZE
;%error Size of boot.bin+kernel.bin = s
times 1474560- (FSIZE) db 0


compile it with:


nasmw -fbin -oimg.img -DFSIZE=15 img.asm


Sure, before you should know the size of the kernel.bin and boot.bin, and sure you can use -DFSIZE 15+30 if you dont whant to make the adition ;), yiu can uncomment the lines if you whant to check them ;).

-------------------------------------------

[FIX]
Ops, I was missing a operator in a previous try, now I have remembered another one, then it can be reduced more ;)

img.asm:




incbin "boot.bin"
incbin  "kernel.bin"
times 1474560- ($-$$) db 0


or




start_here:
incbin "boot.bin"
incbin  "kernel.bin"
end_here:
times 1474560- (end_here-start_here) db 0


compile it with:


nasmw -fbin -oimg.img img.asm


And dont need to add :P, I was failing because I was only using times "1474560- $ db 0", that dosent work ;).
[/FIX]

I do another sugestion.. because $$ signal the start of the segment then is the same than the second one way...

thomasantony

Hi,
  Should have got this before. I think I can still use it by 'incbinning' the FAT data read from the disk.

Thomas :U
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

Polizei

AeroASM: You do not need a PHYSICAL floppy drive, you can emulate it by using VMware WorkStation (I use 5.0 for my boot tests) ;))