Tag Archives: osx

FRIBBLE, a SPITBOL program to play word games such as Word With Friends, now available

The FRIBBLE project is pleased to announce its first release V17.1.30, available at Fribble Project.

FRIBBLE is written in SPITBOL, and uses a brute-force approach, trying all possible moves, to play WWWF.

Fribble can be run in three ways: to play against itself, to play against you, or to help you play a game with a foe, with Fribble finding your moves.

The code speaks for itself. Speaking for my self, I can say that I have never had more fun writing a program than I have had writing FRIBBLE.

FRIBBLE is also my first program inspired by an election.

I was an obsessive follower of the recent presidential election, spending more time than I care to admit on Twitter, reading blogs, listening to podcasts, and so on.

After the election, looking for a more productive and entertaining form of amusement, I started playing Words With Friends, an online version of Scrabble. My foe was a fellow IBMer and friend who said he was quite good at WWF.

Indeed he is. We have played many games and I have yet to beat him. Often his score is 50% higher than mine.

Soon after I realized I was unlikely to ever win a game against him, I though of using my programming skills to see if I would write a program that could play WWF.

Fribble, representing just over two months of the most fun I have yet had writing a program, is the realization of that goal.

What has made the writing of Fribble such fun is the realization that it is as close to an ideal demonstration of SPITBOL as I have yet seen. Everyone knows about games such as Scrabble and WWF, and dealing with strings, words, lines of text, dictionaries, and all that such games involve, is the perfect grist for SPITBOL’s mill.

Though the program is largely done, I plan to continue work on it by using it as a way to teach SPITBOL as a first, or at least early, programming language.

Dave

Advertisements

SPITBOL for OSX is now available

The SPITBOL project is pleased to announce that an implementation for OSX is now available, and can be found at github.com/spitbol/spitbol.

SPITBOL now supports the use of the gas (GNU as) assembler to translate the MINIMAL source code. This is now the default translator used for Unix and OSX.

Executable binaries:

./bin/sbl_osx OSX SPITBOL (64 bits)

./bin/sbl_unix Unix version (64 bits)

./bin/sbl_unix_32 Unix version (32 bits)

Documentation:

./docs/green-book.pdf The SNOBOL4 Programming Language, Griswold, et. al.

./docs/spitbol-manual.pdf SPITBOL User Manual, Emmer and Quillen

./demos demonstration programs from the SPITBOL User Manual

SPITBOL is licensed under the GPL (v2 or later) license. All code needed to build the system is included in this repository.

To build spitbol (./sbl):

OSX:

make osx

make test_osx
Unix:

make unix

make test_unix
See readme.txt for instructions on interpreting the test output.

SPITBOL OSX Port Status, and a New Use for SPITBOL in the Port

I’ve spent the last month or so trying to port SPITBOL to Apple’s OSX.

What I thought would be a simple port — since the Linux x32 and x64 port was solid — turned out to be more daunting.

OSX is now 64-bits by default, and uses a different object format (macho) than does Linux (elf).

The main problem I’ve run into is that in 64-bits the storage model is different, so that code and data must use what is called RIP-addressing, where RIP stands for Relative to Instruction Pointer.

The first problem I ran into was a crash of NASM, the assembler I’ve been using.

Once the folks at NASM fixed that, I was unable to get even the simplest program working in RIP-mode for 64-bit OSX.

I then realized — I wish I had thought of this sooner — that OSX might support 32-bit mode.

Indeed it does. So I tried to build 32-bit SPITBOL using NASM.

This also gave problems, mainly in that it generated bad refs for the first three of so globals defined in m.s. I tried to get around this by moving their declaration to C code, but even after doing that, SPITBOL crashed.

So I have decided to convert the Minimal code generator to target GAS (the GNU assembler) and not NASM. This also involves converting the approximately 1500 lines of assembler needed to link the SPITBOL compiler to the runtime code written in C from NASM to GAS.

I’m in the midst of this, and it’s going well so far, so I’m hopeful the port will get done.

As part of the conversion from NASM to GAS, I’ve learned that GAS is less powerful when it comes to macros and substitutions. For example, in NASM, in 64-bit mode, I can write “%define WA RCX” to map the Minimal register WA to the machine register RCX. For 32-bits I can write “%define WA ECX.”

But I can’t do this in GAS, and so I wrote a program that, given the word size, maps the Minimal register names in upper-case to the corresponding hardware registers:

*	rename Minimal registers to x86_64 registers according to word size for x86_64

	prefix = (eq(host(0),32) "%e", "%r")

	rmap = table(20)
	rmap['XL'] = 'si';  rmap['XR'] = 'di';  rmap['XS'] = 'sp';  rmap['XT'] = 'si'
	rmap['WA'] = 'cx';  rmap['WB'] = 'bx';  rmap['WC'] = 'dx';  rmap['W0'] = 'ax' 
	rmap['IA'] = 'bp'

	rpat =  'IA' | ('X' any('LRST')) | ('W' any('ABC0')) 
next
	line = input				:f(end)
loop
	line rpat . reg = prefix rmap[reg]	:s(loop)
	output = line				:(next)
end

Being able to write code such as this, in a short time (it took about twenty minutes to write and debug) is why it is worth the long slog of implementation and porting.

It’s just such damn fun to write code in SPITBOL.

SPITBOL Status Report

Early this summer I started work on what I thought would be a modest change: convert SPITBOL from using the GNU GAS assembler to my favorite X86 assembler, NASM. I also wanted to do some code cleanup as part of this.

Alas! What I thought would take a few weeks took a few months.

I make no excuses. The fault was mine, and I knew it was my job to fix it.

I also soon realized that while it would take longer, the work was needed, as I hadn’t worked on SPITBOL in almost three decades, and my programming skills, especially in X86 assembler were — to say the least — quite rusty.

I had forgotten almost all — which really wasn’t that much — of SPITBOL structures and internals, so it was necessary to reacquire that knowledge — even if I had to do it the hard way.

The process was complicated by the poor support for assembly language programming provided by Linux. I knew about GDB and its visual front-end, DDD. However, I found them sorely lacking, probably because SPITBOL as I found it intermixed data and code in the code section, and this was enough to cause problems using these tools.

As a result, I implemented a variety of instruction-level traces to try to find out what was happening. That itself was an interesting experience, one that made me appreciate even more the power of SPITBOL when it comes to doing this sort of thing.

I plan to write more about this in a future post, but the immediate porting concerns must be addressed first.

The current status is as follows.

The code now available at Hardbol SPITBOL contains a directory b32 with a bootstrap compiler. This is a 32-bit word, 8-bit character SPITBOL using only TCC as the C compiler, MUSL as the library, and NASM as the assembler. The system is thus self-contained in that does not rely on gcc/gnu code.

It doesn’t support floating point.

The OSINT procedures have been cleaned up in that all mention of obsolete systems such as Windows NT, SOLARIS, and MAC (pre OSX) have been omitted.

Going forth, SPITOBL will support only one operating system — Unix.

I have started work on the port for Linux 64-bit word, 8-bit characters. I expect that won’t take too long, but given my track record, we will see…

Once I have that, I’ll try port to OSX. TCC and MUSL support OSX. If that goes well, I’ll put it out. If I run into too many problems, I’ll back off and just do the next — and key — port, for 64-bit words and 32-bit characters, as that is needed for full UNICODE support.

I’ll keep you posted.

  • Pages

  • December 2017
    M T W T F S S
    « Apr    
     123
    45678910
    11121314151617
    18192021222324
    25262728293031
  • RSS The Wayward Word Press

  • Recent Comments

    mrrdev on On being the maintainer, sole…
    daveshields on On being the maintainer, sole…
    James Murray on On being the maintainer, sole…
    russurquhart1 on SPITBOL for OSX is now av…
    dave porter on On being the maintainer, sole…
  • Archives

  • Blog Stats

  • Top Posts

  • Top Rated

  • Recent Posts

  • Archives

  • Top Rated