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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/27/01 21:09
Read: times


 
#8695 - RE: Comparison Problem.....
Hi Sanjeev,

There are 2 logical mistakes in your code. Cy=1 after subtraction the R7R6 value from 5000 (01388H) means that 5000 < R7R6. Cy=1 after subtraction the R7R6 value from 7000 (01B58H) means that 7000 < R7R6. By the way, why do you use
two instructions
MOV A,#0xxH
MOV P1,A
instead of
MOV P1,#0xxH?

Try the following code, it must work OK.

Good luck,
George

;THE CORRECTED CODE FOR SANJEEV ESPESIALLY
DOACTION: MOV R6,TL0
MOV R7,TH0
MOV P1,#00FH ;TO DISPLAY 0
CLR C
MOV A,#088H
SUBB A,R6
MOV A,#013H
SUBB A,R7
JNC ACTION1 ;jumps if (5000 >= R7R6)
JMP STEP1 ;jumps if (5000 < R7R6)
ACTION1: MOV P1,#00EH ;TO DISPLAY 1 (5000 >= R7R6)
JMP MEASURE_AGAIN
;The value in R7R6 is greater than 5000 (R7R6 > 5000)
STEP1: CLR C
MOV A,#058H
SUBB A,R6
MOV A,#01BH
SUBB A,R7
JNC ACTION2 ;jumps if (7000 >= R7R6)
JMP MEASURE_AGAIN ;jumps if (7000 < R7R6)
;This is happened when 5000 < R7R6<=7000
ACTION2: MOV P1,#00DH ;TO DISPLAY 2 (7000 >= R7R6)
JMP MEASURE_AGAIN
END


List of 9 messages in thread
TopicAuthorDate
Comparison Problem.....            01/01/70 00:00      
RE: Comparison Problem.....            01/01/70 00:00      
RE: Comparison Problem.....            01/01/70 00:00      
RE: Comparison Problem.....            01/01/70 00:00      
RE: Comparison Problem.....            01/01/70 00:00      
RE: Comparison Problem.....            01/01/70 00:00      
RE: Comparison Problem.....            01/01/70 00:00      
RE: Comparison Problem.....            01/01/70 00:00      
RE: Comparison Problem.....            01/01/70 00:00      

Back to Subject List