Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/07/01 20:01
Read: times


 
#17378 - A Comparision program needs check
Dear Friends,

I need the following comparision program, but something is wrong at the programming logic, I couldn't succeded at the construction of programming logic. Any help will be appreciated. Kind Regards.

Nutty Blue

A comparision program, within this program, I have targeted to compare the stored values of 4 sensors which are taken sequentially. Since 1st value is at DPTR and for the related sensor 2nd value is at the address 4+DPTR, so for the second comparision DPTR is incremented 4 times. If the compared value is greater than 3 ( which is the critical value ) then within these 4 comparisions the number of times of greater values are counted within the specified registers.

Org 2400h
;
COMPARE: MOV R5,#04H
MOV R4,#00
MOVX A,@DPTR ; 1st value is taken for to compare
CLR C
SUBB A,#03H ; 03 is the critical value
JNC COUNT ; If C=0 then count, compared value is greater than 03.
INC DPTR ; Increment DPTR 4 times to reach the 2nd value
INC DPTR ; for the same sensor.
INC DPTR
INC DPTR
MOV A,R4
MOV R1,A
INC R1
DJNZ R5, COMPARE
RET
COUNT: INC R4
INC DPTR
INC DPTR
INC DPTR
INC DPTR
MOV A,R4
MOV R1,A
INC R1
DJNZ R5, COMPARE
RET
I want the above program will be store the number of times of greater values at the registers.For each sensor one register place is reserved and this place will be store the count (the number of times of greater values from the critical value ). These register places will be located as sequentially.




List of 2 messages in thread
TopicAuthorDate
A Comparision program needs check             01/01/70 00:00      
RE: A Comparision program needs check             01/01/70 00:00      

Back to Subject List