Skip to content

Instantly share code, notes, and snippets.

@qnnnnez
Created January 8, 2019 13:33
Show Gist options
  • Save qnnnnez/6bafdf883fa3f19c7ecbea8ffa406f20 to your computer and use it in GitHub Desktop.
Save qnnnnez/6bafdf883fa3f19c7ecbea8ffa406f20 to your computer and use it in GitHub Desktop.
compile and run .COM executable in dosbox
OUTPUT_FORMAT("binary")
OUTPUT_ARCH("i386")
ENTRY(_start)
_start = 0x100;
SECTIONS
{
. = 0x100;
.text : { *(.text) }
.data : { *(.data) }
}
.data
hello_str: .ascii "hello from binutils$"
.text
.code16
_start: .global _start
main:
mov $hello_str, %dx
movb $0x9, %ah
int $0x21
exit:
movb $0x4c, %ah
int $0x21
.end
AS := as
LD := ld
DOSBOX := dosbox
%.o: %.S
$(AS) --32 -o $@ $<
output.com: hello.o
$(LD) -T dos.ld -o $@ $<
all: output.com
clean:
rm *.o *.com
dosbox: output.com
$(DOSBOX) -C "mount c: ." -C "c:" -C $<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment