Menu

Asm opcode unknown

Gigi
2025-01-13
2025-01-17
  • Gigi

    Gigi - 2025-01-13

    I'm trying to use some code written in ASM which contains strange opcode.
    It's about :
    PIC16F88
    ;-----------------------
    ; Q1 * COEFF
    ; moltiplicatore
    MOVFW Q_UNO ;MOVLW 0X02

    MOVFW does not work with GCB, while compiling correctly with MICROCHIP ASM.
    It seems that it is possible to replace with: MOVLW Q_UNO ;
    Can you confirm that this is correct?

     

    Last edit: Gigi 2025-01-13
  • Anobium

    Anobium - 2025-01-13

    I would need see the a little more context. Chip? The ASM?

     
  • Chris Roper

    Chris Roper - 2025-01-13

    I am a bit rusty but I think the ASM as code reads as follows:

    Read a byte from a memory location with the label Q_UNO into the W Register
    Write the W register to Memory location 0x02.

    So all you are doing is copying a Byte Value from one location to another.

    I am hesitant as I am not 100% sure about the MOVLW mnemonic.
    Is it possibly a relative address as opposed to MOVWF?

     

    Last edit: Chris Roper 2025-01-13
  • Gigi

    Gigi - 2025-01-13

    It is a CTSS tone recognition algorithm with adc, a little complicated comments in Italian.
    PIC16F88

     
  • Chris Roper

    Chris Roper - 2025-01-13

    Just dusted off my ASM knowledge.

    MOVWL is the simplest form or Move as the value is Literal
    So MOVLW 0X02 Loads the Value 0x02 (00000010) into the W register.
    MOVFW 0x02 would load the value at address 0x02 into the W register.

    But I am no closer to solving your problem and I can't read Italian, other than a Restaurant Menu ;>)

     

    Last edit: Chris Roper 2025-01-13
  • Anobium

    Anobium - 2025-01-13

    Where is the port to GCB ? The ASM will not compile in GCBASIC but I am sure you have ported.

     
  • Gigi

    Gigi - 2025-01-13

    I'm working on it, but going step by step, I'll leave most of it written in ASM otherwise the timing doesn't allow for alternatives.
    So I have to fix MOVFW which is not accepted by GCB.

     
    • Anobium

      Anobium - 2025-01-13

      So, what is the target chip?

      Before I explain re MOVFW support.

       
  • Gigi

    Gigi - 2025-01-13

    Always the PIC16F88, if GCB can't digest MOVFW I have to abandon.

     
  • Gigi

    Gigi - 2025-01-13

    Searching I found the solution:
    MOVFW adr = MOVF adr,W

    Is it possible to create a macro or do I have to replace everything by hand?

     
    • Anobium

      Anobium - 2025-01-13

      Macro MOVFW ( in adr )
      MOVF adr, W
      End macro

       
  • Anobium

    Anobium - 2025-01-13

    Well I cannot resolve without some source.

    I think this is doable. We have to update the chip family description.

    Try this

    Edit CHIPDATA\CORE14.DAT, add the following after the MOVWF f; 1; 00 0000 1fff ffff

    MOVFW f; 1; 00 0000 1fff ffff

    Evan

     
  • Anobium

    Anobium - 2025-01-13

    Change the CORE file. I do not think that macro works as you expect.

    If you inspect the LST file from MPASM and GCASM, after the CORE change - is it the same instruction?

    The CORE binary value has to match the MPASM description. I may have this incorrect.

     

    Last edit: Anobium 2025-01-13
  • Anobium

    Anobium - 2025-01-13

    Hold on.... where is MOVFW in the 16F88 datasheet? It may be part of ASM but it needs to be valid. So, it should not be in CORE16.DAT

    Yes, MOVFW (Move F to W) is supported on the PIC16F88. It's one of the basic data movement instructions available in the PIC16F88's instruction set.

    However, it's worth noting that in the PIC16F88's documentation and most PIC assembly language contexts, this instruction is typically written as "MOVF f,W" rather than "MOVFW". They are functionally identical - both move data from a file register to the W register.
    The syntax would be:

    MOVF f,W ; Move contents of register f to W

    This is because MOVF is a more versatile instruction that can move data either:

    • From register to W (MOVF f,W)
    • Or back to the same register (MOVF f,F) which is useful for testing a register's value

    So while the operation you want (moving from F to W) is definitely supported on the PIC16F88, you'll want to use the MOVF f,W syntax in your code for this microcontroller.

    Change them all.

     
  • Gigi

    Gigi - 2025-01-13

    Yes, now I'll do some testing, I prefer the macro if it works without modifying the CORE FILE (it always scares me to touch something that has always worked well).

    Surely there will still be something that causes problems and I will still need help with the .gcb file
    Thank you

     
  • Gigi

    Gigi - 2025-01-13

    The macro works perfectly, generated hex is the same trying both opcodes.

     
    • Anobium

      Anobium - 2025-01-13

      Excellent!!!

       
  • Gigi

    Gigi - 2025-01-13

    This is the result, from the GCB file everything seems fine, I have doubts about the variables, but I will have to try it in the real world, do you have any advice?

     
    • Anobium

      Anobium - 2025-01-14

      I would revise the memeory allocation of all the variables to the same assignment as in the original ASM. The issue that would concern is that the page addressing is non existent and the original ASM made assumptions about the addresses.

      So, use Dim myVar as Byte at 0x20 - for the variables. The source of the address is the CBLOCK.


      You MUST remove the RETFIE from the Interrupt routine. The Interrupt routine is exiting half way thru the GCBASIC interrupt handler. The state of the restored registers in currently incorrect.


       

      Last edit: Anobium 2025-01-14
  • Gigi

    Gigi - 2025-01-17

    Unfortunately, after various tests I saw that some registers are modified which are probably used by GCB and many parts would have to be rewritten and this is not convenient.

     
    • Anobium

      Anobium - 2025-01-17

      The ASM is actaully very simple. It is doing some maths ( badly ) makes a lot assumptions about memory and paging. I am not surprised it does not work.

      Rewrite in GCBASIC to make it portable. :-)

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.