You are not logged in.

#1 2024-03-15 09:25:38

teh_misteik
Member
From: Iran
Registered: 2024-03-12
Posts: 28

How can i boot an assembly code using qemu

So recently I was trying to make a bootable program and I use qemu for virtualization. But when I try this:

qemu-system-i386 -fda build/main_flp.img

The new windows that my program is supposed to run won't show up. My program does nothing, it's just an endless loop of nothing ( main: jmp main ).
My Makefile basically compiles the main.asm to main.bin and copies it to main_flp.img and

truncate -s 1440k build/main_flp.img

I'm pretty sure that the problem isn't my program so I asked it here.
Any solutions? Thanks

Last edited by teh_misteik (2024-03-16 18:25:03)


Arch Linux newbie here

        Thanks for reading my signature, but I'm afraid there is nothing interesting to see over here. So I don't know why are you still reading this. Okay I should admit that you are curious, so if you are still reading this far, congratulations!       

Offline

#2 2024-03-15 11:27:06

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,858

Re: How can i boot an assembly code using qemu

You need to provide a bootable floppy image that includes everything necessary to start an OS .

Typically bootable floppy images for MSDOS, FreeDos, win98, linux etc are used as a base.
What OS are you intending to boot to on main_flp.img ?

Last edited by Lone_Wolf (2024-03-15 11:27:27)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#3 2024-03-15 13:11:32

teh_misteik
Member
From: Iran
Registered: 2024-03-12
Posts: 28

Re: How can i boot an assembly code using qemu

Lone_Wolf wrote:

You need to provide a bootable floppy image that includes everything necessary to start an OS .

Typically bootable floppy images for MSDOS, FreeDos, win98, linux etc are used as a base.
What OS are you intending to boot to on main_flp.img ?

I am making my own os. If it helps, here is the source code and Makefile for the os

src/main.asm

org 0x7C00
bits 16

main:
  jmp main

times 510-($-$$) db 0
dw 0xaa55

Makefile

ASM=nasm

BUILD=build
SRC=src

$(BUILD)/main_flp.img: $(BUILD)/main.bin
	cp $(BUILD)/main.bin $(BUILD)/main_flp.img
	truncate -s 1440k $(BUILD)/main_flp.img

$(BUILD)/main.bin: $(SRC)/main.asm
	$(ASM) $(SRC)/main.asm -f bin -o $(BUILD)/main.bin

Arch Linux newbie here

        Thanks for reading my signature, but I'm afraid there is nothing interesting to see over here. So I don't know why are you still reading this. Okay I should admit that you are curious, so if you are still reading this far, congratulations!       

Offline

#4 2024-03-16 09:17:44

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,858

Re: How can i boot an assembly code using qemu

You will have to use an existing bootloader or write your own so the physical / virtual machine knows how to start to your OS .

Here are some links I think you'll find useful :

https://retrocomputing.stackexchange.co … k-bootable
https://en.wikibooks.org/wiki/X86_Assembly/Bootloaders
https://stackoverflow.com/questions/327 … 6#32705076

P.S. please change the thread title (edit first post) to something like "How to boot assembly code from floppy image using qemu ?"


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

Board footer

Powered by FluxBB