Introduction to Microchip PIC Assembler Language – Part 1

Microchip PIC Assembler Language

Learning the assembler language is one of the essential skills that still required in the embedded system, although the major drawback using the assembler language is; its required more learning curve time compared to the higher level language but once you acquainted with one type of microcontroller family such as 8-bit 8 pins Microchip PIC 12F683 then coding with assembly language to other type of PIC microcontroller families will be much easier. I’m choosing the PIC 12F683 type because it’s one of the best 8 pins Microchip PIC microcontroller with nanoWatt technology and supporting advanced peripherals such as 8-bit/16-bit TIMER, ADC (Analog Digital Converter), PWM (Pulse Width Modulation) and Comparator with 2K word of flash.Microchip PIC Assembler Language

We often hear that one of the reasons we are still coding in the assembly language is the speed and the small HEX code result, but this is not usually true, because some of high optimized industrial standard C compiler can produced more compact code than the average assembler programmer can do for some simple “if” condition statement. Therefore I will add one more important reason why we have to code in assembler language; …we are forced to use the assembly language because most of the average hobbyist could not effort to buy the industrial standard compiler for their project which use a microcontroller type that is not supported or limited supported (e.g. program size limit) by the higher level language free edition compiler; on the contrary all the microcontroller’s manufacture will certainly provide free assembler language compiler that support all of their product types.

But hey… let’s look at the bright side, we are going to learn the core of microcontroller language which gives us more deep understanding of how the microcontroller really works. So before we start with the exciting lessons, I would suggest that you could read the article Beginners AVR Assembler Language Programming 1 posted on this blog for some introduction to what is the assembler language. For the purpose of this tutorial I will assume that you are already familiar with higher level programming language such as C language.

Typical Microcontroller’s based project cycle is shown on the above picture, we will use this simple cycle for practicing our Microchip PIC assembly language skill through various experiments. Ok now let’s take a look at the circuit design for this tutorial:Schematic Microchip PIC Assembler Language

The Microchip PIC 12F683 has 6 general purpose I/O; GP0 to GP5, the above circuit is suitable for learning such as simple digital I/O up to the advanced topics such as using the PIC 12F683 ADC and PWM peripherals.

The Shopping Bag

For this tutorial you will need this following hardware and software:

1. Microchip PIC 12F683 PDIP microcontroller with the datasheet downloaded from Microchip site (
2. One breadboard or prototype board with an adequate amount of jumper
3. ¼ Watt resistor: 1K (2), 10K (1), 330 (1), 10K Trimport (1)
4. Capacitor: 100nF (1), 10nF (1)
5. One 3mm LED (Light Emitting Diode)
6. One 5 Volt regulated power supply or you could use 3 AA/AAA size alkaline battery for the project power source
7. Microchip PICKit2 programmer for downloading the HEX code
8. Microchip MPLAB IDE for coding, debugging and compiling the code; downloaded from Microchip site.

My first Assembly Program

“Hello World” one of the famous phrase introduced by Brian W. Kernighan and Dennis M. Ritchie on their famous book “The C Programming Language” when they first introduced this new programming language many years ago. As they said “the only way to learn a new programming language is by writing programs in it“. This is true, first time you don’t have to understand the code at all, but by writing the code by your self (I mean laterally not just cut and paste the code), compiling/simulating the code, downloading the code to the microcontroller and running the code you will get the excitement to learn further for having good understanding of the code you just wrote. Ok let’s write your first Hello World program, first open your Microchip MPLAB IDE application, from Project menu choose Project Wizard, after welcome screen you will get the device selection screen, choose the PIC12F683:

Read more: Introduction to Microchip PIC Assembler Language – Part 1

Leave a Comment

Your email address will not be published. Required fields are marked *