Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
I don't think that is correct.Integer calcs? All simulation software I'm aware of using floats for everything... even perceived integers.. .
Word Multiplication Routine
M001: MOVLW 0x10
MOVWF R4L
CLRF R0H
CLRF R0L
M002: RRF R3H,F
RRF R3L,F
BTFSS STATUS,C
GOTO M003
MOVF R1L,W
ADDWF R0L,F
MOVF R1H,W
BTFSC STATUS,C
INCFSZ R1H,W
ADDWF R0H,F
M003: RRF R0H,F
RRF R0L,F
RRF R2H,F
RRF R2L,F
DECFSZ R4L,F
GOTO M002
RETURN
; Word Division Routine
D001: MOVLW 0x10
MOVWF R3L
CLRF R2H
CLRF R2L
D002: RLF R0H,W
RLF R2L,F
RLF R2H,F
MOVF R1L,W
SUBWF R2L,F
MOVF R1H,W
BTFSS STATUS,C
INCFSZ R1H,W
SUBWF R2H,F
BTFSC STATUS,C
GOTO D003
MOVF R1L,W
ADDWF R2L,F
MOVF R1H,W
BTFSC STATUS,C
INCFSZ R1H,W
ADDWF R2H,F
BCF STATUS,C
D003: RLF R0L,F
RLF R0H,F
DECFSZ R3L,F
GOTO D002
RETURN
; Word ShiftRight Routine
SR01: BCF STATUS,C
RRF R0H,F
RRF R0L,F
SR00: ADDLW 0xFF
BTFSC STATUS,C
GOTO SR01
RETURN
Is it better to calc. X * 41/256 rather than X * 16/100 once the error is acceptable in Oshon?
I seem to observe better performance by using multiplication to encourage binary compatible divisions.
Edit: for integer calcs.
So if i have a x/256 I should use x>>8 ?