Skip to content

Commit

Permalink
PIC IL: pic18 registers
Browse files Browse the repository at this point in the history
  • Loading branch information
imbillow committed Apr 16, 2024
1 parent 80e8538 commit 2d21f83
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 8 deletions.
5 changes: 3 additions & 2 deletions librz/arch/isa/pic/pic18_analysis.inc
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ static char *analysis_pic_pic18_get_reg_profile(RzAnalysis *esil) {
"gpr adcon0 .8 95 0\n"
"#stkprt max is 0b11111\n"
"gpr stkptr .8 96 0\n"
"gpr tablat .8 14 0\n";

"gpr tblat .8 14 0\n"
"gpr _sram .8 98 0\n"
"gpr _stack .8 99 0\n";
return strdup(p);
}
113 changes: 107 additions & 6 deletions librz/arch/isa/pic/pic18_il.inc
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ static RzILOpEffect *set_prod16(RzILOpPure *res) {

static RzILOpEffect *op_pop() {
return SEQ2(
SETG("_stack_ptr", SUB(VARG("_stack_ptr"), U16(4))),
SETG("tos", LOADW(32, ADD(VARG("_stack"), VARG("_stack_ptr")))));
SETG("stkptr", SUB(VARG("stkptr"), U16(4))),
SETG("tos", LOADW(32, ADD(VARG("_stack"), VARG("stkptr")))));
}

static RzILOpEffect *op_pop_jmp() {
Expand All @@ -142,8 +142,8 @@ static RzILOpEffect *op_pop_jmp() {

static RzILOpEffect *op_push(RzILOpPure *x) {
return SEQ3(
SETG("_stack_ptr", ADD(VARG("_stack_ptr"), U16(4))),
STOREW(ADD(VARG("_stack"), VARG("_stack_ptr")), x),
SETG("stkptr", ADD(VARG("stkptr"), U16(4))),
STOREW(ADD(VARG("_stack"), VARG("stkptr")), x),
SETG("tos", DUP(x)));
}

Expand Down Expand Up @@ -368,9 +368,110 @@ static RzILOpEffect *pic18_il(Pic18Op *op) {
#undef VPC

static const char *pic18_regnames[] = {
"pcl",
"pclath",
"pclatu",
"bsr",
"tos",
"tosl",
"tosh",
"tosu",
"indf0",
"fsr0",
"fsr0l",
"fsr0h",
"indf1",
"fsr1",
"fsr1l",
"fsr1h",
"indf2",
"fsr2",
"frs2l",
"fsr2h",
"tblptr",
"tblptrl",
"tblptrh",
"tblptru",
"rcon",
"memcon",
"intcon",
"intcon2",
"intcon3",
"pie1",
"porta",
"trisa",
"portb",
"tisb",
"latb",
"portc",
"trisc",
"latc",
"portd",
"trisd",
"latd",
"pspcon",
"porte",
"trise",
"late",
"t0con",
"t1con",
"t2con",
"tmr1h",
"tmr0h",
"tmr1l",
"tmr2",
"pr2",
"ccpr1h",
"postinc2",
"ccpr1l",
"postdec2",
"ccp1con",
"preinc2",
"ccpr2h",
"plusw2",
"ccpr2l",
"ccp2con",
"status",
"c .",
"dc .",
"z .",
"ov .",
"n .",
"prod",
"prodl",
"prodh",
"osccon",
"tmr3h",
"lvdcon",
"tmr3l",
"wdtcon",
"t3con",
"spbrg",
"postinc0",
"rcreg",
"postdec0",
"txreg",
"preinc0",
"txsta",
"plusw0",
"rcsta",
"sspbuf",
"wreg",
"sspadd",
"sspstat",
"postinc1",
"sspcon1",
"postdec1",
"sspcon2",
"preinc1",
"adresh",
"plusw1",
"adresl",
"adcon0",
"stkptr",
"tblat",
"_sram",
"_stack",
"_stack_ptr",
"_stack"
};

static RzAnalysisILConfig *pic18_il_config(
Expand Down

0 comments on commit 2d21f83

Please sign in to comment.