0% found this document useful (0 votes)
69 views8 pages

LAB#1

The document discusses debugging using different commands in an assembler program. It provides information on programming languages, registers, addressing modes, and basic instructions like MOV, ADD, SUB. The lab objectives are to use debugging commands like D, E, R to display, edit and observe the contents of memory locations and registers while performing arithmetic operations on the values. Specific tasks involve displaying, editing and re-displaying memory contents, adding and subtracting values between locations, and unassembling, observing byte sizes and register contents of sample assembly code.

Uploaded by

Yousuf Jamal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views8 pages

LAB#1

The document discusses debugging using different commands in an assembler program. It provides information on programming languages, registers, addressing modes, and basic instructions like MOV, ADD, SUB. The lab objectives are to use debugging commands like D, E, R to display, edit and observe the contents of memory locations and registers while performing arithmetic operations on the values. Specific tasks involve displaying, editing and re-displaying memory contents, adding and subtracting values between locations, and unassembling, observing byte sizes and register contents of sample assembly code.

Uploaded by

Yousuf Jamal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

LAB#1

Objective:
Explore debugger using different commands.

Theory:
PROGRAMMING LANGUAGE

A programming language is an artificial language that can be used to control the behavior of a
machine, particularly a computer. Programming languages, like human languages, have syntactic
and semantic rules to define meaning.

TYPES OF PROGRAMMING LANGUAGE

Programming languages can be classified into three basic categories on the basis of
understanding level of users as well as the machine to which instructions has been given:

1. HIGH LEVEL LANGUAGES


A programming language that enables a programmer to write
programs that are more or less independent of a particular type of computer and are designed
to give a better program efficiency. Such languages are considered high-level because they
are closer to human languages.

2. LOW LEVEL LANGUAGES


These are designed to have both: a relatively good programming efficiency and relatively
good machine efficiency.

3. MACHINE LANGUAGE
Machine language is at the lowest level, because it is the actual binary code of 1s and 0s that
the computer understands. These are designed to give a better machine efficiency.

REGISTERS CLASSIFICATION:The registers inside the microprocessor are classified according to


the function they perform.

In general, they are classified as


1. General purpose registers
2. Address registers
3. Segment register
4. Offset registers
5. Status register

SOME GENERAL PURPOSE REGISTERS:

CE-207: Microprocessor and Microcontroller 1


AX (ACCUMULATOR REGISTER)

 It is the preferred register to use in the arithmetic, logic and data transfer instructions
because its use generates the shortest machine code.
 In multiplication and division operations, one of the numbers involved must be in AX or
AL.
 Input and output operation also requires the use of AX and AL.

BX (BASE REGISTER)

 It is used to store the data also it serves as an address register.

CX (COUNT REGISTER)

 Program loop instructions are facilitated by the use of CX register, serves as a loop
counter.
 Also used as a counter in the string operations.
 CL is used as count in instructions that shift and rotate bits.

DX (DATA REGISTER)

 It is used in multiplication and division operations.


 It is used in IO operation like DL in character output and DX in string output functions.

REGISTER SIZE:

 We have three different sizes of registers:


 8-bit register: AH, AL, BH, BL, CH, CL, DH, DL
 16-bit registers: AX, BX, CX, DX, SP, BP, SI, DI, SS, DS, CS, ES, FS, GS, IP, FLAGS
 32-bit registers: EAX, EXB, ECX, EDX, ESI, EDI, ESP, EBP, EIP, and EFLAGS.

BASIC MOV INSTRUCTION

 The basic MOV instruction is used to transfer data between registers, between and
memory locations, or to have a number directly to a register or memory location.

Syntax: MOV Destination, Source

CE-207: Microprocessor and Microcontroller 2


EXAMPLES:

 MOV AH, BL ; 8-bits register to register


 MOV BX, AX ; 16-bits register to register
 MOV byte1, BL ; 8-bit register to memory
 MOV AX, word1 ;16-bit memory to register

SOME ARITHMETIC INSTRUCTIONS

 ADD:Add the contents of source operand1 to source operand 2 and result store in the
source operand1.

Syntax: ADD Source operand1,Source operand2

EXAMPLE:ADD AL, BL

 SUB: Subtract the contents of source operand1 to source operand 2 and result store in
the source operand1.

Syntax: SUB Source operand1,Source operand2

EXAMPLE:SUB AL,BL

DEBUG PROGRAM:

To create a program in assembler two options exist, the first one is to use the assembler program
such as TASM or Turbo Assembler from Borland, and the second one is to use the debugger - on
this first section we will use this last one since it is found in any PC with the MS-DOS, which
makes it available to any user who has access to a machine with these characteristics.

Debug can only create files with a .COM extension, and because of the characteristics of these
kinds of programs they cannot be larger that 64 kb, and they also must start with displacement,
offset, or 0100H memory direction inside the specific segment.

Debug provides a set of commands that lets you perform a number of useful operations:

CE-207: Microprocessor and Microcontroller 3


A Assemble symbolic instructions into machine code

D Display the contents of an area of memory

E Enter data into memory, beginning at a specific location

G Run the executable program in memory

N Name a program

P Proceed, or execute a set of related instructions

Q Quit the debug program

R Display the contents of one or more registers

T Trace the contents of one instruction

U Unassembled machine code into symbolic code

W Write a program onto disk

 It is possible to visualize the values of the internal registers of the CPU using the Debug
program. To begin working with Debug, type the following prompt in your computer:

C:/>Debug [Enter]

 On the next line a dash will appear, this is the indicator of Debug, at this moment the
instructions of Debug can be introduced using the following command:

-r[Enter]

AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000

DS=0D62 ES=0D62 SS=0D62 CS=0D62 IP=0100 NV EI PL NZ NA PO NC

0D62:0100 2E CS:

0D62:0101 803ED3DF00 CMP BYTE PTR [DFD3],00


CS:DFD3=03

 All the contents of the internal registers of the CPU are displayed; an alternative of
viewing them is to use the "r" command using as a parameter the name of the register
whose value wants to be seen.

 For example:

CE-207: Microprocessor and Microcontroller 4


-rbx

BX 0000

ASSEMBLER STRUCTURE

In assembly language code lines have two parts, the first one is the name of the instruction which
is to be executed, and the second one are the parameters of the command. For example:

addah,bh

Here "add" is the command to be executed; in this case an addition, and "ah" as well as "bh" are
the parameters.For example:

mov al, 25

In the above example, we are using the instruction mov, it means move the value 25 to al
register.The name of the instructions in this language is made of two, three or four letters. These
instructions are also called mnemonic names or operation codes, since they represent a function
the processor will perform.

DIRECT ADDRESSING

Sometimes instructions are used as follows:

add al,[170]

The brackets in the second parameter indicate to us that we are going to work with the content of
the memory cell number 170 and not with the 170 value, this is known as direct addressing.

Creating basic assembler program:

a 100[enter]

mov ax,0002[enter]

mov bx,0004[enter]

addax,bx[enter]

nop[enter][enter]

C:\>debug

-a 100

CE-207: Microprocessor and Microcontroller 5


0D62:0100 mov ax,0002

0D62:0103 mov bx,0004

0D62:0106 add ax,bx

0D62:0108 nop

0D62:0109

 Type the command "t" (trace), to execute each instruction of this program, example

-t

AX=0002 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000

DS=0D62 ES=0D62 SS=0D62 CS=0D62 IP=0103 NV EI PL NZ NA PO NC

0D62:0103 BB0400 MOV BX,0004

 You see that the value 2 move to AX register. Type the command "t" (trace), again, and
you see the second instruction is executed.

-t

AX=0002 BX=0004 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000

DS=0D62 ES=0D62 SS=0D62 CS=0D62 IP=0106 NV EI PL NZ NA PO NC

0D62:0106 01D8 ADD AX,BX

 Type the command "t" (trace) to see the instruction add is executed, you will see the
follow lines:

-t

AX=0006 BX=0004 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000

DS=0D62 ES=0D62 SS=0D62 CS=0D62 IP=0108 NV EI PL NZ NA PE NC

0D62:0108 90 NOP

LAB OBJECTIVES:

CE-207: Microprocessor and Microcontroller 6


TASK#1: Display the contents of the defined memory locations 120, 133, 122 using D
command.

TASK#2:Edit the contents of the above memory locations 120,133,122 by 02,04,03


respectively using E command.

TASK#3: Then again display the contents of the memory locations which we edit in the Task#
2.

TASK#4: Add the contents of the above defined memory location using movinstruction.

TASK#5: Subtract the content of 120 location by 133 and then store the result in the120
location and add the new 120 location contents with the content of 122 location.

TASK#6: Perform the following debug activities

ACT 1.1 :Use debug command U100 to un-assemble the instructions in ACT 1.1. What is the machine
code corresponding to each assembly code instruction.

Assembly Code Machine Code


mov ax,2864h
add ax,3749h
movbx,ax
sub bx,2805
nop

ACT 1.2 :How many bytes does it need to represent each instruction in binary.
Assembly Code No. Of Byte
mov ax,2864h
add ax,3749h
movbx,ax
sub bx,2805
nop

ACT 1.3 :What are the contents of CS , IP , AX & BX ?. Use debug command R to display these
information.

Register Content
CS
IP
AX

CE-207: Microprocessor and Microcontroller 7


BX

ACT 1.4 :Predict the contents of the following registers after execution of each instruction CS , IP , AX
, BX

Register Mov ax,2864 Add ax,3794 Movbx,ax


CS
IP
AX
BX

CE-207: Microprocessor and Microcontroller 8

You might also like