Author Topic: Microchip assembly language  (Read 11009 times)

0 Members and 2 Guests are viewing this topic.

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 628
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: Microchip assembly language
« Reply #25 on: July 31, 2016, 06:42:53 am »
I have one suggestion before you go. Using 'ADDWF PCL' is making your code more complicated than it needs to be. If you replace it with 'MOVWF PCL' then you don't need to calculate the offset between this instruction and the message address. You can also place it anywhere in your code (not necessarily in the table) like this:-

Code: [Select]
Tabla_Mensajes:
Mens_0    DT   "Hola",00
Mens_1    DT   "Adios",00
   .
   .
    MOVLW   Tabla_Mensajes
    MOVWF   PCLATH                           
   .
    movlw   Mens_0
    call    Mensaje
   .
   .
Mensaje       movwf   Temporal_1      ;Salva posición de la tabla
Mensaje_1     movf    Temporal_1,W    ;Recupera posición de la tabla
              call    Table_Read      ;Busca caracter de salida
              movwf   Temporal_2      ;Guarda el caracter
              movf    Temporal_2,F
              btfsc   STATUS,Z        ;Mira si es el último
              return
No_es_ultimo  call    LCD_DATO        ;Visualiza en el LCD
              incf    Temporal_1,F    ;Siguiente caracter
              goto    Mensaje_1

Table_Read    MOVWF PCL               ; jump to table   *** page address  in PCLATH ***
 

Offline Ata

  • Contributor
  • Posts: 19
  • Country: ve
Re: Microchip assembly language
« Reply #26 on: July 31, 2016, 12:02:48 pm »
Jcaser

Strange.... It compiles (no errors) using MPASM 5.64 from MPLABX IDE 3.15
All cases compile the same:

MOVLW   LOW(Tabla_mensajes)+1
MOVLW   LOW(Tabla_mensajes+1)
MOVLW   LOW Tabla_mensajes +1
movlw   low Tabla_mensajes+1

A portion of the LST generated:

MPASM 5.64                          TEST.ASM   7-31-2016  7:27:31         PAGE  2

LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00042  ;el acumulador. El fin de un mensaje se determina mediante el código 0x00
                      00043
001A   00A2   00044  Mensaje         movwf   Temporal_1      ;Salva posición de la tabla
                      00045     
001B   3006   00046         MOVLW   LOW(Tabla_mensajes)+1
001C   3006   00047         MOVLW   LOW (Tabla_mensajes)+1
001D   3006   00048         MOVLW   LOW(Tabla_mensajes +1)
001E   3006   00049         MOVLW   LOW (Tabla_mensajes +1)
001F   3006   00050         MOVLW   LOW Tabla_mensajes + 1
0020   3006   00051         movlw   low Tabla_mensajes+1
                      00052
0021   02A2   00053         SUBWF   Temporal_1,F
                      00054     
0022   0822   00055  Mensaje_1       movf    Temporal_1,W    ;Recupera posición de la tabla
                      00056     
                      00057     
0023   2005   00058                 call    Tabla_mensajes  ;Busca caracter de salida
0024   00A3   00059                 movwf   Temporal_2      ;Guarda el caracter
0025   08A3   00060                 movf    Temporal_2,F
0026   1D03   00061                 btfss   STATUS,Z        ;Mira si es el último
0027   2829   00062                 goto    No_es_ultimo
0028   0008   00063                 return
0029   0000   00064  No_es_ultimo    nop     ;call    LCD_DATO        ;Visualiza en el LCD
002A   0AA2   00065                 incf    Temporal_1,F    ;Siguiente caracter
002B   2822   00066                 goto    Mensaje_1

.............. Same result always.
Which MPASM are you using?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->