The Museum of HP Calculators

HP Forum Archive 15

[ Return to Index | Top of Index ]

Re: Short & Sweet Math Challenges #8: Squares !
Message #1 Posted by Arnaud Amiel on 13 May 2005, 1:46 a.m.

This is a follow up to an archived message.

Ihad posted a Saturn Assembly solution to this challenge but felt it could do with some tiyding up. So I did and gained a few seconds. Then I realised that most of the time was spent squaring the numbers. Knowing that the sum of odd numbers is the list of square numbers, I could change the squaring into a mere couple of additions. This code now runs much faster.

It takes 5.3s on a 49g+ and 13s on a 48GX. I am not talking about emulated speed here but real speed. I still need to port it to the 28S. The 71 has a Saturn but I don't have one and don't know what is its support for assembly...

I can send you the compiled program if you email me.

Arnaud

SAVE SETDEC
LA 1111088889000
C=0.M LC 66665000 B=C.M
LC 33333 RSTK=C

*NextNumber C=RSTK C+1.A SKIPNC { P=0 SETHEX LOADRPL } RSTK=C B+1.M B+1.M A+B.M C=A.M %This is were the square is calculated

P=5 A=0.XS B=0.XS D=0.XS *TestNumber P+1 GOC GoodNumber CSR.W ?C=0.XS GOYES NextNumber ?A#0.XS { A=C.XS GOTO TestNumber } ?A=C.XS GOYES TestNumber ?B#0.XS { B=C.XS GOTO TestNumber } ?B=C.XS GOYES TestNumber ?D#0.XS { D=C.XS GOTO TestNumber } ?D=C.XS GOYES TestNumber GOTO NextNumber

*GoodNumber R1=A.M C=B.M R2=C.M ASL.M ASL.M LA 009 A=0.S GOSBVL =PUSH% SAVE SETDEC A=R1.M C=R2.M B=C.M GOTO NextNumber @

      
Re: Short & Sweet Math Challenges #8: Squares !
Message #2 Posted by Namir on 13 May 2005, 3:34 a.m.,
in response to message #1 by Arnaud Amiel

Arnaud,

All these challenges are not part of some post graduate homework you have been give (<big smile>). Was just wondering!

Namir

(Basking in the sunny and sometimes cloudy southern France ... for a few days more)

            
Re: Short & Sweet Math Challenges #8: Squares !
Message #3 Posted by Arnaud Amiel on 13 May 2005, 4:24 a.m.,
in response to message #2 by Namir

Unfortunately, last time I was given some postgraduate work to do was about 5 years ago, what is more since then I have been basking in the British rain instead of the warm south of France ever since...

Arnaud

                  
Re: Short & Sweet Math Challenges #8: Squares !
Message #4 Posted by Namir on 13 May 2005, 6:16 a.m.,
in response to message #3 by Arnaud Amiel

Arnaud,

You are missing the beauty and magic of southern France. They predictewd clouds today ... well not for long. It's sunny and beautiful at noon today!! It's hard to stay inside and play with the internet and HP emulators. I am surrendering to the temptation of this nice weather.

Namir


[ Return to Index | Top of Index ]

Go back to the main exhibit hall