-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IF .. ELSE .. THEN with relative addressing #382
Comments
An example is the improved I2C driver. Here is my first sketch but I'm not sure if that's the best way to package this: \ STM8eForth : control structures with relative addressing TG9541-201124
\ ------------------------------------------------------------------------------
#require >Y
: THEN ( -- ) [COMPILE] [ HERE OVER - 1- SWAP C! [COMPILE] ] ; IMMEDIATE
: >REL ( -- ) HERE 0 C, ; \ like >MARK for rel. branch
: ELSE ( -- ) [COMPILE] [ $20 C, [COMPILE] ] >REL \ JRA rel
SWAP [COMPILE] THEN ; IMMEDIATE
: JREQ ( F:Z -- ) [COMPILE] [ $27 C, [COMPILE] ] >REL ; IMMEDIATE
: IF ( n -- ) COMPILE >Y [COMPILE] JREQ ; IMMEDIATE What worked quite well is requiring #require >REL
: ]B@IF ( -- ) 2* $7201 + , , ] >REL ; \ BTJF a,#bit A |
Hi Thomas
I wish I had a bit more time to look at this. While my own bit bang
routines have proved reliable that might be because I haven't pushed the
clock speed. When I get the need I'll be sure to dig through this but as
always you are well ahead of me. Great job and all the best for the
coming festive season!
Regards
Richard
…On 26/11/2020 2:53 am, Thomas wrote:
An example is the improved I2C driver
<https://gist.github.com/TG9541/5c3405320794d91ef8129734a4bfc880#improving-the-solution>.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#382 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE7PE25ZKYSH63VSYPY44M3SRVHELANCNFSM4UCYYSFA>.
|
Hi Richard, thanks, and greetings your way! To tell the truth this is the first time I actually use an I2C peripheral. Bit-banging I2C is the way of gravity because since, to work with a device only needs to read one datasheet, not two. I'm now moving from an 8K EEPROM to a DS1621 to learn how the I2C API should look like. Obviously there needs to be error handling and a handshake with the application. |
Some applications, e.g. ISR handlers, Flash page write, or STM8L Low-Power-Run Mode require code that doesn't depend on the STM8 eForth core. While coding in assembler or C is possible, it would be great if Forth structures like
IF .. ELSE .. THEN
could be used withJRxx
orBTJx
.The text was updated successfully, but these errors were encountered: