6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 5:27 pm

All times are UTC




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Thu Jun 02, 2022 2:08 pm 
Offline

Joined: Sat Feb 19, 2022 10:14 pm
Posts: 147
BigDumbDinosaur wrote:
... the 65C816 doesn’t have “16-bit modes.”

I don't know if it rises to a formal definition, but both the 65816 datasheet and the Eyes and Lichty programming manual use the terms "8-bit mode" and "16-bit mode" a number of times. The later also states:
Quote:
The width of the accumulator and the width of the index registers are independently controlled by setting and resetting the two special flag bits within the status register, the index register select (x) and memory/accumulator select (m) flags.

This is the only place in these two documents that the "width" of the registers is used. I prefer "mode" to "width", but both get the point across.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 02, 2022 5:50 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8509
Location: Midwestern USA
tmr4 wrote:
BigDumbDinosaur wrote:
... the 65C816 doesn’t have “16-bit modes.”

I don't know if it rises to a formal definition, but both the 65816 datasheet and the Eyes and Lichty programming manual use the terms "8-bit mode" and "16-bit mode" a number of times.

Eyese & Lichty is incorrect on this score, and the data sheet mixes usages in a confusing way (nothing unusual with WDC data sheets—they’ve long been famous for errors and confusion). That said, this phrase from the data sheet should clear it up:

Quote:
A software switch determines whether the processor is in the 8-bit "emulation" mode, or in the native mode...

Using the above as an example, setting register sizes wouldn't be a mode change, because the MPU's fundamental operation hasn't been changed in any way—the ALU always operates on 16 bits when the 816 is in native mode.

Quote:
This is the only place in these two documents that the "width" of the registers is used.

Consider “width” to be a synonym for “size,” since that is what is changeable when in native mode.

Quote:
I prefer "mode" to "width", but both get the point across.

Whatever floats your boat. However, it doesn't change the way the 816 operates. It has two modes: emulation and native. Within emulation mode, accumulator and index register sizes are fixed at 8 bits. Within native mode, accumulator and index register sizes are selectable, either 8 or 16 bits.

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


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 02, 2022 8:01 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
Hmmm... The L&E terminology does seem confusing there. I hadn't caught that before. The processor's emulation mode emulates the '02 in:

  • vector locations
  • ZP wraparound
  • page-1-only hardware stack, and the stack pointer is only 8 bits wide
  • and yes, that the register widths are stuck at 8 bits. In native mode, to say that the accumulator is in "8-bit mode" or "16-bit mode" refers to the mode the accumulator is in, not the processor, as the width you choose for the index registers is independent of the width of the accumulator. Further, when you first go into native mode, the accumulator and index registers are 8 bits wide until you change them, even though the stack pointer is 16-bit.

Emulation mode does not eliminate the new '816 instructions.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 02, 2022 8:04 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
I have found it useful to think of the '816 as having five modes - it's a quick way to get to an explanation of what it's like to program.

We should all, of course, be making sure we understand each other, with our various terminology, and I think we do.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 02, 2022 8:33 pm 
Offline

Joined: Sat Feb 19, 2022 10:14 pm
Posts: 147
BigDumbDinosaur wrote:
Whatever floats your boat. However, it doesn't change the way the 816 operates. It has two modes: emulation and native. Within emulation mode, accumulator and index register sizes are fixed at 8 bits. Within native mode, accumulator and index register sizes are selectable, either 8 or 16 bits.
No doubt about how the 816 operates but this is just terminology. You're taking a narrow view of the term "mode", applying it only to whether the processor is in "emulation mode" or "native mode". Equating other common usage to errors or confusion seems like a weak explanation.

I agree that using "8-bit mode" is imprecise without knowing that the processor is operating in native mode. If native mode is implied however, using "8-bit mode" seems perfectly acceptable.

BigDumbDinosaur wrote:
That said, this phrase from the data sheet should clear it up:
Quote:
A software switch determines whether the processor is in the 8-bit "emulation" mode, or in the native mode...
That quote simply introduces the concept of an emulation and native mode. It doesn't prevent native mode from having both an 8-bit mode and 16-bit mode. This phase just as easily supports the alternate view:
Quote:
7.23 Accumulator switching from 8-bit to 16-bit
Care must be taken when switching from 16-bit mode to 8-bit mode then to 16-bit mode.
Of course this can only be done in native mode.

Edit:
I knew I should have included the code snippet. I wanted to get off to lunch and didn't want to bother with formating.
Code:
LONGA ON
REP #$20
LDA #$2345
STA MIKE
LONGA OFF
SEP #$20
LDA #$01
STA SAM
LONGA ON
REP #$20
STA BOB
; Here BOB = $2301 and NOT $000V[sic]

That only works in native mode. A similar situation occurs when switching from native 16-bit to emulation and back to native 16-bit. I've verified that on hardware a while back to make sure my emulator treated it correctly.


Last edited by tmr4 on Thu Jun 02, 2022 9:47 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 02, 2022 8:46 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
tmr4 wrote:
That quote simply introduces the concept of an emulation and native mode. It doesn't prevent native mode from having both an 8-bit mode and 16-bit mode. This phase just as easily supports the alternate view:

tmr4, I think you do understand, but can you confirm, what has been repeated here, that the width selection of the accumulator is not tied to the width selection of the index registers. . "16-bit mode" and "8-bit mode" make it sound like the accumulator width and the index-register width must go together and be the same. They don't.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 02, 2022 10:13 pm 
Offline

Joined: Sat Feb 19, 2022 10:14 pm
Posts: 147
GARTHWILSON wrote:
tmr4, I think you do understand, but can you confirm, what has been repeated here, that the width selection of the accumulator is not tied to the width selection of the index registers. . "16-bit mode" and "8-bit mode" make it sound like the accumulator width and the index-register width must go together and be the same. They don't.
Yes, we're on the same page. Context is critical. It's usually clear in the discussion or code but I admit "8-bit mode" and "16-bit mode" isn't precise without the proper context.

BigEd wrote:
We should all, of course, be making sure we understand each other, with our various terminology, and I think we do.

I debated having this discussion here because the OP is struggling with terminology and operations. But I hope it points out that his question and others relate simply to ways to describe how the processor works. I had similar confusion to start, but it soon passes as you dive in deeper. Of course this site helps a lot.

For example, I wouldn't be surprised by a question on the "C register" next. It's just a construct to describe how the processor works. L&E describe it thus:
Quote:
The terminology used to describe the various components of the eight-or-sixteen bit accumulator is: to use A to name the accumulator as a register that may be optionally eight or sixteen bits wide (depending on the m memory/accumulator select flag); to use C when the accumulator is considered to be sixteen bits regardless of the setting of the m flag; and, when A is used in eight-bit mode to describe the low byte only, to use B to describe the hidden high byte of the sixteen-bit accumulator.
This provides necessary precision but seems at odds with the alternate mnemonic allowed such as TSA in place of TSC. This of course is on the original designers. For me, a variable width accumulator (and a hidden B byte) is sufficient. My emulator, for example, doesn't model the C accumulator internally.

In the end, we can't hide from the fact that two definitive documents use terminology that is less than precise, but provides a good shorthand given the proper context. Absent some other definitive document how can we be on the same page?


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 03, 2022 6:35 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
I think for most people the documents are useful, rather than definitive, and we get on with the task in hand: writing code, helping people, debugging things.

It's rare indeed, I think, that anyone becomes confused beyond rescue because they came across some unhelpful terminology. But I agree it's worth trying to be more helpful, rather than less helpful!

Writing technical document is difficult, and the result is often flawed in some way - E&L is just one example of many. But I think the document succeeds in lifting the reader up to a better level of understanding.

(What tends to make these kinds of discussions interminable is an insistence on one specific terminology. Phrases like "I prefer" and "most people say" are useful to de-escalate.)


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 14, 2022 11:48 am 
Offline
User avatar

Joined: Tue Aug 11, 2020 3:45 am
Posts: 311
Location: A magnetic field
Apologies. I did not intend to spur a long tangent on a newbie friendly topic, although this is not the first occasion and regulars are ready and able to tangent.

BigEd on Thu 2 Jun 2022 wrote:
I have found it useful to think of the '816 as having five modes - it's a quick way to get to an explanation of what it's like to program.


65816 introduces three additional mode bits and five permutations are valid. One mode (Emulation) maintains legacy cycle counts and vectors. This was necessary for its first target in Apple IIgs. The other four modes (Native) set accumulator or index register width. One native mode has 8 bit registers. Two modes have a mix of 8/16 bit registers. One mode has 16 bit accumulator and index registers. This latter mode is favored as a default among many 65816 programmers.

When I'm being lazy, I may describe any use of 16 bit registers as "16 bit modes" and the remaining two cases as "8 bit modes". They are definitely modes because they have modal state. However, this description is from the view of implementing a bytecode interpreter and not writing 65816 programs. To write a bytecode interpreter, I'd probably have four or five byte dispatch routines which share the majority of implementation detail. This would eliminate the requirement to check flags before the execution of each instruction or addressing mode.

_________________
Modules | Processors | Boards | Boxes | Beep, Beep! I'm a sheep!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

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