An ISA definition for Kingdom Hearts 2 AI https://govanify.com/post/kh2ai/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.8KB

  1. define space ram type=ram_space size=4 wordsize=1 default;
  2. define space register type=register_space size=4;
  3. # this is obviously wrong and will need to be edited when i understand how
  4. # internal regs are used besides stack
  5. define register offset=0 size=4 [
  6. r0 r1 r2 r3 r4 r5 r6
  7. r7 r8 pc sp ra broken
  8. ];
  9. define token instr(16)
  10. opcode = (0, 3)
  11. ssub_opc = (6, 15)
  12. sub_opc = (4, 5)
  13. iarg = (14, 15);
  14. define token instr_ext(32)
  15. opcode_ext = (0, 3)
  16. sub_opc_ext = (4, 5)
  17. opesub = (6, 7)
  18. _opesub = (6, 7)
  19. rn = (6, 7)
  20. ope3 = (6, 15)
  21. full_ext = (0, 31)
  22. full_rel = (0, 31) signed
  23. # the label thingy
  24. ope2 = (16, 31)
  25. _ope2 = (16, 31)
  26. ope2s = (16, 31) signed;
  27. # relocated labels
  28. LABEL8: reloc is ope2s [ reloc = inst_start+(ope2s*2)+4; ] { export *:4 reloc; }
  29. LABEL02: reloc is ope2s [ reloc = 0x10+(ope2s*2); ] { export *:4 reloc; }
  30. #LABELV: reloc is full_rel [ reloc = 0x10+(full_rel*2); ] { export *:4 reloc; }
  31. NOT_LABEL03: reloc is ope2s [ reloc = 0x10+(ope2s*2); ] { tmp:4 = reloc:4; export tmp; }
  32. #CLABEL: reloc is full_ext [ reloc = 0x10+(full_ext*2); ] { export *:4 reloc; }
  33. # if i'm not mistaken 0x1da4d8 1 and 2 uses two regs
  34. # one of them or more is a status reg so i'll have to double check how it's used
  35. attach variables [ rn ] [ r0 r1 r2 r3 ];
  36. # exit values
  37. attach values [ iarg ] [ 1 2 _ _ ];
  38. define pcodeop system_call;
  39. define pcodeop fmod;
  40. define pcodeop exit;
  41. define pcodeop cos;
  42. define pcodeop sin;
  43. define pcodeop radians_to_degrees;
  44. define pcodeop degrees_to_radians;
  45. macro push(v) {
  46. *[ram]:4 sp = v;
  47. sp = sp + 4;
  48. }
  49. macro pop(v) {
  50. sp = sp - 4;
  51. v = *[ram]:4 sp;
  52. }
  53. macro to_address(v) {
  54. if(v!=0) goto <address>;
  55. v=0;
  56. goto <end>;
  57. <address>
  58. v=0x10+(v*2);
  59. <end>
  60. }