mirror of
https://github.com/sxpert/hp-saturn
synced 2025-01-31 19:57:50 +01:00
add GOSUB
This commit is contained in:
parent
5a834d9006
commit
bb298832ff
2 changed files with 38 additions and 2 deletions
|
@ -17,8 +17,9 @@
|
|||
`define DEC_LC_LEN 21 // 3n...
|
||||
`define DEC_LC 22 // 3n[x]
|
||||
`define DEC_GOTO 30 // 6
|
||||
`define DEC_GOTO_LOOP 31 // 6[x]
|
||||
`define DEC_GOTO_EXEC 32 // 6xxx -> exec
|
||||
`define DEC_GOTO_LOOP 31 // 6[x] -> exec
|
||||
`define DEC_GOSUB 32 // 7
|
||||
`define DEC_GOSUB_LOOP 33 // 7[x] -> exec
|
||||
`define DEC_8X 40 // 8X
|
||||
`define DEC_80X 41 // 80X
|
||||
`define DEC_CONFIG 42 // 805
|
||||
|
@ -37,5 +38,6 @@
|
|||
`define DEC_AaX_EXEC 71 // Aax
|
||||
`define DEC_AbX_EXEC 72 // Abx
|
||||
`define DEC_BX 80 // Bx
|
||||
`define DEC_DX 100 // Dx
|
||||
|
||||
`endif
|
34
opcodes/7xxx_GOSUB.v
Normal file
34
opcodes/7xxx_GOSUB.v
Normal file
|
@ -0,0 +1,34 @@
|
|||
/******************************************************************************
|
||||
* 6xxx GOSUB xxx
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
`include "decstates.v"
|
||||
`include "bus_commands.v"
|
||||
|
||||
`DEC_GOSUB: begin
|
||||
//$display("DEC_GOTO : nibble %h", nibble);
|
||||
jump_offset <= 0;
|
||||
t_cnt <= 2;
|
||||
t_ctr <= 1;
|
||||
jump_offset[3:0] <= nibble;
|
||||
rstk_ptr <= rstk_ptr + 1;
|
||||
decstate <= `DEC_GOSUB_LOOP;
|
||||
end
|
||||
`DEC_GOSUB_LOOP: begin
|
||||
$display("PC %h | t_cnt %d | t_ctr %d | jump_offset %h", PC, t_cnt, t_ctr, jump_offset);
|
||||
jump_offset[t_ctr*4+:4] <= nibble;
|
||||
if (t_ctr == t_cnt) begin
|
||||
new_PC <= PC + 1 + {8'h00, nibble, jump_offset[7:0]};
|
||||
next_cycle <= `BUSCMD_LOAD_PC;
|
||||
decstate <= `DEC_START;
|
||||
RSTK[rstk_ptr] <= PC + 1;
|
||||
`ifdef SIM
|
||||
$display("%5h GOSUB\t%3h\t=> %05h",
|
||||
inst_start_PC,
|
||||
{nibble, jump_offset[7:0]},
|
||||
PC + 1 + {8'h00, nibble, jump_offset[7:0]});
|
||||
`endif
|
||||
end else t_ctr <= t_ctr + 1;
|
||||
end
|
Loading…
Add table
Reference in a new issue