Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 10

Dep’t Of ECENG Comparc PPt

Chap. 3 For 3rd Year Students


Compiled By Instructors.
part 3
Programming the Basic Computer
 Introduction

 25 Instruction Set of the basic computer


 Memory Reference Instruction Symbol Hex Code Description
AND 0xxx 8xxx And memory word to AC
 Register Reference Instruction ADD 1xxx 9xxx Add memory word to AC
LDA 2xxx Axxx Load memory word to AC
 Input-output Instruction
STA 3xxx Bxxx Store content of AC in memory
BUN 4xxx Cxxx Branch unconditionally
BSA 5xxx Dxxx Branch and Save return address
ISZ 6xxx Exxx Increment and skip if zero
 Machine Language CLA
CLE
7800
7400
Clear AC
Clear E
CMA 7200 Complement AC
 Program Categories m CME e 7100 Comp
 1) Binary Code(Machine Language) CIR 7080 Circulate right AC and E
CIL 7040 Circulate left AC and E
 2) Octal or Hexadecimal Code INC 7020 Increment AC
SPA 7010 Skip next instruction if AC positive
 3) Symbolic Code SNA 7008 Skip next instruction if AC negative
SZA 7004 Skip next instruction if AC zero
» Assembly Language SZE 7002 Skip next instruction if E is 0
 4) High Level Language HLT 7001 Halt computer
INP F800 Input character to AC
» C, C++, Java and Fortran OUT F400 Output character from AC
SKI F200 Skip on input flag
SKO F100 Skip on output flag
ION F080 Interrup
IOF F040 Inter
Machine Language Dep’t Of ECENG Comparc PPt
For 3rd Year Students
Compiled By Instructors.

 Program: is a list of instructions that direct the


computer to perform a data processing task.
 Many programming languages (C++, JAVA).
However, the computer executes programs when
they are represented internally in binary form.
 Binary code: a binary representation of
instructions and operands as they appear in
computer memory.
 Octal or hexadecimal code: translation of binary
code to octal or hexadecimal representation.
 symbolic code  binary coded instruction
 The translation is done by a special program
called an assembler.
Dep’t Of ECENG Comparc PPt
The Assembler For 3rd Year Students
Compiled By Instructors.

 An Assembler is a program that accepts a


symbolic language and produces its binary
machine language equivalent.
 The input symbolic program :Source program.
 The resulting binary program: Object program.
Dep’t Of ECENG Comparc PPt

Pseudo instruction For 3rd Year Students


Compiled By Instructors.
 Not a machine instruction
 It is an instruction to the assembler giving information about some
phase of the translation

Ex:
ORG N
Hexadecimal number N is the memory loc. for the instruction or
operand listed in the following line
END
Denotes the end of symbolic program
DEC N
Signed decimal number N to be converted to binary
HEX N
Hexadecimal number N to be converted to binary
MIN = 106, SUB = 107, DIF = 108
Dep’t Of ECENG Comparc PPt
For 3rd Year Students
Compiled By Instructors.
Dep’t Of ECENG Comparc PPt
For 3rd Year Students
Compiled By Instructors.

 Assembly Language
 The rules for writing assembly language program Field
Each line of an assembly language program is arranged in three columns
» 1) Label field :may be empty or it may specify symbolic address.
» 2) Instruction field : machine instruction or pseudo instruction. Label Instruction Comment
» 3) Comment field : may be empty or it may include comment.
 Symbolic Address(Label field)
» One, two, or three, but not more than three alphanumeric characters
» The first character must be a letter; the next two may be letters or numerals
» A symbolic address is terminated by a comma(recognized as a label by the assembler)
 Instruction Field
» 1) A memory-reference instruction(MRI)
 Ex) ADD OPR(direct address MRI), ADD PTR I(indirect address MRI)

» 2) A register-reference or input-output instruction(non-MRI)


 Ex) CLA(register-reference), INP(input-output)

» 3) A pseudo instruction with(ORG N) or with(END) an operand :


 Pseudo instruction is not a Machine Instruction but rather an instruction to the

assembler giving information about some phase of the instruction.


 Comment field
» Comment filed must be preceded by a slash(recognized by assembler as comment)
Dep’t Of ECENG Comparc PPt
For 3rd Year Students
Compiled By Instructors.

 An Example Program
 83 - 23 = 83 + ( 2’s Complement of -23)
Dep’t Of ECENG Comparc PPt
For 3rd Year Students
Compiled By Instructors.
Dep’t Of ECENG Comparc PPt
For 3rd Year Students
Compiled By Instructors.

 Programming Arithmetic & Logic Operations


 Hardware implementation
 Operations are implemented in a computer with one machine instruction
 Ex) ADD :
 Software implementation
 Operations are implemented by a set of instruction(Subroutine)
 Ex) MUL, DIV : CPU
 Multiplication Program
P=00000000
 Positive Number Multiplication +00001111
X=1111
» X = multiplicand P=00001111
Y=1011
Y = multiplier 1111 +00011110
P = Partial Product Sum 1111
0000 P=00101101
1111 +00000000
10100101 P=00101101
+01111000
P=10100101
r t 3
p a 3
d r
En hapte
d C
En

You might also like