It is currently Sun Jul 22, 2018 1:53 pm

 All times are UTC - 7 hours

### Forum rules

Related:
• For making cartridges of your Super NES games, see Reproduction.

 Page 1 of 1 [ 7 posts ]
 Print view Previous topic | Next topic
Author Message
 Posted: Sat Aug 13, 2016 5:58 pm
 Formerly Espozo

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3349
Location: Nacogdoches, Texas
I don't know why I just now thought of this, and it seems other people haven't either. What's the point of having a table with 4 different words (2 bytes) under it instead of having 4 tables with one thing under them? Of course, you'd ask what's the point, but I just thought of how if you're going through a table, instead of doing txa, adc, tax, you'd just do an inx or two. Now, that's a small benefit for kind of being a pain to program with, but I heard that you save a cycle if the index registers are 8 bit instead of 16 bit when using an instruction with them, and that's actually really important, especially considering just about any routine with them is going to be looping repeatedly. Additionally, because there are so few registers in the 65816, you may be able to use the same register in situations that you normally couldn't, as in if the tables you are indexing have different slot sizes but are both being incremented the same number of slots at a time.

You know what's sad? I actually don't know how to get an 8 or 16 bit accumulator with an 8 bit x and y, because I've never done it before. How do you do it?

Top

 Posted: Sat Aug 13, 2016 6:11 pm

Joined: Sun Mar 27, 2016 7:56 pm
Posts: 157
If you've ever heard people talk about how the 6502 and 65816 are better suited for structs of arrays rather than arrays of structs, this is what they were referring to.

rep #\$20 sets A to 16-bit, rep #\$10 sets X and Y to 16-bit, rep #\$30 sets both (because \$20 | \$10 == \$30). sep will do the opposite.

Top

 Posted: Sat Aug 13, 2016 6:17 pm
 Formerly Espozo

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3349
Location: Nacogdoches, Texas
Nicole wrote:
If you've ever heard people talk about how the 6502 and 65816 are better suited for structs of arrays rather than arrays of structs, this is what they were referring to.

I guess I'm not as clever as I thought I was...

Wouldn't this go for other processors too though, or do they generally not have a penalty for larger register sizes or have better ways of incrementing them? (I'm pretty sure the 80186 can increment AX, BX, CX, and DX exactly the same so that's not a problem at least. I'm also pretty sure it has a 16 bit data bus too.)

Top

 Posted: Sat Aug 13, 2016 7:28 pm

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10616
Location: Rio de Janeiro - Brazil
IIRC, indexing on the Z80, for example, favors arrays of structures, instead of structures of arrays like the 6502 does. If I'm not mistaken, indexed operations on the Z80 use 16-bit index registers, and 8-bit offsets as operands. This means you can easily access any byte within a structure of up to 256 bytes anywhere in the 16-bit addressing space just by having the index register point to the start of the structure.

Top

 Posted: Sat Aug 13, 2016 7:32 pm

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20288
Location: NE Indiana, USA (NTSC)
Espozo wrote:
penalty for larger register sizes

As I understand it: WDC 65816 and Intel 8088 have a penalty for loads and stores of 16-bit registers, as do Zilog Z80 and Sharp "GBZ80" if you consider BC, DE, and HL as 16-bit registers. Motorola 68000 has a penalty for 32-bit ALU operations. 68000, Intel 80386SX, and some ARM7TDMI configurations have a penalty for 32-bit loads and stores.

What tokumaru describes for the Z80 also applies to the 68000, with its 32-bit index registers A0-A7 and 16-bit signed offsets. Does the GBZ80, which lacks IX and IY, even have any indexed modes?

Top

 Posted: Sat Aug 13, 2016 7:51 pm

Joined: Sun Mar 27, 2011 10:49 am
Posts: 254
Location: Seattle
It features an auto-increment/decrement addressing mode for indirect accesses with the HL combined register, which gets you maybe halfway there.

One neat trick GBZ80 coders do is "page" aligning data less than 256 bytes (i.e. starting a table at \$xx00) so that an indexed access is just:

Code:
LD L, *index*
LD A, [HL]

Which, depending on where your index is before (register vs immediate), is going to be 20 or 24 cycles and 4 or 5 bytes, versus a more general:

Code:
LD A, *index*
LD L, A
JR NC, .nc
INC H
.nc:
LD A, [HL]

Which is minimum 44 cycles and 10 bytes.

Top

 Posted: Sun Aug 14, 2016 4:11 am

Joined: Wed Feb 13, 2008 9:10 am
Posts: 643
Location: Estonia, Rapla city (50 and 60Hz compatible :P)
ALIGN 256 is poor man's zero page on the Z80
On 68K you want to Auto Increment though your data because it is free, while all others ops cost you something extra.

_________________
http://www.tmeeco.eu

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 7 posts ]

 All times are UTC - 7 hours

#### Who is online

Users browsing this forum: No registered users and 5 guests

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

Search for:
 Jump to:  Select a forum ------------------ NES / Famicom    NESdev    NESemdev    NES Graphics    NES Music    Homebrew Projects       2018 NESdev Competition       2017 NESdev Competition       2016 NESdev Competition       2014 NESdev Competition       2011 NESdev Competition    Newbie Help Center    NES Hardware and Flash Equipment       Reproduction    NESdev International       FCdev       NESdev China       NESdev Middle East Other    General Stuff    Membler Industries    Other Retro Dev       SNESdev       GBDev    Test Forum Site Issues    phpBB Issues    Web Issues    nesdevWiki