With All the binary in the Air for this thread, i thought i'd change it slightly, and say ... this is where hex comes into play.

U dont program in binary, u can however program in hex. Assemblers are very simple Compilers basicly, Assembly is the lowest form of language to people, but when u assemble it, it gets converted into hex. It is this that gets executed by the processor (after conversion into binary).

So from this i'll do a simple example .....

Using most versions of DOS comes a simple debugger ("Debug.exe") using this u can program .com files in assembly, and it will convert the whole file into hex. now with .com files they are an exact copy of the program code (no header info besides the identifyer), they are limited in size to 64k.

if u start debug up preceded by a non existant file name it just gives u a
-
Hit A to enter assemble mode.
it will display the first memory adderss and await input.
then enter your first Assembly instruction.
Hit enter, then enter next instruction...... etc
when done, leave a blank line and just hit enter.

it should look something like this:

C:\>debug blah.com
-A
0B31:0100 mov ax,4c
0B31:0102 int 21h
0B31:0104
-


back to the -

from here we need to enter the amount of bytes to save to the file.

this is stored in the CX register.

so if u type rcx , it will display the current value and prompt u for a new value.

u need to enter the the difference between your start address (in this case 100 (for all com files) ) and your finish address (in my case 104).

so the total leaving 4, so put 4 in CX.

then just hit w to write the data to the file and q if u want to quit.

the output will contain your hexadecimal equivalent to your assembly instructions.

The file will run as a normal .com file (all it does is return control to DOS, if u write anything bigger u need those 2 instructions on the end or the program will crash after execute).

all so simple ...


What the file contains in ascii : ¨YL ¨T!

The Hexadecimal reprisentation in the file each represents an Assembly instruction ... eg 2B 4C (as the first 2 bytes in the file) This is the same as mov AX,4C

u get idea.

using debug u can display the results of your program using the T and the prompt, that will trace through the code and u can see the memory addresses, hex opcodes, operands and registers. quite a powerfull tool (although not as strong as gdb )

And thats basicly how it works. if u know the hex opcodes your blown in (there are hundreds of thousands and very between processor platforms).


heh, sorry this post was a little big, just wanted to explain it well. (although i am drunk and tired).