mark4 changed the topic of #forth to: Forth Programming | do drop >in | logged by clog at http://bit.ly/91toWN backup at http://forthworks.com/forth/irc-logs/ | If you have two (or more) stacks and speak RPN then you're welcome here! | https://github.com/mark4th
Zarutian_HTC has quit [Read error: Connection reset by peer]
Zarutian_HTC1 has joined #forth
Zarutian_HTC1 is now known as Zarutian_HTC
dave0 has joined #forth
<tabemann> hey guys
<mark4> hi
* tabemann should probably get onto implementing support for the flexible memory controller on the STM32F746
<tabemann> now that I've got Quad SPI flash and block support working
<mark4> cool!
<mark4> what is quad spi?
<tabemann> it's a protocol for communicating with external devices, but in this case it's being used to control flash memory
<mark4> :)
<tabemann> the Quad SPI interface on the STM32F746 is specifically designed for it, as it has a mode for mapping flash memory to the addressing space
<tabemann> the block interface turns the Quad SPI interface into a key-value map where the values are 1K blocks
<tabemann> with support for rewriting mappings
<mark4> i wrote a spi interface for a flash device on my last contract, that was pic32, if you ever get a chance to code pic32 run screamin for mamma
<tabemann> (it's not a traditional Forth block interface because it does not assume a contiguous array; the keys can be anything other than $FFFFFFFF)
<mark4> :)
f-a has quit [Ping timeout: 245 seconds]
<tabemann> I've heard the PIC32 is basically MIPS with all its warts, such as raising exceptions on overflow
<tabemann> why the designers of MIPS ever thought that was a good idea, I have no clue
<mark4> it is mips
<mark4> yea thats my biggest critisism of mips
<mark4> they did fix one design flaw
f-a has joined #forth
<tabemann> what was it?
<mark4> im trying to get the info so i state it right :)
<mark4> its what "M" "I" "P" "S" stood for originally
<mark4> a HUGE design flaw and they backtracked on it later
<tabemann> millions of instructions per second?
<tabemann> (I know it didn't officially stand for that)
Zarutian_HTC has quit [Read error: Connection reset by peer]
Zarutian_HTC has joined #forth
<mark4> yea wikipedia has it right at the top
<mark4> microprocessor without interlocked pipeline stages
<mark4> STUPID!
<mark4> lol
<tabemann> btw, what about that made it such a design flaw?
<mark4> the pipeline stage is basiclaly what Ford invented for his production line
<mark4> person 1 does a little bit.
<mark4> then person 2 does a little bit
<mark4> then person 3 does a litter bit
<mark4> that means each time one operation completes one car is built
<mark4> not 2858295 people all working on one car
<mark4> becase as person 1 is working on the second car. person 2 is working on the first in parallel
<mark4> thats what an instruction pipeline gives you as you are fetching one opcode, a different one is completing its execution
<mark4> no pipeline?
<mark4> stupid design
<MrMobius> i thought the error on overflow thing was weird but isnt that only an issue if it overflows 32 bits? doesnt seem like that would happen too often
<mark4> thats also a horrendous design flaw
<MrMobius> unless youre working with 64 bit ints or something
<mark4> this FORCES youo to test if an upcoming operation will cause an overflow or not
<mark4> DUMB
<mark4> it raises an exception on overflow.
<tabemann> what you can do is automatically resolve such instructions an exception handler
<mark4> it does not raise a PSW flag like a sane uC would
dave0 has quit [Quit: dave's not here]
<tabemann> which is stupid because it'd kill performance
<MrMobius> "innovation"
<tabemann> but at least would keep the application from crashing
<mark4> you literally have to do math before you do your math just to ensure that the math you are about to do will not cause an overflow
<MrMobius> only if you are working with 32 bit values though right?
<mark4> onlhy if its a 32 bit core
<mark4> im not familiar with 64 bit mips cores
<tabemann> I wonder if bitshifting to the left can cause exceptions on MIPS
<mark4> lol
<mark4> i assume bit shifts are considered unsigned
<mark4> but if they have a carry flag why dont they have an overflow flag
<mark4> idiotic
<MrMobius> is it something where you set up your own exception hanlding or does the c compiler do it?
<mark4> not sure
<tabemann> it would be smart for the standard library to include an exception handler to handle the cases out of the box
neto_ has quit [Quit: leaving]
<MrMobius> what the heck
<MrMobius> actually should have pasted this https://godbolt.org/z/zqaaPY
<MrMobius> line 10 is checking for overflow
<MrMobius> seems manageable if you can shut off the exception
<MrMobius> seems it only raises the exception for signed numbers
<tabemann> the thing, though, is that for two's complement integers, there is no difference between unsigned and signed addition, subtraction, and multiplication
<MrMobius> so then maybe you can avoid the exception by only using the unsigned instructions
<MrMobius> which is what gcc is outputting for (signed) long long int
<tabemann> the thing is typically for integers there are no separate unsigned and signed integer addition, subtraction, and multiplication instructions
<tabemann> there aren't for ARM Cortex-M with 32-bit values (even though there are such for the "DSP" Cortex-M4 instructions)
<MrMobius> maybe thats why theyre separate on pic32 so you can get around the exception stuff if you dont need it
<tabemann> yeah
f-a has quit [Quit: leaving]
boru` has joined #forth
boru has quit [Disconnected by services]
boru` is now known as boru
_whitelogger has joined #forth
jedb has quit [Ping timeout: 264 seconds]
dave0 has joined #forth
gravicappa has joined #forth
sts-q has quit [Ping timeout: 256 seconds]
joe9 has quit [Quit: joe9]
sts-q has joined #forth
joe9 has joined #forth
hosewiejacke has joined #forth
proteus-guy has joined #forth
jedb has joined #forth
f-a has joined #forth
dave0 has quit [Quit: dave's not here]
mirrorbird has joined #forth
mirrorbird has quit [Quit: Leaving]
mirrorbird has joined #forth
andrei-n has joined #forth
f-a has quit [Ping timeout: 256 seconds]
f-a has joined #forth
<f-a> is there a way to use do … loop outside a colon definition?
<f-a> I am writing a simple script and would like to write something 100 0 do ." ciao" loop in my .fs file
<neuro_sys> f-a: I don't think there is, but just define a word, and execute it?
<f-a> neuro_sys: well, not to pollute the dictionary
gravicappa has quit [Ping timeout: 276 seconds]
f-a has quit [Quit: leaving]
f-a has joined #forth
<inode> f-a: one way would be to create a marker, define an anonymous word including your loop, execute it, and finally call the marker to cleanup
<f-a> seems too much hassle
<f-a> thanks for explaining
<inode> ie. MARKER WIPE :NONAME 100 0 do ." ciao" loop ; EXECUTE WIPE
<inode> HERE before and HERE after shouldn't change then
<inode> but you could also abstract it into an introducer and terminator word pair to do the marking/wiping and anonymous word definition/exec for you
<neuro_sys> Would it be too much overhead/hassle to "forget" the word right after execution? After all compile-only words need to be compiled one way or another, right?
<neuro_sys> I like marker solution, it's basically two lines, one at the beginning, and one at the end of the script.
<f-a> true, cannot do that without compiling
<f-a> I am not overly fussy, I am just trying to understand forth better
<inode> you could probably think of better names than [] and ][ though :)
<neuro_sys> I'm also trying to learn, I think one major important aspect Forth is the compilation, and interpretation states changes. I haven't yet fully grasped it in and out, I guess one better implement Forth to fully understand it
hosewiejacke has quit [Ping timeout: 245 seconds]
<neuro_sys> One alternative would be to use :NONAME to enter compilation state, end it with ;, and EXECUTE
<neuro_sys> :NONAME 10 0 DO I . LOOP ; EXECUTE
<neuro_sys> Ah I see that's what inode suggested, nevermind :)
<neuro_sys> Now I'm curious what would the dictionary entry look like when :NONAME is used.
f-a has quit [Ping timeout: 246 seconds]
f-a has joined #forth
hosewiejacke has joined #forth
tech_exorcist has joined #forth
<andrei-n> Hello. Is there an exercise book to learn to write forth code the correct way? Usually books include very few examples, not enough to learn the language... Thanks.
<f-a> starting forth has some exercises
<f-a> not that many
<andrei-n> I have the main books, but I'd like to write a big project, but in order to do this I want to know how to code in an idiomatic way...
<f-a> well, I guess *reading* code would be useful too
<andrei-n> f-a, What for example?
<f-a> I will let others reply, since I am not sure what the canonical Good Codebases™ are in Forth
m2rrorbird has joined #forth
mirrorbird has quit [Remote host closed the connection]
hosewiejacke has quit [Ping timeout: 245 seconds]
hosewiejacke has joined #forth
Zarutian_HTC has quit [Read error: Connection reset by peer]
Zarutian_HTC has joined #forth
hosewiejacke has quit [Remote host closed the connection]
hosewiejacke2 has joined #forth
<andrei-n> what do you think about gforth?
hosewiejacke2 has quit [Remote host closed the connection]
hosewiejacke2 has joined #forth
<neuro_sys> andrei-n: I think gforth is great for learning. May I ask what kind of project are you thinking?
<neuro_sys> I've found the following useful in learning Forth so far in a brief time: skimming the fundamental books (I've a got list, can share), solving programming challenges (better to learn the language first with this), and only after that solving real problems.
<f-a> ↑
<neuro_sys> One major challenge is to learn "the Forth way", which requires you to forget everything you now about modern languages, they just get in the way.
<neuro_sys> Although I don't think it's wrong to write Forth in any other way you like, but it defeats the purpose IMO.
<neuro_sys> I've made that mistake when I wrote Forth as if it's C, which works exactly the same, but without type checking.
<andrei-n> neuro_sys, Well, it's more a family of projects. The first would be a clone of ED.CMD from CCP/M-86 (it's a text editor), but later I would like to make it a bit like EMACS with forth as its internal language.
<neuro_sys> I reaped the benefits of REPL driven development though.
<neuro_sys> I've recently come across an editor project with Forth, I wonder if I can find it.
<andrei-n> Is the forth code in gforth good?
<neuro_sys> I haven't checked that, but I've found gforth tends to be "modern" as it supports a few goodies that is not vanilla.
<neuro_sys> E.g. locals and :noname words IIRC, both of which I don't use to enjoy the old way.
<andrei-n> At least the introduction of named variables seems to be a good idea instead of solving stack puzzles all the time. I'm not sure if everyone agrees.
<neuro_sys> Another alternative is to use globals and shadowing via Dictionary
<neuro_sys> It's not the evil kind of globals, since you can encapsulate them with vocabularies.
<f-a> andrei-n: I am not saying they are bad, but R is a good friend
<neuro_sys> When I used locals all over, my code ended up being C, but worse.
<neuro_sys> As in, code that looks like C, but without any benefits of type checking.
<neuro_sys> I've found the gist of Forth is to utilize Dictionary as much as possible, and factor out as much as possible.
<neuro_sys> And use globals
<andrei-n> Also I don't really like the idea of using the return stack for storing values, so I'd rather use names.
<f-a> I do not use them as, say I want to write something for an obscure controller etc.
<f-a> not every forth has them
<f-a> but yeah what neuro_sys said
<f-a> thinking forth by leo brodie (a superb book) said that too: factor out as much as you can
<andrei-n> Yeah, I think he preferred many smaller functions to larger stacks.
<neuro_sys> That helps with reducing stack juggling obviously
<proteusguy> Always keep your stack shallow. And factor factor factor. Then factor again. Return stack is your friend. Locals not so much.
<neuro_sys> Ideally one line per word (or words with loop bodies 2 or 3)
<neuro_sys> That allows the stack to be no deeper than 3
hosewiejacke2 has quit [Quit: Leaving]
<neuro_sys> But I've found that some state to be passed between different points across the call hierarchy, then I use globals
<neuro_sys> Typical example could be the file handle
<proteusguy> If you're coming from a C background consider the dictionary as your heap. Don't be afraid to use it adhoc.
<neuro_sys> True. That was my first mistake. I used ALLOCATE/FREE for memory management. It turns out Dictionary and marker is all you need for storage.
<neuro_sys> You can reserve arbitrary space in Dictionary any time with ALLOT and store address with HERE (again, in the dictionary).
<neuro_sys> Or rather get the address with HERE, and store in however you like (, ! TO etc)
elioat has joined #forth
andrei-n has quit [Read error: Connection reset by peer]
andrei-n has joined #forth
<andrei-n> So you usually write your own memory manager or not?
<mark4> i did
<andrei-n> But why not use the os functions?
<mark4> in my case they would be slower because im not linking to any external libraries at all
<mark4> every call to mmap would be a transition from user to kernel back to user
<mark4> my memory manager removes the kernel transitons
<mark4> which is what malloc does for you too
<mark4> malloc is a wrapper for the mmap system call
<andrei-n> So did you use the Fibonacci or similar algorithm?
<mark4> it pre-allocates memory and does not return it to the os
<mark4> no
<mark4> well im not sure what fibinacci would do for you
<andrei-n> Actually the forth dictionary reminds me of how the memory is managed in CP/M 2.2. You just have linear space until the end of RAM and hope that it will be enough. For simple programs you don't even need to release anything.
<mark4> i do sort buffers according to size but not based on fibs
<veltas> f-a: I might be being stupid but I think you could have a loop at interpreter, if a word sets >IN to loop back and it's all on one line
<veltas> i.e. have a word that conditionally sets >IN to 0, and then your loop is from start of line to that word
<f-a> worth a try
<veltas> mark4: I got a segfault in x4 leaving it idling in the background all day and then coming back to it
<veltas> mark4: What's your >IN equivalent?
f-a has quit [Quit: leaving]
lispmacs has joined #forth
<mark4> did you change the size of the window?
<mark4> sig winch is not really being handled right
<mark4> i have >in :)
<mark4> tib, >in #out #line all the usual defs
Zarutian_HTC has quit [Ping timeout: 260 seconds]
<veltas> mark4: Yeah probably I did change size of window
<veltas> How did I know it was related to the terminal code :P
<veltas> Oh I see your forth is case sensitive and only wants lowecase, I prefer writing FORTH not forth
<veltas> mark4: How do I set >in?
m2rrorbird has quit [Remote host closed the connection]
<mark4> in my forth >in is not a variable, its a var which ans calls a value
<mark4> 5 !> >in changes >in
<mark4> ! store > to !> store to
Zarutian_HTC has joined #forth
<mark4> you can also use IS like ' foo is bar is the same as ' foo !> bar
<mark4> >in is defined in parse.s
<mark4> and those parseing words are from laxen and perrys f83
Zarutian_HTC1 has joined #forth
Zarutian_HTC has quit [Read error: Connection reset by peer]
andrei-n has quit [Ping timeout: 256 seconds]
andrei-n has joined #forth
<mark4> emerge kdbg with all 2856926523 T bytes of KDE libs that needs
<mark4> JUST so i can fucking try ANOTHER debugger to see if it actually has a useable interface which nothing else so far has
f-a has joined #forth
mirrorbird has joined #forth
shmorgle has quit [Quit: [TalkSoup] via NEXTSPACE]
shmorgle has joined #forth
mirrorbird has quit [Ping timeout: 265 seconds]
<joe9> mark4, switch to 9front. smaller sizes...
gravicappa has joined #forth
<mark4> ?
<mark4> one of the problems i keep having is postage stamp sized windows with fonts ... .. <-- that big lol
mirrorbird has joined #forth
Zarutian_HTC has joined #forth
Zarutian_HTC1 has quit [Read error: Connection reset by peer]
<mark4> veltas: btw, to see that segfault happen lanuch x4, change the size of the window then press x or some other letter
<mark4> it will segfault
<mark4> but if you hit enter it wont
<veltas> I am getting other random segfaults
<mark4> i dont get segfaults at all randomly
<mark4> maybe i should install your linux in a vm and check there
<mark4> suggest for now switching from x64 to x4 because i know x64 is not as stable
<mark4> but i dont get random segfaults like that
<veltas> Using x4
<mark4> !
<mark4> ok that is weird
<veltas> On my work laptop I just had it in background with x4
<veltas> In case I decided to forth it up
<veltas> Every time I switched to window even without resizing if I had left it for a bit it would crash
<mark4> im going to do that
<mark4> was it just sitting at the OK prompt?
<veltas> Yes
<veltas> dog food your forth
<veltas> Don't you use it every day? :P
<mark4> you cant do >in ! in x4
<veltas> I want to start using my ZX Spectrum Forth at work as a desk calculator
<mark4> >in returns the contents of the >in variable
<veltas> Yeah I understand
<mark4> so you if >in is 5 you are storing at address 5 :)
<veltas> I would have to do 0 !> >IN right?
<boru> Pft, Real Programmers™ build their own RPN desk calculator running their own Forth.
<veltas> That's not the segfault I'm talking about, I did figure out >IN was a 'var'
<mark4> oh i see what thats doing :)
<mark4> x4 has var, const, variable and constant
<f-a> thanks veltas !
<veltas> mark4: f-a asked if you can loop in the interpreter
<mark4> const is a state smart immediate word that compiles the value as a literal in compile mode
<veltas> And I said yeah probably if you keep it on one line :P
<mark4> you can use rep
<mark4> : blah ." blah " ;
<mark4> 10 rep blah
<mark4> but you cant use begin/for etc
<veltas> f-a: This works too https://pastebin.com/raw/DqK6iEm8
<veltas> Not that you'd want to do that
<f-a> mhhh I wonder what [do] [loop] do
<veltas> >IN manipulation for control flow is kind of elegant
<veltas> Although you should expect it to be slow, interpreting is slower than running compiled code generally
<veltas> No harm for short loops though
mark4 has quit [Quit: Leaving]
mark4 has joined #forth
gravicappa has quit [Ping timeout: 260 seconds]
andrei-n has quit [Quit: Leaving]
mark4 has quit [Remote host closed the connection]
f-a has quit [Read error: Connection reset by peer]
f-a has joined #forth
mark4 has joined #forth
mark4 has quit [Client Quit]
lispmacs[work] has joined #forth
f-a has quit [Quit: leaving]
mark4_ has joined #forth
mark4_ has quit [Quit: Leaving]
mark4 has joined #forth
elioat has quit [Quit: elioat]
dddddd has quit [Ping timeout: 256 seconds]
dddddd has joined #forth
neto_ has joined #forth
xek has quit [Ping timeout: 264 seconds]
mirrorbird has quit [Ping timeout: 276 seconds]
mirrorbird has joined #forth
mirrorbird has quit [Ping timeout: 245 seconds]
<mark4> had a really silly bug in my code lol. when im updating the display theres an optimization you can do with terminal escape sequences
<mark4> get the attribs of the firs characer, output the escqpe sequence to set those attribs then write every single character that has those attribs, bouncing the cursor all over the map in the procss.
<mark4> then get the attribs for the next char and do the same
<mark4> also, when doing the update instead of outputting each escape sequence immediately
<mark4> buffer them all and write everything with one single user/kernel transition
<mark4> well i kinda screwed that up lol. escape seqeunces were being cached till the end but characters themselves were being written instantly lol
<mark4> /facepalm :)
<neto_> what is this cli display for mark4 ?
<mark4> its going to be a library like ncurse but insted of being 500 gigs in size its going to be a few K in size :)
<mark4> you can look at it if you have linux
<mark4> github.com/mark4th/uCurses
<mark4> make then do ./u and space pauses the dance and any other key quits it :)
<neto_> oh that's nice, i'm working on a forth based text editor, def will look into using uCurses instead of nCurses
<mark4> it has movable overlapping windows and im about to add lorem ipsum scrolling up the first window and chinese text scrolling up the second
<mark4> this is all in C tho but x4/x64 have the forth version of it but its kind of in a broken state there,
<mark4> i will be fixing that tho
<mark4> right now my plasma desktop is slightly confused lol
<mark4> when i try launching anything it cant find my wayland desktop
<mark4> ern
<mark4> im not running wayland lol
tech_exorcist has quit [Remote host closed the connection]
mark4 has quit [Remote host closed the connection]