21 April 2021, 13:11 | #1 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
small code contest
Hi, time for a little challenge.
Not for anything big, time is too often limited for many of us - even though i'd clearly could find a few cases. It's about doing the work of an instruction that does not exist : asr.l #25,myvar(a5) No assembler will accept this, and for good reasons Doing the same without an available temporary uses - with a classical approach - 6 instructions and 10 code words ! (push tmp, move from mem, moveq #25, shift, move to mem, pop tmp) Else, still 2 tmp Dn, 4 instructions, and 6 code words. Doh, that makes 68k look like a stupid risc cpu Now wondering, if there is a way to do this kind of shift with less code. Something generic, but special code for particular cases is also welcome (f.e. #31 instead of #25, lsl instead of asr, etc). Intended use is for some macros that should be reusable everywhere they are needed. |
21 April 2021, 14:55 | #2 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,959
|
For asr.l #31 only one temp register is necessary.
move.l myvar(a5),D0 add.l D0,D0 subx.l D0,D0 move.l D0,myvar(a5) or move.w myvar(a5),myvar+2(a5) sxx D0 (sorry i dont remember which one) extb.l D0 move.l D0,myvar(a5) |
21 April 2021, 14:57 | #3 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
|
Code:
move.b myvar(a5),d0 asr.b #1,d0 extb.l d0 move.l d0,myvar(a5) |
21 April 2021, 15:03 | #4 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,959
|
For some (most?) cases only one temp register is necessary
move.w myvar(a5),D0 ext.l D0 asr.l #x,D0 move.l d0,myvar(a5) |
21 April 2021, 15:12 | #5 |
Registered User
Join Date: Nov 2018
Location: Germany
Posts: 110
|
|
21 April 2021, 15:14 | #6 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
Code:
bfexts myvar(a5){0:32-25},d0 move.l d0,myvar(a5) |
|
21 April 2021, 15:41 | #7 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,959
|
Seems you need one temp register and one bitfield instruction and one write instruction
or one temp register and combination of three other instructions move.b/move.w and extb.l/ext.w and asr.l #x,D0 and one write instruction. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBCC: How to use small code/data models with nostdlib | Hedeon | Coders. C/C++ | 23 | 04 October 2023 01:10 |
is this correct queston about small blitz basic code? | JPQ | Coders. Blitz Basic | 0 | 08 October 2019 09:40 |
the multi-cpu code density contest | meynaf | Coders. Asm / Hardware | 165 | 12 February 2018 11:51 |
NASA Contest (US only) | Saghalie | Coders. General | 1 | 05 May 2017 18:58 |
AmigaSYS Wallpaper Contest | Calo Nord | News | 10 | 22 April 2005 09:33 |
|
|