6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 10:33 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Tue Jun 23, 2015 7:28 am 
Offline

Joined: Mon Jan 07, 2013 2:42 pm
Posts: 576
Location: Just outside Berlin, Germany
So I've just coded the PER instruction in my 65816 assembler (which calls it phe.r), and am trying to confirm that I've done it right, and as part of that I'm checking it against the WDC Programming Manual. On page 172, we find Fragment 11.13, which looks like this (some secondary stuff deleted):
Code:
0000            ORG $2200
0000 62FD7F     PER DATA1
0003 E220       SEP #$20
0005 A00000     LDY #0
000A            END

0000            ORG $2500
0000 2A2A2A     DC C'***'
0003 FF  DATA1  DC H'FF'
0004 F7  DATA2  DC H'F7'
0005 E3  DATA3  DC H'E3'
0006            END
Here's my problem. The PER instruction starts at $2200, and is three bytes long. So the next byte after it is $2203. If I understand what it is supposed to do, we now need the offset to DATA1, which is at $2503. In my world, this is is an offset of $300, and the PER instruction should come with that as the operand, making the whole instruction 62 00 03 in machine code. Instead, we have this weird 62 FD 7F I can't get my head around. $7FFD looks like the data from DATA2 and DATA3 minus 2, but I have no idea how that is supposed to get up there with PED. It doesn't even make sense as PEA (my phe.#).

Interestingly, the text above the fragment walks you through this example and actually says:
Quote:
Using the instruction (...) in your source program causes the assembler to calculate the offset from $2203 (from the instruction
following the PER instruction at $2200) to DATA1 at $2503, an offset of $300. So the assembler generates object code of a PER opcode followed by $300.
except that in that example, the number following the opcode is $7FE1. Strange. $300 happens to be what my assembler is saying, by the way, so I'm obviously biased.

At the moment, I'm assuming this is another one of the many, many, typos in the Manual. I've started a Erratum at https://docs.google.com/document/d/1DMB ... sp=sharing , unless there is one already?


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 23, 2015 7:47 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
I'd say it's pretty obvious they have an error there. At first I figured it was just because you have not downloaded the improved manual that was a scan and OCR of the original paper one and came out a couple of months ago, because that fragment is on page 223 of my paper one; but surprise--the paper one has the same error. When you're not sure though, it's always good to go to the "The Instruction Sets" section that starts on page 421 and has at least a full page dedicated to every instruction. The full-page detailed description of PER is on page 475.

_________________
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: Tue Jun 23, 2015 8:34 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
My assembler generates this
Code:
                                            .ORG    $2200
002200  620003            :                 PER     DATA1
002203  E220              :                 SEP     #$20
002205  A000              :                 LDY     #0
                                           
                                            .ORG    $2500
002500  2A2A2A            :                 .BYTE   "***"
002503  FF                : DATA1           .BYTE   $FF
002504  F7                : DATA2           .BYTE   $F7
002505  E3                : DATA3           .BYTE   $E3

WDC has used the values stored at DATA1/DATA2 in the PER instruction rather than its address.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 23, 2015 3:14 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1952
Location: Sacramento, CA, USA
viewtopic.php?f=2&t=2639&p=29489#p29489

Mike B.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 23, 2015 5:50 pm 
Offline

Joined: Mon Jan 07, 2013 2:42 pm
Posts: 576
Location: Just outside Berlin, Germany
Ah, Mike, sorry, hadn't seen that.

Just out of curiosity, what is the official, newest, corrected version of the Manual? I'm using the "Copyright 2007" text version. The one now linked to on their website seems to be in a scanned book format, far less useful with small pages.

EDIT: I've added this to my Erratum


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 23, 2015 9:24 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8514
Location: Midwestern USA
scotws wrote:
So I've just coded the PER instruction in my 65816 assembler (which calls it phe.r), and am trying to confirm that I've done it right, and as part of that I'm checking it against the WDC Programming Manual. On page 172, we find Fragment 11.13...

The offset being computed by your assembler ($0300) is correct.

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


Last edited by BigDumbDinosaur on Tue Jun 23, 2015 9:34 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 23, 2015 9:26 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8514
Location: Midwestern USA
GARTHWILSON wrote:
I'd say it's pretty obvious they have an error there. At first I figured it was just because you have not downloaded the improved manual that was a scan and OCR of the original paper one and came out a couple of months ago, because that fragment is on page 223 of my paper one; but surprise--the paper one has the same error. When you're not sure though, it's always good to go to the "The Instruction Sets" section that starts on page 421 and has at least a full page dedicated to every instruction. The full-page detailed description of PER is on page 475.

I have the OCRed version as well as the older PDF that used to be on the WDC site. Both have the identical error.

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


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 23, 2015 9:39 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
I have not taken the time to do an A/B comparison through much of the different versions, but although I've been recommending the manual for years, I began sensing that the one they had online had problems, when I would have my stickies and notes in the paper one and I would try to direct people's attention to the same part of the electronic version. Then in the spring, WDC said they scanned and OCR'ed that paper one to take care of various problems, and posted it. Since it is OCR'ed, you can search it, mark blocks and copy text out of it, etc.. I seem to remember the paper one had sections that were not in the earlier online one.

_________________
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  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

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