Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Macros and their parameter types. #150

Open
NYYR1KK1 opened this issue Aug 23, 2021 · 0 comments
Open

Feature request: Macros and their parameter types. #150

NYYR1KK1 opened this issue Aug 23, 2021 · 0 comments

Comments

@NYYR1KK1
Copy link

NYYR1KK1 commented Aug 23, 2021

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:

`
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

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant