Lab Manual: University of Hail
Lab Manual: University of Hail
Lab Manual: University of Hail
College of Engineering
LAB MANUAL
FOR
1
Table of Contents
Experiment #5 Using BIOS Services and DOS functions Part 1: Text-based Graphics ........ 29
Experiment #6 Using BIOS Services and DOS functions Part 2: Pixel-based Graphics ....... 36
2
Experiment #1 MS-DOS Debugger (DEBUG)
1.0 Objectives:
The objective of this experiment is to introduce the "DEBUG” program that comes with MS-
DOS and Windows operating systems. This program is a basic tool to write, edit and execute
assembly language programs.
1.1 Introduction:
DEBUG program which is supplied with both DOS and Windows, is the perfect tool for
writing short programs and getting acquainted with the Intel 8086 microprocessor. It displays
the contents of memory and lets you view registers and variables as they change. You can use
DEBUG to test assembler instructions, try out new programming ideas, or to carefully step
through your program. You can step through the program one line at a time (called tracing),
making it easier to find logic errors.
3
The following table shows a list of some commonly used DEBUG commands.
COMMAND SYNTAX
Dump D [Address]
Trace T [Address][Number]
The Internal Registers and Status Flags of the 8086 uP are shown in the following tables.
Flag Flag
CF SF
PF IF
AF DF
ZF OF
AX BX C
DS CS E
4
1.3 Pre-lab:
1. Name a few computer operating systems. Which operating system do you mostly use?
3. What is the difference between a logical address and a physical address? Show how a physical
4. What are the following registers used for: DS, CS, SS, SP, IP, AX
5. Define the function each of the following flag bits in the flag register: Overflow, Carry, Sign,
and Zero.
5
1.4 Lab Work:
A. Loading the DEBUG program
1. Load the DEBUG program by typing debug at the MS-DOS prompt, as shown in
the example below: C:\WINDOWS>debug
2. You will see a dash (-) in the left-most column on the screen. This is the DEBUG
prompt.
Note: You have to hit Carriage Return (CR) key (or ENTER key) on the keyboard after you
type any debug command.
1. Use the REGISTER command to display the current contents of all the internal registers by
typing R.
a) List the values of the following registers:
b) What is the address of the next instruction to be executed?
c) What is the instruction held at this address?
AX
SI
DI
DX
IP
3. Use a REGISTER command to first display the current contents of SI and then change
this value to 0102h.
6
4. Use a REGISTER command to first display the current contents of IP and then change
this value to 0300h.
5. Use a REGISTER command to first display the current contents of the flag register and
then reset the overflow, sign, and auxiliary flags.
6. Redisplay the contents of all the internal registers. Compare the displayed register
contents with those observed in step 1 above. What instruction is now pointed by CS: IP?
1 Use the DUMP command (D) to display the first 50 bytes of the current data
segment.
2 Use the DUMP command (D) to display the first 50 bytes of the code segment
starting the current value of CS: IP.
3 Use the ENTER command (E) to load locations CS:50, CS:52, and CS:54 with AA,
BB, and CC, respectively.
4 Use the ENTER command (E) to load five consecutive byte-wide memory locations
starting at CS:55 with data „00‟.
5 Verify the result of steps 3 and 4 using the DUMP command.
6 Use the FILL command (F) to initialize the 10h storage locations starting at DS:10
with the value 11h, the 10h storage locations starting at address DS:30 with 22h, the 10h
storage locations starting at address DS:50 with 33h, and the 10h storage locations starting
at address DS:70 with 44h
7 Verify the result of step 6 using the DUMP command.
7
D. Coding instructions in 8086 machine language
1. Enter each of the following instructions starting at address CS:100 one-by-one using
the ASSEMBLE command (A).
MOV AX,BX
MOV AX, AAAAh
MOV AX,[BX]
MOV AX,[0004H]
MOV AX,[BX+SI]
MOV AX,[SI+4H]
MOV AX,[BX+SI+4H]
Instruction
MOV BX, CX
MOV SI, AAAA
MOV AX,[DI]
MOV BX,[4]
MOV DI,[BX+SI]
MOV IP,[SI+4]
MOV AX,[BP+DI+F]
8
E. Coding instructions in 8086 machine language
1. Using the ASSEMBLE command (A), load the program shown below into
memory starting at address CS: 0100.
2. Verify the loading of the program by displaying it with the UNASSEMBLE (U)
command.
a) How many bytes of memory does the program take up?
b) What is the machine code for the DEC CX instruction?
c) What is the address offset for the label BACK?
3. Fill 16 bytes of memory locations starting at DS: 0200 with value 45H and verify.
4. Execute the above program one instruction at a time using the TRACE command (T).
Observe how the values change for registers: AX, CX, SI, DI flag register, and IP.
6. What are the final values of registers: AX, CX, SI, and DI?
9
Experiment #2 Addressing Modes and Data
2.0 Objective
The objective of this experiment is to learn various addressing modes and to verify the actions
of data transfer.
2.1 Introduction
Assembly language program can be thought of as consisting of two logical parts: data and
code. Most of the assembly language instructions require specification of the location of the
data to be operated on. There are a variety of ways to specify and find where the operands
required by an instruction are located. These are called addressing modes. This section is a
brief overview of some of the addressing modes required to do basic assembly language
programming.
The operand required by an instruction may be in any one of the following locations
Therefore the basic addressing modes are register, immediate, and memory addressing modes
In this addressing mode, data is specified as part of the instruction. For example, in the
following instruction
MOV BX,1000H the immediate value
1000H is placed into the register BX.
A variety of modes are available to specify the location of an operand in memory. These are
direct, register-indirect, based, indexed and based-indexed addressing modes
10
2.2 Pre-lab:
Using turbo debugger, initialize the registers and memory locations before executing the
following statements and fill the corresponding columns in Table 1.
b. Initialize BX=1111H;
MOV BX,2000H
Addressing
Source Destination
Mode
Statement
Register/ Register/ Contents before Contents
Contents
Memory Memory execution
MOV AL,[BX+SI] Memory 2A Memory 10 2A Based indexed
MOV AX,[DI+8]
MOV BX,2000H
XCHG BX,CX
MOV [DI],AX
MOV AX,[BX+SI+5]
MOV AX,[BP+2]
TABLE 1 11
2.3 Lab Work:
USING AN ASSEMBLER
In Experiment 1, we learned to use the DEBUG program development tool that is available in
the PC‟s operating system. This DEBUG program has some limitations. Program addresses
must be computed manually (usually requiring two phases – one to enter the instructions and a
second to resolve the addresses), no inserting or deleting of instructions is possible, and
symbolic addresses cannot be used. All of these limitations of DEBUG can be overcome by
using the proper assembly language tools.
Assembly language development tools, such as Microsoft‟s macro-assembler (MASM),
Borland‟s Turbo assembler (TASM) together with the linker programs, are available for DOS.
An assembler considerably reduces program development time.
Using an assembler, it is very easy to write and execute programs. When the program is
assembled, it detects all syntax errors in the program – gives the line number at which an error
occurred and the type of error.
We will be using the Turbo assembler (TASM) and linker (TLINK) programs in this lab.
Program Template
The following program template must be followed when using the Turbo assembler to write
programs.
TITLE “Experiment 2”
.MODEL SMALL
.STACK 032h
.DATA
…………..
END
Any line starting with a „;‟ (semi-colon) is considered a comment and is ignored by the
assembler.
In assembler we have to explicitly perform many functions which are taken for granted in
high level languages. The most important of these is exiting from a program. The last two
lines
MOV AX,4C00H
INT 21H
in the code segment are used to exit the program and transfer the control back to DOS.
Procedure (to be followed for all programs):
• Edit the above program using an editor. Type “edit program1.asm” at the DOS
prompt. Save your file and exit the editor. Make sure your file name has an extension of
“.asm”.
• Assemble the program created in (a). Type “tasm program1” at the DOS prompt.
If errors are reported on the screen, then note down the line number and error type from
the listing on the screen. To fix the errors go back to step (a) to edit the source file. If no
errors are reported, then go to step (c).
• Link the object file created in (b). Type “tlink program1” at the DOS prompt.
This creates an executable file “program1.exe”.
• Type “program1” at the DOS prompt to run your program.
Note: You have to create your source file in the same directory where the TAMS.exe and
TLINK.exe programs are stored.
14
Program 2: Write a program for TASM that stores the hex numbers 20, 30, 40, and 50 in the
memory and transfers them to AL, AH, BL, and BH registers. Verify the program using turbo
debugger; specially identify the memory location where the data is stored.
num DB 10,20,30,40
.CODE
LEA SI,num
END ; end
The directive DB „Define Byte‟ is used to store data in a memory location. Each data has a
length of byte. (Another directive is DW „Define Word‟ whose data length is of two bytes)
The label „num‟ is used to identify the location of data. The two instructions
MOV AX,@DATA
MOV DS,AX
together with LEA SI,num
are used to find the segment and offset address of the memory location „num‟. Notice that
memory addressing modes are used to transfer the data.
15
Program 3: Write a program that allows a user to enter characters from the keyboard using
the character input function. This program should also store the characters entered into a memory
location. Run the program after assembling and linking. Verify the program using turbo debugger,
specially identify the location where the data will be stored.
.CODE
MOV [SI], AL
END
The directive DB when used with DUP allows a sequence of storage locations to be defined or
reserved. For example
DB 20 DUP(?)
reserves 20 bytes of memory space without initialization. To fill the memory locations with
some initial value, write the initial value with DUP instead of using „question mark‟. For
example DB 20 DUP(10) will reserve 20 bytes of memory space and will fill it with the
numbers 10.
The Keyboard input function waits until a character is typed from the keyboard. When the
following two lines
MOV AH,01
INT 21H
are encountered in a program, the program will wait for a keyboard input. The ASCII value of
the typed character is stored in the AL register. For example if „carriage return‟ key is pressed
then AL will contain the ASCII value of carriage return i.e. 0DH
16
2.5 EXERCISE
Write a program in TASM that reserves a memory space „num1‟ of 10 bytes and initializes
them with the hex number „AA‟. The program should copy the 10 bytes of data of „num1‟ into
another memory location „num2‟ using memory addressing mode. Verify the program using
turbo debugger.
Hint : Use DB instruction with DUP to reserve the space for „num1‟ of 10 bytes with the
initialized value of „AA‟. Again use DB with DUP to reserve another space for „num2‟, but
without initialization. Use memory content transfer instructions to copy the data of „num1‟ to
„num2‟.
17
Experiment #3
Arithmetic Instructions
3.0 Objective
The objective of this experiment is to learn the arithmetic instructions and write simple
programs using TASM
3.1 Introduction
Arithmetic instructions provide the micro processor with its basic integer math skills. The
80x86 family provides several instructions to perform addition, subtraction, multiplication, and
division on different sizes and types of numbers. The basic set of assembly language
instructions is as follows
Examples:
ADD AX,BX
adds the content of BX with AX and stores the result in AX register.
ADC AX,BX adds the content of BX, AX and the carry flag and store it
in the AX register. It is commonly used to add multibyte operands together (such as 128-bit
numbers)
18
3.2 Pre-lab:
1. Write a program in TASM that performs the addition of two byte sized numbers that
are initially stored in memory locations „num1‟ and „num2‟. The addition result should be
stored in another memory location „total‟. Verify the result using turbo debugger.
[Hint: Use DB directive to initially store the two byte sized numbers in memory locations
called „num1‟ and „num2‟. Also reserve a location for the addition result and call it „total‟]
2. Write a program in TASM that multiplies two unsigned byte sized numbers that are
initially stored in memory locations „num1‟ and „num2‟. Store the multiplication result in
another memory location called „multiply‟. Notice that the size of memory location „multiply‟
must be of word size to be able to store the result. Verify the result using turbo debugger.
Example Program 1:Write a program that asks to type a letter in lowercase and then convert
that letter to uppercase and also prints it on screen.
a
MSG1 DB MSG2 DB CHAR DB „Enter0DH,0?, „$‟
.CODE
MOV AX,@DATA ; get the address of the data segment
MOV DS,AX ; and store it in register DS
MOV AH,01 ; single character keyboard input function INT 21H ; call the function,
result will be stored in AL (ASCII code)
SUB AL,20H ; convert to the ASCII code of upper case LEA SI,CHAR ; load the
address of the storage location MOV [SI],AL ; store the ASCII code of the
converted letter to memory
19
MOV AH,9 ; display string function
LEA SI,MSG2 ; get memory location of second message
MOV DX,[SI] ; and store it in the DX register
INT 21H ; display the string
String output function is used in this program to print a string on screen. The effective
address of string must first be loaded in the DX register and then the following two lines are
executed
MOV AH,09 INT 21H
Exercise 1: Modify the above program so that it asks for entering an uppercase letter and
converts it to lowercase.
Example Program 2: The objective of this program is to enter 3 positive numbers from the
keyboard (0-9), find the average and store the result in a memory location called „AVG‟.
Run the program in turbo debugger and verify the result.
MOV CL,03
START:
(ASCII)
SUB AL,30H
LEA SI,num
20
MOV [SI],AL
DEC CL
CMP CL,0
JE ADD_IT
INC SI
JMP ADD_IT
END
Exercise 2: Write a program in TASM that calculates the factorial of number 5 and stores the
result in a memory location. Verify the program using turbo debugger [Hint: Since 5! =
5x4x3x2x1, use MUL instruction to find the multiplication. Store 5 in a register and decrement
the register after every multiplication and then multiply the result with the decremented
register. Repeat these steps using conditional jump instruction]
Exercise 3: Modify the factorial program such that it asks for the number for which factorial
is to be calculated using string function and keyboard input function. Assume that the number
will be less than 6 in order to fit the result in one byte.
21
Experiment #4 Shift and
Rotate Instructions
4.0 Objectives:
The objective of this experiment is to write programs demonstrating the applications of Shift
4.1 Introduction:
Shift Instructions
The 8086 can perform two types of Shift operations; the logical shift and the arithmetic shift.
There are four shift operations (SHL, SAL, SHR, and SAR).
Mnemonic Meaning
SAL Shift Arithmetic
SHL Shift Logical Lef
SAL Shift Arithmetic
SHL Shift Logical Rig
If the source operand is specified as CL instead of 1, then the count in this register represents
the number of bit positions the contents of the operand are to be shifted. This permits the count
to be defined under software control and allows a range of shifts from 1 to 255 bits.
A logical shift fills the newly created bit position with zero:
22
An arithmetic shift fills the newly created bit position with a copy of the number‟s sign
The SHL (shift left) instruction performs a logical left shift on the destination operand, filling
the lowest bit with 0.
n
Shifting left 1 bit multiplies a number by 2 and shifting left n bits multiplies the operand by 2
. For example:
n
Shifting right 1 bit divides a number by 2 and shifting right n bits divides the operand by 2
.
23
Rotate Instructions
The 8086 can perform two types of rotate operations; the rotate without carry and the rotate
through carry. There are four rotate operations (ROL, ROR, RCL, and RCR).
Mnemonic Meaning
ROL Rotate Left
ROR Rotate Right
RCL Rotate Left through carry
RCR Rotate Right through carry
ROL shifts each bit of a register to the left. The highest bit is copied into both the Carry flag
and into the lowest bit of the register. No bits are lost in the process.
ROR shifts each bit of a register to the right. The lowest bit is copied into both the Carry flag
and into the highest bit of the register. No bits are lost in the process.
24
RCL (rotate carry left) shifts each bit to the left. It copies the Carry Flag to the least significant
bit and copies the most significant bit to the Carry flag.
RCR (rotate carry right) shifts each bit to the right. It copies the Carry Flag to the most
significant bit and copies the least significant bit to the Carry flag.
25
4.2 Pre-lab:
Run the following instructions in Turbo Debugger and state the values of source and
destination for each Shift or Rotate instruction.
26
4.3 Lab Work:
The MUL and DIV instructions take much longer to execute than the Shift instructions.
Therefore, when multiplying/dividing an operand by a small number it is better to use Shift
instructions than to use the MUL/DIV instructions. For example MUL BL where BL = 2 takes
many more clock cycles than SHL AL, 1.
In Exercise 1, and 2, you will write programs to multiply, and divide respectively, using shift
instructions.
Write each of the programs using the TASM assembler format. Programs 1, 2, and 3 must be
executed using the Turbo Debugger (TD) program. Program 4 must be directly executable
from the DOS prompt.
1. Write a program to multiply AX by 27 using only Shift and Add instructions. You should
not use the MUL instruction.
27
2. Write a program to divide AX by 11 using Shift and Subtract instructions. You should
not use the DIV instruction. Assume AX is a multiple of 11.
3. Write a program to check if a byte is a Palindrome. [Hint: Use Rotate instructions]. If the byte
is a Palindrome, then move AAh into BL. Otherwise move 00h in BL.
[Hint: Use logical shift instruction to move data bit into the carry flag]
4. Write a program to display the bits of a register or memory location. Use the INT 21H
interrupts to display data on the display monitor.
28
Experiment #5
5.0 Objectives:
The objective of this experiment is to introduce BIOS and DOS interrupt service routines
to be utilized in assembly language programs. In this experiment, you will use BIOS and DOS
5.1 Introduction:
The Basic Input Output System (BIOS) is a set of x86 subroutines stored in Read-Only
Memory (ROM) that can be used by any operating system (DOS, Windows, Linux, etc) for
low-level input/output to various devices. Some of the services provided by BIOS are also
provided by DOS. In fact, a large number of DOS services make use of BIOS services. There
are different types of interrupts available which are divided into several categories.
29
.
Positions on the screen are referenced using (row, column) coordinates. The upper left
corner has coordinates (0,0). For an 80 x 25 display, the rows are 0-24 and the columns are
0-79.
30
5.2 Pre-lab:
1. The following program allows a user to enter characters from the keyboard using the
character input function (AH=01) of INT 21h. This program also stores the characters entered into
a buffer. Run the program after assembling and linking.
TITLE "Program to enter characters from keyboard"
char_buf
.CODE
MOV AX,@DATA ; get the address of the data segment MOV DS,
AX ; and store it in register DS
LEA SI, char_buf ; load the address offset of buffer to store the name MOV AH, 01 ; DOS
interrupt for character input from keyboard AGAIN: INT 21H ; call the DOS interrupt
MOV [SI], AL ; store character in buffer INC SI ; point to next location in buffer
CMP AL, 0DH ; check if Carriage Return <CR> key was hit JNE AGAIN ; if not
<CR>, then continue input from keyboard
• Edit the above program using an editor. Type “edit program1.asm” at the DOS
prompt. Save your file and exit the editor. Make sure your file name has an extension of
“.asm”.
• Assemble the program created in (a). Type “tasm program1” at the DOS prompt.
If errors are reported on the screen, then note down the line number and error type from
the listing on the screen. To fix the errors go back to step (a) to edit the source file. If no
errors are reported, then go to step (c).
• Link the object file created in (b). Type “tlink program1” at the DOS prompt.
This creates an executable file “program1.exe”.
• Type “program1” at the DOS prompt to run your program.
Note: You have to create your source file in the same directory where the TAMS.exe and
TLINK.exe programs are stored.
31
2. Modify the above program such that the characters entered from the keyboard are not
echoed back on the screen (i.e., they are not displayed when keys are pressed). [Hint: use function
AH=07 with INT 21h]. After that, add the following lines of code between “JNE AGAIN” and
MOV AX, 4C00H to display the characters stored in the buffer on the screen.
LEA DI, char_buf ; load the address offset of buffer to store the name MOV DL,
[DI] ; move character to be displayed in DL MOV AH, 02 ; DOS interrupt for
character output
BACK: INT 21H ; call the DOS interrupt INC DI ; point to next location in buffer CMP
[DI], 0DH ; check for 0Dh - ASCII value for ENTER key JNE BACK ; if not ENTER key,
then continue output to screen
3. The following program clears the screen and positions the cursor at a specified location on
the screen using INT 10H functions. The program also displays a message string on the screen
using function 09h of INT 21H. Run the program after assembling and linking.
TITLE "Program to enter characters from keyboard"
LF CR
msg1 DB "EE 390 Lab, EE Department, KFUPM ", LF, CR, "$"
msg2 DB "Press any key to exit", LF, CR, "$"
.CODE
MAIN PROC
MOV AX,@DATA ; get the address of the data segment MOV DS,
AX ; and store it in register DS
CALL CLEARSCREEN ; clear the screen
MOV DH, 10 ; row 10 MOV DL, 13 ; column 13
CALL SETCURSOR ; set cursor position
LEA DX, msg1 ; load the address offset of message to be displayed MOV AH, 09h ;
use DOS interrupt service for string display INT 21H ; call the DOS interrupt
LEA DX, msg2 ; load the address offset of message to be displayed MOV AH, 09h ;
use DOS interrupt service for string display INT 21H ; call the DOS interrupt
32
INT 21H
MAIN ENDP
CLEARSCREEN PROC
CLEARSCREEN ENDP
SETCURSOR PROC
MOV AH, 2 ; use DOS interrupt service for positioning screen MOV BH, 0 ; video
page (usually 0) INT 10H ; call the DOS interrupt RET ; return to main procedure
SETCURSOR ENDP
END MAIN
Notes:
1 The above program uses three procedures – MAIN, SETCURSOR, and
CLEARSCREEN. The SETCURSOR and CLEARSCREEN procedures are called from the
MAIN procedure using the CALL instruction.
2 The SETCURSOR procedure sets the cursor at a specified location on the screen whereas
the CLEARSCREEN procedure uses the SET MODE function 00H of INT 10H to set the video
mode to 80 x 25 text which automatically clears the screen.
3 You can display a string of characters on the screen, without using a loop, by using
MOV AH, 09 with INT 21h. But the string must end with „$‟ character. You must also load
the effective address of the string in register DX.
4 To display a string on a new line, you need to put CR after your string and LF and '$'
at the end. CR stands for Carriage Return (or Enter key) and LF stands for Line Feed. You
can also put 0Dh or 13 instead of CR (or cr), and 0Ah or 10 instead of LF (or lf).
33
5.3 Lab Work:
The following program clears the screen and positions the cursor in the middle of the screen. Two
memory locations „row‟ and „col‟ are used to keep track of the cursor position.
.MODEL SMALL
.STACK 100
.DATA
row DB 12
col DB 39
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS, AX
CALL CLEARSCREEN
CALL SETCURSOR
MOV AX, 4C00H
INT 21H
MAIN ENDP
CLEARSCREEN PROC
MOV AH, 00
MOV AL, 03
INT 10H
RET
CLEARSCREEN ENDP
SETCURSOR PROC
SETCURSOR ENDP
END MAIN
34
Note that the SETCURSOR procedure shown above gets its row and column positions directly
from the memory variables „row‟ and „col‟.
Modify the MAIN procedure in the above program to read an arrow key value from the
keyboard using the DOS single character input function INT 21h, AH=7 which waits for a
character and does not echo the character to the screen. Depending on which arrow key is
pressed, the program must move the cursor accordingly
The program must wrap the cursor correctly around to the next boundary, for e.g., if the cursor
moves off the right edge it should appear at the left edge and vice-versa. Similarly, if the
cursor moves off the bottom edge it should appear at the top edge and vice-versa.
The program must continuously check for a key press (using the ASCII values given above)
inside a loop, and move the cursor to a new position only when an arrow key is pressed. The
program must exit the loop and return to DOS when the ENTER key (ASCII value 0Dh) is
pressed.
35
Experiment #6
6.0 Objectives:
The objective of this experiment is to introduce BIOS and DOS interrupt service routines to
write assembly language programs for pixel-based graphics.
In this experiment, you will use BIOS and DOS services to write programs that can do the
following:
• Set graphics video mode
• Write a pixel on the screen
• Draw a line on the screen
• Draw a rectangle on the screen
6.1 Introduction:
In text mode, the cursor is always displayed on the screen and the resolution is indicated as
number of characters per line and number of lines per screen. In graphics mode, the cursor
will not appear on the screen and the resolution is specified as number of pixels per line and
number of lines per screen. Text can be used as usual in graphics mode.
36
6.2 Pre-lab:
1. Drawing a Pixel
The following program draws a pixel on the screen at location (240, 320) using the “write pixel”
function (AH=0Ch) of INT 10h. Run the program after assembling and linking it.
TITLE "Program to enter characters from keyboard" .MODEL SMALL ; this
defines the memory model .STACK 100 ; define a stack segment of 100 bytes
.DATA ; this is the data segment .CODE ; this is the code segment
MOV AX,@DATA ; get the address of the data segment MOV DS,
AX ; and store it in DS register
; draw a green color pixel at location (240, 320) MOV AH, 0Ch
; Function 0Ch: Write pixel dot MOV AL, 02 ; specify green
color MOV CX, 320 ; column 320 MOV DX, 240 ; row 240
MOV BH, 0 ; page 0 INT 10h
MOV AH, 07h ; wait for key press to exit program INT 21h
37
2. Drawing a horizontal line
The following program draws a horizontal line on the screen from location (240, 170) to (240,
470) by writing pixels on the screen using function (AH=0Ch) of INT 10h. Run the program after
assembling and linking it.
TITLE "Program to enter characters from keyboard" .MODEL SMALL ; this
defines the memory model .STACK 100 ; define a stack segment of 100 bytes
.DATA ; this is the data segment .CODE ; this is the code segment
MOV AX,@DATA ; get the address of the data segment MOV DS,
AX ; and store it in DS register
; draw a green color line from (240, 170) to (240, 470) MOV CX, 170 ;
start from row 170 MOV DX, 240 ; and column 240 MOV AX, 0C02h ;
AH=0Ch and AL = pixel color (green)
BACK: INT 10h ; draw pixel INC CX ; go to next column CMP CX, 470 ; check if
column=470 JB BACK ; if not reached column=470, then continue
MOV AH, 07h ; wait for key press to exit program INT 21h
38
6.3 Lab Work:
Draw the following figure on the screen using function 0Ch of INT 10h. Assemble, link, and run
it and show it to your lab instructor for credit.
39