News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

HJWasm .SWITCH - .CASE - .DEFAULT - .ENDSWITCH

Started by habran, April 10, 2016, 08:26:42 PM

Previous topic - Next topic

habran

Cod-Father

jj2007

Quote from: nidud on April 12, 2016, 08:28:47 PM

1312   cycles, rep(100), code(1920) - .switch - no match
21844   cycles, rep(100), code(1481) -  SWITCH - no match (MasmBasic)

Can you post source & exe, please?

nidud

#32
deleted

habran

Hi nidud,
Can you please upload your project with HJWasm so that I can debug it and see where is that bug
It doesnt have to be here, just send me the site address.
If you don't want to do it here you cam PM me
Cod-Father

nidud

#34
deleted

nidud

#35
deleted

nidud

#36
deleted

jj2007

Quote from: nidud on April 12, 2016, 11:42:02 PM

mbswitch proc value
mov eax,value
SWITCH eax
enum_mb = 0
repeat count
  case enum_mb
mov eax,enum_mb
enum_mb = enum_mb + 1
endm
default
xor eax,eax
ENDSW
ret
mbswitch endp

That is the classical Masm32 Switch macro. MasmBasic Switch_ looks different, and behaves differently:
1255      cycles, rep(96), code(1844) for swproc
980       cycles, rep(96), code(2825) for MB Switch_
20555     cycles, rep(96), code(1421) for Masm32 switch
20456     cycles, rep(96), code(1430) for ifproc


The count is too high for the MasmBasic Switch_ macro, but count equ 96 works, see attachment.

nidud

#38
deleted

jj2007

I must admit I have no idea what this code does:
swproc proc value ; OPT_Assembler asmc
mov eax,value
int 3
.SWITCH eax
enum = 0
repeat count
  .case enum
mov eax,enum
.break
enum = enum + 1
endm
ifdef __HJWASM__
.default
xor eax,eax
.break
endif
MENDSW
@CCCD0:
ret
swproc endp


Under the hood:
0040209F             Ú$  55                 push ebp                           ; timeit.0040209F(guessed Arg1)
004020A0             ³.  8BEC               mov ebp, esp
004020A2             ³.  8B45 08            mov eax, [arg1]
004020A5             ³.  CC                 int3
004020A6             ³. E9 C5030000        jmp 00402470
004020AB             ³>  B8 00000000        mov eax, 0
004020B0             ³. E9 1B070000        jmp 004027D0
004020B5             ³>  B8 01000000        mov eax, 1
....
004027BE             ³.  83F8 60            cmp eax, 60
004027C1             ³. 0F84 90FCFFFF      je 00402457
004027C7             ³.  83F8 60            cmp eax, 60
004027CA             ³. 0F84 91FCFFFF      je 00402461
004027D0             ³>  5D                 pop ebp
004027D1             À.  C2 0400            retn 4
::)

HSE

Don't forget ObjAsm also have a switch, that say is a modification a Greg Falen one (MASM32).

I used only one time. Apparently support multiple case in one line: case 1, 4, 6, etc
1293      cycles, rep(96), code(1499) for swproc
1000      cycles, rep(96), code(2825) for MB Switch_
27252     cycles, rep(96), code(1421) for Masm32 switch
874       cycles, rep(96), code(1421) for ObjAsm switch
24227     cycles, rep(96), code(1430) for ifproc
hit any key to continue...
 
Equations in Assembly: SmplMath

nidud

#41
deleted

HSE

 :biggrin: It's the same after each macro expansion at compilation time: repeat count ... endm. Nothing to do with test (perhaps JJ could change "count" to "limit" or something more clear).
Equations in Assembly: SmplMath

nidud

#43
deleted

HSE

#44
 :t
Equations in Assembly: SmplMath