MEMORY ADDRESS | MNEMONICS | COMMENTS |
3000 | LDA 3050 |
|
3003 | MOV H, A | A -> H |
3004 | LDA 3051 | A<-[2051] |
3007 | ADD H | A + H -> A |
3006 | MOV L, A | A -> L |
3007 | MVI A 00 | 00 -> A |
3009 | ADC A | A+A+carry -> A |
300A | MOV H, A | A -> H |
300B | SHLD 4050 | H→4051, L→4050 |
300E | HLT |
|
Mnemonics | Operand | Comments |
LXI H, | 3502 H | Get address of 2nd no. in H-L pair. |
MVI A, | 99 | Place 99 in accumulator. |
SUB | M | 9’s compliment of 2nd no. |
INR | A | 10’s compliment of 2nd no. |
DCX | H | Get address of 1st no. |
ADD | M | Add 1st no. & 10’s compliment 2nd no. |
DAA |
| Decimal Adjustment. |
STA | 3503 H | Store result in 3503 H. |
HLT
|
| Stop the program. |
…. | … |
5000H | CD |
5001H | AB |
5002H | 2D |
5003H | FE |
… | …. |
Labels | Mnemonics | Operand | Comments |
| LXI H, | 5000H | Point to LSB of first operand |
| LXI D, | 5002H | Point to LSB of second address |
| LDAX | D | Load Acc with content pointed by DE |
| ADD | M | Add memory element pointed by HL with Acc |
| MOV C, | A | Store LSB result at C |
| INX | H | Point to next byte of first operand |
| INX | D | Point to next byte of second operand |
| LDAX | D | Load Acc with content pointed by DE |
| ADC | M | Add memory element pointed by HL with Acc+ Carry |
| MOV B, | A | Store the MSB at B |
| MOV H, | B | Move B to H |
| MOV L, | C | Move C to L |
| SHLD | 5050H | Store the result at 5050H and 5051H |
| JNC | DONE | Skip to end |
| MVI A, | 01H | Load 1 to Acc |
| STA | 5052H | Store Acc content into 5052H |
DONE: | HLT |
| Stop the program. |
Labels | Mnemonics | Operand | Comments |
| LXI H, | 5000H | Address for count in H-L pair |
| MOV C, | M | Count in C register |
| INX | H | Address for 1st no. |
| MOV A, | M | 1st no. sent to the accumulator |
| DCR | C | Decrement count |
LOOP: | INX | H | Address of next no. |
| CMP | M | Compare next no. |
| JC | AHEAD | If no, get smaller no. in accumulator go to AHEAD |
| MOV A, | M | get smaller no. in accumulator |
AHEAD: | DCR | C | Decrement count |
| JNZ | LOOP |
|
| STA | 4000H | Store in 4000H |
| HLT |
| Stop program |
Labels | Mnemonics | Operand | Comments |
| LXI H, | 5000H | Address for count in H-L pair |
| MOV C, | M | Count in C register |
| INX | H | Address for 1st no. |
| MOV A, | M | 1st no. sent to the accumulator |
| DCR | C | Decrement count |
LOOP: | INX | H | Address of next no. |
| CMP | M | Compare next no. |
| JNC | AHEAD | If no, go to AHEAD |
| MOV A, | M | Or get larger no. in accumulator |
AHEAD: | DCR | C | Decrement count |
| JNC | LOOP |
|
| STA | 4000H | Store in 4000H |
| HLT |
| Stop program |
Labels | Mnemonics | Operand | Comments |
| MVI B, | FFH | 7 T states required |
LOOP: | DCR | B | 4 T states required and will be executed 255 (FF) times |
| JNZ | LOOP | 10 T states required when it jumps (It jumps 254 times), otherwise it take 7 T-States |
| RET |
| 10 T states required |
Labels | Mnemonics | Operand | Comments |
| LXI B, | FFFFH | 10 T states required |
LOOP: | DCX | B | 6 T states required |
| MOV A, | B | 4 T states required |
| ORA | C | 4 T states required |
| JNZ | LOOP | 10 T states required when it jumps, otherwise it take 7 T-States |
| RET |
| 10 T states required |
LXI SP, xx99H | Load SP register with address xx99 |
PUSH H | It copies content of register pair (HL) on stack [H:xx98,L:xx97]. The SP register is decremented each time [SP = xx97] |
PUSH B | It copies content of register pair (BC) on stack [B:xx96, C:xx95] The SP register is decremented each time [SP = xx95] |
PUSH PSW | It is program status word which means content of A and F [A:xx94, F: xx93]. The SP register is decremented each time [SPxx93] |
POP H | It copies content of top 2 memory locations to HL. [H: xx94, L: xx93]. The SP is incremented each time [SP: xx95] |
POP B | It copies content of top 2 memory locations to HL. [H: xx95, L: xx96]. The SP is incremented each time [SP: xx97] |
POP PSW | It is program status word which means content of A and F [A: xx98, F: xx97]. The SP register is incremented each time [SP: xx99] |
Memory location | Instruction |
2000H | LX SP, 2300H |
2040H | CALL 2070H |
2043H | Next Instruction |