HEX keypad table

Status
Not open for further replies.

smileguitar

New Member
Code:
Key_Table  		ADDWF   PCL, f
          		RETLW   0x43
        	    RETLW   0x42
         	  	RETLW   0x30
        	   	RETLW   0x41
       	    	RETLW   0x44
        	   	RETLW   0x39
         	  	RETLW   0x38
          	 	RETLW   0x37
         	  	RETLW   0x45
        	   	RETLW   0x36
        	   	RETLW   0x35
       	    	RETLW   0x34
        	   	RETLW   0x46
        	   	RETLW   0x33
         	  	RETLW   0x32
         	  	RETLW   0x31

Above is the HEX keypad (4X4) table. I've been read the explanation, but I'm not really understand. How can form the HEX table? How we know the address "0X30, 0X41, 0X44, 0X39....)?

Thanks in advance!
 

Those aren't addresses, they are values to be returned in W by the action of RETLW - the table is a jump table, and adds the value in W (0 to 15) to the PCL (program counter)
 
To add to Nigel's explanation, 0X43, 0X42, 0X30, 0X41, etc reside at the address pointed to by Key_Table+1, Key_Table+2, Key_Table+3, Key_Table+4, etc and are embedded in the RETLW instruction. PCL is equal to the address of Key_Table at the start of the routine posted above. So you don't really need to know where they are, just where they are relative to Key_Table. If you really want to know where they are in memory, choose VIEW/DISASSEMBLY LISTING in Mplab after compiling your code.
I'll save page boundary issues for another day.
 
Last edited:
Does it make more sense when it's like this,
Code:
Key_Table	ADDWF   PCL, f
		RETLW   'C'
		RETLW   'B'
		RETLW   '0'
		RETLW   'A'
		RETLW   'D'
		RETLW   '9'
		RETLW   '8'
		RETLW   '7'
		RETLW   'E'
		RETLW   '6'
		RETLW   '5'
		RETLW   '4'
		RETLW   'F'
		RETLW   '3'
		RETLW   '2'
		RETLW   '1'

As you can see it is the character that is on the actual key.

Mike.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…