13 May 2016, 14:40 | #61 | |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Quote:
Let me see if I can come up with another one, and this time I'll be more clear about the requirements. |
|
13 May 2016, 15:57 | #62 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,351
|
|
13 May 2016, 16:39 | #63 | |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Ok I got another one. The first one ended a bit too fast, but I don't think anyone could beat Meynaf's 5-line solution anyway. My own solution was 8 lines and I couldn't have made it a single line shorter.
For the next one, in honor of the original Amiga, you will print 1000-bit integers: Write a subroutine that takes a pointer A0 to a 1000-bit integer, and a pointer A1 to where you will print the integer. The input at A0 is a big-endian two's complement signed integer, so no different from a regular 4-byte/32-bit integer, other than being 125 bytes/1000 bits long in memory. The integer can take all possible values, and is aligned on an even address in memory. You're not allowed to modify the input. The integer must be written to an output string pointed to by A1, and it must be pretty-printed as plain null-terminated ASCII with a minus-sign if negative, but no leading zeroes, no spaces, and no plus-sign. It must also be adjusted in memory so the first character is where A1 points to. The string has 400 bytes of space (you will need ~300 at most), but may not be aligned in memory. This is acceptable output: 123 0 -456 This is not: 000 0123 - 0 +2300 55 You have 1024 bytes of stack space for temporary use. The code must be plain M68000 user-mode code and run on all machines, so forward-compatible and no SMC. You don't have to save the contents of any registers. You're allowed to use look-up tables, but they will count towards the final size of your code. Shortest subroutine wins. Quote:
Also, today is Friday the 13th, so be careful when coding................. Last edited by Leffmann; 13 May 2016 at 21:21. |
|
13 May 2016, 17:16 | #64 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,351
|
Can the original 1000-bit data be modified in the process or is it read only ?
|
13 May 2016, 18:13 | #65 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,831
|
Why 68000 only? 68000 limitations suck.
|
13 May 2016, 21:07 | #66 | |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Quote:
I've updated my post with more details. Yeah I guess, but I think more people can participate this way. |
|
13 May 2016, 21:42 | #67 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,351
|
|
14 May 2016, 10:08 | #68 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Ok, but let's wait and see if someone still wants to tackle it. I have a couple of simpler and more fun problems I can post in the meantime if people are still interested.
|
14 May 2016, 10:58 | #69 |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 881
|
I'd love to have a go at it, but the deadline is too short for me.
I would only be able to something basic in that timeframe using the small subset of the processor I am currently comfortable with. I like the idea of this comp as a way to force myself to further research the instruction set and more advanced ways of doing things. I have almost finished my first game and I have probably only used 15 different instructions |
14 May 2016, 11:07 | #70 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,351
|
Perhaps every coder could post his own challenge ?
|
14 May 2016, 11:11 | #71 |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 881
|
I'd really liked the original idea that Dan had for doing stuff that can end up in your utils.s
I would love to have an integer to ascii routine of the quality I expect you guys will produce for example |
14 May 2016, 12:10 | #72 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,351
|
Quote:
The 1000-bit integer stuff we have here is another kind of beast. |
|
14 May 2016, 12:13 | #73 |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 881
|
32 bit version would be much appreciated. I don't anticipate needing 1000bit integers in the foreseeable future
|
14 May 2016, 13:17 | #74 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,351
|
Here is my current routine.
It takes the int in D0 and returns A0=string (in a static buffer). For unsigned int ; if signed, test and append "-" then neg, if it was negative. Requires 68020+. Code:
movem.l d0-d2,-(a7) lea staticbuff+10,a0 moveq #10,d2 .loop moveq #0,d1 divu.l d2,d1:d0 addi.b #"0",d1 move.b d1,-(a0) tst.l d0 bne.s .loop movem.l (a7)+,d0-d2 rts |
14 May 2016, 13:50 | #75 |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 881
|
Thanks - I will convert it to 16bit 68000 and will be perfect for what I need.
|
15 May 2016, 09:55 | #76 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
I sense there's some irritation and lack of interest in the 1000-bit problem, so let's forget I posted it.
The idea was that people would use long division, like we used to do with pen and paper, where longer numbers is just a matter of repeating the division step more times. So if you've already printed an integer to ASCII then you're almost there, you just have to apply it in a loop and consider the whole length of the number. Maybe someone else can post a better challenge? |
15 May 2016, 10:52 | #77 | |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 881
|
Quote:
Last edited by alpine9000; 15 May 2016 at 11:00. |
|
15 May 2016, 11:04 | #78 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,351
|
Dunno if it can be considered as better (perhaps it's even a lot worse ), but i might have one.
It's quite simple : reverse the bit order of a 16-bit int. This can easily be done with a table, so i put in a limitation : not more than 80 bytes, including data. The winner is the fastest routine (020/030 timing). All 020+ instructions are allowed. All regs can be used. Results can be published here. I won't personnally participate (but i can give my routine at the end if asked). At second thoughts, the challenge may be interesting even if someone rushes in with a good routine : someone else can then find an optimization in that routine and win the game And trust me : this cannot be done with just a 5 liner |
15 May 2016, 11:26 | #79 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 720
|
An algorithm with no division
http://www.eng.utah.edu/~nmcdonal/Tu...onversion.html Technically is binary2bcd, but you can go bcd2string pretty easy. |
15 May 2016, 12:13 | #80 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,351
|
Quote:
|
|
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 |
|
|