Computer Architecture O 06 Programming the Basic Computer
Computer Architecture O 06 Programming the Basic Computer
Computer
Computer Architecture
and Organization
INTRODUCTION
2
INTRODUCTION…
3
Symbol Hex Code Description
Memory-reference AND 0xxx 8xxx And memory word to AC
instruction ADD 1xxx 9xxx Add memory word to AC
LDA 2xxx Axxx Load memory word to AC
STA 3xxx Bxxx Store content of AC in memor
BUN 4xxx Cxxx Branch unconditionally
BSA 5xxx Dxxx Branch and Save return addre
ISZ 6xxx Exxx Increment and skip if zero
CLA 7800 Clear AC
CLE 7400 Clear E
Register -reference CMA 7200 Complement AC
instruction CME 7100 Complement E
CIR 7080 Circulate right AC and E
CIL 7040 Circulate left AC and E
INC 7020 Increment AC
SPA 7010 Skip next instruction if AC pos
SNA 7008 Skip next instruction if AC neg
SZA 7004 Skip next instruction if AC zero
SZE 7002 Skip next instruction if E is 0
HLT 7001 Halt computer
Memory-reference INP F800 Input character to AC
instruction OUT F400 Output character from AC
SKI F200 Skip on input flag
SKO F100 Skip on output flag
ION F080 Interrupt On
IOF F040 Interrupt Off 4
MACHINE LANGUAGE
5
MACHINE LANGUAGE…
3. Symbolic Code :( Assembly Language )
✓ The user employ symbols for operation part, the address part,
and other parts of the instruction
✓ Each symbolic instruction can be translated to binary coded
instruction
✓ This translation is done by a special program called assembler.
4. High Level Language
✓ The program is written in a sequence of statements in forms that
people prefer to think when solving a problem.
✓ These statements translated to binary code by compiler.
✓ Machine language is a program that is written in a binary format.
6
COMPARISON OF PROGRAMMING
LANGUAGES
▪ The program is to add two numbers (C = A + B )
▪ The first column is memory location and the second indicate the
content of each location.
▪ The program is stored in the indicated portion of memory as
shown in table. a. and, the execution is beginning from address 0.
▪ However, for people this program is difficult to understand what
the program is.
Table A: Binary Program to Add Two Numbers
7
COMPARISON OF PROGRAMMING
LANGUAGES…
▪ But, writing in binary is tedious.
▪ We reduce the number of digits if we write the hexadecimal
equivalent to binary code(shown in Table B)
▪ But, it must be converted to binary code to be executed by a
computer.
Table B: Hexadecimal Program to Add Two Numbers
8
COMPARISON OF PROGRAMMING
LANGUAGES…
▪ The program is written in symbolic instead of binary and
hexadecimal code(Symbolic programs is shown in Table C)
▪ The address part of MRI as well as, operands, remain in their
hexadecimal . Comments are to explain the function of each
instruction.
▪ Symbolic programs are easier to handle, and it is preferable to
write programs with symbols
▪ This symbols also has to converted to binary to be executed by a
computer. Table C: Program with Symbolic Operation Codes
9
COMPARISON OF PROGRAMMING
LANGUAGES…
▪ A program in Table D is the assembly-language program for
adding two numbers.
▪ The ORG is not a machine instruction and it is to specify an
origin, that is, the memory location of the next instr. below it.
▪ The next three lines have symbolic addresses and, their values
are specified by their being present as a label in the first column.
▪ Decimal operands are specified following the symbol DEC.
▪ The symbol END indicating that the end of the prog.
Table D: Assembly Language Program to Add Two Numbers
10
COMPARISON OF PROGRAMMING
LANGUAGES…
▪ The equivalent Fortran program is shown as below.
11
ASSEMBLY LANGUAGE
▪ A programming language is defined by a set of rules.
17
ASSEMBLY LANGUAGE…
Example: Assembly language program to subtract two
numbers
▪ When the two part assembled, we obtain the hexadecimal code 2107
19
TRANSLATION TO BINARY CODE…
▪ The other lines also translated in similar fashion and
their hexadecimal code is listed below
20
ADDRESS SYMBOL TABLE
▪ The translation process can be simplified if we scan the entire
symbolic program twice and, no translation is done during the first
scan
▪ We assign a memory location to each machine instruction and
operand.
▪ The location assignment will defined the address value of labels and
facilitate the translation process during the second scan
▪ In above table, we assign 100 to the first instruction after ORG.
▪ We then assign sequential location for each lines of code until END .
▪ ORG and END are not assigned a numerical location b/c they do not
represent an instruction or an operand.
▪ When the first scan is completed, we associated with each label its
location number and form a table that defines the hexadecimal value
of each symbolic address.
21
ADDRESS SYMBOL TABLE
▪ For this program, the address symbol table is shown as below