What's new

Shifting arrays

Doomulation

?????????????????????????
As I was thinking about optimizations to some chip8 opcodes, I thought of shifting...
but my question is, is it possible to shift entire arrays? Like, shift the contents of the array further by 128 bytes? If it would be possible, it would be a damn nice optimization than moving memory.
 

euphoria

Emutalk Member
I'd say no, though i don't entirely understand what you mean.
Shifting happens only in registers and as you know they're 32bit, and any larger shifts had to be composed of multiple shifts and memory read/writes and that'd be inefficient as hell.
 
OP
Doomulation

Doomulation

?????????????????????????
I mean shifting the entire array. Say if it was 128*64 (8192 or 0x2000) bytes long, I'd shift this by 128 * 8, shifting it about 128 bytes right.
This is what I mean by shifting arrays.
 

blight

New member
shifting is usually meant to be the bitwise operation to shift each bits of a register to the right or left. shifting means that every "empty" bit is filled with 0. what you want is to move memory (shift on a byte boundary through multiple bytes) - using any kind of shift instruction would be a waste of time, memmove() is what you want i think
 
OP
Doomulation

Doomulation

?????????????????????????
I thought it wouldn't be possible. But the thing is, I *WANT* every bit to be filled with 0.
If you remember the chip8 screen array, every 0 means no pixel is drawn and 1 means a pixel is drawn. I want to push down the screen one line.

Well, thanks.
 

Top