Browse Source

variable length bitpicture support for the manual

tags/v0.1
parent
commit
2cf06c5e5c
No known key found for this signature in database
4 changed files with 57 additions and 36 deletions
  1. +1
    -0
      .gitignore
  2. +1
    -1
      data/languages/kh2ai.ldefs
  3. +31
    -31
      data/languages/kh2ai.sinc
  4. +24
    -4
      data/manuals/kh2ai.tex

+ 1
- 0
.gitignore View File

@@ -2,6 +2,7 @@
.*.sw*
.*.swp
.swp
*.swp
*.aux
*.log
*.pdf

+ 1
- 1
data/languages/kh2ai.ldefs View File

@@ -5,7 +5,7 @@
endian="little"
size="32"
variant="default"
version="1.0"
version="0.1"
slafile="kh2ai.sla"
processorspec="kh2ai.pspec"
manualindexfile="../manuals/kh2ai.idx"

+ 31
- 31
data/languages/kh2ai.sinc View File

@@ -5,25 +5,25 @@ define space register type=register_space size=4;
# this is obviously wrong and will need to be edited when i understand how
# internal regs are used besides stack
define register offset=0 size=4 [
r0 r1 r2 r3 r4 r5 r6
r0 r1 r2 r3 r4 r5 r6
r7 r8 pc sp ra broken
];

define token instr(16)
opcode = (0, 3)
ssub_opc = (6, 15)
sub_opc = (4, 5)
iarg = (14, 15);
opcode = (0, 3)
ssub_opc = (6, 15)
sub_opc = (4, 5)
iarg = (14, 15);

define token instr_ext(32)
opcode_ext = (0, 3)
sub_opc_ext = (4, 5)
opesub = (6, 7)
rn = (6, 7)
ope3 = (6, 15)
full_ext = (0, 31)
# the label thingy
ope2 = (16, 31);
opcode_ext = (0, 3)
sub_opc_ext = (4, 5)
opesub = (6, 7)
rn = (6, 7)
ope3 = (6, 15)
full_ext = (0, 31)
# the label thingy
ope2 = (16, 31);

# relocated labels
LABEL8: reloc is ope2 [ reloc = inst_start+(ope2*2)+4; ] { export *:4 reloc; }
@@ -47,13 +47,13 @@ define pcodeop degrees_to_radians;


macro push(v) {
*[ram]:4 sp = v;
sp = sp + 4;
*[ram]:4 sp = v;
sp = sp + 4;
}

macro pop(v) {
sp = sp - 4;
v = *[ram]:4 sp;
sp = sp - 4;
v = *[ram]:4 sp;
}

#
@@ -83,7 +83,7 @@ macro pop(v) {
}

:push LABEL02 is opcode_ext=0 & sub_opc_ext=2 & opesub=3 & LABEL02 {
# this is wrong! it pushes the pointer, not the data
# this is wrong! it pushes the pointer, not the data
push(LABEL02:4);
}

@@ -164,7 +164,7 @@ macro pop(v) {
local tmp:4 = sp;
pop(tmp);
if(tmp s<= 0) goto <min>;
goto <done>;
goto <done>;
<min>
tmp=-tmp;
<done>
@@ -376,12 +376,12 @@ macro pop(v) {
pop(tmp2);
local ret:4 = 1;
if(tmp!=0) goto <next>;
goto <end>;
goto <end>;
<next>
if(tmp2==0) goto <end>;
ret=0;
ret=0;
<end>
push(ret);
push(ret);
}

# equal to zero (2 variable stack edition)
@@ -392,12 +392,12 @@ macro pop(v) {
pop(tmp2);
local ret:4 = 1;
if(tmp==0) goto <next>;
goto <end>;
goto <end>;
<next>
if(tmp2!=0) goto <end>;
ret=0;
ret=0;
<end>
push(ret);
push(ret);
}


@@ -442,7 +442,7 @@ macro pop(v) {
local tmp2:4 = sp;
pop(tmp);
pop(tmp2);
# primitive doesn't exist, so we do with what we can
# primitive doesn't exist, so we do with what we can
local ret:4 = fmod(tmp2, tmp);
push(ret);
}
@@ -451,21 +451,21 @@ macro pop(v) {


:jmp7_unk1 LABEL8 is opcode_ext=7 & ope3=0 & LABEL8 {
call LABEL8;
call LABEL8;
}

:jmp7_unk2 LABEL8 is opcode_ext=7 & ope3=1 & LABEL8 {
call LABEL8;
call LABEL8;
}

:jmp7_unk3 LABEL8 is opcode_ext=7 & ope3=2 & LABEL8 {
call LABEL8;
call LABEL8;
}

# jump
# TODO: verify first arg!
:jmp ope3, LABEL8 is opcode_ext=8 & LABEL8 & ope3 {
call LABEL8;
call LABEL8;
}


@@ -477,7 +477,7 @@ macro pop(v) {

# return
:ret is opcode=9 & ssub_opc=2{
return[ra];
return[ra];
}

# push cached -> push last cached pushed element to stack

+ 24
- 4
data/manuals/kh2ai.tex View File

@@ -8,6 +8,8 @@
\usepackage[bookmarks=true]{hyperref}
\usepackage{bookmark}
\usepackage{xinttools}
\usepackage{xstring}
\usepackage{ifthen}

\newcounter{bitindex}

@@ -73,18 +75,35 @@
}

\newcommand\bitpicture [1]{%
\setlength{\unitlength}{0.9mm}
\StrLen{#1}[\bitlen]
\StrLeft{#1}{32}[\bita]
\StrRight{#1}{32}[\bitb]
\ifthenelse{\bitlen > 16}{\setlength{\unitlength}{0.9mm}}{\setlength{\unitlength}{1.6mm}}
\setlength{\fboxsep}{0mm}
\begin{picture}(130,16)
% sign bit
\ifthenelse{\bitlen > 32}{
\setcounter{bitindex}{1}%
\xintFor* ##1 in {\bita}
\do
{\put(\numexpr 1+4*\value{bitindex},4){\framebox(4,8){##1}}%
\stepcounter{bitindex}}%
\setcounter{bitindex}{1}%
\xintFor* ##1 in {\bitb}
\do
{\put(\numexpr 1+4*\value{bitindex},-12){\framebox(4,8){##1}}%
\stepcounter{bitindex}}
}{
\setcounter{bitindex}{1}%
\xintFor* ##1 in {#1}
\do
{\put(\numexpr 1+4*\value{bitindex},4){\framebox(4,8){##1}}%
\stepcounter{bitindex}}%
}
% upper labels
\put(0,14){\scriptsize{MSB}}
\put(126,14){\scriptsize{LSB}}
%\put(0,14){\scriptsize{MSB}}
%\put(126,14){\scriptsize{LSB}}
%lower labels
% \put(3,0){\scriptsize{S}}
% \put(7,0){\line(0,1){2}}
@@ -98,6 +117,7 @@
% \put(130,1){\vector(-1,0){38}}
% \put(130,0){\line(0,1){2}}
\end{picture}%
\ifthenelse{\bitlen > 32}{\\ \\ \\}{}
}


@@ -120,7 +140,7 @@

\Chapter{Instruction Set}

\ISA{PUSH: Push}{b}{c}{d}{e}{f}{01000000010010010000111111010000}
\ISA{PUSH: Push}{b}{c}{d}{e}{f}{01000000010010010000111111010000111111}

\ISA{PUSHA: Push and Add}{b}{c}{d}{e}{f}{01000000010010010000111111010000}


Loading…
Cancel
Save