Origin of Assembly Table


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2010
    Posts
    11

    Default Origin of Assembly Table

    I am working on a PID controller that also does the quadrature decoding of an optical encoder (which I made tehehe). I have it basically working using assembly interrupts.

    The basic operation is to get the current encoder channels and the encoder channels from the last interrupt (interrupt on change of pin value) into one byte, which goes from 0-15 (I make sure to clear the 4 MSB bits).Then it uses a lookup table (In assembly, consisting of a PCL addition to a GOTO branch) to determine what this code means. I know it'd be faster to shift my index left by 1 or 2 places, and then have the necessary instructions on 2 or 4 lines. However, I'm not there yet.

    My main concern is that right now, I put my interrupt service routine as close the top of the code as possible, w/the table near the top of the interrupt service routine. I do this because I want the PCL to have a value that is less than 255-15, so that when I add to it jumps to the right place. According to AN556 from Microchip (http://www.engr.usask.ca/classes/EE/331/AN556.pdf) standard practice is to put an "org [address]" at the beginning of a table. What I can't figure out, even after searching quite a bit, is what is a good value for this? I've played around with it a bit, but it either doesn't compile because the address interferes w/PBP code, or crashes my code.

    Where can I determine a good value for the ORG of my table? Also, I know that the interrupt service routine needs to be near the top, is this because it has to be on the first page?

    I'm a bit confused about these pages and stuff. What's the best way to attach code?

    Please advise.

    Thanks,
    Matt
    Last edited by dksoba; - 8th February 2010 at 02:52.

  2. #2
    Join Date
    Feb 2010
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Here is the code:

    http://pastebin.com/f3d55f851

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink

    Hi, Matt

    You have two solutions ...Using PBP ...


    1) Use a Lookup table ... PBP will care of all the adresses.

    2) Using an assembler retrieve table

    Code:
    	
    peekcode ( 850 + sampled ), delay		' 881 = 850 + 31 !!!
    
    .
    .
    
    END
    
    '*****************************************************************************
    'Fading_Table
    '*****************************************************************************
    '         			 0   1   2   3   4   5   6   7   8   9  
    '
    Pokecode @881,		             24, 27, 29, 32, 35, 38, 41, 44, 47,_	'  30
             			 50, 54, 57, 60, 64, 68, 71, 75, 79, 83,_	'  40
             			 87, 91, 96,100,104,109,113,118,123,127,_	'  50
             			132,137,142,147,153,158,163,169,174,180,_	'  60
             			186,191,197,203,209,212,217,245,250,  1,_	'  70
             			  7, 13, 21, 30, 39, 48, 57, 24, 25, 26,_	'  80
             			 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,_	'  90
             			 37, 38, 39, 40, 41, 43, 44, 45, 46, 48,_	' 100
             			 49, 50, 52, 53, 54, 56, 57, 59, 60, 62,_	' 110
             			 63, 65, 67, 68, 70, 72, 73, 75, 77, 79,_	' 120
             			 81, 83, 84, 86, 88, 90, 92, 94, 97, 99,_	' 130
             			101,103,105,107,110,112,114,117,119,122,_	' 140
             			124,126,129,132,134,137,139,142,145,148,_	' 150
             			150,153,156,159,162,165,168,172,176,180	        ' 160
    		     	     
     END
    Note, for me , the " sampled " value was from 31 to ... a lot !!!

    Here , the best is to compile @ first using the Highest adresses of the Prog memory, to see where the program ends, and then shift the table adress to lower adresses.

    Here, I have 140 values, so, first compile has been made with Pokecode @ 860 ( leaving little room for the END statement ! - was a 12F675 )

    The MPLAB Program window, here is a GREAT help ...


    some months after that ... I've added as much program lines as possible ... this explains my table is @ the very top memory adresses available. ( 1022/1024 lines occupied ...)

    Alain
    Last edited by Acetronics2; - 8th February 2010 at 12:44.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile As Mister_e says...

    Hi Matt, Welcome to the PBP forum.
    Quote Originally Posted by dksoba View Post
    <snip>...
    I'm a bit confused about these pages and stuff. What's the best way to attach code?
    Please advise.

    Thanks,
    Matt
    http://www.picbasic.co.uk/forum/misc.php?do=bbcode

    As Mister_e says:
    [ code] paste your code here [/code ] leave out the spaces inside the [/code ] tags

  5. #5
    Join Date
    Feb 2010
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Matt

    You have two solutions ...Using PBP ...
    My interrupt is an assembly interrupt, so I can't have PBP code there... right?

    Matt

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default

    Hi, Matt

    Its no problem ... the method is the same ...

    in assembler NOW ...

    Code:
      Line    Address    Opcode        Label                  Disassembly           
    
        805     324       3052   Z000A7            MOVLW 0x52                       
        806     325       0744                     ADDWF _Sampled, W                
        807     326       00B8                     MOVWF 0x38                       
        808     327       3003                     MOVLW 0x3                        
        809     328       1803                     BTFSC STATUS, 0                  
        810     329       3E01                     ADDLW 0x1                        
        811     32A       00B9                     MOVWF 0x39                       
        812     32B       0838                     MOVF 0x38, W                     
        813     32C       00B0                     MOVWF R8                         
        814     32D       0839                     MOVF 0x39, W                     
        815     32E       00B1                     MOVWF 0x31                       
        816     32F       20B6                     CALL JUMPMAN                     
        817     330       00BD                     MOVWF delay                      
       .
       .
       .
       .
               
        879     36E       3FFF                                                      
        880     36F       3FFF                                                      
        881     370       3FFF                                                      
        882     371       3418                     RETLW 0x18          ; jumpman label here ..             
        883     372       341B                     RETLW 0x1b                       
        884     373       341D                     RETLW 0x1d                       
        885     374       3420                     RETLW 0x20                       
        886     375       3423                     RETLW 0x23                       
        887     376       3426                     RETLW 0x26                       
        888     377       3429                     RETLW 0x29                       
        889     378       342C                     RETLW 0x2c                       
        
    ...
             
        991     3DE       3465                     RETLW 0x65                       
        992     3DF       3467                     RETLW 0x67                       
        993     3E0       3469                     RETLW 0x69                       
        994     3E1       346B                     RETLW 0x6b                       
        995     3E2       346E                     RETLW 0x6e                       
        996     3E3       3470                     RETLW 0x70                       
        997     3E4       3472                     RETLW 0x72                       
        998     3E5       3475                     RETLW 0x75                       
        999     3E6       3477                     RETLW 0x77                       
       1000     3E7       347A                     RETLW 0x7a                       
       1001     3E8       347C                     RETLW 0x7c                       
       1002     3E9       347E                     RETLW 0x7e                       
       1003     3EA       3481                     RETLW 0x81                       
       1004     3EB       3484                     RETLW 0x84                       
       1005     3EC       3486                     RETLW 0x86                       
       1006     3ED       3489                     RETLW 0x89                       
       1007     3EE       348B                     RETLW 0x8b                       
       1008     3EF       348E                     RETLW 0x8e                       
       1009     3F0       3491                     RETLW 0x91                       
       1010     3F1       3494                     RETLW 0x94                       
       1011     3F2       3496                     RETLW 0x96                       
       1012     3F3       3499                     RETLW 0x99                       
       1013     3F4       349C                     RETLW 0x9c                       
       1014     3F5       349F                     RETLW 0x9f                       
       1015     3F6       34A2                     RETLW 0xa2                       
       1016     3F7       34A5                     RETLW 0xa5                       
       1017     3F8       34A8                     RETLW 0xa8                       
       1018     3F9       34AC                     RETLW 0xac                       
       1019     3FA       34B0                     RETLW 0xb0                       
       1020     3FB       34B4                     RETLW 0xb4                       
       1021     3FC       0063   Z000C3            SLEEP                            
       1022     3FD       2BFC                     GOTO Z000C3                      
       1023     3FE       3FFF                                                      
       1024     3FF       3FFF
    does it sound good now ???

    Note it's the straight Compiled PBP lines ... soooo , speed is " not so bad " don't you think ???

    so I can't have PBP code there... right?
    It's a very very good question, indeed ...

    But, If I tell you more ... Darrel will " blow a couple of fuses " ... LOL !

    Alain
    Last edited by Acetronics2; - 8th February 2010 at 19:40.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Lookup Table
    By yasser hassani in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 11th March 2008, 10:38
  2. Assembly Guru : Question
    By Archangel in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th May 2007, 03:51
  3. PIC 18F452 Table Pointer/ Table Read
    By sougata in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 14th March 2006, 03:07
  4. Writing to a table.
    By Rhatidbwoy in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 24th December 2005, 16:20
  5. How do you do this in Assembly
    By ice in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th May 2005, 06:47

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts