Closed differentprogramming closed 5 years ago
I bet that no one recognized that problem when @mist64 moved many variables from the zero page! Some bit
-skips are invalid, now. That might be one reason why Release 34 seems to be a regression.
65816 "emulation mode" is not emulating a 65C02 processor, it is emulating 65C02 opcodes ... so any opcodes that are not implemented in the base 65C02 perform their 65816 operation in emulation mode. If there is a "COP" encountered, it would execute a vectored coprocessor call whether it is in emulation mode or not.
After all, that's how you escape emulation mode ... by using a 65816 opcode that is not a base 65C02 opcode.
Found another bit instruction bug. I'm gonna get rid of all of them and do a pull request
Look at this, a bit instruction skipping to a bne. That can NEVER work
; ** ; close_all - closes all files on a ; given device. ; ; > search tables for given fa & do a ; proper close for all matches. ; ; > IF one of the closed entries is the ; current I/O channel THEN the default ; channel will be restored. ; ; entry: .a = device (fa) to close ; ; **
close_all sta fa ;save device to shut down cmp dflto bne @10 ;...branch if not current output device lda #3 sta dflto ;restore screen output .byte $2c
@10 cmp dfltn bne @20 ;...branch if not current input device lda #0 sta dfltn ;restore keyboard input
Or look at this one CBDOS better never be defined or it will skip the first two bytes of a jsr
.segment "SERIAL"
sdata = $ffff ; XXX fill for X16
;command serial bus device to talk ; talk .ifdef CBDOS jsr jsrfar .word $c000 + 3 * 7 .byte BANK_CBDOS rts .endif ora #$40 ;make a talk adr .byt $2c ;skip two bytes
;command serial bus device to listen ; listn .ifdef CBDOS jsr jsrfar .word $c000 + 3 * 6 .byte BANK_CBDOS rts .endif ora #$20 ;make a listen adr list1 pha
I had a bug in Basic that I suspected was this. I built roms with no .byte $2c in the basic or kernal roms, and yes, it fixes the bug.
The fix is merged. Thank you everyone!
The "bit" instruction hack is used to skip a 3 byte instruction instead of a 2 byte instruction. The reason it's working is that the unmasked byte is $02 and the emulator mistakenly assumes that all unused instruction are 1 byte NOPS. In reality it's a 2 byte NOP on the 65c02.
Not sure about a 65816 in emulation mode. In regular mode it's a 2 byte COP instruction. And on the original 6502 it's a KIL.
The original Kernal was 8k and you have 16k, so PLEASE get rid of these tricks that stop the assembler from flagging errors. You just don't need the extra bytes. And if you really want to optimize the code, then do it after the code is stable and only make changes that will be significant.
; RECEIVE SCANCODE AFTER shflag ; key down only ; modifiers have been interpreted ; and filtered ; out: X: prefix (E0, E1; 0 = none) ; A: scancode low (0 = none) ; Z: scancode available ; 0: yes ; 1: no ;**** receive_down_scancode_no_modifiers: jsr receive_scancode beq no_key jsr scancode_to_joystick php jsr check_mod bcc no_mod plp bcc key_down eor #$ff and shflag .byte $2c key_down: ;THIS LINE IS WRONG BECAUSE shflag IS NOT ON ZERO PAGE ora shflag sta shflag key_up: lda #0 ; no key to return rts no_mod: plp bcs key_up no_key: rts ; original Z is retained