//flex table opened by JP

Click to See Complete Forum and Search --> : Programming where do I start...?


Vacinden Ragnatrov
03-28-2000, 08:02 AM
I want to learn the very basics of computersystems.....I want to be able to understand every detail of what my computer is doing.....what is the most low-level programming language there is...and how can I begin to understand it......?

Paul V
03-28-2000, 11:16 AM
The truly low-level is machine code. It's a pain. Really a pain. I have had to write machine code (yup, write it all in binary then convert to hex) for a programming course.

Above this is assembly language. There are variants on this. For all processors there is a language (and each has its own) that does nothing more than use mnemonics instead of binary instructions, but implements no further functionality than machine code. for example, in MIPS assembler, the command addu, to add unsigned numbers, looks like:

addu $8, $8, $9

and takes the place of:

0000 0001 0000 1001 0100 0000 0010 0001

(or 0x01094021 in hex)

However, many assembly language variants (most indeed, supported by all but the most basic assemblers) allow for other structures, such as labels for locations. So in any reasonably advanced x86 assembler, this command will jump to the label entitled label1:

jmp label1

.
.
.
other stuff here
.
.
.
label1: more stuff

In "pure" assembly, you need to count the number of bytes that all the commands in between take, and use a jmp with the number of bytes specified.

True assembly is kind of a pain. The best real use for it is to write an assembler so you never have to use it again http://www.sysopt.com/forum/wink.gif The thing about true assembly is you can write a program straight with only a hex editor, no software at all (besides the OS unless you write that or bypass it which is doable too) is needed to run it.

I suggest taking a course at a local college actually, take a course on computer architecture, I've had many on architecture and design, and, given time and someone to manufacture parts to my designs, could in theory make a whole computer. It would take a looong time though.

Oh, one other note: All assembly languages are different. I've used x86 and several variants of MIPS assembler. But they all are reasonably similar, so if you know one, as long as you get a list of commands and their syntax you will be able to write in any other. Differences are really mnemonic and syntactic. Like:

add ax, 4

and

add $8, $8, 4

do the same thing (increment the value of a register by 4), the first is x86 assembler, the second is MIPS assembler.

Hope this gives you some ideas as to the nature of a computer. Also good luck if you plan to do machine coding http://www.sysopt.com/forum/smile.gif Do it all on pencil and paper first, where you write the instruction mnemonic on one line, above writh the instruction format, then on the line above that fill in the fields that are required. It's easiest that way. Also add lines through the opcodes (the binary representations of the operations) to separate fields for easy checking. Like this is how I would do the addu command from above:



0000 00|01 000|0 1001| 0100 0|000 0010 0001
0000 00|ss sss|t tttt| dddd d|000 0010 0001
addu $d, $s, $t



Here I can, at a glance, see that ddddd = 8, sssss = 8, and ttttt = 9. So this does addu $8, $8, $9 as I wanted.

Then you can convert binary to hex easily, take each group of 4 and convert it to its hex equiv (which is why we group in 4. This works as 16 = 2^4.)

So:


0000 00|01 000|0 1001| 0100 0|000 0010 0001

=

0 1 0 9 4 0 2 1


in hex.

Sorry if this is more or less than you wanted to know, and HTH.

EDIT:

Man, UBB is retarded. The ONE UBB tag that allows the equiv of the HTML "PRE" tag, which is often used to display FIXED WIDTH things, includes a font command to use Verdana or Arial, both VARIABLE width fonts. Try looking at the stuff in the CODE tags in fixed width, it looks clear then. Just hit edit to look at it in the message edit window, then you will see it fixed width.

[This message has been edited by Paul V (edited 03-28-2000).]