English Amiga Board Amiga Lore


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 15 May 2017, 14:27   #21
meynaf
68k wisdom
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon (France)
Age: 44
Posts: 2,223
Quote:
Originally Posted by ross View Post
Ok, alone in this crusade versus code illegality
Perhaps this could become a different category with its own ranking. But you're alone having sent code to me so far...
meynaf is offline  
AdSense AdSense  
Old 15 May 2017, 17:23   #22
Nightfox
Registered User

Nightfox's Avatar
 
Join Date: Apr 2016
Location: Australia
Posts: 138
I just submitted my entry. I don't expect to even come close to winning because I'm still an assembly n00b but hey this is great for learning.
Nightfox is offline  
Old 17 May 2017, 08:32   #23
meynaf
68k wisdom
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon (France)
Age: 44
Posts: 2,223
I currently have 4 submissions. Time for the first results :
1. paraj (15)
2. ross (19)
3. a/b (20)
4. sacredbanana (38)
All versions have been checked with my result testing program under winuae.

Now that you know where you are, you can of course submit new versions and get a better score.
meynaf is offline  
Old 17 May 2017, 10:31   #24
ross
Vae victis!

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Posts: 218
arghh, and now paraj knows the instructions number to make a 2^18 in/out combo

ross is offline  
Old 17 May 2017, 12:35   #25
meynaf
68k wisdom
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon (France)
Age: 44
Posts: 2,223
And you know how much it takes for 100*100*2*2 as well
meynaf is offline  
Old 17 May 2017, 13:15   #26
a/b
Registered User

 
Join Date: Jun 2016
Location: europe
Posts: 18
Quote:
Originally Posted by meynaf View Post
All versions have been checked with my result testing program under winuae.
Could you please post or message me your testing program?
a/b is offline  
Old 17 May 2017, 13:36   #27
meynaf
68k wisdom
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon (France)
Age: 44
Posts: 2,223
Quote:
Originally Posted by a/b View Post
Could you please post or message me your testing program?
Ok, here's the code for testing :
Code:
 moveq #1,d7        ; x
.xloop
 moveq #1,d6        ; ~z
.zloop
 move.w #$99,d5     ; b
.bloop
 sub.l d0,d0        ; x=0, d0=0
 abcd d5,d0
 cmp.b d5,d0
 bne.s .bskip       ; b = invalid bcd
 move.w #$99,d4     ; a
.aloop
 sub.l d0,d0
 abcd d4,d0
 cmp.b d4,d0
 bne.s .askip        ; a = invalid bcd
 bsr.s .init
 abcd d0,d1
 move ccr,d3        ; ref ccr = d3
 move.l d1,a0       ; ref res = a0
 bsr.s .init
 bsr tstcode        ; call emu code
 move ccr,d2
 eor.b d3,d2
 andi.b #$15,d2     ; keep x,z,c
 bne.s .ohno        ; wrong ccr
 cmp.l a0,d1
 bne.s .ohno        ; wrong result
.askip
 dbf d4,.aloop
.bskip
 dbf d5,.bloop
 dbf d6,.zloop
 dbf d7,.xloop
; if we get there, everything is ok
 rts
.init
 move.b d4,d0
 move.b d5,d1
 move.b d7,d2
 mulu #$11,d2        ; x=c
 move d2,ccr
 btst #0,d6          ; z
 rts
.ohno
; abort here
meynaf is offline  
Old 17 May 2017, 15:30   #28
Nightfox
Registered User

Nightfox's Avatar
 
Join Date: Apr 2016
Location: Australia
Posts: 138
I can't hope to compete against you masters haha but I'm just happy I managed to get working code and learn a lot in the process
Nightfox is offline  
Old 17 May 2017, 20:17   #29
paraj
Registered User

 
Join Date: Feb 2017
Location: Denmark
Posts: 76
Didn't imagine everyone was using so many instructions, now I may have to look into also handling the rest of the cases

@sacredbanana: Hang in there, you'll quickly get a hang of the basics tricks (e.g. knowing which operations set which flags so you rarely have to use cmp, and making sure otherwise unused parts of registers still do work). Here you need to at least some of the time manipulate both BCD digits at once to get to a low instruction count. Hint: 6 is a magic value for BCD

For this exact challenge it's annoying that most operations clear the carry flag, there must be a more elegant way to handle it than the way I'm currently doing it.
paraj is offline  
Old 17 May 2017, 23:12   #30
Nightfox
Registered User

Nightfox's Avatar
 
Join Date: Apr 2016
Location: Australia
Posts: 138
Thank you Paraj, I am thinking about your hints and coming up with ideas. Whether they work or not is yet to be seen
Nightfox is offline  
Old 18 May 2017, 09:41   #31
meynaf
68k wisdom
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon (France)
Age: 44
Posts: 2,223
Quote:
Originally Posted by paraj View Post
For this exact challenge it's annoying that most operations clear the carry flag, there must be a more elegant way to handle it than the way I'm currently doing it.
It might be interesting to see how much the code could be reduced if we only had to care about X and not C. However I think the biggest pest here is Z.
meynaf is offline  
Old 19 May 2017, 19:38   #32
paraj
Registered User

 
Join Date: Feb 2017
Location: Denmark
Posts: 76
Quote:
Originally Posted by meynaf View Post
It might be interesting to see how much the code could be reduced if we only had to care about X and not C. However I think the biggest pest here is Z.
Yeah, but I was prepared for that since Z is so volatile. There's probably a good reason why so many instructions clear the C flag, it was just annoying here since it destroyed many of my plans.

EDIT: You can trivially reduce my code by 2 instructions if C doesn't need to be preserved.

Last edited by paraj; 19 May 2017 at 19:50.
paraj is offline  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone up for an ASM coding competition? DanScott Coders. Asm / Hardware 523 02 May 2017 09:24
4th tutorial on ASM- and HW-coding Vikke Coders. Asm / Hardware 11 10 April 2013 20:32
3rd tutorial on ASM- and HW-coding Vikke Coders. Asm / Hardware 6 26 March 2013 15:57
First tutorial on ASM- and HW-coding Vikke Coders. Asm / Hardware 46 18 March 2013 12:33
2nd tutorial on ASM- and HW-coding Vikke Coders. Asm / Hardware 10 17 March 2013 11:49

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:31.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Page generated in 0.20631 seconds with 12 queries