It is currently Fri Dec 15, 2017 10:34 pm

All times are UTC - 7 hours



Forum rules


Related:



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Aug 31, 2016 10:37 pm 
Offline
User avatar

Joined: Sat Jun 27, 2009 11:05 pm
Posts: 717
Location: New Mexico, USA
Hello all,

I've been looking at Bazz' tutorials (http://wiki.superfamicom.org/snes/show/ ... ES+Program) and had a question.

I ran the first.smc (which is included in the link at the bottom of the tutorial: http://wiki.superfamicom.org/snes/files ... program.7z) through the MESS emulator debugger and WLA is assembling the code incorrectly. I don't know if it's a coding error (likely) or if it's an actual bug in WLA (unlikely).

In the InitializeSNES method (which is in the InitSNES.asm source file) it is assembling the following two lines:

LDA #$0000 ;set Direct Page = $0000
TCD ;Transfer Accumulator to Direct Register

...into the following 3 bytes:
A9 00 5B

...when it should really be 4 bytes since the accumulator is in 16-bit mode:
A9 00 00 5B

The $5B value is actually the TCD opcode but it's being treated as the upper byte of the LDA instruction! :-o I have included a screenshot for you.

I have also recompiled first.smc from scratch using the latest WLA binaries available here (viewtopic.php?f=12&t=12334) but the recompiled SMC has the exact same problem.

Does the source code need an extra assembler directive or something in order to tell WLA that the accumulator is in 16-bit mode?

Thanks!


Attachments:
File comment: mess_screenshot
bad_assemble.png
bad_assemble.png [ 80.06 KiB | Viewed 861 times ]
Top
 Profile  
 
PostPosted: Thu Sep 01, 2016 12:04 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
This subject has been discussed at ridiculous length on the forum already (no offense) -- "ridiculous length" means several pages. The problem is exacerbated by crummy documentation. See the section talking about .8BIT, .16BIT, .24BIT, .ACCU 8, .INDEX 8, and Section 3.6 (Mneumonics).

If you want to force 16-bit addressing, you need to use the .w "extension" on your opcode, e.g. lda.w #$0000. Likewise there is .b (byte) and .l (24-bit). You can alternately use this on the operand itself, e.g. lda #$0000.w; your choice.

It's still your responsibility to ensure the runtime accumulator or X/Y indexes are the correct size via rep/sep.


Top
 Profile  
 
PostPosted: Thu Sep 01, 2016 12:21 am 
Offline
User avatar

Joined: Sat Jun 27, 2009 11:05 pm
Posts: 717
Location: New Mexico, USA
Aha, thanks a lot! And I see all the pages you are talking about now. The problem is I didn't know what I was looking for. I've never programmed for the 65816 (or any other 16-bit CPU for that matter). Thanks again.


Top
 Profile  
 
PostPosted: Thu Sep 01, 2016 12:36 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
No prob. The WLA DX documentation is very badly organised and not well-written (I believe written by someone whose native tongue is not English). IMO, the "pinnacle" of PC 65816 cross-assemblers was x816 by Norman Yen, but it's for MS-DOS.


Top
 Profile  
 
PostPosted: Thu Sep 01, 2016 12:49 am 
Offline
User avatar

Joined: Fri Sep 02, 2011 8:34 pm
Posts: 476
Yo, thanks for the report. This can be fixed by finding the "InitializeSNES:" label in InitSNES.asm and adding the following 2 lines before it:
Code:
.ACCU 16
.INDEX 16
InitializeSNES:


Unfortunately, all of the separate projects in the tutorial series each have this file so it needs to be replaced across the board. This makes me lean towards creating a Github repo which has all sub-projects source the same one library file, for easy maintenance.

_________________
SNES Tutorials (WLA DX)
SNES Memory Mapping Tutorial (Universal / LoROM) -- By Universal I introduce how memory mapping works, rather than just provide a LoROM map.
SNES Tracker (WIP) - Music/SFX composition tool / SPC Debugger


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot], Google Adsense [Bot] and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group