I need this in MASM Irvine 32 Assembly Language. Str_nextWord Procedure Write a
ID: 3868742 • Letter: I
Question
I need this in MASM Irvine 32 Assembly Language. Str_nextWord Procedure Write a procedure called Str_nextWord that scans a string for th first occurrence of a certain delimiter character and replaces the delimiter with a null byte. There are two input parameters: a pointer to the string and the delimiter character. After the call, if the delimiter was found, the Zero flag is set and EAX contains the offset of the next character beyond the delimiter. Otherwise, the Zero flag is clear and EAX is undefined. The following example code passes the address of target and a comma as the delimiter: .data target BYTE "Johnson, Calvin", 0 .code INVOKE Str_nextWord, ADDR target, ',' jnz notFound
Explanation / Answer
INCLUDE Irvine32.inc
.data
prompt byte "Please enter a string to manipulate : ",0
prompt2 byte "Please enter a character to remove: ",0
answerMSG byte "The new string is: ",0
string BYTE 51 DUP (0)
char BYTE ?
byteCount dword ?
.code
main PROC
call clrscr
push eax ;perserve the registers
push ecx
push edx
mov edx, OFFSET prompt ;prints the prompt
call writeString
mov edx, OFFSET string ;moves the register to the first location for the string
mov ecx, SIZEOF string ;Sets the max characters
call readString
mov byteCount,eax ;places actual count into a counting register
call crlf
mov edx, OFFSET prompt2 ;prints the prompt
call writeString
mov edx, OFFSET char
mov ecx, 1
call readString
call clrscr
mov ecx, byteCount
mov edx, OFFSET string
call stringMan
mov edx, OFFSET string
call writeString
pop edx
pop ecx
pop eax
main ENDP
;
stringMan PROC USES eax ecx edx
mov eax,0
L1:
movzx edx , string[ecx]
cmp dl, char
jz L2
push edx
inc eax
L2:
mov string[ecx],0
LOOP L1
mov ecx,eax
mov eax,0
L3:
pop edx
mov byte ptr string[eax],dl
inc eax
loop L3
ret
stringMan ENDP
END main
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.