Author Topic: .FOR built in JWasm  (Read 32532 times)

qWord

  • Member
  • *****
  • Posts: 1454
  • The base type of a type is the type itself
    • SmplMath macros
Re: .FOR build in JWasm
« Reply #15 on: July 05, 2012, 06:15:52 PM »
Extending the macro system or adding some kind of plug-in system does not mean to break with existing code.
A plug-in interface would be the most powerful feature, but it would also require fixing some of jwasm's internal structures. Probably this would make the future development harder.
IMO exiting the macro system is more practical  (e.g. advanced sting- and operator evaluation function).
MREAL macros - when you need floating point arithmetic while assembling!

habran

  • Member
  • *****
  • Posts: 1107
    • uasm
Re: .FOR build in JWasm
« Reply #16 on: July 07, 2012, 02:41:51 PM »
changed to JWasm 2.07
Cod-Father

habran

  • Member
  • *****
  • Posts: 1107
    • uasm
Re: .FOR built in JWasm
« Reply #17 on: September 05, 2012, 11:55:32 AM »
changed to JWasm 2.08
Cod-Father

habran

  • Member
  • *****
  • Posts: 1107
    • uasm
Re: .FOR built in JWasm
« Reply #18 on: November 02, 2012, 06:37:30 AM »
I have updated the attachment at the top and added some more features
If anyone find some errors please let me know
Cat got your tongue? :biggrin: 
Cod-Father

japheth

  • Guest
Re: .FOR built in JWasm
« Reply #19 on: November 04, 2012, 09:31:57 PM »
Hello habran,

If anyone find some errors please let me know

I'm running WinXP SP3, and trying to start jwasm.exe from your package opens a message box: JWasm.exe is not a valid Win32 application.

Additionally, the binary references MSVCR110.dll, a dll which I don't have installed.

habran

  • Member
  • *****
  • Posts: 1107
    • uasm
Re: .FOR built in JWasm
« Reply #20 on: November 05, 2012, 06:06:47 AM »
sorry, it was working fine on my machine
I have attached VS8 build at the top, try that one
please let me know if not OK
however, you have the source code available

thank you for telling me that
Cod-Father

Greenhorn

  • Member
  • **
  • Posts: 93
Re: .FOR built in JWasm
« Reply #21 on: November 05, 2012, 07:58:22 AM »
habran,

you must link to msvcrt statically.

Project properties -> C++ -> Code generation -> Runtime library

Set it to /MTd for Debug Configuration and /MT for Release.


Greenhorn

habran

  • Member
  • *****
  • Posts: 1107
    • uasm
Re: .FOR built in JWasm
« Reply #22 on: November 05, 2012, 10:59:42 PM »
here is it
Cod-Father

anta40

  • Member
  • ***
  • Posts: 293
Re: .FOR built in JWasm
« Reply #23 on: November 05, 2012, 11:13:50 PM »
Is nested loop supported?

habran

  • Member
  • *****
  • Posts: 1107
    • uasm
Re: .FOR built in JWasm
« Reply #24 on: November 06, 2012, 05:48:52 AM »
>Is nested loop supported?
Yes, according to japheth it is unlimited

>you must link to msvcrt statically.
thankyou Greenhorn, I was not aware of that

I have uploaded the new version on the top
It takes more memory

hope now works for everyone

Cod-Father

anta40

  • Member
  • ***
  • Posts: 293
Re: .FOR built in JWasm
« Reply #25 on: November 06, 2012, 12:16:35 PM »
I tried this:
Code: [Select]
.486
option casemap:none

include \masm32\include\masm32rt.inc
includelib \masm32\lib\masm32.lib

.code
start:

.for (ebx=3¦ebx>=1¦ebx--)
.for(ecx=1¦ecx<=ebx¦ecx++)
print str$(ecx)," "
        .endfor
print " ",13,10,0
.endfor

exit
end start

My expected output is:
Quote
1 2 3
1 2
1

But the actual output is:
Quote
1
1
1

Am I doing something wrong here?

habran

  • Member
  • *****
  • Posts: 1107
    • uasm
Re: .FOR built in JWasm
« Reply #26 on: November 06, 2012, 02:52:26 PM »
Yes, you are calling 'print str$(ecx)," "' which uses ecx register which is volatile register
and it gets trashed
you can use nonvolatile registers or PUSH and POP eg:
Code: [Select]
.for (ebx=3¦ebx>=1¦ebx--)
.for(ecx=1¦ecx<=ebx¦ecx++)
                push ecx
print str$(ecx)," "
                pop ecx
        .endfor
print " ",13,10,0
.endfor
When you write print str$(ecx)," "
you use these two macros:
Code: [Select]
      print MACRO arg1:REQ,varname:VARARG      ;; display zero terminated string
        invoke StdOut,reparg(arg1)
      IFNB <varname>
        invoke StdOut,chr$(varname)
      ENDIF
    ENDM

  ; ----------------------------------------------------------
  ; function position macros that takes a DWORD parameter and
  ; returns the address of the buffer that holds the result.
  ; The return format is for use within the INVOKE syntax.
  ; ----------------------------------------------------------
    str$ MACRO DDvalue
      LOCAL rvstring
      .data
        rvstring db 20 dup (0)
        align 4
      .code
      invoke dwtoa,DDvalue,ADDR rvstring
      EXITM <ADDR rvstring>
    ENDM
as you can see they both call functions that do not preserve volatile registers
Cod-Father

anta40

  • Member
  • ***
  • Posts: 293
Re: .FOR built in JWasm
« Reply #27 on: November 06, 2012, 03:05:33 PM »
Ah thanks. I forget about it once again  :redface:

They are already listed in jj's page, anyway:
http://www.webalice.it/jj2006/Masm32_Tips_Tricks_and_Traps.htm

habran

  • Member
  • *****
  • Posts: 1107
    • uasm
Re: .FOR built in JWasm
« Reply #28 on: November 06, 2012, 03:46:44 PM »
no worries mate  :biggrin:
ones I'v spent days to find the bug in my source
and all I needed is to finish the function with RET :icon_mrgreen:
now when I start some function first thing I write is RET :lol:
we usually see everything except most obvious things
for example: if your wife is cheating on you, you will be the last one to know it
your neighbors well know that long time before you

best regards
Cod-Father

jj2007

  • Member
  • *****
  • Posts: 7541
  • Assembler is fun ;-)
    • MasmBasic
Re: .FOR built in JWasm
« Reply #29 on: November 06, 2012, 05:26:59 PM »
Am I doing something wrong here?

As Habran already wrote, ecx is the culprit. No problem with MB, but print (lowercase p) and str$ are Masm32 macros. Same if you use Windows or CRT functions like printf etc.

include \masm32\MasmBasic\MasmBasic.inc   ; download
  Init
  For_ ebx=0 To 3
     For_ ecx=1 To 4-ebx
          Print Str$(ecx), " "   ; MasmBasic preserves ecx
     Next
     Print
  Next

  Inkey
  Exit
end start