8051 controller asm problem

Status
Not open for further replies.

hassan ali

Member level 2
Joined
May 18, 2010
Messages
47
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
egypt
Activity points
1,667
hi , sorry for my English

i have connected my project (8051 interface with keypad), the keypad output is in decimal,
so by example (if i write 800 using keypad)i want to take this number and then subtract this number from (65535) and then load the counter (TH0 , TL0) with the output result from the subtraction process, how can i do this ?????

note:i am using Assembly language, and i want to do it using Assembly.
 

first thank u for your reply
but i have already do these previous steps
but i asked for how can i sub the number from 65535 and then take this number to load the counter.
 

If the number is binary as byte1H and byte1L (that is 16-bit number), the subtraction could be performed as:

==============================
MOV A, byte1L
CPL A
ADD A, #1
MOV byte2L, A
MOV A, byte1H
CPL A
ADDC A, #0
MOV byte2H, A
==============================

Now byte2H and byte2L hold 65336-byte1H/L


But, if you like instead that byte2H/L = 65335-byte1H/L

==============================
MOV A, byte1L
CPL A
MOV byte2L, A
MOV A, byte1H
CPL A
MOV byte2H, A
==============================
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…