Discussion in "8051 Discussion Forum" started by    kekkon    Jul 11, 2009.
Sat Jul 11 2009, 06:17 AM
Hi, i am currently doing a project using lookup table which i am not really familiar with.

The 8051 reads through Port 1 where higher nibbles stand for 1 sets of inputs and the lower nibbles stand for another set,which is total of 2 sets of inputs after every 60seconds.

The question now I am facing is how to use the lookup table to read the 2 different sets of input to compare them whether they are equal, smaller or greater to each other.

Thanks for helping:-)
Sat Jul 11 2009, 05:54 PM
well I understand what you need but i am not able to understand how lookup tables are involved in this.

you said u want to compare two nibbles of P1 so from where this lookup table comes?

or gimme better explanation with example
Tue Jul 14 2009, 05:23 PM
Sorry for the late reply.

The lookup table is register like that store the inputs from P1 nibbles.

Example: first input is 0100 and the second is 0110 then the input data is move to the lookup table.

Then the data in the lookup table is being compare to determine whether they are bigger,equal or smaller.

Thanks :-)
Tue Jul 14 2009, 06:19 PM
The question is why use a lookup table to compare values

You would use the micro's comparison instructions to do that.

A lookup table is normally fixed, pre-set data, used to swap one value
for a different one.

[ Edited Tue Jul 14 2009, 06:30 PM ]
Tue Jul 14 2009, 07:18 PM
Ya, I know. But this is a question given by my lecturer, i have to do what he told me to do :-|
Tue Jul 14 2009, 07:54 PM
i agree with ExperimenterUK
mask ---> swap ---> compare
that's it!!!
look up table may not be fixed, they can be set up inside ram location , for this case we don't need either

If this is a question given by your lecture and we are helping you ? then what's the point
without trying how you can learn something ? refer Mazidi for implementation of lookup tables :bye

[ Edited Tue Jul 14 2009, 07:59 PM ]
Tue Jul 14 2009, 08:08 PM
Since this is a pointless exercise it is hard to know what
a good method is
However you could..
Fill an array (table) of 16 bytes with 0s
Get the first nibble, use it as an offset into the table,store 1 at that entry.
Fill all addresses that follow with 2s

To compare,
Use the second nibble as an offset into the table and get the byte at that entry.
If the byte is 0 the second nibble is lower, if 1, it is the same
and if it is 2, it is higher.
(and I get the marks )

Generally I agree with afilash's comment about doing this yourself, but I think
a small pointer is OK just this once.

[ Edited Thu Jul 16 2009, 11:27 AM ]
Wed Jul 15 2009, 12:19 PM
are you using C or assembly?

in assembly lookup table is defined in CODE memory as follows:

LookUp: ;this is a lable
DB: 03H,05H

i stored 03H and 05H in code memory using directive DB (define byte).
to use these values or to read them from lookup table we use MOVC instruction as shown below..

CLR A ;clear A
MOV DPTR,#LookUp ;load address from lable
MOVC A,@A+DPTR ;load data from address pointed by A+DPTR
;remember its good to have A as 0 before reading from lookup table and increment DPTR for next value
Wed Jul 15 2009, 12:20 PM
[Topic moved to 8051 Discussion forum]
Thu Jul 16 2009, 03:31 AM
Thanks for all your help in this topic. :-)

I am using assembly language. (FX8031 kits). :-)

Start:  CLR     P1.0
        CLR     P0.0
        CLR     A
        MOV     TMOD,#11H
        MOV     TCON,#01H
        MOV     IE,#082H

        MOV     DPTR,#LookUp
        MOVC    A,@A+DPTR
        MOV     R2,A
        INC     DPTR
        MOVC    A,@A+DPTR

        SUBB    A,R2
        JC      BIGGER
        JNC     SMALLER
        SJMP    EQUAL

        CALL    DELAY_20MS
        CLR     P0.0


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

[ Edited Thu Jul 16 2009, 04:41 AM ]

Get Social


Powered by e107 Forum System


Wed Nov 08 2017, 01:35 PM
Anirudh jain
I want to burn code in atmel 89s51 24pc 0329 but cannot get the connection with the burner. Can somebody provide me with the circuit diagram for connecting controller to burner. I'm using usb burner
Thu Nov 02 2017, 11:44 AM
write a program to exchange the content of b register with external RAM address 02CFH help me
Wed Nov 01 2017, 05:47 PM
i am using the DHT11 but i'm getting some errors in the simulate the programe in proteus 8 professional,: 1)cannot find model file 'DHTXX.MDF'.2)simulation failed due to netlist linker error(s).
Fri Sep 29 2017, 02:45 AM
i am doing the same project on verilog please contact me [email protected]
Wed Sep 20 2017, 12:36 AM
In a missing pulse detector using a 555 timer connected as a monostable vibrator with a PNP transistor,how does the positve input pulse turn on the PNP transistor?
Sun Sep 03 2017, 02:29 PM
How do I connect an <NOKIA 1100 LCD > to an atmega328P ?
Sun Aug 20 2017, 10:23 AM
i am intending to interface sd card with STM32F4 and want to write a file in sd card using SPI protocol but using HAL only. Can anyone help me PLEASE!!!!
Sun Aug 20 2017, 10:22 AM
Fri Aug 18 2017, 11:37 AM
hi @ angel patel i will attach a file i hope it will be helpfull for you
Mon Aug 14 2017, 09:57 PM
@ angel patel... just log in and post your problem



Mon Nov 20 2017, 07:40 PM
Sun Nov 19 2017, 07:34 PM
Wed Nov 15 2017, 10:46 AM
Sat Nov 11 2017, 03:43 AM
Fri Nov 10 2017, 06:53 AM
Wed Nov 08 2017, 05:27 PM
Tue Nov 07 2017, 09:08 AM
Sat Nov 04 2017, 10:46 PM


Guests: 53, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37918
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Nov 20 2017, 10:18 PM
Here is a version of the tutorial that reads a key...
Ansh12 Avatar
Posted By Ansh12
Mon Nov 20 2017, 02:15 AM
As a starting point, can you tell us how much of t...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Nov 19 2017, 08:35 PM
As a starting point, can you tell us how much of t...
Ansh12 Avatar
Posted By Ansh12
Fri Nov 17 2017, 04:07 AM
I am looking keypad interfacing program. I was rea...
JardCrocker Avatar
Posted By JardCrocker
Wed Nov 08 2017, 05:29 PM
Hi...i am a new user here. I was also facing the s...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 07 2017, 07:13 PM
> It employs a fairly advanced technique to detect...
vivitern Avatar
Posted By vivitern
Tue Nov 07 2017, 09:33 AM
I own a used Clavia ddrum4 SE drum module. It empl...
bvdb Avatar
Posted By bvdb
Wed Oct 18 2017, 01:50 AM
I purchased the RKitL51 8051 C compiler from Raiso...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Oct 16 2017, 11:44 PM
That looks complicated.Is 8051_BLK a standard 80...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Oct 15 2017, 07:29 PM
According to this, gmail should support POP3.https...