6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri May 10, 2024 12:46 pm

All times are UTC




Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sun Dec 03, 2023 7:21 pm 
Offline
User avatar

Joined: Fri Nov 05, 2021 1:06 pm
Posts: 20
Osi wrote:
Hi tius,
to calculate the instruction length for a 6502 CPU, here the code I'm using in one of my programs:
...

Thank you Thomas! I like the aproach with the minimal table.


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 04, 2023 7:19 pm 
Offline
User avatar

Joined: Sun Nov 01, 2020 10:36 am
Posts: 35
Location: Tatooine
I think this might be incorrect:
tius wrote:
Code:
instruction_size:
    ldx #3

    eor #$03   
    bit #$03
    beq @one                ; x3, x7, xB, xF


the x7 and xF instructions are wider: BBx (xF) instructions are 3 bytes long, while xMB (x7) are 2 bytes long.


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 05, 2023 9:20 am 
Offline
User avatar

Joined: Fri Nov 05, 2021 1:06 pm
Posts: 20
BB8 wrote:
...
the x7 and xF instructions are wider: BBx (xF) instructions are 3 bytes long, while xMB (x7) are 2 bytes long.

You are right! This has changed with newer 65c02s (see http://www.6502.org/tutorials/65c02opcodes.html):

Code:
      x2:     x3:     x4:     x7:     xB:     xC:     xF:
     -----   -----   -----   -----   -----   -----   -----
0x:  2 2 .   1 1 .   . . .   1 1 a   1 1 .   . . .   1 1 c
1x:  . . .   1 1 .   . . .   1 1 a   1 1 .   . . .   1 1 c
2x:  2 2 .   1 1 .   . . .   1 1 a   1 1 .   . . .   1 1 c
3x:  . . .   1 1 .   . . .   1 1 a   1 1 .   . . .   1 1 c
4x:  2 2 .   1 1 .   2 3 g   1 1 a   1 1 .   . . .   1 1 c
5x:  . . .   1 1 .   2 4 h   1 1 a   1 1 .   3 8 j   1 1 c
6x:  2 2 .   1 1 .   . . .   1 1 a   1 1 .   . . .   1 1 c
7x:  . . .   1 1 .   . . .   1 1 a   1 1 .   . . .   1 1 c
8x:  2 2 .   1 1 .   . . .   1 1 b   1 1 .   . . .   1 1 d
9x:  . . .   1 1 .   . . .   1 1 b   1 1 .   . . .   1 1 d
Ax:  . . .   1 1 .   . . .   1 1 b   1 1 .   . . .   1 1 d
Bx:  . . .   1 1 .   . . .   1 1 b   1 1 .   . . .   1 1 d
Cx:  2 2 .   1 1 .   . . .   1 1 b   1 1 e   . . .   1 1 d
Dx:  . . .   1 1 .   2 4 h   1 1 b   1 1 f   3 4 i   1 1 d
Ex:  2 2 .   1 1 .   . . .   1 1 b   1 1 .   . . .   1 1 d
Fx:  . . .   1 1 .   2 4 h   1 1 b   1 1 .   3 4 i   1 1 d
a) 1-cycle NOP on some older 65C02s; RMB instruction on Rockwell and on modern WDC 65C02s
b) 1-cycle NOP on some older 65C02s; SMB instruction on Rockwell and on modern WDC 65C02s
c) 1-cycle NOP on some older 65C02s; BBR instruction on Rockwell and on modern WDC 65C02s
d) 1-cycle NOP on some older 65C02s; BBS instruction on Rockwell and on modern WDC 65C02s
e) $CB is the WAI instruction on WDC 65C02
f) $DB is the STP instruction on WDC 65C02
g) $44 uses zp address mode to read memory
h) $54, $D4, and $F4 use zp,X address mode to read memory
i) $DC and $FC use absolute address mode to read memory
j) $5C reads from somewhere in the 64K range, using no known address mode

I'm not using these instructions yet, so I didn't notice the error. Thanks for the code review!


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

All times are UTC


Who is online

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