A very minor item.
avr8 has bm-set, bm-clear and bm-toggle as assembler words but does
not appear to have bm-test. This is not a big thing as it is easily
defined in forth as
: bm-test ( c a -- c ) c@ and ;
However, I've made myself an assembler version so I have a matching
set. It seems only very marginally faster than the forth one above.
; ( bitmask byte-addr -- byte )
; MCU
; return (byte at addr) AND bitmask
VE_BM_TEST:
.dw $ff07
.db "bm-test"
.dw VE_HEAD
.set VE_HEAD = VE_BM_TEST
XT_BM_TEST:
.dw PFA_BM_TEST
PFA_BM_TEST:
movw zl, tosl
loadtos
ld temp0, Z
and tosl, temp0
clr tosh ; zero high byte of TOS
jmp_ DO_NEXT
msp430 is missing bm-toggle and arm, risc-v have none of them.
It also seemed a reasonable opportunity to try out tester-amforth.frt
I could well be using it incorrectly. Corrections welcomed.
\ #include tester-amforth.frt
variable v
$ffff v !
\ some passes and fails to see what it looks like
\ should pass
t{ $ff v bm-test -> $ff }t
\ should pass
t{ $1 v bm-test -> $1 }t
\ should pass
t{ $0 v bm-test -> $0 }t
\ should pass
t{ $ffff v bm-test -> $ff }t
\ should fail
t{ $ffff v bm-test -> $ffff }t
\ should pass
t{ $ff00 v bm-test -> $00 }t
\ should fail
t{ $ff00 v bm-test -> $ff00 }t
\ Not sure if this is an approved way of using t{ ... }t
\ should pass for all values
: test.1
#256 0 ?do
i v !
#256 0 ?do
t{ i v bm-test -> j $ff and i and }t
loop
loop
;
\ intentionally broken word
: bm-broken ( mask a -- n )
2dup c@ dup 23 = rot rot = and if
drop drop 0
else
bm-test
then
;
\ should fail only once when i=j=23
: test.2
#256 0 ?do
i v !
#256 0 ?do
j 23 = if i . cr then
t{ i v bm-broken -> j $ff and i and }t
loop
loop
;
Best wishes,
Tristan
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
[email protected]
https://lists.sourceforge.net/lists/listinfo/amforth-devel