Page 1 of 1

Megadrive Work-RAM Write Issue

Posted: Tue Jun 12, 2012 1:35 am
by MintyTheCat
Hello all,

I am doing some tests in order to write to all of the Megadrive's Memory such as VRAM, VSRAM, CRAM, etc.

I have tried to write to Work-RAM using the Routine below. MESS will write to the 68K's Work-RAM but will then bypass the next instructions and execute the Halt (coloured in Red).

I would appreciate some Advice on what I am doing incorrectly here, please.

Code: Select all


WRAMBasicWriteRead:

	lea			(WRAM_Base).l,		a0

	;	Write Test-Values to WRAM:
	move.l	0x88BEEF99,	(a0)+
	move.l	0x11BEEF22,	(a0)+
	move.l	0x44BEEF55,	(a0)

	;	Read back from WRAM:
	clr.l		d0
	move.l	(a0), d0

@_WRAMBasicWriteReadEnd:
	rts

Code: Select all


; ******************************************************************
; *	[Constants]
; ******************************************************************

WRAM_Base:						equ	0x00FF0000	;	Megadrive Work-RAM Range: 0x00FF0000 to 0x00FFFFFF.
Calling is as:

Code: Select all


; ... previous Initialisation/etc....

	jsr	WRAMBasicWriteRead		;	ToDo: fails and causes the Machine to stop having written to WRAM!

	jsr	VRAMBasicWrite

	stop #$2700 ; Halt CPU    ; [color=red]HITS Here after first write to WRAM.[/color]

My Writes and Reads to VRAM work correctly and do not incur this Response.

Cheers
:wink:

Posted: Tue Jun 12, 2012 7:14 am
by Chilly Willy
Did you mean to do this instead?

Code: Select all

   move.l   #0x88BEEF99,   (a0)+
   move.l   #0x11BEEF22,   (a0)+
   move.l   #0x44BEEF55,   (a0)
Without the '#', you are moving from an address... the first being odd which immediately throws an odd address error on real hardware... in an emulator, it will probably work, but copy from a non-existent location.

Posted: Tue Jun 12, 2012 10:14 am
by MintyTheCat
Chilly Willy wrote:Did you mean to do this instead?

Code: Select all

   move.l   #0x88BEEF99,   (a0)+
   move.l   #0x11BEEF22,   (a0)+
   move.l   #0x44BEEF55,   (a0)
Without the '#', you are moving from an address... the first being odd which immediately throws an odd address error on real hardware... in an emulator, it will probably work, but copy from a non-existent location.
Chilly, I was indeed a naughty Boy for not making that a Literal :lol: - Defence can only be "It was late Maam". Many Thanks for correcting me there - you are completely correct and I should have seen that sooner (perhaps not as late at Night).

Cheers!

Posted: Tue Jun 12, 2012 6:05 pm
by Chilly Willy
Sometimes it's the littlest things that get us. I've done similar things in the past... and you're so close to the problem that you can't see it. You read it the way you MEANT to write it instead of how it's actually written. That's why it's good to have someone else take a quick look when you run into a problem. :D

Posted: Tue Jun 12, 2012 6:28 pm
by MintyTheCat
Chilly Willy wrote:Sometimes it's the littlest things that get us. I've done similar things in the past... and you're so close to the problem that you can't see it. You read it the way you MEANT to write it instead of how it's actually written. That's why it's good to have someone else take a quick look when you run into a problem. :D
This is why I see Code-Reviews as something useful overall if no a little embarassing :oops:

Cheers for that Chilly!

Posted: Wed Jun 13, 2012 2:40 am
by Nemesis
Don't worry about it, anyone who's done assembly programming for the Mega Drive has made that mistake at one point or another. It's actually a variation on that mistake which stopped my MegaLD dumping program from working for 2 months. I didn't identify the problem until I was comparing the machine code output from the assembler with a section of compiled code I was trying to duplicate. :oops: