12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253 |
- #include <common.h>
- #include <linux/ctype.h>
- #include <bedbug/bedbug.h>
- #include <bedbug/ppc.h>
- #include <bedbug/regs.h>
- #include <bedbug/tables.h>
- #define Elf32_Word unsigned long
- #ifdef USE_SOURCE_CODE
- extern int line_info_from_addr __P ((Elf32_Word, char *, char *, int *));
- extern struct symreflist *symByAddr;
- extern char *symbol_name_from_addr __P ((Elf32_Word, int, int *));
- #endif
- int print_operands __P ((struct ppc_ctx *));
- int get_operand_value __P ((struct opcode *, unsigned long,
- enum OP_FIELD, unsigned long *));
- struct opcode *find_opcode __P ((unsigned long));
- struct opcode *find_opcode_by_name __P ((char *));
- char *spr_name __P ((int));
- int spr_value __P ((char *));
- char *tbr_name __P ((int));
- int tbr_value __P ((char *));
- int parse_operand __P ((unsigned long, struct opcode *,
- struct operand *, char *, int *));
- int get_word __P ((char **, char *));
- long read_number __P ((char *));
- int downstring __P ((char *));
- int disppc (unsigned char *memaddr, unsigned char *virtual, int num_instr,
- int (*pfunc) (const char *), unsigned long flags)
- {
- int i;
- struct ppc_ctx ctx;
- #ifdef USE_SOURCE_CODE
- int line_no = 0;
- int last_line_no = 0;
- char funcname[128] = { 0 };
- char filename[256] = { 0 };
- char last_funcname[128] = { 0 };
- int symoffset;
- char *symname;
- char *cursym = (char *) 0;
- #endif
-
- ctx.flags = flags;
- ctx.virtual = virtual;
-
- if (ctx.flags & F_RADOCTAL) {
-
- strcpy (ctx.radix_fmt, "O%o");
- } else if (ctx.flags & F_RADUDECIMAL) {
-
- strcpy (ctx.radix_fmt, "%u");
- } else if (ctx.flags & F_RADSDECIMAL) {
-
- strcpy (ctx.radix_fmt, "%d");
- } else {
-
- strcpy (ctx.radix_fmt, "0x%x");
- }
- if (ctx.virtual == 0) {
- ctx.virtual = memaddr;
- }
- #ifdef USE_SOURCE_CODE
- if (ctx.flags & F_SYMBOL) {
- if (symByAddr == 0)
- ctx.flags &= ~F_SYMBOL;
- else {
- cursym = (char *) 0;
- symoffset = 0;
- }
- }
- #endif
-
- for (i = 0; i < num_instr; ++i, memaddr += 4, ctx.virtual += 4) {
- #ifdef USE_SOURCE_CODE
- if (ctx.flags & F_LINENO) {
- if ((line_info_from_addr ((Elf32_Word) ctx.virtual,
- filename, funcname, &line_no) == true) &&
- ((line_no != last_line_no) ||
- (strcmp (last_funcname, funcname) != 0))) {
- print_source_line (filename, funcname, line_no, pfunc);
- }
- last_line_no = line_no;
- strcpy (last_funcname, funcname);
- }
- #endif
- sprintf (ctx.data, "%08lx: ", (unsigned long) ctx.virtual);
- ctx.datalen = 10;
- #ifdef USE_SOURCE_CODE
- if (ctx.flags & F_SYMBOL) {
- if ((symname =
- symbol_name_from_addr((Elf32_Word) ctx.virtual,
- true, 0)) != 0) {
- cursym = symname;
- symoffset = 0;
- } else {
- if ((cursym == 0) &&
- ((symname =
- symbol_name_from_addr((Elf32_Word) ctx.virtual,
- false, &symoffset)) != 0)) {
- cursym = symname;
- } else {
- symoffset += 4;
- }
- }
- if (cursym != 0) {
- sprintf (&ctx.data[ctx.datalen], "<%s+", cursym);
- ctx.datalen = strlen (ctx.data);
- sprintf (&ctx.data[ctx.datalen], ctx.radix_fmt, symoffset);
- strcat (ctx.data, ">");
- ctx.datalen = strlen (ctx.data);
- }
- }
- #endif
- ctx.instr = INSTRUCTION (memaddr);
- if (ctx.flags & F_INSTR) {
-
- sprintf (&ctx.data[ctx.datalen],
- " %02lx %02lx %02lx %02lx ",
- ((ctx.instr >> 24) & 0xff),
- ((ctx.instr >> 16) & 0xff), ((ctx.instr >> 8) & 0xff),
- (ctx.instr & 0xff));
- ctx.datalen += 18;
- } else {
- strcat (ctx.data, " ");
- ctx.datalen += 3;
- }
- if ((ctx.op = find_opcode (ctx.instr)) == 0) {
-
- sprintf (&ctx.data[ctx.datalen], " .long 0x%08lx",
- ctx.instr);
- ctx.datalen += 24;
- (*pfunc) (ctx.data);
- continue;
- }
- if (((ctx.flags & F_SIMPLE) == 0) ||
- (ctx.op->hfunc == 0) ||
- ((*ctx.op->hfunc) (&ctx) == false)) {
- sprintf (&ctx.data[ctx.datalen], "%-7s ", ctx.op->name);
- ctx.datalen += 8;
- print_operands (&ctx);
- }
- (*pfunc) (ctx.data);
- }
- return true;
- }
- int print_operands (struct ppc_ctx *ctx)
- {
- int open_parens = 0;
- int field;
- unsigned long operand;
- struct operand *opr;
- #ifdef USE_SOURCE_CODE
- char *symname;
- int offset;
- #endif
-
-
- for (field = 0; ctx->op->fields[field] != 0; ++field) {
- if (ctx->op->fields[field] > n_operands) {
- continue;
- }
- opr = &operands[ctx->op->fields[field] - 1];
- if (opr->hint & OH_SILENT) {
- continue;
- }
- if ((field > 0) && !open_parens) {
- strcat (ctx->data, ",");
- ctx->datalen++;
- }
- operand = (ctx->instr >> opr->shift) & ((1 << opr->bits) - 1);
- if (opr->hint & OH_ADDR) {
- if ((operand & (1 << (opr->bits - 1))) != 0) {
- operand = operand - (1 << opr->bits);
- }
- if (ctx->op->hint & H_RELATIVE)
- operand = (operand << 2) + (unsigned long) ctx->virtual;
- else
- operand = (operand << 2);
- sprintf (&ctx->data[ctx->datalen], "0x%lx", operand);
- ctx->datalen = strlen (ctx->data);
- #ifdef USE_SOURCE_CODE
- if ((ctx->flags & F_SYMBOL) &&
- ((symname =
- symbol_name_from_addr (operand, 0, &offset)) != 0)) {
- sprintf (&ctx->data[ctx->datalen], " <%s", symname);
- if (offset != 0) {
- strcat (ctx->data, "+");
- ctx->datalen = strlen (ctx->data);
- sprintf (&ctx->data[ctx->datalen], ctx->radix_fmt,
- offset);
- }
- strcat (ctx->data, ">");
- }
- #endif
- }
- else if (opr->hint & OH_REG) {
- if ((operand == 0) &&
- (opr->field == O_rA) && (ctx->op->hint & H_RA0_IS_0)) {
- strcat (ctx->data, "0");
- } else {
- sprintf (&ctx->data[ctx->datalen], "r%d", (short) operand);
- }
- if (open_parens) {
- strcat (ctx->data, ")");
- open_parens--;
- }
- }
- else if (opr->hint & OH_SPR) {
- strcat (ctx->data, spr_name (operand));
- }
- else if (opr->hint & OH_TBR) {
- strcat (ctx->data, tbr_name (operand));
- }
- else if (opr->hint & OH_LITERAL) {
- switch (opr->field) {
- case O_cr2:
- strcat (ctx->data, "cr2");
- ctx->datalen += 3;
- break;
- default:
- break;
- }
- }
- else {
- sprintf (&ctx->data[ctx->datalen], ctx->radix_fmt,
- (unsigned short) operand);
- if (open_parens) {
- strcat (ctx->data, ")");
- open_parens--;
- }
- else if (opr->hint & OH_OFFSET) {
- strcat (ctx->data, "(");
- open_parens++;
- }
- }
- ctx->datalen = strlen (ctx->data);
- }
- return 0;
- }
- int get_operand_value (struct opcode *op, unsigned long instr,
- enum OP_FIELD field, unsigned long *value)
- {
- int i;
- struct operand *opr;
-
- if (field > n_operands) {
- return false;
- }
-
- for (i = 0; op->fields[i] != 0; ++i) {
- if (op->fields[i] != field) {
- continue;
- }
- opr = &operands[op->fields[i] - 1];
- if (value) {
- *value = (instr >> opr->shift) & ((1 << opr->bits) - 1);
- }
- return true;
- }
- return false;
- }
- struct opcode *find_opcode (unsigned long instr)
- {
- struct opcode *ptr;
- int top = 0;
- int bottom = n_opcodes - 1;
- int idx;
-
- while (top <= bottom) {
- idx = (top + bottom) >> 1;
- ptr = &opcodes[idx];
- if ((instr & ptr->mask) < ptr->opcode) {
- bottom = idx - 1;
- } else if ((instr & ptr->mask) > ptr->opcode) {
- top = idx + 1;
- } else {
- return ptr;
- }
- }
- return (struct opcode *) 0;
- }
- struct opcode *find_opcode_by_name (char *name)
- {
- int idx;
-
- downstring (name);
- for (idx = 0; idx < n_opcodes; ++idx) {
- if (!strcmp (name, opcodes[idx].name))
- return &opcodes[idx];
- }
- return (struct opcode *) 0;
- }
- char *spr_name (int value)
- {
- unsigned short spr;
- static char other[10];
- int i;
-
-
- spr = ((value >> 5) & 0x1f) | ((value & 0x1f) << 5);
- for (i = 0; i < n_sprs; ++i) {
- if (spr == spr_map[i].spr_val)
- return spr_map[i].spr_name;
- }
- sprintf (other, "%d", spr);
- return other;
- }
- int spr_value (char *name)
- {
- struct spr_info *sprp;
- int spr;
- int i;
-
- if (!name || !*name)
- return 0;
- if (isdigit ((int) name[0])) {
- i = htonl (read_number (name));
- spr = ((i >> 5) & 0x1f) | ((i & 0x1f) << 5);
- return spr;
- }
- downstring (name);
- for (i = 0; i < n_sprs; ++i) {
- sprp = &spr_map[i];
- if (strcmp (name, sprp->spr_name) == 0) {
-
- i = htonl (sprp->spr_val);
- spr = ((i >> 5) & 0x1f) | ((i & 0x1f) << 5);
- return spr;
- }
- }
- return 0;
- }
- char *tbr_name (int value)
- {
- unsigned short tbr;
-
-
- tbr = ((value >> 5) & 0x1f) | ((value & 0x1f) << 5);
- if (tbr == 268)
- return "TBL";
- else if (tbr == 269)
- return "TBU";
- return "???";
- }
- int tbr_value (char *name)
- {
- int tbr;
- int val;
-
- if (!name || !*name)
- return 0;
- downstring (name);
- if (isdigit ((int) name[0])) {
- val = read_number (name);
- if (val != 268 && val != 269)
- return 0;
- } else if (strcmp (name, "tbl") == 0)
- val = 268;
- else if (strcmp (name, "tbu") == 0)
- val = 269;
- else
- return 0;
-
- val = htonl (val);
- tbr = ((val >> 5) & 0x1f) | ((val & 0x1f) << 5);
- return tbr;
- }
- int handle_bc (struct ppc_ctx *ctx)
- {
- unsigned long bo;
- unsigned long bi;
- static struct opcode blt = { B_OPCODE (16, 0, 0), B_MASK, {O_BD, 0},
- 0, "blt", H_RELATIVE
- };
- static struct opcode bne =
- { B_OPCODE (16, 0, 0), B_MASK, {O_cr2, O_BD, 0},
- 0, "bne", H_RELATIVE
- };
- static struct opcode bdnz = { B_OPCODE (16, 0, 0), B_MASK, {O_BD, 0},
- 0, "bdnz", H_RELATIVE
- };
-
- if (get_operand_value(ctx->op, ctx->instr, O_BO, &bo) == false)
- return false;
- if (get_operand_value(ctx->op, ctx->instr, O_BI, &bi) == false)
- return false;
- if ((bo == 12) && (bi == 0)) {
- ctx->op = &blt;
- sprintf (&ctx->data[ctx->datalen], "%-7s ", ctx->op->name);
- ctx->datalen += 8;
- print_operands (ctx);
- return true;
- } else if ((bo == 4) && (bi == 10)) {
- ctx->op = =⃥
- sprintf (&ctx->data[ctx->datalen], "%-7s ", ctx->op->name);
- ctx->datalen += 8;
- print_operands (ctx);
- return true;
- } else if ((bo == 16) && (bi == 0)) {
- ctx->op = &bdnz;
- sprintf (&ctx->data[ctx->datalen], "%-7s ", ctx->op->name);
- ctx->datalen += 8;
- print_operands (ctx);
- return true;
- }
- return false;
- }
- int print_source_line (char *filename, char *funcname,
- int line_no, int (*pfunc) (const char *))
- {
- char out_buf[256];
-
- (*pfunc) ("");
- sprintf (out_buf, "%s %s(): line %d", filename, funcname, line_no);
- (*pfunc) (out_buf);
- return true;
- }
- unsigned long asmppc (unsigned long memaddr, char *asm_buf, int *err)
- {
- struct opcode *opc;
- struct operand *oper[MAX_OPERANDS];
- unsigned long instr;
- unsigned long param;
- char *ptr = asm_buf;
- char scratch[20];
- int i;
- int w_operands = 0;
- int n_operands = 0;
- int asm_debug = 0;
-
- if (err)
- *err = 0;
- if (get_word (&ptr, scratch) == 0)
- return 0;
-
- if ((opc = find_opcode_by_name (scratch)) == (struct opcode *) 0) {
- if (err)
- *err = E_ASM_BAD_OPCODE;
- return 0;
- }
- if (asm_debug) {
- printf ("asmppc: Opcode = \"%s\"\n", opc->name);
- }
- for (i = 0; i < 8; ++i) {
- if (opc->fields[i] == 0)
- break;
- ++w_operands;
- }
- if (asm_debug) {
- printf ("asmppc: Expecting %d operands\n", w_operands);
- }
- instr = opc->opcode;
-
- while (n_operands < w_operands) {
- oper[n_operands] = &operands[opc->fields[n_operands] - 1];
- if (oper[n_operands]->hint & OH_SILENT) {
-
- if (asm_debug) {
- printf ("asmppc: Operand %d \"%s\" SILENT\n", n_operands,
- oper[n_operands]->name);
- }
- ++n_operands;
- continue;
- }
- if (get_word (&ptr, scratch) == 0)
- break;
- if (asm_debug) {
- printf ("asmppc: Operand %d \"%s\" : \"%s\"\n", n_operands,
- oper[n_operands]->name, scratch);
- }
- if ((param = parse_operand (memaddr, opc, oper[n_operands],
- scratch, err)) == -1)
- return 0;
- instr |= param;
- ++n_operands;
- }
- if (n_operands < w_operands) {
- if (err)
- *err = E_ASM_NUM_OPERANDS;
- return 0;
- }
- if (asm_debug) {
- printf ("asmppc: Instruction = 0x%08lx\n", instr);
- }
- return instr;
- }
- int parse_operand (unsigned long memaddr, struct opcode *opc,
- struct operand *oper, char *txt, int *err)
- {
- long data;
- long mask;
- int is_neg = 0;
-
- mask = (1 << oper->bits) - 1;
- if (oper->hint & OH_ADDR) {
- data = read_number (txt);
- if (opc->hint & H_RELATIVE)
- data = data - memaddr;
- if (data < 0)
- is_neg = 1;
- data >>= 2;
- data &= (mask >> 1);
- if (is_neg)
- data |= 1 << (oper->bits - 1);
- }
- else if (oper->hint & OH_REG) {
- if (txt[0] == 'r' || txt[0] == 'R')
- txt++;
- else if (txt[0] == '%' && (txt[1] == 'r' || txt[1] == 'R'))
- txt += 2;
- data = read_number (txt);
- if (data > 31) {
- if (err)
- *err = E_ASM_BAD_REGISTER;
- return -1;
- }
- data = htonl (data);
- }
- else if (oper->hint & OH_SPR) {
- if ((data = spr_value (txt)) == 0) {
- if (err)
- *err = E_ASM_BAD_SPR;
- return -1;
- }
- }
- else if (oper->hint & OH_TBR) {
- if ((data = tbr_value (txt)) == 0) {
- if (err)
- *err = E_ASM_BAD_TBR;
- return -1;
- }
- }
- else {
- data = htonl (read_number (txt));
- }
- return (data & mask) << oper->shift;
- }
- char *asm_error_str (int err)
- {
- switch (err) {
- case E_ASM_BAD_OPCODE:
- return "Bad opcode";
- case E_ASM_NUM_OPERANDS:
- return "Bad number of operands";
- case E_ASM_BAD_REGISTER:
- return "Bad register number";
- case E_ASM_BAD_SPR:
- return "Bad SPR name or number";
- case E_ASM_BAD_TBR:
- return "Bad TBR name or number";
- }
- return "";
- }
- int get_word (char **src, char *dest)
- {
- char *ptr = *src;
- int nchars = 0;
-
-
- while (*ptr && isblank (*ptr))
- ptr++;
- if (*ptr == 0) {
- *src = ptr;
- return 0;
- }
-
- while (*ptr && !isblank (*ptr) && (*ptr != ','))
- dest[nchars++] = *ptr++;
- ptr = (*ptr == ',') ? ptr + 1 : ptr;
- dest[nchars] = 0;
- *src = ptr;
- return nchars;
- }
- long read_number (char *txt)
- {
- long val;
- int is_neg = 0;
-
- if (txt == 0 || *txt == 0)
- return 0;
- if (*txt == '-') {
- is_neg = 1;
- ++txt;
- }
- if (txt[0] == '0' && (txt[1] == 'x' || txt[1] == 'X'))
- val = simple_strtoul (&txt[2], NULL, 16);
- else
- val = simple_strtoul (txt, NULL, 10);
- if (is_neg)
- val = -val;
- return val;
- }
- int downstring (char *s)
- {
- if (!s || !*s)
- return 0;
- while (*s) {
- if (isupper (*s))
- *s = tolower (*s);
- s++;
- }
- return 0;
- }
- int find_next_address (unsigned char *nextaddr, int step_over,
- struct pt_regs *regs)
- {
- unsigned long pc;
- unsigned long ctr;
- unsigned long cr;
- unsigned long lr;
- unsigned long instr;
- unsigned long next;
- unsigned long step;
- unsigned long addr = 0;
- unsigned long aa = 0;
- unsigned long lk = 0;
- unsigned long bo = 0;
- unsigned long bi = 0;
- struct opcode *op = 0;
- int ctr_ok = 0;
- int cond_ok = 0;
- int conditional = 0;
- int branch = 0;
-
- if (nextaddr == 0 || regs == 0) {
- printf ("find_next_address: bad args");
- return false;
- }
- pc = regs->nip & 0xfffffffc;
- instr = INSTRUCTION (pc);
- if ((op = find_opcode (instr)) == (struct opcode *) 0) {
- printf ("find_next_address: can't parse opcode 0x%lx", instr);
- return false;
- }
- ctr = regs->ctr;
- cr = regs->ccr;
- lr = regs->link;
- switch (op->opcode) {
- case B_OPCODE (16, 0, 0):
- case B_OPCODE (16, 0, 1):
- case B_OPCODE (16, 1, 0):
- case B_OPCODE (16, 1, 1):
- if (!get_operand_value (op, instr, O_BD, &addr) ||
- !get_operand_value (op, instr, O_BO, &bo) ||
- !get_operand_value (op, instr, O_BI, &bi) ||
- !get_operand_value (op, instr, O_AA, &aa) ||
- !get_operand_value (op, instr, O_LK, &lk))
- return false;
- if ((addr & (1 << 13)) != 0)
- addr = addr - (1 << 14);
- addr <<= 2;
- conditional = 1;
- branch = 1;
- break;
- case I_OPCODE (18, 0, 0):
- case I_OPCODE (18, 0, 1):
- case I_OPCODE (18, 1, 0):
- case I_OPCODE (18, 1, 1):
- if (!get_operand_value (op, instr, O_LI, &addr) ||
- !get_operand_value (op, instr, O_AA, &aa) ||
- !get_operand_value (op, instr, O_LK, &lk))
- return false;
- if ((addr & (1 << 23)) != 0)
- addr = addr - (1 << 24);
- addr <<= 2;
- conditional = 0;
- branch = 1;
- break;
- case XL_OPCODE (19, 528, 0):
- case XL_OPCODE (19, 528, 1):
- if (!get_operand_value (op, instr, O_BO, &bo) ||
- !get_operand_value (op, instr, O_BI, &bi) ||
- !get_operand_value (op, instr, O_LK, &lk))
- return false;
- addr = ctr;
- aa = 1;
- conditional = 1;
- branch = 1;
- break;
- case XL_OPCODE (19, 16, 0):
- case XL_OPCODE (19, 16, 1):
- if (!get_operand_value (op, instr, O_BO, &bo) ||
- !get_operand_value (op, instr, O_BI, &bi) ||
- !get_operand_value (op, instr, O_LK, &lk))
- return false;
- addr = lr;
- aa = 1;
- conditional = 1;
- branch = 1;
- break;
- default:
- conditional = 0;
- branch = 0;
- break;
- }
- if (conditional) {
- switch ((bo & 0x1e) >> 1) {
- case 0:
- if (--ctr != 0)
- ctr_ok = 1;
- cond_ok = !(cr & (1 << (31 - bi)));
- break;
- case 1:
- if (--ctr == 0)
- ctr_ok = 1;
- cond_ok = !(cr & (1 << (31 - bi)));
- break;
- case 2:
- ctr_ok = 1;
- cond_ok = !(cr & (1 << (31 - bi)));
- break;
- case 4:
- if (--ctr != 0)
- ctr_ok = 1;
- cond_ok = cr & (1 << (31 - bi));
- break;
- case 5:
- if (--ctr == 0)
- ctr_ok = 1;
- cond_ok = cr & (1 << (31 - bi));
- break;
- case 6:
- ctr_ok = 1;
- cond_ok = cr & (1 << (31 - bi));
- break;
- case 8:
- if (--ctr != 0)
- ctr_ok = cond_ok = 1;
- break;
- case 9:
- if (--ctr == 0)
- ctr_ok = cond_ok = 1;
- break;
- case 10:
- ctr_ok = cond_ok = 1;
- break;
- }
- }
- if (branch && (!conditional || (ctr_ok && cond_ok))) {
- if (aa)
- step = addr;
- else
- step = addr + pc;
- if (lk)
- next = pc + 4;
- else
- next = step;
- } else {
- step = next = pc + 4;
- }
- if (step_over == true)
- *(unsigned long *) nextaddr = next;
- else
- *(unsigned long *) nextaddr = step;
- return true;
- }
|