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

PASS pseudo opcode #49

Open
thrust26 opened this issue Jun 15, 2020 · 8 comments
Open

PASS pseudo opcode #49

thrust26 opened this issue Jun 15, 2020 · 8 comments
Labels
enhancement New feature or request

Comments

@thrust26
Copy link
Member

I think it would be helpful to query the current pass number.

I have some checking macros (e.g. for code and data alignment) which often fail in the first passes and abort assembly. But in the final pass they would pass.

It would be even better if ERR (or a new pseudo op) would only stop assembling in the last pass.

@thrust26 thrust26 added the enhancement New feature or request label Jun 15, 2020
@andrew-davie
Copy link
Member

How about a workaround...?

I'm thinking something like you have a reference to a label that is ONLY defined inside the checking macro, and the macro only defines it when it actually succeeds. That is, the label definition is inside the "IF" condition. So when the checking macro initially fails, the label isn't defined - hence another pass will happen. Assembler will keep doing passes up to the maximum or until no undefined labels. No undefined labels means your checking macros are all happy (they have defined the labels that say OK).

I haven't tried this, but maybe something like this would work for your use-case?

@thrust26
Copy link
Member Author

thrust26 commented Jun 15, 2020

Good idea. Here is my macro:

_ERR SET 0

  MAC CHECKPAGE ; {address}
    LIST OFF              ; keep the list file clean
    IF (>(.-1)) != >{1}
      ECHO ""
      ECHO "ERROR: different pages! (", {1}, ",", .-1, ")"
      ECHO ""
;      ERR                ; previously this aborted the assembly
_ERR SET _ERR + 1         ; count number of errors
    ELSE
CHECKPAGE_{1}             ; define in case of success
    ENDIF
$CHECK SET CHECKPAGE_{1}  ; check success
    LIST ON
  ENDM

You can use it e.g. at the end of a table to make sure the table doesn't cross a page boundary.

@andrew-davie
Copy link
Member

Perhaps worth posting in the "DASM CLUB"?

@thrust26
Copy link
Member Author

thrust26 commented Jun 15, 2020

Good Idea!

But I still would like to have the pass number. 😄

@thrust26
Copy link
Member Author

thrust26 commented Jun 15, 2020

Hm, after I switched from an old DASM version to the latest one, the macro doesn't create an error anymore. 😒

The labels are undefined, but DASM returns "complete".

@thrust26
Copy link
Member Author

The current code LINE would be helpful in macros too.

@msaarna
Copy link
Member

msaarna commented Jun 15, 2020

I think the cleanest solution here would be a new pseudo-op that will force another pass. If it doesn't stop getting triggered in later passes, dasm will naturally error-out the assembly.

@msaarna
Copy link
Member

msaarna commented Jun 16, 2020

Also, you can get the pass number by sticking the following construct at the top of your assembly...
ifnconst PASS
PASS SET 0
endif
PASS SET (PASS+1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants