Discussion in "8051 Discussion Forum" started by    kekkon    Jul 11, 2009.
Fri Jul 17 2009, 03:30 am
#11


This is the code that I've tried to write. Is the method I am using correct ?:-)

kekkon


What does it do ?
Sat Jul 18 2009, 02:50 am
#12
Ok timeout!
previously i was thinking of helping you with just hints
but you are making things complicated
so i will frame a question and try to give its answer
please match it with your case and come to a conclusion!


question:
you will receive something (some data) on Port P1
the data you received will contain two separate portions
1. one on lower nibble
2. another on upper nibble

each of these nibble values corresponds to a data stored in rom location
say 0x02A0
lets assume the data values to be as follows


0x02A0 0000 30
0x02A1 0001 45
0x02A2 0010 23
0x02A3 0011 62
0x02A4 0100 31
0x02A5 0101 31
0x02A6 0110 73
0x02A7 0111 82
0x02A8 1000 36
0x02A9 1001 89
0x02AA 1010 42
0x02AB 1011 74
0x02AC 1100 41
0x02AD 1101 39
0x02AE 1110 57
0x02AF 1111 97

what you have to do is
get the values corresponding to the nibbles and
calculate the difference
and show the result?

ANSWER:
BUS 	EQU	P1

	ORG 	0000H
REBOOT:	ACALL APPLICATION
	SJMP 	$

APPLICATION:
	MOV	BUS, #0FFH	;MAKE P1 AS INPUT PORT
	MOV	A,P1		; GET THE INPUT		ASSUME IT TO BE 24

	MOV	B,A		; SAVE IT FOR FUTURE PROCESS
	ANL  	A,#0FH		; MASK LOWER NIBBLE		GET	2
	MOV	R0,A		; SAVE IT IN R0
	MOV	A,B		; RETRIVE SAVED INPUT
	SWAP 	A		; SWAP IT TO OBTAIN HIGHER NIBBLE IN A[3..0]
	ANL  	A,#0FH		; MASK HIGHER NIBBLE		GET	4

	MOV 	DPTR, #DAT	; TABLE LOCATION
	MOVC 	A, @A+DPTR	; GET THE CONTENT 	WITH A AS 4 WHICH IS 31H
	MOV	B,A		; SAVE IT
	
	MOV	A,R0		; GET 2
	MOVC 	A, @A+DPTR	; WILL RESULT IN 23H
	
	CJNE 	A,B,NOT_EQUAL	; WILL NOT BE EQUAL SINCE A<B
EQUAL:	;CODE FOR EQUAL CONDITION
	;
	;
	RET

NOT_EQUAL:
	JC	A_ISSMALLER
A_ISGREATER:
	; CODE FOR A GREATER
	;
	;
	RET
	
A_ISSMALLER:
	; CODE FOR A SMALLER
	;
	;
	RET

	org 02A0h
dat: DB 30H,45H,23H,62H,31H,31H,73H,82H
     DB	36H,89H,42H,74H,41H,39H,57H,97H

END



Please understand that i am 'NOT' writing code for you :-|
if this help you in any way, i will be more than happy
try to learn more patterns from this example
If you have any doubts please revert!
Sat Jul 18 2009, 11:53 am
#13
erm, any help from some of you guys please :mad
Sat Jul 18 2009, 12:47 pm
#14
:-s


[ Edited Sat Jul 18 2009, 12:48 pm ]
Sat Jul 18 2009, 03:26 pm
#15
Can anyone help me :-)
Sat Jul 18 2009, 04:04 pm
#16
afilash,

0x02A0 0000 30
0x02A1 0001 45
0x02A2 0010 23
0x02A3 0011 62
0x02A4 0100 31
0x02A5 0101 31
0x02A6 0110 73
0x02A7 0111 82
0x02A8 1000 36
0x02A9 1001 89
0x02AA 1010 42
0x02AB 1011 74
0x02AC 1100 41
0x02AD 1101 39
0x02AE 1110 57
0x02AF 1111 97

is for what use ??
Sat Jul 18 2009, 09:56 pm
#17


its just an example
the thing is that for those input nibble values we have read through port P1, each nibble value corresponding to some value(say probability density function of some function F(x) !dance ) is given in the table inside the code space.

I was joking, don't get confused, they are just some values in the rom location
-or-
if you are not satisfied with this explanation
consider those location contains , say ascii values for those nibbles :-|
Sat Jul 18 2009, 10:16 pm
#18
how about this ??

dat: DB 30H,45H,23H,62H,31H,31H,73H,82H
DB 36H,89H,42H,74H,41H,39H,57H,97H

???
Sat Jul 18 2009, 10:21 pm
#19
kekkon, afilash has given a good example to explain how to use loopup tables and comparing.

I think your Lab work need a revision. I think its not an appropriate way to learn using lookup tables. I recommend you to talk to your lecturer and get some advice from him or get an example from him on how things are need to be done exactly.

coz lookup tables are pre-stored values in code memory, and as you said you want to store the read values in lookup table, that is not possible. coz the name says.. look up is just for lookup purpose, you just read from it for reference not write into it.
Sun Jul 19 2009, 09:48 am
#20
I am sorry, I though the thread has not been replied. I am very sorry about this.
I did not see the page 2 button.

A deep apologize for my stupid replied above. :-|

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Robertrip
Fri Apr 26 2024, 11:20 am
ArnoldDiant
Fri Apr 26 2024, 03:53 am
RodneyKnorb
Thu Apr 25 2024, 07:08 pm
Williamjef
Thu Apr 25 2024, 02:08 pm
SamuelSmise
Thu Apr 25 2024, 09:56 am
DustinErele
Thu Apr 25 2024, 08:44 am
ztaletpzca
Wed Apr 24 2024, 11:19 pm
IrardlPex
Wed Apr 24 2024, 08:42 pm