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 |