From 67d25d837ac55f28a366c0a3b262e439a6e75fc3 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 19 Aug 2017 12:15:28 +0200 Subject: Add AmForth --- amforth-6.5/avr8/words/popcnt.asm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 amforth-6.5/avr8/words/popcnt.asm (limited to 'amforth-6.5/avr8/words/popcnt.asm') diff --git a/amforth-6.5/avr8/words/popcnt.asm b/amforth-6.5/avr8/words/popcnt.asm new file mode 100644 index 0000000..66f8f47 --- /dev/null +++ b/amforth-6.5/avr8/words/popcnt.asm @@ -0,0 +1,29 @@ +; ( n1 -- n2 ) +; Arithmetics +; count the Number of 1 bits (population count) +VE_POPCNT: + .dw $ff06 + .db "popcnt" + .dw VE_HEAD + .set VE_HEAD = VE_POPCNT +XT_POPCNT: + .dw PFA_POPCNT +PFA_POPCNT: + movw zl, tosl + clr tosl + rcall PFA_POPCNT1 + mov zl, zh + rcall PFA_POPCNT1 + clr tosh + jmp_ DO_NEXT + +PFA_POPCNT1: + ldi tosh, 8 +PFA_POPCNT2: + ror zl + ;breq PFA_POPCNT3 + adc tosl, zeroh + dec tosh + brne PFA_POPCNT2 +POPCNT3: + ret \ No newline at end of file -- cgit v1.2.3