Calculate the sum of series of even numbers
- LDA 2500H
- MOV C, A : "Initialize counter"
- MVI B, 00H : "sum = 0"
- LXI H, 2501H : "Initialize pointer"
- BACK: MOV A, M : "Get the number"
- ANI 01H : "Mask Bit l to Bit7"
- JNZ SKIP : "Don't add if number is ODD"
- MOV A, B : "Get the sum"
- ADD M : "SUM = SUM + data"
- MOV B, A : "Store result in B register"
- SKIP: INX H : "increment pointer"
- DCR C : "Decrement counter"
- JNZ BACK : "if counter 0 repeat"
- STA 2505H : "store sum"
- HLT : "Stop"
Comments
Post a Comment