You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
(5) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
|
Feb
(6) |
Mar
(41) |
Apr
(23) |
May
(11) |
Jun
(2) |
Jul
|
Aug
|
Sep
(9) |
Oct
(2) |
Nov
(1) |
Dec
(1) |
| 2008 |
Jan
(6) |
Feb
(1) |
Mar
(23) |
Apr
(18) |
May
(21) |
Jun
(13) |
Jul
(34) |
Aug
(5) |
Sep
(1) |
Oct
(4) |
Nov
|
Dec
(4) |
| 2009 |
Jan
|
Feb
(5) |
Mar
(5) |
Apr
(10) |
May
(1) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(13) |
| 2010 |
Jan
(10) |
Feb
(4) |
Mar
(28) |
Apr
(3) |
May
(38) |
Jun
(22) |
Jul
(92) |
Aug
(154) |
Sep
(218) |
Oct
(45) |
Nov
(20) |
Dec
(1) |
| 2011 |
Jan
(33) |
Feb
(15) |
Mar
(32) |
Apr
(33) |
May
(48) |
Jun
(35) |
Jul
(7) |
Aug
|
Sep
(11) |
Oct
(5) |
Nov
|
Dec
(7) |
| 2012 |
Jan
(56) |
Feb
(11) |
Mar
(6) |
Apr
|
May
(128) |
Jun
(59) |
Jul
(21) |
Aug
(16) |
Sep
(24) |
Oct
(39) |
Nov
(12) |
Dec
(12) |
| 2013 |
Jan
(14) |
Feb
(61) |
Mar
(97) |
Apr
(46) |
May
(13) |
Jun
(23) |
Jul
(12) |
Aug
(25) |
Sep
(9) |
Oct
(81) |
Nov
(73) |
Dec
(45) |
| 2014 |
Jan
(36) |
Feb
(57) |
Mar
(20) |
Apr
(41) |
May
(43) |
Jun
(11) |
Jul
(14) |
Aug
(32) |
Sep
(9) |
Oct
(27) |
Nov
(21) |
Dec
(6) |
| 2015 |
Jan
(14) |
Feb
(23) |
Mar
(1) |
Apr
(19) |
May
(40) |
Jun
(11) |
Jul
(1) |
Aug
(2) |
Sep
(14) |
Oct
(10) |
Nov
(9) |
Dec
(13) |
| 2016 |
Jan
(4) |
Feb
(3) |
Mar
(7) |
Apr
|
May
(4) |
Jun
(13) |
Jul
(8) |
Aug
(3) |
Sep
(4) |
Oct
(1) |
Nov
|
Dec
|
| 2017 |
Jan
(6) |
Feb
(1) |
Mar
(1) |
Apr
(7) |
May
(10) |
Jun
(5) |
Jul
(7) |
Aug
(9) |
Sep
|
Oct
(1) |
Nov
(5) |
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
(3) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(54) |
Nov
(47) |
Dec
(53) |
| 2019 |
Jan
(23) |
Feb
(24) |
Mar
(19) |
Apr
(15) |
May
(5) |
Jun
(34) |
Jul
(9) |
Aug
(9) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
(7) |
Apr
(7) |
May
(5) |
Jun
(15) |
Jul
(22) |
Aug
(28) |
Sep
(13) |
Oct
(9) |
Nov
(17) |
Dec
(13) |
| 2021 |
Jan
(5) |
Feb
(1) |
Mar
(1) |
Apr
(9) |
May
(21) |
Jun
(9) |
Jul
|
Aug
(6) |
Sep
(16) |
Oct
|
Nov
(1) |
Dec
(6) |
| 2022 |
Jan
|
Feb
|
Mar
|
Apr
(7) |
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(11) |
Sep
(21) |
Oct
(5) |
Nov
(1) |
Dec
(1) |
| 2024 |
Jan
(1) |
Feb
(4) |
Mar
|
Apr
(7) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2025 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(7) |
Sep
(9) |
Oct
|
Nov
(4) |
Dec
|
|
From: Leon M. <leo...@gm...> - 2010-09-13 02:21:14
|
Interesting -- I'll look in to it. I've been thinking about rewriting f/ to use integer arithmetic -- hopefully that'll make it faster. I might do the rewrite and see if that solves the problem. -Leon On Sat, Sep 11, 2010 at 4:03 PM, pito <pi...@vo...> wrote: > Leon, > we've observed an interesting anomaly: when first time the float > library is uploaded to a fresh amforth install, the f/ is causing a > crash (e.g. when uploading floatconstants immediately after the > float lib - the first f/ causes a freeze). When the float library is > unmarked and uploaded again, it works afterwards. It has been > confirmed by other user as well. P. > > > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > Amforth-devel mailing list > Amf...@li... > https://lists.sourceforge.net/lists/listinfo/amforth-devel > |
|
From: pito <pi...@vo...> - 2010-09-11 21:03:57
|
Leon, we've observed an interesting anomaly: when first time the float library is uploaded to a fresh amforth install, the f/ is causing a crash (e.g. when uploading floatconstants immediately after the float lib - the first f/ causes a freeze). When the float library is unmarked and uploaded again, it works afterwards. It has been confirmed by other user as well. P. |
|
From: Matthias T. <mt...@we...> - 2010-09-11 18:23:11
|
Marcin, > on stack (use it or restore it to zero at exit). > > (Matthias: I noticed that techdoc says R22:R23 > are TOS and R24:R25 are W, in my case on ATmega328P > it's the other way around) Fixed, thank you. Matthias |
|
From: pito <pi...@vo...> - 2010-09-11 16:12:35
|
Michael, thanks! I will rather start step by step, so no forth words called from within assembler now! As I can see the tosl and tosh and register setup are changing. I hope they are same for any processor type within a release. P. > worked with amforth3.6 > still good with 4.1? > Michael |
|
From: pito <pi...@vo...> - 2010-09-11 15:17:44
|
> Please keep in mind that machine stack is not > indefinite (64 bytes only). So if your routine > is pushing something on stack and doing some > calls it can get tight. I've changed that to 256: .set rstackstart = RAMEND ; start address of return stack, grows downward .set stackstart = RAMEND - 256 ; 80 start address of data stack, grows downward > Regarding you other email, regarding "here", "dp" > etc. DP and HERE are stored in EEPROM (in my case > EEPROM So when RAM is needed within fuX word and only there, I have to read HERE and DP and from that point to allocate RAM fro fuX. When leaving fuX, I do not need to write the new pointers to EEPROM, I just leave that as they are (as I do not need RAM anymore.. So the template for fictious word 'fuX' is now (based on my amforth .lst as the Registers are concerned): ; amforth 4.1 ; ..core\words\fuX.asm ; Function fuX( a b c -- m l k ) ; R( ? -- ? ) ; calculates a special function fuX ; it uses ALL registers except Y ; it calls subroutines placed within the word fuX ; does not use Y - points the data stack VE_FUX: .dw $ff03 ;? .db "fuX",0 .dw VE_HEAD .set VE_HEAD = VE_FUX XT_FUX: .dw PFA_FUX PFA_FUX: push R0 push R1 ; R2 you may use, restore to 0 ; R3 you may use, restore to 0 push R4 push R5 push R6 push R7 push R8 push R9 push R10 push R11 push R12 push R13 ; R14 you may use, no need to push/pop, = temp4 ; R15 you may use, no need to push/pop, = temp5 ; R16 you may use, no need to push/pop, = temp0 ; R17 you may use, no need to push/pop, = temp1 ; R18 you may use, no need to push/pop, = temp2 ; R19 you may use, no need to push/pop, = temp3 ; R20 you may use, no need to push/pop, = temp6 ; R21 you may use, no need to push/pop, = temp7 push R22 push R23 ; R24 do not push/pop, = tosl ; R25 do not push/pop, = tosh push R26 push R27 ; R28 do not use, = Y ; R29 do not use, = Y ; R30 you may use, no need to push/pop, = Z ; R31 you may use, no need to push/pop, = Z do_something ld R24, Y+ ld R25, Y+ ; takes c from stack do_something ld R24, Y+ ld R25, Y+ ; takes b from stack do_something ld R24, Y+ ld R25, Y+ ; takes a from stack do_something work_with_RAM_indirect_Using_Z work_with_RAM_indirect_Using_X call sub3 do_something jmp label1 do_something label1: do_something jmp label2 ; ijmp rjmp as well do_something call sub3 do_something jmp label3 label2: do_something call sub1 ; rcall icall as well call sub2 do_something label3: do_something call sub2 do_something st -Y, R25 st -Y, R24 ; puts m on stack do_something st -Y, R25 st -Y, R24 ; puts l on stack do_something st -Y, R24 st -Y, R25 ; puts k on stack pop R27 ; RESTORE REGISTERS IN REVERSE ORDER .... pop R4 ldi R3, 0 ldi R2, 0 pop R1 pop R0 jmp label_end ; jmp to the end of the word "fuX" sub1: do_something call sub3 ret sub2: do_something call sub1 ret sub3: do_something work_with_RAM_indirect_Using_Z work_with_RAM_indirect_Using_X ret label_end: jmp_ DO_NEXT ; this is the end of the word "fuX" |
|
From: Marcin C. <sa...@sa...> - 2010-09-11 12:01:27
|
On Sat, 11 Sep 2010, pito wrote: > push R0 ; worst case - store everything > push R1 > push R2 > ..... > push R31 Please be careful NOT to restore r28, r29 (register Y - your data stack pointer) and r24, r25 - top of your stack. > > ld R10, Y+ > ld R11, Y+ ; takes c from stack > > ld R12, Y+ > ld R13, Y+ ; takes b from stack > > ld R14, Y+ > ld R15, Y+ ; takes a from stack This is wrong - TOS is in r26:r25 (tosh:tosl) *NOT* in RAM! > st -Y, R16 > st -Y, R17 ; puts m on stack > > st -Y, R18 > st -Y, R19 ; puts l on stack > > st -Y, R20 > st -Y, R21 ; puts k on stack Same as above - just leave TOS in r26:r25 and don't restore it via pop: > pop R31 ; worst case housekeeping > .... > pop R2 > pop R1 > pop R0 Don't restore tosl, tosh, Y (r24, r25, r28, r29) - since then your stack effects will be void (or just corrupted). No need to save temp0..temp5 (r14, r15, r16, r17, r18, r19, r20, r21). r30 and r31 (zl, zh) are used as a scratchapad register, so no need to save these too. r2 and r3 should be zero, so no need to save that on stack (use it or restore it to zero at exit). (Matthias: I noticed that techdoc says R22:R23 are TOS and R24:R25 are W, in my case on ATmega328P it's the other way around) Please keep in mind that machine stack is not indefinite (64 bytes only). So if your routine is pushing something on stack and doing some calls it can get tight. Regarding you other email, regarding "here", "dp" etc. DP and HERE are stored in EEPROM (in my case EEPROM address $6 and $8, respectively), please see PFA_EFETCH how to read EEPROM from assembly or push them on the data stack before running your asm routing as parameters. --Marcin |
|
From: Matthias T. <mt...@we...> - 2010-09-11 11:52:32
|
Hi, > > > First, from what I understand - Matthias please > > correct me if I am > > wrong - the "code" word creates a new word for you > > but > > it does not switch FORTH into the compilation mode > > (unlike ":" > > or "]"). > > > M? "code" creates the full dictionary header and sets the XT of that newly defined word to its data field. That means, that whenever the XT of that word is called by the inner interpreter, the content of the data field is executed as machine code. Whatever that code may do, the final operation should be a jmp to DO_EXIT. Since the label DO_EXIT is only known at compile time of the initial hex file, the forth word "end-code" does exactly that: writes the machine instruction "jmp DO_EXIT". It is up to the developer to make sure that the forth vm can continue its work. Otherwise anything strange can happen... > > > I don't know - where does assembler use Z? > Lubos is using Z in his assembler source e.g. > code high ( pinmask portadr -- ) > \ dup c@ rot or swap c! \ replaced by assembler > ZL TOSL movw, \ tos->z > R16 Z ld, \ addr c@ R16/17 was used as tosl/tosh in earlier versions, now its slightly different. Probably no-one has noticed that yet. > > I am not sure whether the code is correct in > > assembler.frt - > > it uses "here" to indicated labels in the code, > > where > > it should probably use "dp" (dictionary pointer) - > > due to > > RAM (last position pointed to by "here", advanced > > by "allot") and dictionary > > in flash (managed by "dp", advanced by comma) are > > different thing > > in amforth. > M? see above, sounds like a regression. > > I was > > thinking > > about uploading .hex files or even ready-to-run > > object > Yes this is exactly what I am talking about.. Good luck. You do know that even C has some assumptions about its runtime environment? And portable assembler code is something I've never seen yet. AS a general hint: there are so many existing code samples that work well enough. Please read them first. Most of your questions can be answered by "read the source and do it that way". Matthias |
|
From: pito <pi...@vo...> - 2010-09-11 11:01:41
|
Matthias, Marcin - here is the template for function fuX. Is the construction ok? It will be assembled by normal asm. Pito. ; amforth 4.1 ; ..core\words\fuX.asm ; ( a b c -- m l k ) Function fuX ; R( ? -- ? ) ; calculates a special function fuX ; it uses ALL registers except Y ; it calls subroutines placed within the word fuX ; does not use Y - points the data stack VE_FUX: .dw $ff03 ;? .db "fuX",0 .dw VE_HEAD .set VE_HEAD = VE_FUX XT_FUX: .dw PFA_FUX PFA_FUX: push R0 ; worst case - store everything push R1 push R2 ..... push R31 ld R10, Y+ ld R11, Y+ ; takes c from stack ld R12, Y+ ld R13, Y+ ; takes b from stack ld R14, Y+ ld R15, Y+ ; takes a from stack do_something work_with_RAM_indirect_Using_Z work_with_RAM_indirect_Using_X call sub3 do_something jmp label1 do_something label1: do_something jmp label2 ; ijmp rjmp as well do_something call sub3 do_something jmp label3 label2: do_something call sub1 ; rcall icall as well call sub2 do_something label3: do_something call sub2 st -Y, R16 st -Y, R17 ; puts m on stack st -Y, R18 st -Y, R19 ; puts l on stack st -Y, R20 st -Y, R21 ; puts k on stack pop R31 ; worst case housekeeping .... pop R2 pop R1 pop R0 jmp label_end ; jmp to the end of the word "fuX" sub1: do_something call sub3 ret sub2: do_something call sub1 ret sub3: do_something work_with_RAM_indirect_Using_Z work_with_RAM_indirect_Using_X ret label_end: jmp_ DO_NEXT ; this is the end of the word "fuX" |
|
From: pito <pi...@vo...> - 2010-09-11 07:50:09
|
Marcin, thanks!
> First, I am assuming that "Luboš assembler" is a
> set of words
> from the lib/assembler.frt file in the amforth
> distribution.
> Is this correct?
Yes
> (I don't understand this - what is your "header"
> etc.)
E.g.:
; ( n1 -- n2 ) Arithmetics
; R( -- )
; optimized increment
VE_1PLUS:
.dw $ff02
.db "1+"
.dw VE_HEAD
.set VE_HEAD = VE_1PLUS
XT_1PLUS:
.dw PFA_1PLUS
PFA_1PLUS:
> If you want to return only one cell ("y") you need
> just to set the
> TOS in tosh:tosl register pair. No need to use
> savetos.
tosh:tosl contains the value - you need to execute st -Y, rx to
write it to ram, don'you?
> First, from what I understand - Matthias please
> correct me if I am
> wrong - the "code" word creates a new word for you
> but
> it does not switch FORTH into the compilation mode
> (unlike ":"
> or "]").
>
M?
> I don't know - where does assembler use Z?
Lubos is using Z in his assembler source e.g.
code high ( pinmask portadr -- )
\ dup c@ rot or swap c! \ replaced by assembler
ZL TOSL movw, \ tos->z
R16 Z ld, \ addr c@
loadtos, \ delete portadr
R16 TOSL or, \ or pinmask
Z R16 st, \ c!
loadtos, \ delete pinmask
end-code
> Please feel free to "allot" something and use
> that.
> There is also "pad" available as well.
>From my assembler source, how? Or it shall be done before?
> I am not sure whether the code is correct in
> assembler.frt -
> it uses "here" to indicated labels in the code,
> where
> it should probably use "dp" (dictionary pointer) -
> due to
> RAM (last position pointed to by "here", advanced
> by "allot") and dictionary
> in flash (managed by "dp", advanced by comma) are
> different thing
> in amforth.
M?
> Use "here" and "allot".
>From asm sorce?
> Of course you can use it. It's what "push" and
> "pop" do.
So when calling within an asm source properly I will not destroy
Rstack, it means it will stay as before I executed my asm?
> You do not need "rjmp DO_NEXT" (or most probably
> "jmp DO_NEXT")
> if using "end-code" word ($940c and DO_NEXT
> address will be
> compiled - see "end-code.asm").
I meant normal asm (L.asm=lubos's forth asm asm-normal asm)
> I don't know what kind of portability you mean.
When writing _any_ "words" (e.g. fuX) in asm. Portability means use
ANS forth words only..
> I was
> thinking
> about uploading .hex files or even ready-to-run
> object
Yes this is exactly what I am talking about..
Pito
|
|
From: Matthias T. <mt...@we...> - 2010-09-11 07:47:06
|
Pito, I'll start here, the upper "half" will take more time. But make yourself clear, what do you want to achieve: add an assembly word to the initial hex file or implement it on a running system. The assemblers only look similiar, they are not inter-changeable. > Interrupts: The interrupt support in amforth is weak. It lakes some features one may urgently need. > 1. it is understood you handle intrpts forth's way - the > generic-isr.asm is an interface to forth only, which sets Tflag and > translates vector to forth. What is the worst case latency? 1ms (if the interrupt occures at the beginning of the word 1ms.) I believe, that division is faster, but did not test it yet. Generally speaking: interrupts are handled by the inner interpreter. Any primitive word is atomar wrt to (forth-level) interrupts. > 2. how to work with several interrupts enabled (priority handling in > forth?), e.g. as we register ['] tick_isr TIMER2_OVFAddr int!, what > happens when I register for example 15 interrupts sources that way? The last registered code gets called. A problem arises, if interrupt x has fired and interrupt y comes before the x has been handled. In that case x will be completly unhandled (the curint variable is overwritten). Matthias |
|
From: Marcin C. <sa...@sa...> - 2010-09-10 22:03:57
|
On Fri, 10 Sep 2010, pito wrote:
First, I am assuming that "Luboš assembler" is a set of words
from the lib/assembler.frt file in the amforth distribution.
Is this correct?
> 1. I want to write a new word full in asm called fuX (a b c -- y )
> 2 I want to use an existing "code" written in assembler, it is
> relocable.
> 3. I will take a "template" from a word, I can see the header etc.
(I don't understand this - what is your "header" etc.)
> 4. the input and output is now clear to me, loadtos, savetos
> indirect via Y.
If you want to return only one cell ("y") you need just to set the
TOS in tosh:tosl register pair. No need to use savetos.
> Q: which registers (Rx) can I freely use without ANY limitation in
> my fuX? I can see the register used in .lst of course, however I
> need a proven list which really can be used.
> Q: there are registers named tempx - again - which can be used?
> There is a difference when using those tempx in Lubos' assmbler vs.
> usage in normal asm - Lubos' asm is based on forth words, which may
> use internally some registers, this was what I saw - some registers
> combinations did garbage.
Yes, tempx are left for free use of FORTH words. That's what
Matthias wrote before already.
First, from what I understand - Matthias please correct me if I am
wrong - the "code" word creates a new word for you but
it does not switch FORTH into the compilation mode (unlike ":"
or "]").
So that means that all words (like "ld,", "st,") are executed
immediately and they can produce compiled machine
code entered into the dictionary only in the explicit way
by using "," (comma) word.
Practically means that all FORTH code in the assembler is executed
immediately (think of it as they all were IMMEDIATE words) and
the only thing you are left in your newly defined word is pure
assembler code as defined by you. Luboš code is gone by the time
you are executing a word. So it does not matter whether you
use some registers when using code ... end-code or whether
using direct assembly (like adding .asm file to your amforth).
If you have some problems with "garbage" - please be more specific,
it is possible that the error is somewhere else.
> Q: which registers can we use in Lubos' asm, which in normal asm
> (again - we can see the .lst allocation, but pls confirm.
> Q: Lubos is using Z registers frequently - is it allowed (both in L
> asm or normal asm)? We need some indirect addressing so is Z fully
> free to use?
I don't know - where does assembler use Z? See above - it probably
does not matter at all.
> Q: When using L.asm (Lubos') or normal asm - which regs shall be
> pushed, popped?
If you are only using tosh, tosl, tempX registers - none.
Please be aware that push and pop goes to the machine stack
which is FORTH return stack (therefore they are an equivalent
of >r and r>).
> Q: When RAM space is required in the asm code - can you give us some
> RAM ragion where we may do what we really want?
Please feel free to "allot" something and use that.
There is also "pad" available as well.
> Q: It is understood we cannot use calls inside fuX, only jumps.
> L.asm needs a kind of table for jumps, normal asm does not I guess.
I don't understand this problem. I think you can define labels
using the assembler.frt. (I didn't use them though).
I am not sure whether the code is correct in assembler.frt -
it uses "here" to indicated labels in the code, where
it should probably use "dp" (dictionary pointer) - due to
RAM (last position pointed to by "here", advanced by "allot") and dictionary
in flash (managed by "dp", advanced by comma) are different thing
in amforth.
> Q: shall the interrupts be disabled when in fuX?
I don't think so.
> Q: accessing vars - can we define a specific place in RAM where we
> can place the local asm variables and which will not be interfered
> by forth?
Use "here" and "allot".
> 6. the fuX will read the data from data stack, it will process it
> (about 500 lines of assembler) and at the end it writes results to
> data stack. Q: Can we create such long word? Any restriction on the
> lenght of a word?
No limits on length except size of your flash.
> 8. forth's Return stack - my understanding is we cannot use it for
> any assembler routine, can we? how?
Of course you can use it. It's what "push" and "pop" do. See question
above regarding push/pop.
> 9. so now I have an asm word fuX - with header (copied from other
> words and adjusted accordingly), body (~500lines asm) and it will
> end with "rjmp DO_NEXT". I will include this fuX.asm into dictionary
> and compile together with amforth. This is the basic Idea.
You do not need "rjmp DO_NEXT" (or most probably "jmp DO_NEXT")
if using "end-code" word ($940c and DO_NEXT address will be
compiled - see "end-code.asm").
> I DO UNDERSTAND THIS WAY OF WORKING WITH AMFORTH IS NOT THE
> PREFFERED ONE FROM PRINCIPLE (PORTABILITY), but I still cope with an
> idea to be able to "link" _ANY_ asm code into an amforth word (input
> output via dstack).
I don't know what kind of portability you mean. Forth code is
way more portable between different platforms than assembly code
(with obvious limitations related to the low-level words).
So writing words is assembler is not really the Forth way.
The other thing you might mean is interoperability (not portability)
as in "I want to write some code in C or assembly and attach
it to my forth words". Sure you can. I was thinking
about uploading .hex files or even ready-to-run
object or ELF files that could be executed by the
FORTH word. FORTH does not really limit you in this
unless you need a bootloader-specific code.
> Interrupts:
No answers from me on that this time :-)
--Marcin |
|
From: pito <pi...@vo...> - 2010-09-10 21:12:51
|
Matthias, Marcin, thanks a lot for the infos - I've spent a time to work in order to write my first amforth routine ++_ - based on Lubos sources so I've got the first touch.. Basically my problem is not the assembler of any processor, but what are the limitation for a specific integration in the forth. Imagine following case (an example only): 1. I want to write a new word full in asm called fuX (a b c -- y ) 2 I want to use an existing "code" written in assembler, it is relocable. 3. I will take a "template" from a word, I can see the header etc. 4. the input and output is now clear to me, loadtos, savetos indirect via Y. Q: which registers (Rx) can I freely use without ANY limitation in my fuX? I can see the register used in .lst of course, however I need a proven list which really can be used. Q: there are registers named tempx - again - which can be used? There is a difference when using those tempx in Lubos' assmbler vs. usage in normal asm - Lubos' asm is based on forth words, which may use internally some registers, this was what I saw - some registers combinations did garbage. Q: which registers can we use in Lubos' asm, which in normal asm (again - we can see the .lst allocation, but pls confirm. Q: Lubos is using Z registers frequently - is it allowed (both in L asm or normal asm)? We need some indirect addressing so is Z fully free to use? Q: When using L.asm (Lubos') or normal asm - which regs shall be pushed, popped? Q: When RAM space is required in the asm code - can you give us some RAM ragion where we may do what we really want? Q: It is understood we cannot use calls inside fuX, only jumps. L.asm needs a kind of table for jumps, normal asm does not I guess. Q: shall the interrupts be disabled when in fuX? Q: accessing vars - can we define a specific place in RAM where we can place the local asm variables and which will not be interfered by forth? 6. the fuX will read the data from data stack, it will process it (about 500 lines of assembler) and at the end it writes results to data stack. Q: Can we create such long word? Any restriction on the lenght of a word? 8. forth's Return stack - my understanding is we cannot use it for any assembler routine, can we? how? 9. so now I have an asm word fuX - with header (copied from other words and adjusted accordingly), body (~500lines asm) and it will end with "rjmp DO_NEXT". I will include this fuX.asm into dictionary and compile together with amforth. This is the basic Idea. I DO UNDERSTAND THIS WAY OF WORKING WITH AMFORTH IS NOT THE PREFFERED ONE FROM PRINCIPLE (PORTABILITY), but I still cope with an idea to be able to "link" _ANY_ asm code into an amforth word (input output via dstack). Interrupts: 1. it is understood you handle intrpts forth's way - the generic-isr.asm is an interface to forth only, which sets Tflag and translates vector to forth. What is the worst case latency? 2. how to work with several interrupts enabled (priority handling in forth?), e.g. as we register ['] tick_isr TIMER2_OVFAddr int!, what happens when I register for example 15 interrupts sources that way? Pito. |
|
From: pito <pi...@vo...> - 2010-09-10 18:16:58
|
Matthias, thanks! I've tried to comment indirect access like ( n -- (tos-n) ) and that killed me for a while..P. > nested comments are not allowed. |
|
From: Matthias T. <mt...@we...> - 2010-09-10 18:08:02
|
Pito, > Hi, is this correct behaviour in respect to comment content? P. > > > : abcd1 ( n -- xx ) > .s ; > > > : abcd2 ( n -- (xx) ) <<<< nested comments are not allowed. I just tried your code with gforth (0.7.0) and it produces (other but) similiar strange output. The ( searches for the next ) and continues after that ) with the normal operation. In this case with the second ), which is seen as a number (for whatever reason, it should produce an error "word not found"...) Matthias |
|
From: Matthias T. <mt...@we...> - 2010-09-10 18:04:06
|
Hi 李雪愚, > I've got headache on debug the words on the board. I need a simulator for amforth. Thats sad. I know of no s(usable) imulator for the avr's. The Atmel Development studio has a built-in simulator, but I never managed to get amforth running there. It simply crashes. > Or how to compile the amForth to X86? amforth is not portable to x86 processors. You can find a large number for that target, e.g. gforth. > Where are the forth source of the core? Just download the amforth package from sourceforge and you will get the full sources. Just look at amforth.asm and follow the includes (there are many, but in a structured way). good luck Matthias |
|
From: pito <pi...@vo...> - 2010-09-10 17:50:49
|
adiw xl, 1 DO_NEXT: brts DO_INTERRUPT movw zl, XL ; READ IP readflashcell wl, wh adiw XL, 1 ; INC IP DO_EXECUTE: movw zl, wl readflashcell temp0,temp1 movw zl, temp0 ijmp <<<<<<<<<<<<<<<< HERE CALLS AVRStudio usoft DO_INTERRUPT: ; here we deal with interrupts the forth way lds temp0, intcur ldi zl, LOW(intvec) ldi zh, HIGH > however after few steps the AVR Studio crashed (it > shots down the > simulator) - always on first "ijmp" instruction > (atmega1284p). |
|
From: pito <pi...@vo...> - 2010-09-10 17:42:36
|
Hi, I can imagine the headache, indeed. The experts may answer the simulator Q.. I've put the stuff into AVR Studio 4.18 SP2 (build 700 and 692)and I've tried to run amforth in simulator. IT WORKS, however after few steps the AVR Studio crashed (it shots down the simulator) - always on first "ijmp" instruction (atmega1284p). The other way is to simulate in VMLAB (this supports the smaller atmels only). You cannot compile to x86 as the amforth is written in ATMEGA AVR assembler. P. > hi, all > > I've got headache on debug the words on the board. > I need a simulator for amforth. > Does anyone know how to solve it? Or how to > compile the amForth to X86? Where are the forth > source of the core? > > |
|
From: pito <pi...@vo...> - 2010-09-10 17:06:52
|
Hi, is this correct behaviour in respect to comment content? P. : abcd1 ( n -- xx ) .s ; : abcd2 ( n -- (xx) ) <<<< .s ; > 1234 abcd1 0 12846 1234 ok > > .s ok > 1234 abcd2 0 12844 0 <<<< additional 0 on stack 1 12846 1234 ok > |
|
From: pito <pi...@vo...> - 2010-09-10 16:24:52
|
Hi, better code for stacks hexa vertical. Pito \ Some new .s \ by Pito 2010-09-10 \ v3 WITH TOS, TOR ON RIGHT SIDE \ PRINTED VERTICALLY !!! \ a little bit optimised marker -newdots : u.r ( s n -- ) 0 swap ud.r ; \ comment if installed : nibble ( n -- nth_nibbble ) 1- 2* 2* rshift $f and ; : ns@ ( n -- tos-n ) \ fetches n-th dstack position from tos 1+ 2* sp@ + @ ; \ ONELINE HEXA DSTACK VERTICAL : .svh hex sp@ base @ depth 1- 1- 4 0 do ." [" dup 0 ?do dup 1- i - 2* 3 ns@ + @ 4 j - nibble 1 u.r ." " loop ." <S]" cr loop drop \ drop depth base ! drop \ drop sp@ ; : rdepth rp0 rp@ - 2/ 1- 1- ; \ ONELINE HEXA RSTACK VERTICAL : .rvh hex rp@ 1- base @ rdepth 1- 1- 4 0 do ." [" dup 0 ?do dup 1- i - 2* 3 ns@ + @ 4 j - nibble 1 u.r ." " loop ." <R]" cr loop drop \ drop rdepth base ! drop \ drop rp@ ; : ? .svh .rvh cr ; : rtest ? $ABCD $BCDA ? >r ? >r ? r> ? r> ? drop drop ? ; \ -------------------------- EX: > $1122 $3344 $5566 $7788 $99FF ok > .svh [1 3 5 7 9 <S] [1 3 5 7 9 <S] [2 4 6 8 F <S] [2 4 6 8 F <S] ok > $1122 $3344 $5566 $7788 $99FF ok > .svh [1 3 5 7 9 1 3 5 7 9 <S] [1 3 5 7 9 1 3 5 7 9 <S] [2 4 6 8 F 2 4 6 8 F <S] [2 4 6 8 F 2 4 6 8 F <S] ok > .s 0 3FEB 99FF 1 3FED 7788 2 3FEF 5566 3 3FF1 3344 4 3FF3 1122 5 3FF5 99FF 6 3FF7 7788 7 3FF9 5566 8 3FFB 3344 9 3FFD 1122 ok > .rvh [0 1 <R] [6 E <R] [0 D <R] [3 E <R] ok > rtest [<S] [<S] [<S] [<S] [0 1 1 1 <R] [6 F F E <R] [0 1 0 D <R] [3 6 D E <R] [A B <S] [B C <S] [C D <S] [D A <S] [0 1 1 1 <R] [6 F F E <R] [0 1 0 D <R] [3 B D E <R] [A <S] [B <S] [C <S] [D <S] [0 B 1 1 1 <R] [6 C F F E <R] [0 D 1 0 D <R] [3 A D D E <R] [<S] [<S] [<S] [<S] [0 B A 1 1 1 <R] [6 C B F F E <R] [0 D C 1 0 D <R] [3 A D F D E <R] [A <S] [B <S] [C <S] [D <S] [0 B 1 1 1 <R] [6 C F F E <R] [0 D 2 0 D <R] [3 A 1 D E <R] [A B <S] [B C <S] [C D <S] [D A <S] [0 1 1 1 <R] [6 F F E <R] [0 2 0 D <R] [3 3 D E <R] [<S] [<S] [<S] [<S] [0 1 1 1 <R] [6 F F E <R] [0 2 0 D <R] [3 6 D E <R] ok > |
|
From: 李雪愚 <sno...@gm...> - 2010-09-10 13:02:11
|
hi, all I've got headache on debug the words on the board. I need a simulator for amforth. Does anyone know how to solve it? Or how to compile the amForth to X86? Where are the forth source of the core? Thnks and Best Regards. |
|
From: pito <pi...@vo...> - 2010-09-10 10:19:19
|
Hi, here is the data stack printed Vertically, TOS on rigt side. Currently HEX only, not optimised yet.. Pito \ Some new .s \ by Pito 2010-09-10 \ v3 WITH TOS ON RIGHT SIDE \ PRINTED VERTICALLY !!! \ not optimised yet marker -newdots : u.r ( s n -- ) 0 swap ud.r ; \ comment if installed variable temporary : num4 ( n -- n4th ) \ takes 4th nibble 8 rshift 4 rshift $f and ; \ WHY DOES SHIFT NOT WORK WITH WORD??? : num3 ( n -- n3rd ) \ takes 3rd nibble 8 rshift $f and ; \ WHY DOES SHIFT NOT WORK WITH WORD??? : num2 ( n -- n2nd ) \ takes 2nd nibble 4 rshift $f and ; \ WHY DOES SHIFT NOT WORK WITH WORD??? : num1 ( n -- n1st ) \ takes 1st nibble $f and ; \ WHY DOES SHIFT NOT WORK WITH WORD??? \ ONELINE HEXA STACK VERTICAL : .svh sp@ temporary ! ." [" depth dup 0 ?do dup 1- i - 2* temporary @ + base @ swap hex @ num4 1 u.r ." " base ! loop drop ." <T]" cr sp@ temporary ! ." [" depth dup 0 ?do dup 1- i - 2* temporary @ + base @ swap hex @ num3 1 u.r ." " base ! loop drop ." <O]" cr sp@ temporary ! ." [" depth dup 0 ?do dup 1- i - 2* temporary @ + base @ swap hex @ num2 1 u.r ." " base ! loop drop ." <S]" cr sp@ temporary ! ." [" depth dup 0 ?do dup 1- i - 2* temporary @ + base @ swap hex @ num1 1 u.r ." " base ! loop drop ." <H]" cr ; : stest1 .svh $ABCD .svh 20 0 do dup .svh cr loop 20 0 do drop .svh cr loop drop .svh cr ; ------------------------- ex: > stest1 [<T] [<O] [<S] [<H] [A <T] [B <O] [C <S] [D <H] [A A <T] [B B <O] [C C <S] [D D <H] [A A A <T] [B B B <O] [C C C <S] [D D D <H] [A A A A <T] [B B B B <O] [C C C C <S] [D D D D <H] [A A A A A <T] [B B B B B <O] [C C C C C <S] [D D D D D <H] [A A A A A A <T] [B B B B B B <O] [C C C C C C <S] [D D D D D D <H] [A A A A A A A <T] [B B B B B B B <O] [C C C C C C C <S] [D D D D D D D <H] [A A A A A A A A <T] [B B B B B B B B <O] [C C C C C C C C <S] [D D D D D D D D <H] [A A A A A A A A A <T] [B B B B B B B B B <O] [C C C C C C C C C <S] [D D D D D D D D D <H] [A A A A A A A A A A <T] [B B B B B B B B B B <O] [C C C C C C C C C C <S] [D D D D D D D D D D <H] [A A A A A A A A A A A <T] [B B B B B B B B B B B <O] [C C C C C C C C C C C <S] [D D D D D D D D D D D <H] [A A A A A A A A A A A A <T] [B B B B B B B B B B B B <O] [C C C C C C C C C C C C <S] [D D D D D D D D D D D D <H] [A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D D <H] [A A A A A A A A A A A A A <T] [B B B B B B B B B B B B B <O] [C C C C C C C C C C C C C <S] [D D D D D D D D D D D D D <H] [A A A A A A A A A A A A <T] [B B B B B B B B B B B B <O] [C C C C C C C C C C C C <S] [D D D D D D D D D D D D <H] [A A A A A A A A A A A <T] [B B B B B B B B B B B <O] [C C C C C C C C C C C <S] [D D D D D D D D D D D <H] [A A A A A A A A A A <T] [B B B B B B B B B B <O] [C C C C C C C C C C <S] [D D D D D D D D D D <H] [A A A A A A A A A <T] [B B B B B B B B B <O] [C C C C C C C C C <S] [D D D D D D D D D <H] [A A A A A A A A <T] [B B B B B B B B <O] [C C C C C C C C <S] [D D D D D D D D <H] [A A A A A A A <T] [B B B B B B B <O] [C C C C C C C <S] [D D D D D D D <H] [A A A A A A <T] [B B B B B B <O] [C C C C C C <S] [D D D D D D <H] [A A A A A <T] [B B B B B <O] [C C C C C <S] [D D D D D <H] [A A A A <T] [B B B B <O] [C C C C <S] [D D D D <H] [A A A <T] [B B B <O] [C C C <S] [D D D <H] [A A <T] [B B <O] [C C <S] [D D <H] [A <T] [B <O] [C <S] [D <H] [<T] [<O] [<S] [<H] ok > -12345 $FFE2 2200 0 -1 ok > .svh [C F 0 0 F <T] [F F 8 0 F <O] [C E 9 0 F <S] [7 2 8 0 F <H] ok > Pito |
|
From: pito <pi...@vo...> - 2010-09-10 00:35:27
|
Ni, based on Stefan's recommendation - everything in right->left and bottom-> up. Ufff! GRRRH! Pito \ Some new .s \ by Pito 2010-09-09 \ v2 WITH TOS AND TOR ON RIGHT SIDE \ WITH TOS AND TOR ON BOTTOM marker -newdots : u.r ( s n -- ) 0 swap ud.r ; \ comment if installed variable temporary : rdepth rp0 rp@ - 2/ 1- 1- ; \ ONELINE HEXA STACK : .slh sp@ temporary ! ." [" depth dup 0 ?do dup 1- i - 2* temporary @ + base @ swap hex @ 6 u.r base ! loop drop ." <TOSH]" ; \ ONELINE UNSIGNED STACK : .slu sp@ temporary ! ." [" depth dup 0 ?do dup 1- i - 2* temporary @ + base @ swap decimal @ 6 u.r base ! loop drop ." <TOSU]" ; \ ONELINE SIGNED STACK : .sls sp@ temporary ! ." [" depth dup 0 ?do dup 1- i - 2* temporary @ + base @ swap decimal @ 6 .r base ! loop drop ." <TOSS]" ; \ ONELINE SIGNED RSTACK : .rls rp@ 1- temporary ! \ alignment vs. .s ??? ." [" rdepth dup 0 ?do dup 1- i - 2* temporary @ + base @ swap decimal @ 6 .r base ! loop drop ." <TORS]" ; \ ONELINE UNSIGNED RSTACK : .rlu rp@ 1- temporary ! \ alignment vs. .s ??? ." [" rdepth dup 0 ?do dup 1- i - 2* temporary @ + base @ swap decimal @ 6 u.r base ! loop drop ." <TORU]" ; \ ONELINE HEXA RSTACK : .rlh rp@ 1- temporary ! \ alignment vs. .s ??? ." [" rdepth dup 0 ?do dup 1- i - 2* temporary @ + base @ swap hex @ 6 u.r base ! loop drop ." <TORH]" ; \ IN COLUMNS DSTACK ON BOTTOM NO ADDRR UNSIGNED SIGNED HEXA : .scb sp@ temporary ! depth dup 0 ?do dup 1- i - dup dup 0 = if ." TOS>|" drop else negate 4 .r ." |" then 2* temporary @ + \ dup 7 u.r ( prints the address ) dup dup base @ swap decimal @ 7 u.r base ! base @ swap decimal @ 7 .r base ! base @ swap hex @ 6 u.r base ! cr loop drop ; \ IN COLUMNS DSTACK ON BOTTOM WITH ADDRR UNSIGNED SIGNED HEXA : .sab sp@ temporary ! depth dup 0 ?do dup 1- i - dup dup 0 = if ." TOS>|" drop else negate 4 .r ." |" then 2* temporary @ + dup 7 u.r ." |" ( prints the address ) dup dup base @ swap decimal @ 7 u.r base ! base @ swap decimal @ 7 .r base ! base @ swap hex @ 6 u.r base ! cr loop drop ; \ IN COLUMNS RSTACK ON BOTTOM WITH ADDRR UNSIGNED SIGNED HEXA : .rcb rp@ 1- temporary ! rdepth dup 0 ?do dup 1- i - dup dup 0 = if ." TOR>|" drop else negate 4 .r ." |" then 2* temporary @ + \ dup 7 u.r ( prints the address ) dup dup base @ swap decimal @ 7 u.r base ! base @ swap decimal @ 7 .r base ! base @ swap hex @ 6 u.r base ! cr loop drop ; \ IN COLUMNS RSTACK ON BOTTOM WITH ADDRR UNSIGNED SIGNED HEXA : .rab rp@ 1- temporary ! rdepth dup 0 ?do dup 1- i - dup dup 0 = if ." TOR>|" drop else negate 4 .r ." |" then 2* temporary @ + dup 7 u.r ." |" ( prints the address ) dup dup base @ swap decimal @ 7 u.r base ! base @ swap decimal @ 7 .r base ! base @ swap hex @ 6 u.r base ! cr loop drop ; \ a quick test for oneline .s marker -testsdtot : .sla cr .sls cr .slu cr .slh ; : stest1 $AAAA .sla cr 5 0 do dup .sla cr loop 5 0 do drop .sla cr loop drop .sla cr ; : ? .sls cr .rls cr ; : rtest ? -8888 -8888 -8888 -8888 ? >r ? >r ? >r ? >r ? r> ? r> ? r> ? r> ? drop drop drop drop ? ; : rtest1 .rls ; : rtest2 rtest1 ; : rtest3 rtest2 ; : rtestc1 cr .rab ; : rtestc2 rtestc1 ; : rtestc3 rtestc2 ; --------------------------------------------- Examples: > stest1 [-21846<TOSS] [ 43690<TOSU] [ AAAA<TOSH] [-21846-21846<TOSS] [ 43690 43690<TOSU] [ AAAA AAAA<TOSH] [-21846-21846-21846<TOSS] [ 43690 43690 43690<TOSU] [ AAAA AAAA AAAA<TOSH] [-21846-21846-21846-21846<TOSS] [ 43690 43690 43690 43690<TOSU] [ AAAA AAAA AAAA AAAA<TOSH] [-21846-21846-21846-21846-21846<TOSS] [ 43690 43690 43690 43690 43690<TOSU] [ AAAA AAAA AAAA AAAA AAAA<TOSH] [-21846-21846-21846-21846-21846-21846<TOSS] [ 43690 43690 43690 43690 43690 43690<TOSU] [ AAAA AAAA AAAA AAAA AAAA AAAA<TOSH] [-21846-21846-21846-21846-21846<TOSS] [ 43690 43690 43690 43690 43690<TOSU] [ AAAA AAAA AAAA AAAA AAAA<TOSH] [-21846-21846-21846-21846<TOSS] [ 43690 43690 43690 43690<TOSU] [ AAAA AAAA AAAA AAAA<TOSH] [-21846-21846-21846<TOSS] [ 43690 43690 43690<TOSU] [ AAAA AAAA AAAA<TOSH] [-21846-21846<TOSS] [ 43690 43690<TOSU] [ AAAA AAAA<TOSH] [-21846<TOSS] [ 43690<TOSU] [ AAAA<TOSH] [<TOSS] [<TOSU] [<TOSH] ok > rtest [<TOSS] [ 0 934 1539 14535 14526 13987<TORS] [ -8888 -8888 -8888 -8888<TOSS] [ 0 934 1539 14544 14526 13987<TORS] [ -8888 -8888 -8888<TOSS] [ 0 934 1539 -8888 14546 14526 13987<TORS] [ -8888 -8888<TOSS] [ 0 934 1539 -8888 -8888 14548 14526 13987<TORS] [ -8888<TOSS] [ 0 934 1539 -8888 -8888 -8888 14550 14526 13987<TORS] [<TOSS] [ 0 934 1539 -8888 -8888 -8888 -8888 14552 14526 13987<TORS] [ -8888<TOSS] [ 0 934 1539 -8888 -8888 -8888 14554 14526 13987<TORS] [ -8888 -8888<TOSS] [ 0 934 1539 -8888 -8888 14556 14526 13987<TORS] [ -8888 -8888 -8888<TOSS] [ 0 934 1539 -8888 14558 14526 13987<TORS] [ -8888 -8888 -8888 -8888<TOSS] [ 0 934 1539 14560 14526 13987<TORS] [<TOSS] [ 0 934 1539 14565 14526 13987<TORS] ok > rtest1 [ 0 934 1539 14573 13987<TORS] ok > rtest2 [ 0 934 1539 14581 14573 13987<TORS] ok > rtest3 [ 0 934 1539 14589 14581 14573 13987<TORS] ok > rtestc1 -4| 16634| 0 0 0 -3| 16632| 934 934 3A6 -2| 16630| 1539 1539 603 -1| 16628| 14599 14599 3907 TOR>| 16626| 14427 14427 385B ok > rtestc2 -5| 16634| 0 0 0 -4| 16632| 934 934 3A6 -3| 16630| 1539 1539 603 -2| 16628| 14608 14608 3910 -1| 16626| 14599 14599 3907 TOR>| 16624| 14427 14427 385B ok > rtestc3 -6| 16634| 0 0 0 -5| 16632| 934 934 3A6 -4| 16630| 1539 1539 603 -3| 16628| 14617 14617 3919 -2| 16626| 14608 14608 3910 -1| 16624| 14599 14599 3907 TOR>| 16622| 14427 14427 385B ok > .s ok > 1 2 3 4 5 6 7 8 9 10 ok > .slh [ 1 2 3 4 5 6 7 8 9 A<TOSH] ok > .sls [ 1 2 3 4 5 6 7 8 9 10<TOSS] ok > .slu [ 1 2 3 4 5 6 7 8 9 10<TOSU] ok > .scb -9| 1 1 1 -8| 2 2 2 -7| 3 3 3 -6| 4 4 4 -5| 5 5 5 -4| 6 6 6 -3| 7 7 7 -2| 8 8 8 -1| 9 9 9 TOS>| 10 10 A ok > .sab -9| 16381| 1 1 1 -8| 16379| 2 2 2 -7| 16377| 3 3 3 -6| 16375| 4 4 4 -5| 16373| 5 5 5 -4| 16371| 6 6 6 -3| 16369| 7 7 7 -2| 16367| 8 8 8 -1| 16365| 9 9 9 TOS>| 16363| 10 10 A ok > |
|
From: Marcin C. <sa...@sa...> - 2010-09-10 00:18:12
|
Two quick remarks: >> 2. how the data from data stack (or from return stack) are passed to >> assembler - data stack (all elements EXCEPT top of the stack) are kept close to the end of RAM (end of RAM - 128), growing down. - TOP of the stack is kept in register pair (tosh:tosl) >> 3. how the data are passed from asm. back to data stack or return >> stack - if you just change top of the stack (say remove 1 parameter and put 1 cell of results) just change contents of tosh:tosl registers - "loadtos" macro fetches the second item on stack and loads it into the tosh:tosl, while moving stack pointer down - - so it effectively the same as DROP. Of course, if one needs to preserve top of stack another "ld" command can be used to load 2nd, 3rd, etc. elements into other registers. - "storetos" macro stores the TOS on to the stack, therefore it is how DUP is implemented. If you want just to push something on stack just "storetos" and modify tosh:tosl. - return stack is the machine stack. it starts at the end of RAM and grows downward (toward smaller addresses), the same direction as the data stack. It means you have 128 bytes (64 16-bit words) for the return stack available by default. - second item on a data stack is pointed by the YH:YL register pair - push, pop operate on the return stack then (see >r, r>, r@) - inner interpreter stores current Forth instruction pointer in the register pair XH:XL and pushes it/pops off the return stack as necessary. It's all in amforth.asm - first 87 lines --Marcin |
|
From: Kalus M. <mic...@on...> - 2010-09-09 18:49:55
|
Am 09.09.2010 um 20:10 schrieb Matthias Trute:
...
> There is no way to use forth words from within the
> assembler code. For that you need to initialize
> a forth vm and call it. The only "guide" for that
> is the startup code itself (amforth.asm).
and goes like this:
<snip>
sei ; global interupt enable.
push XL
push XH
lds XL,0x5F ; status register
push XL
.. maybe you have to include even more registers
push R22 ; tosl = r22
push R23 ; tosh = r23
push R24 ; wl
push R25 ; wh
push YL
push YH
push ZL
push ZH
...
<your code>
...
; switch to high level forth: :
sei
ldi XL,low(pfa_forthISR)
ldi XH,high(pfa_forthISR)
jmp DO_NEXT
; -- pointer to NEXT word:
pfa_forthISR:
.dw XT_MAINWORD
; -- come back to code:
.dw PC+1 ; next IP
.dw PC+1 ; next cfa
...
<more of your code>
...
pop ZH
pop ZL
pop YH
pop YL
pop R25
pop R24
pop R23
pop R22
.. maybe you have to include even more registers
pop XL
sts 0x5F,XL
pop XH
pop XL
jmp DO_NEXT (or RTI if you are in an ISR)
</snip>
see examples in paper VD1/2010 http://www.forth-ev.de/filemgmt/
viewcat.php?cid=53
worked with amforth3.6
still good with 4.1?
Michael
|
|
From: Matthias T. <mt...@we...> - 2010-09-09 18:33:41
|
him > 10. how the local .asm variables (used in asm rouitne shall be > handled (e.g. where in ram to place the local variables). If you use Lubos assembler, you can allocate RAM and use the address. The assembler is, after all, forth code which compiles machine code. When using the avrasm, there are examples in the source tree: e.g. base.asm or any other variable. IMHO not trivial, but no real secrets. Matthias |