Author Topic: ScriptBasic4Android  (Read 20573 times)

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
ScriptBasic4Android
« on: August 04, 2013, 01:24:56 AM »
I was able to compile ScriptBasic native on Android Linux along with the runtime libraries. (static and dynamic) This was done on my stock Samsung Galaxy Tab 2 10.1 tablet. (non-rooted)


Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic4Android
« Reply #1 on: August 04, 2013, 01:58:13 PM »
I have finished my clean-up. (optimization, strip, makefile tweaks) I'm happy with the results.

Code: [Select]
shell@android:/data/data/org.connectbot/bin/ScriptBasic/src/bin/exe $ ls -l
-rwxr-xr-x u0_a119  u0_a119    363888 2013-08-04 13:47 scriba
shell@android:/data/data/org.connectbot/bin/ScriptBasic/src/bin/exe $ ls -l ../lib
-rw-rw-rw- u0_a119  u0_a119    370768 2013-08-04 13:50 libscriba.a
-rwxr-xr-x u0_a119  u0_a119    417100 2013-08-04 13:49 libscriba.so
-rw-rw-rw- u0_a119  u0_a119    369500 2013-08-04 13:50 lscriba.a
shell@android:/data/data/org.connectbot/bin/ScriptBasic/src/bin/exe $

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic4Android
« Reply #2 on: August 04, 2013, 06:40:52 PM »
I pleased to announce that compiling native on Android does have an advantage over cross compiling with the NDK.

Code: [Select]
FOR x = 65 TO 90
  a = a & CHR(x)
NEXT x
FOR x = 1 TO 1000
  FOR y = 26 TO 1 STEP -1
    b = b & MID(a, y, 1)
  NEXT y
  b = b & a
NEXT x
PRINT LEN(b),"\n"

shell@android:/sdcard/scriptbasic $ time scriba_ndk strbench.sb
52000
    0m13.07s real     0m13.01s user     0m0.01s system
shell@android:/sdcard/scriptbasic $ time scriba strbench.sb                                                                                                    
52000
    0m4.03s real     0m4.00s user     0m0.02s system
shell@android:/sdcard/scriptbasic $

Here is the BaCon  numbers for the same test on Android. (BASIC to C translator - compiled)

shell@android:/data/local/BaCon $ time ./strbench
52000

    0m3.83s real     0m3.80s user     0m0.00s system
shell@android:/data/local/BaCon $

« Last Edit: August 04, 2013, 07:22:41 PM by support »

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic4Android
« Reply #3 on: August 04, 2013, 11:22:17 PM »
ScriptBasic extension modules seem to compile fine native and half the size as the NDK counterpart.

Code: [Select]
declare sub MD5 alias "md5fun" lib "t"

m = MD5("JRS")

for x = 1 to len(m)
  print right("0" & hex(asc(mid(m,x,1))),2)
next
printnl

shell@android:/sdcard/scriptbasic $ scriba t_md5.sb
95B75AF8A9A72665C52E361994020219

shell@android:/sdcard/scriptbasic $ ls -l /data/data/org.connectbot/bin/ScriptBasic/lib
-rwxr-xr-x u0_a119  u0_a119      7736 2013-08-04 22:10 t.so
-rwxr-xr-x u0_a119  u0_a119     14161 2013-08-01 18:49 t_ndk.so
shell@android:/sdcard/scriptbasic $

This is a SB MD5 example running on Android compared to the Linux C version. The SB version has to do the following.

  • Load scriba
  • Parse/tokenize script
  • Load extension module and declare external functions
  • Load 4.3 MB string from a file into a SB string variable
  • Call the extension module MD5 function passing the loaded text of the bible.
  • Format binary results to a HEX string
  • Cleanup memory, unload extension module and exit scriba

Compare that to a compile C program that is a standard Linux utility and there is 3 tenths of a second difference.  8)

Code: [Select]
declare sub MD5 alias "md5fun" lib "t"
declare sub LoadString alias "loadstring" lib "t"

s = LoadString("Bible.txt")

m = MD5(s)

for x = 1 to len(m)
  print right("0" & hex(asc(mid(m,x,1))),2)
next
printnl

shell@android:/sdcard/scriptbasic $ time scriba md5cc.sb
17CE80BA9F6A0F74093C575205C9CB17
    0m0.12s real     0m0.06s user     0m0.04s system
shell@android:/sdcard/scriptbasic $ time md5 Bible.txt
17ce80ba9f6a0f74093c575205c9cb17  Bible.txt
    0m0.09s real     0m0.05s user     0m0.02s system
shell@android:/sdcard/scriptbasic $

shell@android:/sdcard/scriptbasic $ ls -l Bible.txt
-rw-rw-r-- root     sdcard_rw  4397206 2012-07-01 00:45 Bible.txt
shell@android:/sdcard/scriptbasic $

« Last Edit: August 05, 2013, 01:19:26 AM by support »