fix DUPk not working (use pop instead of peek)
This commit is contained in:
parent
9ee039f413
commit
5d28728e61
3 changed files with 19 additions and 23 deletions
|
|
@ -84,9 +84,6 @@ let dev (Machine { dev; _ }) = dev
|
|||
let wst (Machine { stack; _ }) = stack
|
||||
let rst (Machine { callstack; _ }) = callstack
|
||||
|
||||
let stack (Machine { stack; callstack; _ }) mode =
|
||||
if mode then callstack else stack
|
||||
|
||||
let create code =
|
||||
let data = Bytes.create 65536 in
|
||||
let dev = Bytes.create 256 in
|
||||
|
|
@ -178,8 +175,9 @@ let dispatch ?(trace = false) ?(breakpoints = []) (Machine m) (pc : int) =
|
|||
push mode stk c;
|
||||
push mode stk a
|
||||
| 0x06 (* DUP *) ->
|
||||
let a = peek mode stk in
|
||||
let a = pop mode stk in
|
||||
trace [ a ];
|
||||
push mode stk a;
|
||||
push mode stk a
|
||||
| 0x07 (* OVR *) ->
|
||||
let b = pop mode stk in
|
||||
|
|
@ -203,7 +201,7 @@ let dispatch ?(trace = false) ?(breakpoints = []) (Machine m) (pc : int) =
|
|||
let a = pop mode stk in
|
||||
trace [ a; b ];
|
||||
pushbyte mode stk (if a > b then 1 else 0)
|
||||
| 0x0b (* GTH *) ->
|
||||
| 0x0b (* LTH *) ->
|
||||
let b = pop mode stk in
|
||||
let a = pop mode stk in
|
||||
trace [ a; b ];
|
||||
|
|
@ -223,18 +221,10 @@ let dispatch ?(trace = false) ?(breakpoints = []) (Machine m) (pc : int) =
|
|||
let addr = pop mode stk in
|
||||
trace [ addr ];
|
||||
if short then pc := addr else pc := !pc + Util.uint8_to_int8 addr
|
||||
| 0x0f (* STH *) -> (
|
||||
| 0x0f (* STH *) ->
|
||||
let a = pop mode stk in
|
||||
trace [ a ];
|
||||
match mode with
|
||||
| Mode mode ->
|
||||
push
|
||||
(Mode
|
||||
{
|
||||
mode with
|
||||
temp = (match stk' with Stack { sp; _ } -> sp);
|
||||
})
|
||||
stk' a)
|
||||
push mode stk' a
|
||||
| 0x10 (* LDZ *) ->
|
||||
let addr = popbyte mode stk in
|
||||
trace [ addr ];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue