Author Topic: TinyScheme  (Read 63641 times)

0 Members and 3 Guests are viewing this topic.

Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #165 on: September 08, 2014, 03:06:04 PM »
And does the resultant TS give a correct answer to such a command:

(- 80000000001 80000000000)

which should be 1? If it doesn't then TDM GCC can't automatically convert TS' original code to legit 64 bits. But then you can also try and use TDM GCC instead of VC to compile my fixes to see if the resultant binary is smaller, or faster, or whatever...

JRS

  • Guest
Re: TinyScheme
« Reply #166 on: September 08, 2014, 03:09:36 PM »


C:\tinyscheme-master\src>scheme
TinyScheme 1.41
ts> (- 80000000001 80000000000)
1
ts>


It works!

JRS

  • Guest
Re: TinyScheme
« Reply #167 on: September 08, 2014, 03:25:19 PM »
Mike,

If we can get by these three warnings, I wonder if it would work. (kings reward - ext. int) I also changed the %l to %ll which didn't cause any errors or warnings but didn't solve the zero problem in KR fields beyond 32.  :-[

If we can get TDM-GCC=64 to compile TS with little change, I'm going gcc across the board. I'll only use VS2013 for Dave's COM stuff.


C:\tinyscheme-master\src>mingw32-make -B
gcc -fpic -I. -c -g -Wno-char-subscripts -O -DUSE_STRLWR=0 -DUSE_DL=1 -DUSE_MATH=1 -DUSE_ASCII_NAMES=0  scheme.c
scheme.c: In function 'alloc_cellseg':
scheme.c:584:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
          if(((unsigned long)cp)%adj!=0) {
              ^
scheme.c:585:28: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
            cp=(char*)(adj*((unsigned long)cp/adj+1));
                            ^
scheme.c:585:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
            cp=(char*)(adj*((unsigned long)cp/adj+1));
               ^
gcc -fpic -I. -c -g -Wno-char-subscripts -O -DUSE_STRLWR=0 -DUSE_DL=1 -DUSE_MATH=1 -DUSE_ASCII_NAMES=0  dynload.c
gcc -shared -o libtinyscheme.dll scheme.o dynload.o -m64 -lm
ar crs libtinyscheme.a scheme.o dynload.o
gcc -fpic -o scheme -g -Wno-char-subscripts -O scheme.o dynload.o -m64 -lm

C:\tinyscheme-master\src>

« Last Edit: September 08, 2014, 03:59:21 PM by John »

JRS

  • Guest
Re: TinyScheme
« Reply #168 on: September 08, 2014, 04:37:55 PM »
I was able to eliminate the warnings with the following code change.

Code: Scheme
  1.          // if(((unsigned long)cp)%adj!=0) {
  2.          if(((intptr_t)cp)%adj!=0) {
  3.            // cp=(char*)(adj*((unsigned long)cp/adj+1));
  4.            cp=(char*)(adj*((intptr_t)cp/adj+1));
  5.  


C:\tinyscheme-master\src>mingw32-make -B
gcc -fpic -I. -c -g -Wno-char-subscripts -O -DUSE_STRLWR=0 -DUSE_DL=1 -DUSE_MATH=1 -DUSE_ASCII_NAMES=0  scheme.c
gcc -fpic -I. -c -g -Wno-char-subscripts -O -DUSE_STRLWR=0 -DUSE_DL=1 -DUSE_MATH=1 -DUSE_ASCII_NAMES=0  dynload.c
gcc -shared -m64 -o libtinyscheme.dll scheme.o dynload.o -lm
ar crs libtinyscheme.a scheme.o dynload.o
gcc -fpic -o scheme -g -Wno-char-subscripts -O scheme.o dynload.o -lm

C:\tinyscheme-master\src>scheme king.scm
The reward of the King
----------------------

 field 1  number of grains   1
 field 2  number of grains   2
 field 3  number of grains   4
 field 4  number of grains   8
 field 5  number of grains   16
 field 6  number of grains   32
 field 7  number of grains   64
 field 8  number of grains   128
 field 9  number of grains   256
 field 10  number of grains   512
 field 11  number of grains   1024
 field 12  number of grains   2048
 field 13  number of grains   4096
 field 14  number of grains   8192
 field 15  number of grains   16384
 field 16  number of grains   32768
 field 17  number of grains   65536
 field 18  number of grains   131072
 field 19  number of grains   262144
 field 20  number of grains   524288
 field 21  number of grains   1048576
 field 22  number of grains   2097152
 field 23  number of grains   4194304
 field 24  number of grains   8388608
 field 25  number of grains   16777216
 field 26  number of grains   33554432
 field 27  number of grains   67108864
 field 28  number of grains   134217728
 field 29  number of grains   268435456
 field 30  number of grains   536870912
 field 31  number of grains   1073741824
 field 32  number of grains   2147483648
 field 33  number of grains   0
 field 34  number of grains   0
 field 35  number of grains   0
 field 36  number of grains   0
 field 37  number of grains   0
 field 38  number of grains   0
 field 39  number of grains   0
 field 40  number of grains   0
 field 41  number of grains   0
 field 42  number of grains   0
 field 43  number of grains   0
 field 44  number of grains   0
 field 45  number of grains   0
 field 46  number of grains   0
 field 47  number of grains   0
 field 48  number of grains   0
 field 49  number of grains   0
 field 50  number of grains   0
 field 51  number of grains   0
 field 52  number of grains   0
 field 53  number of grains   0
 field 54  number of grains   0
 field 55  number of grains   0
 field 56  number of grains   0
 field 57  number of grains   0
 field 58  number of grains   0
 field 59  number of grains   0
 field 60  number of grains   0
 field 61  number of grains   0
 field 62  number of grains   0
 field 63  number of grains   0
 field 64  number of grains   0

C:\tinyscheme-master\src>


JRS

  • Guest
Re: TinyScheme
« Reply #169 on: September 08, 2014, 05:31:03 PM »
I feel the only outstanding issue with using MinGW-TDM-64 is getting printf() correctly printing 64 bit values with a %l format option.

Any ideas?

I'm beginning to think this isn't a printf issue.
« Last Edit: September 08, 2014, 05:49:19 PM by John »

JRS

  • Guest
TinyScheme - The End ?
« Reply #170 on: September 08, 2014, 07:55:55 PM »
I noticed that we have lost Charles along the way taking over his forum with our Lisp projects. He hasn't posted an update since Aug. 24th which seems unusual to me. Should we take this somewhere else? I would be willing to open up the All BASIC forum with a fresh start and open to All BASIC programmers. Since BP.org is gone, maybe it would make sense.

@Mike - Would you be interested in helping me setup a new All BASIC forum and be a co-admin / moderator?

With Charles's permission, I could move the Lisp (XBLisp, TS, ...) intact to the All BASIC forum to give it a head start. We could also rummage through the old All BASIC forum for content that might be worth moving to the new forum. All of this depends on you and Charles's feelings about this continuing here.
 
  • O2 - Active
  • SB - Active
  • FBSL - Active
  • FB - Future Unkown
  • Yabasic - Future Unkown
  • PB - Future Unkown
  • BCX - Future Unkown
  • Business BASIC - Future Unkown
  • Retro BASIC's - Personal efforts with unknown user base

If we don't pull together as a community, this is our fate.


« Last Edit: September 08, 2014, 11:41:04 PM by John »

Charles Pegge

  • Guest
Re: TinyScheme
« Reply #171 on: September 08, 2014, 11:29:03 PM »

Hi John,

I have been quietly following the LISP threads. You are welcome to continue them here if that suits you. It is good to see how things are progressing.

JRS

  • Guest
Re: TinyScheme
« Reply #172 on: September 08, 2014, 11:33:39 PM »
Just wanted to make sure you are still good with the Open Forum abuse.

I'm happy folks (Mike) are taking an interest in 64 bit Windows.


Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #173 on: September 09, 2014, 02:39:30 AM »
I feel the only outstanding issue with using MinGW-TDM-64 is getting printf() correctly printing 64 bit values with a %l format option.

Hi John,

Please goto line 1937 in scheme.c and overwrite what's in there with the following code (I told you Windows printf() and its family in msvcrt.dll do not understand %ll prefixes in their format strings, and TDM GCC will not convert them for you automatically because they are hardcoded string literals):

Code: [Select]
     } else if (is_number(l)) {
          p = sc->strbuff;
          if (f <= 1 || f == 10) /* f is the base for numbers if > 1 */ {
if (num_is_integer(l)) {
snprintf(p, STRBUFFSIZE, "%I64d", ivalue_unchecked(l));
}
else {
snprintf(p, STRBUFFSIZE, "%.20g", rvalue_unchecked(l));
  /* r5rs says there must be a '.' (unless 'e'?) */
                   f = (int)strcspn(p, ".e");
                   if (p[f] == 0) {
                        p[f] = '.'; /* not found, so add '.0' at the end */
                        p[f+1] = '0';
                        p[f+2] = 0;
                   }
              }
          } else {
__int64 v = ivalue(l);
if (f == 16) {
if (v >= 0)
snprintf(p, STRBUFFSIZE, "%I64x", v);
else
snprintf(p, STRBUFFSIZE, "-%I64x", -v);
}
else if (f == 8) {
if (v >= 0)
snprintf(p, STRBUFFSIZE, "%I64o", v);
else
snprintf(p, STRBUFFSIZE, "-%I64o", -v);
}
else if (f == 2) {
unsigned __int64 b = (v < 0) ? -v : v;
p = &p[STRBUFFSIZE - 1];
*p = 0;
do { *--p = (b & 1) ? '1' : '0'; b >>= 1; } while (b != 0);
if (v < 0) *--p = '-';
}
  }


Also goto line 1157 there and overwrite it with the following:

Code: [Select]
     else if (*name == 'o') {/* #o (octal) */
          snprintf(tmp, STRBUFFSIZE, "0%s", name+1);
  sscanf(tmp, "%I64o", (__int64 unsigned *)&x);
          return (mk_integer(sc, x));
     } else if (*name == 'd') {    /* #d (decimal) */
sscanf(name + 1, "%I64d", (__int64 *)&x);
          return (mk_integer(sc, x));
     } else if (*name == 'x') {    /* #x (hex) */
          snprintf(tmp, STRBUFFSIZE, "0x%s", name+1);
  sscanf(tmp, "%I64x", (__int64 unsigned *)&x);
          return (mk_integer(sc, x));


I think this will fix your console output for long numbers.
« Last Edit: September 09, 2014, 03:52:21 AM by Mike Lobanovsky »

Mike Lobanovsky

  • Guest
Re: TinyScheme - The End ?
« Reply #174 on: September 09, 2014, 02:54:15 AM »
@Mike - Would you be interested in helping me setup a new All BASIC forum and be a co-admin / moderator?

John,

I don't think it would be a wise decision to split our meager human resources any further. The OxygenBasic forum is a well-established resource with good general visitor rate and a solid base of registered fellow BASIC developers.

We're acting on its Open Forum board and we aren't spawning multiple threads here. We've got only two of them -- TS and Lisp-in-Basic -- and I don't think we'll need any more. The former was an offspring of the latter but noone can foretell that we won't ever come back to the original topic. It isn't just ripe at the moment but who knows...

JRS

  • Guest
Re: TinyScheme
« Reply #175 on: September 09, 2014, 07:21:20 AM »
Thanks Mike for the code and effort to resolve the 64 bit C printing issue. It would save me some time if you were to post your working code. Is there any additional includes needed or type casting to eliminate warnings?

I have been chatting with Dave via e-mail and it looks like the COM / VB effort is now in my hands. Dave has some debilitating issues with his arms that makes extended programming sessions very painful (physical) for him. It would be great if Charles can have a look at Dave's code and see if it can be combined with the DLLC effort and O2 COM. I have shifted my efforts from TinyScheme (once SB TS Win64 ext. mod. is working) to understanding better where Dave has left off. I think most of his goals have been completed.

OT

I seem to be making some progress on the Twitter front and picking up a few high asset likes.





« Last Edit: September 09, 2014, 08:16:48 AM by John »

Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #176 on: September 09, 2014, 08:39:00 AM »
It would save me some time if you were to post your working code. Is there any additional includes needed or type casting to eliminate warnings?

I don't clearly see what working code you're expecting from me. I have none except the one I fixed for VS2013 and uploaded here.

I repeat I do not have a 64-bit TDM GCC installed to run the compilations myself. As I understood from you previous messages, you secceeded in compiling the original TS code into a genuine 64-bit executable without warnings using your installation of 64-bit TDM GCC for Windows, and the only issue you're having now is printing your math with correct bitness.

So why don't you do as I suggest in my earlier message: overwrite (or rem out temporarily) the old code with what I offered and recompile. I think it will make your print work as expected. As simple as that - no warnings and working print in a 64-bit TS when compiled with TDM GCC. Just forget VC and my submission if TDM GCC is so smart as to turn the sources to 64 bits automatically except the format strings that I fixed for you manually. If this works as expected then you can add conditional compilation to these two print portions with #ifdef WIN32 and keep the original %l's for Linux. This will conform to your principle of one source for all platforms and bitnesses.

JRS

  • Guest
Re: TinyScheme
« Reply #177 on: September 09, 2014, 09:07:34 AM »
Got it. Great advice which I will follow. I'll use my last  warningless/errorless TDM-GCC-64 code as a base.  At this point my plan is to use gcc 4.8.1 across the board for SB. (all supported OSs) As mentioned before, I'm only using VS2008 at the moment with Dave's COM stuff. I tried to upgrade his code to VS2013 and it broke too many things due to deprecation. (most were warnings with only one hard error) If there is any interest in Dave's effort, the Github repository is the place to go. Dave has a Windows installer for the SB IDE/Debugger in the distribution if you want to give it a try. I works fine on both XP & Win7 64. (WOW)


RobbeK

  • Guest
Re: TinyScheme
« Reply #178 on: September 09, 2014, 02:16:54 PM »
Something not mentioned about Lisp  yet ,  maybe one of its most powerful tools -- the macro (in the sense of "a programmable programming language - extending the language ).

Maybe you're already bored by declaring and initiating all those globals

(define something somewhat) ....   (define something-else somewhat-else) etc ...    this is a solution (did this in NewLisp )

(define define-Integer   ;; can be changed to any type and even typeless
  (lambda-macro ()
     (doargs (i) (set i 0))))

now we can do   (define-Integer a z e r t y)      resulting a..y is defined as 0 (an integer)

Similar mechanisms exist in Scheme and Common Lisp (but here it is easier, because NewLisp does not need to compile such things )
The (set i . ) does the trick here , it doesn't quote i , but points to the value pointed by i .. 

I've been told, writing macro's in C really is not easy .. (?)

best Rob

 



.
« Last Edit: September 09, 2014, 02:27:06 PM by RobbeK »

JRS

  • Guest
Re: TinyScheme
« Reply #179 on: September 09, 2014, 02:40:36 PM »
Thankfully BASIC was spared. I can only imagine what picture would be used.   :o

Is it just me or does Lisp seem more popular and feature rich on the Linux side? I have 64 bit versions of all the most popular Lisp languages built from scratch on my box. Porting these to Windows isn't walk in the park.



« Last Edit: September 09, 2014, 02:47:50 PM by John »