Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > CSDb Entries > Event id #2417 : First CSDb "Unintended OpCode coding challenge"
2015-10-11 07:18
Monte Carlos

Registered: Jun 2004
Posts: 351
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....
 
2015-10-19 19:25
Rastah Bar

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 :-)
2015-10-19 19:50
Bitbreaker

Registered: Oct 2002
Posts: 501
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
2015-10-19 20:23
Rastah Bar

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 ;-)
2015-10-20 06:49
Bitbreaker

Registered: Oct 2002
Posts: 501
        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
2015-10-20 08:14
Rastah Bar

Registered: Oct 2012
Posts: 336
I am not sure I understand this version. X&A may contain $00, $20, $40, or $60, flags in SBX are set like CMP, so the BPL start never happens??

Focus? There wasn't any focus ... I was just looking for a nice application for opcodes like SLO, SRE, RLA, RRA :-D
2015-10-20 08:51
Bitbreaker

Registered: Oct 2002
Posts: 501
Umm, i guess it should be bmi if i get it right, but flags are set perfectly well by sbx, so no problem.

The values i have noted are the input and resulting values. We need to focus on $00, $20, $40, $60 (00,01,10,11) by subtracting $e0 we manage to receive a negative result only upon $60 as input value, so we can branch out beforehand here as we would end up with a wrong carry in the following code. What remains are $00 - $e0, $20 - $e0 and $40 - $e0 as further results. so for 00 we have $20, for case 01 we have $40 and for case 10 we have $60 as result in X. If we now do a cpx we end up to have the carry cleared for case 00 and set for case 01 and case 10, right? After that we branch always. However i just notice that we should better do a cpx #$3f to fullfill the branch always :-D

        lda #seed1
        sta zp1
        lda #seed2
        clc
start:
        ldx #$60
        rol zp1
        rol
        sbx #$e0        ;x = a & $60 - $e0 -> clc
        bmi start
        cpx #$3f
        ;$20-$40 -> clc   $40-$40 -> sec   $60-$40 -> sec
        bne start
2015-10-20 11:03
Rastah Bar

Registered: Oct 2012
Posts: 336
That is even more efficient. Cool!

From this and other examples such as the ones posted by Monte Carlos I get the impression that SBX is a pretty useful UOC.
2015-10-20 12:49
Oswald

Registered: Apr 2002
Posts: 5034
anything to emulate cpx ,y or cpy ,x ?
2015-10-20 15:52
algorithm

Registered: May 2002
Posts: 702
@Oswald, maybe something like the below?

stx loc+1
loc cpy #$00

with code in zero page, would use 5 cycles.

No single illegal/legal opcode for the above :-(
2015-10-20 21:24
Oswald

Registered: Apr 2002
Posts: 5034
I mean cpx abs,y or vice versa, they seem so obvious to have still not implemented.

damn you chuck ;)
Previous - 1 | 2 | 3 | 4 | 5 | 6 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Mike
Linus/MSL
Dwangi/Fairlight
jailbird
Peacemaker/CENSOR/Hi..
Visage/Lethargy
Exile/Anubis
DnP
hedning/G★P
Doc Snyder/ONS
Guests online: 82
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 Uncensored  (9.6)
7 Comaland 100%  (9.6)
8 No Bounds  (9.6)
9 Aliens in Wonderland  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 It's More Fun to Com..  (9.5)
7 Dawnfall V1.1  (9.5)
8 Birth of a Flower  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Morph  (9.5)
Top Groups
1 Nostalgia  (9.4)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Offence  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 Tim  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.046 sec.