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 a switch macro #1

Open
jpelletier opened this issue Jun 17, 2013 · 0 comments
Open

Add a switch macro #1

jpelletier opened this issue Jun 17, 2013 · 0 comments

Comments

@jpelletier
Copy link

These macros specific for the AVR microcontrollers add a switch construct

;;;-----------------------------------------------------------------
;;; Switch
;;; _sw_case R16-31,Value
;;; _case R16-31,Value
;;; _break_sw
;;; _default
;;; _end_sw
;;;-----------------------------------------------------------------
.macro _sw_case REG VALUE
cpi \REG,\VALUE
.set __ST_IFNEST, __ST_IFNEST+2
_st_mkjmp _st_jmp_not_eq, %__ST_IFNEST, f
.endm

.macro _break_sw
_st_mkjmp _st_jmp_always, %__ST_IFNEST+1, f
.endm

.macro _case REG VALUE
_st_label %__ST_IFNEST
cpi \REG,\VALUE
_st_mkjmp _st_jmp_not_eq, %__ST_IFNEST, f
.endm

.macro _default
_st_label %__ST_IFNEST
.endm

.macro _end_sw
_st_label %__ST_IFNEST
_st_label %__ST_IFNEST+1
.set __ST_IFNEST, __ST_IFNEST-2
.endm

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

No branches or pull requests

1 participant