You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all I must say SjASMPlus is currently my favorite assembler. It can compile a lot of existing sources and it has even some quite unique features I enjoy... How ever it does not mean that I don't still keep dreaming about new stuff. :)
I've been wondering that it would be really nice, if the macros could have free amount of parameters (I believe this has been requested already) and they could behave differently based on parameter types given...
I did put most of my dreams to this one over complicated pseudo code macro... I know it is a bit tall order, but maybe something to think about:
MACRO PRINT 1..2 ; (parameter format loaned from Sjasm)
IF TYPE(@1)==FLAG
JP NOT(@1),.SKIP
ROTATE 1 ; from Sjasm (@1=@2)
ENDIF
IF TYPE(@1)==STRING
IF LEN(@1)==1
LD A,@1
CALL CHRPUT
ELSE
CALL PRINT_PC
DB @1, 0
ENDIF
ENDIF
IF TYPE(@1)==REGISTER
IF @1 <> A
LD A,@1
ENDIF
CALL CHRPUT
ENDIF
IF TYPE(@1)==REGISTERPAIR
IF @1 == IX | @1 == IY
PUSH @1
POP HL
ELSE
IF @1 <> HL
LD L,@1.LOW
LD H,@1.HIGH
ENDIF
ENDIF
CALL PRINT_HL
ENDIF
IF TYPE(@1)==REGISTERPAIRPOINTER ; () automatically removed
IF @1 == HL
LD A,(HL)
INC HL
LD H,(HL)
LD L,A
CALL PRINT_HL
ELSE
LD A,(@1)
LD L,A
INC @1
LD A,(@1)
LD H,A
DEC @1
CALL PRINT_HL
ENDIF
ENDIF
IF TYPE(@1)==POINTER ; () automatically removed
LD HL,(@1)
CALL PRINT_HL
ENDIF
IF TYPE(@1)==NUMBER
IF @1 > 255
LD HL,@1
CALL PRINT_HL
ELSE
IF @1 <> 0
LD A,@1
ELSE
XOR A
ENDIF
CALL CHRPUT
ENDIF
ENDIF
.SKIP:
ENDM
PRINT_PC:
POP HL
LD A,(HL)
INC HL
PUSH HL
AND A
RET Z
CALL CHRPUT
JP PRINT_PC
PRINT_HL:
LD A,(HL)
INC HL
AND A
RET Z
CALL CHRPUT
JP PRINT_HL
The text was updated successfully, but these errors were encountered:
I don't think the types make much sense here, the whole macro system in sjasmplus is based on source code processing (as string, before parsing it), but because of that, you get into macro value "as was typed in source", so technically the macro itself could check for your own convention how to distinguish between type.
Right now that means you have to go straight into lua scripting inside macro, as the there are no string operators in the macro language itself, but I can imagine the lua script checking if the value is enclosed in quotes (string type), or does match keyword string (hl,bc,de,..), or evaluate it as expression otherwise to get 16bit value, etc. You can even devise your own way of marking special types in macro values, like adding =X= ahead of the argument value to mark it as your own type "X" and detect such prefix inside lua script.
So I believe you can implement most of this yourself, although the lua script implementing it would be non-trivial, probably worth of some functions library, so I'm curious if it's worth the effort.
variadic arguments:
now this IMHO does make sense even with text preprocessor nature of macros, and I believe it's slightly related also to #103 (as variadic arguments would need similar changes/extensions to code base as macro overloading - with few extras on top of it to handle variadic arguments somehow).
(I have right now no plans to work on enhancement of this scope, but this could hang around with other ideas, just in case somebody ever will start to change sjasmplus a bit more)
Hi,
First of all I must say SjASMPlus is currently my favorite assembler. It can compile a lot of existing sources and it has even some quite unique features I enjoy... How ever it does not mean that I don't still keep dreaming about new stuff. :)
I've been wondering that it would be really nice, if the macros could have free amount of parameters (I believe this has been requested already) and they could behave differently based on parameter types given...
I did put most of my dreams to this one over complicated pseudo code macro... I know it is a bit tall order, but maybe something to think about:
The text was updated successfully, but these errors were encountered: