COA-Unit 3 ppt
COA-Unit 3 ppt
Register-reference Instruction
15 14 12 11 0
0 1 1 1 Register Operation
Input-Output Instruction
15 14 12 11 0
1 1 1 1 I/O Operation
Memory-reference Instructions
15 14 12 11 0
I Opcode Address
Memory
Symbol Hex code
word
1 PL 50 4C
2 3, 33 2C
3 LD 4C 44
4 A 41 20
5 SU 53 55
6 B 42 20
7 I CR 49 0D
Conti…
• Each symbol is terminated by the code for space (0x20) except last, which is
terminated by the code of carriage return (0x0D).
• If a line of code has a comment, the assembler recognizes it from code 0x2F
(slash): assembler ignores all characters in the comment field and keeps checking
for a CR code.
• The input for the assembler program is the user’s symbolic language
• program in ASCII.
• The binary program is the output generated by the assembler.
First Pass of an assembler
First pass
LC ← 0
Increment LC
Second pass
Second Pass
LC ← 0
of an
Scan next line of code Set LC Done
Yes Yes
assembler
Pseudo- Yes No
ORG END
instruction
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
Specification of Program
Multiplication of 8-bit positive numbers
8-bit x 8-bit = 16-bit Result
Ex: 0000 1111 (15) x 0000 1011 (11)
00001111 x (00000001 + 00000010 + 00001000)
= 00001111 + 00001111 x 2 + 00001111 x 8
= 00001111 + 00001111 << 1 + 00001111 << 3
= 00001111 + 00011110 + 01111000
= 10100101
Multiplication can be implemented with SHIFT
and ADD instructions
CTR - 8
P0 Example with four significant digits
E0
P
AC Y X= 0000 1111
Y= 0000 1011 0000 0000 X holds the multiplicand
0000 1111 0000 1111 Y holds the multiplier
cir EAC
0001 1110 0010 1101 P holds the product
0000 0000 0010 1101
Y AC 0111 1000 1010 0101
1010 0101
=0 =1
E
PP+X
E0
AC X
cil EAC
cil
X AC
CTR CTR + 1
0 =0
CTR Stop
A.L.P. to Multiplication program
ORG 100
LOP, CLE E0 E0 E0
LDA Y AC000B AC0005 AC0002
CIR E1, AC0005 E1, AC0002 E0, AC0001
STA Y Y0005 Y0002 Y0002
SZE
BUN ONE PCONE PCONE
BUN ZRO PCZRO
ONE, LDA X AC000F AC001E
ADD P AC000F+0 AC001E+000F
STA P PAC PAC
CLE E0 E0
ZRO, LDA X AC000F AC001E AC003C
CIL E0, AC001E E0, AC003C E0, AC0078
STA X XAC XAC XAC
ISZ CTR CTR1-8 CTR1-7 CTR1-6
BUN LOP PCLOP PCLOP PCLOP
HLT
CTR, DEC -8 -7 -6 -5
X, HEX 000F 001E 003C 0078
Y, HEX 000B 0005 0002 0001
P, HEX 0 000F 002D 002D
END
A.L.P. to Add Two Double-Precision Numbers
o Double Precision
o A number stored in Two memory word
o Used for great accuracy
o Ex: 00F0FF0F + 00FF00FF = 01F0000E
o Double-precision addition: addition of two 32-bit unsigned integers.
o Added numbers place in two consecutive memory
o locations, AL and AH, and BL and BH.
o Sum is stored in CL and CH:
A.L.P. to Add Two Double-Precision Numbers
00F0FF0F + 00FF00FF = 01F0000E
AL = 1111 1111 0000 1111 (FF0F)
AH = 0000 0000 1111 0000 (00F0)
BL = 0000 0000 1111 1111 (00FF)
BH = 0000 0000 1111 1111 (00FF)
CL = AL+ BL = 1 0000 0000 0000 1110 (1000E)
CL = 0000 0000 0000 1110 (000E)
Carry = 0000 0000 0000 0001 (0001)
AH = 0000 0000 1111 0000 (00F0)
AH+ Carry = 0000 0000 1111 0001 (00F1)
BH = 0000 0000 1111 1111 (00FF)
CH = AH+ carry+ BH = 0000 0001 1111 0000 (01F0)
CH & CL = 01F0 000E
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
Logic Operations
LDA A /ACA
CMA /ACA’
STA TMP /TMPA’
LDA B /ACB
CMA /ACB’
AND TMP /ACB’&A’
CMA /AC(B’&A’)’
Shift Operations
AC
• Second char: N
o Programmed IO
o Most of CPU time is spent at checking IF or OF
o Loss of CPU time
o Easy to Implement
o Interrupt
o CPU request I/O to device
o CPU goes to do Other jobs
o Device Interrupt CPU when I/O operation is Done
o CPU performs Interrupt Service Routine
Interrupt Service Routine
o Interrupt Occurs
o for Interrupt cycle
o IEN0, (0)PC, PC1
o Save Contents of processor registers
o Basic Computer has AC and E registers
o Check which Flag is Set
o IF(FGI) and OF(FGO) Flag
o Priority of Interrupt: Which is serviced first?
o Service the device whose flag is set
o Restore Contents of processor registers
o Turn the Interrupt facility On
o IEN1, for Next interrupt
o Return to the running program
0 ZRO, HEX 0
Ex: ISR 1
…
BUN SRV