Table 1.1 is an example of DEC PDP-10 assembler language, a function that returns the largest integer in a group of them, named NUMARY. The group contains NCOUNT elements.
| Label | OpCode | Register | Memory Address |
Index Register |
Comment |
| GETMAX: | MOVSI | T1 | 400000 | ; init T1 to smallest integer | |
| MOVE | T2 | NCOUNT | ; get number of array elements | ||
| GTMAX2: | SOJL | T2 | [POPJ P,] | ; decr idx, if -1 then done | |
| CAMG | T1 | NUMARY | (T2) | ; skip if T1 > array element | |
| JRST | GTMAX2 | ; continue with next number | |||
| MOVE | T1 | NUMARY | (T2) | ; T1 gets new max number | |
| JRST | GTMAX2 | ; continue with next number | |||
|
|
|||||
I'm showing you this so that you will have a feel for how primitive computer instruction sets are. I'm not going to go into the details of every instruction. If you want to go through it in detail on your own, the PDP-10 Machine Language is detailed here.
A few points I want to expose you to are the general kinds of things being done.
- moving objects (numbers) into the computer's registers - very fast temporary storage,
- decrementing the value in a register,
- comparing the contents of a register to some value in memory, and
- transfering control to an instruction that's not in the standard sequential order - down the page.
But there is a problem with assembler language - it is unique for every computer architecture. Although most deskside and notebook computers these days use the Intel architecture, this is only recently the case. And... a variety of computer architectures are commonly used in game systems, smart phones, tablets, automobiles, appliances, etc...
Ok, we are almost at a point where I can show you machine language, the *native* language of a computer. But for you to understand it, I'm going to have to explain how everything is represented in a computer.
Ei kommentteja:
Lähetä kommentti