Top Banner
Assembly Language In Electronics
13

Assembly Language In Electronics

Apr 14, 2017

Download

Engineering

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Assembly Language In Electronics

Assembly Language In Electronics

Page 2: Assembly Language In Electronics

First Need To Know Why We Use Assembly Language In Electronics

When a human programmer develops a set of instructions to directly tell a microprocessor how to do something They’re programming in the CPU’s own “language” This language, which consists of the very same binary codes which the Control Unit inside the CPU chip decodes to perform tasks, is often referred to as machine language.

it is often written in hexadecimal form, because it is easier for human beings to work with. For example, I’ll present just a few of the common instruction codes for the Intel 8080 micro-processor chip.

Page 3: Assembly Language In Electronics

Hexadecimal Binary Instruction description

7B 01111011 Move contents of register A to register E

87 10000111 Add contents of register A to register E

1C 00011100 Increment the contents of register E by 1

D3 1101001 1 Output byte of data to data bus

Page 4: Assembly Language In Electronics

FLOW OF COMPILATION ASSEMBLY IN HARDWARE

Page 5: Assembly Language In Electronics

COMPILATION

Page 6: Assembly Language In Electronics

ASSEMBLY LANGUAGE

PROGRAMMING YOUR ROBOT

It is generally accepted that there are three types or levels of computer programming languages; Machine Code, Assembly Language and High level languages.

MACHINE CODE Machine code is the "Native" language of the CPU that is running the program. The

instructions are binary numbers composed on 8, 16 or more bits that when fed to the CPU provide Opcodes (What command is requested), (more information that specifies how much, or where information) Operands, and other information.

A small 8-bit machine code program might look something like this: 10001010

0110001110001101 11001111

As you can see, without the "Secret Decoder Ring" that comes with the CPU, this seems like gibberish and has no meaning. Also, remembering the sequences of ones and zeros as specific commands is close to impossible for our human minds. But, this is the language the CPU needs to see, so all of the languages below must be converted to machine code before they can run on a particular chip

Page 7: Assembly Language In Electronics

Assembly Language RoboT

Because of the difficulty in reading and remembering machine code, assembly code was invented to make commands more meaningful and readable to us humans. Here is a short assembly code program, similar to the assembly in the Motorola 68HC11 chip that adds the numbers 7 and 10 and stores the result in memory location 252. LDAA 07ADDA 0ASTAA 00 FCStop Translated, this is....

LDAA 07 = Load Accumulator A with the number 7 ADDA 0A = Add to accumulator A the number 10 (0A is hexadecimal for decimal 10) STAA 00 FC = Store what is in Accumulator A at memory location 00FC. Since the address bus in the 68HC11 is 16 bits, we need to specify a 16 bit address. The number 252 in 16 bit binary is 00000000 11111100, when converted to hex is 00FC. Stop = End the program

Page 8: Assembly Language In Electronics

MSP430 LAUNCHPAD FOR LINUX

The MSP-EXP430G2 Launchpad Development Kit is an easy-to-use microcontroller development board for the low-power and low-cost MSP430G2x MCUs. It has on-board emulation for programming and debugging and features a 14/20-pin DIP socket, on-board buttons and LEDs & Booster Pack Plug-in Module pinouts that support a wide range of modules for added functionality such as wireless, displays & more.

Page 9: Assembly Language In Electronics

Here are few example programs which I had done as a part of learning msp430 assembly language programming..(microcontroller used -> MSP430G2231)(assembler  used         ->naken430asm) 

To familiarize the assembly language programming, I did some basic codes and tested it in the launchpad. Those codes are below….

0xfffe is the reset vector address. When it resets, the program counter (PC/r0) is loaded with the 16 bit value in the reset vector address, ie here it will be loaded with the starting address of the program...Program memory of the msp430g2231 starts at 0xf800 and ends at 0xffff. 

TO TURN ON THE RED LED (P1.0) ON THE MSP430 LAUNCHPAD

Page 10: Assembly Language In Electronics

THOUGHT ASSEMBLY WAS A DEAD LANGUAGE, WHY WASTE THE TIME USE IT IN

ELECTRONICS ?

Though it's true, you probably won't find yourself writing your next customer's app in assembly, there is still much to gain from learning assembly. Today, assembly language is used primarily for direct hardware manipulation, access to specialized processor instructions, or to address critical performance issues. Typical uses are device drivers, low-level embedded systems, and real-time systems. The fact of the matter is, the more complex high level languages become, and the more ADT (abstract data types) that are written, the more overhead is incurred to support these options. In the instances of .NET, perhaps bloated MSIL. Imagine if you knew MSIL. This is where assembly language shines. (EDIT)Assembly language is as close to the processor as you can get as a programmer so a well designed algorithm is blazing -- assembly is great for speed optimization. It's all about performance and efficiency. Assembly language gives you complete control over the system's resources. 

Page 11: Assembly Language In Electronics

ADVANTAGE OR DISDVANGE USE IT IN ELECTRONICS

Advantage :-1.Very fast because of direct conversation from assembly language to binary 2.Direct access to hardware features e.g. embedded computers in home appliances

Disadvantage :-1.Low level language are difficult to learn 2.Lack of portability because assembly language is dependent on the make of processor

Page 12: Assembly Language In Electronics
Page 13: Assembly Language In Electronics

QUERIES