Re: [Flashforth-devel] atmega assembler
Brought to you by:
oh2aun
From: <mik...@fl...> - 2015-01-23 18:27:29
|
Graham, The square brackets are needed to compile inline assembler code. Without square brackets you will compile code that compiles assembler when the code is executed. Here are some examples for Atmega I just put together. You can use SEE to see the generated code and compare it with the FF words. /Mike -asmexamples marker -asmexamples \ Top of stack is always cached in R24:R25 \ duplicate top of stack \ identical to DUP on FlashForth : _dup ( n -- n n ) [ R25 -Y st, ] [ R24 -Y st, ] ; inlined \ drop top of stack \ identical to DROP on FlashForth : _drop ( n -- ) [ R24 Y+ ld, ] [ R25 Y+ ld, ] ; inlined \ Load constant $1234 to top of stack : a-number ( -- 1234 ) dup \ Make space for new TOS value [ R24 $34 ldi, ] [ R25 $12 ldi, ] ; \ Pop the top of stack to registers R18:R19 \ R18 and R19 are free to use unless DO..LOOP is used : tos-to-r18-r19 ( n -- ) [ R18 R24 movw, ] \ Move TOS to R18:R19 drop \ load R24:R25 with new TOS ; On 23.01.2015 10:46, GRAHAM BOYD wrote: > Mikael - I am trying to get started with the assembler. I have > compiled > asm.txt and asmtest.txt. testif0,testif1 and testuntil appear to > work. > > Could you give some more examples - load a register with a constant > and > push to stack, pop from stack to a register, pop from stack-2 to a > register would help me get started. > > I am not understanding why the square brackets ( enter interpreter > state) is required??? > > -- > Graham Boyd |