Why doesn't NASM compile to an object file with the org directive?
org 0x7C00
nop
mov ax, ax
nop
If I compile this with:
nasm -O0 -fobj temp.asm
NASM gives me an error for whatever reason:
temp.asm:1: error: parser: instruction expected
In this case instead of org
you should use resb
:
; file: nasmOrg.asm
; assemble: nasm -f obj nasmOrg.asm -o nasmOrg.obj
SEGMENT _TEXT PUBLIC CLASS=CODE USE16
; resb 0x0100 ; reserve 0x0100 bytes for a .COM program
resb 0x7C00 ; reserve 0x7C00 bytes for a boot sector
..start:
nop
mov ax, ax
nop
This is how you can compile different parts of a .COM program into separate object files. If you use TLINK as the linker, the next step would be:
tlink.exe /t nasmOrg.obj [any other object files], nasmOrg.bin
Note that if you omit the comma and the following name of the resultant binary (nasmOrg.bin) or if you specify a name with the .COM extension (e.g. nasmOrg.com), TLINK will refuse to link, it will say something like:
Error: Cannot generate COM file : invalid initial entry point address
And you'll have to change 0x7C00 to 0x0100 to make a .COM program.