89s51 magnitude code

Status
Not open for further replies.

ohms

New Member
Hey guys wassup. i need with wiriting a code for comaring two 8 bit numbers in the 89s51 controller. basically there will be a value in the code already set. then through one of the port there will be a 8 bit value consitant coming for a adc. i was to compare that value to the value in the code and i want to know if it is < > or = to the value in the program.
can anyone help? :idea:
thx
 
Here is how you do it.
Code:
; ACC Countains data from Port 1 and is compared to value 45H
MOV A, P1
CJNE A,#45H,NOT_EQ
; ... ....		; A = 45H.
SJMP COMPARE_END

NOT_EQ: JC SMALLER	; IF A < 45H.
; ... ....		; A > 45H.
SJMP COMPARE_END

SMALLER:
; ... ....		; A < 45H.

COMPARE_END:
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…