![]() |
![]() |
#1 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,945
|
Lua interpreter with arbitrary precision math.
Here's a build of the Lua interpreter from Lua 5.2.3: lua.lha
Works with Kicstart 3.0+ and 68020+ (only tested with 68030). Compiled with SASC6.58, so might work with Kicstart 2+. Does NOT require an FPU, ixemul.library, etc. Only needs standard Workbench libraries. This build of Lua doesn't support loading dynamic libraries. To use, simply unpack the archive anywhere you want, and start from Workbench. You can also run lua.exe from the CLI directly. When starting from the CLI, use lua.exe -l mapm to start the interpreter with the math library. Example usage (type into the interpreter command line directly): Code:
mapm.digits(100) a=mapm.sqrt(12345) b=mapm.sqrt(54321) print(a*b) c=mapm.number"1" d=mapm.number"3" e=c/d print(e*d) Currently there's no documentation, but you can get some pointers here: mapm: http://www.tc.umn.edu/~ringx004/mapm-4.9.5a.tar.gz lmapm: http://webserver2.tecgraf.puc-rio.br...2/lmapm.tar.gz Mapm is the arbitrary precision floating point library. This contains documentation about the functions. Lmapm is the code that links mapm to lua. The file lmapm.c will show you which functions are available in the interpreter. Sorry, but it will have to do for now. Last edited by Thorham; 20 October 2014 at 21:33. |
![]() |
![]() |
#2 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,945
|
No one's interested in Lua here?
|
![]() |
![]() |
#3 |
AmigaMan
Join Date: Oct 2012
Location: Castro Urdiales/Spain
Posts: 765
|
I like LUA. I have the book Programming in lua. Like the concept but I dont use it.
I hope your work can be used by the talented coders we have around. |
![]() |
![]() |
#4 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
No offense, but I have never heard of Lua until now (not surprising considering there's over 500+ programming languages - consult the official 'Hello World' collection).
I will probably give it a try sometime over the next few days - I'll need a break from trying to get the 4096 tile in Coagulus' game and from drawing new GFX for my own game. |
![]() |
![]() |
#5 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,945
|
|
![]() |
![]() |
#6 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
I prefer Python, but Lua is probably slimmer and faster to run directly on the Amiga.
I've also built the Lua interpreter and compiler with SAS/C, but they give run-time errors for certain programs. My guess is that SAS/C isn't implementing the standard C library correctly, which Lua is entirely dependent on. |
![]() |
![]() |
#7 | |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,945
|
Quote:
I had that problem with things like print(0x1234567a). Just hangs. Fixed it by playing with the compiler options (I'll upload the fixed version later). SASC also shows lots of warnings when compiling Lua. Tried to do it with GCC (no warnings), but I can't seem to link the Lua interpreter with the mapm library properly without ixemul (both work fine without ixemul, combine them, and mapm doesn't work properly). Very annoying (probably something small as I'm a compiler n00b). |
|
![]() |
![]() |
#8 |
Registered User
Join Date: Feb 2008
Location: RNO
Posts: 1,010
|
I like Lua too. I did learn it recently, because there's a native implementation of Lua included in MorphOS by default, and it can be used to replace ARexx. I converted some of my ARexx scripts to Lua and also wrote some new ones. You can find them here if interested.
Lua is still missing something compared to ARexx, but OTOH it's more powerful in many other areas. Nevertheless I enjoy making scripts with both languages. |
![]() |
![]() |
#9 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 729
|
I've compiled lua with gcc and then run this
Code:
-- sieve.lua -- the sieve of Eratosthenes programmed with coroutines -- typical usage: lua -e N=500 sieve.lua | column -- generate all the numbers from 2 to n function gen (n) return coroutine.wrap(function () for i=2,n do coroutine.yield(i) end end) end -- filter the numbers generated by `g', removing multiples of `p' function filter (p, g) return coroutine.wrap(function () for n in g do if n%p ~= 0 then coroutine.yield(n) end end end) end local start = os.clock() c=0 N=N or 500 -- from command line x = gen(N) -- generate primes up to N while 1 do local n = x() -- pick a number until done if n == nil then break end --print(n) -- must be a prime number c=c+1 x = filter(n, x) -- now remove its multiples end print(c) print(string.format("elapsed time: %.2f\n", os.clock() - start)) Here are the results: Code:
3.Work:t/amath> lua.exe sieve.lua 95 elapsed time: 4.34 3.Work:t/amath> lua.exe sieve.lua 95 elapsed time: 4.33 3.Work:t/amath> luagcc sieve.lua 95 elapsed time: 3.26 3.Work:t/amath> luagcc sieve.lua 95 elapsed time: 3.26 Didn't expect that much. |
![]() |
![]() |
#10 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,945
|
|
![]() |
![]() |
#11 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 729
|
|
![]() |
![]() |
#12 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,945
|
|
![]() |
![]() |
#13 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 729
|
Weird. I don't get crashes (emulated A1200). Maybe it overuses the stack. I think I was playing with 500k stack (was going for 50k but I typed one zero too many).
|
![]() |
![]() |
#14 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,945
|
|
![]() |
![]() |
#15 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 729
|
ok, gcc6 is GODLIKE
![]() Code:
3.Work:t/amath> lua.exe sieve.lua 95 elapsed time: 5.31 3.Work:t/amath> luagcc sieve.lua 95 elapsed time: 4.64 3.Work:t/amath> /lua sieve.lua [gcc6 68000 version] 95 elapsed time: 3.48 3.Work:t/amath> /lua sieve.lua [gcc6 68020 version] 95 elapsed time: 3.34 3.Work:t/amath> /lua /for.lua [gcc6 68020 version] 5000050000 11.7 seconds 3.Work:t/amath> lua.exe /for.lua 5000050000 26.632 seconds 3.Work:t/amath> luagcc /for.lua 5000050000 24.58 seconds Code for for.lua Code:
s = os.clock() sum = 0 for i=1,100000 do sum = sum + i end print(sum) print(tostring(os.clock()-s) .. " seconds") https://drive.google.com/open?id=1dg...SxkL-YLLzDbXQA |
![]() |
![]() |
#16 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,659
|
|
![]() |
![]() |
#17 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,379
|
Huge stacks are common for programs coming from other platforms (understand : pc).
I've found that usually 300k is enough, though. |
![]() |
![]() |
#18 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 729
|
It's an interpreter
![]() For example the last version I linked runs happily the "for.lua" with 4k stack. "sieve.lua" crashed with 50k stack, worked with 100k. |
![]() |
![]() |
#19 |
Hardware Designer
Join Date: Aug 2018
Location: Bialystok/Poland
Age: 51
Posts: 184
|
|
![]() |
![]() |
#20 |
Registered User
Join Date: Mar 2017
Location: Minehead / UK
Posts: 608
|
Apologies for resurrecting an old thread but any idea what hardware the above tests were performed on?
For example " 11.7 down from gcc3.4.0's 24.58, down from 26.6 of SAS C " I'm just trying to guage my results with the lua i just built. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Logitech Precision gamepad hasn't worked since 2.3.3 | Sigma | support.WinUAE | 13 | 20 March 2013 09:29 |
File timestamps lose precision in shared folders | mark_k | support.WinUAE | 9 | 06 February 2013 16:25 |
Talkie infocom interpreter | Anakirob | project.Amiga Game Factory | 2 | 28 May 2011 03:34 |
looking for AmigaBasic Interpreter | phil321 | New to Emulation or Amiga scene | 41 | 19 December 2006 14:26 |
making a basic interpreter | staticgerbil | Coders. General | 2 | 27 January 2004 23:28 |
|
|