[SOLVED] Assembly language for 8051 for nue b

Status
Not open for further replies.

ANS HAFEEZ

Advanced Member level 4
Joined
Jul 25, 2013
Messages
101
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,298
Location
LAHORE,PAKISTAN
Visit site
Activity points
1,911
Salam
as in 8051 assembly all conditional jumps are short jumps
i m using kiel and when in assemble my code it generates an error "target out of rang" it generates error because of short jump after a condition satisfy so ...
I need lo000ng jump after a condition satisfy
any tips for assembly language
found nothing on g00gle so i m here
i m riting a code for a line follower with 5 sensors and i have to call just 6 functions on different sensors input
help plx
 

I write my C_51 programs directly as assembly codes.

As you know, the LJMP command accepts an address from 0 to 65535.

So for your condition, you have two ways to jump outside the 2K boundary:

(1) To jump to a nearby label at which you put the command LJMP.

(2) if possible, you reverse your condition then follow it by an LJMP instruction line.
but if both jumps are to far addresses, you have to follow the previous method.
 
Last edited:

THANKZ kerimf
but i tried the first method but still SAME error
my CODE EXAMPLE HERE:


Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
MOV A,P1
XRL A,#11111000B
JZ FASTRIGHT
 
MOV A,P1
XRL A,#11110010B
JZ FASTRIGHT
 
MOV A,P1
XRL A,#11111010B
JZ FASTRIGHT
 
MOV A,P1
XRL A,#11110110B
JZ FASTRIGHT



like this i have to compare 32 combinations and call the 6 six functions with these 32 combinations any other programming tips PLX I TRIED IT MANY different ways
 
Last edited by a moderator:

Sorry, I couldn't get exactly what you look for.

Do you mean P1 could be a value in the range #11100000 to #11111111?
And only for 6 values of them, the program should jump to a far address?
 

port P1 takes input from five sensors and line tracker mov according to the different combination of these five sensors the sensors input could be 11111 or 00000 or 10001 or 10101 or 10111 or 11101 ETC...

and robot have to move fast ,slow, turn right ,turn left ,turn left fastly ,turn right fastly


actually this design is for complex line or may be a confusing line for robot but robot should be intelligent so that it couldnt be confused

My code become very large and complex there for i am getting " TARGET OUT OF RANG" .. . . . . . ... . .

JUST I NEED IS A SINGLE IDEA OR TIP FOR ASSEMBLY LANGUAGE
 

Let us see if we can take advantage of:
JMP @A+DPTR ;Jump indirect relative to Data Pointer

The following possibilty comes to my mind now.

First, we build a table of 32 LJPM lines that are addressing (the way you like) the 6 different routines:

Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
; This table takes 64 bytes
   .org xx00H ; it is better, for clarity, that this address has its 6 least significant bits as 0's
 
MOVtabl:
 LJMP FASTright ; line 1
 LJMP MOVEleft ; line 2
 LJMP FASTleft ; line 3
...
...
 LJMP MOVright ; line 32



Then in your code:


Code ASM - [expand]
1
2
3
4
5
MOV A, P1
ANL A, #00011111B ; read only sensor's bits
RR A ; since each table entry takes 2 bytes
MOV DPTR, #MOVtabl
JMP @A+DPTR



Does this work for you?
 
Last edited by a moderator:

I forgot adding a note about the return from every move routine.

Back to the code:


Code ASM - [expand]
1
2
3
4
5
6
7
8
MOV A, P1
ANL A, #00011111B ; read only sensor's bits
RR A ; since each table entry takes 2 bytes (as multiplying by 2)
MOV DPTR, #MOVtabl
JMP @A+DPTR
 
MOVEret: ; the return address from all 6 routines
... more instructions





At the end of every routine (FASTright, FASTleft... etc), we can return to the main code with:

Code:
LJMP MOVEret
 
Last edited by a moderator:
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…