Lab 02: Getting Started With Turbo Assembler (TASM) : Objective(s)
Lab 02: Getting Started With Turbo Assembler (TASM) : Objective(s)
Objective(s):
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.
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.
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.
Debug commands
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.
• ‘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.
• 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.
• 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.
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.
• 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.
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.
4. Now change only DH to 33h but do not change DL. Verify using –R.