Fix a lot of spurious whitespace
This commit is contained in:
parent
51e2a244bb
commit
cea45e869f
5
Makefile
5
Makefile
@ -1,5 +1,8 @@
|
||||
export TEXINPUTS := $(shell pwd)//:${TEXINPUTS}
|
||||
|
||||
doc:
|
||||
cd source; latexmk -pdf -shell-escape avremu
|
||||
|
||||
test: test-simple
|
||||
cd source/test-suite; ./test-suite
|
||||
|
||||
@ -9,4 +12,4 @@ test-simple: source/simple-testsuite.tex
|
||||
test-%: source/test-suite/%.c
|
||||
cd source/test-suite; ./test-suite single $(shell basename $<)
|
||||
|
||||
.PHONY: test-simple
|
||||
.PHONY: test-simple doc
|
||||
|
@ -23,10 +23,8 @@
|
||||
\newcount\avr@ihex@count
|
||||
\newcount\avr@ihex@instrs
|
||||
|
||||
|
||||
\def\avr@ihex@load#1{%
|
||||
\newread\avr@input%
|
||||
|
||||
\avr@ihex@instrs=0\relax%
|
||||
\openin\avr@input=#1\relax%
|
||||
\@whilesw\unless\ifeof\avr@input\fi{%
|
||||
@ -46,9 +44,7 @@
|
||||
%\avr@debug{=\avr@ihex@opcode}%
|
||||
\advance \avr@ihex@count by -1\relax%
|
||||
\advance \avr@ihex@addr by 1\relax%
|
||||
\repeat
|
||||
|
||||
|
||||
\repeat%
|
||||
}{}%
|
||||
}%
|
||||
}%
|
||||
|
@ -104,7 +104,7 @@
|
||||
}%
|
||||
\edef\@tmpb{#1}%
|
||||
\expandafter\avr@bin@setbit@helper\@tmpb\@nnil%
|
||||
\edef#4{\@tempa}
|
||||
\edef#4{\@tempa}%
|
||||
}
|
||||
|
||||
% \avr@bin@btw bs:byte, \result -> \result = 00000000+bs
|
||||
@ -178,7 +178,7 @@
|
||||
}%
|
||||
\edef\@tempa{#1}%
|
||||
\def#2{}%
|
||||
\expandafter\avr@bin@lsb@del@helper\@tempa\@nnil
|
||||
\expandafter\avr@bin@lsb@del@helper\@tempa\@nnil%
|
||||
}
|
||||
|
||||
% Get LSB: bs, \result
|
||||
@ -191,7 +191,7 @@
|
||||
\fi%
|
||||
}%
|
||||
\edef\@tempa{#1}%
|
||||
\expandafter\avr@bin@lsb@get@helper\@tempa\@nnil
|
||||
\expandafter\avr@bin@lsb@get@helper\@tempa\@nnil%
|
||||
}
|
||||
|
||||
% Delete MSB: bs, \result,\carry
|
||||
|
@ -19,14 +19,14 @@
|
||||
\avr@bin@tocount{#1}{\avr@accA}%
|
||||
\avr@log{DRAW CMD: \the\avr@accA}%
|
||||
\avr@draw@command{\the\avr@accA}%
|
||||
\avr@draw@argc = 0\relax
|
||||
\avr@draw@argc = 0\relax%
|
||||
}
|
||||
|
||||
\csdef{avr@io@000011@set}#1{%
|
||||
\avr@bin@tocount{#1}{\avr@accA}%
|
||||
\avr@debug{AVR DRAW PUSH: \the\avr@accA}%
|
||||
\csxdef{avr@draw@stack@\the\avr@draw@argc}{\the\avr@accA}%
|
||||
\advance\avr@draw@argc by 1\relax
|
||||
\advance\avr@draw@argc by 1\relax%
|
||||
}
|
||||
|
||||
\def\avr@draw@stack#1{\csuse{avr@draw@stack@#1}}
|
||||
@ -111,7 +111,7 @@
|
||||
|
||||
\newwrite\avr@file%
|
||||
|
||||
\newcommand{\avrdrawppm}[1]{
|
||||
\newcommand{\avrdrawppm}[1]{%
|
||||
% Dump to .ppm file
|
||||
\immediate\openout\avr@file=#1%
|
||||
\immediate\write\avr@file{P3}%
|
||||
|
@ -34,10 +34,12 @@
|
||||
\avr@instr@run%
|
||||
}
|
||||
|
||||
\newcommand{\avrsinglestep}{
|
||||
\newcommand{\avrsinglestep}{%
|
||||
\avr@instr@singlestep%
|
||||
}
|
||||
|
||||
\newcommand{\avrinstrcount}{\the\avr@instr@executed}
|
||||
|
||||
\def\avr@instr@step{%
|
||||
\avr@code@get{\avr@instr@current}%
|
||||
%\avr@reg@get{\csuse{avr@r24}}{\@@A}%
|
||||
@ -60,7 +62,7 @@
|
||||
\newcount\avr@instr@steps
|
||||
\def\avr@instr@stepn#1{%
|
||||
\avr@instr@steps=#1%
|
||||
\def\avr@instr@stepn@helper{
|
||||
\def\avr@instr@stepn@helper{%
|
||||
\ifnum \avr@instr@steps > 0%
|
||||
\advance \avr@instr@steps by -1\relax%
|
||||
\avr@instr@step%
|
||||
@ -73,9 +75,9 @@
|
||||
}
|
||||
|
||||
% Run Forever
|
||||
\def\avr@instr@run{
|
||||
\def\avr@instr@run{%
|
||||
\avr@instr@steps=1%
|
||||
\def\avr@instr@stepn@helper{
|
||||
\def\avr@instr@stepn@helper{%
|
||||
\ifnum \avr@instr@steps > 0%
|
||||
\avr@instr@step%
|
||||
\else%
|
||||
@ -154,7 +156,7 @@
|
||||
\def#2{2}%
|
||||
}{%
|
||||
\def#2{1}%
|
||||
}
|
||||
}%
|
||||
}
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Match also from end for these prefixes
|
||||
@ -523,7 +525,7 @@
|
||||
\advance \avr@count@tmpa by 1\relax%
|
||||
\fi%
|
||||
\avr@count@tobin@b{\avr@count@tmpa}{\@@res}%
|
||||
\avr@bin@msb@del{\@@res}{#2}{\@tempa}
|
||||
\avr@bin@msb@del{\@@res}{#2}{\@tempa}%
|
||||
}
|
||||
\def\avr@instr@jump@dec#1#2{%
|
||||
\avr@bin@tocount{0#1}{\avr@count@tmpa}%
|
||||
@ -635,7 +637,7 @@
|
||||
}
|
||||
|
||||
% #1 = Value to be reached
|
||||
\csdef{avr@instr@11110}#1#2#3#4#5#6#7#8#9\@nnil{
|
||||
\csdef{avr@instr@11110}#1#2#3#4#5#6#7#8#9\@nnil{%
|
||||
\edef\@@required{\avr@bit@negate #1}%
|
||||
\def\@@offset{#2#3#4#5#6#7#8}%
|
||||
\def\@@bit{00000#9}%
|
||||
@ -645,7 +647,7 @@
|
||||
\avr@bin@getbit{\@@sreg}{\@@bit}{\@@found}%
|
||||
\avr@count@tmpa=\@@required%
|
||||
\avr@count@tmpb=\@@found\relax%
|
||||
\avr@debug{BRB{CS} - (\@@sreg[\@@bit] == \@@required) ? +\@@offset : +0}
|
||||
\avr@debug{BRB{CS} - (\@@sreg[\@@bit] == \@@required) ? +\@@offset : +0}%
|
||||
\ifnum \avr@count@tmpa = \avr@count@tmpb%
|
||||
\avr@instr@jump@dec{\@@offset}{\avr@count@tmpa}%
|
||||
\avr@debug{BRB -- JUMP \the\avr@count@tmpa}%
|
||||
@ -657,7 +659,7 @@
|
||||
% RJMP
|
||||
% #1 = Offset
|
||||
% FIXME latex assembler
|
||||
\csdef{avr@instr@1100}#1\@nnil{
|
||||
\csdef{avr@instr@1100}#1\@nnil{%
|
||||
\avr@instr@rjump@dec{#1}{\avr@count@tmpa}%
|
||||
\avr@debug{RJMP \the\avr@count@tmpa}%
|
||||
\avr@pc@add{\avr@count@tmpa}%
|
||||
@ -676,7 +678,7 @@
|
||||
\avr@pc@inc%
|
||||
\avr@debug{ done}%
|
||||
}
|
||||
\csdef{avr@instr@1101}#1\@nnil{
|
||||
\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}%
|
||||
@ -688,28 +690,28 @@
|
||||
}
|
||||
|
||||
\def\avr@instr@ICALL#1{\avr@code@set{1001010100001001}{#1}}
|
||||
\csdef{avr@instr@1001010100001001}\@nnil{
|
||||
\csdef{avr@instr@1001010100001001}\@nnil{%
|
||||
\avr@count@tobin@w{\the\avr@pc}{\@@pc}%
|
||||
\avr@regw@get{\csuse{avr@Z}}{\@@addr}
|
||||
\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
|
||||
\avr@pc=\avr@addr%
|
||||
}
|
||||
|
||||
\def\avr@instr@IJMP#1{\avr@code@set{1001010000001001}{#1}}
|
||||
\csdef{avr@instr@1001010000001001}\@nnil{
|
||||
\csdef{avr@instr@1001010000001001}\@nnil{%
|
||||
\avr@count@tobin@w{\the\avr@pc}{\@@pc}%
|
||||
\avr@regw@get{\csuse{avr@Z}}{\@@addr}
|
||||
\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{IJMP \the\avr@addr {r24:\@@a} {r25:\@@b} {r26:\@@c}}%
|
||||
\avr@pc=\avr@addr
|
||||
\avr@pc=\avr@addr%
|
||||
}
|
||||
|
||||
% RET
|
||||
@ -719,9 +721,9 @@
|
||||
\csdef{avr@instr@1001010100001000}\@nnil{%
|
||||
\avr@reg@get{\csuse{avr@r24}}{\@@X}%
|
||||
\avr@debug{RET (r24=\@@X)}%
|
||||
\advance\avr@stackptr by 1\relax
|
||||
\advance\avr@stackptr by 1\relax%
|
||||
\avr@mem@get{\the\avr@stackptr}{\@@high}%
|
||||
\advance\avr@stackptr by 1\relax
|
||||
\advance\avr@stackptr by 1\relax%
|
||||
\avr@mem@get{\the\avr@stackptr}{\@@low}%
|
||||
\avr@bin@tocount{\@@high \@@low}{\avr@pc}%
|
||||
\avr@pc@inc\relax%
|
||||
@ -737,7 +739,7 @@
|
||||
\csdef{avr@instr@001011}#1#2#3#4#5#6#7\@nnil{%
|
||||
\avr@reg@get{#1#7}{\avr@Rr}%
|
||||
\avr@reg@set{\avr@Rr}{#2#3#4#5#6}%
|
||||
\avr@debug{MOV - #2#3#4#5#6 <- #1#7(=\avr@Rr)}
|
||||
\avr@debug{MOV - #2#3#4#5#6 <- #1#7(=\avr@Rr)}%
|
||||
\avr@pc@inc%
|
||||
}
|
||||
|
||||
@ -752,7 +754,7 @@
|
||||
\avr@reg@set{\avr@Rr}{#1#2#3#40}%
|
||||
\avr@reg@get{#51}{\avr@Rd}%
|
||||
\avr@reg@set{\avr@Rd}{#1#2#3#41}%
|
||||
\avr@debug{MOV - #1#2#3#4[01] <- #5[01](=\avr@Rr:\avr@Rd)}
|
||||
\avr@debug{MOV - #1#2#3#4[01] <- #5[01](=\avr@Rr:\avr@Rd)}%
|
||||
\avr@pc@inc%
|
||||
}
|
||||
|
||||
@ -993,14 +995,14 @@
|
||||
\def\avr@instr@LDS#1#2#3{%
|
||||
\avr@code@set{1001000#20000}{#1}%
|
||||
\avr@count@tmpa=#1%
|
||||
\advance \avr@count@tmpa by 1\relax
|
||||
\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
|
||||
\advance \avr@count@tmpa by 1\relax%
|
||||
\avr@code@set{#3}{\the\avr@count@tmpa}%
|
||||
}
|
||||
|
||||
@ -1263,7 +1265,7 @@
|
||||
\def\avr@skip@instr@eq#1#2{%
|
||||
\ifdefstrequal{#1}{#2}{%
|
||||
\avr@pc@inc%
|
||||
\avr@instr@length{\the\avr@pc}{\@@length}
|
||||
\avr@instr@length{\the\avr@pc}{\@@length}%
|
||||
\avr@debug{SKIP (\@@length) instruction}%
|
||||
\avr@pc@add{\@@length}%
|
||||
}{%
|
||||
@ -1375,8 +1377,8 @@
|
||||
\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@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}%
|
||||
|
@ -2,13 +2,20 @@
|
||||
%% The IO Subsystem
|
||||
%%
|
||||
|
||||
\newcommand{\avrUDR}{%
|
||||
\avr@UDR%
|
||||
}
|
||||
\newcommand{\avrUDRclear}{%
|
||||
\def\avr@UDR{}%
|
||||
}
|
||||
|
||||
\def\avr@io@init{%
|
||||
\def\avr@UDR{}%
|
||||
}
|
||||
|
||||
% OUT
|
||||
\def\avr@instr@OUT#1#2#3{% A, R
|
||||
\def\@@A{#2}
|
||||
\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}%
|
||||
@ -24,10 +31,10 @@
|
||||
|
||||
% IN
|
||||
\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}%
|
||||
\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{%
|
||||
|
@ -266,7 +266,7 @@
|
||||
}
|
||||
%% RAM
|
||||
\newcount\avr@stackptr
|
||||
\def\avr@stack@init{
|
||||
\def\avr@stack@init{%
|
||||
\avr@stackptr=0%
|
||||
}
|
||||
|
||||
@ -283,20 +283,20 @@
|
||||
\avr@count@tobin@w{\avr@stackptr}{\@@stack}%
|
||||
\avr@bin@word@high{\@@stack}{\@@high}%
|
||||
\avr@bin@tocount{\@@high #1}{\avr@stackptr}%
|
||||
\avr@debug{ SP=\the\avr@stackptr}
|
||||
\avr@debug{ SP=\the\avr@stackptr}%
|
||||
}
|
||||
|
||||
\def\avr@stack@SPH@set#1{%
|
||||
\avr@count@tobin@w{\avr@stackptr}{\@@stack}%
|
||||
\avr@bin@word@low{\@@stack}{\@@low}%
|
||||
\avr@bin@tocount{#1\@@low}{\avr@stackptr}%
|
||||
\avr@debug{ SP=\the\avr@stackptr}
|
||||
\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
|
||||
\ifnum \avr@count@tmpa > 0%
|
||||
\csxdef{avr@mem@\the\avr@count@tmpa}{00000000}%
|
||||
\advance \avr@count@tmpa by -1\relax%
|
||||
\else%
|
||||
|
@ -2,6 +2,14 @@
|
||||
\ProvidesPackage{avremu} [2014/10/09 v0.1 avremu]
|
||||
\RequirePackage{etoolbox}
|
||||
\RequirePackage{tabularx}
|
||||
\RequirePackage{kvoptions}
|
||||
|
||||
\SetupKeyvalOptions{
|
||||
family=avr,
|
||||
prefix=avr@
|
||||
}
|
||||
\DeclareBoolOption{debug}
|
||||
\ProcessKeyvalOptions*
|
||||
|
||||
\input{avr.numbers}
|
||||
\input{avr.binary}
|
||||
@ -11,6 +19,11 @@
|
||||
\input{avr.io}
|
||||
\input{avr.testsuite}
|
||||
|
||||
\ifavr@debug
|
||||
\relax
|
||||
\else
|
||||
\def\avr@debug#1{}
|
||||
\fi
|
||||
|
||||
\newcommand{\useavremulibrary}[1]{
|
||||
\def\do##1{%
|
||||
|
Loading…
Reference in New Issue
Block a user