Thabks for the quick help.
Have implemented it in my figforth code.
But I think the RSHIFT is not working correct.
10 2 LSHIFT . 40 OK
40 2 RSHIFT . 40 OK
I include my code.
Please can youtake a look.
Cheers,
Jan
Code:
;
; LSHIFT
;
L8800 .BYTE $86,"LSHIF",$D4
.WORD L8721
LSHIFT .WORD LSHIFT+2
LDY 0,X ; See how many bit positions we're supposed to go.
shLb1: BEQ shLo1 ; If the shift distance is 0, just exit without action.
shLlp: ASL 2,X ; Shift the low byte of the number (putting 0 in bit 0),
ROL 3,X ; then the high byte, bringing bit 7 into bit 8's position.
DEY ; Mark off one more shift done.
BNE shLlp ; If there's at least 1 more shift to do, loop again.
shLo1: JMP POP ; Remove one cell from the stack, and go to NEXT.
;
; RHIFT
;
L8900 .BYTE $86,"RSHIF",$D4
.WORD L8800
RRSHIFT .WORD RRSHIFT+1
LDY 0,X ; See how many bit positions we're supposed to go.
BEQ shLo1 ; If the shift distance is 0, just exit without action.
sfRlp: LSR 3,X ; Shift the high byte of the number (putting 0 in high bit)
ROR 2,X ; then low byte, bringing bit 8 in to bit 7's position.
DEY ; Mark off one more shift done.
BNE sfRlp ; If there's at least one more shift to do, loop again.
JMP POP ; Remove one cell from the stack, and go to NEXT.