0% found this document useful (0 votes)
319 views10 pages

Lab 02: Getting Started With Turbo Assembler (TASM) : Objective(s)

goodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgood

Uploaded by

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

Lab 02: Getting Started With Turbo Assembler (TASM) : Objective(s)

goodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgoodgood

Uploaded by

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

Lab 02: Getting Started with Turbo Assembler (TASM)

Objective(s):

 Understanding TASM Assembler and Debug Commands


 Lab Exercises

Theory:

Step 1 :
Download and Install DOS-BOX and MP (Microprocessor) Zipped folder
Go to: https://drive.google.com/file/d/0B36ww40izFp6dkVWOVk0c1VnOFE/view

Step 2:
Extract the ‘MP’ folder and Paste it on your C:\ Drive

Step 3 :
-Open DOS-BOX from your desktop.

Department of Computer Sciences 1 Semester BS CS 03


CEL21: Computer Organization & Assembly Language Lab Lab 02: TASM Assembler
Department of Computer Sciences 2 Semester BS CS 03
CEL21: Computer Organization & Assembly Language Lab Lab 02: TASM Assembler
Step 3 :
-Open DOS-BOX from your desktop.
Type in the following Commands ,the default terminal drive is set as Z:\> ( Press Ctrl+Enter to go
Full Screen)

Z:\>mount c c:\MP
(Sets Virtual ‘C:\’  C Drive as the path C:\MP )
Z:\>c:\
(changes the drive terminal)
C:\>
(we are in our Virtually allocated C:\ which is the path C:\MP)

Debug

• Debug is a program which allows the programmer to write , execute and debug assembly language
programs, and to examine the content of registers and memory. It can also be used to run a program
one instruction at a time.
• To start DEBUG its name is typed after DOS prompt. i.e. c:\> DEBUG
• Start Debug by typing Debug and hitting return. The indicator that you are in debug will be a
“dash”or “hyphen”: - . Debug commands are entered after the dash. For example, when you want
to quit Debug you enter a Q (for quit) after the dash.

Department of Computer Sciences 3 Semester BS CS 03


CEL21: Computer Organization & Assembly Language Lab Lab 02: TASM Assembler

Debug commands
• It has a number of commands to facilitate users to write, execute and debug programs.
• A DEBUG command is represented by a one-letter symbol.
• DEBUG commands are not case-sensitive.

What is Debug available in?

• All Versions of MS-DOS, Windows 95, Windows 98


Windows ME, Windows NT, Windows 2000 ,Windows XP and 32 bit systems
• Not available in 64 bit systems.

Debug commands

• A – Assemble Command.: It allows user to enter assembly language program and


converts it into machine codes.
Syntax: A [offset-address]
• R – Register Command : Used to display the contents of one or more registers. It also display the
status of the flags.
Syntax: R [register name]
• G – Go Command : It is used to execute a program.
Syntax: G [= address]
• T – Trace Command : It is used to run a program in single-step mode.
• D – Display or Dump Command : It is used to display the contents of specified memory locations.
Syntax: D address-range or D address
• E – Enter Command : It is used to enter the data or machine code. Its default register is the DS.
Syntax: E address
• F – Fill Command : It is used to fill the specified range of locations with the values given in a list.
Syntax: F address-range values
• M – Move Command : It copies the block of data from one memory area to another.
Syntax: M range address
• S – Search Command :It is used to search the specified memory range for the specified list of
bytes. The default register is the DS.
Syntax: S range list
• N – Save Command : It is used to save a file.
Syntax: N filename.com
• W – Write Command
• L – Load Command
• Q – Quit Command

Assembly - Registers

To speed up the processor operations, the processor includes some internal memory storage locations,
called registers. The registers store data elements for processing without having to access the memory. A
limited number of registers are built into the processor chip.

Department of Computer Sciences 4 Semester BS CS 03


CEL21: Computer Organization & Assembly Language Lab Lab 02: TASM Assembl

1.General Purpose Registers


1. 1 Data Registers
• Four 32-bit data registers are used for arithmetic, logical, and other operations. These 32-bit
registers can be used in three ways −
• As complete 32-bit data registers: EAX, EBX, ECX, EDX.
• Lower halves of the 32-bit registers can be used as four 16-bit data registers: AX, BX, CX and DX.
• Lower and higher halves of the above-mentioned four 16-bit registers can be used as eight 8-bit data
registers: AH, AL, BH, BL, CH, CL, DH, and DL.

Some of these data registers have specific use in arithmetical operations.

• ‘X’ in their names stand for extended meaning 16bit registers. For example AX means we are
referring to the extended 16bit “A” register. Its upper and lower byte are separately accessible as
AH (A high byte) and AL (A low byte). All general purpose registers can be accessed as one 16bit
register or as two 8bit registers. The two registers AH and AL are part of the big whole AX. Any
change in AH or AL is reflected in AX as well.

• AX is the primary accumulator:The A of AX stands for Accumulator. Even though all general
purpose registers can act as accumulator in most instructions there are some specific variations
which can only work on AX which is why it is named the accumulator.

• BX is known as the base register:as it could be used in indexed addressing.


• CX is known as the count register:as there are certain instructions that work with an automatic
count in the CX register.
• DX is known as the data register:it is also used in input/output operations. It is also used with AX
register along with DX for multiply and divide operations involving large values.

1.2 Pointer registers

• The pointer registers are 32-bit EIP, ESP, and EBP registers and corresponding 16-bit right portions
IP, SP, and BP. There are three categories of pointer registers –

• Instruction Pointer (IP) − The 16-bit IP register stores the offset address of the next instruction to
be executed. IP in association with the CS register (as CS:IP) gives the complete address of the
current instruction in the code segment.

Department of Computer Sciences 5 Semester BS CS 03


CEL21: Computer Organization & Assembly Language Lab Lab 02: TASM Assembler
• Stack Pointer (SP) − The 16-bit SP register provides the offset value within the program stack. SP
in association with the SS register (SS:SP) refers to be current position of data or address within the
program stack.

• Base Pointer (BP) − The 16-bit BP register mainly helps in referencing the parameter variables
passed to a subroutine. The address in SS register is combined with the offset in BP to get the
location of the parameter. BP can also be combined with DI and SI as base register for special
addressing.

1.3. Index Registers


• The 32-bit index registers, ESI and EDI, and their 16-bit rightmost portions. SI and DI, are used for
indexed addressing and sometimes used in addition and subtraction. There are two sets of index
pointers −
• Source Index (SI) − It is used as source index for string operations.
• Destination Index (DI) − It is used as destination index for string operations

2.Control Registers

• The 32-bit instruction pointer register and the 32-bit flags register combined are considered as the
control registers.
• Many instructions involve comparisons and mathematical calculations and change the status of the
flags and some other conditional instructions test the value of these status flags to take the control
flow to other location.

Department of Computer Sciences 6 Semester BS CS 03


CEL21: Computer Organization & Assembly Language Lab Lab 02: TASM Assembler
FLAGS:
8086 Microprocessor has 16 flag registers among which 9 are active. The purpose of the FLAGS register is
to indicate the status of the processor. It does this by setting the individual bits called flags. There are two
kinds of FLAGS;

Status FLAGS and Control FLAGS.


• Status FLAGS reflect the result of an operation executed by the processor.
• Control FLAGS enable or disable certain operations of the processor.
• Overflow Flag (OF) − It indicates the overflow of a high-order bit (leftmost bit) of data after a
signed arithmetic operation.
• Direction Flag (DF) − It determines left or right direction for moving or comparing string data.
When the DF value is 0, the string operation takes left-to-right direction and when the value is set to
1, the string operation takes right-to-left direction.
• Interrupt Flag (IF) − It determines whether the external interrupts like keyboard entry, etc., are to
be ignored or processed. It disables the external interrupt when the value is 0 and enables interrupts
when set to 1.
• Trap Flag (TF) − It allows setting the operation of the processor in single-step mode. The DEBUG
program we used sets the trap flag, so we could step through the execution one instruction at a time.
• Sign Flag (SF) − It shows the sign of the result of an arithmetic operation. This flag is set according
to the sign of a data item following the arithmetic operation. The sign is indicated by the high-order
of leftmost bit. A positive result clears the value of SF to 0 and negative result sets it to 1.

• Zero Flag (ZF) − It indicates the result of an arithmetic or comparison operation. A nonzero result
clears the zero flag to 0, and a zero result sets it to 1.
• Auxiliary Carry Flag (AF) − It contains the carry from bit 3 to bit 4 following an arithmetic
operation; used for specialized arithmetic. The AF is set when a 1-byte arithmetic operation causes a
carry from bit 3 into bit 4.
• Parity Flag (PF) − It indicates the total number of 1-bits in the result obtained from an arithmetic
operation. An even number of 1-bits clears the parity flag to 0 and an odd number of 1-bits sets the
parity flag to 1.
• Carry Flag (CF) − It contains the carry of 0 or 1 from a high-order bit (leftmost) after an arithmetic
operation. It also stores the contents of last bit of a shift or rotate operation.

The following table indicates the position of flag bits in the 16-bit Flags register:
A
Flag: O D I T S Z P C

Bit no: 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

3.Segment registers

Segments are specific areas defined in a program for containing data, code and stack. There are three main
segments −
• Code Segment − It contains all the instructions to be executed. A 16-bit Code Segment register or
CS register stores the starting address of the code segment.
• Data Segment − It contains data, constants and work areas. A 16-bit Data Segment register or DS
register stores the starting address of the data segment.
Department of Computer Sciences 7 Semester BS CS 03
CEL21: Computer Organization & Assembly Language Lab Lab 02: TASM Assembler
• Stack Segment − It contains data and return addresses of procedures or subroutines. It is
implemented as a 'stack' data structure. The Stack Segment register or SS register stores the starting
address of the stack.

Exercise

A. Start Debug by typing Debug and hitting return. The indicator that you are in debug will be a “dash”or
“hyphen”: - . Debug commands are entered after the dash. For example, when you want to quit Debug
you enter a Q (for quit) after the dash.

B. The command to examine the content of registers is “R”. This will display the content of all the
registers, in hex, as follows:

1. Use the R command to view the register contents for your machine. Record the results:
AX: _________ BX:_________ CX:_______ DX:______
SP:________ BP:_______ SI:______ DI:_____
DS:______ ES:_______ SS:______ CS:______
IP:____

C. You can change the 16-bit content of a register or the flag bits by following the R command with the
register you want to change. (Be very careful about changing the segment registers because that will affect
where your program runs or your data is contained.)

-R AX will respond with the present value of AX and then allow you to enter a new 4-digit hex number for
its content. You cannot change only 8-bits, i.e., -R AH is not allowed.

Department of Computer Sciences 8 Semester BS CS 03


CEL21: Computer Organization & Assembly Language Lab Lab 02: TASM Assembler
2 .Change AX to 1234h and use –R to verify that the change occurred.

AX-----------

3. Enter –R f and see that all the flag values are given. You can make changes by entering the new
literal codes for the flags you want to change in any order. Change the sign and auxiliary carry to
be the opposite of what is presently shown and verify the change was made.

The one-bit flags are shown by a literal code. Starting from the left the flags are:
Set (1) Clear(0) Your Flags:
Overflow OV (yes) NV (no)
Direction DN UP
Interrupt enable EI DI (disabled)
Sign PL NG
Zero ZR NZ
Aux. Carry AC (yes) NA
Parity PE (even) PO (odd)
Carry CY NC

2. Suppose you want to change only CL to FFh but CH should keep the same value. Explain how this
can be done, do it and verify your results.

Department of Computer Sciences 9 Semester BS CS 03


CEL21: Computer Organization & Assembly Language Lab Lab 02: TASM Assembler
Before: CX = so CL = and CH =
AfterS: CX = so CL = and CH =

4. Now change only DH to 33h but do not change DL. Verify using –R.

Department of Computer Sciences 10 Semester BS CS 03


CEL21: Computer Organization & Assembly Language Lab Lab 02: TASM Assembler

You might also like