English Amiga Board


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

 
 
Thread Tools
Old 01 May 2016, 07:51   #41
demolition
Unregistered User
demolition's Avatar
 
Join Date: Sep 2012
Location: Copenhagen / DK
Age: 38
Posts: 3,736
Quote:
Originally Posted by alpine9000 View Post
We could start with something far less ambitious while we see if the concept of a coding competition here works.
Probably a good idea. If it was too complicated, you might also only get two entries which would not be much fun. It should be simple enough so that people with mediocre skills could join in and make something (perhaps not win, but at least make a pitch).
demolition is offline  
Old 01 May 2016, 12:46   #42
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 47
Posts: 441
N-balls colliding on screen
(http://vobarian.com/collisions/2dcollisions2.pdf)
alkis is offline  
Old 02 May 2016, 08:19   #43
meynaf
son of 68k
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 45
Posts: 3,195
Quote:
Originally Posted by demolition View Post
Probably a good idea. If it was too complicated, you might also only get two entries which would not be much fun. It should be simple enough so that people with mediocre skills could join in and make something (perhaps not win, but at least make a pitch).
I second that.
meynaf is offline  
Old 03 May 2016, 02:34   #44
alpine9000
Registered User

 
Join Date: Mar 2016
Location: Australia
Posts: 604
We seem to be going around in circles a bit.

Maybe if we just nominate someone to run the first round, they can come up with a goal and judging rules.

Then people can enter the round if they find it interesting.

If we get enough entries, the competition goes ahead.
alpine9000 is offline  
Old 03 May 2016, 07:45   #45
britelite
Registered User
 
Join Date: Feb 2010
Location: Espoo / Finland
Posts: 442
Some good hints on how to run such a compo:

http://amycoders.org/compo/index.php
britelite is offline  
Old 03 May 2016, 10:39   #46
gilgamesh
Linux snob

gilgamesh's Avatar
 
Join Date: Sep 2008
Location: Monkey Island
Posts: 997
Nice. I'll be the cheerleading squad.
gilgamesh is offline  
Old 11 May 2016, 22:57   #47
Thorham
Computer Nerd

Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 42
Posts: 3,084
So... what are we going to write, then?
Thorham is offline  
Old 12 May 2016, 14:11   #48
Thorham
Computer Nerd

Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 42
Posts: 3,084
Guys?
Thorham is offline  
Old 12 May 2016, 15:05   #49
meynaf
son of 68k
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 45
Posts: 3,195
Appears they are sleeping

Who runs the compo and who participates ?
meynaf is offline  
Old 12 May 2016, 22:21   #50
Thorham
Computer Nerd

Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 42
Posts: 3,084
Quote:
Originally Posted by meynaf View Post
Appears they are sleeping

Who runs the compo and who participates ?
Apparently no one cares enough, or everyone is waiting for someone else to take charge (myself included)
Thorham is offline  
Old 12 May 2016, 23:08   #51
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,177
DanScott is arranging it I guess, but he's busy with his game too.

I have a small one for you to warm up with:

You're given two unsigned 32-bit integers in D0 and D1. Write a subroutine that determines if D0 is greater or equal to 2/3 of D1.

F.ex. if D1 is 14, then 2/3 of that is 9.333... and so 9 is not enough, and D1 must be 10 or greater.

D0 and D1 can take on all possible 32-bit values. No pre-computed tables are allowed, and it must be plain 68000 code. Other than that you can can return your result in any form and any machine register you want.

The shortest subroutine wins.
Leffmann is offline  
Old 12 May 2016, 23:32   #52
DanScott
Lemon. / Core Design

DanScott's Avatar
 
Join Date: Mar 2016
Location: Belgrade, Serbia
Posts: 318
I'm alive Been busy with a gazillion things...

Let's go with Leffmans "warm up" challenge... I'll post my result tomorrow evening
DanScott is offline  
Old 13 May 2016, 08:18   #53
meynaf
son of 68k
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 45
Posts: 3,195
Quote:
Originally Posted by Leffmann View Post
The shortest subroutine wins.
In code size or number of instructions ?

Last edited by meynaf; 13 May 2016 at 08:18. Reason: oops - misread
meynaf is offline  
Old 13 May 2016, 09:04   #54
meynaf
son of 68k
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 45
Posts: 3,195
Ok, first version here anyway :
Code:
 move.l d0,d2
 lsr.l #1,d2
 add.l d2,d0
 bcs.s .done
 cmp.l d0,d1
.done
Final result like CMP (CCR bits C and Z are set).

Instead of comparing D0 vs 2/3 *D1, we could do 3*D0 vs 2*D1 but it's the same as 1.5*D0 vs D1.
If 1.5*D0 doesn't fit in 32 bits then it can't be <D1 (hence the bcs).
Carry generated by lsr doesn't matter (cmp 10 with 9 is same as cmp 10 with 9.5 ; cmp 10 with 10.5 is same as 10 with 10 because it's greater or equal we want to know).
meynaf is offline  
Old 13 May 2016, 11:54   #55
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,177
OK that's a very short solution, but maybe I was a bit too lax on the restrictions when I said "any form and any machine register", because in this form you can't use the code with any branch at all. You have to read the CCR and look at the bits individually, which also means that on M68000 you have to go into supervisor mode to actually make use of that code, and on M68020 and later we don't have MOVE from SR. The idea is that the code should run on all machines.

So let's agree that you either have to set the condition codes correctly so that you can use BHS/BCC, or return a non-zero result in any data register to indicate that the condition holds true. Sorry about that.

Though hold off posting any code for a while, other people may want to have a go, and posting a solution right underneath the problem takes away the whole element of competition.
Leffmann is offline  
Old 13 May 2016, 12:13   #56
roomeo
Registered User

 
Join Date: Aug 2014
Location: Telemark
Posts: 207
@Leffman

We should set a deadline, and pm the answers to a dedicated person.
Great little exercise btw...
roomeo is offline  
Old 13 May 2016, 12:42   #57
meynaf
son of 68k
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 45
Posts: 3,195
Quote:
Originally Posted by Leffmann View Post
OK that's a very short solution, but maybe I was a bit too lax on the restrictions when I said "any form and any machine register", because in this form you can't use the code with any branch at all. You have to read the CCR and look at the bits individually, which also means that on M68000 you have to go into supervisor mode to actually make use of that code, and on M68020 and later we don't have MOVE from SR. The idea is that the code should run on all machines.

So let's agree that you either have to set the condition codes correctly so that you can use BHS/BCC, or return a non-zero result in any data register to indicate that the condition holds true. Sorry about that.
There is absolutely no need to test the CCR bits individually and this code runs on all machines. Just use the BLS/BHI branch condition (or SHS/SHI to set a register if you prefer).


Quote:
Originally Posted by Leffmann View Post
Though hold off posting any code for a while, other people may want to have a go, and posting a solution right underneath the problem takes away the whole element of competition.
Yeah but if you post too late then someone else may post the same solution before you - at least on very simple stuff like this.
PM'ing the answers before a deadline can indeed be the solution to this.
meynaf is offline  
Old 13 May 2016, 12:59   #58
alpine9000
Registered User

 
Join Date: Mar 2016
Location: Australia
Posts: 604
I like the idea of PMing answers.

Now I have seen meynaf's solution I can't unsee it, and i can guarantee I won't be coming up with anything better
alpine9000 is offline  
Old 13 May 2016, 13:01   #59
DanScott
Lemon. / Core Design

DanScott's Avatar
 
Join Date: Mar 2016
Location: Belgrade, Serbia
Posts: 318
bah! I wasn't thinking "out the box" enough... won't even post my feeble attempt

ah go on then.. but it's not short not tested.. and probably wrong

but I used the fact that 2/3 is approx: (1/2) + (1/8) + (1/32) + (1/128) + (1/512)

Code:
move.l	d1,d2
lsr.l	#1,d2
move.l	d2,d3
lsr.l	#2,d3
move.l	d3,d4
lsr.l	#2,d4
move.l	d4,d5
lsr.l	#2,d5
move.l	d5,d1
lsr.l	#2,d1
add.l	d2,d1
add.l	d3,d1
add.l	d4,d1
add.l	d5,d1
moveq	#0,d2
cmp.l	d0,d1
shi	d2
rts
DanScott is offline  
Old 13 May 2016, 13:45   #60
meynaf
son of 68k
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 45
Posts: 3,195
There is a way to do it shorter (cmp'ing d0*3 with d1*2), but it won't work for very large values :
Code:
 sub.l d0,d1	; b-a
 add.l d1,d1	; 2b-2a
 sub.l d0,d1	; 2b-3a
(sorry i gave code again, but now it's too late for PM'ing anything, right ?)
meynaf is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Starting ASM coding on A1200. Which Assembler? Nosferax Coders. Asm / Hardware 68 27 November 2015 16:14
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 07:32.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.09540 seconds with 14 queries