11th February

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Lab Session 03

3. OBJECT
Exploring Assembly Language Programming

3. Assembly Language:
3.1 Definition

Assembly language is a low-level programming language for computers,


microprocessors, microcontrollers, and other programmable devices in which each statement
corresponds to a single machine language instruction. An assembly language is specific to a
certain computer architecture, in contrast to most high-level programming languages, which
generally are portable to multiple systems.

Assembly language programs are converted into executable machine code by a utility program
referred to as an assembler, the conversion process being referred to as assembly or assembling
the program.

3.2 Advantages of Assembly Language:


 Assembly language is more human-readable than machine language.
 It can directly communicate with hardware.
 Uses symbolic coded instructions which are easier to remember
 Programming is simplified as a programmer does not need to know the exact storage
location of data and instructions.
 It compiles directly into machine code and thus you have very direct control over
memory.

3.3 Disadvantages of Assembly Language:


 Assembler languages are unique to specific types of computers.
 Programs are not portable to other computers.
 assembly language is specific to a particular machine architecture. assembly languages
are designed for specific make and model of a microprocessor.
 It takes lot of time to code or write the program, as it is more complex in nature.
 A program written in assembly language takes more execution time compared to machine
language.

3.4 Introduction to Debug:


MS-DOS Debug runs at a 16-bit process level and therefore it is limited to 16-bit
computer programs Free DOS Debug has a "DEBUGX" version supporting 32-bit DPMI
programs as well. Well, nowadays, processors are 64 bit so a separate 80x86 zip file and a
platform name DOSBOX is to be downloaded and install in computer to make debug.exe
workable perfectly!!
Then install DOSBOX in following location
C:\Program Files (x86)\DOSBox-0.74
Then start DOSBOX and
Change the Z (default drive) to C drive by typing
mount c: c:\SUBFOLDER
LIKE AS mount c: c:\Debug64bit\DOSBox\debug
The result that will be shown that C drive has been mounted
then enter c:
It will appear C:\
Type debug and write “a” to start assembly language code
Type extra enter when done typing assembly language code and type “r”, “t”, “q” for
checking register, trapping or quit.

 IP Instruction Pointer
 PC Program Counter
 Points the next instruction to be executed.
 Shows the address of next instruction.

3.5 Command Parameters


Debug's command prompt is a hyphen (–). Commands may be typed in either uppercase or
lowercase letters, in any column. A command may be followed by one or more parameters. A
comma or space may be used to separate any two parameters. The standard command parameters
are explained here.
 <Address> consists of two portions. Segment address: Offset address. Segment registers,
CS, DS, ES and SS are often used to hold a segment address. Segment address can be omitted,
but the offset value must be indicated.

 <Number> a 4 digit hexadecimal number.  <Byte> a 2 digit hexadecimal number. 


<String> a set of characters included in single or double quotation marks

3.6 DEBUG COMMANDS


The system commands can be divided into the following groups according to their functions.
 Memory Management Commands.  Assembler Commands.  Program Execution

Commands.
3.6.1. Memory Management Commands
 C Compare the contents of two blocks of memory.  D Display the contents of memory.
 E Edit (Write) data into memory.  F Fill the memory with a value.  M Move the
contents of memory.
 Command C: Compare the contents of two blocks of memory
Command syntax C<Range>,<Address>
For example, the bytes between DS:0100 and DS:0105 are compared to the bytes at DS:0200:
C 100 105 200
The following is displayed by Debug:

 Command D: Display the contents of memory


Command syntax D<Range>
It will display the contents of a specified memory location. <Range> tells the D command what
range of memory to display. If range is not specified, then the default starting address is set to the
location following the last address used by a previous D

3.6.2 Assembler Commands


A====== Assemble a program.
U ======Disassemble a program
 Command A: Assemble a program into machine language.
Command syntax A [<Address>]

 Command U: Disassemble a
program
Command syntax U [<Range>]
It is used to disassemble assembly language instructions into machine code. <Range> is used to
select a block of memory to disassemble. If <Range> is not specified, then the system will start
immediately after the final address of the last U command.
Exercise

Write different code and observe changes in flags

Mov ax, 0045


Add ax 45

For each add instruction in this exercise, assume that EAX contains the given contents before
the instruction is executed. Give the contents of EAX as well as the values of the CF, OF, SF, PF,
AF and ZF after the instruction is executed. All numbers are in hex. (Hint: add eax, 45 adds
45 to the contents of register eax and stores the result back in eax)

Contents of EAX Contents of EAX


Instruction CF OF SF PF AF ZF
(Before) (After)
0045 add ax, 45
FF45 add ax, 45
0045 add ax, -45
FF45 add ax, -45
FFFF add ax, 1

Q2. Write down the code to display the contents of 300 to 400 memory locations in DS.
Q3 Write down the following code @ offset address 100 of Code segment, Write down the
command to display initial values of all registers, execute by tracing Command, write down the
step by step changes in AX,BX,CX,DX and IP registers
MOV ax,1234 MOV bx,1232 add ax,bx NOP

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy