GAme

tiistai 26. kesäkuuta 2012

Programming Languages (Assembler Language)

One step above a computer's native language is assembler language.  In an assembler language, everything is given human-friendly symbolic names.  The programmer works with operations that the microprocessor knows how to do, they have symbolic names.  The microprocessor's registers and addresses in the computer's memory can also be given meaningful names by the programmer.  This is actually a very big step over what a computer understands, but still tedious for writing a large program.  Assembler language instructions still have a place for little snipits of software that need to interact directly with the microprocessor and/or those that are executed many, many, many times.
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
Table 1.1

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.
  1. moving objects (numbers) into the computer's registers - very fast temporary storage,
  2. decrementing the value in a register,
  3. comparing the contents of a register to some value in memory, and
  4. transfering control to an instruction that's not in the standard sequential order - down the page.
So, as you've seen, higher-level programming languages provide similar functionality and in a form that is closer to the English language. 
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