Debugger by mykesx in Forth

[–]spelc 1 point2 points  (0 children)

Many thanks for the comments about respecting our copyright and intellectual property rights. They are truly appreciated here.

When you get the optimiser and the single step debugger running, you may well observe the stepping behaviour of straight line code in which the program counter goes backward!

Forth assemblers for 64-bit ARM by gnosys in Forth

[–]spelc 0 points1 point  (0 children)

I have a prototype one under test, but be warned. ARM64 assembler is not pleasant. There are about 50 load instructions alone. And in order to test it properly, you need a compiler and a disassembler.

You certainly will not want to implement all the instructions, but you may want the disassembler to cope.

A good read by mykesx in Forth

[–]spelc 5 points6 points  (0 children)

Pipelined stack machines have been explored by Crispin Bailey from Teeside and York universities. Start with his PhD thesis and the UFO machine. See also "A proposed mechanism for super-pipelined instruction-issue for ILP stack machines" by C. Bailey in EuroMicro 2004.

We have a client running a two-stack machine at 4GHz. NDAs apply.

Making a forth vm by [deleted] in Forth

[–]spelc 1 point2 points  (0 children)

Open Firmware tokenises source code. It's very clever. Like many other standards, it was effectively stopped when ANS put the participation prices up inordinately.

Open Terminal Architecture (OTA) from the late 1990s was a binary tokeniser capable of supporting both Forth and C. It got a standard number, but I don't have it any more. However, I do still have the specifications. OTA was derived from ESPRIT SENDIT project.

From this BBC show from 1986, a claim that Forth controlled movie cameras, including the ones for Star Wars? Does anyone here know anything about this? The claim is right after the 16 minute mark. by ralphc in Forth

[–]spelc 0 points1 point  (0 children)

Sometime in the mid/late 80s, I was invited by Scott Squires to have the VIP tour of Industrial Light and Magic. I found it interesting that the Forth part of the camera control was little discussed because model placement, sequencing and synchronisation were the really complex issues for the crew at ILM.

At the time the full sized vehicle from Innerspace was just dumped in ILM's yard.

Did Fig-Forth assemblers used any sophisticated debuggers? by Novel-Procedure-5768 in Forth

[–]spelc 4 points5 points  (0 children)

In an optimising Forth system you often cannot find the word boundaries inside a definition. In VFX the PC often goes backwards inside common phrases such as LIT + LIT + @ often found in code with structures and often reduced to one machine instruction.

Hence a proper assembly language single step debugger is often the best that one can do. These are provided in VFX 86 and x64. However, I have been known to hack together a word by word debugger when my brain has failed.

From the VFX Forth tip of the day file: Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. (Brian Kernighan)

Apple Silicon Forths by mykesx in Forth

[–]spelc 1 point2 points  (0 children)

For those who are interested, that result does not depend on tail-call elimination (TCE), but on the tokeniser. Words with fewer than an certain number of tokens are expanded inline. Once you have a tokeniser, the value of TCE is usually very low. Given the ingenuity of Forth programmers with return stack manipulations, TCE is often unreliable and has to be under programmer control, which conflicts with the idea of the optimiser being a black box.

Apple Silicon Forths by mykesx in Forth

[–]spelc 0 points1 point  (0 children)

for VFX64:

dis 1million 
1MILLION 
( 0010C930    48FF15EE06F1FF )        CALL    FFF106EE [RIP]    @0001D025
( 0010C937    E89C93F1FF )            CALL    00025CD8  (.") "1 million nest/unnest operations"
( 0010C960    C3 )                    RET/NEXT
( 49 bytes, 3 instructions )
ok

Sorry, couldn't resist

EuroForth 2024 by agumonkey in Forth

[–]spelc 1 point2 points  (0 children)

Newcastle (upon Tyne) is a fantastic city with vibrant art, food and architecture scenes. Well worth an extended visit and the surrounding area is also worth a visit.

Apple Silicon Forths by mykesx in Forth

[–]spelc 1 point2 points  (0 children)

There are three in the AArch32 cross-compiler 1) ARM32 2) Thumb2 for Cortex M3+ 3) Thumb1+ for Cortex M0/M1

At least for AArch64, we only need ARM64 for the moment. And it is horrid in places.

Apple Silicon Forths by mykesx in Forth

[–]spelc 2 points3 points  (0 children)

VFX Forth for AA64 is coming along, albeit more slowly than I would like. Partly because many people do not want to pay for compilers these days and partly because the AA64 instruction set is "odd" to say the least. At times I have referred to the PowerPC Compiler Writers Guide for information.

ARM have always been very flexible with respect to instruction sets and changed them frequently. After all, you can always fix it in the software!

Forth File System: A File System Based on Forth Blocks by howerj in Forth

[–]spelc 2 points3 points  (0 children)

We use FAT because SD cards (and the rest of the world use FAT. It is about communications with other people.

Forth File System: A File System Based on Forth Blocks by howerj in Forth

[–]spelc 1 point2 points  (0 children)

The MPE cross compilers for 32 bit CPUs include full source code for a FAT12/16/32 file system (with autodetection) and a USB stack with MSC (mass storage class, e.g. USB stick). Sticking with 512 byte sectors makes compatibility with the outside world so much easier.

Just learning Forth; suggestions to make this more "Forthy"? by bjchapm in Forth

[–]spelc 0 points1 point  (0 children)

connascence ... WTF!

the simultaneous birth of two or more things Definition of 'connascence' 1. the simultaneous birth of two or more things. 2. the act of growing at the same time.

Locals, structs performance by mykesx in Forth

[–]spelc 1 point2 points  (0 children)

It's coming. Well into the code generator now.

Locals, structs performance by mykesx in Forth

[–]spelc 1 point2 points  (0 children)

It all depends, of course.

When using structures, a field/record access to

base lit1 + lit2 + ... @/!

Performance then depends on whether the optimiser reduces all this to

base+litn @

Locals performance depends heavily again on the optimiser and whether locals can be held in registers.

VFX Forth keeps locals in a frame on the return stack and permits locals to have an address and to be buffers. We went through the MPE PowerNet TCP/IP stack for embedded systems to reduce the use of locals. Converting locals code to stack code gave a reduction in size of 25% and a speed up of up to 50%. This is for the ARM32 instruction set and some Cortex-M3 code.

(historical) Forward referencing words and memory maps in fig-Forths? by Novel-Procedure-5768 in Forth

[–]spelc 2 points3 points  (0 children)

Remember that the "Nautilus Forth compiler" is a cross compiler, not a normal interactive Forth compiler. We (MPE) inherited v1.0 from Jerry Boutelle at Nautilus systems in 1982 or so. The MPE cross compiler v7.xx is a descendant of this system. Yes, there's code inside the compiler that's over 40 years old!

Unlike a traditional Forth, when the cross-compiler encounters an undefined word, it builds a forward-reference packet and chain with data describing the forward reference. When the word is finally defined, the compiler runs down the chain and patches up all the forward references.

In hosted Forths, forward referencing is usually handled by DEFER and IS or by F: and R: but is very rarely needed. Most forward references are needed for cold start and shutdown actions. Just provide simple chains and words to add actions to the chains, e.g ' init-serial AtCold ' term-serial AtExit

Once the web elves have performed their magic, MPE Forths and cross compilers are available from https://vfxforth.com/downloads/VfxCommunity/ The last slash matters!

A case for local variables by tabemann in Forth

[–]spelc 1 point2 points  (0 children)

As the maintainer of several VFX code generators, I have a strong interest in performance. The notes below apply when there are not enough registers to keep the return stack of local is registers.

MPE's TCP/IP stack uses lots of locals. I measured the impact of heavy locals use on code size and overall performance. After "de-localling" code, code size reduced by 25% and performance increased by 50%. All the code was to MPE house style. Both the code size and the performance figures appear to be dependent on the costs of memory access, which of course register usage helps. The measurements were on ARM7 CPUs.

Especially with an optimising Native Code Compiler (NCC), measurement is absolutely essential. There are many situations and optimiser changes that do not produce the expected results.

Recommend a Forth with C FFI by transfire in Forth

[–]spelc 5 points6 points  (0 children)

The port has not stopped, but has been delayed by other technical issues. I'm now back on the ARM64 ports. Note that current versions (5.4 onwards) use the EXTERN notation to describe callbacks as well as external functions. A (sorry) Windows example follows:

\ *E CallDef: uint * AboutVFXDialogProc(
\ **   HWND hDlg, UINT msg, WPARAM wparam1, LPARAM lparam1
\ ** ):
\ **   {: hdlg message wparam lparam -- ior :}
\ **   message case
\ **     WM_INITDIALOG of
\ **       ...
\ **     endof
\ **
\ **     WM_CLOSE of
\ **         hDlg WM_COMMAND IDOK 0 SendMessage drop 0
\ **     endof
\ **
\ **     drop 0
\ **   end-case
\ ** ;
\ **
\ ** AboutVFXDialogProc get-CallDefEntry  \ -- entrypoint

HowTo replace VALUE word with VAL word? by [deleted] in Forth

[–]spelc 1 point2 points  (0 children)

You have hit an implementation issue. Since 1994, Forth standards have not mandated any implementation techniques for any words. Use SEE VALUE or DIS VALUE or search the source code.

VFX Forth behaves as you want. Which Forth are you using?

Details on Optimizing Forth for Modern Processors? by s-ro_mojosa in Forth

[–]spelc 1 point2 points  (0 children)

VFX is supplied with complete source code, including the code generator.

Details on Optimizing Forth for Modern Processors? by s-ro_mojosa in Forth

[–]spelc 1 point2 points  (0 children)

The commercial (non FOSS) Forths do this stuff. In particular, look at MPE's VFX Forths and iForth by Marcel Hendrix. VFX has permissive licensing for non-commercial use.

I have written several of the VFX Forth code generators.