Introduction To Assembly Language

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

INTRODUCTION

CHAPTER 1
OVERVIEW OF COMPUTER SYSTEMS

•A user‟s view of a computer system depends on the degree of abstraction


provided by the underlying software.
• At the highest level 5, the user interaction is limited to the interface
• At the level 4, problem solving is done in one of the high-level languages such
as C and Java
• Both levels 4 and 5 are system-independent, i.e., independent of a particular
processor used in the system
• By contrast, software development done at all levels below level 4 is system-
dependent.
OVERVIEW OF COMPUTER SYSTEMS
OVERVIEW OF COMPUTER SYSTEMS

• Assembly language programming is referred to as low-level programming


• Programming in the assembly language also requires knowledge about system
internal details such as the processor architecture, memory organization etc.
• Machine language in Level 2 is a close relative of the assembly language
• The processor understands only the machine language, whose instructions
consist of strings of 1‟s and 0‟s.
OVERVIEW OF COMPUTER SYSTEMS

• Our operating system hides several of the low-level details so that the
assembly language programmer can work easily
• System hardware, which consists of digital logic circuits and the associated
support electronics execute the machine language instructions.
CISC PROCESSOR

• CISC means Complex Instruction Set Computers


• CISC is a type of processor where single instructions can execute several low-
level operations (such as a load from memory, an arithmetic operation, and a
memory store) or are capable of multi-step operations or addressing modes
within single instructions. This makes the CISC instructions short but „complex‟.
• CISC processors were helpful in simplifying the code and making it shorter in
order to reduce the memory requirement.
CISC PROCESSOR

• Microprocessors and microcontrollers that have CISC architecture includes


Motorola 6800, 6809 and 68000-families; the Intel 8080, and x86-family;
Intel 8051-family.
• Advantages:
• The code size is comparatively shorter which minimizes the memory requirement.
• Execution of a single instruction accomplishes several low-level tasks.
• Complex addressing mode makes the memory access flexible.
• CISC instruction can directly access memory locations.
CISC PROCESSOR

• Disadvantages:
• Though the code size is minimized but it requires several clock cycles to execute a single
instruction. Thereby reduce the overall performance of the computer.
• Implementing pipelining for CISC instruction is a bit complicated.
• The hardware structure needs to be more complex to simplify software implementation.
• Designed to minimize the memory requirement when memory was smaller and costlier. But
today the scenario has changed nowadays memory is inexpensive and mostly all
computers have a large amount of memory.
RISC PROCESSOR

• RISC means Reduced Instruction Set Computers


• RISC is a type of microprocessor architecture that utilizes a small, highly-
optimized set of instructions, rather than a more specialized set of instructions.
• RISC systems assume that the required operands are in the processor‟s
registers, not in the main memory
RISC PROCESSOR

• RISCdesigns use uniform instruction length for almost all instructions, and
employ strictly separate load/store-instructions.
• The many varieties of RISC designs include MIPS, SPARC, IBM POWER
instruction set, Alpha, RISC-V, ARM architecture, ARC.
• RISC processors are also used in supercomputers, Unix workstation, embedded
processors in laser printers, routers and similar products
• The use ofARM architecture processors in smartphones and tablet computers
such as the iPad and Android devices provided a wide user base for RISC-
based systems.
RISC PROCESSOR

• Advantages of RISC Processor


• RISC instructions are simpler and fewer machine instruction.
• RISC instructions are hardwired to fasten the execution.
• RISC instruction has simple addressing modes.
• RISC instruction executes faster because most of instruction operates on processor register
and there is no need to access memory for each instruction.
• RISC instructions execute one instruction per clock cycle.
RISC PROCESSOR

• Disadvantages of RISC Processor


• RISC instruction size is reduced but more instructions are required to perform an
operation when compared with CISC.
• The machine instructions are hardwired in RISC so, it would cost if any instruction needs
modification.
• It finds is difficulty in processing complex instruction and complex addressing mode.
• RISC instructions do not allow direct memory to memory transfer, it requires Load and
Store instructions to do so.
CISC VS RISC
CISC RISC
Emphasis on hardware Emphasis on software Single-clock,
Includes multi-clock complex instructions reduced instruction only

Memory-to-memory: "LOAD" and "STORE" Register to register: "LOAD" and "STORE"


incorporated in instructions are independent instructions
Small code sizes, high cycles per second Low cycles per second, large code sizes

Transistors used for storing complex instructions Spends more transistors on memory registers

The machine language instructions of CISC RISC processors use fixed-length machine
processors vary in length language instructions
WHAT IS ASSEMBLY LANGUAGE?

• Assembly Language is a low-level programming language. It helps in


understanding the programming language to machine code.
• Assembly language is directly influenced by the instruction set and architecture
of the processor
• Theassembly language code must be processed by a program in order to
generate the machine language code.
• Assembler is the program that translates assembly language code into the
machine language.
WHAT IS ASSEMBLY LANGUAGE?

• Here are some Assembly language of Pentium Processor examples:


• inc result
• mov class_size, 45
• and mask1, 128
• add marks, 10

• The first instruction increments the variable result. This assembly language
instruction is equivalent to result++;
WHAT IS ASSEMBLY LANGUAGE?

• The second instruction initializes class_size to 45. The equivalent statement in C is


class_size = 45;
• The third instruction performs the bitwise and operation on mask1 and can be
expressed in C as
mask1 = mask1 & 128;
• The last instruction updates marks by adding 10. This is equivalent to
marks = marks + 10;
WHAT IS ASSEMBLY LANGUAGE?

• In contrast, the MIPS instructions use three addresses as shown below:


• andi $t2,$t1,15
• addu $t3,$t1,$t2
• move $t2,$t1

• The operands in these instructions are in processor registers. The processor registers t1, t2,
and t3 are identified by $.
• The andi instruction performs bitwise and of t1 contents with 15 and writes the result in t2.
• The second instruction adds contents of t1 and t2 and stores the result in t3.
• The last instruction copies the t1 value into t2.
ADVANTAGES OF HIGH-LEVEL LANGUAGES

• Program development is faster


• Programs written in a high-level language are relatively small
• These programs are also easier to code and debug
• Programs are easier to maintain.
• easier to understand and when good programming practices are followed easier to maintain
• Programs are portable.
• can be used with little or no modification on different computer systems
ADVANTAGES OF ASSEMBLY LANGUAGE

• 1. It allows complex jobs to run in a simpler way.


• 2. It is memory efficient, as it requires less memory
• 3. It is faster in speed, as its execution time is less.
• 4. It is mainly hardware oriented.
• 5. It requires less instruction to get the result.
• 6. It is used for critical jobs i.e. time-critical jobs
• 7. It is not required to keep track of memory locations.
• 8. It is a low-level embedded system
ADVANTAGES OF ASSEMBLY LANGUAGE

• Having an understanding of assembly language makes one aware of −


• How programs interface with OS, processor, and BIOS;
• How data is represented in memory and other external devices;
• How the processor accesses and executes instruction;
• How instructions access and process data;
• How a program accesses external devices.
DISADVANTAGES OF ASSEMBLY LANGUAGE

• It takes a lot of time and effort to write the code for the same.
• The syntax is difficult to remember
• It has a lack of portability between different computers
WHY PROGRAM IN THE ASSEMBLY LANGUAGE?

• Assembly language serves many purposes, such as improving program speed,


reducing memory needs, and controlling hardware
• However, there are two main reasons why programming is still done in the
assembly language: (1) efficiency, and (2) accessibility to system hardware
• Efficiency refers to how “good” a program is in achieving a given objective.
Here we consider two objectives based on space (space efficiency) and time
(time efficiency).
WHY PROGRAM IN THE ASSEMBLY LANGUAGE?

• Space efficiency refers to the memory requirements of a program, i.e., the size
of the executable code
• Time efficiency refers to the time taken to execute a program. Obviously a
program that runs faster is said to be better from the time-efficiency point of
view
• Assembly language programs have direct control over system hardware. For
example, writing a device driver to a new scanner on the market almost
certainly requires programming in the assembly language
TYPICAL APPLICATIONS

• Time efficiency: Applications for which the execution speed is important fall
under two categories:
• 1. Time convenience (to improve performance)
• 2. Time-critical (to satisfy functionality)
1. Applications in the first category benefit from time-efficient programs
because it is convenient or desirable. For example, a graphics package that
scales an object instantaneously is more pleasant
TYPICAL APPLICATIONS

• In time-critical applications, tasks have to be completed within a specified time


period. These applications, also called real-time applications, include aircraft
navigation systems, process control systems, robot control software, and target
acquisition (e.g., missile tracking) software.
• Accessibility to hardware: System software often requires direct control over
the system hardware. Examples include operating systems, assemblers,
compilers, linkers, loaders, device drivers, and network interfaces.
TYPICAL APPLICATIONS

• Space efficiency: For most systems, compactness of application code is not a


major concern. However, in portable and handheld devices, code compactness
is an important factor. Space efficiency is also important in spacecraft control.
REFERENCES

• Text book
• https://en.wikipedia.org/wiki/Complex_instruction_set_computer
• https://en.wikipedia.org/wiki/Reduced_instruction_set_computer
• https://cs.stanford.edu/people/eroberts/courses/soco/projects/risc/risccisc/

You might also like