A block of data is stored in memory location starting from C040 H. Length of the block
Fantastic news! We've Found the answer you've been seeking!
Question:
A block of data is stored in memory location starting from C040 H. Length of the block is stored in register B. Write an Assembly language program to find the number of times (COUNT) the data AB H occurred from the given block of data and store the result at the end of the block.
What will be the output after execution of the following block of code?
What will be contents of the registers - A, B, C and the flags register, F?
S | Z | X | AC | X | P | X | CY |
Memory Location | Op-Code | Labels | Mnemonics | Comments |
C000 H | LXI H, C040H | ;Initialize the register pair HL to memory location C040 H | ||
C001 H | 40 | |||
C002 H | C0 | |||
C003 H | MVI A, AB H | ;Load the data AB H to accumulator | ||
C004 H | AB | |||
C005 H | MVI B, 05 H | ;Set the counter for 05 numbers in register B | ||
C006 H | 05 | |||
C007 H | MVI C, 00 H | ;Clear the data content of register C | ||
C008 H | 00 | |||
C009 H | UP: | CMP M | ;Compare content of memory pointed by HL register pair with the data content of accumulator | |
C00A H | JNZ DOWN: | ;If Zero flag is reset (Z= 0) then jump to memory location C00EH | ||
C00B H | 0E | |||
C00C H | C0 | |||
C00D H | INR C | ;Increment the data content of register C by 1 | ||
C00E H | DOWN: | INX H | ;Increment HL register pair by 1 | |
C00F H | DCR B | ;Decrement the counter by 1 | ||
C010 H | JNZ UP: | ;If counter 0 (reg. B 0 )then jump to memory location C009H. | ||
C011 H | 09 | |||
C012 H | C0 | |||
C013 H | MOV M, C | ;Copy the data content of register C to memory location pointed by HL register pair | ||
C014 H | RST 1 | ;Stop the execution |
Related Book For
Posted Date: