From: Stuart B. <zu...@us...> - 2007-03-02 23:47:54
|
Update of /cvsroot/hppaqemu/hppaqemu/target-hppa In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv311 Modified Files: exec.h op.c translate.c Log Message: Most recent version, with better carry flag code and various cleanups. Index: translate.c =================================================================== RCS file: /cvsroot/hppaqemu/hppaqemu/target-hppa/translate.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** translate.c 27 Feb 2007 23:21:24 -0000 1.2 --- translate.c 2 Mar 2007 23:47:46 -0000 1.3 *************** *** 267,270 **** --- 267,282 ---- */ + /* two possible ways to do nullification + * easiest is probably to generate code to check the N flag on each insn + * (which also sucks) + * + * actually can use the DisasContext so that checking is only done + * where the insn could be anulled + */ + + /* possily anulled? */ + + /* if so, check N flag. if set, branch and clear flag */ + /* Major Opcodes */ switch(op) { *************** *** 435,442 **** break; case 0x26: /* UADDCM */ ! genn_op_uaddcm_T1_T0(); break; case 0x27: /* UADDCMT */ ! genn_op_uaddcmt_T1_T0(); break; case 0x28: /* ADDL */ --- 447,455 ---- break; case 0x26: /* UADDCM */ ! gen_com_T1(); ! gen_op_addl_T1_T0(); break; case 0x27: /* UADDCMT */ ! gen_op_uaddcmt_T1_T0(); break; case 0x28: /* ADDL */ *************** *** 545,549 **** gen_movl_T1_reg(r); gen_movl_imm_T0(im21); ! gen_op_add_T1_T0(); gen_movl_reg_T0(1); break; --- 558,562 ---- gen_movl_T1_reg(r); gen_movl_imm_T0(im21); ! gen_op_addl_T1_T0(); gen_movl_reg_T0(1); break; Index: op.c =================================================================== RCS file: /cvsroot/hppaqemu/hppaqemu/target-hppa/op.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** op.c 27 Feb 2007 23:21:24 -0000 1.2 --- op.c 2 Mar 2007 23:47:46 -0000 1.3 *************** *** 2,6 **** * HPPA micro operations * ! * Copyright (c) 2005 Stuart brady <sd...@nt...> * * This library is free software; you can redistribute it and/or --- 2,6 ---- * HPPA micro operations * ! * Copyright (c) 2005 Stuart Brady <sd...@nt...> * * This library is free software; you can redistribute it and/or *************** *** 120,129 **** void OPPROTO op_mov_T0_GR0(void) { ! T0 = 0; } void OPPROTO op_mov_T1_GR0(void) { ! T1 = 0; } --- 120,129 ---- void OPPROTO op_mov_T0_GR0(void) { ! T0 = 0; } void OPPROTO op_mov_T1_GR0(void) { ! T1 = 0; } *************** *** 138,204 **** void OPPROTO op_mov_T0_im(void) { ! T0 = PARAM1; } void OPPROTO op_mov_T1_im(void) { ! T1 = PARAM1; } /* TODO: lazy PSW */ ! void OPPROTO op_addc_T1_T0(void) { ! uint32_t mask; ! uint32_t pswbit; ! int carry; ! int i; ! ! T0 += T1; ! /* add the carry */ ! if (env->psw & PSW_CB7) { ! T0 += 1; ! carry = 1; ! } else { ! carry = 0; ! } /* calculate carry flags */ ! i = 0; env->psw &= ~PSW_CB ! mask = 0xffffffff; ! pswbit = PSW_CB7; ! while(i < 8) { ! if(((T0 & mask) < (T1 & mask)) || ! (carry && ((T0 & mask) == (T1 & mask)))) ! env->psw |= pswbit; ! pswbit >>= 1; ! mask >>= 4; ! mask &= 0x0fffffff; ! i++; ! } } /* TODO: lazy PSW */ ! void OPPROTO op_add_T1_T0(void) { ! uint32_t mask; ! uint32_t pswbit; ! int i; T0 += T1; /* calculate carry flags */ ! i = 0; env->psw &= ~PSW_CB ! mask = 0xffffffff; ! pswbit = PSW_CB7; ! while(i < 8) { ! if((T0 & mask) < (T1 & mask)) ! env->psw |= pswbit; ! pswbit >>= 1; ! mask >>= 4; ! mask &= 0x0fffffff; ! i++; ! } /* gen_op_add_T1_imm(1) -- for ADDC and ADDCO */ --- 138,207 ---- void OPPROTO op_mov_T0_im(void) { ! T0 = PARAM1; } void OPPROTO op_mov_T1_im(void) { ! T1 = PARAM1; } + + /* computation instructions... page 169 PA1.1 specification */ + /* TODO: lazy PSW */ ! void OPPROTO op_add_T1_T0(void) { ! target_ulong carry; ! target_ulong tmp; + tmp = T0; + T0 += T1; + /* calculate carry flags */ ! carry = (tmp & T1) | ((tmp | T1) & ~T0); ! /* extract the MSB from each nibble */ ! /* axxxbxxxcxxxdxxxexxxfxxxgxxxhxxx */ ! carry >>= 3; /* 000axxxbxxxcxxxdxxxexxxfxxxgxxxh */ ! carry &= 0x11111111; /* 000a000b000c000d000e000f000g000h */ ! carry |= carry >> 3; /* 000a00ab00bc00cd00de00ef00fg00gh */ ! carry &= 0x03030303; /* 000000ab000000cd000000ef000000gh */ ! carry |= carry >> 6; /* 000000ab0000abcd000000ef0000efgh */ ! carry &= 0x000f000f; /* 000000000000abcd000000000000efgh */ ! carry |= carry >> 12; /* 000000000000abcd00000000abcdefgh */ ! carry &= 0x000000ff; /* 000000000000000000000000abcdefgh */ ! env->psw &= ~PSW_CB ! env->psw |= carry << PSW_CB7_SHIFT; } /* TODO: lazy PSW */ ! void OPPROTO op_addc_T1_T0(void) { ! target_ulong carry; ! target_ulong tmp; + tmp = T0; T0 += T1; + + /* add the carry */ + if (env->psw & PSW_CB7) { + T0 += 1; + } /* calculate carry flags */ ! carry = (tmp & T1) | ((tmp | T1) & ~T0); ! /* axxxbxxxcxxxdxxxexxxfxxxgxxxhxxx */ ! carry >>= 3; /* 000axxxbxxxcxxxdxxxexxxfxxxgxxxh */ ! carry &= 0x11111111; /* 000a000b000c000d000e000f000g000h */ ! carry |= carry >> 3; /* 000a00ab00bc00cd00de00ef00fg00gh */ ! carry &= 0x03030303; /* 000000ab000000cd000000ef000000gh */ ! carry |= carry >> 6; /* 000000ab0000abcd000000ef0000efgh */ ! carry &= 0x000f000f; /* 000000000000abcd000000000000efgh */ ! carry |= carry >> 12; /* 000000000000abcd00000000abcdefgh */ ! carry &= 0x000000ff; /* 000000000000000000000000abcdefgh */ ! env->psw &= ~PSW_CB ! env->psw |= carry << PSW_CB7_SHIFT; ! } /* gen_op_add_T1_imm(1) -- for ADDC and ADDCO */ *************** *** 206,211 **** /* set condition flags */ /* set nullify if condition met */ - } void OPPROTO op_addl_T1_T0(void) { --- 209,214 ---- /* set condition flags */ /* set nullify if condition met */ + /* add logical */ void OPPROTO op_addl_T1_T0(void) { *************** *** 245,248 **** --- 248,281 ---- } + /* TODO: lazy PSW */ + void OPPROTO op_subc_T1_T0(void) + { + target_ulong borrow; + target_ulong tmp; + + tmp = T0; + T0 -= T1; + + /* subtract the borrow */ + if (!(env->psw & PSW_CB7)) { + T0 -= 1; + } + + /* calculate carry/borrow flags */ + borrow = (~tmp & T1) | (~(tmp ^ T1) & T0); + /* axxxbxxxcxxxdxxxexxxfxxxgxxxhxxx */ + borrow >>= 3; /* 000axxxbxxxcxxxdxxxexxxfxxxgxxxh */ + borrow &= 0x11111111; /* 000a000b000c000d000e000f000g000h */ + borrow |= borrow >> 3; /* 000a00ab00bc00cd00de00ef00fg00gh */ + borrow &= 0x03030303; /* 000000ab000000cd000000ef000000gh */ + borrow |= borrow >> 6; /* 000000ab0000abcd000000ef0000efgh */ + borrow &= 0x000f000f; /* 000000000000abcd000000000000efgh */ + borrow |= borrow >> 12; /* 000000000000abcd00000000abcdefgh */ + borrow &= 0x000000ff; /* 000000000000000000000000abcdefgh */ + + env->psw &= ~PSW_CB + env->psw |= ~borrow << PSW_CB7_SHIFT; + } + void OPPROTO op_next_insn(void) { Index: exec.h =================================================================== RCS file: /cvsroot/hppaqemu/hppaqemu/target-hppa/exec.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** exec.h 27 Feb 2007 23:20:43 -0000 1.1 --- exec.h 2 Mar 2007 23:47:46 -0000 1.2 *************** *** 2,6 **** * HPPA execution defines * ! * Copyright (c) 2005 Stuart Brady * Copyright (c) 2003 Fabrice Bellard * --- 2,6 ---- * HPPA execution defines * ! * Copyright (c) 2005 Stuart Brady <sd...@nt...> * Copyright (c) 2003 Fabrice Bellard * |