00:00:00 --- log: started forth/18.10.07 01:34:29 --- quit: jedb (Ping timeout: 268 seconds) 01:34:45 --- join: jedb (~jedb@199.66.90.113) joined #forth 01:56:47 --- quit: dave9 (Quit: dave's not here) 02:04:16 --- quit: ashirase (Ping timeout: 246 seconds) 02:07:28 --- join: ashirase (~ashirase@modemcable098.166-22-96.mc.videotron.ca) joined #forth 02:29:44 --- join: ncv (~neceve@2a02:c7d:c5c9:a900:1ec6:932f:1b02:d27e) joined #forth 02:29:44 --- quit: ncv (Changing host) 02:29:44 --- join: ncv (~neceve@unaffiliated/neceve) joined #forth 02:35:06 --- quit: wa5qjh (Remote host closed the connection) 02:44:00 --- join: rixard (~rixard@h-112-233.A444.priv.bahnhof.se) joined #forth 03:34:12 --- quit: rixard (Quit: rixard) 04:10:05 --- join: dddddd (~dddddd@unaffiliated/dddddd) joined #forth 04:28:41 Zarutian: you tested that sixel.fs out? 04:29:00 apparently suckless' st supports the format but fuck me if I can figure out how to use it. 04:46:45 --- quit: pierpal (Ping timeout: 252 seconds) 05:17:58 --- join: pierpal (~pierpal@host168-226-dynamic.104-80-r.retail.telecomitalia.it) joined #forth 05:27:35 --- quit: pierpal (Ping timeout: 268 seconds) 05:31:54 --- quit: ashirase (Ping timeout: 268 seconds) 05:33:13 --- join: ashirase (~ashirase@modemcable098.166-22-96.mc.videotron.ca) joined #forth 05:42:47 WilhelmVonWeiner: no, I havent tested it 05:44:18 --- join: siraben (~user@unaffiliated/siraben) joined #forth 06:01:45 --- quit: ashirase (Ping timeout: 252 seconds) 06:02:19 --- join: ashirase (~ashirase@modemcable098.166-22-96.mc.videotron.ca) joined #forth 06:21:36 --- quit: ncv (Remote host closed the connection) 06:21:57 --- join: ncv (~neceve@unaffiliated/neceve) joined #forth 06:23:00 pointfree: Just tried the 16 bit random number generator linked, maybe it's not random enough? 06:23:03 https://i.imgur.com/Su8Dcx1.png 06:23:20 There's a visualization, this is a bit-for-bit memory representation 06:24:23 Here's the source in case there's a mistake 06:24:24 https://pastebin.com/raw/0YCvNYNt 06:24:42 My << performs a single left shift, >> performs a right shift. 06:25:45 So when I run RANDS it runs and writes the result of RAND over a region in memory then displays it, then repeats until ENTER is presed. 06:25:47 pressed* 06:26:45 Oh wait, there's a mistake. 06:27:00 RANDF is using the word RAND which is different from RANDOM16, oops. 06:27:07 I'll fix it and give another screenshot. 06:36:08 All the features of suckless tools are broken out into patches that don't apply. 06:37:59 --- quit: siraben (Remote host closed the connection) 06:56:49 --- join: siraben (~user@unaffiliated/siraben) joined #forth 06:57:55 pointfree: It works now: https://imgur.com/a/Tu3etYk :) 06:57:55 Thanks for that xorshift, wouldn't have guessed. 06:59:59 Out of curiosity, is there a cryptographically secure RNG for 16 bit or is it not possible? 07:05:02 siraben: it is possible, you could port https://gist.github.com/jzakiya/4544459 to work on 16 bit cells 07:05:20 and use the truncated output from that. 07:05:39 Oh wow, this is a lot. 07:06:03 What Forth implementation does it rely on? 07:06:48 Definitely overkill for my target. 07:07:10 --- join: kumool (~kumool@adsl-64-237-233-169.prtc.net) joined #forth 07:10:27 siraben, what do you mean cryptographically secure RNG? wouldn't that exclude all PRNGs? 07:10:44 siraben: it says it uses ANS Forth 07:11:37 MrMobius: Something like https://en.wikipedia.org/wiki/Blum_Blum_Shub 07:12:14 Secure in the sense that the output is unpredictable, but I suppose that's a hard test anyway. 07:12:46 ^that it passes a test suite like RandCrush 07:13:04 I mean BigCrush 07:13:33 "A naive C implementation of a xorshift+ generator that passes all tests from the BigCrush suite (with an order of magnitude fewer failures than Mersenne Twister or WELL) typically takes fewer than 10 clock cycles on x86 to generate a random number, thanks to instruction pipelining." 07:13:46 From the wikipedia page 07:17:50 hmmm, I guess if you are supplying a seed like that algorithm you could use that 07:19:32 but it looks like xorshift would not be secure 07:19:44 Which one is? 07:19:47 --- join: pierpal (~pierpal@host168-226-dynamic.104-80-r.retail.telecomitalia.it) joined #forth 07:20:11 Blum Blum Shub? 07:20:40 I mean I dont know about Blum, Blum, Shub but when you look at RNGs, anything that generates random numbers only mathematically is inherently predictable and shouldnt be used for cryptography 07:20:41 It only works if M is a product to large primes p and q in x_n+1 = x^2 mod M 07:20:54 Up to a certain point, yeah. 07:21:10 But there's probably some true randomness somewhere in the calculator 07:21:13 you need to find a way to mix entropy into it 07:21:26 Reading system RAM, perhaps? 07:21:28 maybe. how would you measure it though? 07:21:40 people have tried that and as I remember it's not a good way 07:21:56 generating cryptographically secure randomness is a huge topic 07:22:05 Testing randomness would just be reading from a source repeatedly and plotting it into the screen. 07:22:16 some newer processors include a mechanism that generates truly random bits 07:22:48 not exactly. what if the sequence of numbers repeats itself after the first 1 million bits? you wouldnt notice that pattern on a graph 07:22:50 I thought the 8-bit register R would be an RNG according to a source, but after plotting it, it was really predicatable. 07:22:57 Right. 07:23:06 So, xorshift is enough. 07:23:26 its enough to make your games unpredictable 07:23:35 but not enough for encryption 07:23:46 not that anyone needs real encryption on a ti 84 :) 07:24:08 I would just xor every pixel of a picture with the next pixel when I wanted to hide things 07:24:17 As KipIngram said, "99% of the code we write isn't performance critical", so "99% of the code we write isn't cryptographically critical" 07:24:41 Right, not that anyone needs to decode their PGP signed messages on a calculator, right? 07:25:46 if I were you I would implement the simplest RNG possible to save program space 07:26:00 Right. 07:26:04 since it wont matter anyway for encryption 07:26:44 Entropy could be provided through reading key presses :) 07:27:02 Reading the port raw and asking the user to spam for a bit. 07:27:03 yep. a little bit. linux does that and I think it got added to windows eventually 07:27:05 Yeah - gather entropy all the time, as you use the thing. 07:27:09 Keep it in an available pool. 07:27:43 heh, actually asking the user to spam is something they tried and that is an especially bad way to generate entropy. it turns out humans are not good at generating random numbers either :P 07:28:04 With whitening and what not, but yeah, human are bad at RNG. 07:28:58 As a trick you can ask two people to generate a list of 30 coin flips and one of them does it for real, the other in their head, you can usually tell which one is human made by checking whether it alternates a lot: THTHHHTHTHT 07:30:36 Another source of randomness is the timer. I might switch to reading from that and performing some bit shifts if it's faster and smaller than full xorshift 08:40:01 that might work but you could get into trouble if the program is generating random numbers in a loop depending on the timer frequency 08:52:34 siraben: Does your application require truly random numbers, or would pseudo-random do? 09:05:01 KipIngram: psuedo-random would do. 09:05:28 Actually, I don't even know what the application would need. It's the language layer I'm working on. 09:05:36 When I want pseudo-random I usually think about using a linear feedback shift register. 09:05:51 So I'll just leave the bitshifts and so on, the user can implement their own RNGs/ 09:06:31 I think I know how I can make Forth useful now that I have most of the elements implemented. 09:06:45 With appropriately chosen tap points, an LFSR will give you 2^N - 1 values before repeating. 09:06:53 Never gives you 0, but gives you everything else. 09:07:24 Some sort of information retrieval system, like a small wiki with keyword searching and so on. Or maybe a dictionary, who knows? 09:07:31 Ah I see. That's interesting. 09:08:36 How does the randomness play into it? 09:08:52 Just part of the language for use, I suppose. 09:09:14 I implemented the xorshift to test variables, bitshift, reading and writing memory and plotting. 09:09:18 Hits all those points. 09:09:18 Oh, ok. So it doesn't actually get used in managing your storage? 09:09:25 No. 09:09:34 Ok - that was what made me curious. :-) 09:09:46 Having a Prolog-like language on the calculator would be nice. 09:10:16 Or just some special words in Forth to add backtracking. 09:10:44 Ah, ok. Prolog is interesting. 09:10:48 Would allow for solving all sorts of normal pencil-and-paper brute force problems 09:11:11 Do you know that puzzle about the five guys, living in the five houses, with the five pets, five favorite drinks, tobaccos, and so on? 09:11:32 Yeah I did that a couple of years ago. 09:11:38 Something like that, was it five? 09:11:47 I solved that in Prolog a year or so ago. 09:11:47 I thought it was something like 12, not sure exactly. 09:11:49 The one I saw was. 09:11:58 But obviously it could be extended. 09:11:58 Five, yeah I think so. 09:12:11 I didn't know logic programming back then, but it would be a breeze now. 09:12:14 Prolog did it very nicely - it really was just stating the facts and then asking the question. 09:12:52 The only logic programming language I know is http://minikanren.org/ , but that's enough to solve most problems. 09:13:01 Prolog is on my list of languages to learn next. 09:13:18 Different philosophy to it and all that, which would be fun. 09:15:47 Using logic programming to solve problems sometimes feels like using a very large hammer. Sometimes it's just fun not to use it, for instance, Sudoku puzzles. 09:16:11 Ah, a Sudoku solver in Forth would be nice as well. 09:19:57 How do you people usually do testing of primitives in Forth? Is there a way to easily write tests within Forth? 09:21:50 Hm. There's https://forth-standard.org/standard/testsuite for those interested. 09:22:02 Tests are written like this: T{ 1 2 3 SWAP -> 1 3 2 }T 09:24:28 siraben, can you jump jump into the calculator ROM for RNG stuff? I would try to map as much to the existing firmware as I could if you are worried about space 09:25:54 I have an FRAND word which puts a random floating point number 0-1 on the floating point stack. That's a ROM call. 09:26:07 neato 09:26:16 AFAIK there isn't any other, or if such calls exists they might be slow. 09:26:53 Space is starting to become a problem, but I'll find ways to improve it. 09:27:13 oh I see 09:27:16 Such as storing programs in flash memory then loading them to RAM when needed, and unloading them afterwards. 09:27:39 so you would want to create a 16 bit RNG that is faster than multiplying 2^16 by the float from the ROm call? 09:27:59 pointfree: lol about the suckless patches thing. My dwm config was hell at one point. 09:28:05 ROM calls perform a lot of other stuff under the hood. 09:28:18 Depending on the call, but they're hard to reason about in terms of speed. 09:28:33 right 09:28:43 I don't use strcopy, cpHLDE, etc. I just write assembly version of them. 09:28:59 Also they're pretty underdocumented. 09:29:01 but after the call you could measure the speed of multiplying the float to get a 16 bit number I think 09:29:20 Right. That would involve implementing a profiler. 09:29:22 vs skipping the rom call and generating a 16 bit random number yourself 09:29:49 I wonder how useful it is to optimize assembly code given the overhead of NEXT anyway. 09:30:45 does the emulator let you set a breakpoint and county cycles to the next breakpoint? 09:30:57 siraben, dont mean to interrogate you. this is just really interesting :) 09:31:30 Oh don't worry about asking me, I'm more than happy to share information on this target :) 09:31:38 I'm not using an emulator! 09:31:48 It's real hardware all the way. 09:31:55 i.e. the actual calculator itself. 09:32:00 oh 09:32:07 isnt that a lot slower? 09:32:16 Compared to what? 09:32:37 dunno how it works on the z80 calcs but for the TI 89 the C compiler would automatically send the program to an emulator and run it 09:33:00 is there anything like that? 09:33:21 Here's my workflow. I edit my forth.asm file then run the assembler, then drag the file with my mouse to the calculator icon in the TI-connect app and hit return. 09:33:29 It's not the most glamorous, but it works. 09:33:53 that works 09:33:58 I wish I could automate it more, I guess. 09:34:24 there might be a way to run the assembler and then load the file into an emu in one script 09:34:33 if those few seconds you save are worht it to you :P 09:34:41 But that's the easy part by far. The hardest parts was writing the assembly file in the first place. 09:35:12 Probably spent several hours debugging vs. a couple of seconds in total dragging 09:35:22 heh 09:35:38 I dont think I would write assembly nowadays without a simulator 09:35:52 you can go cycle by cycle and see what stupid mistake you made 09:36:27 Here's another way I do things. Suppose I have a Forth file called test.fs and I want to generate a binary to flash to the calculator, I run this: hexdump -e '".db "16/1 "$%02x, " "\n"' test.fs | sed 's/$ ,/$00,/g' | sed 's/.$//' > test.asm && ./spasm test.asm test.8xp || rm test.asm 09:36:58 what does that do? 09:37:10 The almighty UNIX hexdump command generates a hexdump of a file, but in the format I want. 09:37:18 i.e. a list of assembly bytes like this: 09:37:27 .db $32, $03, $23 ... 09:37:46 wont the assembler do that if you generate a listing? 09:38:14 Ah, a string? It's a big hassle. I have to wrap quotes around each line and escape quotes and so on. 09:38:45 So once that list of bytes are generated it gets written into a file and assembled. 09:39:37 I can load that into the calculator and the OS's "variable allocation table" (which allows for the searching of programs and other data) can find it. 09:39:53 Yeah, I would love to use an emulator if I could. 09:40:14 But not having a debugger teaches you to look at the code 09:40:28 You can do a lot without a debugger. :-) 09:40:44 KipIngram, how do you do your development on your Forth system? 09:40:52 No emulator I presume? 09:41:01 siraben, so you are doing that to look at the source on the calculator? 09:41:01 No, no emulator. 09:41:12 I just write it, run it, and figure out what's wrong with it. 09:41:23 It's a lot easier now that I have so much working, but early on it was kind of tedious. 09:41:35 MrMobius: Yeah, this allows me to extend the system later with an editor. 09:41:53 I often isolated problems by putting EXIT (return to OS) in my word somewhere - if I exited before I got the segfault or whatever, I'd ooch it forward. 09:42:00 Right. I found it got easier as I had more. 09:42:35 Once I had emit I could stick 49 emit in there or something like that, so I could verify I reached a point and continue. 09:42:35 Plus, you can always develop your own error-handling mechanisms. 09:42:39 one advantage of an emulator is you can usually get it to count how many cycles something takes 09:42:47 Then when I had . working it became much easier, because I could inspect the stack and so on. 09:42:56 if you want to find the fastest way 09:43:27 Ah, fortunately there's a ROM call to print the contents of the 16-bit HL register, so I used that as the definition of . for a while until I had a proper one that depended on the current base. 09:43:45 So I'm not exactly starting from scratch, but more so than I ever have. 09:44:05 It is immensely gratifying though, I have to admit. 09:44:45 Then once the interpreter was working I could call QUIT from anywhere in a word, and then MANUALLY inspect the stack. 09:45:48 I just traced through my NEXT routine manually and it takes 47 cycles. 09:46:11 Ah yes. Implementing .S allowed me to fix a lot of bugs. 09:46:26 So, Forth does end up creating a debugger for itself. 09:46:35 SEE is also a good debugger. 09:47:00 117.5 microseconds for a NEXT, not bad. 09:47:01 09:48:39 KipIngram: That test suite I linked above to looks pretty promising. Not only could you bootstrap Forth by changing a couple of primitives but verify that it is correct by running a series of tests. 09:48:59 I've measured mine to be about 1.5 ns. 09:49:14 A clock cycle or NEXT? 09:49:21 NEXT 09:49:27 How did you measure it? 09:49:48 KipIngram, which calculator is that :P 09:49:56 I wrote a loop that did a countdown of the item on top of the stack - I knew how many nexts that is. 09:50:03 Counted down from 10 billion and timed it. 09:50:14 MrMobius: Not a calculator - a Macbook Air. 09:50:29 just kidding :P 09:50:32 So it's actually a bit less than that; I was ascribing the whole time just to the nexts. 09:50:34 :-) 09:50:44 Cool. In 1.5 nanoseconds light travels 44.969 centimeters. 09:50:47 I.e., not considering the actual working parts of the words. 09:50:54 That's crazy fast. 09:51:05 You have barely any overhead then. 09:51:10 I wrote the same thing as best I could in gcc - it was about 3x faster. 09:51:31 My loop was this: 09:51:53 : downcount 1- .0<>me drop ; 09:52:00 What's .0<>me ? 09:52:14 So that has two nexts in it, one in the 1- and one in the .0<>me 09:52:34 1- just has a dec rcx instruction, so not much to it other than its next. 09:52:42 Is .0<>me like the assembly instruction DJNZ in a sense? 09:53:12 Yes, it's basically a jnz, the . at the front says that it doesn't consume its argument. 09:53:24 Ah. That's a good abstraction. 09:53:34 Do you have an assembler in Forth working? 09:53:37 But there's more to it than an assembly instruction, since it has to update the Forth IP one way or the other. 09:53:45 By the way, does macOS allow for the execution of RAM contents? 09:53:53 No, haven't written any assembler words yet. 09:54:00 Yes, it does. 09:54:14 You mean of data sections, right? 09:54:17 It's all in RAM. 09:54:19 Yes. 09:54:21 Ah. 09:54:37 siraben, you cant execute from a hard drive if thats what you mean 09:54:43 It defaults the .data and .bss sections to read/write only, but you can do a system call to make them executable. 09:55:04 The .text section is where the code goes, and it defaults to read/execute, but not write. 09:55:34 The code from the assembly file, I mean. 09:56:14 There's no longer enough space to put the .data section in my program. I'm modifying it to ask the OS to allocate space for another program which just gives it more RAM 09:57:17 It's getting late. Thanks for the conversation, all. 09:57:34 Rest well. 09:58:22 Yeah, no such restrictions like that on the Mac. I did a 1 GB resb in the .bss section, so I have all the RAM I could ever want. 09:58:47 How fancy. 10:00:42 Well, I guess it makes the thing take a GB of my RAM, so it's not exactly "efficient" if I'm trying to do a bunch of other things too. 10:01:14 Maybe MacOS "manages" it somehow so it's not always necessarily "allocated" unless I try to use it. 10:40:27 --- quit: ncv (Remote host closed the connection) 11:49:51 --- quit: pierpal (Read error: Connection reset by peer) 11:50:02 --- join: pierpal (~pierpal@host168-226-dynamic.104-80-r.retail.telecomitalia.it) joined #forth 11:51:07 --- quit: pierpal (Read error: Connection reset by peer) 11:51:43 --- join: pierpal (~pierpal@host168-226-dynamic.104-80-r.retail.telecomitalia.it) joined #forth 12:48:39 --- quit: pierpal (Remote host closed the connection) 13:41:54 --- join: groovy2shoes (~groovy2sh@unaffiliated/groovebot) joined #forth 13:48:42 --- quit: tabemann (Ping timeout: 252 seconds) 14:01:14 --- join: tabemann (~tabemann@71-13-2-250.static.ftbg.wi.charter.com) joined #forth 14:49:25 --- quit: tabemann (Ping timeout: 240 seconds) 15:07:17 --- quit: reepca (Remote host closed the connection) 15:21:52 --- join: wa5qjh (~quassel@175.158.225.207) joined #forth 15:21:52 --- quit: wa5qjh (Changing host) 15:21:52 --- join: wa5qjh (~quassel@freebsd/user/wa5qjh) joined #forth 15:34:37 --- quit: Zarutian (Read error: Connection reset by peer) 15:40:33 --- join: Zarutian (~zarutian@173-133-17-89.fiber.hringdu.is) joined #forth 16:09:21 --- join: tabemann (~tabemann@2602:30a:c0d3:1890:b90b:3bee:a83b:ed44) joined #forth 16:24:41 What's [IF] [ELSE] [THEN] and how does is compare to IF ELSE and THEN? 16:27:04 i think those are immediately executed, even while compiling a word 16:27:09 but i might be misremembering 16:29:22 Ah, so conditional compilation? 16:29:29 kind of 16:29:38 yes 16:29:50 How do I implement it? 16:30:46 like IF but with IMMEDIATE, would be my first approach 16:31:11 or wait 16:31:27 that won't practically work 16:31:30 i don't know 16:31:40 Yeah, there's something special about how it operates. 16:31:52 I'll just make do without it for now and come back later. 16:33:04 jn__: Found something: https://forth-standard.org/standard/tools/BracketIF 16:33:09 And https://forth-standard.org/standard/tools/BracketELSE 16:33:46 Looks reasonably simple. 16:34:10 yep, that description doesn't look scary 16:34:39 I like it that this guide includes the implementation section for a lot of words. 16:52:05 --- quit: siraben (Ping timeout: 268 seconds) 16:59:24 --- quit: wa5qjh (Remote host closed the connection) 17:07:15 --- quit: tabemann (Ping timeout: 252 seconds) 17:33:49 --- join: tabemann (~tabemann@218-83-181-166.mobile.uscc.net) joined #forth 17:56:24 --- join: dave9 (~dave@90.20.215.218.dyn.iprimus.net.au) joined #forth 17:56:43 hi 18:01:42 --- quit: kumool (Ping timeout: 252 seconds) 18:10:08 --- join: reepca (~user@208.89.170.250) joined #forth 18:22:16 --- join: [1]MrMobius (~default@c-73-134-82-217.hsd1.va.comcast.net) joined #forth 18:25:54 --- quit: MrMobius (Ping timeout: 252 seconds) 18:25:54 --- nick: [1]MrMobius -> MrMobius 18:41:15 --- quit: dddddd (Remote host closed the connection) 19:09:44 --- join: kumool (~kumool@adsl-64-237-233-169.prtc.net) joined #forth 19:58:55 --- quit: tabemann (Ping timeout: 272 seconds) 19:59:42 --- join: wa5qjh (~quassel@175.158.225.207) joined #forth 19:59:42 --- quit: wa5qjh (Changing host) 19:59:42 --- join: wa5qjh (~quassel@freebsd/user/wa5qjh) joined #forth 20:29:15 --- join: tabemann (~tabemann@2602:30a:c0d3:1890:b90b:3bee:a83b:ed44) joined #forth 20:58:23 --- quit: kumool (Quit: Leaving) 23:31:37 --- quit: wa5qjh (Remote host closed the connection) 23:59:59 --- log: ended forth/18.10.07