Computer Science, asked by patilswastik2004, 2 days ago

Write an assembly language program to count the occurrence of data 05H in a memory block starting from 4000H to 4004H .Store the result at 4070H.

Answers

Answered by puspitapanda27
0

Explanation:

assemble language programs

Attachments:
Answered by Tulsi4890
0

Here's an assembly language program to count the occurrence of data 05H in a memory block starting from 4000H to 4004H and store the result at 4070H:

ORG 0000H ; Start at address 0000H

MOV CX, 0005H ; Initialize the counter to 5

MOV BX, 4000H ; Set the starting address to 4000H

MOV DI, 4070H ; Set the address to store the result to 4070H

LOOP1:

CMP CX, 0 ; Check if the counter has reached 0

JE END ; If so, exit the loop

MOV AL, [BX] ; Load the value at the current address into AL

CMP AL, 05H ; Check if the value is equal to 05H

JNE NEXT ; If not, skip to the next address

INC BYTE PTR [DI] ; If so, increment the count at 4070H

NEXT:

INC BX ; Increment the address pointer

DEC CX ; Decrement the counter

JMP LOOP1 ; Jump back to the beginning of the loop

END:

HLT ; Halt the program

  • Set the initial values of CX, BX, and DI registers to 0005H, 4000H, and 4070H, respectively.
  • Start a loop that iterates through each memory address between 4000H and 4004H.
  • Check if the value at the current address is equal to 05H.
  • If the value is equal to 05H, increment the value stored at address 4070H.
  • Move to the next address and continue the loop until all five addresses have been checked.
  • Halt the program once the loop is complete.
  • This program will count the occurrence of data 05H in a memory block starting from 4000H to 4004H and store the result at 4070H.

To learn more about assembly language from the given link.

https://brainly.in/question/24470006

#SPJ3

Similar questions