learnign assembly notes 1

learning assembly notes 1

Computer is a complex machine so we should divide small parts:

  • Transistors
  • Gates
  • CPU, memory, I/O Devices
  • Compuer System

languages

Hll = High Level Language that people can understand
Lll = Low Level Language that people can not understand

Fortran, C (hll)-> Machine Language(lll) -> Computer hardware

Machine Language = Not human readable (Binary) computer instructions to execute programs or services.

So lets talk about Assembly Language:
+ More human readable form of machine language
+ Low level programming language
+ But also we need to convert this code to Machine Language so we need ASSEMBLER

Complete picture:

         -----------                  ------------
HLL ---> | compiler|---> assembly --->| assembler|--->machine
         -----------     language     ------------    language

(least detailed) (most detailed)
(top level) (bottom level)

(taken from: http://pages.cs.wisc.edu/~smoler/x86text/lect.notes/basics.html)

about computer architecture

                        | ------------- CPU
                        | 
computer        ------- |-------------- Memory
                        |
                        |-------------- I/O 
  • Cpu is the most important part of all computer arch. System controlled by cpu
    • executes instructions
    • makes requests of the memory

how to control cpu

  • alu: (arithmetic and logic unit) which performs arithmetic and logic.
  • registers: to hold variables
  • interconnections : (internal busses)

The state includes the user visible general purpose registers, as well as theProgram Counter (PC: it contains the address of the next instruction to beexecuted), theInterrupt Address Register (IAR: contains the address ofthe instruction being suspended), and aProgram Status Register (PSR:this usually holds the status flags for the machine, like condition codes,masks for interrupts, etc.).

CPU         Memory          I/O
 |             |             |   
 |             |             |
 |-------------|-------------|
 ----------------------------- BUS

interaction between processor and memory

to execute an instruction, the processor must be able to request 3 things from memory:

1. instruction                     FETCH
2. operand (variable) load         LOAD
3. operand (variable) store        STORE


the memory needs 2 operations

1. read   (fetch or load)
2. write  (store)


where?       a label specifies a unique place (a location) in memory.
     a label is often identified as an address.


read:   CPU specifies an address and a read operation
    memory responds with the contents of the given address

write:  CPU specifies an address, data to be stored, and
    a write operation
    memory responds by overwriting the data at the
    address specified

instructions and operands are stored in memory.before they can be used by the processor, they must be fetched/loaded