6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 16, 2024 8:35 pm

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Mon Nov 30, 2015 1:21 pm 
Offline

Joined: Sun Feb 23, 2014 2:43 am
Posts: 78
How does one deal with the different register sizes in a 65816 disassembler? So far all I can think of is to try to keep track of SEP/REP instructions.


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 30, 2015 1:51 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10981
Location: England
There isn't going to be a foolproof way - that's the nature of mode bits. So whatever you do by way of guessing, be sure to allow an override.


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 30, 2015 3:55 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8491
Location: Midwestern USA
joe7 wrote:
How does one deal with the different register sizes in a 65816 disassembler? So far all I can think of is to try to keep track of SEP/REP instructions.

That's how I do it in Supermon 816.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 01, 2015 10:22 am 
Offline

Joined: Mon Jan 07, 2013 2:42 pm
Posts: 576
Location: Just outside Berlin, Germany
Yeah, this is a problem. For the Forth disassembler, I have these routines:
Code:
\ handle register size switch and add comment
: .sep  ( addr+1 -- addr+1)
   dup c@
   case  .commentspace
      10 of xy:8  ." xy:8" endof
      20 of a:8  ." a:8" endof
      30 of a:8 xy:8  ." axy:8" endof
      ." warning: unusual use of sep" endcase ;

 \ print comment for rep register size switch
: .rep  ( addr+1 -- addr+1)
   dup c@
   case  .commentspace
      10 of xy:16  ." xy:16" endof
      20 of a:16  ." a:16" endof
      30 of a:16 xy:16  ." axy:16" endof
      ." warning: unusual use of rep" endcase ;
In other words, we check the byte after REP and SEP and set internal flags depending (xy:8, a:16, etc). To help with debugging, the disassembler adds a comment to the output so the user knows what the program thinks it knows. If REP or SEP are not used for normal register switches, print a warning.


Top
 Profile  
Reply with quote  
PostPosted: Wed Dec 02, 2015 4:29 pm 
Offline

Joined: Sun Feb 23, 2014 2:43 am
Posts: 78
Thanks. I feel that some (if unreliable) detection strategies are needed. The register size detection seems pretty straightforward, but trying to detect the emulation mode could have problems:
Code:
; the usual way
clc
xce

; an unusual way which relies on some result
adc #29
xce


This seems unlikely though?


Top
 Profile  
Reply with quote  
PostPosted: Wed Dec 02, 2015 5:03 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10981
Location: England
Yes, that's unlikely!


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 03, 2015 3:22 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8491
Location: Midwestern USA
joe7 wrote:
Thanks. I feel that some (if unreliable) detection strategies are needed. The register size detection seems pretty straightforward, but trying to detect the emulation mode could have problems:
Code:
; the usual way
clc
xce

; an unusual way which relies on some result
adc #29
xce

This seems unlikely though?

More like pointless. Why use three bytes to do a two-byte job?

It's a rare case where switching between native and emulation modes occurs as a regular activity. About the only one I can think of off-hand is when a eight bit Apple is retrofitted with an '816.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 03, 2015 3:51 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
BigDumbDinosaur wrote:
... More like pointless. Why use three bytes to do a two-byte job?

I don't know of any way to increase the accumulator by 29 or 30 and potentially switch modes in only two bytes of code, so I personally would be more inclined to call it "obscure" or maybe "obtuse", rather than "pointless". Some other "ob-" words also come to mind, like "obfuscated" and "obnoxious".

Quote:
It's a rare case where switching between native and emulation modes occurs as a regular activity. About the only one I can think of off-hand is when a eight bit Apple is retrofitted with an '816.

I installed a 65c802 in my old Apple ][+ back in about 1990, to experiment with the 16-bit registers. It was fun for awhile, but a bit cumbersome, because the monitor was completely clueless about what I was trying to do. I thought about adding the necessary monitor functionality myself, but eventually moved on to a different interest instead. I grew weary of all the mode-switching, which couldn't be avoided to get my experiments to "play nice" with the Apple ][ firmware. I went through my attic recently, but only found a //e and a Franklin Ace up there ... I hope I didn't lose that '802 in one of my moves. Meh ... easy come, easy go ...

Mike B.


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 20, 2015 9:01 pm 
Offline

Joined: Mon Sep 14, 2015 8:50 pm
Posts: 112
Location: Virginia USA
I came across an article in Apple Assembly Lines archive on just this topic: http://txbobsc.com/aal/1986/aal8603.html#a4
I also have a 65802 installed in a Laser 128EX that I just got working today after being in storage and moving again and again and again...

Regards,
Andy


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 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: