New Opcode: MUL, LPM, LDS, STS
This commit is contained in:
parent
17c77fe7e2
commit
154366010f
3
Makefile
Normal file
3
Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
test:
|
||||
pdflatex -halt-on-error avr.tex
|
||||
cd tests; ./test-suite
|
209
avr.instr.tex
209
avr.instr.tex
@ -3,7 +3,9 @@
|
||||
}
|
||||
|
||||
\def\avr@error#1{%
|
||||
\avr@dump%
|
||||
\errmessage{\the\avr@pc: #1}\bye%
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +19,14 @@
|
||||
% Dispatch Instruction by prefix
|
||||
\expandafter\avr@instr@dispatch\avr@instr@current\@nnil%
|
||||
\relax%
|
||||
|
||||
}
|
||||
|
||||
\def\avr@singlestep{%
|
||||
\avr@dump%
|
||||
\typein{Press Enter to Step}%
|
||||
\avr@instr@step%
|
||||
\avr@singlestep%
|
||||
}
|
||||
|
||||
\newcount\avr@instr@steps
|
||||
@ -26,8 +36,10 @@
|
||||
\ifnum \avr@instr@steps > 0%
|
||||
\advance \avr@instr@steps by -1\relax%
|
||||
\avr@instr@step%
|
||||
\avr@instr@stepn@helper%
|
||||
\else%
|
||||
\let\avr@instr@stepn@helper\relax%
|
||||
\fi%
|
||||
\avr@instr@stepn@helper%
|
||||
}%
|
||||
\avr@instr@stepn@helper%
|
||||
}
|
||||
@ -87,6 +99,16 @@
|
||||
\avr@error{Unkown Instruction: #1}%
|
||||
}%
|
||||
}
|
||||
|
||||
\def\avr@instr@length#1#2{% Addr, Length
|
||||
\avr@code@load{#1}{\@@code}%
|
||||
\avr@bin@and{\@@code}{1111110000001111}{\@@LDS}%
|
||||
\ifdefstring{\@@LDS}{1001000000000000}{%
|
||||
\def#2{2}%
|
||||
}{%
|
||||
\def#2{1}%
|
||||
}
|
||||
}
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Match also from end for these prefixes
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
@ -120,7 +142,6 @@
|
||||
\avr@code@set{#1#4#2}{#3}%
|
||||
}
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Arithmetic instructions
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
@ -227,7 +248,7 @@
|
||||
\avr@reg@get{#2#3#4#5#6}{\avr@Rd}%
|
||||
\avr@flag@get C \@@carry%
|
||||
\xdef \avr@instr@extracarry {\avr@bit@negate \@@carry}%
|
||||
\avr@debug{CP - #2#3#4#5#6(=\avr@Rd) - \%#1#7(=\avr@Rr)}%
|
||||
\avr@debug{CPC - #2#3#4#5#6(=\avr@Rd) - \%#1#7(=\avr@Rr)}%
|
||||
\csuse{avr@instr@subber@helper}%
|
||||
% Do not set the output register
|
||||
\avr@pc@inc%
|
||||
@ -268,7 +289,7 @@
|
||||
\@@or {\@@and \@@R \@@D}%
|
||||
{%
|
||||
\@@or{\@@and \@@R {\@@not \@@X}}%
|
||||
{\@@and \@@X {\@@not \@@D}}}}%
|
||||
{\@@and \@@D {\@@not \@@X}}}}%
|
||||
\avr@flag@set C {\avr@ADD@carry}%
|
||||
% Two's Complement Overflow
|
||||
\def\@@tmp{\@@or%
|
||||
@ -332,6 +353,32 @@
|
||||
\avr@flags@update \avr@Rx%
|
||||
}
|
||||
|
||||
% INC, DEC
|
||||
\def\avr@instr@INC#1#2{\avr@code@set{1001010#20011}{#1}}
|
||||
\csdef{avr@instr@1001010:0011}#1\@nnil{%
|
||||
\avr@instr@INCDEC@helper{#1}{1}%
|
||||
}
|
||||
\def\avr@instr@DEC#1#2{\avr@code@set{1001010#21010}{#1}}
|
||||
\csdef{avr@instr@1001010:1010}#1\@nnil{%
|
||||
\avr@instr@INCDEC@helper{#1}{-1}%
|
||||
}
|
||||
|
||||
\csdef{avr@instr@INCDEC@helper}#1#2{%
|
||||
\avr@reg@get{#1}{\avr@Rd}%
|
||||
\avr@debug{INCDEC #1(=\avr@Rd) +(#2)}%
|
||||
\avr@bin@tocount{\avr@Rd}{\avr@count@tmpa}%
|
||||
\advance \avr@count@tmpa by #2\relax%
|
||||
\avr@count@modulo@byte{\avr@count@tmpa}%
|
||||
\avr@count@tobin@b{\avr@count@tmpa}{\avr@Rx}%
|
||||
\ifdefstring{\avr@Rx}{01111111}{%
|
||||
\avr@flag@set V 1%
|
||||
}{%
|
||||
\avr@flag@set V 0%
|
||||
}%
|
||||
\avr@flags@update \avr@Rx%
|
||||
\avr@reg@set{\avr@Rx}{#1}%
|
||||
\avr@pc@inc%
|
||||
}
|
||||
|
||||
% LDI -- Load Immediate Value
|
||||
\def\avr@instr@LDI{\avr@instr@gen@regconst{1110}}
|
||||
@ -588,7 +635,7 @@
|
||||
\def\avr@instr@LDD@helper#1#2#3#4{%
|
||||
% PreIncrement, RegisterW, PostIncrement, Target
|
||||
\avr@regw@get{\csuse{avr@#2}}{\@@addr}%
|
||||
\avr@debug{LD *(#1:#2:#3,#2=\@@addr)}%
|
||||
\avr@debug{LD #4 <- *(#1:#2:#3,#2=\@@addr)}%
|
||||
\avr@bin@tocount{\@@addr}{\avr@addr}%
|
||||
\advance \avr@addr by #1\relax%
|
||||
\avr@count@overflow{\avr@addr}\relax%
|
||||
@ -605,7 +652,7 @@
|
||||
% PreIncrement, RegisterW, PostIncrement, SourceReg
|
||||
\avr@regw@get{\csuse{avr@#2}}{\@@addr}%
|
||||
\avr@reg@get{#4}{\avr@Rd}%
|
||||
\avr@debug{ST *(#1:#2:#3,#2=\@@addr)}%
|
||||
\avr@debug{ST #4 -> *(#1:#2:#3,#2=\@@addr)}%
|
||||
\avr@bin@tocount{\@@addr}{\avr@addr}%
|
||||
\advance \avr@addr by #1\relax%
|
||||
\avr@count@overflow{\avr@addr}\relax%
|
||||
@ -759,6 +806,108 @@
|
||||
\avr@pc@inc%
|
||||
}
|
||||
|
||||
% STS/LTS (16 Bit)
|
||||
\def\avr@instr@LDSS#1#2#3{%
|
||||
\avr@bin@nibble@low{0#3}{\@@low}%
|
||||
\avr@bin@nibble@high{0#3}{\@@high}%
|
||||
\avr@bin@msb@del{#2}{\@@dddd}{\@tempa}%
|
||||
\avr@code@set{1010\@@high\@@dddd\@@low}{#1}%
|
||||
}
|
||||
\def\avr@instr@STSS#1#2#3{%
|
||||
\avr@bin@nibble@low{1#3}{\@@low}%
|
||||
\avr@bin@nibble@high{1#3}{\@@high}%
|
||||
\avr@bin@msb@del{#2}{\@@dddd}{\@tempa}%
|
||||
\avr@code@set{1010\@@high\@@dddd\@@low}{#1}%
|
||||
}
|
||||
|
||||
\def\avr@instr@LDSTS#1#2#3#4#5#6#7#8\@nnil{%
|
||||
\avr@bin@tocount{{\avr@bit@negate #3}#3#1#2#8}{\avr@addr}%
|
||||
\def\avr@RD{1#4#5#6#7}%
|
||||
}
|
||||
\csdef{avr@instr@10010}#1\@nnil{%
|
||||
\avr@instr@LDSTS#1\@nnil%
|
||||
\avr@debug{LDS - \avr@RD <- (\the\avr@addr)}%
|
||||
\avr@mem@get{\the\avr@addr}{\@@value}%
|
||||
\avr@reg@set{\@@value}{\avr@RD}%
|
||||
\avr@pc@inc%
|
||||
}
|
||||
\csdef{avr@instr@10101}#1\@nnil{%
|
||||
\avr@instr@LDSTS#1\@nnil%
|
||||
\avr@debug{STS - \avr@RD <- (\the\avr@addr)}%
|
||||
\avr@reg@get{\avr@RD}{\@@value}%
|
||||
\avr@mem@set{\@@value}{\the\avr@addr}%
|
||||
\avr@pc@inc%
|
||||
}
|
||||
|
||||
% LDS/STS (FULL)
|
||||
\def\avr@instr@LDS#1#2#3{%
|
||||
\avr@code@set{1001000#20000}{#1}%
|
||||
\avr@count@tmpa=#1%
|
||||
\advance \avr@count@tmpa by 1\relax
|
||||
\avr@code@set{#3}{\the\avr@count@tmpa}%
|
||||
}
|
||||
|
||||
\def\avr@instr@STS#1#2#3{%
|
||||
\avr@code@set{1001001#20000}{#1}%
|
||||
\avr@count@tmpa=#1%
|
||||
\advance \avr@count@tmpa by 1\relax
|
||||
\avr@code@set{#3}{\the\avr@count@tmpa}%
|
||||
}
|
||||
|
||||
\csdef{avr@instr@1001001:0000}#1\@nnil{%
|
||||
\avr@pc@inc%
|
||||
\avr@code@get{\@@addr}%
|
||||
\avr@reg@get{#1}{\@@value}%
|
||||
\avr@bin@tocount{\@@addr}{\avr@addr}%
|
||||
\avr@debug{STS - #1 -> (\the\avr@addr)}%
|
||||
\avr@mem@set{\@@value}{\the\avr@addr}%
|
||||
\avr@pc@inc%
|
||||
}
|
||||
\csdef{avr@instr@1001000:0000}#1\@nnil{%
|
||||
\avr@pc@inc%
|
||||
\avr@code@get{\@@addr}%
|
||||
\avr@bin@tocount{\@@addr}{\avr@addr}%
|
||||
\avr@debug{LDS - #1 <- (\the\avr@addr)}%
|
||||
\avr@mem@get{\the\avr@addr}{\@@value}%
|
||||
\avr@reg@set{\@@value}{#1}%
|
||||
\avr@pc@inc%
|
||||
}
|
||||
|
||||
% LPM Commands
|
||||
\def\avr@instr@LPM#1{\avr@code@set{1001010111001000}{#1}}
|
||||
\def\avr@instr@LPMZ{\avr@instr@gen@onereg{1001000}{0100}}
|
||||
\def\avr@instr@LPMZp{\avr@instr@gen@onereg{1001000}{0101}}
|
||||
|
||||
\csdef{avr@instr@1001010111001000}\@nnil{%
|
||||
\avr@LPM@helper{00000}{0}%
|
||||
}
|
||||
\csdef{avr@instr@1001000:0100}#1\@nnil{%
|
||||
\avr@LPM@helper{#1}{0}%
|
||||
}
|
||||
\csdef{avr@instr@1001000:0101}#1\@nnil{%
|
||||
\avr@LPM@helper{#1}{1}%
|
||||
}
|
||||
\def\avr@LPM@helper#1#2{%
|
||||
\avr@regw@get{\csuse{avr@Z}}{\@@addr}%
|
||||
\avr@bin@lsb@del{\@@addr}{\@@instr}{\@@switch}%
|
||||
\avr@bin@tocount{0\@@instr}{\avr@addr}%
|
||||
\avr@code@load{\the\avr@addr}{\@@code}%
|
||||
\avr@debug{LPM #1 <- code(\the\avr@addr)+\@@switch+#2}%
|
||||
% Increment
|
||||
\avr@bin@tocount{\@@addr}{\avr@addr}%
|
||||
\advance \avr@addr by #2\relax%
|
||||
\avr@count@tobin@w{\avr@addr}{\@@addr}%
|
||||
\avr@regw@set{\@@addr}{\csuse{avr@Z}}%
|
||||
\expandafter \ifnum \@@switch = 1%
|
||||
\avr@bin@word@high{\@@code}{\@@value}%
|
||||
\else%
|
||||
\avr@bin@word@low{\@@code}{\@@value}%
|
||||
\fi%
|
||||
\avr@reg@set{\@@value}{#1}%
|
||||
\avr@pc@inc%
|
||||
}
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Misc
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
@ -961,8 +1110,11 @@
|
||||
\avr@count@tmpa=\@@found%
|
||||
\avr@count@tmpb=\@@required\relax%
|
||||
\ifnum \avr@count@tmpa = \avr@count@tmpb%
|
||||
\avr@debug{SKIP one instruction}%
|
||||
\avr@pc@inc%
|
||||
\avr@instr@length{\the\avr@pc}{\@@length}
|
||||
\avr@debug{SKIP (\@@length) instruction}%
|
||||
\avr@pc@add{\@@length}%
|
||||
\avr@pc@add{-1}%
|
||||
\fi%
|
||||
\avr@pc@inc%
|
||||
}
|
||||
@ -1010,6 +1162,49 @@
|
||||
\avr@pc@inc%
|
||||
}
|
||||
|
||||
\def\avr@instr@SWAP#1#2{\avr@code@set{1001010#20010}{#1}}
|
||||
\csdef{avr@instr@1001010:0010}#1\@nnil{%
|
||||
\avr@reg@get{#1}{\avr@Rr}%
|
||||
\avr@debug{SWAP: #1(=\avr@Rr)}%
|
||||
\avr@bin@nibble@low{\avr@Rr}{\@@low}%
|
||||
\avr@bin@nibble@high{\avr@Rr}{\@@high}%
|
||||
\avr@reg@set{\@@low \@@high}{#1}%
|
||||
\avr@pc@inc%
|
||||
}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Multiplication Commands
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% MUL -- Multiply Unsigned Integers
|
||||
\newcount\avr@MUL@A
|
||||
\newcount\avr@MUL@B
|
||||
|
||||
\def\avr@instr@MUL{\avr@instr@gen@tworegs{100111}}
|
||||
\csdef{avr@instr@100111}#1#2#3#4#5#6#7\@nnil{%
|
||||
\avr@reg@get{#1#7}{\avr@Rr}%
|
||||
\avr@reg@get{#2#3#4#5#6}{\avr@Rd}%
|
||||
\avr@bin@tocount{\avr@Rr}{\avr@MUL@A}
|
||||
\avr@bin@tocount{\avr@Rd}{\avr@MUL@B}
|
||||
\avr@debug{MUL - \the\avr@MUL@A * \the\avr@MUL@B}%
|
||||
\multiply \avr@MUL@A by \avr@MUL@B\relax%
|
||||
\avr@count@tobin@w{\avr@MUL@A}{\avr@Rx}%
|
||||
\avr@bin@word@low{\avr@Rx}{\@@low}%
|
||||
\avr@bin@word@high{\avr@Rx}{\@@high}%
|
||||
\avr@reg@set{\@@low}{\csuse{avr@r0}}%
|
||||
\avr@reg@set{\@@high}{\csuse{avr@r1}}%
|
||||
% Flags
|
||||
\avr@bin@msb@get{\avr@Rx}{\@@carry}%
|
||||
\avr@flag@set C \@@carry%
|
||||
\ifdefstring{\avr@Rx}{0000000000000000}{%
|
||||
\avr@flag@set Z 1%
|
||||
}{%
|
||||
\avr@flag@set Z 0%
|
||||
}%
|
||||
% Do not set the output register
|
||||
\avr@pc@inc%
|
||||
}
|
||||
|
||||
|
||||
%%% Local Variables:
|
||||
%%% mode: latex
|
||||
%%% TeX-master: "avr.tex"
|
||||
|
@ -2,6 +2,10 @@
|
||||
%% The IO Subsystem
|
||||
%%
|
||||
|
||||
\def\avr@io@init{%
|
||||
\def\avr@UDR{}%
|
||||
}
|
||||
|
||||
% OUT
|
||||
\csdef{avr@instr@10111}#1#2#3#4#5#6#7#8\@nnil{%
|
||||
\def\@@A{#1#2#8}%
|
||||
@ -44,11 +48,11 @@
|
||||
\csdef{avr@io@111110@set}#1{\avr@stack@SPH@set{#1}}
|
||||
\csdef{avr@io@111101@set}#1{\avr@stack@SPL@set{#1}}
|
||||
|
||||
\def\avr@UDR#1{\relax}
|
||||
\csdef{avr@io@001100@set}#1{%
|
||||
\avr@bin@tocount{#1}{\avr@count@tmpa}%
|
||||
\avr@ascii{\the\avr@count@tmpa}{\@@char}%
|
||||
\avr@debug{UDR: #1=\the\avr@count@tmpa}%
|
||||
\def\avr@UDR{#1}%
|
||||
\xdef\avr@UDR{\avr@UDR \@@char}%
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
\avr@reg@init%
|
||||
\avr@pc@init%
|
||||
\avr@stack@init%
|
||||
\avr@mem@init{1024}%
|
||||
\avr@io@init%
|
||||
}
|
||||
|
||||
\newcount\avr@accA
|
||||
@ -52,6 +54,31 @@
|
||||
\end{tabular}
|
||||
}
|
||||
|
||||
\def\avr@dump{%
|
||||
\avr@sreg@get{\@@X} \avr@debug{SREG::='\@@X' (ITHS VNZC)}
|
||||
\def\avr@dump@reg##1##2{%
|
||||
\avr@reg@get{\csuse{avr@##1}}{\@@X}%
|
||||
\avr@bin@tocount{\@@X}{\avr@count@tmpa}%
|
||||
\edef##2{##1=\the\avr@count@tmpa}%
|
||||
}%
|
||||
\def\avr@dump@row##1##2##3##4{%
|
||||
\avr@dump@reg{##1}{\@@A}%
|
||||
\avr@dump@reg{##2}{\@@B}%
|
||||
\avr@dump@reg{##3}{\@@C}%
|
||||
\avr@dump@reg{##4}{\@@D}%
|
||||
\avr@debug{(\@@A) (\@@B) (\@@C) (\@@D)}%
|
||||
}%
|
||||
\avr@dump@row{r0}{r1}{r2}{r3}%
|
||||
\avr@dump@row{r4}{r5}{r6}{r7}%
|
||||
\avr@dump@row{r8}{r9}{r10}{r11}%
|
||||
\avr@dump@row{r12}{r13}{r14}{r15}%
|
||||
\avr@dump@row{r16}{r17}{r18}{r19}%
|
||||
\avr@dump@row{r20}{r21}{r22}{r23}%
|
||||
\avr@dump@row{r24}{r25}{r26}{r27}%
|
||||
\avr@dump@row{r28}{r29}{r30}{r31}%
|
||||
}
|
||||
|
||||
|
||||
%% Status Register && Flags
|
||||
\def\avr@flag@set#1#2{% Register Name, Value \in 0,1
|
||||
\csxdef{avr@flag@#1}{#2}\relax%
|
||||
@ -226,6 +253,10 @@
|
||||
\edef#1{\csuse{avr@code@\the\avr@pc}}%
|
||||
}
|
||||
|
||||
\def\avr@code@load#1#2{% Result Macro
|
||||
\edef#2{\csuse{avr@code@#1}}%
|
||||
}
|
||||
|
||||
\def\avr@code@set#1#2{% OpString (16 Bit), Number
|
||||
\csxdef{avr@code@#2}{#1}%
|
||||
}
|
||||
@ -258,6 +289,20 @@
|
||||
\avr@debug{ SP=\the\avr@stackptr}
|
||||
}
|
||||
|
||||
\def\avr@mem@init#1{%
|
||||
\avr@count@tmpa = #1\relax
|
||||
\def\avr@mem@init@helper{%
|
||||
\ifnum \avr@count@tmpa > 0
|
||||
\csxdef{avr@mem@\the\avr@count@tmpa}{00000000}%
|
||||
\advance \avr@count@tmpa by -1\relax%
|
||||
\else%
|
||||
\let \avr@mem@init@helper \relax%
|
||||
\fi%
|
||||
\avr@mem@init@helper%
|
||||
}%
|
||||
\avr@mem@init@helper%
|
||||
}
|
||||
|
||||
\def\avr@mem@set#1#2{% Bitstring, Address (as number)
|
||||
\ifnum #2 < 96 % 0x60
|
||||
% FIXME
|
||||
@ -267,6 +312,7 @@
|
||||
\csxdef{avr@mem@#2}{#1}%
|
||||
}
|
||||
|
||||
|
||||
\def\avr@mem@get#1#2{% Address (as number), Target Macro
|
||||
\ifnum #1 < 96 % 0x60
|
||||
% FIXME
|
||||
|
275
avr.numbers.tex
275
avr.numbers.tex
@ -359,25 +359,286 @@
|
||||
\def\avr@count@overflow#1{%
|
||||
\def\avr@count@overflow@flag{0}%
|
||||
\ifnum #1 < 0%
|
||||
#1=65535%
|
||||
\advance #1 by 65535%
|
||||
\def\avr@count@overflow@flag{1}%
|
||||
\fi%
|
||||
\ifnum #1 > 65535%
|
||||
#1=0%
|
||||
\advance #1 by -65535%
|
||||
\def\avr@count@overflow@flag{1}%
|
||||
\fi%
|
||||
}
|
||||
|
||||
\def\avr@count@modulo@byte#1{%
|
||||
\avr@count@tmpa=#1%
|
||||
\divide \avr@count@tmpa by 256%
|
||||
\multiply \avr@count@tmpa by 256%
|
||||
\advance #1 by -\avr@count@tmpa%
|
||||
\avr@count@tmpa=#1\relax%
|
||||
\avr@count@tmpb=#1\relax%
|
||||
\divide \avr@count@tmpa by 256\relax%
|
||||
\multiply \avr@count@tmpa by 256\relax%
|
||||
\advance \avr@count@tmpb by -\avr@count@tmpa\relax%
|
||||
#1 = \avr@count@tmpb\relax%
|
||||
}
|
||||
|
||||
\def\avr@ascii@def#1#2{\csdef{avr@ascii@#1}{\detokenize{#2}}}
|
||||
\def\avr@ascii#1#2{\def#2{\csuse{avr@ascii@#1}}}
|
||||
|
||||
\avr@ascii@def{0}{^0}
|
||||
\avr@ascii@def{1}{^1}
|
||||
\avr@ascii@def{2}{^2}
|
||||
\avr@ascii@def{3}{^3}
|
||||
\avr@ascii@def{4}{^4}
|
||||
\avr@ascii@def{5}{^5}
|
||||
\avr@ascii@def{6}{^6}
|
||||
\avr@ascii@def{7}{^7}
|
||||
\avr@ascii@def{8}{^8}
|
||||
\avr@ascii@def{9}{^9}
|
||||
\avr@ascii@def{10}{^10}
|
||||
\avr@ascii@def{11}{^11}
|
||||
\avr@ascii@def{12}{^12}
|
||||
\avr@ascii@def{13}{^13}
|
||||
\avr@ascii@def{14}{^14}
|
||||
\avr@ascii@def{15}{^15}
|
||||
\avr@ascii@def{16}{^16}
|
||||
\avr@ascii@def{17}{^17}
|
||||
\avr@ascii@def{18}{^18}
|
||||
\avr@ascii@def{19}{^19}
|
||||
\avr@ascii@def{20}{^20}
|
||||
\avr@ascii@def{21}{^21}
|
||||
\avr@ascii@def{22}{^22}
|
||||
\avr@ascii@def{23}{^23}
|
||||
\avr@ascii@def{24}{^24}
|
||||
\avr@ascii@def{25}{^25}
|
||||
\avr@ascii@def{26}{^26}
|
||||
\avr@ascii@def{27}{^27}
|
||||
\avr@ascii@def{28}{^28}
|
||||
\avr@ascii@def{29}{^29}
|
||||
\avr@ascii@def{30}{^30}
|
||||
\avr@ascii@def{31}{^31}
|
||||
\avr@ascii@def{32}{ }
|
||||
\avr@ascii@def{33}{!}
|
||||
\avr@ascii@def{34}{"}
|
||||
\avr@ascii@def{35}{\#}
|
||||
\avr@ascii@def{36}{\$}
|
||||
\avr@ascii@def{37}{\%}
|
||||
\avr@ascii@def{38}{\&}
|
||||
\avr@ascii@def{39}{'}
|
||||
\avr@ascii@def{40}{(}
|
||||
\avr@ascii@def{41}{)}
|
||||
\avr@ascii@def{42}{*}
|
||||
\avr@ascii@def{43}{+}
|
||||
\avr@ascii@def{44}{,}
|
||||
\avr@ascii@def{45}{-}
|
||||
\avr@ascii@def{46}{.}
|
||||
\avr@ascii@def{47}{/}
|
||||
\avr@ascii@def{48}{0}
|
||||
\avr@ascii@def{49}{1}
|
||||
\avr@ascii@def{50}{2}
|
||||
\avr@ascii@def{51}{3}
|
||||
\avr@ascii@def{52}{4}
|
||||
\avr@ascii@def{53}{5}
|
||||
\avr@ascii@def{54}{6}
|
||||
\avr@ascii@def{55}{7}
|
||||
\avr@ascii@def{56}{8}
|
||||
\avr@ascii@def{57}{9}
|
||||
\avr@ascii@def{58}{:}
|
||||
\avr@ascii@def{59}{;}
|
||||
\avr@ascii@def{60}{<}
|
||||
\avr@ascii@def{61}{=}
|
||||
\avr@ascii@def{62}{>}
|
||||
\avr@ascii@def{63}{?}
|
||||
\avr@ascii@def{64}{@}
|
||||
\avr@ascii@def{65}{A}
|
||||
\avr@ascii@def{66}{B}
|
||||
\avr@ascii@def{67}{C}
|
||||
\avr@ascii@def{68}{D}
|
||||
\avr@ascii@def{69}{E}
|
||||
\avr@ascii@def{70}{F}
|
||||
\avr@ascii@def{71}{G}
|
||||
\avr@ascii@def{72}{H}
|
||||
\avr@ascii@def{73}{I}
|
||||
\avr@ascii@def{74}{J}
|
||||
\avr@ascii@def{75}{K}
|
||||
\avr@ascii@def{76}{L}
|
||||
\avr@ascii@def{77}{M}
|
||||
\avr@ascii@def{78}{N}
|
||||
\avr@ascii@def{79}{O}
|
||||
\avr@ascii@def{80}{P}
|
||||
\avr@ascii@def{81}{Q}
|
||||
\avr@ascii@def{82}{R}
|
||||
\avr@ascii@def{83}{S}
|
||||
\avr@ascii@def{84}{T}
|
||||
\avr@ascii@def{85}{U}
|
||||
\avr@ascii@def{86}{V}
|
||||
\avr@ascii@def{87}{W}
|
||||
\avr@ascii@def{88}{X}
|
||||
\avr@ascii@def{89}{Y}
|
||||
\avr@ascii@def{90}{Z}
|
||||
\avr@ascii@def{91}{[}
|
||||
\avr@ascii@def{92}{\char92}
|
||||
\avr@ascii@def{93}{]}
|
||||
\avr@ascii@def{94}{^}
|
||||
\avr@ascii@def{95}{_}
|
||||
\avr@ascii@def{96}{`}
|
||||
\avr@ascii@def{97}{a}
|
||||
\avr@ascii@def{98}{b}
|
||||
\avr@ascii@def{99}{c}
|
||||
\avr@ascii@def{100}{d}
|
||||
\avr@ascii@def{101}{e}
|
||||
\avr@ascii@def{102}{f}
|
||||
\avr@ascii@def{103}{g}
|
||||
\avr@ascii@def{104}{h}
|
||||
\avr@ascii@def{105}{i}
|
||||
\avr@ascii@def{106}{j}
|
||||
\avr@ascii@def{107}{k}
|
||||
\avr@ascii@def{108}{l}
|
||||
\avr@ascii@def{109}{m}
|
||||
\avr@ascii@def{110}{n}
|
||||
\avr@ascii@def{111}{o}
|
||||
\avr@ascii@def{112}{p}
|
||||
\avr@ascii@def{113}{q}
|
||||
\avr@ascii@def{114}{r}
|
||||
\avr@ascii@def{115}{s}
|
||||
\avr@ascii@def{116}{t}
|
||||
\avr@ascii@def{117}{u}
|
||||
\avr@ascii@def{118}{v}
|
||||
\avr@ascii@def{119}{w}
|
||||
\avr@ascii@def{120}{x}
|
||||
\avr@ascii@def{121}{y}
|
||||
\avr@ascii@def{122}{z}
|
||||
\avr@ascii@def{123}{{}
|
||||
\avr@ascii@def{124}{|}
|
||||
\avr@ascii@def{125}{}}
|
||||
\avr@ascii@def{126}{~}
|
||||
\avr@ascii@def{127}{^?}
|
||||
\avr@ascii@def{128}{^128}
|
||||
\avr@ascii@def{129}{^129}
|
||||
\avr@ascii@def{130}{^130}
|
||||
\avr@ascii@def{131}{^131}
|
||||
\avr@ascii@def{132}{^131}
|
||||
\avr@ascii@def{133}{^133}
|
||||
\avr@ascii@def{134}{^134}
|
||||
\avr@ascii@def{135}{^135}
|
||||
\avr@ascii@def{136}{^136}
|
||||
\avr@ascii@def{137}{^137}
|
||||
\avr@ascii@def{138}{^138}
|
||||
\avr@ascii@def{139}{^139}
|
||||
\avr@ascii@def{140}{^140}
|
||||
\avr@ascii@def{141}{^141}
|
||||
\avr@ascii@def{142}{^142}
|
||||
\avr@ascii@def{143}{^143}
|
||||
\avr@ascii@def{144}{^144}
|
||||
\avr@ascii@def{145}{^145}
|
||||
\avr@ascii@def{146}{^146}
|
||||
\avr@ascii@def{147}{^147}
|
||||
\avr@ascii@def{148}{^148}
|
||||
\avr@ascii@def{149}{^149}
|
||||
\avr@ascii@def{150}{^150}
|
||||
\avr@ascii@def{151}{^151}
|
||||
\avr@ascii@def{152}{^152}
|
||||
\avr@ascii@def{153}{^153}
|
||||
\avr@ascii@def{154}{^154}
|
||||
\avr@ascii@def{155}{^155}
|
||||
\avr@ascii@def{156}{^156}
|
||||
\avr@ascii@def{157}{^157}
|
||||
\avr@ascii@def{158}{^158}
|
||||
\avr@ascii@def{159}{^159}
|
||||
\avr@ascii@def{160}{^160}
|
||||
\avr@ascii@def{161}{¡}
|
||||
\avr@ascii@def{162}{¢}
|
||||
\avr@ascii@def{163}{£}
|
||||
\avr@ascii@def{164}{¤}
|
||||
\avr@ascii@def{165}{¥}
|
||||
\avr@ascii@def{166}{¦}
|
||||
\avr@ascii@def{167}{§}
|
||||
\avr@ascii@def{168}{¨}
|
||||
\avr@ascii@def{169}{©}
|
||||
\avr@ascii@def{170}{ª}
|
||||
\avr@ascii@def{171}{«}
|
||||
\avr@ascii@def{172}{¬}
|
||||
\avr@ascii@def{173}{^173}
|
||||
\avr@ascii@def{174}{®}
|
||||
\avr@ascii@def{175}{¯}
|
||||
\avr@ascii@def{176}{°}
|
||||
\avr@ascii@def{177}{±}
|
||||
\avr@ascii@def{178}{²}
|
||||
\avr@ascii@def{179}{³}
|
||||
\avr@ascii@def{180}{´}
|
||||
\avr@ascii@def{181}{µ}
|
||||
\avr@ascii@def{182}{¶}
|
||||
\avr@ascii@def{183}{·}
|
||||
\avr@ascii@def{184}{¸}
|
||||
\avr@ascii@def{185}{¹}
|
||||
\avr@ascii@def{186}{º}
|
||||
\avr@ascii@def{187}{»}
|
||||
\avr@ascii@def{188}{¼}
|
||||
\avr@ascii@def{189}{½}
|
||||
\avr@ascii@def{190}{¾}
|
||||
\avr@ascii@def{191}{¿}
|
||||
\avr@ascii@def{192}{À}
|
||||
\avr@ascii@def{193}{Á}
|
||||
\avr@ascii@def{194}{Â}
|
||||
\avr@ascii@def{195}{Ã}
|
||||
\avr@ascii@def{196}{Ä}
|
||||
\avr@ascii@def{197}{Å}
|
||||
\avr@ascii@def{198}{Æ}
|
||||
\avr@ascii@def{199}{Ç}
|
||||
\avr@ascii@def{200}{È}
|
||||
\avr@ascii@def{201}{É}
|
||||
\avr@ascii@def{202}{Ê}
|
||||
\avr@ascii@def{203}{Ë}
|
||||
\avr@ascii@def{204}{Ì}
|
||||
\avr@ascii@def{205}{Í}
|
||||
\avr@ascii@def{206}{Î}
|
||||
\avr@ascii@def{207}{Ï}
|
||||
\avr@ascii@def{208}{Ð}
|
||||
\avr@ascii@def{209}{Ñ}
|
||||
\avr@ascii@def{210}{Ò}
|
||||
\avr@ascii@def{211}{Ó}
|
||||
\avr@ascii@def{212}{Ô}
|
||||
\avr@ascii@def{213}{Õ}
|
||||
\avr@ascii@def{214}{Ö}
|
||||
\avr@ascii@def{215}{×}
|
||||
\avr@ascii@def{216}{Ø}
|
||||
\avr@ascii@def{217}{Ù}
|
||||
\avr@ascii@def{218}{Ú}
|
||||
\avr@ascii@def{219}{Û}
|
||||
\avr@ascii@def{220}{Ü}
|
||||
\avr@ascii@def{221}{Ý}
|
||||
\avr@ascii@def{222}{Þ}
|
||||
\avr@ascii@def{223}{ß}
|
||||
\avr@ascii@def{224}{à}
|
||||
\avr@ascii@def{225}{á}
|
||||
\avr@ascii@def{226}{â}
|
||||
\avr@ascii@def{227}{ã}
|
||||
\avr@ascii@def{228}{ä}
|
||||
\avr@ascii@def{229}{å}
|
||||
\avr@ascii@def{230}{æ}
|
||||
\avr@ascii@def{231}{ç}
|
||||
\avr@ascii@def{232}{è}
|
||||
\avr@ascii@def{233}{é}
|
||||
\avr@ascii@def{234}{ê}
|
||||
\avr@ascii@def{235}{ë}
|
||||
\avr@ascii@def{236}{ì}
|
||||
\avr@ascii@def{237}{í}
|
||||
\avr@ascii@def{238}{î}
|
||||
\avr@ascii@def{239}{ï}
|
||||
\avr@ascii@def{240}{ð}
|
||||
\avr@ascii@def{241}{ñ}
|
||||
\avr@ascii@def{242}{ò}
|
||||
\avr@ascii@def{243}{ó}
|
||||
\avr@ascii@def{244}{ô}
|
||||
\avr@ascii@def{245}{õ}
|
||||
\avr@ascii@def{246}{ö}
|
||||
\avr@ascii@def{247}{÷}
|
||||
\avr@ascii@def{248}{ø}
|
||||
\avr@ascii@def{249}{ù}
|
||||
\avr@ascii@def{250}{ú}
|
||||
\avr@ascii@def{251}{û}
|
||||
\avr@ascii@def{252}{ü}
|
||||
\avr@ascii@def{253}{ý}
|
||||
\avr@ascii@def{254}{þ}
|
||||
\avr@ascii@def{255}{ÿ}
|
||||
|
||||
|
||||
%%% Local Variables:
|
||||
%%% mode: latex
|
||||
%%% TeX-master: t
|
||||
%%% TeX-master: "avr.tex"
|
||||
%%% End:
|
||||
|
@ -29,6 +29,13 @@
|
||||
}%
|
||||
}
|
||||
|
||||
\def\avr@test@UDR#1{% Tests UDR output
|
||||
\ifdefstring{\avr@UDR}{#1}{%Success
|
||||
}{%
|
||||
\avr@error{UDR unequal: #1 != \avr@UDR}%
|
||||
}%
|
||||
}
|
||||
|
||||
% Hook Macro for the tests
|
||||
\def\avr@test{}
|
||||
|
||||
@ -432,11 +439,44 @@
|
||||
\avr@instr@stepn{2}%
|
||||
\avr@test@MEM{258}{00000000}
|
||||
\avr@test@MEM{257}{00000000}
|
||||
|
||||
|
||||
}
|
||||
\preto\avr@test{\avr@test@STZ}
|
||||
|
||||
\def\avr@test@SWAP{%
|
||||
\avr@test@setup{SWAP}%
|
||||
\avr@instr@LDI{0}{\csuse{avr@r20}}{00001001}%
|
||||
\avr@instr@SWAP{1}{\csuse{avr@r20}}%
|
||||
|
||||
\avr@instr@stepn{2}%
|
||||
\avr@test@REG{r20}{10010000}
|
||||
}
|
||||
\preto\avr@test{\avr@test@SWAP}
|
||||
|
||||
\def\avr@test@LDSS{%
|
||||
\avr@test@setup{LDS - STS}%
|
||||
\avr@instr@LDI{0}{\csuse{avr@r20}}{00001001}%
|
||||
\avr@instr@STSS{1}{\csuse{avr@r20}}{1101001}%
|
||||
\avr@instr@LDSS{2}{\csuse{avr@r21}}{1101001}%
|
||||
|
||||
\avr@instr@stepn{3}%
|
||||
\avr@test@REG{r21}{00001001}
|
||||
}
|
||||
\preto\avr@test{\avr@test@LDSS}
|
||||
|
||||
\def\avr@test@LDSS{%
|
||||
\avr@test@setup{LDS - STS (long)}%
|
||||
\avr@instr@LDI{0}{\csuse{avr@r20}}{00001001}%
|
||||
\avr@instr@STS{1}{\csuse{avr@r20}}{0000000011111111}%
|
||||
\avr@instr@LDS{3}{\csuse{avr@r21}}{0000000011111111}%
|
||||
\avr@instr@SBRC{5}{\csuse{avr@r0}}{011}% Skip always
|
||||
\avr@instr@LDS{6}{\csuse{avr@r20}}{0000000011110000}%
|
||||
\avr@instr@NOP{8}%
|
||||
|
||||
\avr@instr@stepn{5}%
|
||||
\avr@test@REG{r21}{00001001}
|
||||
}
|
||||
\preto\avr@test{\avr@test@LDSS}
|
||||
|
||||
%%% Local Variables:
|
||||
%%% mode: latex
|
||||
%%% TeX-master: "avr.tex"
|
||||
|
32
tests/mul.c
Normal file
32
tests/mul.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include <avr/io.h>
|
||||
|
||||
volatile char foo[30];
|
||||
|
||||
int main() {
|
||||
foo[0] = 23;
|
||||
foo[1] = 42;
|
||||
// Should produce a mul
|
||||
foo[2] = foo[0] * foo[1];
|
||||
|
||||
// Contains a decrement (8 Bit Dividend)
|
||||
foo[3] = (unsigned char)((unsigned char )foo[1] / (unsigned char)foo[0]);
|
||||
|
||||
foo[4] = foo[1] % foo[0];
|
||||
|
||||
asm volatile ("break");
|
||||
}
|
||||
|
||||
/*
|
||||
check-name: Complex Memory Operations
|
||||
check-start:
|
||||
\avr@instr@stepn{100000}
|
||||
|
||||
\avr@test@MEM{96}{00010111} % 23
|
||||
\avr@test@MEM{97}{00101010} % 42
|
||||
\avr@test@MEM{98}{11000110} % 198
|
||||
|
||||
\avr@test@MEM{99}{00000001} % 1
|
||||
\avr@test@MEM{100}{00010011} % 19
|
||||
|
||||
check-end:
|
||||
*/
|
22
tests/string.c
Normal file
22
tests/string.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <avr/io.h>
|
||||
|
||||
// Produces LPM operations
|
||||
const char *foo = "abc";
|
||||
|
||||
int main() {
|
||||
char* p = foo;
|
||||
while (*p) {
|
||||
UDR = *p++;
|
||||
}
|
||||
|
||||
asm volatile ("break");
|
||||
}
|
||||
|
||||
/*
|
||||
check-name: String Operations
|
||||
check-start:
|
||||
\avr@instr@stepn{1000000}
|
||||
|
||||
\avr@test@UDR{abc}
|
||||
check-end:
|
||||
*/
|
@ -111,7 +111,11 @@ do_test()
|
||||
if [ "$actual_exit_value" -ne 0 ]; then
|
||||
error " Actual exit value does not match the expected one."
|
||||
error " expected 0, got $actual_exit_value"
|
||||
if [ x"$V" = x"1" ]; then
|
||||
cat $file.output | sed 's/^/ /'
|
||||
else
|
||||
tail -n 10 $file.output | sed 's/^/ /'
|
||||
fi
|
||||
test_failed=1
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user