From d59eab62e63217430047eb337ddbabbe9cb6f9c0 Mon Sep 17 00:00:00 2001 From: Christian Dietrich Date: Sun, 28 Sep 2014 23:21:43 +0200 Subject: [PATCH] IJMP & ICALL --- avr.instr.tex | 45 +++++++++++++++++++++++++++++++++++++-------- tests/func-ptr.c | 22 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 tests/func-ptr.c diff --git a/avr.instr.tex b/avr.instr.tex index 233d90c..3ac2925 100644 --- a/avr.instr.tex +++ b/avr.instr.tex @@ -544,14 +544,8 @@ } % RCALL -\csdef{avr@instr@1101}#1\@nnil{ - \avr@count@tobin@w{\the\avr@pc}{\@@pc}% - \avr@instr@rjump@dec{#1}{\avr@count@tmpa}% - \avr@reg@get{\csuse{avr@r24}}{\@@A}% - \avr@reg@get{\csuse{avr@r25}}{\@@B}% - \avr@reg@get{\csuse{avr@r26}}{\@@C}% - \avr@debug{RCALL \the\avr@count@tmpa {r24:\@@A} {r25:\@@B} {r26:\@@C}}% - \avr@pc@add{\avr@count@tmpa}% +\def\avr@CALL@helper#1{% + \edef\@@pc{#1}% \avr@bin@word@low{\@@pc}{\@@low}% \avr@bin@word@high{\@@pc}{\@@high}% \avr@mem@set{\@@low}{\the\avr@stackptr}% @@ -561,6 +555,41 @@ \avr@pc@inc% \avr@debug{ done}% } +\csdef{avr@instr@1101}#1\@nnil{ + \avr@count@tobin@w{\the\avr@pc}{\@@pc}% + \avr@instr@rjump@dec{#1}{\avr@count@tmpa}% + \avr@reg@get{\csuse{avr@r24}}{\@@A}% + \avr@reg@get{\csuse{avr@r25}}{\@@B}% + \avr@reg@get{\csuse{avr@r26}}{\@@C}% + \avr@debug{ICALL \the\avr@count@tmpa {r24:\@@A} {r25:\@@B} {r26:\@@C}}% + \avr@CALL@helper{\@@pc}% + \avr@pc@add{\avr@count@tmpa}% +} + +\def\avr@instr@ICALL#1{\avr@code@set{1001010100001001}{#1}} +\csdef{avr@instr@1001010100001001}\@nnil{ + \avr@count@tobin@w{\the\avr@pc}{\@@pc}% + \avr@regw@get{\csuse{avr@Z}}{\@@addr} + \avr@bin@tocount{\@@addr}{\avr@addr}% + \avr@reg@get{\csuse{avr@r24}}{\@@A}% + \avr@reg@get{\csuse{avr@r25}}{\@@B}% + \avr@reg@get{\csuse{avr@r26}}{\@@C}% + \avr@debug{ICALL \the\avr@addr {r24:\@@A} {r25:\@@B} {r26:\@@C}}% + \avr@CALL@helper{\@@pc}% + \avr@pc=\avr@addr +} + +\def\avr@instr@IJMP#1{\avr@code@set{1001010000001001}{#1}} +\csdef{avr@instr@1001010000001001}\@nnil{ + \avr@count@tobin@w{\the\avr@pc}{\@@pc}% + \avr@regw@get{Z}{\@@addr} + \avr@bin@tocount{\@@addr}{\avr@addr}% + \avr@reg@get{\csuse{avr@r24}}{\@@A}% + \avr@reg@get{\csuse{avr@r25}}{\@@B}% + \avr@reg@get{\csuse{avr@r26}}{\@@C}% + \avr@debug{IJMP \the\avr@addr {r24:\@@A} {r25:\@@B} {r26:\@@C}}% + \avr@pc=\avr@addr +} % RET \def\avr@instr@RET#1{% diff --git a/tests/func-ptr.c b/tests/func-ptr.c new file mode 100644 index 0000000..e42f26d --- /dev/null +++ b/tests/func-ptr.c @@ -0,0 +1,22 @@ +#include + +// Produces LPM operations +__attribute__((noinline)) void bar() { + UDR='X'; +} +void (*foo)() = bar; + +int main() { + bar(); + foo(); + asm volatile ("break"); +} + +/* + check-name: Function Pointers + check-start: + \avr@instr@stepn{1000000} + + \avr@test@UDR{XX} + check-end: +*/