Hi Enoch,

since you asked for comments ...

On 02/13/2013 05:38 AM, Enoch wrote:
> Hello Matthias and all,
> 
> I'd like to see this forum also offering code snippets, so here's my
> first humble attempt of harnessing the atomic bit manipulation
> instructions.
> 
> : port:hi ( portadr bitno -- )            \ SBI
>      swap $20 - 3 lshift or $9A00 or code , end-code
> ;
> 
> : port:lo ( portadr bitno -- )            \ CBI
>      swap $20 - 3 lshift or $9800 or code , end-code
> ;
> 
> example:
> 
> PORTB 7 port:hi green.hi
> PORTB 7 port:lo green.lo
> 

So you want to set or clear a bit in some register.

What is wrong with the words found in bitnames.frt?

  include lib/bitnames.frt
  PORTB 7  portpin: green

and later

  green pin_output
  green high
  \ do something here
  green low

Sure, bitnames is doing read+modify+write on the memory mapped
location of the register, while your solution uses sbi/cbi which
does not work on the memory mapped location (hence $20 - ).
But what exactly is better with using sbi/cbi? That sbi/cbi
cannot be interrupted once the instruction is executing? But
all the instructions leading up to the sbi/cbi can be
interrupted, can't they? Do I miss the entire motivation of
the code snippet? Would you dare to enlighten me??


As Matthias pointed out elsewhere: your snippet is intersting,
because assembly instructions are coded in at compile time
without loading the full assembler. That I can see.

Cheers,
Erich

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to