Previous 199869 Revisions Next

r18824 Saturday 3rd November, 2012 at 00:29:31 UTC by R. Belmont
Z8000: Fixed implementation of trdb, trdrb, trib, trirb, trtdb, trtdrb, trtib, trtirb instructions. [Christian Grössler]
[src/emu/cpu/z8000]z8000ops.c

trunk/src/emu/cpu/z8000/z8000ops.c
r18823r18824
58295829}
58305830
58315831/******************************************
5832 trtib   @rd,@rs,rr
5833 flags:  -ZSV--
5832 trtib    @rd,@rs,rr
5833 flags:    -ZSV--
58345834 ******************************************/
58355835static void ZB8_ddN0_0010_0000_rrrr_ssN0_0000(z8000_state *cpustate)
5836{//@@@
5836{
58375837   GET_DST(OP0,NIB2);
58385838   GET_SRC(OP1,NIB2);
58395839   GET_CNT(OP1,NIB1);
5840   UINT8 xlt = RDMEM_B(cpustate,  (UINT16)(cpustate->RW(src) + RDMEM_B(cpustate, cpustate->RW(dst))));
5841   cpustate->RB(2) = xlt;
5840   UINT8 xlt = RDMEM_B(cpustate, addr_from_reg(cpustate, src) + RDMEM_B(cpustate, addr_from_reg(cpustate, dst)));
5841   cpustate->RB(1) = xlt;   /* load RH1 */
58425842   if (xlt) CLR_Z; else SET_Z;
5843   cpustate->RW(dst)++;
5843   addr_to_reg(cpustate, dst, addr_add(cpustate, addr_from_reg(cpustate, dst), 1));
58445844   if (--cpustate->RW(cnt)) CLR_V; else SET_V;
58455845}
58465846
58475847/******************************************
5848 trtirb  @rd,@rs,rbr
5849 flags:  -ZSV--
5848 trtirb    @rd,@rs,rbr
5849 flags:    -ZSV--
58505850 ******************************************/
58515851static void ZB8_ddN0_0110_0000_rrrr_ssN0_1110(z8000_state *cpustate)
5852{//@@@
5852{
58535853   GET_DST(OP0,NIB2);
58545854   GET_SRC(OP1,NIB2);
58555855   GET_CNT(OP1,NIB1);
5856   UINT8 xlt = RDMEM_B(cpustate,  (UINT16)(cpustate->RW(src) + RDMEM_B(cpustate, cpustate->RW(dst))));
5857   cpustate->RB(2) = xlt;
5856   UINT8 xlt = RDMEM_B(cpustate, addr_from_reg(cpustate, src) + RDMEM_B(cpustate, addr_from_reg(cpustate, dst)));
5857   cpustate->RB(1) = xlt;   /* load RH1 */
58585858   if (xlt) CLR_Z; else SET_Z;
5859   cpustate->RW(dst)++;
5860   if (--cpustate->RW(cnt)) { CLR_V; cpustate->pc -= 4; } else SET_V;
5859   addr_to_reg(cpustate, dst, addr_sub(cpustate, addr_from_reg(cpustate, dst), 1));
5860   if (--cpustate->RW(cnt)) {
5861     CLR_V;
5862     if (!xlt)
5863       cpustate->pc -= 4;
5864   }
5865   else SET_V;
58615866}
58625867
58635868/******************************************
5864 trtdb   @rd,@rs,rbr
5865 flags:  -ZSV--
5869 trtdb    @rd,@rs,rbr
5870 flags:    -ZSV--
58665871 ******************************************/
58675872static void ZB8_ddN0_1010_0000_rrrr_ssN0_0000(z8000_state *cpustate)
5868{//@@@
5873{
58695874   GET_DST(OP0,NIB2);
58705875   GET_SRC(OP1,NIB2);
58715876   GET_CNT(OP1,NIB1);
5872   UINT8 xlt = RDMEM_B(cpustate,  (UINT16)(cpustate->RW(src) + RDMEM_B(cpustate, cpustate->RW(dst))));
5873   cpustate->RB(2) = xlt;
5877   UINT8 xlt = RDMEM_B(cpustate, addr_from_reg(cpustate, src) + RDMEM_B(cpustate, addr_from_reg(cpustate, dst)));
5878   cpustate->RB(1) = xlt;   /* load RH1 */
58745879   if (xlt) CLR_Z; else SET_Z;
5875    cpustate->RW(dst)--;
5880   addr_to_reg(cpustate, dst, addr_sub(cpustate, addr_from_reg(cpustate, dst), 1));
58765881   if (--cpustate->RW(cnt)) CLR_V; else SET_V;
58775882}
58785883
58795884/******************************************
5880 trtdrb  @rd,@rs,rbr
5881 flags:  -ZSV--
5885 trtdrb    @rd,@rs,rbr
5886 flags:    -ZSV--
58825887 ******************************************/
58835888static void ZB8_ddN0_1110_0000_rrrr_ssN0_1110(z8000_state *cpustate)
5884{//@@@
5889{
58855890   GET_DST(OP0,NIB2);
58865891   GET_SRC(OP1,NIB2);
58875892   GET_CNT(OP1,NIB1);
5888   UINT8 xlt = RDMEM_B(cpustate,  (UINT16)(cpustate->RW(src) + RDMEM_B(cpustate, cpustate->RW(dst))));
5889   cpustate->RB(2) = xlt;
5893   UINT8 xlt = RDMEM_B(cpustate, addr_from_reg(cpustate, src) + RDMEM_B(cpustate, addr_from_reg(cpustate, dst)));
5894   cpustate->RB(1) = xlt;   /* load RH1 */
58905895   if (xlt) CLR_Z; else SET_Z;
5891    cpustate->RW(dst)--;
5892   if (--cpustate->RW(cnt)) { CLR_V; cpustate->pc -= 4; } else SET_V;
5896   addr_to_reg(cpustate, dst, addr_sub(cpustate, addr_from_reg(cpustate, dst), 1));
5897   if (--cpustate->RW(cnt)) {
5898     CLR_V;
5899     if (!xlt)
5900       cpustate->pc -= 4;
5901   }
5902   else SET_V;
58935903}
58945904
58955905/******************************************
5896 trib    @rd,@rs,rbr
5897 flags:  -ZSV--
5906 trib    @rd,@rs,rbr
5907 flags:    -ZSV--
58985908 ******************************************/
58995909static void ZB8_ddN0_0000_0000_rrrr_ssN0_0000(z8000_state *cpustate)
5900{//@@@
5910{
59015911   GET_DST(OP0,NIB2);
59025912   GET_SRC(OP1,NIB2);
59035913   GET_CNT(OP1,NIB1);
5904   UINT8 xlt = RDMEM_B(cpustate,  (UINT16)(cpustate->RW(src) + RDMEM_B(cpustate, cpustate->RW(dst))));
5905   WRMEM_B(cpustate,  cpustate->RW(dst), xlt);
5906   cpustate->RW(dst)++;
5914   UINT8 xlt = RDMEM_B(cpustate, addr_from_reg(cpustate, src) + RDMEM_B(cpustate, addr_from_reg(cpustate, dst)));
5915   WRMEM_B(cpustate, addr_from_reg(cpustate, dst), xlt);
5916   cpustate->RB(1) = xlt;   /* destroy RH1 */
5917   addr_to_reg(cpustate, dst, addr_add(cpustate, addr_from_reg(cpustate, dst), 1));
59075918   if (--cpustate->RW(cnt)) CLR_V; else SET_V;
59085919}
59095920
59105921/******************************************
5911 trirb   @rd,@rs,rbr
5912 flags:  -ZSV--
5922 trirb    @rd,@rs,rbr
5923 flags:    -ZSV--
59135924 ******************************************/
59145925static void ZB8_ddN0_0100_0000_rrrr_ssN0_0000(z8000_state *cpustate)
5915{//@@@
5926{
59165927   GET_DST(OP0,NIB2);
59175928   GET_SRC(OP1,NIB2);
59185929   GET_CNT(OP1,NIB1);
5919   UINT8 xlt = RDMEM_B(cpustate,  (UINT16)(cpustate->RW(src) + RDMEM_B(cpustate, cpustate->RW(dst))));
5920   WRMEM_B(cpustate,  cpustate->RW(dst), xlt);
5921   cpustate->RW(dst)++;
5930   UINT8 xlt = RDMEM_B(cpustate, addr_from_reg(cpustate, src) + RDMEM_B(cpustate, addr_from_reg(cpustate, dst)));
5931   WRMEM_B(cpustate, addr_from_reg(cpustate, dst), xlt);
5932   cpustate->RB(1) = xlt;   /* destroy RH1 */
5933   addr_to_reg(cpustate, dst, addr_add(cpustate, addr_from_reg(cpustate, dst), 1));
59225934   if (--cpustate->RW(cnt)) { CLR_V; cpustate->pc -= 4; } else SET_V;
59235935}
59245936
59255937/******************************************
5926 trdb    @rd,@rs,rbr
5927 flags:  -ZSV--
5938 trdb    @rd,@rs,rbr
5939 flags:    -ZSV--
59285940 ******************************************/
59295941static void ZB8_ddN0_1000_0000_rrrr_ssN0_0000(z8000_state *cpustate)
5930{//@@@
5942{
59315943   GET_DST(OP0,NIB2);
59325944   GET_SRC(OP1,NIB2);
59335945   GET_CNT(OP1,NIB1);
5934   UINT8 xlt = RDMEM_B(cpustate,  (UINT16)(cpustate->RW(src) + RDMEM_B(cpustate, cpustate->RW(dst))));
5935   WRMEM_B(cpustate,  cpustate->RW(dst), xlt);
5936    cpustate->RW(dst)--;
5946   UINT8 xlt = RDMEM_B(cpustate, addr_from_reg(cpustate, src) + RDMEM_B(cpustate, addr_from_reg(cpustate, dst)));
5947   WRMEM_B(cpustate, addr_from_reg(cpustate, dst), xlt);
5948   cpustate->RB(1) = xlt;   /* destroy RH1 */
5949   addr_to_reg(cpustate, dst, addr_sub(cpustate, addr_from_reg(cpustate, dst), 1));
59375950   if (--cpustate->RW(cnt)) CLR_V; else SET_V;
59385951}
59395952
59405953/******************************************
5941 trdrb   @rd,@rs,rbr
5942 flags:  -ZSV--
5954 trdrb    @rd,@rs,rbr
5955 flags:    -ZSV--
59435956 ******************************************/
59445957static void ZB8_ddN0_1100_0000_rrrr_ssN0_0000(z8000_state *cpustate)
5945{//@@@
5958{
59465959   GET_DST(OP0,NIB2);
59475960   GET_SRC(OP1,NIB2);
59485961   GET_CNT(OP1,NIB1);
5949   UINT8 xlt = RDMEM_B(cpustate,  (UINT16)(cpustate->RW(src) + RDMEM_B(cpustate, cpustate->RW(dst))));
5950   WRMEM_B(cpustate,  cpustate->RW(dst), xlt);
5951    cpustate->RW(dst)--;
5962   UINT8 xlt = RDMEM_B(cpustate, addr_from_reg(cpustate, src) + RDMEM_B(cpustate, addr_from_reg(cpustate, dst)));
5963   WRMEM_B(cpustate, addr_from_reg(cpustate, dst), xlt);
5964   cpustate->RB(1) = xlt;   /* destroy RH1 */
5965   addr_to_reg(cpustate, dst, addr_sub(cpustate, addr_from_reg(cpustate, dst), 1));
59525966   if (--cpustate->RW(cnt)) { CLR_V; cpustate->pc -= 4; } else SET_V;
59535967}
59545968

Previous 199869 Revisions Next


© 1997-2024 The MAME Team