News:

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

Modified JWasm

Started by habran, March 01, 2012, 02:42:17 AM

Previous topic - Next topic

dedndave

seems to me it would be more trouble than it's worth - lol
just write the thing in 32-bit   :U

i know - i am a paaaaaaaarty-pooper

dedndave

if you want a real neat trick...
write some code so i can execute 64-bit stuff under a 32-bit OS, provided i have a suitable CPU   :U
now, you have something to be excited about - lol

jj2007

Quote from: johnsa on March 24, 2012, 07:37:11 PM
Oh heck yeah.. that would be brilliant :)
I wonder if there's another call-gate or if that one works from 64->32..

Ray Chen tries desperately to sell the message "it's not possible". One thing is sure: it's not in the interest of Microsoft and the hardware industry...

If I really had to write a wrapper for letting a 64-bit dll access my 32-bit libraries, WM_COPYDATA and memory-mapped files would be high on my list of ingredients :bg

qWord

well, that is assembler: severely restricted portability   :P
FPU in a trice: SmplMath
It's that simple!

habran

#64
Hi
I have developed this MACRO for JWasm users
it can be nested as many time as needed, JWasm has no limit 20
it is based on .REPEAT and .UNTIL FALSE
it can be used for x86 or x64
I think that it can also work with ML.EXE but not with ml64.exe
any improvements welcome



usage:
NO SPACES ALLOWED BETWEEN ":"
this=begin:limit:step:--next
this=begin:limit:step:++next
EXAMPLE:
;count=src,dest,2,++count
;count=0:dest:8:++count
;rbx=24:0:1:--rbx
;rax=0:24:4:++rax
;if step = 0 'next' will be added or subtracted to 'this'
;count=src:dest:0:--rax
;count=src:dest:0:++src
;if step = 0 and no '--' or '++', 'this' = 'next' and will stop when this == limit
;count=src:dest:0:rax

;.FOR count=src:dest:1:++count
;     nop
;     .break .if (!count)
;     nop
;     .continue .if (!src)
;     nop
;     .continue
;     nop
;     .break
;     mov eax,1
;.ENDFOR
;.forever
;   nop
;   .break .if (!eax)
;   nop
;.endfor

option dotname        ;;it wan't work without tis
TRUE = 1
FALSE = 0

.for  MACRO  these:vararg
LOCAL pm,mreg,rg,this,begin,step,limit,next,column1,column2,column3,iseq
LOCAL startloop
  iseq EQU @InStr(1,<these>,<=>)
  this TEXTEQU @SubStr(<these>,1, iseq-1)
  column1 EQU @InStr(iseq+1,<these>,<:>)
  begin TEXTEQU @SubStr(<these>,iseq+1,column1-iseq-1)
  column2 EQU @InStr(column1+1,<these>,<:>)
  limit TEXTEQU @SubStr(<these>,column1+1,column2-column1-1)
  column3 EQU @InStr(column2+1,<these>,<:>)
  step TEXTEQU @SubStr(<these>,column2+1,column3-column2-1)
  pm TEXTEQU @SubStr(<these>,column3+1,2)
  IFIDNI pm, <++>
    next TEXTEQU @SubStr(<these>,column3+3)
  ELSEIFIDNI pm, <-->
    next TEXTEQU @SubStr(<these>,column3+3)
  ELSE
    next TEXTEQU @SubStr(<these>,column3+1)
  ENDIF
rg = (OPATTR this) AND 127  ;;checking if 'this' is register
IF rg NE 48                 
rg = 0                      ;;not register
ELSE
rg = 1                      ;;yes
ENDIF
IFE rg
IFDEF _WIN64 
    mreg TEXTEQU <rax>
ELSE
    mreg TEXTEQU <eax>
ENDIF
ENDIF
IFIDN <begin>,<0>
   IF rg
       mov this,next
   ELSE
      mov mreg,next
      mov this,mreg
   ENDIF
ELSE
   IF rg
      mov this,begin
   ELSE
      mov mreg,begin
      mov this,mreg
   ENDIF
ENDIF
jmp startloop
.repeat                      ;;here is the LOOP
      IFIDN pm, <++>
            IF rg         
               IFE step
                 add this,next
               ELSE
                 add this,step 
               ENDIF
            ELSE
               mov mreg,this           
               IFE step
                add mreg,next
               ELSE
                add mreg,step
               ENDIF           
               mov this,mreg   
            ENDIF         
      ELSEIFIDN pm, <-->
            IF rg         
               IFE step
                 sub this,next
               ELSE
                 sub this,step 
               ENDIF
            ELSE
               mov mreg,this           
               IFE step
                sub mreg,next
               ELSE
                sub mreg,step
               ENDIF           
               mov this,mreg   
            ENDIF         
      ELSE
        IF rg
         mov this,next
        ELSE
         mov mreg,next
         mov this,mreg
        ENDIF
      ENDIF
startloop:
   IFIDN pm, <++>
     IF rg
      .break .if (this < limit)
     ELSE
      .break .if (mreg < limit)
     ENDIF
   ELSEIFIDN pm, <-->
     IF rg
      .break .if (this < limit)
     ELSE
      .break .if (mreg < limit)
     ENDIF
   ELSE
        IF rg
         .break .if (this == limit)
        ELSE
         .break .if (mreg == limit)
        ENDIF
      ENDIF     
ENDM

.forever MACRO
    .repeat
ENDM
.endfor     MACRO
      .until FALSE         ;;LOOP forever
ENDM
.FOREVER EQU .forever
.Forever EQU .forever
.FOR EQU .for
.ENDFOR EQU .endfor
.For EQU .for
.Endfor EQU .endfor
 

_________________________
I added cool smileys to this message... if you don't see them go to: http://s.exps.me

_________________________
I added cool smileys to this message... if you don't see them go to: http://s.exps.me

habran

I have fixed some bugs and now everything works properly

habran

here is how it looks expanded by assembler:

.FOR count=src:dest:1:++count
     nop                     
     .break .if (!count)     
     nop                     
     .continue .if (!src)   
     nop                     
     .continue               
     nop                     
     .break                 
     mov eax,1               
.ENDFOR                     

.for rsi=src:0:0:[rsi].AXPOINT.next
    nop
    .break
    nop
.endfor

.forever
   nop
   .break .if (!eax)
   nop
.endfor

;--------------------------------------------------------------
  1080: .FOR count=src:dest:1:++count
000000000044B019  mov         rax,qword ptr [rbp+18h]
000000000044B01D  mov         qword ptr [rbp+20h],rax
000000000044B021  jmp         somefunction+29h (44B02Fh)
000000000044B023  mov         rax,qword ptr [rbp+20h]
000000000044B027  add         rax,1
000000000044B02B  mov         qword ptr [rbp+20h],rax
000000000044B02F  cmp         rax,qword ptr [rbp+10h]
000000000044B033  jb          somefunction+4Ch (44B052h)
  1081:      nop                     
000000000044B035  nop             
  1082:      .break .if (!count)     
000000000044B036  cmp         qword ptr [rbp+20h],0
000000000044B03B  je          somefunction+4Ch (44B052h)
  1083:      nop                     
000000000044B03D  nop             
  1084:      .continue .if (!src)   
000000000044B03E  cmp         qword ptr [rbp+18h],0
000000000044B043  je          somefunction+4Ah (44B050h)
  1085:      nop                     
000000000044B045  nop             
  1086:      .continue               
000000000044B046  jmp         somefunction+4Ah (44B050h)
  1087:      nop                     
000000000044B048  nop             
  1088:      .break                 
000000000044B049  jmp         somefunction+4Ch (44B052h)
  1089:      mov eax,1               
000000000044B04B  mov         eax,1
  1090: .ENDFOR                     
000000000044B050  jmp         somefunction+1Dh (44B023h)
;--------------------------------------------------------------
  1092: .for rsi=src:0:0:[rsi].AXPOINT.next
000000000044B052  mov         rsi,qword ptr [rbp+18h]
000000000044B056  jmp         somefunction+55h (44B05Bh)
000000000044B058  mov         rsi,qword ptr [rsi]
000000000044B05B  or          rsi,rsi
000000000044B05E  je          somefunction+60h (44B066h)
  1093:     nop
000000000044B060  nop             
  1094:     .break
000000000044B061  jmp         somefunction+60h (44B066h)
  1095:     nop
000000000044B063  nop             
  1096:  .endfor
000000000044B064  jmp         somefunction+52h (44B058h)
;--------------------------------------------------------------
  1097:  .forever
  1098:    nop
000000000044B066  nop             
  1099:    .break .if (!eax)
000000000044B067  and         eax,eax
000000000044B069  je          somefunction+68h (44B06Eh)
  1100:    nop
000000000044B06B  nop             
  1101: .endfor
000000000044B06C  jmp         somefunction+60h (44B066h)
;--------------------------------------------------------------
  1104:   .if (rcx != rdx)
000000000044B06E  cmp         rcx,rdx

habran

some more examples:

  1080: .FOR count=src:dest:8:--count
000000000044B019  mov         rax,qword ptr [rbp+18h]
000000000044B01D  mov         qword ptr [rbp+20h],rax
000000000044B021  jmp         somefunction+29h (44B02Fh)
000000000044B023  mov         rax,qword ptr [rbp+20h]
000000000044B027  sub         rax,8
000000000044B02B  mov         qword ptr [rbp+20h],rax
000000000044B02F  cmp         rax,qword ptr [rbp+10h]
000000000044B033  jb          somefunction+4Ch (44B052h)
  1081:      nop                     
000000000044B035  nop             
  1082:      .break .if (!count)     
000000000044B036  cmp         qword ptr [rbp+20h],0
000000000044B03B  je          somefunction+4Ch (44B052h)
  1083:      nop                     
000000000044B03D  nop             
  1084:      .continue .if (!src)   
000000000044B03E  cmp         qword ptr [rbp+18h],0
000000000044B043  je          somefunction+4Ah (44B050h)
  1085:      nop                     
000000000044B045  nop             
  1086:      .continue               
000000000044B046  jmp         somefunction+4Ah (44B050h)
  1087:      nop                     
000000000044B048  nop             
  1088:      .break                 
000000000044B049  jmp         somefunction+4Ch (44B052h)
  1089:      mov eax,1               
000000000044B04B  mov         eax,1
  1090: .ENDFOR                     
000000000044B050  jmp         somefunction+1Dh (44B023h)
  1091:
  1092: .for rsi=src:0:0:[rsi].AXPOINT.next
000000000044B052  mov         rsi,qword ptr [rbp+18h]

or like this:

  1080: .FOR rbx=src:dest:4:--rbx
000000000044B019  mov         rbx,qword ptr [rbp+18h]
000000000044B01D  jmp         somefunction+1Dh (44B023h)
000000000044B01F  sub         rbx,4
000000000044B023  cmp         rbx,qword ptr [rbp+10h]
000000000044B027  jb          somefunction+40h (44B046h)
  1081:      nop                     
000000000044B029  nop             
  1082:      .break .if (!count)     
000000000044B02A  cmp         qword ptr [rbp+20h],0
000000000044B02F  je          somefunction+40h (44B046h)
  1083:      nop                     
000000000044B031  nop             
  1084:      .continue .if (!src)   
000000000044B032  cmp         qword ptr [rbp+18h],0
000000000044B037  je          somefunction+3Eh (44B044h)
  1085:      nop                     
000000000044B039  nop             
  1086:      .continue               
000000000044B03A  jmp         somefunction+3Eh (44B044h)
  1087:      nop                     
000000000044B03C  nop             
  1088:      .break                 
000000000044B03D  jmp         somefunction+40h (44B046h)
  1089:      mov eax,1               
000000000044B03F  mov         eax,1
  1090: .ENDFOR                     
000000000044B044  jmp         somefunction+19h (44B01Fh)
  1091:
  1092: .for rsi=src:0:0:[rsi].AXPOINT.next
000000000044B046  mov         rsi,qword ptr [rbp+18h]