Question: Write an Pentium NASM assembly language program to locate a character in a string. Read a random string and a character from the input in

Write an Pentium NASM assembly language program to locate a character in a string.

Read a random string and a character from the input in a main procedure. Use the other procedure to determine if there is such a character in the string. The procedure return yes or no to the main procedure and the main procedure display the result.

pass the parameters using a register.

pass the parameters using the stack.

This is my code:

BUF_LEN EQU 41

%include "io.mac"

.STACK 200H

.DATA

PROMPT_MSG DB "ENTER AN STRING:- ",0

CHAR_MSG DB "ENTER ANY CHARACTER :- ",0

NF_MSG DB "NO, CHARACTER FOUND IN THE GIVEN STRING"

YES_MSG DB "YES. CHARACTER FOUND IN THE GIVEN STRING "

COUNT DB 0

.UPDATA

String RESB BUF_LEN

.CODE

.STARTUP

PutStr PROMPT_MSG

GetStr String,BUF_LEN

mov EBX, String

mov AX,COUNT

PutStr CHAR_MSG

GetCh AL

call check

done:

.EXIT

check:

push EBX

Push AL

push AX

yes_no:

mov SI,[EBX]

cmp AL,[SI]

jne NotFound

inc AX

skip:

inc SI

jmp check

cmp AX,0

je NotFound

mov DL,AX

inc DL

jmp check_done

check_done:

PutStr YES_MSG

PutInt DL

pop EBX

pop AL

leave

ret

NotFound:

PutStr NF_MSG

jmp done

when I run it, DOSBOX showed there are many errors but I couldnot find out them, please check and fix it to me, thank you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!