]> Joshua Wise's Git repositories - fpgaboy.git/blob - core/insn_call-callcc.v
Instructions: ld hl, sp+imm8 and add sp, imm8
[fpgaboy.git] / core / insn_call-callcc.v
1 `define INSN_CALL               9'b011001101
2 `define INSN_CALLCC             9'b0110xx100    // Not that call/cc.
3
4 `ifdef EXECUTE
5         `INSN_CALL,`INSN_CALLCC: begin
6                 case (cycle)
7                 0:      begin
8                                 `EXEC_INC_PC
9                                 `EXEC_READ(`_PC + 1)
10                         end
11                 1:      begin
12                                 `EXEC_INC_PC
13                                 `EXEC_READ(`_PC + 1)
14                         end
15                 2:      begin
16                                 `EXEC_INC_PC
17                                 if (!opcode[0]) // i.e., is callcc
18                                         /* We need to check the condition code to bail out. */
19                                         case (opcode[4:3])
20                                         `INSN_cc_NZ:    if (`_F[7]) `EXEC_NEWCYCLE
21                                         `INSN_cc_Z:     if (~`_F[7]) `EXEC_NEWCYCLE
22                                         `INSN_cc_NC:    if (`_F[4]) `EXEC_NEWCYCLE
23                                         `INSN_cc_C:     if (~`_F[4]) `EXEC_NEWCYCLE
24                                         endcase
25                         end
26                 3:      `EXEC_WRITE(`_SP - 1, `_PCH)
27                 4:      `EXEC_WRITE(`_SP - 2, `_PCL)
28                 5:      `EXEC_NEWCYCLE
29                 endcase
30         end
31 `endif
32
33 `ifdef WRITEBACK
34         `INSN_CALL,`INSN_CALLCC: begin
35                 case (cycle)
36                 0:      begin /* type F */ end
37                 1:      tmp <= rdata;   // tmp contains newpcl
38                 2:      tmp2 <= rdata;  // tmp2 contains newpch
39                 3:      begin /* type F */ end
40                 4:      `_PCH <= tmp2;
41                 5:      begin
42                                 `_PCL <= tmp;
43                                 `_SP <= `_SP - 2;
44                         end
45                 endcase
46         end
47 `endif
This page took 0.028483 seconds and 4 git commands to generate.