News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Loop problem

Started by ~Paul~, September 03, 2007, 07:37:32 AM

Previous topic - Next topic

~Paul~

Alright i think i have it now :U Thanks everyone for all the help.

Mirno

If 1111 is considered "well ordered" you can do:

.data
  szNumber db "1111", 13, 10

.code
  mov ecx, offset szNumber
  xor edx, edx

while_loop:
  mov eax, "9999"
  sub eax, [ecx]
  jz the_end

  test eax, 000FFFFFFh
  jnz @F
  mov al, BYTE PTR [ecx + 0]
  add al, 1

  mov BYTE PTR [ecx + 0], al
  mov BYTE PTR [ecx + 1], al
  mov BYTE PTR [ecx + 2], al
  mov BYTE PTR [ecx + 3], al
  jmp while_loop

@@:
  test eax, 00000FFFFh
  jnz @F
  mov al, BYTE PTR [ecx + 1]
  add al, 1

  mov BYTE PTR [ecx + 1], al
  mov BYTE PTR [ecx + 2], al
  mov BYTE PTR [ecx + 3], al
  jmp while_loop

@@:
  test eax, 0000000FFh
  jnz @F
  mov al, BYTE PTR [ecx + 2]
  add al, 1

  mov BYTE PTR [ecx + 2], al
  mov BYTE PTR [ecx + 3], al
  jmp while_loop

@@:
  add BYTE PTR [ecx + 3], 1
  jmp while_loop

the_end:


No point looping back to zero after all.