| |
Monte Carlos
Registered: Jun 2004 Posts: 364 |
Event id #2417 : First CSDb "Unintended OpCode coding challenge"
So here it is. The First CSDb "Unintended OpCode coding challenge" starts over.
First CSDb "Unintended OpCode Coding Challenge"
Please give some feedback about your interest in this compo.
For those who have been part of the discussion
http://csdb.dk/forums/?roomid=12&topicid=112819#112927
please let me know if you are in better agreement with the reworked rules than before.
However, there will not be a rule change anymore. |
|
... 44 posts hidden. Click here to view all posts.... |
| |
Bitbreaker
Registered: Oct 2002 Posts: 508 |
If you want it comfortable, switch to Java. |
| |
Rastah Bar Account closed
Registered: Oct 2012 Posts: 336 |
If you want to make it a subroutine, is this a good idea?
start: lda zp2
clc
ldx #$60
rol zp1
rol zp2
sbx #$00
lda $c000,x
sta start+2
rts
Where $c000, $c020, $c040, and $c060 contain $18,$38,$38,$18, respectively (opcode clc=$18, sec=$38).
First call: jsr init
Subsequent calls: jsr start
With RLA:
start:
clc
lda #$60
rol zp1
rla zp2
tax
lda $c000,x
sta start
rts
But I can imagine you want to call it for example 8 times in a row to generate an entire byte in which case the overhead of storing the state of the MLS generator can be much reduced. |
| |
Oswald
Registered: Apr 2002 Posts: 5095 |
Quote: If you want it comfortable, switch to Java.
|
| |
Rastah Bar Account closed
Registered: Oct 2012 Posts: 336 |
Quoting Color BarIf you want to make it a subroutine, is this a good idea?
start: lda zp2
clc
ldx #$60
rol zp1
rol zp2
sbx #$00
lda $c000,x
sta start+2
rts
Where $c000, $c020, $c040, and $c060 contain $18,$38,$38,$18, respectively (opcode clc=$18, sec=$38).
[/code]
Faster is:
init: lda #seed1
sta zp1
start: lda #seed2
clc ; or sec depending on how you want to initialize
rol zp1
rol
sta start+1
tax
lda $c000,x
sta start+2
rts
This requires a look up table with $18,$38 values for any value of A after the rol. This has the advantage that it is easier to generalize to other MLS orders, where you may have to EOR more than two bits. No UOC required :-( |
| |
Monte Carlos
Registered: Jun 2004 Posts: 364 |
lax blabla,x (y)
sbx #..
should emulate cpx,y or cpx,x |
| |
chatGPZ
Registered: Dec 2001 Posts: 11390 |
but since that destroys akku, you can just aswell use
txa
cmp bla,y
:) |
| |
Oswald
Registered: Apr 2002 Posts: 5095 |
yeah I wanted to keep A intact :) |
| |
Rastah Bar Account closed
Registered: Oct 2012 Posts: 336 |
In the special case that 'bla' is on a page boundary (for example $1f00):
sty label+1
label:
cpx $1f00 |
| |
Oswald
Registered: Apr 2002 Posts: 5095 |
yup that would work, but probably also be slower or on par with what I wanted to optimize. |
| |
Rastah Bar Account closed
Registered: Oct 2012 Posts: 336 |
Code optimization is hard ... |
Previous - 1 | 2 | 3 | 4 | 5 | 6 - Next |