Skip to content

Commit

Permalink
PIC IL: pic18 impl
Browse files Browse the repository at this point in the history
  • Loading branch information
imbillow committed Apr 9, 2024
1 parent 72e1b2f commit 1d1cfaf
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 35 deletions.
16 changes: 8 additions & 8 deletions librz/arch/isa/pic/pic18_analysis.inc
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,16 @@ static int analysis_pic_pic18_op(
case PIC18_OPCODE_RETFIE: // retfie
aop->type = RZ_ANALYSIS_OP_TYPE_RET;
break;
case PIC18_OPCODE_TBLWTMm: // tblwt
case PIC18_OPCODE_TBLWTMma: // tblwt
case PIC18_OPCODE_TBLWTam: // tblwt
case PIC18_OPCODE_TBLWTMms: // tblwt
case PIC18_OPCODE_TBLWTMs: // tblwt
case PIC18_OPCODE_TBLWTMsi: // tblwt
case PIC18_OPCODE_TBLWTis: // tblwt
case PIC18_OPCODE_TBLWTMsd: // tblwt
aop->type = RZ_ANALYSIS_OP_TYPE_LOAD;
break;
case PIC18_OPCODE_TBLRDam: // tblrd
case PIC18_OPCODE_TBLRDm: // tblrd
case PIC18_OPCODE_TBLRDma: // tblrd
case PIC18_OPCODE_TBLRDms: // tblrd
case PIC18_OPCODE_TBLRDis: // tblrd
case PIC18_OPCODE_TBLRDs: // tblrd
case PIC18_OPCODE_TBLRDsi: // tblrd
case PIC18_OPCODE_TBLRDsd: // tblrd
aop->type = RZ_ANALYSIS_OP_TYPE_STORE;
break;
case PIC18_OPCODE_POP: // pop
Expand Down
50 changes: 39 additions & 11 deletions librz/arch/isa/pic/pic18_il.inc
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,45 @@ static RzILOpEffect *pic18_il(Pic18Op *op) {
case PIC18_OPCODE_SUBWFB: return op_sub(R_DEST, VRF, VRW, VRC);
case PIC18_OPCODE_SWAPF:
return SETG(R_DEST, APPEND(UNSIGNED(4, VRF), UNSIGNED(4, SHIFTR0(VRF, U8(4)))));
case PIC18_OPCODE_TBLWTam: break;
case PIC18_OPCODE_TBLWTMms: break;
case PIC18_OPCODE_TBLWTMma: break;
case PIC18_OPCODE_TBLWTMm: break;
case PIC18_OPCODE_TBLRDam: break;
case PIC18_OPCODE_TBLRDms: break;
case PIC18_OPCODE_TBLRDma: break;
case PIC18_OPCODE_TBLRDm: break;
case PIC18_OPCODE_TSTFSZ: break;
case PIC18_OPCODE_XORWF: break;
case PIC18_OPCODE_XORLW: break;

case PIC18_OPCODE_TBLRDs:
return SETG("tblat", LOAD(VARG("tblptr")));
case PIC18_OPCODE_TBLRDis:
return SEQ2(
SETG("tblptr", ADD(VARG("tblptr"), U32(1))),
SETG("tblat", LOAD(VARG("tblptr"))));
case PIC18_OPCODE_TBLRDsd:
return SEQ2(
SETG("tblat", LOAD(VARG("tblptr"))),
SETG("tblptr", SUB(VARG("tblptr"), U32(1))));
case PIC18_OPCODE_TBLRDsi:
return SEQ2(
SETG("tblat", LOAD(VARG("tblptr"))),
SETG("tblptr", ADD(VARG("tblptr"), U32(1))));
case PIC18_OPCODE_TBLWTMs:
return STORE(VARG("tblptr"), VARG("tblat"));
case PIC18_OPCODE_TBLWTis:
return SEQ2(
SETG("tblptr", ADD(VARG("tblptr"), U32(1))),
STORE(VARG("tblptr"), VARG("tblat")));
case PIC18_OPCODE_TBLWTMsd:
return SEQ2(
STORE(VARG("tblptr"), VARG("tblat")),
SETG("tblptr", SUB(VARG("tblptr"), U32(1))));
case PIC18_OPCODE_TBLWTMsi:
return SEQ2(
STORE(VARG("tblptr"), VARG("tblat")),
SETG("tblptr", ADD(VARG("tblptr"), U32(1))));
case PIC18_OPCODE_TSTFSZ:
return op_skip_if(op, IS_ZERO(VRF));
case PIC18_OPCODE_XORWF:
return SEQ2(
SETG(R_DEST, XOR(VRW, VRF)),
status_res(VR_DEST));
case PIC18_OPCODE_XORLW:
return SEQ2(
SETG(RW, XOR(VRW, VRF)),
status_res(VRW));
case PIC18_OPCODE_INVALID: break;
}
return NULL;
Expand Down
16 changes: 8 additions & 8 deletions librz/arch/isa/pic/pic_pic18.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ static const Pic18OpDesc ops[] = {
{ PIC18_OPCODE_RESET, 0xff, 0xff, "reset", NO_ARG },
{ PIC18_OPCODE_RETURN, 0x12, 0x13, "return", S_T },
{ PIC18_OPCODE_RETFIE, 0x10, 0x11, "retfie", S_T },
{ PIC18_OPCODE_TBLWTam, 0xf, 0xf, "tblwt+*", NO_ARG },
{ PIC18_OPCODE_TBLWTMms, 0xe, 0xe, "tblwt*-", NO_ARG },
{ PIC18_OPCODE_TBLWTMma, 0xd, 0xd, "tblwt*+", NO_ARG },
{ PIC18_OPCODE_TBLWTMm, 0xc, 0xc, "tblwt*", NO_ARG },
{ PIC18_OPCODE_TBLRDam, 0xb, 0xb, "tblrd+*", NO_ARG },
{ PIC18_OPCODE_TBLRDms, 0xa, 0xa, "tblrd*-", NO_ARG },
{ PIC18_OPCODE_TBLRDma, 0x9, 0x9, "tblrd*+", NO_ARG },
{ PIC18_OPCODE_TBLRDm, 0x8, 0x8, "tblrd*", NO_ARG },
{ PIC18_OPCODE_TBLWTis, 0xf, 0xf, "tblwt+*", NO_ARG },
{ PIC18_OPCODE_TBLWTMsd, 0xe, 0xe, "tblwt*-", NO_ARG },
{ PIC18_OPCODE_TBLWTMsi, 0xd, 0xd, "tblwt*+", NO_ARG },
{ PIC18_OPCODE_TBLWTMs, 0xc, 0xc, "tblwt*", NO_ARG },
{ PIC18_OPCODE_TBLRDis, 0xb, 0xb, "tblrd+*", NO_ARG },
{ PIC18_OPCODE_TBLRDsd, 0xa, 0xa, "tblrd*-", NO_ARG },
{ PIC18_OPCODE_TBLRDsi, 0x9, 0x9, "tblrd*+", NO_ARG },
{ PIC18_OPCODE_TBLRDs, 0x8, 0x8, "tblrd*", NO_ARG },
{ PIC18_OPCODE_DAW, 0x7, 0x7, "daw", NO_ARG },
{ PIC18_OPCODE_POP, 0x6, 0x6, "pop", NO_ARG },
{ PIC18_OPCODE_PUSH, 0x5, 0x5, "push", NO_ARG },
Expand Down
16 changes: 8 additions & 8 deletions librz/arch/isa/pic/pic_pic18.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ typedef enum {
PIC18_OPCODE_SWAPF,
PIC18_OPCODE_SUBLW,

PIC18_OPCODE_TBLWTam,
PIC18_OPCODE_TBLWTMms,
PIC18_OPCODE_TBLWTMma,
PIC18_OPCODE_TBLWTMm,
PIC18_OPCODE_TBLRDam,
PIC18_OPCODE_TBLRDms,
PIC18_OPCODE_TBLRDma,
PIC18_OPCODE_TBLRDm,
PIC18_OPCODE_TBLRDs,
PIC18_OPCODE_TBLRDis,
PIC18_OPCODE_TBLRDsd,
PIC18_OPCODE_TBLRDsi,
PIC18_OPCODE_TBLWTMs,
PIC18_OPCODE_TBLWTis,
PIC18_OPCODE_TBLWTMsd,
PIC18_OPCODE_TBLWTMsi,
PIC18_OPCODE_TSTFSZ,

PIC18_OPCODE_XORWF,
Expand Down

0 comments on commit 1d1cfaf

Please sign in to comment.