what language? pic16f877a

Thread Starter

thePHAN

Joined May 30, 2011
14
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
CLRF PORTB
MOVF LEFT_DIGIT2,W ; Get Left2’s Segments
MOVWF PORTB
BSF PORTC,2
CALL DELAY_5_MILLISECONDS

what language is this im using mplab
 

Thread Starter

thePHAN

Joined May 30, 2011
14
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?
 

Barnaby Walters

Joined Mar 2, 2011
102
Also is all assembly language the same or does it depend on your pic to?
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!

Thanks,
Barnaby
 

debjit625

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

Also is all assembly language the same or does it depend on your pic to?
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
 

ErnieM

Joined Apr 24, 2011
8,377
i knew it was called assembly but i thought it would've had a branch hahahahhaa
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.
 

John P

Joined Oct 14, 2008
2,026
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:
Top