A
A
Adhol2019-05-12 15:45:37
assembler
Adhol, 2019-05-12 15:45:37

How to make a loop in assembler?

Here is my code

.386
.model flat, stdcall
option casemap: none

include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib

.data
  msg1 db "Please, enter String: ",0, 13
  numberOfChanges db 0

.data?
  buffer db 256 dup(?)

.code

start:
  push offset msg1
  call StdOut
  
  push 256
  push offset buffer
  call StdIn
  
  mov edi, offset buffer
  mov al, "a"
  repne scasb
  mov al, "b"
  inc numberOfChanges
  mov byte ptr[edi-1], "b"
  
  push offset buffer
  call StdOut
  
exit:
  push 0
  call ExitProcess

End start

It is necessary to loop the replacement of letters, this program changes only 1 encountered letters a
I also can’t figure out how to increment the replacement counter and output it along with the changed string

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2019-05-12
@dollar

You need to use conditional jumps.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question