Browse Source

trying to calculate labels for jumps

tags/v0.1
parent
commit
facebce973
Signed by: govanify GPG Key ID: DE62E1E2A6145556
6 changed files with 90 additions and 69 deletions
  1. +3
    -1
      .gitignore
  2. +0
    -62
      data/kh2ai.cspec
  3. BIN
      data/languages/.kh2ai.sinc.swp
  4. +7
    -5
      data/languages/kh2ai.sinc
  5. +0
    -1
      data/languages/peda-session-sleigh.txt
  6. +80
    -0
      notes.txt

+ 3
- 1
.gitignore View File

@@ -1,2 +1,4 @@
*.sla
mep.zip
*.swp
.gdb_history


+ 0
- 62
data/kh2ai.cspec View File

@@ -1,62 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>

<compiler_spec>
<data_organization> <!-- These tags were generated with gcc 4.2.4 -->
<absolute_max_alignment value="0" />
<machine_alignment value="2" />
<default_alignment value="1" />
<default_pointer_alignment value="4" />
<pointer_size value="4" />
<wchar_size value="4" />
<short_size value="2" />
<integer_size value="4" />
<long_size value="4" />
<long_long_size value="8" />
<float_size value="4" />
<double_size value="8" />
<long_double_size value="8" />
<size_alignment_map>
<entry size="1" alignment="1" />
<entry size="2" alignment="2" />
<entry size="4" alignment="4" />
<entry size="8" alignment="8" />
</size_alignment_map>
</data_organization>
<global>
<range space="ram"/>
</global>
<stackpointer register="sp" space="ram"/>
<default_proto>
<prototype name="__stdcall" extrapop="0" stackshift="0">
<input>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r1"/>
</pentry>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r2"/>
</pentry>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r3"/>
</pentry>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r4"/>
</pentry>
<pentry minsize="1" maxsize="500" align="4">
<addr offset="0" space="stack"/>
</pentry>
</input>
<output>
<pentry minsize="1" maxsize="4" extension="inttype">
<register name="r0"/>
</pentry>
</output>
<unaffected>
<register name="r5"/>
<register name="r6"/>
<register name="r7"/>
<register name="r8"/>
<register name="sp"/>
</unaffected>
</prototype>
</default_proto>
</compiler_spec>

BIN
data/languages/.kh2ai.sinc.swp View File


+ 7
- 5
data/languages/kh2ai.sinc View File

@@ -25,10 +25,12 @@ define token instr_advanced(16)

define token instr_ext(32)
ope1 = (0, 3)
ope4 = (6, 31);
#opa3 = (5, 9);

ope4 = (6, 31)
ope3 = (6, 15)
# the label thingy
ope2 = (16, 31);

LABEL: ope2 is ope2 { tmp:4 = (ope2:4 + ((inst_next/2)-0x10)); export tmp; }

# needed a full 4bit mapping
attach variables [ rn ] [ broken r0 r1 broken broken r0 r1 broken broken r0 r1 broken broken r0 r1 broken ];
@@ -256,7 +258,7 @@ define pcodeop system_call;

# jump
# TODO: offset is incorrect, need to fix!!!
:jmp ope4 is ope1=8 & ope4 {
:jmp ope3, LABEL is ope1=8 & LABEL & ope3 {
}


@@ -304,7 +306,7 @@ define pcodeop system_call;

#syscall
:syscall op3,ib is op1=0xA & op3 ; ib {
r0=system_call();
r0=system_call(op3:4,ib:4);
}

:unkB is op1=0xB ; in{


+ 0
- 1
data/languages/peda-session-sleigh.txt View File

@@ -1 +0,0 @@


+ 80
- 0
notes.txt View File

@@ -0,0 +1,80 @@
OPCodes are 8 bits, 0x0-0xB, lowest bits. Arguments come BEFORE(!!!!)

def value():
if(Y==1): return state_r1+cmd
if(Y==2): return state_r2+cmd
if(Y==3): return cmd_0x10+(cmd<<1) #drops the opcode
else: return cmd


-0x0, PUSH, 48 bit operand, encoded 0xX000ZZZZZZZZ:
Y=X>>2
if(X & 3 == 2): r1 = mem[value(Y)]
if(X & 3 != 2): r1 = value(Y)
state_reg3=*addr
-0x1, 16 bit operand, encoded 0xZYZ1:
r1 = value(Y)
r1 = state_reg3...???????
-0x2, 16 bit operand, encoded 0xZYZ1:


-0x3, 32 bit operand, encoded 0x3:
r1 = state_reg3 + *addr



XX001000
^
-0x8, JMP, 32 bit operand, encoded bXX001000:
state_reg2=X*4
*(state_reg2)=pc
entrypoint=X

-0xA, JMP, 32 bit operand, encoded bXAXXYYYY:


-0x5:
--&3==0 aka integer:
-0: to_int
-2: minus
-3: invert
-4,8: compare w/ zero
-5: absolute
-6: ??
-7: inferior to one
-9: not equal to zero
-0xa
-0xb: is_positive
--&3==1 aka float:
-1: convert to word fixed point
-2: minus
-5: ABS
-6: inferior to 0
-7: inferior or equal to 0
-8: equal to zero
-9: not equal to zero
-0xA: inferior or equal to zero
-0xB: inferior to zero



1da3f8
======
tmp=reg3
reg3-=0x4
t3[left]=tmp-1
t3[right]=tmp-4


=============================================================================================================
TODO:
0x0: push is broken
0x1: is that a pop? also args
0x2: to reverse
0x3: to reverse
0x4: to reverse
0x7: to reverse, 2 ops
0x8: jmp is broken
0x9: verify which is sin and which is cos
0xB: to reverse

Loading…
Cancel
Save