Main Menu

Forums SwiftForth Forum SwiftForth from Emacs Console?

This topic contains 4 replies, has 3 voices, and was last updated by  Todd King 1 year, 6 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #5218



    I normally like to run from inside of Emacs. But when I try to fire up sf it bombs immediately after printing the version banner with an illegal instruction exception. SwiftForth runs just fine in a terminal window on Mac OSX.

    Here’s a short session:
    # proof of life…
    bash-3.2$ echo pad 20 dump | sf

    3B908 6E 00 07 00 AF 24 00 00 6F 00 07 00 AF 24 00 00 n….$..o….$..
    3B918 70 00 07 00 p…
    # try interactive mode
    bash-3.2$ sf
    SwiftForth i386-Mac OS X 3.6.3 29-Jun-2016
    Illegal instruction: 4

    So, let’s look at the debugger session:

    bash-3.2$ lldb
    (lldb) file /usr/local/SwiftForth/bin/osx/sf
    Current executable set to ‘/usr/local/SwiftForth/bin/osx/sf’ (i386).
    (lldb) run
    Process 20697 launched: ‘/usr/local/SwiftForth/bin/osx/sf’ (i386)
    SwiftForth i386-Mac OS X 3.6.3 29-Jun-2016
    Process 20697 stopped
    * thread #1: tid = 0x19ec003, 0x00004af9 sf, queue = ‘’, stop reason = EXC_BAD_ACCESS (code=2, address=0x1003000)
    frame #0: 0x00004af9 sf
    -> 0x4af9: movb %bl, (%edx)
    0x4afb: incl %edx
    0x4afc: decl %ecx
    0x4afd: jne 0x4af9

    I’m sure the problem is related to Emacs command line I/O from a shell buffer. But I’m just not sure where to be looking for a solution. I can’t tell from the brief debugger output what part of Forth I’m viewing.

    Any hints?



    a little more info… Here are the registers:

    (lldb) register read
    General Purpose Registers:
    eax = 0x00012450
    ebx = 0x00000020
    ecx = 0xff00f44f
    edx = 0x01003000
    edi = 0x00002020
    esi = 0x00010450
    ebp = 0xbffff9dc
    esp = 0xbfff7990
    ss = 0x00000023
    eflags = 0x00010292
    eip = 0x00004af9
    cs = 0x0000001b
    ds = 0x00000023
    es = 0x00000023
    fs = 0x00000000
    gs = 0x0000000f


    So, it appears that Forth is trying to fill a buffer with BL. And the destination address is faulted. But look also at that counter in ECX. Pretty bizarre count.

    – DM



    Okay… I think I’m beginning to see what the issue is. Perusing the kernel sources (and many thanks for including those!!) I see that SwiftForth is trying hard not to rely on anything other than its own resources. And so it performs character/line console I/O directly against the OS kernel TTY devices.

    To be honest, I haven’t seen that on desktop computers for several decades. But I appreciate where you are coming from. I’m an old old hand at Forth.

    So, if I really desired this capability, I think I could write a glue layer to perform character / line I/O against STDIN and then modify the kernel to vector to those glue routines. Emacs already handles all the nice line editing, history, and completion. I just need to regenerate the Forth system. Maybe a project for me during quieter times…

    For now I can live happily in a Terminal window and use Emacs on demand from inside of SwiftForth. That works just fine too.

    – DM


    Cyril Elkaim


    For your information you will be able to run SF from the ‘term’ command (M-x term). ‘term’ is not as easy to use than ‘shell’ por ‘eshell’ but it’s a workaround.

    Tested with emacs on debian stretch.



    Todd King

    I have a related question about the Windows product. I have used the trial with Linux and use Emacs.

    Is there a way to access the Windows IDE console (“Command Window”) as a terminal/console app as in Linux?


Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.