Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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.
 

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
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.
 

KerimF

Advanced Member level 4
Joined
May 17, 2011
Messages
1,461
Helped
374
Reputation
756
Reaction score
370
Trophy points
1,363
Location
Syria
Activity points
12,314
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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top