Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to count the number of characters in a null-terminated ASCII str

ID: 3727041 • Letter: W

Question

Write a program to count the number of characters in a null-terminated ASCII string that are equal to a KEY. The
KEY is stored in memory location 0x0150. The string is stored in memory beginning at address 0x0160. Store the 8-bit count in
memory location 0x0154. (Assume the maximum count is 255.)

This is an intel 8086 assembly problem, there are many answers here that are all wrong, please don't use registers that are not in 8086 (EAX(32 bit) or RAX (64 bit)) Only use 16 bit registers, and please do it in Intel 8086.

Explanation / Answer

program:-

To count the numbers

DATA SEGMENT

STR1 DB "ABCDEFGHIJ"

STR2 DB "BDCDABCDEF"

CNT DB 0H

MSG1 DB 10,13,'FISRT STRING IN MEMORY IS : $'

MSG2 DB 10,13,'SECOND STRING IN MEMORY IS : $'

MSG3 DB 10,13,'COUNT OF SAME POSITION EQUAL CHAR(S) IS : $'

DATA ENDS

DISPLAY MACRO MSG

MOV AH,9

LEA DX,MSG

INT 21H

ENDM

CODE SEGMENT

ASSUME CS:CODE,DS:DATA

START:

MOV AX,DATA

MOV DS,AX

DISPLAY MSG1

DISPLAY STR1

DISPLAY MSG2

DISPLAY STR2

LEA SI,STR1

LEA DI,STR2

MOV CX,10

CHECK:

MOV AL,[SI]

CMP [DI],AL

JNE NOTEQU

INC CNT

NOTEQU: INC SI

INC DI

LOOP CHECK

DISPLAY MSG3

MOV DL,CNT

ADD DL,30H

MOV AH,2

INT 21H

MOV AH,4CH

INT 21H

CODE ENDS

END START

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote