+/*-----------------------------------------------------------------*/
+/* pCode2str - convert a pCode instruction to string */
+/*-----------------------------------------------------------------*/
+char *pCode2str(char *str, size_t size, pCode *pc)
+{
+ char *s = str;
+
+ switch(pc->type) {
+
+ case PC_OPCODE:
+
+ SNPRINTF(s,size, "\t%s\t", PCI(pc)->mnemonic);
+ size -= strlen(s);
+ s += strlen(s);
+
+ if( (PCI(pc)->num_ops >= 1) && (PCI(pc)->pcop)) {
+ if(PCI(pc)->isBitInst) {
+ if(PCI(pc)->pcop->type == PO_GPR_BIT) {
+ char *name = PCI(pc)->pcop->name;
+ if (!name)
+ name = PCOR(PCI(pc)->pcop)->r->name;
+ if( (((pCodeOpRegBit *)(PCI(pc)->pcop))->inBitSpace) )
+ SNPRINTF(s,size,"(%s >> 3), (%s & 7)", name, name);
+ else
+ SNPRINTF(s,size,"%s,%d", name, (((pCodeOpRegBit *)(PCI(pc)->pcop))->bit)&7);
+ } else if(PCI(pc)->pcop->type == PO_GPR_BIT) {
+ SNPRINTF(s,size,"%s,%d", get_op_from_instruction(PCI(pc)),PCORB(PCI(pc)->pcop)->bit);
+ } else
+ SNPRINTF(s,size,"%s,0 ; ?bug", get_op_from_instruction(PCI(pc)));
+ } else {
+ if(PCI(pc)->pcop->type == PO_GPR_BIT) {
+ if( PCI(pc)->num_ops == 2)
+ SNPRINTF(s,size,"(%s >> 3),%c",get_op_from_instruction(PCI(pc)),((PCI(pc)->isModReg) ? 'F':'W'));
+ else
+ SNPRINTF(s,size,"(1 << (%s & 7))",get_op_from_instruction(PCI(pc)));
+ } else {
+ SNPRINTF(s,size,"%s",get_op_from_instruction(PCI(pc)));
+ size -= strlen(s);
+ s += strlen(s);
+ if( PCI(pc)->num_ops == 2)
+ SNPRINTF(s,size,",%c", ( (PCI(pc)->isModReg) ? 'F':'W'));
+ }
+ }
+ }
+ break;
+
+ case PC_COMMENT:
+ /* assuming that comment ends with a \n */
+ SNPRINTF(s,size,";%s", ((pCodeComment *)pc)->comment);
+ break;
+
+ case PC_INLINE:
+ /* assuming that inline code ends with a \n */
+ SNPRINTF(s,size,"%s", ((pCodeComment *)pc)->comment);
+ break;
+
+ case PC_LABEL:
+ SNPRINTF(s,size,";label=%s, key=%d\n",PCL(pc)->label,PCL(pc)->key);
+ break;
+ case PC_FUNCTION:
+ SNPRINTF(s,size,";modname=%s,function=%s: id=%d\n",PCF(pc)->modname,PCF(pc)->fname);
+ break;
+ case PC_WILD:
+ SNPRINTF(s,size,";\tWild opcode: id=%d\n",PCW(pc)->id);
+ break;
+ case PC_FLOW:
+ SNPRINTF(s,size,";\t--FLOW change\n");
+ break;
+ case PC_CSOURCE:
+ SNPRINTF(s,size,"%s\t.line\t%d; \"%s\"\t%s\n",(options.debug?"":";"),PCCS(pc)->line_number, PCCS(pc)->file_name, PCCS(pc)->line);
+ break;
+ case PC_ASMDIR:
+ if(PCAD(pc)->directive) {
+ SNPRINTF(s,size,"\t%s%s%s\n", PCAD(pc)->directive, PCAD(pc)->arg?"\t":"", PCAD(pc)->arg?PCAD(pc)->arg:"");
+ } else if(PCAD(pc)->arg) {
+ /* special case to handle inline labels without a tab */
+ SNPRINTF(s,size,"%s\n", PCAD(pc)->arg);
+ }
+ break;
+
+ case PC_BAD:
+ SNPRINTF(s,size,";A bad pCode is being used\n");