2022-03-31 00:53:03 So who among you guys have written editors for Forth systems? I'm pondering my next one. I've done several in the past. Most were "line" editors - the last one was a pretty nice "full screen" editor (well, full block, at least). 2022-03-31 00:53:18 This time I want to honor newlines instead of 64x64'ing it. 2022-03-31 00:54:14 And what I'm specifically pondering right now is supporting colors, styles, etc. via embedded ansi sequences. As far as I can tell they always start with and are then terminated by the next *letter*. 2022-03-31 00:54:29 So they're easy to detect on a left to right scan, but not on a right to left scan. 2022-03-31 00:55:04 I think I'm about to modify WORD to ignore them. 2022-03-31 00:55:17 So they can be embedded in the source without effect. 2022-03-31 00:55:38 And then if I ever wanted to try out any of Chuck's color ideas, I'd be halfway there already. 2022-03-31 00:56:18 Anyway, I'm interested in any thoughts / experiences on useful data structures, things that worked and didn't work, etc. 2022-03-31 00:56:48 The WORD modification should be pretty fast an easy, since that is in fact a left to right scan. 2022-03-31 00:57:36 "cursor left" looks harder - I don't see any alternative to starting over in column one and scanning left until I get to "one less than my current column." 2022-03-31 00:57:44 I mean scanning right. 2022-03-31 01:12:52 KipIngram: are you there? 2022-03-31 01:13:15 I wanted to ask you if you've read the threaded interpretive languages book 2022-03-31 01:14:24 because it was kind of weird that you didn't recomend it now even named it, it seems it can help me a bit 2022-03-31 01:14:37 s/now/not/ 2022-03-31 01:15:02 I am here, and I think I did some rather long time ago. 2022-03-31 01:15:03 wanted to ask you before but I've forgot what wanted to ask you :D 2022-03-31 01:15:16 :-) 2022-03-31 01:15:38 I just always gravitated to the McCabe book; it pretty much covered everything I was curious about. 2022-03-31 01:15:52 I'm trying to learn asm, can't do nothing yet, but If forth wants to be implemented in asm, I'll try 2022-03-31 01:16:02 I always wanted to learn asm anyways 2022-03-31 01:16:16 atm I just can make a program to exit with a return value xD 2022-03-31 01:16:44 but learning asm will help me also to understand jonesforth and try to make it work in my machine 2022-03-31 01:17:01 also I see I can put some C code, and asm code in C 2022-03-31 01:17:16 I saw I can even use mov with C variables 2022-03-31 01:18:27 I'll take a look at this book, I see a lot of good reviews 2022-03-31 01:18:40 That's exactly the way to start. 2022-03-31 01:18:48 Just get back to your prompt without crashing. 2022-03-31 01:19:11 Then get a routine that will output a string, one that will read from the keyboard, etc. 2022-03-31 01:19:58 Once you have two or three little routines, you can add an inner interpreter, string them together into a definition, and see if you can read a string, write it back out, and quit, all done by a real Forth definition. 2022-03-31 01:20:07 It doesn't take too long to get to that point. 2022-03-31 01:20:21 what I want is to get right the return stack and the structure control words like if begin again, I'm a bit worried also about postpone and alike 2022-03-31 01:20:27 I can refer you to a good syscall table, and can give you pointers on getting the syscalls to work. 2022-03-31 01:20:48 You also need to make a plan for your registers. 2022-03-31 01:20:53 What kind of computer are you on? 2022-03-31 01:20:58 Is it Linux? 2022-03-31 01:21:03 I see a lot of words, it's not so easy than I initially thought but it's my first real project and I really want (I feel the need) to do it 2022-03-31 01:21:11 it's netbsd 2022-03-31 01:21:46 it's weird but now than I've "discovered" forth I cannot come back 2022-03-31 01:21:58 Ok. So for registers, you want one as the Forth instruction pointer, one as the data stack pointer, one as the return stack pointer, and one as your "top item of data stack" cache reg. 2022-03-31 01:21:59 that* 2022-03-31 01:22:03 That's kind of the minimum. 2022-03-31 01:22:14 that's why I say you shouldn't apologize when you type wrong stuff :D 2022-03-31 01:22:16 There are other worthy things to use registers for, but those re the big ones. 2022-03-31 01:22:31 I kick the dictionary in every sentence 2022-03-31 01:22:32 You'll probably need two "scratch" registers for the inner interpreter. 2022-03-31 01:22:41 One is usually called "W". 2022-03-31 01:23:03 So so far you have IP, TOS (top of stack), SP, RP, and W, and then another one for scratch that doesn't have a common name. 2022-03-31 01:23:07 KipIngram: I saw about using a register for the top of the stack, they say it gives some performance 2022-03-31 01:23:31 I wonder why they don't use 2 registers as most of arithmetic words will use 2 values 2022-03-31 01:23:38 It does. Caching the top two items gives a hair more, but it's painful to implement and the payoff isn't nearly as big as adding that first one. 2022-03-31 01:23:41 and I wonder also about a circular data stack 2022-03-31 01:23:53 The GForth guys have delved pretty deep into this, and got quantitative results on it. 2022-03-31 01:24:29 Chuck went to circular in his chips. My old HP calculator had just four registers in the stack, and the top one would "repeat on drop". 2022-03-31 01:24:43 But I've never tried a limited stack Forth. 2022-03-31 01:24:53 For your first attempt I think I recommend not doing that. 2022-03-31 01:25:03 Don't put obstacles in your path. 2022-03-31 01:25:26 https://hackeradam.com/x86-64-linux-syscalls/ 2022-03-31 01:25:34 I wonder what happens if I use the ah al registers in order to have more registers available instead of the extended ones 2022-03-31 01:25:58 I'd have run out if I didn't use the whole 64-bit register set. 2022-03-31 01:26:15 What are you saving them for? 2022-03-31 01:26:36 Generally you'll be writing Forth, not assembler, so I'd say use them to make the Forth as good as it can be. 2022-03-31 01:26:39 nothing, but they could help with making a stack 2022-03-31 01:26:57 Ok. Well, I haven't explored that territory. 2022-03-31 01:27:07 I've always just done the one top of stack cache reg. 2022-03-31 01:27:21 That's far and away the most common approach. 2022-03-31 01:27:38 I'll just try to stick to what the book says, for what I've read it seems a book for writing forths so it's what I wanted 2022-03-31 01:28:03 I think you're going to have a lot of fun. 2022-03-31 01:28:17 At first it's a little tedious, but then... things start to WORK. 2022-03-31 01:28:21 still having the mcabe book, thanks KipIngram I keep finding more forth books 2022-03-31 01:28:32 Once you get it running definitions, then you just inch your way forward, toward an interpreter. 2022-03-31 01:29:07 well I want theory first, I want to understand how I'm supposed to do the stuff 2022-03-31 01:29:17 Once you get it so you can type a string and have it echo it, and you're looping on that (as a Forth loop, not an assembler loop), then that's the skeleton of the interpreter. 2022-03-31 01:29:45 I don't like when I have to copypaste code I don't understand in order to study it and learn stuff from that 2022-03-31 01:30:03 I mean this is some approach some books and tutorials have 2022-03-31 01:30:05 sounds like me. I want to understand everything. 2022-03-31 01:30:26 Well, copy and paste the IDEAS, but write your own code. 2022-03-31 01:30:30 it's a weird question, but are you cancer in the horoscope? 2022-03-31 01:30:39 Capricorn. 2022-03-31 01:31:01 :0 I don't believe in predictions, but somehow the descriptions seem to match 2022-03-31 01:31:10 :-) 2022-03-31 01:33:16 I'll go to read a bit of the book, I want my forth, but I know is better to wait than make another abomination like before 2022-03-31 01:36:02 You'll get there. I use nasm, by the way. There are others, but I only know the one. It's been a good workhorse. 2022-03-31 01:45:36 I've seen a nice youtube tutorial using masm (he uses windows and visual studio) 2022-03-31 01:45:55 but he explains well and shows with the debugger what happens when demostrating what he says 2022-03-31 01:47:06 https://www.youtube.com/watch?v=rxsBghsrvpI&list=PLKK11Ligqitg9MOX3-0tFT1Rmh3uJp7kA&ab_channel=Creel 2022-03-31 01:50:52 Cool. It's been *forever* since I used a debugger. Literally the DEBUG days, back on DOS. 2022-03-31 01:51:18 I've tried off and on to use gdb, and actually did accomplish a little with it a week ago or so, but it's not really enough to count. 2022-03-31 01:51:37 Ok, well, I THINK I got an ansi sequence skipper into WORD. 2022-03-31 01:51:43 But I've no good way to test it. 2022-03-31 01:51:59 It's not breaking anything, but it's not really getting exercised either. 2022-03-31 01:52:32 It was pretty simple, though - I'd say I'm like 85% sure it's right. 2022-03-31 01:54:18 Oh, wait - I can choose some other character to "stand in" for escape, and then I'll be able to test it. Say, ~. 2022-03-31 02:32:52 Ok, ansi skipper is working now. 2022-03-31 08:02:34 dave0: A little "me" time is quite often too much "me" time 2022-03-31 08:06:48 veltas: far out that message was like 24 hours ago lol 2022-03-31 08:17:02 I have a high IRC latency :P 2022-03-31 10:28:43 So, do contemporary Linux distros still support framebuffers, a la /dev/fb0? 2022-03-31 10:37:46 That's not really a distro thing, but rather a kernel thing. You can probably load a module to create those device nodes to allow fb access, but it will probably depend if modern kernels still support it. 2022-03-31 10:38:02 I can't tell you for certain, since I'm a BSD guy, but I'd imagine you're in luck. 2022-03-31 10:39:45 they do 2022-03-31 10:42:31 Some goddess of discord you are, with your informative contributions! 2022-03-31 10:44:16 haha 2022-03-31 10:44:25 i meant linux kernels 2022-03-31 10:44:32 they do support fb still, caveats and all 2022-03-31 11:28:18 KipIngram, with gdb did you put it in TUI mode? makes an enormous difference 2022-03-31 11:28:57 I like nasm too. I used it on a 6502 project to do preprocessing since the macro language is decent and it just ignores all the 6502 instructions since it doesnt understand them 2022-03-31 11:29:44 No, didn't know to try that. I'll check it out. 2022-03-31 11:30:06 It was the first time I'd ever gotten gdb to fly AT ALL - I've found it rather frustrating over the years. 2022-03-31 11:36:40 what I see for example: https://ibb.co/4s4hLhD 2022-03-31 11:46:54 There are lots of scripts around to enhance TUI mode as well. 2022-03-31 11:47:04 And simulator mode. 2022-03-31 12:25:43 How does one run gdb in that tui mode? 2022-03-31 12:28:46 IMHO, the less We know about GDB the better. 2022-03-31 12:30:52 GDB-ing is like flogging, make no ""bugs"". 2022-03-31 12:32:12 Well, that's actually been how I've felt all these years. 2022-03-31 12:32:27 I cut my teeth on DEBUG. Simple, easy, just did what you told it to do. 2022-03-31 12:32:44 As far as I can tell gdb won't even let me use an ADDRESS to specify a breakpoint. 2022-03-31 12:32:54 Insists on a symbol. I may just not know what I'm doing, though. 2022-03-31 12:33:17 So if I didn't happen to have a label where I wanted the breakpoint, I was just sol. 2022-03-31 12:34:07 Just because you add nice fancy symbol handling doesn't mean you should throw out the "basics." 2022-03-31 12:34:41 It also seemed unwilling to single step through something unless it "believed" it was a code routine. 2022-03-31 12:34:53 I think it should just do what I tell it to do, and it's wrong it's on me. 2022-03-31 12:36:35 "if" it's wrong 2022-03-31 12:37:33 Anyway, I think I got a little insight from it while trying to debug that signal handler the other day. 2022-03-31 12:37:58 That was mostly a pain because the documentation out there is really scant. 2022-03-31 12:38:21 What I wanted to do required messing with a very machine dependent data structure, and it just doesn't seem "talked about" much. Not in detail, at least. 2022-03-31 12:38:37 I guess it makes sense to me why that would be the case - most folks are trying to avoid non-portable stuff. 2022-03-31 12:39:06 But I needed to modify the saved user processor state, so that when the os returned it would go somewhere other than where it came from. 2022-03-31 12:40:07 So this morning I saw a few things online that alluded to the possibility of mmapping the /dev/fb0 frame buffer, and then directly modifying the screen by working that memory buffer. 2022-03-31 12:40:24 I'm old fashioned - that's how I feel like a graphics interface SHOULD work. 2022-03-31 12:46:44 What are the W/Intrinsic_function s of graphics hardware? An obvious question? Straightforward solution? 2022-03-31 12:52:43 KipIngram: break on an address with `break *0x1234`, iirc 2022-03-31 12:54:40 Ok, I didn't know about the * 2022-03-31 12:54:51 Thanks. 2022-03-31 12:55:21 KipIngram, that gdb option is "layout regs" 2022-03-31 12:55:43 also try "si" instead of "s" for step 2022-03-31 12:56:08 if you want to see the individual instruction sof a macro instead of executing the whole line which may contain many instructions 2022-03-31 12:56:36 and "disp/i $pc" shows a disassembly of the next instruction to be executed as you see in my example 2022-03-31 12:57:13 you can save all those in a text file and pass the filename to gdb as an argument if you like 2022-03-31 12:58:53 another thing i didnt quite get working is to always set a breakpoint on label "breakpoint" and use macro trickery to define it somewhere harmless if it doesnt exist but to not define it if it already exists 2022-03-31 13:16:36 Oh, that sounds useful. 2022-03-31 21:50:15 You know, it occurred to me today that now that I have the compiler skipping ansi sequences, I could use that mechanism for other purposes. In particular, for core words (which will rarely, if ever, move once the system is mature), I could use an otherwise unused ansi sequence to insert the result of searching for a word *into the source stream*. 2022-03-31 21:50:59 Then the next time I loaded it, I could immediately go to that spot, confirm the word is there, and if it is, compile that. If something has moved, I'd know that and would do a search (and would update the stored data item in the source). 2022-03-31 21:51:30 This feels a good bit like some of the stuff Chuck did in later years, when he got those insanely high compilation speeds. 2022-03-31 21:51:43 It would eliminate a LOT of searching. 2022-03-31 21:52:01 And the core words are the ones that are at the far end of the linked lists and take the longest to find. 2022-03-31 21:52:22 So the payoff comes exactly where you'd like to have it. 2022-03-31 21:52:37 The cost is expanded source size. 2022-03-31 21:56:28 I couldn't store the address values in source in binary, though - those ANSI sequences are *letter terminated*. So I'd need to store the addresses as decimal values. 2022-03-31 21:56:51 It would just be an offset from header base, though. 2022-03-31 21:57:43 So I'd need an escape to start it off, the value, and some unused letter to terminate it. 2022-03-31 21:58:09 WORD would find it, strip it out, and would store the payload value in a variable for use by FIND. 2022-03-31 22:00:21 You'd want to be able to force full search sometimes though - you might have tinkered with the search path with the deliberate intent of using a different word that bore the same name. 2022-03-31 22:00:40 Though hopefully I won't be re-using core word names very much. 2022-03-31 22:18:34 Oh, and this mechanism is entirely optional. If a source word has no address attached to it, then we search - no other choice. 2022-03-31 22:19:23 Also, if I decided to restrict ansi sequences of any kind to word boundaries, the any ansi sequence could actually replace one of the spaces around the word - I'd render a space on screen, but not store one on disk. 2022-03-31 22:21:54 have you thought about a binary search for dictionary words? 2022-03-31 22:25:04 just curious. ive wondered about doing that 2022-03-31 22:31:55 Some, and other methods too. There's a thing called a Pamela tree that's awfully fast. 2022-03-31 22:32:07 But it's pretty space inefficient. 2022-03-31 22:32:44 I haven't figured out a good way to implement vocabularies with binary search though, other than having each vocabulary be it's own separate list. 2022-03-31 22:33:25 I like this idea. I'll think about it more - but if you held a gun on me and made me start building it I'd apply it to the Forth vocabularly only. 2022-03-31 22:34:04 I imagine once I have vocabularies in play I'll be dealing with code that doesn't necessarily get loaded consistently to the same place every time. 2022-03-31 22:47:03 ya seems like primitives and user words would be two separate linked lists 2022-03-31 22:55:07 Could be. I usually don't - the vocabularies is my only way out fo that linked list. 2022-03-31 22:55:13 That first primary one, I mean. 2022-03-31 22:56:22 Having two lists would draw a distinction that I'm not sure is "real." 2022-03-31 22:59:29 I was thinking more so that you need to update the links when you add a new word 2022-03-31 23:00:02 so it makes sense to keep the primitives separate though no reason to assume they arent in ram too unless it's embedded 2022-03-31 23:58:11 https://portal.mozz.us/gemini/gem.librehacker.com/gemlog/tech/20220331-0.gmi?inline=1