2014-09-28 16:52:56 +02:00
|
|
|
%%
|
|
|
|
%% The IO Subsystem
|
|
|
|
%%
|
|
|
|
|
2014-09-28 22:53:22 +02:00
|
|
|
\def\avr@io@init{%
|
|
|
|
\def\avr@UDR{}%
|
|
|
|
}
|
|
|
|
|
2014-09-28 16:52:56 +02:00
|
|
|
% OUT
|
2014-09-29 00:47:17 +02:00
|
|
|
\def\avr@instr@OUT#1#2#3{% A, R
|
|
|
|
\def\@@A{#2}
|
|
|
|
\avr@bin@msb@del{\@@A}{\@@A}{\@@a}%
|
|
|
|
\avr@bin@msb@del{\@@A}{\@@A}{\@@b}%
|
|
|
|
\avr@code@set{10111\@@a\@@b#3\@@A}{#1}%
|
|
|
|
}
|
|
|
|
|
2014-09-28 16:52:56 +02:00
|
|
|
\csdef{avr@instr@10111}#1#2#3#4#5#6#7#8\@nnil{%
|
|
|
|
\def\@@A{#1#2#8}%
|
|
|
|
\avr@reg@get{#3#4#5#6#7}{\avr@Rr}%
|
|
|
|
\avr@debug{OUT \@@A <- \avr@Rr}%
|
|
|
|
\avr@io@set{\avr@Rr}{\@@A}%
|
|
|
|
\avr@pc@inc%
|
|
|
|
}
|
|
|
|
|
2014-09-29 20:39:23 +02:00
|
|
|
% OUT
|
|
|
|
\def\avr@instr@IN#1#2#3{% A, R
|
|
|
|
\def\@@A{#2}
|
|
|
|
\avr@bin@msb@del{\@@A}{\@@A}{\@@a}%
|
|
|
|
\avr@bin@msb@del{\@@A}{\@@A}{\@@b}%
|
|
|
|
\avr@code@set{10110\@@a\@@b#3\@@A}{#1}%
|
|
|
|
}
|
|
|
|
|
|
|
|
\csdef{avr@instr@10110}#1#2#3#4#5#6#7#8\@nnil{%
|
|
|
|
\avr@debug{IN #1#2#8 -> #3#4#5#6#7}%
|
|
|
|
\edef\@@IOA{#1#2#8}%
|
|
|
|
\avr@io@get{\@@IOA}{\avr@Rr}%
|
|
|
|
\avr@reg@set{\avr@Rr}{#3#4#5#6#7}%
|
|
|
|
\avr@pc@inc%
|
|
|
|
}
|
|
|
|
|
2014-09-28 16:52:56 +02:00
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
% IO Handlers
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
% #1=Value, #2=Addr
|
|
|
|
\def\avr@io@set#1#2{%
|
|
|
|
\ifcsdef{avr@io@#2@set}{%
|
|
|
|
\csuse{avr@io@#2@set}{#1}%
|
|
|
|
}{%
|
|
|
|
\avr@io@set@default{#1}{#2}%
|
|
|
|
}%
|
|
|
|
}
|
|
|
|
% #1=Addr, #2=\result
|
|
|
|
\def\avr@io@get#1#2{%
|
2014-09-29 20:39:23 +02:00
|
|
|
\avr@debug{ IO R #1}%
|
2014-09-29 00:47:17 +02:00
|
|
|
\ifcsdef{avr@io@#1@get}{%
|
|
|
|
\csuse{avr@io@#1@get}{#2}%
|
2014-09-28 16:52:56 +02:00
|
|
|
}{%
|
|
|
|
\avr@io@get@default{#1}{#2}%
|
|
|
|
}%
|
|
|
|
}
|
|
|
|
|
|
|
|
\def\avr@io@set@default#1#2{%
|
|
|
|
\avr@error{IO Port #2 is not defined (OUT #1)}%
|
|
|
|
}
|
|
|
|
|
2014-09-29 00:47:17 +02:00
|
|
|
\def\avr@io@get@default#1#2{%
|
2014-09-29 20:39:23 +02:00
|
|
|
\avr@error{IO Port #1 is not defined (IN -> #2)}%
|
2014-09-29 00:47:17 +02:00
|
|
|
}
|
|
|
|
|
2014-09-28 16:52:56 +02:00
|
|
|
\csdef{avr@io@111111@set}#1{%
|
|
|
|
\avr@debug{ SREG=#1}%
|
|
|
|
\avr@sreg@set{#1}%
|
|
|
|
}
|
2014-09-29 20:39:23 +02:00
|
|
|
\csdef{avr@io@111111@get}#1{\avr@sreg@get{#1}}
|
2014-09-28 16:52:56 +02:00
|
|
|
|
2014-09-29 20:39:23 +02:00
|
|
|
% Stackpointer IO Ports
|
2014-09-28 16:52:56 +02:00
|
|
|
\csdef{avr@io@111110@set}#1{\avr@stack@SPH@set{#1}}
|
|
|
|
\csdef{avr@io@111101@set}#1{\avr@stack@SPL@set{#1}}
|
2014-09-29 20:39:23 +02:00
|
|
|
\csdef{avr@io@111110@get}#1{\avr@stack@SPH@get{#1}}
|
|
|
|
\csdef{avr@io@111101@get}#1{\avr@stack@SPL@get{#1}}
|
2014-09-28 16:52:56 +02:00
|
|
|
|
|
|
|
\csdef{avr@io@001100@set}#1{%
|
|
|
|
\avr@bin@tocount{#1}{\avr@count@tmpa}%
|
2014-09-28 22:53:22 +02:00
|
|
|
\avr@ascii{\the\avr@count@tmpa}{\@@char}%
|
2014-09-29 20:39:23 +02:00
|
|
|
\avr@debug{UDR: \the\avr@count@tmpa}%
|
2014-09-28 22:53:22 +02:00
|
|
|
\xdef\avr@UDR{\avr@UDR \@@char}%
|
2014-09-28 16:52:56 +02:00
|
|
|
}
|
|
|
|
|
2014-09-29 00:47:17 +02:00
|
|
|
% SPDR
|
|
|
|
\csdef{avr@io@001111@set}#1{%
|
|
|
|
\csdef{avr@io@001111}{#1}%
|
|
|
|
}
|
|
|
|
|
|
|
|
\csdef{avr@io@001111@get}#1{%
|
|
|
|
\xdef#1{\csuse{avr@io@001111}}%
|
|
|
|
}
|
2014-09-28 16:52:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
%%% Local Variables:
|
|
|
|
%%% mode: latex
|
|
|
|
%%% TeX-master: "avr.tex"
|
|
|
|
%%% End:
|