emulator crashing when sep/rep processor status bits

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
dext3r
Posts: 14
Joined: Fri May 06, 2011 1:03 pm

emulator crashing when sep/rep processor status bits

Post by dext3r »

hello, im using Neviksti's snes-starterkit (WLA-DX assembler) and messing with the example Hello.asm...

let me show some example code:

Code: Select all

	
; some other init code/misc stuff goes here....

; do some math with the decimal flag clear
	PrintString "\nDecimal flag clear: 9+8 = "
	lda #9
	clc
	adc #8
	sta var2	
	PrintNum var2

;this is what i put in
   rep #$30 ;16 bit A, X, Y
	lda #$FEEB
	sta $0000
	sep #$30 ;8 bit A,X,Y
;end of 'this is what i put in'

forever:
	wai	;wait for next frame
	;do whatever you feel like here	
	;let's print the current frame number
	SetCursorPos 20, 10
	ldy #FrameNum
	PrintString "Frame num = %d    "
	jmp forever
Snes9x Geiger's Debugger will crash every time (as in program hard crash)
bsnes will just give be a blank screen.

Why is this happening? I was told to look at the output generated by WLA-DX after it processes the macros, but I'm not sure how to do that. I do suspect that there is an issue with the macros here, I just don't know how to pinpoint it.

I also thought maybe interrupt had something to do with it, like it was trying to run some other code in the middle of the thing i inserted, so i
disabled interrupts before and then enabled them after my snippet but it did not help.

any help would be appreciated, thanks.
mic_
Posts: 922
Joined: Thu Oct 05, 2006 6:29 am

Post by mic_ »

I don't know why Snes9x crashes. What I can say is that you should ditch Snes9x right away and use BSNES instead, as it's a lot more accurate and also has a debugger.

What were the register size bits set to before the instructions you inserted? You should make sure they're set to the same as they were before. Otherwise you might start executing garbage.
dext3r
Posts: 14
Joined: Fri May 06, 2011 1:03 pm

Post by dext3r »

mic_ wrote:I don't know why Snes9x crashes. What I can say is that you should ditch Snes9x right away and use BSNES instead, as it's a lot more accurate and also has a debugger.

What were the register size bits set to before the instructions you inserted? You should make sure they're set to the same as they were before. Otherwise you might start executing garbage.
im not sure what they were set to before but im 100% sure that its crashing at the first occurrence of modifying the register size bits. (so its not even getting a chance to execute garbage code)

i can fiddle with the decmial and IRQ, etc flags all day but as soon as i touch the register size, everything breaks.

i am not running in 6502 emulation mode either, at least i dont think i am. i put this at the start of my code:

Code: Select all

	clc
	xce
mic_
Posts: 922
Joined: Thu Oct 05, 2006 6:29 am

Post by mic_ »

I couldn't even assemble the code if I added those 4 lines. The assembler chokes at an LDX instruction in SetCursorPos that is trying to load an immediate larger than 8 bits after you've set all the registers to 8-bit with SEP #$30.
psycopathicteen
Posts: 3180
Joined: Wed May 19, 2010 6:12 pm

Post by psycopathicteen »

ZSNES and SNES9x are cheating emulators that hide technical shortcommings with game-specific patching.

I find all the interrupt stuff confusing and not very well documented. I just had to keep manipulating my code until it worked.
User avatar
MottZilla
Posts: 2837
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla »

Solution, use BSNES. It's the best emulator for testing things. But testing in real hardware is always going to be the only way to really know if your programs work or not.
dext3r
Posts: 14
Joined: Fri May 06, 2011 1:03 pm

Post by dext3r »

mic_ wrote:I couldn't even assemble the code if I added those 4 lines. The assembler chokes at an LDX instruction in SetCursorPos that is trying to load an immediate larger than 8 bits after you've set all the registers to 8-bit with SEP #$30.
Yeah not sure how i was getting the code to assemble...i restarted over and youre right, it would not assemble (which makes sense).
(i know bsnes is the accuracy emulator but it wasnt performing as expected in bsnes either, meaning the problem is my ability to code :lol: )

i've been messing with it more and i think i have got it working.

Code: Select all

forever:
	wai	;wait for next frame
	;do whatever you feel like here	
	;let's print the current frame number
	;rep #$10
	SetCursorPos 20, 10
	ldy #FrameNum
	PrintString "Frame num = %d    "
	
	rep #$20
	lda #$EFBE
	sta $0000
	sep #$20
	
jmp forever
so in conclusion i think i'm just a retard of some kind. thank you for the help.
Post Reply