Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Logically, those instructions are not the same thing...it looks like the machine code you wrote is using the incorrect operand sizes in the second example, but I could be wrong.
Somehow I'm guessing flat binary output was what you had in mind...but if I'm wrong correct me.
Try changing it to:
nasm -f aout ex.asm -o ex.o
ld ex.o -o ex.bin -oformat=binary
I'm also confused as to why you have all of the command line switches to remove symbols...I'm not sure if it can do the jump $ without them, but maybe it can. I've never before used ELF as an output format from nasm, and it does not work on my system as ld won't take it as an input file. My knowledge of nasm and ld are limited, so I could be wrong...
Also, if this is related to osdev, try reading Bran's kernel tutorial (google it), it might help you get started.
what you are missing is a "bits 32" directive. If its not present it causes nasm to guess the operation size, which ends up being different for both targets.
The differences you see are the various prefixes to force 16 or 32 bit code operation.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
the '-f elf' directive, among other things, tells NASM to default to 32 bit code.
the '-f bin' (default) directive tells it to default to 16 bit code.
The fact that the changes are '66's is a dead giveaway - '66' is a prefix that tells the CPU 'the next instruction uses a 16 bit register if we're running 32 bit code or a 32 bit register if we're running 16 bit code'.