1
0
mirror of synced 2024-11-25 14:34:22 +01:00

IJMP & ICALL

This commit is contained in:
Christian Dietrich 2014-09-28 23:21:43 +02:00
parent 154366010f
commit d59eab62e6
2 changed files with 59 additions and 8 deletions

View File

@ -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{%

22
tests/func-ptr.c Normal file
View File

@ -0,0 +1,22 @@
#include <avr/io.h>
// 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:
*/