2022-03-16 00:10:24 someone was talking about writing a forth 9p client. Is it complete? I need to do something similar too. 2022-03-16 04:25:04 joe9: https://github.com/iru-/9p4 ? 2022-03-16 08:05:56 Looks like that will choose default argument values for you when appropriate, but I guess the stack has to be otherwise empty in order for that to work? 2022-03-16 08:06:09 crc, that is good code. I like it. Thanks. 2022-03-16 08:06:47 It occurs to me that it would be nice to be able to "fence" your stack, so you could have stack underflow warnings when you foul up even if there is "outside unrelated stuff" on the stack. 2022-03-16 08:07:16 You would fence when starting some piece of work, and un-fence when done. Sort of create yourself a "sandbox." 2022-03-16 08:07:20 that is part of the interpreter loop. 2022-03-16 08:07:33 with ff 2022-03-16 08:07:34 Well, checking for the errors is. 2022-03-16 08:07:54 Ah, so you'd run a new copy of the interpreter for the new work? 2022-03-16 08:08:03 That's kind of reasonable, I guess. 2022-03-16 08:08:21 That way you'd get protection when LOAD-ing. 2022-03-16 08:09:00 I'll need to think about that - I have the normal underflow check in my interpreter loop, but it doesn't reset "bottom" if the interpreter is re-called. 2022-03-16 08:09:07 But it could - thanks; good idea. 2022-03-16 08:09:36 That's probably the best way. 2022-03-16 08:09:55 Transparent, and LOAd would be when you'd most want it. 2022-03-16 08:11:41 It at least minimizes the damage an errant LOAD will do to the previously existing stuff. In most systems it won't wholly prevent it, though, since by the time that check is made some damage can already be done. 2022-03-16 08:12:01 You can't set hardware protection finely enough for that, can you? 2022-03-16 08:12:02 https://github.com/iru- I like this guy's forth code. 2022-03-16 08:12:09 Isn't that just on 4k page boundaries? 2022-03-16 08:12:10 does he hang out here? 2022-03-16 08:21:00 My error recovery will handle this - if LOAD throws an error it will restore the stack to whatever it was at the beginning of my *typed from keyboard* line that led to the error. 2022-03-16 08:21:11 But I still see this as an improvement. 2022-03-16 08:52:48 joe9: I haven't seen him here 2022-03-16 18:37:33 How gross is it to use MIN on addresses? 2022-03-16 18:38:21 Within a data structure that you defined that doesn't seem gross to me at all. Across independent data structures... don't know. Might be odd, but odd things happen. 2022-03-16 18:39:24 It's something I'd only use on a buffer/array 2022-03-16 18:40:02 I can envisage an embedded machine where the dictionary might cross 0x8000 for example 2022-03-16 18:40:30 So it's probably a bad idea to use in FORTH that's meant to be portable 2022-03-16 18:41:23 : UMIN ( u1 u2 - u3) 2DUP IF SWAP THEN NIP ; 2022-03-16 18:46:25 I just realised you can implement byte access with MOVE if you have a standard FORTH system where character and cell types are larger than a byte 2022-03-16 19:17:32 Oh, well, you certainly ought to use unsigned operators for that, right? 2022-03-16 19:21:06 I don't follow your definition - you're intending 2dup to take you from u1 u2 to u1 u2 u1 u2 ? 2022-03-16 19:22:04 Looks to me like that leaves you with more than one item on the stack. 2022-03-16 19:25:35 : UMIN ( u1 u2 - u3) 2DUP U< IF SWAP THEN NIP ; 2022-03-16 19:25:40 Sorry yeah 2022-03-16 19:26:16 Just checking you're paying attention ;) 2022-03-16 19:27:41 :-) 2022-03-16 19:27:56 I was just checking to make sure I wasn't becoming demented. 2022-03-16 19:30:35 I would probably make UMIN a primitive, but it's slick to have that up your sleeve if you're on a system that was missing it. 2022-03-16 19:33:03 I write 'portable' FORTH code sometimes targeting a normal ANS system, avoiding too many assumptions 2022-03-16 19:33:08 That's where I am using it 2022-03-16 19:33:43 I do make some assumptions though, e.g. what R> DROP EXIT does and that characters are 1 byte 2022-03-16 19:33:56 Because f*** write CHARS and CHAR+ everywhere 2022-03-16 19:34:00 writing* 2022-03-16 19:35:01 Yeah. I find the beautiful simplicity of ASCII really hard to let go of. 2022-03-16 19:35:22 I was just nosing around UTF-8 a couple of days ago to see if I could swallow it. I'm not ready to yet. 2022-03-16 19:55:42 hello, anybody knows a 'forth in x86_64 asm' tutorial ? 2022-03-16 19:56:17 also, stupid question, has anyone ever wrote a stack-type-checker for forth ? 2022-03-16 19:58:00 agumonkey: I haven't seen a specific tutorial, but I'm hips deep in writing an x86_64 Forth in nasm, and I'd be glad to answer questions / discuss. 2022-03-16 20:00:05 jonesforth? 2022-03-16 20:32:05 yeah I guess I'll study jonesforth 2022-03-16 20:32:13 I found a few nasm gists too 2022-03-16 20:32:27 but maybe you guys knew more sources 2022-03-16 20:32:56 KipIngram: how much have you done yet ? 2022-03-16 20:36:45 check out ff (felix forth). It is nasm (though x86 based). I have an unpolished amd64 of it. But, still some ways to go before releasing it. 2022-03-16 20:39:04 I focused on writing things necessary for the inner interpreter first. I wrote block read and write words today, and I'm running on a temporary version of . Otherwise it's pretty much ready to commence "in system development," as soon as I port over my block editor from the last version. 2022-03-16 20:39:16 It's much more "complete" than "incomplete." 2022-03-16 20:39:42 Numeric input is completely in place, with my own mechanism for variable radix. 2022-03-16 20:39:57 No create/does yet. 2022-03-16 20:43:50 Actually that . word is pretty good. It does everything you'd expect. It's just that I plan to add a printf-style formatted output facility. I've done it before and it works well - just haven't implemented it on this system yet. 2022-03-16 20:45:18 The word search is "vocabularly capable," but I haven't implemented VOCABULARY itself yet. 2022-03-16 20:47:58 was it your first asm program ? 2022-03-16 21:01:23 bbl 2022-03-16 21:01:25 thx 2022-03-16 21:10:44 Well, I've done asm off and on on various processors for nearly 40 years now. The first Forth I ever wrote, in college, was in asm for the 6809 processor. As Forth's go it wasn't very elegant - I didn't really understand how Forth worked yet at the time. But the assembly was fine. :-) This is the second x86_64 asm Forth I've done. 2022-03-16 21:10:54 I know my way around fairly well. 2022-03-16 21:30:16 Is there a normal way to exit forth? I want to jump to hex address 0300. 2022-03-16 21:37:38 I don't think there's a standard way to transfer control to a specific address. But it's likely you can do so anyway, unless you're specifically prvented from accessing / executing that RAM. BYE is a common word for exiting to the operating system; I'm not aware of what the standards might say. Maybe there's EXIT too. If QUIT is there it will probably restart your interpreter loop. 2022-03-16 21:37:54 Is your system direct threaded or indirect threaded? 2022-03-16 21:39:12 How easy it is to pull off will depend a lot on your system implementation. 2022-03-16 21:41:30 Ok, I will admit to not knowing much. I was trying to burn something useful into flash on a W65C816 board and OF816 worked. I would like to exit / jump back to the monitor. BYE hangs. I probably need to edit the address in somewhere. 2022-03-16 21:43:25 Ok, it is direct threaded! 2022-03-16 21:48:37 Ok, so if you have execute access to your target, and if you can get at the actual definition headers of your words, then you can re-direct the CFA of a word you define so that it will send you to the target. In a direct threaded system you'd just put your target address in the CFA field, and execute the word. In an indirect threaded system, you'd add a level of indirection - so, CFA -> some word of memory 2022-03-16 21:48:40 -> target. 2022-03-16 21:49:06 If it's a basic straightforward Forth you can probably do that; if it's some fancy dancy thing that's hidden a lot of stuff from you, it might not work out. 2022-03-16 21:49:24 And of course, check your docs to see if there's an official way for doing something like this. 2022-03-16 21:49:39 But the nice thing about Forth is that you can hack around on it in all kinds of ways. 2022-03-16 21:54:54 Ok, I was wondering if it was something simple. I appreciate the info and I will look into hacking it. I think it just executes a 6502 BRK instruction so I can setup a BRK handler or replace it with a JMP. 2022-03-16 22:02:56 Oh, good - on an old processor like that there won't be any fancy memory protection. It should be wide open for you. 2022-03-16 22:06:05 Old processor, cheeky, I bought it yesterday! The ROM has a 1995 date! You are right I am sure it is hackable. Just wanted to shorten the debug round trip. 2022-03-16 22:10:32 The forth uses something called fcode. The looks like the unloved child of the Sun Microsystems boot roms from the 80s. 2022-03-16 22:19:15 Forth is a great tool for playing with something like that. 2022-03-16 22:19:50 Once you get your hooks into it you'll be able to do all kinds of things. 2022-03-16 23:38:59 SpaceCoaster: f-code is a form of bytecode that's well tuned to implementing Forth. Makes for extremely compact code. 2022-03-16 23:39:18 maw KipIngram 2022-03-16 23:39:26 maw dave0