Question

MASM Assembly Language programming question. I'm having serious issues. I am attempting to scan through a...

MASM Assembly Language programming question. I'm having serious issues. I am attempting to scan through a string and replace all the "o" characters with an exclamation mark (!). However my program does not work and no change seems to occur to the string. Also the loop breaks once the first "o" character is encountered.Is there anyone in this Universe that can help me???Please

main PROC

   ;mov edi,OFFSET string
   mov ecx, LENGTHOF string
   mov edi,OFFSET string
  
L1:

   mov eax,0
   ;mov al,BYTE PTR [edi]
   mov al,[edi]
   cmp al,"o"
   jz Change
   inc edi
   loop L1
  
Change:

   mov eax,0
   mov al,"!"
   call DumpRegs
   mov edi,eax
  

   inc edi
  
  
      
      
      
          
Final:
       mov edx,OFFSET string  
       call WriteString
      

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note:- I had made the required changed and kept in BOLD format. The reason it is not replacing because in Change function ; you were not looping the control back and after change it is going to FINAL label and closing the program. The CHANGE function should be written at the end of the program

MASM PROGRAM :-

main PROC

;mov edi,OFFSET string
mov ecx, LENGTHOF string
mov edi,OFFSET string

mov ebx, 0

L1:

mov eax,0
mov bl, 111
;mov al,BYTE PTR [edi]
mov al,[edi]
cmp al,bl
jz Change
inc edi
loop L1
  
Final:
mov edx,OFFSET string
call WriteString
     
Change:
mov eax,0
mov al,"!"
call DumpRegs
mov [edi],al

inc edi
loop L1

Add a comment
Know the answer?
Add Answer to:
MASM Assembly Language programming question. I'm having serious issues. I am attempting to scan through a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • X86 Assembly Language Help to implement the CipherChar Procedure at the end of the given code...

    X86 Assembly Language Help to implement the CipherChar Procedure at the end of the given code INCLUDE Irvine32.inc         .data       KeyPrompt BYTE "Enter the passphrase: ",0       TextPrompt BYTE "Enter the plaintest: ",0           str1 BYTE "The passphrase has length:",0           str2 BYTE "The plaintest has length:",0       KeyIs BYTE "The passphrase: ",0       PlainTextIs BYTE "The plaintext: ",0       CipherTextIs BYTE "The ciphertext: ",0       KMAX = 64                        ; passphrase buffer maximum size       BMAX = 128                       ; test...

  • rnte a P instruction with indirect addressing, and call the ReadChar ein AL.)(10 pts.) BYTE named myString. Use the LOO edure from the book's link library- (ReadChar-returns its valu 50. Code a P...

    rnte a P instruction with indirect addressing, and call the ReadChar ein AL.)(10 pts.) BYTE named myString. Use the LOO edure from the book's link library- (ReadChar-returns its valu 50. Code a PROC declaration for a procedure named MySub. Use the USES operator to preserve the EAX and EBX registers. 51. Draw a flowchart that corresponds to the following code: (6 pts.) mov ecx, LENGTHOF array mov eax, 0 mov esi, OFFSET array L1: add eax, [esi] add esi, TYPE...

  • Assembly Language NASM create a substring ASSIGNMENT INSTRUCTIONS: Create the Substring from the Given string, beginIndex...

    Assembly Language NASM create a substring ASSIGNMENT INSTRUCTIONS: Create the Substring from the Given string, beginIndex and endIndex The program should create a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex – 1. Thus the length of the substring is endIndex-beginIndex. In other words you can say that beginIndex is inclusive and endIndex is exclusive while getting the substring. Initialize the following values in...

  • I need help with a code in assembly language MASM (x86)

    write an assembly language (x86) program to input in a string 10 multi-digit integers and displays them in ascending order. Modify the code below to comply with the requirement..model small.stack 100h.datastrg1 DB 'Insert numbers: $'strg2 DB 'Sorted numbers: $'Arr Db 10 dup(?)v dw ?.codemain procmov ax,@datamov ds,axmov ah,9lea dx,strg1int 21hmov dl,0ahmov ah,2int 21h;inputsmov di,0mov cx,10Input_loop:mov ah,1int 21hmov arr[di],almov dl,0ahmov ah,2int 21hinc diloop Input_loopmov v,0sort:mov di,0mov cx,10sub cx,vB:mov al,Arr[di]cmp al,Arr[di+1]jng Cmov al,Arr[di]xchg al,Arr[di+1]mov Arr[di],alc:inc diloop Binc vcmp v,10jne sort;Outputmov ah,9lea dx,strg2int...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT