Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help with routine inc / dec in ASM 16 bit PIC16f877

Status
Not open for further replies.

aless2056

Member level 1
Member level 1
Joined
May 11, 2020
Messages
37
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
338
Guys, I made this code in asm for a PIC 16F877 that decreases Value (high and low) to 0x00 and increases to 0x64. Does anyone see something wrong with this code, or do you think it could be improved?

Code:
DEC

    MOVF    VALUE_HIGH,W
    SUBLW    B'00000000'
    BTFSS    STATUS,C
    GOTO    DC_DEC
    MOVF    VALUE_LOW,W
    SUBLW    B'00000000'
    BTFSC    STATUS,C
    GOTO    EXIT

DC_DEC
    DECF    VALUE_LOW,F
    MOVLW    .255
    XORWF    VALUE_LOW,W
    BTFSC    STATUS,Z
    DECF    VALUE_HIGH,F
    GOTO    EXIT




INC

    MOVLW    B'00000011'
    SUBWF    VALUE_HIGH,W
    BTFSS    STATUS,C
    GOTO    DC_INC
    MOVLW    B'11101000'
    SUBWF    VALUE_LOW,W
    BTFSC    STATUS,C
    GOTO    EXIT

DC_INC
    INCF    VALUE_LOW,F
    BTFSC    STATUS,Z
    INCF    VALUE_HIGH,F
    GOTO    EXIT
 
Last edited by a moderator:

Hi,

I'm not familiar with PIC and the ASM instructions.

But usually one starts with the LOW byte ... and in case of Carry one processes the HIGH byte.
With your solution it seems to be the other way around. Don't know if it's right or wrong.

Don't know what you do with the values 0b00000000, 0b00000011, 0b11101000 .... they don't match your text.

What about drawing a flow chart?
What about running a real world test or simulation?

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top