I didn't know what to label this as I'm not sure exactly what is causing the problem.
The intent was to write two macros, one to precede some test code, and one to follow. The second macro will sometimes jump back into the code created by the first macro as needed. In this test, it is just coded to always do so.
When I assemble and run this with Masm, I get the results 012X312X312X342X342X342X34 as expected. When I assemble and run with JWasm, the program get's lost and does nothing obvious.
.686
.model Flat, Stdcall
option Casemap :None
.nolist
include windows.inc
uselib MACRO libname
include libname.inc
includelib libname.lib
ENDM
uselib user32
uselib kernel32
.list
part1 macro
mov al,"0" stosb
ExtraLoopsLoop = $
sub ExtraLoops,1 mov al,"1" stosb
TimingLoop = $
mov al,"2" stosb
endm
part2 macro
mov al,"3" stosb cmp ExtraLoops,0 jne ExtraLoopsLoop ; go back and do test code again mov al,"4" stosb sub Loops,1 jnz TimingLoop
endm
.data?
ExtraLoops dd ?
Loops dd ?
ResultBuffer db 1000 dup (?)
.data
xxx db "test",0
.code
program:
mov ExtraLoops,3 mov Loops,4 lea edi,ResultBuffer part1
; invoke MessageBox,0,addr xxx,0,0
mov al,"X" ; the test code
stosb
part2 mov al,0 stosb invoke MessageBox,0,addr ResultBuffer,0,0 ; **** result should be 012X312X312X342X342X342X34 ret
end program
Source and listings attached.
To illustrate this further, here two excerpts from OllyDbg:
part2 macro
mov al,"3"
stosb
cmp ExtraLoops,0
jne ExtraLoopsLoop ; go back and do test code again
; JWasm:
; 00401031 |. 833D 10414000 0>cmp dword ptr [ExtraLoops], 0
; 00401038 |>- 75 FE jnz short 00401038 <<<<<<<<<<<<< endless loop <<<<
; ML 6.15:
; 0040101E |> 832D 60304000 0>sub dword ptr [403060], 1
;...
; 00401031 |. 833D 60304000 0>|cmp dword ptr [403060], 0
; 00401038 |.^ 75 E4 |jnz short 0040101E