Flowchart Prog Exercise2
Flowchart Prog Exercise2
1. a) Addition
4201 Carry
C Carry
MOV A,M
Load operand 1 into [A]. INX H
Load operand 2 into [B]. MOV B,M
NO JNC SKIP
Any carry?
YES
SKIP: STAX D
Store results in INX D
End.
memory. MOV A,C
STAX D
RST 1
b) Subtraction
4201 Carry
C Borrow
MOV A,M
Load operand 1 into [A]. INX H
Load operand 2 into [B]. MOV B,M
NO JNC SKIP
Any borrow?
YES
SKIP: STAX D
Store results in INX D
End.
memory. MOV A,C
STAX D
RST 1
c) Multiplication
MOV B,M
Load operand 1 (multiplicand) into [B]. INX H
Load operand 2 (multiplier) into [C]. MOV C,M
NO JNC SKIP
Any carry?
YES
JNZ REPEAT
Multiplier = 0?
NO
LXI H,4200H
YES MOV M,A
INX H
Store results in memory. End. MOV M,E
RST 1
d) Division
MOV A,M
Load operand 1 (dividend) into [A]. INX H
Load operand 2 (divisor) into [B]. MOV B,M
YES JC STORE
[A] < [B]?
NO
NO JNC REPEAT
[A] < [B]?
YES
Process:
Checks input for even parity. If the input has even parity, parity bit = 0. If
input has odd parity, parity bit = 1. The parity bit is the MSB of the 8 bit
output.
Example:
Input: R = 52H = 101 0010B (odd parity)
Output: 1101 0010B (even parity)
Set counter.
Set pointer to LXI H, 5000H
data in memory MVI C, count
NO
Even parity? Insert ‘1’ at MSB.
Transfer value back.
YES
ADI 80H
MOV M,A
Set pointer to next
SKIP: INX H data.
NO YES
Counter = 0?
End. RST 1
Even parity checker at the receiving end
Process:
Check each data to confirm that it has even parity. If all data has even parity,
store ‘ACK’. If any one of the data has odd parity, an error has occurred and
‘NAK’ is stored.
YES
Odd parity? Store ‘NAK’
DCR C
Decrement counter. JNZ NXTCHECK
NO YES
Counter = 0? Store ‘ACK’
MVI A,ACK
STA 8800H
End. RST 1