News:

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

Main Menu

.FOR built in JWasm

Started by habran, July 03, 2012, 11:38:29 PM

Previous topic - Next topic

qWord

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

Cod-Father

habran

Cod-Father

habran

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

Hello habran,

Quote from: habran on November 02, 2012, 06:37:30 AM
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

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

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
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

habran

Cod-Father

anta40


habran

>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

I tried this:

.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

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:

.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:

      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

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

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

Quote from: anta40 on November 06, 2012, 12:16:35 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