Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.

Latest threads

Back
Top