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.

PIC assembly language library needed

Status
Not open for further replies.

comp_freak

Member level 1
Joined
Jan 19, 2006
Messages
40
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,687
PIC assembly library

I am using PIC16f877 for my project, previously i was used to assembly coding with motorola mcu,

however two do airthmatic operations add,sub for 16 bit number i usually do by two step

1) first do operation on lower byte, store the result
2) than do operation on upper byte, and store the result

however, one of expert told me for pic there exit libraries,which u can be used..according to him there should be a arithmatic library where all this airthmatic and logical expression for various bit such as 16,32 bits should be available.. if any of you knw where that library is located and how to use it..

i am really frustrated cuz i did about 1hr searchin on microchip website i couldnt find it. i knw library exists for C code,, but i have no clue about assembly language library .. some1 pls knw this stuff just give me some idea.. where to get that library
 

PIC assembly library

i used to use pic MC for more than 4 years, i don't know any thing about that liberary for assemply language, if you will program pic in assemply, don't wast your time and write you own routin
shafee
 

    comp_freak

    Points: 2
    Helpful Answer Positive Rating
PIC assembly library

I have such a library that I wrote. Here are the two macros from my library you require:

Code:
;Adds two integers together (int_c = int_a + int_b).
;An integer is a two byte number.
;int_aH:  the address of the high byte of the integer.  The low byte is assumed
; to be at the next address (int_aH+1) so that the integer is int_aH:int_aL.
;int_bH:  the address of the high byte of the integer.  The low byte is assumed
; to be at the next address (int_bH+1) so that the integer is int_bH:int_bL.
;int_cH:  the address of the high byte of the integer.  The low byte is assumed
; to be at the next address (int_cH+1) so that the integer is int_cH:int_cL.
; int_cH can be equal to int_aH or int_bH
;Affects WREG and STATUS
;------------------------------------------------------------------------------
INT_ADD macro int_aH, int_bH, int_cH
    local int_aL, int_bL, int_cL
    int_aL = int_aH+1
    int_bL = int_bH+1
    inc_cL = int_cH+1
    if int_aH == int_cH     ;Special case int_a = int_a + int_b
        movf int_bL, w
        addwf int_aL, f
        movf int_bH, w
        btfsc STATUS, C
            addlw 0x01
        addwf int_aH, f
    else
        if int_bH == int_cH ;Special case int_b = int_a + int_b
            movf int_aL, w
            addwf int_bL, f
            movf int_aH, w
            btfsc STATUS, C
                addlw 0x01
            addwf int_bH, f
        else
            movf int_aL, w
            addwf int_bL, w
            movwf int_cL
            movf int_aH, w
            btfsc STATUS, C
                addlw 0x01
            addwf int_bH, w
            movwf int_cH
        endif
    endif
	endm

;Subtracts two integers (int_c = int_a - int_b).
;An integer is a two byte number.
;int_aH:  the address of the high byte of the integer.  The low byte is assumed
; to be at the next address (int_aH+1) so that the integer is int_aH:int_aL.
;int_bH:  the address of the high byte of the integer.  The low byte is assumed
; to be at the next address (int_bH+1) so that the integer is int_bH:int_bL.
;int_cH:  the address of the high byte of the integer.  The low byte is assumed
; to be at the next address (int_cH+1) so that the integer is int_cH:int_cL.
; int_cH can be equal to int_aH or int_bH
;Affects WREG and STATUS
;------------------------------------------------------------------------------
INT_SUB macro int_aH, int_bH, int_cH
    local int_aL, int_bL, int_cL
    int_aL = int_aH+1
    int_bL = int_bH+1
    inc_cL = int_cH+1
    if int_aH == int_cH ;Special case int_a = int_a - int_b
        movf int_bL, w
        subwf int_aL, f
        movf int_bH, w
        btfss STATUS, C
            addlw 0x01
        subwf int_aH, f
    else
        movf int_bL, w
        subwf int_aL, w
        movwf int_cL
        movf int_bH, w
        btfss STATUS, C
            addlw 0x01
        subwf int_aH, w
        movwf int_cH
    endif
	endm

I do not think you have found these because it is trivial (8 instructions or less). I don't like writing the six or eight lines myself over and over, so I have these macros in an include file. Hope that helps. I have a few more libraries on my website. Also, www.piclist.com is a great pic assembly resource.

-jonathan
 

    comp_freak

    Points: 2
    Helpful Answer Positive Rating
Re: PIC assembly library

thanx a lot ... i m still working on it... if i find something new will let u update.....
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top