Problem – Calculate the sum of series of even numbers from the given list of numbers. The length of the list is in memory location 2200H and the series begins from memory location 2201H. Result will store at memory location 2210H.
Input : 2200H= 4H 2201H= 20H 2202H= l5H 2203H= l3H 2204H= 22H Output : Result 2210H = 42H
|LDA||2200H||[A] <- 2200H|
|MOV||C, A||Initialize counter|
|MVI||B, 00H||sum = 0|
|LXI||H, 2201H||Initialize pointer|
|BACK:||MOV A, M||Get the number|
|ANI||0lH||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|
|JNZ||BACK||if counter 0 repeat|
|MOV||A, B||Store result in A register|
|HLT||Terminate program execution|
A microprocessor is a computer processor that incorporates the functions of a central processing unit on a single integrated circuit.
- A is an 8-bit accumulator which is used to load and store the data directly.
- LDA is used to load accumulator direct using 16-bit address (3 Byte instruction).
- Instructions like MOV, MVI, LDA are the data transfer instructions.
- ADD is used to add data.
- HLT is used to halt the program.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.