News:

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

Assembler time type query..?

Started by Ficko, June 21, 2010, 07:20:11 AM

Previous topic - Next topic

qWord

Quote from: dedndave on June 22, 2010, 01:17:07 PMwill it return the type (byte) or the sizeof (string length) ?
the type.

I've also noticed that this is "official documented" in the MASM Programmer's Guide. This technique is shown in an example-macro for OPATTR:
Quoteload    MACRO reg:REQ, adr:REQ
    IF (OPATTR (adr)) AND 00010000y    ;; Register
        IFDIFI reg, adr                ;; Don't load register
            mov     reg, adr           ;;   onto itself
        ENDIF
    ELSEIF (OPATTR (adr)) AND 00000100y
        mov     reg, adr               ;; Constant
    ELSEIF (TYPE (adr) EQ BYTE) OR (TYPE (adr) EQ SBYTE)
        mov    reg, OFFSET adr         ;; Bytes
    ELSEIF (SIZE (TYPE (adr)) EQ 2
        mov    reg, adr                ;; Near pointer
    ELSEIF (SIZE (TYPE (adr)) EQ 4
        mov    reg, WORD PTR adr[0]    ;; Far pointer
        mov    ds,  WORD PTR adr[2]
    ELSE
        .ERR <Illegal argument>
    ENDIF
END
M
FPU in a trice: SmplMath
It's that simple!

jj2007

Quote from: dedndave on June 22, 2010, 01:17:07 PM
if you have a string ?
will it return the type (byte) or the sizeof (string length) ?

Add this to the macro:
else
oa = (opattr arg) AND 127
tmp$ CATSTR <arg>, < is something else with an opattr of >, %oa
% echo tmp$


MyStringPtr dd MyString
MyString db "Ok, so that's a string with 41 characters", 0

.code
start:
..
TrueType MyStringPtr
TrueType MyString
TrueType offset MyString


Output:
MyStringPtr is an unsigned dword
MyString is something else with an opattr of 42
offset MyString is something else with an opattr of 38

jj2007

Quote from: qWord on June 22, 2010, 10:35:31 AM
most of my macros won't work with jwasm  ::)
If it's "most", the cause might be some specific programming habit of yours. I have a lot of odd and idiosyncratic macros in MasmBasic.inc, but until now they all work in JWasm and ml 6.15+
Anyway, I filed it as a bug in SourceForge

qWord

Quote from: jj2007 on June 22, 2010, 06:09:45 PMIf it's "most", the cause might be some specific programming habit of yours.
What habit should it be? - Currently there are still incompatibilities in jwasm. e.g.:
tm TEXTEQU <1>
bla TEXTEQU %1+tm ; error with jwasm

(also reported on SourceForge)
I've also tried to make the affected macros compatible, but when one error is 'solved' the next one comes up.
However, I'm very sure japhet will get them all  :8)
FPU in a trice: SmplMath
It's that simple!

jj2007

Quote from: qWord on June 22, 2010, 09:20:33 PM
Quote from: jj2007 on June 22, 2010, 06:09:45 PMIf it's "most", the cause might be some specific programming habit of yours.
What habit should it be? - Currently there are still incompatibilities in jwasm. e.g.:
tm TEXTEQU <1>
bla TEXTEQU %1+tm ; error with jwasm

(also reported on SourceForge)

Workaround:

include \masm32\include\masm32rt.inc

tm EQU 1
bla TEXTEQU %1+tm ; no error with jwasm

;tm TEXTEQU <1>
;bla TEXTEQU %1+tm ; error with jwasm

.code
start:
% echo zeBla: bla
exit
.err
end start

Quote
I've also tried to make the affected macros compatible, but when one error is 'solved' the next one comes up.
However, I'm very sure japhet will get them all  :8)

He is morally obliged to chase them, with such an enthusiastic audience :bg

jj2007

Quote from: qWord on June 22, 2010, 09:20:33 PM
However, I'm very sure japhet will get them all  :8)

Japheth, 22.6.2010: It's fixed in v2.03

That means we can improve our macro collections soon :bg

Ficko

Due to we are winded up by JWASM I have here this little pain can get it work on JWASM. :bg
The %echo shows legitimate out put but JWASM doesn't like it any idea? ::)


.686p
.model flat, stdcall
option casemap :none
Pilot$_ PROTO C :DWORD,:VARARG
Pilot$ MACRO Params:VARARG
LOCAL pushed,Cn
pushed EQU <>
Cn = 0
FOR Param,<Params>
pushed CATSTR pushed,<,>,<Param>
Cn = Cn + 1
ENDM
%echo @CatStr(<invoke Pilot$_,>,<%Cn>,<pushed>)
@CatStr(<invoke Pilot$_,>,<%Cn>,<pushed>)
ENDM

.code
start:
Pilot$ eax,ebx
end start

jj2007

Quote from: Ficko on June 23, 2010, 12:42:53 PM
Due to we are winded up by JWASM I have here this little pain can get it work on JWASM. :bg
The %echo shows legitimate out put but JWASM doesn't like it any idea? ::)

include \masm32\include\masm32rt.inc
.686p

Pilot$_ PROTO C :DWORD,:VARARG

Pilot$ MACRO Params:VARARG
LOCAL pushed,Cn
pushed EQU <>
Cn = 0
FOR Param,<Params>
pushed CATSTR pushed,<,>,<Param>
Cn = Cn + 1
ENDM
% echo @CatStr(<invoke Pilot$_,>,<%Cn>,<pushed>)
% @CatStr(<invoke Pilot$_,>,<%Cn>,<pushed>)
ENDM

.code
start:
Pilot$ eax, ebx
exit
Pilot$_ proc C args, more:vararg
invoke MessageBox, 0, chr$("Ciao"), chr$("Title"), MB_OK
ret
Pilot$_ endp

end start


By the way: It is considered good practice only examples that have been tested. Yours threw an error both with ML and JWasm.

Ficko

Thanks I would never figure that one out. :U

Quote
By the way: It is considered good practice only examples that have been tested. Yours threw an error both with ML and JWasm.

Noway dude. :bg
perhaps you had renamed your "JWASM.exe" to "ML.exe" a long time ago. :wink

Quote
invoke Pilot$_,2,eax,ebx
Microsoft (R) Macro Assembler Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.
Make finished.
Total compile time 78 ms

jj2007

Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

NewWin32.obj : error LNK2001: unresolved external symbol _Pilot$_
NewWin32.exe : fatal error LNK1120: 1 unresolved externals


For ml 9.0, 6.15 and 6.14, dude :bg

Ficko

May that's come from the linker ::)
Mine is :
Quote
Microsoft (R) Incremental Linker Version 10.00.30319.01
I never sad the program can be linked. :bg

But what the trick or rule with this "%" thing by JWASM?

I have this code and I do not wanna call my macro with "%" :naughty:


.686p
.model flat, stdcall
option casemap :none
MBMAIN = 1
POINTER  TYPEDEF DWORD
OPENCONSOLE__ PROTO :POINTER
; ------------------------------------------------
OPENCONSOLE_ MACRO CInfo:REQ
IF MBMAIN EQ 2
push CInfo
invoke AllocConsole
pop ecx
.if (eax != 0)
invoke OPENCONSOLE__,ecx
.endif
ELSE
invoke OPENCONSOLE__,CInfo
ENDIF
ENDM
; -----------------------
;; INLINE [nX] OPCODE,...
; -----------------------
inline equ <INLINE>
Inline equ <INLINE>
INLINE MACRO vs:VARARG
LOCAL pos
FOR arg,<vs>
IFNB <arg>
pos=@InStr(1,arg,<!:>)
argy CATSTR <arg>
IF pos
argy CATSTR <@SubStr(<arg>,1,pos-1),@SubStr(<arg>,pos+1)>
ENDIF
IFIDN @SubStr(<arg>,2,1),<X>
REPEAT @SubStr(<arg>,1,1)
@SubStr(%argy,4)
ENDM
ELSE
argy
ENDIF
ENDIF
ENDM
ENDM

.code
start:
;Inline push eax,OPENCONSOLE_ eax,pop eax
%Inline push eax,OPENCONSOLE_ eax,pop eax ;JWASM req %
end start

jj2007

Same as before. It should throw an error because _OPENCONSOLE__ proc is not found.

*** Assemble using \Masm32\bin\ml /nologo /c /coff  /Fl /Sn /Fo "NewWin32" ***
Assembling: tmp_file.asm
*** Link using link with sub CONSOLE   "NewWin32.obj" /OUT:"NewWin32.exe" (no resources) ***

Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

NewWin32.obj : error LNK2001: unresolved external symbol _OPENCONSOLE__@4
NewWin32.exe : fatal error LNK1120: 1 unresolved externals

Ficko

You should not link it dude!  :wink

The point is to compile it.

I have about 80 macros here not compiling under JWASM.

You sad
Quote
If it's "most", the cause might be some specific programming habit of yours.

I thought might you right and I like to understand what is it and what can I do about it because I like JWASM due to it fixes over MASM but I just can't use it.
I write 10 macros and get 64 errors. :eek

jj2007


Ficko