I have this NASM code:
Note that this is the original code before correcting my first error (see edit below):
[org 0x0100]
jmp start
Numbers: dw 10, 40, 20, 14, 19, 13, 50, 6, 60, 14
swap: db 0
start: mov bx, 0
mov byte [swap], 0
loop1: mov ax, [Numbers+bx]
cmp ax, [Numbers+bx+2]
jle noswap
mov dx, [Numbers+bx+2]
mov [Numbers+bx+2], ax
mov [Numbers+bx], dx
mov byte [swap], 1
noswap: add bx, 2
cmp bx, 18
jne loop1
mov ax, 0x4c00
int 0x21
I am using this command to assemble:
nasm -f elf Max.asm
I get this error:
error: unrecognized directive org
Why am I getting this error, and how can I fix it?
EDIT: After removing the brackets around the org
statement as suggested in the comments, I am now getting this error instead:
Max.asm:1: error: parser: instruction expected
The originate directive tells the assembler to initialise all offsets for data and code in the program from given value.
org 0x0100
is used when writing small(Normally .COM files) DOS programs to compensate for the PSP(Program Statement Prefix)
.
If you are working on linux, there is no point in adding the orginate directive.
nasm -f bin max.asm
will work, but then it can be executed only in DOSBOX.