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

Apply workaround for ASxxxx macro problem #259

Closed
TG9541 opened this issue Aug 10, 2019 · 3 comments · Fixed by #260
Closed

Apply workaround for ASxxxx macro problem #259

TG9541 opened this issue Aug 10, 2019 · 3 comments · Fixed by #260
Assignees

Comments

@TG9541
Copy link
Owner

TG9541 commented Aug 10, 2019

@kenyapcomau found a workaround for the bug in ASxxxx (sdasstm8) macro processing described in the SDCC tracker issue 2626:

using octal escapes for characters like , and ; prevents the assembler crash.

Now all headers in forth.asm can use the HEADER macro!

@TG9541 TG9541 mentioned this issue Aug 10, 2019
@kenyapcomau
Copy link

I have sent a link to this page to Alan Baldwin.

@kenyapcomau
Copy link

Reply from Alan:

Ken,

I see how the argument being passed is causing the problem.
A macro expects arguments to be separated by white space or the
delimiter ','. So if the macro is passed an argument as -

HEADER "C" which has no delimiters in the argument "C"
the "C" is passed as the argument.

If the macro is passed an argument as -

HEADER "," which has a delimiter, then the macro believes
there are two arguments " and ".

If the argument contains a ";" then the ; signifies and end of code
and the argument is a single ".

The macro documentation specifies how to pass arguments containing
delimiters as ^/arg/. So the method to pass string arguments with
(or without) delimiters is -

HEADER ^/","/

or with any argument containing white space.
Note that the / character can be any character
not in the string to be passed. The arguments
are just a series of characters and the "
characters have no special meaning to the macro
parser.

I hope this clarifies the problem.

Alan

p.s.:
From the assembler code it appears my checking
of the macro argument count is in the wrong
place and misses detecting the extra arguments
trashing the macro structure, this I will need
to fix. I have attached MT.asm which calls
the macro HEADER over 500 times. Uncommenting
the line containing HEADER a,b will cause a
seg fault.

MT.zip

@TG9541
Copy link
Owner Author

TG9541 commented Aug 11, 2019

Great info, thanks Ken!

Using the notation ^/"..."/ mostly works, but it leaves the special case of HEADER STRCQ ^/"$,""/ which results in the following error message:

forth.asm:3410: Error: <q> missing or improper operators, terminators, or delimiters

Encoding $," as '$\054"' works.

EDIT: encoding as HEADER STRCQ ^/'$,"'/ works, too!

@TG9541 TG9541 reopened this Aug 11, 2019
@TG9541 TG9541 changed the title Apply workaround for ASxxxx macro bug Apply workaround for ASxxxx macro problem Aug 11, 2019
@TG9541 TG9541 mentioned this issue Aug 11, 2019
@TG9541 TG9541 closed this as completed in bf903c8 Aug 11, 2019
@TG9541 TG9541 self-assigned this Aug 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants