Help with some maths in assembly


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2009
    Location
    London
    Posts
    251

    Default Help with some maths in assembly

    Hi, I have this code which I am simulating using Proteus. I am running the PIC @ 4MHz so every instruction is 1uS.
    Now my code runs a delay routine 0-255 then inside that routine another routine runs 0-255. Total delay should be 255 x 255 = 65025 mS. But the delay is somewhere between 180-200mS region. Can someone explain why this is happening please? Thanks
    Code:
        PAGE0
        CLRF    PORTD
        CLRF    PORTB
        PAGE1
        CLRF    TRISD
        CLRF    TRISB
        PAGE0
        MOVLW    0
        MOVWF    COUNT1
        MOVWF    COUNT2
        MOVWF    COUNT3
        MOVWF    COUNT4
    
    
    MAIN
        BSF    RSET
        CALL    DELAY250
        BCF    RSET
        CALL    DELAY250
        MOVWF    COUNT1
        MOVWF    COUNT2
        GOTO    MAIN
    
    
    DELAY250
        CALL        DELAY500
        INCFSZ        COUNT1,f
        GOTO         DELAY250
        BCF        STATUS,Z
        RETURN
    DELAY500
        INCFSZ        COUNT2,f
        GOTO        DELAY500
        BCF        STATUS,Z
        RETURN
    
    
        END

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Help with some maths in assembly

    Start a new ASM project within MPLAB and run MPSIM... see what happen step by step..... then discover WHY it happen. I think you could also do it in Proteus...

    Checkout the Piclist as well
    http://www.piclist.com/techref/picli...egen/delay.htm
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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