Timex M851 Watch User Manual


 
M851 WristApp Design Guide Rev 1.2
Timex Corporation 109
GLOBAL cntAddDataByAcceleration
cntAddDataByAcceleration: ; **SUBROUTINE
cntAddDataByAcceleration
push SC
; Use decimal addition.
UTL_DECIMAL_MATH_MODE
;--------------------------------------------------------------
; Determine the acceleration factor for COREEventArgument and
; write factor into AReg.
;--------------------------------------------------------------
;--------------------------------------------------------------
; Get starting address into the acceleration table then subtract
; it by 1 to get the exact acceleration data. Take note that
; the least number of pulses that the system will send is 1.
;--------------------------------------------------------------
ld IX, #utlAccelerationTable1Min - 1
; Get the number of pulses.
ld L, [COREEventArgument]
; Get the acceleration factor.
ld A, [IX + L]
cntAddDataBy1EntryPoint:
;--------------------------------------------------------------
; Note for using this as the entry point.
; AReg - Value to be added to the current counter.
; IYReg- Counter ASD address.
; SCReg should be pushed.
; bDecimalFlag should be set.
;--------------------------------------------------------------
push IY
; Set HLReg and IYReg to point to the data low address.
add IY, #CNTDATALOOFFSET
ld HL, IY
; Increment the counter.
add [HL], A
inc HL
adc [HL], #0
; Get the current counter data.
ld HL, [IY]
;--------------------------------------------------------------
; Check if counter data exceeds its maximum. If it exceeds
; then compute for the excess data so that it would look
; like it has wraparound.
;--------------------------------------------------------------
cp HL, #CNTMAXDATA
jr C, cntAddDataExit
jr Z, cntAddDataExit
ld HL, IY
sub [HL], #@LOW(CNTMAXDATA+1)
inc HL
sbc [HL], #@HIGH(CNTMAXDATA)
cntAddDataExit:
pop IY
pop SC
ret