Computer Organisation and Architecture
Computer Organisation and Architecture
(COA)
GTU # 3140707
Unit-3
Programming the Basic
Computer
LC ← 0
Increment LC
Second pass
Second Pass
LC ← 0
of an
Scan next line of code Set LC Done
Yes Yes
No EN
assembler
Pseudo- Yes OR
instruction G D
No
No
No DEC or HEX Convert
Yes MRI operand to
binary and
Get operation Valid non- store in
No
code and set MRI location
bits 2-4 instruction given by LC
There are four basics operation add, Subtract, multiply, and divide.
Operations that are implemented in a computer with one machine instruction are said to be
implemented by hardware.
Operation implemented by a set of instruction that constitute a program are said to be
implemented by software.
Software implementation results in long programs both in number of instruction and in
Execution time.
Double-Precision Addition
When two 16-bit unsigned numbers are multiplied, the result is a 32-bit product that must be
stored in two memory words. A number stored in two memory words is said to have double
precision.
A.L.P. to Add Two Double-Precision Numbers
1 ORG 100 /Origin of program is HEX 100
2 LDA AL /Load A low
3 ADD BL /Add B low, carry in E
4 STA CL /Store in C low
5 CLA /Clear AC
6 CIL /Circulate to bring carry into AC(16)
7 ADD AH /Add A high and carry
8 ADD BH /Add B high
9 STA CH /Store in C high
10 HLT /Halt
AL Location of Operands
AH
BL
BH
CL
CH
Logic Operations
The basic Computer has three machine instructions that perform logic operations:
AND, CMA, and CLA.
For Example
LDA A //Load first operand A
CMA //Complement to Get A
STA TMP // Store in a Temporary location
LDA B // Load Second operand B
CMA // Complement to Get B
AND TMP // AND operation of A and B
CMA // Complement of AND operation
Shift Operations
The logical Shift requires that zeroes be added to the extreme positions. This is easily
accomplished by clearing E(Extended clear to AC) and Circulating the AC and E.
Logical Shift – right operations we need the two instructions.
CLE
CIR
Logical Shift – left operation We need the two instructions
CLE
CIL
Subroutines
Subroutine with example
A set of common instructions that can
be used in a program many times is
called a subroutine. ORG 100
Each time that a subroutine is used in 100 LDA X 109 SH4, HEX 0
the main part of the program, a branch 101 BSA SH4 10A CIL
is executed to the beginning of the 102 STA X 10B CIL
subroutine. 103 LDA Y 10C CIL
After the subroutine has been executed, 104 BSA SH4 10D CIL
a branch is made back to the main 105 STA Y 10E AND MSK
program. 106 HLT 10F BUN SH4 I
A subroutine consists of a self 107 X, HEX 1234 110 MSK, HEX FFF0
contained sequence of instructions that 108 Y, HEX 4321 END
carries a given task.
Subroutine Parameters and
Data Linkage
I-O Programming
Section - 7
A.L.P. to input one character & output one character
Input Output
1 Program
ORG 100 /Origin of program is HEX 100 1 Program
ORG 100 /Origin of program is HEX 100
2 CIF, SKI /Check input flag 2 LDA CHR /Load character into AC
3 BUN CIF /Flag = 0, branch to check again 3 COF, SKO /Check output flag
4 INP /Flag = 1, input character 4 BUN COF /Flag = 0, branch to check again
5 OUT /Print character 5 OUT /Flag = 1, output character
6 STA CHR /Store character 6 HLT
7 HLT
7 CHR, HEX 0057 /Character is “W”
8 CHR, - /Store character here
8 END
9 END
Questions asked in CVMU
exam
Section - 8
Questions asked in CVMU exam
1. What is an Assembler? With clear flowcharts for first and second pass, explain its working.
2. Write an assembly language program to add 10 numbers from memory.
3. Write a brief note on: Subroutine call and return.
4. Write an ALP for multiplying 3 integers stored in register stack.
5. Write an assembly program to multiply two positive numbers.
6. What is machine language? How it differs from assembly language?
7. Define pseudo-instruction.
8. For the following C language code, write assembly language program:
int a, b, c;
a = 83; //plus 83
b = -23; //minus 23
c = a + b;