Professional Documents
Culture Documents
Assignment 2
Question 1
Code:
XRA A // clear the accumulator
ADI 47H
SUI 92H
ADI 64H
STA 0020H // store answer in memory location 0020H
HLT
HLT 5 Halt
Flag Register:
Value S Z AC P CY
0100 0111 0 0 0 0 1
HLT 5 Halt
Flag Register:
Value S Z AC P CY
0000 1000 0 0 1 0 0
HLT 5 Halt
Flag Register:
Value S Z AC P CY
0000 1000 0 0 0 0 0
Question 4
Code:
LHLD 0010H // load X1 and X2 from addresses 0010H and 0011H into H and L MOV
A,H //move X2 to A
ORA L // X1 or X2
CMA //gives X1 nor X2
MOV B,A //store nor result in B
LHLD 0020H //load X3 and X4 from addresses 0020H and 0021H into H and L MOV
A,H //move X4 to accumulator
ANA L //X3 and X4
CMA //gives X3 nand X4
ORA B //(X1 nor X2) or (X3 nand X4)
STA 2100H //store result in 2100H
HLT
HLT 5 Halt
Flag Register:
Value S Z AC P CY
1100 1011 1 0 0 0 0
Question 5
Code:
LXI B,1040H // load B & C with 1040H (16-Bit)
LXI D,2311H // load D & E with 2311H (16-Bit)
MOV A,C // move contents of C into A
ADD E // add contents of E with A
MOV H,A // move contents of A into H
MOV A,B // move contents of B into A
ADC D // adding A and D with prev carry
MOV L,A // move contents of A into L
SHLD 511F // store content from H & L registers at 511FH
HLT
HLT 5 Halt
Flag Register:
Value S Z AC P CY
0011 0011 0 0 0 1 0
Question 6(a)
Code:
MVI B,00H // A=00H is stored in reg B
MVI C,01H // B=01H is stored in reg C
MVI D,01H // C=01H is stored in reg D
MOV A,B // move contents of reg B into A
ANA C // AND operator with contents of reg C and A
MOV E,A // store contents of A in reg E
MOV A,C // move contents of reg C into A
ANA D // AND operator with contents of reg D and A
CMA // NOT operator on contents of A
ORA E // OR perator with contents of reg E and A
STA 2100H // store contents of A at 2100H
HLT
HLT 5 Halt
Flag Register:
Value S Z AC P CY
0000 0000 0 1 0 1 0
Question 6(b)
Code:
MVI B,00H // A=00H is stored in reg B
MVI C,01H // B=01H is stored in reg C
MVI D,01H // C=01H is stored in reg D
MOV A,B // move contents of reg B into A
ANA C // AND operator with contents of reg C and A
MOV E,A // store contents of A in reg E
MOV A,B // move contents of reg C into A
ORA C // OR perator with contents of reg C and A
ANA D // AND operator with contents of reg D and A
ORA E // OR perator with contents of reg E and A
STA 2100H // store contents of A at 2100H
HLT
HLT 5 Halt
Flag Register:
Value S Z AC P CY
0000 0001 0 0 0 0 0
Question 7
Code:
LDA 0100H //8-bit data at 0100H is loaded into accumulator
MOV B,A // move contents of A into reg B
ANI F0H //masking lower order bits (D7D6D5D40000)
RRC
RRC // right rotating twice for (00D7D6D5D400)
MOV C,A //store contents of A at reg C
MOV A,B // move contents of reg B into A
ANI 0FH //masking higher order bits (0000D3D2D1D0 )
RRC
RRC //right rotating twice for (D1D00000D3D2 )
MOV D,A //store contents of A at reg D
ANI F0H //masking lower order bits (D1D0000000)
RRC
RRC //right rotating twice for (00D1D00000)
MOV E,A //store contents of A at reg E
MOV A,D // move contents of reg D into A
ANI 0FH //masking higher order bits (000000D3D2 )
RLC
RLC // left rotating twice for (0000D3D200)
ORA E // Contents of reg E OR contents of A = (00D1D0D3D200)
ANA C // Contents of reg C OR contents of A = (00D7.D1D6.D0D5.D3D4.D200)
STA 2100H
HLT
HLT 5 Halt
Flag Register:
For 8-bit input B5H (1011 0101), output bit sequence is 04H (0000 0100).
Value S Z AC P CY
0000 0100 0 0 1 0 0