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

Add preprocessor macros #62

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

imrehorvath
Copy link

@imrehorvath imrehorvath commented May 26, 2023

Add initial implementation of AVRASM2 style preprocessor macros. It is not yet a full implementation. However it does support the following.

.device atmega328p

#define EIGHT (1 << 3)
#define SQR(X) ((X)*(X))

ldi r16, EIGHT
ldi r16, SQR(4)

#define FOOBAR subi
#define IMMED(X) X##i
#define SUBI(X,Y) X ## Y

IMMED(ld) r16, 1
SUBI(FOO, BAR) r16, 1

IMMED(ld) r16, SQR(SQR(1+1))

Regression test provided, all passing.

cd tests/regression && ./runtests.sh

Testing p36-invalid-inequality-operator
PASSED

Testing pr16
PASSED

Testing pr31
HEX file ok
EEPROM file ok
PASSED

Testing pr36-invalid-equality-operator
PASSED

Testing pr36-valid-binary-operators
HEX file ok
EEPROM file ok
PASSED

Testing preprocessor-macros
HEX file ok
No expected EEPROM file found
PASSED

Testing test1
HEX file ok
EEPROM file ok
PASSED

Testing test2
HEX file ok
EEPROM file ok
PASSED

8 tests, 0 failed

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

Successfully merging this pull request may close these issues.

1 participant