Example 1.0: ; draw line in graphicsmode [org 0x0100] mov ax, 0x000D ; set 320x2
ID: 3612509 • Letter: E
Question
Example 1.0: ; draw line in graphicsmode[org 0x0100]
mov ax, 0x000D ; set 320x200 graphics mode
int 0x10 ;bios video services
mov ax, 0x0C07 ; put pixel in white color
xor bx,bx ; page number 0
mov cx,200 ; x position 200
mov dx,200 ; y position 200
l1: int 0x10 ; bios video services
dec dx ; decrease y position
loopl1 ;decrease x position and repeat
mov ah,0 ;service 0 – get keystroke
int 0x16 ;bios keyboard services
mov ax,0x0003 ; 80x25 text mode
int 0x10 ;bios video services
mov ax,0x4c00 ; terminate program
int 0x21
Explanation / Answer
The following program draws a horizontal line on the screen fromlocation (0, 0) to (80,25) by writing pixels on the screen usingfunction (AH=0Ch) of INT 10h.
.MODEL SMALL // this defines thememory model
.STACK 100 //define a stack segment of 100 bytes
.DATA //thisis 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
MOV AH, 00h //set video mode
MOV AL, 12h //graphics 640x480
INT 10h
// Draw a green color line from (0, 0) to (80,25)
MOV CX, 0 //start from row 0
MOVDX, 80 //and column 80
MOV AX, 0C02h //AH=0Ch and AL = pixel color (green)
BACK: INT 10h //draw pixel
INC CX //go to next column
CMP CX, 80 //check if column=80
JB BACK //if not reached column=80, then continue
MOV AH, 07h //wait for key press to exit program
INT 21h
MOV AX, 4C00H //Exit to DOS function
INT 21H
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.