Autor Tema: Problemas con Computed Goto en PIC 18F  (Leído 2038 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado BrunoF

  • Administrador
  • DsPIC30
  • *******
  • Mensajes: 3865
Problemas con Computed Goto en PIC 18F
« en: 13 de Diciembre de 2009, 14:21:09 »
Hola gente!

Bueno, me estoy encontrando frente a un problema el cual creo alguuuna vez he leido algo, pero ahora no se donde fue...

Estoy intentando hacer un computed goto de la siguiente manera:

Código: ASM
  1. BEGIN_LOW
  2.         rlncf   Aux2,W          ;multiply OCPODE per 2
  3.         addwf   PCL,F
  4.         goto    OP00                    ;OP =
  5.         goto    OP01                    ;OP =
  6.         ...        
  7.         ...

Pero no me funciono bien.  El problema saltó de inmediato al mirar el código que genera el MPASM:
Código: ASM
  1. 346:   BEGIN_LOW
  2.   007E    456C     RLNCF 0x6c, W, BANKED          347:          rlncf   Aux2,W          ;multiply OCPODE per 2
  3.   0080    26F9     ADDWF 0xff9, F, ACCESS         348:          addwf   PCL,F
  4.   0082    EF09     GOTO 0x612                     349:          goto    OP00                    ;OP =
  5.   0084    F003     NOP
  6.   0086    EFBC     GOTO 0x978                     350:          goto    OP01                    ;OP =
  7.   0088    F004     NOP

Como pueden ver, el MPASM al ensamblar, agrega un NOP despues de cada GOTO.

No pude encontrar explicacion alguna en el datasheet.

Si el GOTO es una instruccion que ocupa 2 Words como el resto, no encuentro explicación de por qué me agrega un NOP a continuación de cada uno.
¿Está impuesto por la arquitectura?¿O es una opción del MPASM que puede deshabilitarse?

Gracias a quien puedan ayudarme.
"All of the books in the world contain no more information than is broadcast as video in a single large American city in a single year. Not all bits have equal value."  -- Carl Sagan

Sólo responderé a mensajes personales, por asuntos personales. El resto de las consultas DEBEN ser escritas en el foro público. Gracias.

Desconectado Nocturno

  • Administrador
  • DsPIC33
  • *******
  • Mensajes: 18286
    • MicroPIC
Re: Problemas con Computed Goto en PIC 18F
« Respuesta #1 en: 13 de Diciembre de 2009, 14:54:20 »
5.2.4 TWO-WORD INSTRUCTIONS
The standard PIC18 instruction set has four two-word
instructions: CALL, MOVFF, GOTO and LSFR. In all
cases, the second word of the instructions always has
‘1111’ as its four Most Significant bits; the other 12 bits
are literal data, usually a data memory address.
The use of ‘1111’ in the 4 MSbs of an instruction
specifies a special form of NOP. If the instruction is
executed in proper sequence, immediately after the
first word, the data in the second word is accessed and
used by the instruction sequence. If the first word is
skipped for some reason and the second word is
executed by itself, a NOP is executed instead. This is
necessary for cases when the two-word instruction is
preceded by a conditional instruction that changes the
PC. Example 5-4 shows how this works

Desconectado BrunoF

  • Administrador
  • DsPIC30
  • *******
  • Mensajes: 3865
Re: Problemas con Computed Goto en PIC 18F
« Respuesta #2 en: 13 de Diciembre de 2009, 15:05:32 »
Ufff gracias Mano.

Ya había visto eso. Creo que estaba perturbado, pero gracias a ti, releer ese párrafo puede que haya sido mi salvación.

O sea que tengo que multiplicar por 4 para poder saltar correctamente... :rolleyes:
« Última modificación: 13 de Diciembre de 2009, 21:36:14 por BrunoF »
"All of the books in the world contain no more information than is broadcast as video in a single large American city in a single year. Not all bits have equal value."  -- Carl Sagan

Sólo responderé a mensajes personales, por asuntos personales. El resto de las consultas DEBEN ser escritas en el foro público. Gracias.