Hi all!
A very simple transformation of @if/@else, etc (http://masm32.com/board/index.php?topic=8790.0) apparently is working well.
mov rax, 5
mov value1, rax
@while rax gt 0
conout str$(rax),lf
mov rax, value1
sub rax, 1
mov value1, rax
@endw
conout "--------------",lf
mov rax, 0
mov value1, rax
@while rax le 7
conout str$(rax),lf
mov rax, value1
add rax, 1
mov value1, rax
@endw
To work with floating point numbers, macros requiere SmplMath. The examples attached are very simple and don't need that.
Most tests are needed, could be interesting to know failures.
Thanks in advance, HSE.
updates:
October 13, 2022, 10:49:27 AM -- flow.zip (7.62 kB - downloaded 3 times.)
-- missing a critical piece
October 14, 2022, 04:07:08 AM -- flow1.zip (7.85 kB - downloaded 19 times.)
-- added @break and nesting capacity
Hi HSE
Examples run fine here.
It is a good thing you added the 64bit code path :thumbsup:
Will you add this code to one of your GitHub projects?
Biterider
Hi Biterider
Quote from: Biterider on October 13, 2022, 06:18:29 PM
Will you add this code to one of your GitHub projects?
Yes. But compiled .while/.endw have one less instruction using the negation. First I have to see if that is not so complex adapting Mabdelouahab's macros. Perhaps don't worth the effort, I don't know.
HSE
Was working, but a piece was missing :biggrin:
Now with some combined conditions:
mov eax, 6
mov v1, eax
@while eax ua 0 && ebx ua 3
print str$(eax), 13, 10
mov eax, v1
sub eax, 1
mov v1, eax
@endw
print " @while/@endw finished",13,10,13,10
Updated in first post.
Hi all!
While expecting New Year :biggrin:
- Added @break macro: @while eax gt 0
print str$(eax),13,10
.if v1 >= 10
@break
.endif
mov eax, v1
add eax, 1
mov v1, eax
@endw
- Added nesting capacity (see complete examples in files):
@while eax gt 0
···
@while ecx lt 6
···
@endw
.if v1 >= 10
@break
.endif
···
@endw
"break" have default level 0. That means break cut current cycle. Inside nesting cycles, using "break levels", break cut current cycle and levels previous cycles.
@while eax gt 0
···
@while ecx lt 6
.if v1 >= 7 && v2 > 3
@break 1
.endif
···
@endw
.if v1 >= 10
@break
.endif
···
@endw
Updates in first post.
Thanks for testings, HSE.