Question

In: Computer Science

Write an assembly code the counts the number of accuracies of the byte AAh in memory...

Write an assembly code the counts the number of accuracies of the byte AAh in memory from address 120Ah to address 130Ah. You need to use a subroutine and call it 'COUNT' to do so. You also need to provide the count in BCD if it was less than 64h so that you need to include another subroutine called 'ToBCD' to do so.
assembly 8086

Solutions

Expert Solution

Greetings!!

Code:

;MAIN STARTS HERE

.CODE
MOV AX,@DATA
MOV DS,AX
  
CALL COUNT ;calling COUNT procedure to count the occurance of AA
  
HLT

;MAIN ENDS HERE

;procedure count definition
PROC COUNT NEAR
  
MOV AX,0 ;initialize AX with 0 for counting
MOV CX,100 ;load count into CX register[130A-120A=100].
MOV SI,120AH ;load the starting address into SI for reading the element from the memory
NEXT:
MOV BL,[SI] ;load the number into BL
INC SI ;point to next element in the memory
CMP AL,99H ;check the count less than 99
JNE CONTINUE ;if not 99 then continue   
CALL TOBCD ;if 99 call TOBCD procedure
CONTINUE:   
CMP BL,0AAH ;compare the number loaded from memory is AA or not
JNZ SKIP ;if not AA then skip
ADD AL,1 ;if AA, then increment the COUNT in AL
DAA ;adjust to BCD after each addition
SKIP:   
LOOP NEXT ;repeat the process
  
RET


;DEFINITION OF TOBCD FUNCTION   
PROC TOBCD NEAR

INC AH ;increment AH if the count in AL is 99
MOV AL,00 ;clear the AL count and start from 0 again
RET

Output screenshot:

Tested with more than 100 elements Iin an array and the count is shown below

Hope this helps


Related Solutions

Write an inline assembly program that initializes a 100 byte area of memory to 0xFF using...
Write an inline assembly program that initializes a 100 byte area of memory to 0xFF using the STOS instruction with REP using DWORD transfers.
Write an inline assembly program that initialized a 100 byte area of memory using the STOS...
Write an inline assembly program that initialized a 100 byte area of memory using the STOS instruction.
HCS12 Assembly Language: 1. Write a program to convert a decimal number stored at memory location...
HCS12 Assembly Language: 1. Write a program to convert a decimal number stored at memory location $1010 into a binary number. Store the result in memory location $2000
Please write a pep/9 assembly code that checks if a word or number is a palindrome
Please write a pep/9 assembly code that checks if a word or number is a palindrome
Assume a 222 byte memory: a. What are the lowest and highest addresses if memory is...
Assume a 222 byte memory: a. What are the lowest and highest addresses if memory is byte-addressable? b. What are the lowest and highest addresses if memory is word-addressable, assuming a 16-bit word? c. What are the lowest and highest addresses if memory is word-addressable, assuming a 32-bit word? Explain with Steps please
arduino c code only write a code that counts down a timer on serial monitor and...
arduino c code only write a code that counts down a timer on serial monitor and if A1 is typed into serial monitor prints the timer counting down and writes at 1 second hello and at 5 secs goodbye and repeats every 5 secs A2 is typed as above at 2 seconds writes hello and 3 seconds writes goodbye A3 same as above but at 3 seconds says hello and 2 seconds goodbye This continues until c is pressed to...
How to write fill.asm code (hack assembly)
How to write fill.asm code (hack assembly)
C code required * byteSwap - swaps the nth byte and the mth byte * Examples:...
C code required * byteSwap - swaps the nth byte and the mth byte * Examples: byteSwap(0x12345678, 1, 3) = 0x56341278 * byteSwap(0xDEADBEEF, 0, 2) = 0xDEEFBEAD * You may assume that 0 <= n <= 3, 0 <= m <= 3 * Legal ops: ! ~ & ^ | + << >> * Max ops: 25 * Rating: 2 */
Write an 8088/8086 assembly program that counts the length of a null terminated string that starts...
Write an 8088/8086 assembly program that counts the length of a null terminated string that starts at location STR.Assume string length will not exceed 255 character.Print the result on the screen?
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code that transmits a single character and lights the red LED upon receiving that character. The board will "talk" to itself. The green LED should turn on whenever a message is sent and the LCD will display the message being received.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT