Assembly Language
Assembly Language
Language
• Programming language
– Assembly
– C
– Python
– Java
• Analytics
– R language
– S language
• Web services
– Java
– Html
– Php
• Mobile application development
– Java
Embedded systems
• Computers used as part of a larger system
– That usually doesn’t look like a computer
– That usually controls physical devices
• Often reliability is critical
• Often resources (memory, processor capacity) are limited
• Often real-time response is essential
• What are we talking about? • Fuel injector controls
– Assembly line quality monitors • Medical equipment monitors
– Bar code readers • PDAs
– Bread machines • Printer controllers
– Cameras • Sound systems
– Car assembly robots • Rice cookers
– Cell phones • Telephone switches
– Centrifuge controllers • Water pump controllers
– CD players • Welding machines
– Disk drive controllers • Windmills
– “Smart card” processors • Wrist watches
• Often there are plenty of resources to handle the common cases
– But crises happen and must be handled
• Predictability is key
• Correctness is even more important than usual
– “correctness” is not an abstract concept
– “but I assumed that the hardware worked correctly” is no excuse
• Over a long time and over a large range of conditions, it simply doesn’t
Embedded systems programming
• You (usually) have to be much more aware of the resources consumed
in embedded systems programming than you have to in “ordinary”
programs
– Time
– Space
– Communication channels
– Files
– ROM (Read-Only Memory)
– Flash memory
– …
• You must take the time to learn about the way your language features
are implemented for a particular platform
– Hardware
– Operating system
– Libraries
• A lot of this kind of programming is
– Looking at specialized features of an RTOS (Real Time Operating
System)
– Using a “Non-hosted environment” (that’s one way of saying “a
language right on top of hardware without an operating system”)
– Involving (sometimes complex) device driver architectures
– Dealing directly with hardware device interfaces
– …
• We won’t go into details here
– That’s what specific courses and manuals are for
Introduction
Levels of Programming Languages
• Machine Language
– Consists of individual instructions that will be executed by the CPU one at a time
• Assembly Language (Low Level Language)
– Designed for a specific family of processors (different processor groups/family has
different instruction set)
– Consists of symbolic instructions directly related to machine language instructions
one-for-one and are assembled into machine language.
• High Level Languages
– e.g. : C, C++ and Vbasic
– Designed to eliminate the technicalities of a particular computer.
– Statements compiled in a high level language typically generate many low-level
instructions.
Assembly Languages
…
add r1,r2
sub r2,r3
PC cmp r3,r4 Memory
ALU Registers
bne I1
sub r4,1
I1: jmp I3
…
Statements
• Syntax:
operation operand(s) comments
– comment are optional
– Number of operands depend on the instruction
– One statement per line
• At least one blank or tab character must separate the field.
ADD R1, R3
Opcode Operands
What to do with Where to get
the data data and put
(ALU operation) the results
Types of Opcodes
• Arithmetic, logical:
– ADD, SUB, MULT
– AND, Or
– CMP
• Memory load/store:
– LOAD, ST
• Control transfer:
– JMP
• Complex:
– MOV
Operands
• Each operand taken from a particular addressing mode:
• Examples:
Register ADD r1, r2, r3
Immediate ADD r1, r2, #10H
Register Indirect MOV r1, (r2)
Indirect MOV r1, @10H
DX 0001 0001
INC & DEC
• INC (increment) instruction is used to add 1 to the contents of a register or
memory location.
– Syntax: INC destination
– Example: INC WORD1
Before After
WORD1 0002 0003
DEC BYTE1
Before After
BYTE1 FFFE FFFD
Advantages of Assembly Language
• Assembly language is easier to understand and use as
compared to machine language.
• It is easy to locate and correct errors.
• It is easier to correct errors and modify program
instructions.
• It can access machine-dependent registers and I/O.
Disadvantages Assembly Language
• It is that assembly language is machine dependent.
• A program written for one computer might not run in other
computers with different hardware configuration.
• It is long and tedious to write initially.
• Code can be fairly difficult to understand and modify, i.e. to
maintain.
Application of Assembly Language