<tpbsd>
heh, my Forth powered STM32F103C8-DIAGNOSTICS.bin has been downloaded 211 times now
<tabemann>
odd
<tabemann>
I just recompiled everything, and reloaded everything, and no problem
<tpbsd>
same
<tpbsd>
except this problem at the end
<tpbsd>
Ill add hardware handshaking as soon as I can get a list of your error messages
<tabemann>
there is no list of error messages :P
<tpbsd>
because then I use a parser to beep my terminal bell on errors
<tpbsd>
i upload so fast I cant read the screen
<tabemann>
there is a point in the code where it sends nak
<tabemann>
you could make it so it sends BEL as well
<tabemann>
this is in the kernel assembly, btw
<tpbsd>
all forths really need a Bell on error
<tpbsd>
Id be utterly lost without mine
<tpbsd>
it only takes one error to screw up a complex app in unkowable ways
<tpbsd>
id recommend adding a macro that rings the bell and perhaps lights a LED on the board
<tpbsd>
on a error
<tpbsd>
that way you can add that macro to every error message
<tabemann>
back
<tabemann>
I added a bell to every exception and abort
<tabemann>
I also think I fixed the problem you were getting with end-compress-flash
<tpbsd>
ready to try ?
<tpbsd>
ahh i see it is
<tpbsd>
brb
<tabemann>
unfortunately I don't hear the BELs, even though the terminal I am using supposedly supports audio for them
<tpbsd>
tabemann, all ok
<tpbsd>
hmm
<tpbsd>
i do get a nice short pip, it's absolutely vital for me, but I do it by parsing the errors
<tpbsd>
Mecrisp-Stellaris has no way to handle error messages
<tpbsd>
i used to pactch the Mecrisp-Stellaris source but in the end it's way easier to do it withing screen as a sub program
<tabemann>
the main thing for me is that error messages are essentially an open class
<tabemann>
anyone can create an error message
<tpbsd>
any programmer ...
<tabemann>
all an error message is is an xt passed into ?raise which displays a message when executed (if the exception is never caught, or is continually re-raised)
<tpbsd>
oh
<tpbsd>
sounds much simpler
<tabemann>
I never liked the way ANS handles exceptions
iyzsong has joined #forth
<tabemann>
I do have to credit rdrop-exit for this idea
<tpbsd>
i dont care about ans
<tpbsd>
this is Forth
<tpbsd>
yeah, he is a Forth guu
<tpbsd>
guru
<tabemann>
the genious of ?raise is that because it only raises if passed a non-zero value, one can pair it with try (ANS "catch") so that if try returns a non-zero value, you can do cleanup, then re-raise with ?raise, whereas if try returns zero (a non-exception), ?raise will do nothing
<tpbsd>
ill have to ponder that statement for a while
<tpbsd>
is try like an assert ?
<tabemann>
nah
<tabemann>
try is like a typical try-catch block
<tpbsd>
if you can, I recommend an 'assert' Word
<tpbsd>
it's just for hardware
<tabemann>
that's what rdrop-exit calles "averts"
<tabemann>
I'll call it "assert" though just because that's better-known
<tpbsd>
one problem cortex-m user run into that can take days to solve with unfamilar peripherals is verifying that a config has been written as intended
<tpbsd>
sometimes a single bit may refuse to be written as it's 'protected' by another bit or sequence
<tpbsd>
and sometimes the sequence required may not be in the doc youre reading
<tpbsd>
so it's very handy to be able to write them verify in a easy way with an Assert word
<tabemann>
added ASSERT
<tpbsd>
oh wow thats fast
<tabemann>
also ASSERT works both in interpretation mode and compilation mode even though it reads a token off the input
<tabemann>
wait asecond
<tpbsd>
no problemo
<tabemann>
back
<tabemann>
fixed
<tpbsd>
cool
<tabemann>
I still don't get why basic.fs by itself takes up a whopping 13K of flash
<tpbsd>
do you have a dissasembler to look for the reasons ?
<tabemann>
I find disassembling the compiled forth code with gdb to be painful
<tabemann>
and I don't know how to dump all of flash and disassemble it, if I even had a disassembler
<tpbsd>
my program to do that in in the latest 3 month old Mecrisp-Stellaris tarball
<tabemann>
aha cutter turned out to actually be useful
<tpbsd>
radare2 is
<tabemann>
I used st-flash to dump the flash then fed the binary into cutter
<tpbsd>
emailed to you
<tpbsd>
ah yes, thats the other way :)
<tpbsd>
the *much* faster way
<tabemann>
I don't see how this code, with inlining and everything, is any much worse than my hand-coded assembly
reepca has quit [Remote host closed the connection]
reepca has joined #forth
<tpbsd>
there is one answer but you wont like it ;-)
<tabemann>
what is it?
<tpbsd>
oh cool i accidentally uploaded a *.sh file and had a ton of beeps from my bell
<tpbsd>
perhaps your assembly needs more refinement ?
<tpbsd>
take the usual Forth "min" ?
<tpbsd>
people on redit suggested the following for it:
<tabemann>
what I mean is that basic.fs comes out at about the same size as the entire kernel
<tabemann>
but the kernel does so much more than basic.fs
<tpbsd>
your Forth words are probably 2-3x the equivalent in assembly
<tabemann>
but when I look at the asm for basic.fs it looks similar to my own hand-coded asm for the kernel
<tpbsd>
in terms of size
<tpbsd>
damn I cant read all the redit comments anymore
<tabemann>
back
<tabemann>
okay, this must be inefficient
<tabemann>
here's the code for MIN:
<tabemann>
wait, why won't Cutter let me copy?
<tpbsd>
yeh, it's the widget bs I guess
rdrop-exit has joined #forth
<tabemann>
0x0000827c push {lr}
<tabemann>
0x0000827e str r6, [r7, -0x4]!
<tabemann>
0x00008286 ldr r6, [r7], 4
<tabemann>
0x00008284 movs r0, r6
<tabemann>
0x00008282 ldr r6, [r7, 4]
<tabemann>
0x0000828a subs r6, r6, r0
<tabemann>
0x0000828c str r6, [r7, -0x4]!
<tabemann>
0x00008290 subs r7, 4
<tabemann>
0x00008292 str r6, [r7]
<tabemann>
0x00008294 movs r6, 0
<tabemann>
0x00008296 bl fcn.000013d2
<tabemann>
0x0000829a movs r0, r6
<tabemann>
0x0000829c ldr r6, [r7], 4
<tabemann>
0x000082a0 ands r6, r0
<tabemann>
0x000082a2 movs r0, r6
<tabemann>
0x000082a4 ldr r6, [r7], 4
<tabemann>
0x000082a8 adds r6, r6, r0
<tabemann>
0x000082aa pop {pc}
<tabemann>
hey rdrop-exit
<tpbsd>
ok, now compare it to this
<tpbsd>
see min
<tpbsd>
000016E4: CF01 ldmia r7 { r0 }
<tpbsd>
000016E6: 42B0 cmp r0 r6
<tpbsd>
000016E8: DC00 bgt 000016EC
<tpbsd>
000016EA: 0006 lsls r6 r0 #0
<tpbsd>
000016EC: 4770 bx lr
<tpbsd>
Bytes: 10 ok.
<rdrop-exit>
hi tabemann
<tpbsd>
hey Zen Forth Guru!
<rdrop-exit>
hi Forth Master Technician (tm)!
<rdrop-exit>
c[]
<tpbsd>
tabemann, thats a M3 Mecrisp-Stellaris 'min'
<tabemann>
that horrific mess of code ressponds to just: : min ( n1 n2 -- n3 ) over - dup 0 < and + ;
<rdrop-exit>
0< is usually a word
<tpbsd>
: min2 ( n1 n2 -- n3 ) over - dup 0 < and + ; ok.
<tpbsd>
20000398: CF08 ldmia r7 { r3 }
<tpbsd>
2000039C: F847
<tpbsd>
2000039A: 1AF6 subs r6 r6 r3
<tpbsd>
see min2
<tpbsd>
2000039E: 3D04 subs r5 #4
<rdrop-exit>
(as opposed to 0 < )
<tpbsd>
200003A0: 2E00 cmp r6 #0
<tpbsd>
200003A2: DA02 bge 200003AA
<tpbsd>
200003A4: 2300 movs r3 #0
<tpbsd>
200003A6: 43DB mvns r3 r3
<tpbsd>
200003A8: E000 b 200003AC
<tpbsd>
200003AA: 2300 movs r3 #0
<tpbsd>
200003AC: 401E ands r6 r3
<tpbsd>
200003AE: CF08 ldmia r7 { r3 }
<tpbsd>
200003B0: 199E adds r6 r3 r6
<tpbsd>
200003B2: 4770 bx lr
<tpbsd>
Bytes: 28 ok.
<rdrop-exit>
the branchless version is over - dup 0< and +
<rdrop-exit>
presumably inlined
<tpbsd>
so 28 to 36 bytes for the Forth compiled version and 10 for matthias hand written assy version
<rdrop-exit>
the point of the over - dup 0< and + version is to avoid branches
<rdrop-exit>
whether branchless code pays off depends on the platform
<rdrop-exit>
Chuck is a fan of branchless code
<rdrop-exit>
of course if you don't inline it, then there will still be the call
<tpbsd>
tabemann, so a 2.8 to 3.6 times smaller min with matthias hand asembled 'min' ...
<rdrop-exit>
his hand assembled code is not really comparable since it branches
<tabemann>
the problem is I'm not seeing how to write branchless 0< type conditionals in thumb
<tabemann>
wait
<tabemann>
there is IT
<rdrop-exit>
0< is equivalent to an arithmetic right shift by one less than your cell width
<rdrop-exit>
(assuming 2's complement)
<rdrop-exit>
i.e. your filling the cell with the sign bit
<rdrop-exit>
if your sign bit is 0 then you get 0
<rdrop-exit>
if your sign bit is 1 then you get -1
<rdrop-exit>
on a 32-bit system it's equivalent to 31 ARSHIFT
<rdrop-exit>
(don't remember what ANS calls their arithmetic right shift, in my Forths I name it ARSHIFT)
<tabemann>
any similar tricks for 0>
<rdrop-exit>
back
<tabemann>
okay, I think I've got them figured out
<rdrop-exit>
for 0> sign bit has to be 0 while the overall value isn't 0
<tabemann>
the only ones I've got left are 0= and 0<>
<tabemann>
whereas now I have branchless, inlinable words for 0>, 0<, 0>=, and 0<=
<rdrop-exit>
0 =
<rdrop-exit>
0 <>
<rdrop-exit>
of course one can often do better on specific cpus using the flags
<tabemann>
so aside from relying on cpu flags, there isn't a good way to do those
<dave0>
i use the carry bit and subtract-with-carry to get the forth flag (amd64 but hopefully also on arm?)
<dave0>
tabemann: on amd64 it's sbb rax,rax maybe arm has something similar? subc r0,r0,r0 ?
<dave0>
tabemann: 0= is sub rax,1 ; sbb rax,rax 0<> is add rax,-1 ; sbb rax,rax
<tabemann>
thank you!
<dave0>
carry flag is so handy
<rdrop-exit>
here's some super old x86 code
<rdrop-exit>
0= ax 1 # cmp ax ax sbb
<rdrop-exit>
0<> ... ax neg ax ax sbb
<dave0>
aha that's a nice 0<>
<rdrop-exit>
I haven't touched x86 assembly in decades, had to dig through some of my ancient code
<dave0>
i think forth will make a great boot loader
<dave0>
becaue it's so small
<rdrop-exit>
0> ...
<rdrop-exit>
cx cx sub
<rdrop-exit>
ax 0 # cmp
<rdrop-exit>
cl setg
<rdrop-exit>
ax pop
<rdrop-exit>
cx neg
<rdrop-exit>
cx push
<dave0>
for amd64 0> is sub rax,1 ; sub rax,0x7fffffffffffffff ; sbb rax,rax
<dave0>
and 0< is add rax,0x8000000000000000 ; sbb rax,rax
<rdrop-exit>
my last example seems to not use stack caching, very old
<dave0>
0< 0> 0= 0<> all uses the carry flag and is tight
<rdrop-exit>
typical
<rdrop-exit>
the take away is that comparison primitives are always branchless on any cpu
gravicappa has joined #forth
<rdrop-exit>
you could always do like Ting and start off with a very small set of core primitives and optimize the rest once your system is fully functional and tested
<rdrop-exit>
heck even = can start out as xor 0=
<rdrop-exit>
IIRC an eForth port starts out with around 30 primitives
<rdrop-exit>
makes it super quick to port it to a new platform, of course it runs slow as molasses initially
<dave0>
i'm trying that :-)
<rdrop-exit>
cool :)
<dave0>
:-)
<tabemann>
back
<dave0>
some words are just so nice in assembly that i add it that way
<tabemann>
now I've got 0=, 0<>, 0<, 0>, 0<=, and 0>= implemented :D
<dave0>
did you test them :-)
<tabemann>
yes I did
<rdrop-exit>
even when you write it in assembly it's always good to have the high level equivalent in a comment or other block/file
<tabemann>
I wish Thumb had predication
<tabemann>
well... IT might count as predication
<tabemann>
(IT being a weird instruction whose name stands for if-then
<tabemann>
okay, I need to hit the sack
<tabemann>
g'night guys
<dave0>
byes tabemann
<rdrop-exit>
good night
<rdrop-exit>
lunch is served, catch you all later
rdrop-exit has quit [Quit: Lost terminal]
<dave0>
oops he left too quick
MrMobius has joined #forth
dddddd has quit [Ping timeout: 256 seconds]
<tpbsd>
<dave0> i think forth will make a great boot loader
<tpbsd>
dave0, you know Forth has been used as a bootloader for decades with FreeBSD ?
<tpbsd>
dave0, sadly, the next version of FreeBSD will have LUA instead
ecraven has quit [Quit: bye]
ecraven has joined #forth
WickedShell has quit [Remote host closed the connection]
rdrop-exit has joined #forth
jsoft has quit [Ping timeout: 265 seconds]
mtsd has joined #forth
<tpbsd>
tabemann, re assert ( f "name" -- ) can you give me an example please ?
<tpbsd>
rdrop-exit, what do you thing tabemann's assert stack picture indicates ?
rdrop-exit has quit [Ping timeout: 240 seconds]
rdrop-exit has joined #forth
<rdrop-exit>
tp, not sure
<tpbsd>
"f" is supposed to be a flag
<tpbsd>
so I read
<rdrop-exit>
yes, but he may be mixing the compile-time and execution time stack pictures into one
<tpbsd>
i get this
<tpbsd>
1 "fail" assert unable to parse: "fail"
<rdrop-exit>
my averts takes an exception name at compile-time, and takes an arbitrary cell at execution time
<tpbsd>
assuming that "name" is the assert fail name ?
<rdrop-exit>
for example:
<tpbsd>
this is his comment "\ Assert that a value is true, otherwise raise a specified exception
<rdrop-exit>
but that's how I do it, other forths do it differently
<tpbsd>
sure
<rdrop-exit>
my excetion numbers are just the XTs of the corresponding fallback exception handler
<rdrop-exit>
this is different from how ANS does exceptions, they're way is more complicated
<tpbsd>
these would be software exceptions I assume
<tpbsd>
Im only familiar with hardware exceptions
<rdrop-exit>
yes, Forth exceptions, although nothing prevents you in having a hardware exception trigger a forth exception
<tpbsd>
except that many hardware exceptions will freeze the chip
<rdrop-exit>
well you can only percolate a hardware exception to a Forth exception if there's a way to hook the hardware exception
<tpbsd>
yeah
<tpbsd>
makes sense
<tpbsd>
and if the cpu isnt in halt mode because of the hardware exception
<tpbsd>
they dont like the PC running wild it seems
<rdrop-exit>
that can be dealt with in a tethered Forth via JTAG
<tpbsd>
naturally!
<rdrop-exit>
giving you access to the debug controller/subsystem of the chip from your host Forth's command line
<tpbsd>
yeah, it's a much better dev system for sure
<tpbsd>
Id love one for cortex-m
<tpbsd>
maybe tabemann might get inspired to make one sometime
<rdrop-exit>
Maybe the guy who made your Forth will make one eventually
<tpbsd>
at age 66 I doubt I'll live long enuf to try yours ;-)
<tpbsd>
no, Ive asked him. He hates cortex-m and thumb1
<tpbsd>
basically his forst Forth was for the MSP430 and he 'ported' it to cortex-m
<rdrop-exit>
I don't usually distribute my Forths, they're always very customized to my idiosyncracies
<tpbsd>
ahh
<tpbsd>
I understand, Im the only person using my Forth dev system tho a few are using my svd2forth system
<tpbsd>
211 have downloaded that diagnostic binary I made (in forth) tho theyre all windows arduino users
<rdrop-exit>
cool
<tpbsd>
but only as it has a simple menu
<tpbsd>
i did write a blinky for it and thats been dl about 11 times as it has to be uploaded to the chip in their terminal
<tpbsd>
so we had this massive problem with Chinese fake chips, I wrote the bootable binary diagnostic that interrogates the chip, someone else decapped all the variants and took pics so now everyone pretty much understands what they are dealing with
<tpbsd>
not bad for a few hobbysists
<rdrop-exit>
I read your web page on that, pretty cool
<tpbsd>
some of the Chinese 'compatibles' arent, and there is no tech sheet anywhere for them
<tpbsd>
I should include the latest decapped pics
<tpbsd>
the chips are all different, so not a copy, only 'compatible' which is how they dont get sued I guess ?
<rdrop-exit>
I haven't been programming during my quarantine, catching up on other things
<tpbsd>
pulling hair out ?
<tpbsd>
screaming ?
<tpbsd>
running around in circles ?
<tpbsd>
going batshit crazy ?
<tpbsd>
so how do you get food in your quarantine ?
<rdrop-exit>
Fixing organizing stuff in the condo, spending quality time with my wife, reading, watching videos, video conferencing with my kids
<rdrop-exit>
We stocked up a couple weeks before the lockdown
<tpbsd>
the Internet has sure helped with quarantines
<tpbsd>
can you venture out to buy food ?
<rdrop-exit>
yes with a special form you have to fill out, but I've no need to, well stocked up
<tpbsd>
what do you then do with the special form ?
<rdrop-exit>
you give it to the police if they ask what you're up to
<tpbsd>
ahh
<rdrop-exit>
there are 9 shopping centers within walking distance if ever I need to do a run
<rdrop-exit>
my wife has fresh fruits and veggies delivered from the province every week
<tpbsd>
thats a bit like our 'vehicle check'. if a vehicle is unlicensed you can drive it on the road to the nearest vehicle check business, but you must write a letter to the police explaining that and put in your pocked in case pulled over
<rdrop-exit>
my biggest worry is eventually running out of espresso beans and cigarettes
<tpbsd>
so it's fairly well organised ? What about the peseants in the slum areas ?
<tpbsd>
i guess it's every man for himself out there ?
<rdrop-exit>
it varies, most people stay at home, unless they have a logistics or health related job
<tpbsd>
sounds like here
<rdrop-exit>
lots are running deliveries
<tpbsd>
thayre saying here that Australia will be locked down until September
dys has quit [Ping timeout: 258 seconds]
<rdrop-exit>
before the quarantine I started working on a new user interface for my pc forth, go tired of dealing with terminal emulators
<rdrop-exit>
basign it on the x11 protocol
<rdrop-exit>
* basing
<rdrop-exit>
4 windows, 1 for the outer interpreter, 3 others for block viewing and editing
<tpbsd>
is color involved ? ;-)
<rdrop-exit>
for the moment, not much the outer-interpreter window will have a different color scheme from the others
<tpbsd>
sounds good
<tpbsd>
I've done what I can as far as my programming abilities can take me and Im fappy with my 'semi tethered' Forth ;-)
<tpbsd>
-f+h
<rdrop-exit>
I made that custom raster font I talked about
<rdrop-exit>
all ASCII glyphs, and single charcter cell hex pairs
<rdrop-exit>
The only character in block that shows up as a blank on the screen is the ASCII space character
<tpbsd>
hows it look ? all 70's retro ? ;-)
<rdrop-exit>
pretty much 70s, the font is large 16x16
<rdrop-exit>
pixels per character
<rdrop-exit>
that way I can fit two hex charaters in the same space as a single ASCII character
<rdrop-exit>
by making each nibble digit 8x16
<tpbsd>
which is a great idea
<rdrop-exit>
I plan on having quasi-mode that will display the a window completly in hex while you hold it down
<rdrop-exit>
* a quasi-mode
<tpbsd>
very handy
<rdrop-exit>
let go and your back to ASCII (except for non-glyph characters which are always shown in the hex font)
<tpbsd>
hmm, youve got me wondering if VIM has a similar facility now
<rdrop-exit>
The font looks ok, I don't do any anti-aliasing though which gives it that retro look
<rdrop-exit>
Here's the layout of the letter A
<rdrop-exit>
................
<rdrop-exit>
......****......
<rdrop-exit>
...***....***...
<rdrop-exit>
....***..***....
<rdrop-exit>
.....******.....
<rdrop-exit>
..***......***..
<rdrop-exit>
..***......***..
<rdrop-exit>
..************..
<rdrop-exit>
..***......***..
<rdrop-exit>
..***......***..
<rdrop-exit>
..***......***..
<rdrop-exit>
..***......***..
<rdrop-exit>
................
<rdrop-exit>
................
<tpbsd>
what res is the monitor you view it on ?
<rdrop-exit>
while this is the layout of a hex 00 occupying the same 16x16
rdrop-exit has quit [Quit: Lost terminal]
<tpbsd>
a "10" would be more relevant
rdrop-exit has joined #forth
<rdrop-exit>
got kicked of irc
Zarutian_HTC has quit [Remote host closed the connection]
<tpbsd>
hahah, flooding ?
<rdrop-exit>
..*****.*****...
<rdrop-exit>
..*...*.*...*...
<rdrop-exit>
..*...*.*...*...
<rdrop-exit>
..*...*.*...*...
<rdrop-exit>
..*...*.*...*...
dys has joined #forth
<rdrop-exit>
..*...*.*...*...
<rdrop-exit>
..*...*.*...*...
<rdrop-exit>
..*...*.*...*...
<rdrop-exit>
..*...*.*...*...
<rdrop-exit>
..*...*.*...*...
<rdrop-exit>
..*****.*****...
<tpbsd>
great idea, it doesnt alter the line lengths
<rdrop-exit>
two hex digits occupy the same space as a single display character
<rdrop-exit>
I've been wanting to do something like this for a while, now that I'm experimenting with a x11 port seemed a good time
<tpbsd>
well you have a few months to work on it now when youre not patrolling the rooftop etc
<rdrop-exit>
But my main reason it to have both key press and key release events, that's the deficiency of terminals that bothers me the most
<rdrop-exit>
It'll mean a complete rewrite of my UI and block editor to take advantage of it
<tpbsd>
for sure
<rdrop-exit>
I want to convert my block editor's incremental search to a quasi-mode like on the Canon Cat