[ale] so im crazy

Irv Mullins irvm at ellijay.com
Wed Dec 19 09:11:43 EST 2001


On Wednesday 19 December 2001 07:03 am, Stephen Turner wrote:
> ok so maybe im crazy but i wanna learn to program in
> hex.. 

Not crazy - it's a good thing to learn how computers 
actually work.

> yea ok so i asked my teacher a lil about this
> and he pointed me to the conversions of the binary 0's
> 1's to hex.. dandy.. neat trick... 

Computers only understand 1's and 0's. People, on the other hand,
are easily confused by long lists of them, like this:

00111000
00000000
11111000
00000001
10100001
11100001

So they use the hex representation of the binary numbers instead.
(easier to read, much easier to type)

38
00
F8
01
A1
E1

> now how do i make
> the hex do stuff? he says something about asembly.. i
> look up assembly for intel based processors since i
> heard the assembly language is based on processor.
> well its nothing more than text which i could slap in
> notepad instead of using a hex editor or so it seems..
> anyways im either confused at this subject or see no
> point in a hex editor except for a program dump... can
> someone straighten me out ? much appreciated :) web
> sites welcome

Correct.. You could write your program, just like I have 
written the hex code above, with any plain text editor.
It wouldn't load or run, but that's another matter.

In addition, as you can see, it's still not very easy to know what it's 
supposed to do, and even harder to find a mistake. 
That's where an assembler comes in.  The above code (part of a timer 
application) was actually written:

ORG:: 0000  SKP       ; jump over the next byte
TIME:          BYTE     ; which stores the time delay requested
INIT:            LDI  01   ; load the value 1 
                  PLO  1   ; into register 1.0
                  SEX  1   ; make R1 the I/O pointer (nice mnemonic, no?)
.............

The idea is that mnemonics (like LDI - short for LoaD Immediate) are 
easier to remember than the hex equivalent. I never forget SEX, for example.
Having comments helps in understanding what you meant to do.

The assembler program takes the above text, and changes the mnemonics 
to hex, assigns addresses, then adjusts jumps, offsets, etc, saving you a 
lot of tedious work. Either it, or a separate loader program, converts the 
hex to runnable binary.

A hex editor will only be needed if you want to look at the final binary 
file, and even then, if your program is longer than a few dozen bytes, 
editing it can be more work than it's worth. As for writing a program with 
a hex editor -- well, you could, but you also 'could' saw down an oak 
tree with a fingernail file.

A warning is in order here: since you will be working directly with the 
processor, it's very easy to make a misteak that can trash (not just crash) 
the whole computer. Better learn with an old pc, or better yet, a simple 
single-board micro. 

Regards,
Irv


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list