what language? pic16f877a

Discussion in 'Embedded Systems and Microcontrollers' started by thePHAN, Jun 4, 2011.

  1. thePHAN

    Thread Starter New Member

    May 30, 2011
    i just started doing pic and i understand its language and all but i never new what the language name is

    CLRF PORTC ; Turn Off All Segments and Digits
    MOVF LEFT_DIGIT2,W ; Get Left2’s Segments

    what language is this im using mplab
  2. mik3

    Senior Member

    Feb 4, 2008
    This is assembly.
  3. thePHAN

    Thread Starter New Member

    May 30, 2011
    i knew it was called assembly but i thought it would've had a branch hahahahhaa like how c is different from c# c++ thought this would've had a specific name to. Also is all assembly language the same or does it depend on your pic to?
  4. Barnaby Walters


    Mar 2, 2011
    Generally, each 'family' of PICs will have their own version of asm. For example, the 12F family has 35 instructions, as do the 16F (although I think some of the might be different… Don't quote me on that, I haven't checked). The 18F family has quite a few more instructions, some of which are specific to PIC hardware (E.G. Multiply instructions).

    What's more, each PIC has different SFRs, and different features to get your head round!

  5. debjit625

    Well-Known Member

    Apr 17, 2010
    mik3 is correct but to be more specific you can call this PIC assembly.

    No, different microcontrollers have different machine instruction or op-code which we call assembly. Machine instructions or op-codes are in binary like “000111001” ,normally working with binary will be a lot messier if you have hundreds of instruction so we represent these binary code in our own language (English) and call it assembly ,each assembly instruction represent a single machine instruction or op-code like for example “CLRF PORTB” in binary “00110011110101”.

    Microchip provides a vast range of microcontrollers known as PIC, and they understand a specific set of op-code or machine instructions which could be called as PIC assembly.

    Like Microchip other companies also provide different types of microcontrollers, which understand different type of machine instructions, like Atmel provide some 8051 architecture microcontrollers, their assembly language is known as 8051 assembly, right know I am writing form a PC having Intel P4 which understand a different type of machine instructions which we called x86 or x86 assembly.

    Good Luck
  6. atferrari

    AAC Fanatic!

    Jan 6, 2004
    By the way, WHAT language is that?
  7. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    MPLAB is the IDE (Integrated Development Enviroment), and MPASM is the assembler (tool). You can use other tools in MPLAB so you are not limited to just assembler.

    And.... MPASM doesn't have a branch like you want. You have to code for one!

    The only branch instruction is "GOTO <label>" which will always do the jump.

    To make a conditional jump you need to use either the "btfss" or "btfsc" instructions. These stand for "Bit Test f, Skip if Set" and "Bit Test f, Skip if Clear." The "Skip" is the next instruction.

    Here's how to use that. Say you want to jump when you get an answer of zero for something. This is going to set the "Z" bit (zero flag) in the STATUS register, so you don't do the jump (skip) when the Z flag is clear (not zero).

    <do something>
    btfsc STATUS
    goto Somewhere ; jump when the result was zero
    ; you drop thru here when the result was not zero

    Yeah, it is confusing but it is all you have. My brain refuses to get this correct so I make myself a macro to code the jumps for me (but that is another thread).

    At least there are only 33 instruction defined in Section 15.0 INSTRUCTION SET SUMMARY in the device data sheet. You need to be very familiar with these.
  8. John P

    AAC Fanatic!

    Oct 14, 2008
    That's the benefit of a high-level language (like C). No matter what the crazy characteristics of the processor are, the language makes it all logical and consistent. Though you do have to allow for the fact that the processor may have special features that need to be dealt with in non-standard ways. And if you feel you need to, you also have the option to cheat somewhat by writing your code in ways that encourage the compiler to give you more efficient results. But in general, C would keep you away from the processor's native language.
    Last edited: Jun 8, 2011