| |
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.... |
| |
Monte Carlos
Registered: Jun 2004 Posts: 364 |
just search for "no more secrets" and reveal:
No More Secrets
Think this and grahams reference are the most advanced docus. |
| |
Rastah Bar Account closed
Registered: Oct 2012 Posts: 336 |
Thanks!
I constructed a 15 bit Maximum Length Sequence (MLS) generator, using RLA. This is what I have got now:
lda #seed1
sta zp1
lda #seed2
sta zp2
start:
clc
lda #$60 ;MSB of zp2 is output of the MLS, bits 6+5 are EORed (according to primitive polynomial for m=15)
rol zp1
rla zp2 ;actually the Carry flag contains the most recent output of the MLS at this point, while the MSB of zp2 is the output of the previous cycle.
beq start ; shift a zero bit in
;now we must distinguish between 01 or 10 versus 11 for bits 6 and 5 of A
eor #$60
beq start ; shift a zero bit in
sec ; shift a one bit in
jmp start+1
Reference for MLS: http://www.kempacoustics.com/thesis/node83.html
I don't know if this can be done more efficiently (probably). |
| |
Monte Carlos
Registered: Jun 2004 Posts: 364 |
Is this related to generation of random numbers which also are maximum length sequences or is this something on it's own? |
| |
Rastah Bar Account closed
Registered: Oct 2012 Posts: 336 |
Yes, this is related. I dont know the details, but the reference explains more. I remembered something about random number generation with MLS, looked up the reference and saw a connection with RLA. |
| |
Monte Carlos
Registered: Jun 2004 Posts: 364 |
Interesting idea. I only know bout these eor randomizers. |
| |
Bitbreaker
Registered: Oct 2002 Posts: 508 |
Nice! A optimization that comes to my mind at a chort glance:
eor #$60
beq start ; shift a zero bit in
sec ; shift a one bit in
jmp start+1
;isn't that the same as:
eor #$60
cmp #$01 ;sets carry on $20 $40 $60 and clears carry on $00
bne start+1 ;branch always
The lda #$60 + eor #$60 gives me the feeling that it can be optimized too, twice the same value :-D Also it would help to get a negated carry, hmm |
| |
Rastah Bar Account closed
Registered: Oct 2012 Posts: 336 |
Quote: Nice! A optimization that comes to my mind at a chort glance:
eor #$60
beq start ; shift a zero bit in
sec ; shift a one bit in
jmp start+1
;isn't that the same as:
eor #$60
cmp #$01 ;sets carry on $20 $40 $60 and clears carry on $00
bne start+1 ;branch always
The lda #$60 + eor #$60 gives me the feeling that it can be optimized too, twice the same value :-D Also it would help to get a negated carry, hmm
Yes, thanks for the optimization!
I'm studying Groepaz's document now to see if another UOC can be sneaked in advantageously :-) |
| |
Bitbreaker
Registered: Oct 2002 Posts: 508 |
Next try, and hope i don't spoil the fun, also: untested and just sketched in an editor :-D
lda #seed1
sta zp1
lda #seed2
start:
clc
ldx #$60
rol zp1
rol
sbx #$00 ;x = a & $60
beq start ;x = 0?
sbx #$60 ;$60-$60=0, $20 - $60=$c0 $40-$60=$e0
cpx #$01 ;clear carry on x = 0, else set
bne start+1
|
| |
Rastah Bar Account closed
Registered: Oct 2012 Posts: 336 |
Nice. The code after start: is 1 cycle faster, isn't it? But it does use the x-register as well.
For practical use of the MLS the code should probably be modified such that you can go through one update of it (as a subroutine?) and use the output elsewhere.
I don't want to give up too easily on RLA ;-) |
| |
Bitbreaker
Registered: Oct 2002 Posts: 508 |
lda #seed1
sta zp1
lda #seed2
clc
start:
ldx #$60
rol zp1
rol
sbx #$e0 ;x = a & $60 - $e0 -> clc
bpl start
cpx #$40
;$20-$40 -> clc $40-$40 -> sec $60-$40 -> sec
bne start
Still untested, so i might be very wrong. Of course this method would not work well as a call, but i guess it was not the focus? :-D |
Previous - 1 | 2 | 3 | 4 | 5 | 6 - Next |