Download Assembly Language Programming with TASM

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Assembly Language Programming with TASM
COM 3: Computer System with Assembly Language Midterm Lecture 1
An Assembly Language Program
MOV AX, 10
; moves the value 10 to AX
MOV BX, 9
; moves the value 9 to BX
ADD BX, AX
; add the contents of AX to BX
MOV AX, BX
; moves the value of BX to AX
END
; stops the program
Introduction to Assembly Language Programming
Computer Language – is a language that consists of a vocabulary of commands to make a computer solve
a particular problem.
Programming languages can be:
 a machine language (A program that can be loaded into memory of the computer and executed
immediately).
• It is the set of binary codes that the circuits in the arithmetic/logic unit (ALU) can execute.
 an assembly language (uses English-like abbreviations that represent instruction of what the
computer has to do).
• The programming language that is closest to machine language.
 a high-level language (the language understood by humans)
• The programming language that is easier to understand and produce results more quickly
than assembly languages.
The conversions between them is possible via:
– a translator (converts assembly and high-level language into machine language).
– an assembler (converts assembly language program into machine language).
– a compiler / interpreter (converts high-level program into machine language).
Three Levels of Programming Languages
 Low-level language - Programmer is concerned with each and every operation that takes place within
the computer.
 Medium-level language - This language shares both low and high level language.
 High-level language - Primary concerned of the programmer is the algorithm, logic, and formulas of the
program.
Three Levels of Low-Level Language
 Lowest level - Binary code - Sometimes refers to a machine language that is consists of series binary
digits (0’s and 1’s).
 Lower level - Hexadecimal code - This commands consists of hexadecimal numbers.
 Low level - Assembly code - Closest level of communication between man and computer.
Assembly Language
– A symbolic machine language that uses mnemonic codes (ADD for addition, MUL for multiplication) in
place of numbers and variable names instead of binary memory locations.
– A low-level language, which is the fastest and most powerful language available for a given computer.
– It is considered a type of low-level programming language because each statement corresponds directly
to a single machine instruction, as compared to a higher-level language such as C, in which a single
instruction corresponds to multiple machine instructions.
–
–
–
–
–
–
–
–
–
Assembly language, at its basic level, is numbers; it is a list of steps and tests. In programming terms,
the steps are called code, and the numbers in their blocks are called data. The blocks themselves are
usually called storage.
An instruction in assembly language reads ADD 5 to Register A. An ADD instruction in the code alters
a data value stored in a block named Register A.
Code and data are distinct from each other; the code includes steps that place data into storage (MOVE
instructions) and steps that alter data that is already in storage (INCREMENT or DECREMENT
instructions).
Among the tests that the code makes are tests that examine data in storage (COMPARE instructions). If
a given data value exists in storage, the code may do one thing; if that value does not exist in storage, the
code will do something else, as in the JUMP BACK and JUMP AHEAD instructions.
To create a software program to accomplish a particular task, the developer chooses an appropriate
language, develops the algorithm (a sequence of steps which, when carried out in the order prescribed,
achieve the desired result), implements this algorithm in the chosen language (coding), then tests and
debugs the final result.
The software development cycle does not end here. What follows is the maintenance phase, during
which bugs are fixed and new features are added.
The chosen language will need to be converted into the appropriate binary bit-patterns which the target
processor understands. This process of conversion is called translation.
To best understand assembly language, you need to first understand machine language. Machine
language is pure binary code, sequences of 1s and 0s, which represent instructions that are loaded,
decoded, and executed by a microprocessor. Assembly language is a direct translation of binary code to
a symbolic form that is easier for humans to manage.
When a program in a high-level language such as C of C++ is compiled, it is turned into assembly
language, which is then translated by the assembler into machine language.
Four Powers of Assembly Language
 Speed
o No program can run faster than the program of an assembly programmer, that is specially
required in graphics displays and mathematical operations that involve huge data.
 Efficiency
o The procedures and software products are more reliable from assembly language.
 Memory consumption
o Sophisticated program can be developed in Assembly with minimal requirement than no other
language can be a challenge.
 Hardware
o Professional Assembly programmers are usually fully aware of the computer architectural
hardware and that gives them greater opportunity to maximize the powers of computer in various
fields.
Difficulties in Assembly Language
 Long programs
o Assembly programs are very long especially if we compared to object-oriented language.
 Difficult to understand.
o Command are not English-like unlike high-level languages.
o Assembly uses at least two registers and one interrupt to produce a string on the screen.
 Difficult in debugging.
o Correcting and debugging of errors are hard to locate.
 Machine dependent.
o Each microcomputer has its own instruction sets for Assembly language, which reflects on its
own architecture.
When to Use Assembly Language
 To do something awkward or impossible with high-level language;
 To speed up slow program;
 To design a program to be small as possible; and
 For enjoyment.
Common Terms in Assembly Language
 Processor
o the chip, on the main system board, that performs the basic operations of the computer.
 Instruction set
o the set of possible instructions that a processor can perform.
 Program
o it refers to the series of instructions.
 Language
o it refers to the series of rules.
 Machine language
o set of basic operations, performed by the processor, along with rules for using them.
 Computer language
o set of instructions with which programs can be written.
 High-level language
o language with instructions that are far from machine language.
 Low-level language
o a language with instructions that are close to machine language.
 Assembly language
o a type of low-level language in which mnemonic abbreviations represents machine operations
and storage locations.
o It makes possible to program directly to the processor without using machine language.
 Compiler
o a program that translates high-level programs into machine language in order to be executed by
the machine or computer.
 Interpreter
o a program that translates high-level programs into machine language, one line at a time, as they
executed.
 Incremental interpreter
o a programs that combines compiling and interpreting by translating a high-level program into an
intermediate form (pseudo code) that is later interpreted.
 Assembler
o a program that translate low-level programs into machine language.
 Linker
o a programs that processes a translated assembly program into a form that can be executed.
 Coding
o process of writing the program
 Debugger
o a programs that provides an environment for testing load modules.