Alex,
I’ve been interested in that as well. I understand the concept and the table part of the lists are pretty self explanatory, but I don’t know enough assembler to be able to work it into the places I would want it in Thorsten’s code.
I started with a book by Square 1 electronics called “Easy Microcontrol’n”. It goes very briefly into a simple lookup table for assigning different 8 bit binary values to the anodes of a common cathode 7-segment digit display. My sister just got me the “Programming and Customizing PIC uC’s” book by Myke Predko, so maybe there’s better info in that. If I find anything good, I’ll bring a link back to this thread.
Here’s most of the “baby” table from the book. Sorry if it’s stuff you already know, but maybe someone else can use it. It’s also directly loading the outputs with the eight ones and zeros for each table item, so it’s a heck of a lot simpler than trying to link the items to individual “snapshot” type functions or MIDI messages.
-----Basic header junk snipped, including an equate for the program counter’s address in this particular chip (0x02), and the assignment of all outputs to portb (the 7-segment display).
-----the code (they’re trying to send a number “2” to the display) –
char    movlw  0x02
       call    segmnt
       movwf  portb
;
segmnt  addwf  pc, f
        retlw   0x3f
        retlw   0x06
        retlw   0x5b
        retlw   0x4f
        retlw   0x66
        end   ; I skipped the remainder of the table
------------------------------------- and here it is with comments and formatting that would flip MPASM like a Mario Bros. turtle ;D ---->
char movlw 0x02 Â
; That’s actually the “2nd” item in the table list (table item could be anything, and has no connection to the “2” you’re trying to display). Don’t know why they gave this area a label, or why they foolishly chose an example number which looks just like the program counter’s address either. The number lands in the work register.
call segmnt  Â
; The routine which uses the work register’s contents as the offset from the start of the table list (starting at zero), and loads the work register with the binary data (in hex here) which you wish to display. The program counter holds the current location in the code, so once you jump into the table, whatever offset you have in the work reg. will take you to that number of lines beyond the start of the table, jumping over any previous items. The table items in this example are all retlw instructions, so right after they load the work reg., they’ll leave the segmnt routine and jump back to where you were when you called it, but with new work reg. contents (you won’t hit any subsequent table items).
movwf portb Â
; After returning from the segment routine with a new hex number in the work reg., it dumps the contents into the lights at portb.
segment addwf pc,f Â
; The “segmnt” routine adds the work reg. offset (0x02 here) to the start of the program counter, which will begin at the table below.
      Â
retlw  0x3f  ; Start of the table. This is the first (no offset) item. Sends back a hex 3f to light up a “0”. (0011 1111)
retlw  0x06 ; If given an offest of one, it would come back with 0x06 to display a “1”
retlw  0x5b ; Offset of two (the example offset). Displays 0101 1011 (a number 2)
retlw  0x4f ; Gives you a number four, blah, blah, blah (5 more table items for the numbers 5-9)
– If there are any errors in those descriptions, feel free to correct them.
Hope that helps somebody, and please put any good info links here for us.
               -George Â
Â