Hi guys,
Ive found out that the only way to have a value larger than 255(for a variable) is by increasing the value of another variable every time the first variable overflow. By the way im using pic16f84 and im currently learning how to program in assembly language.
Example, "counta" for values from 0-256 and "countb" is for overflow of "counta".
This is an example code that i found which shows the calculation of numbers more than 256. The result will correspond to an address in a map.
rpmhi=counter overflow for rpmlow.
value of rpm : 74<(rpmhi+rpmlow)<600
; the formula to get the data stored in the map is as follows
;
; (rpmhi+rpmlow count) - 74
; 131 - ----- ----------------------
; 4
;
caladv movlw d'74' ; (rpmhi+rpmlow count) - 74
subwf rpmlo,F ; rpmlo = rpmlo - 74
btfss STATUS,C
decf rpmhi,F
;
; divide result by 4
;
bcf STATUS,C
rrf rpmhi,F
rrf rpmlo,F ; / 2
;
bcf STATUS,C
rrf rpmhi,F
rrf rpmlo,F ; / 4
;
movlw .131 ; 131 entries in map list
movwf math
;
movf rpmlo,W
subwf math,W ; W = 131 - result
;
bcf PCLATH,0 ; be sure to go h'200'
bsf PCLATH,1 ; where is the map.
call map ; read map
movwf rtdset ; come back with new retard value
Im not sure how the codes work.Ive tried the logic, and it seems fine for numbers <256,
example :
say value of rpm : (rpmhi+rpmlow)=240
where rpmhi=0 and rpmlow=d'240'
ive done 2 different approach :
a) using calculator =41.5
b) using the logic operator (subwf,rrf) =41
But when rpm value > 256, say (rpmhi+rpmlow)=496
where rpmhi=1 and rpmlow=d'240'
same approach as above:
a) using calculator =105.5
b) using the logic operator (subwf,rrf) =41
or am i missing something here..