Sie sind auf Seite 1von 11

Activity No.

8
ATTRIBUTES
Course Code: CPE005
Program:
Course Title: Computer Systems Organization with Assembly Language
Date Performed:
Section:
Date Submitted:
Name:
Instructor:
1. Objective:
This activity aims to demonstrate cursor positioning and text-based attributes in Assembly.
2. Intended Learning Outcomes (ILOs):
After completion of this activity the students should be able to:
1.1 Display a text based on a specified position on a monitor screen
TITLE
screen1.asm
1.2 Create a program that involves
text-based
attributes.
.model
small
3. Discussion :
.stack
The Screen
.data
The screen is typically has 80(0-79)
.code columns x 25 (0-24). The columns and rows provide a grid of
addressable locations at any one ofstart:
which the cursor can be set. INT 10h and Service 06h handles the
process of clearing the screen.
It is required to determine the position of X and Y coordinates where the next character is to be
ax,position.
0600h
displayed. INT 10H Service 02H sets the mov
cursor
mov bh, 00eh
mov cx,0
The attribute byte in text mode determines
the0184fh
characteristics of each displayed character. When a
mov dx,
program set an attribute, it remains set; that
is , all subsequent displayed character have the same attribute
int 10h
until one operation changes it. You can use INT 10H functions to generate a screen attribute and perform
such actions as scroll up or down, read attribute
mov ah,or02character, or print / display attribute or character.
4. Resources:
Computer with 32-bit Operating System
TASM
5. Procedure:
Sample Problem A.
1. Type the following program

mov bh,0
mov dh, 10
mov dl,34
int 10h
mov ah,02
mov dl, 'T'
int 21h
mov ah,02
mov dl, 'I'
int 21h
mov ah,02
mov dl, 'P'
int 21h
mov ah, 4ch
int 21h
end start

in Notepad.

2.
3.
4.

Save the program as screen1.asm.


Assemble and execute the program.
Analyze and record the output in Table 8.1.
Sample Problem B.
1. Modify program screen1.asm, replace line number 15 with mov bh,0ch.
2. Analyze and record the output in Table 8.2.
3. How is your output different from before? Why?
_________________________________________________________________________________

_________________________________________________________________________________
_________________________________________________________________________________
Sample Problem C.
1. Modify program screen1.asm, replace line number 2 with mov bh,1bh.
2. Analyze and record the output in Table 8.3.
3. How is your output different from before? Why?
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________

Sample Problem D.
1. Type the following

TITLE screen2.asm
dosseg
.model small
.stack
.code
start:
mov ax, 0b800h
mov es, ax
mov ah, 06h
mov cl, 00h
mov ch, 00h
mov dl, 18h
mov dh, 18h
mov bh, 20h
int 10h
mov ah, 06h
mov cl, 18h
mov ch, 00h
mov dl, 36h
mov dh, 18h
mov bh, 40h
int 10h
mov ah, 06h
mov cl, 36h
mov ch, 00h
mov dl, 4fh
mov dh, 18h
mov bh, 10h
int 10h
mov ah, 4ch
int 21h
end start

program in Notepad.

2. Save the program as screen2.asm.


3. Assemble and execute the program.
4. Analyze and record the output in Table 8.2.

6. DATA ANALYSIS:
Table 8.1- Output of screen1.asm

Table 8.2- Output of screen2.asm

PROBLEMS:
1. Modify screen2.asm. Change the background into four-color vertical Light blue, yellow, magenta
and Cyan and write down the name of the color on the space provided for every color.
Sample Output:

2. Modify program screen2.asm so that it will display the figure below:

3. Make an assembly program that will display the figure shown below. Save your file as Football.asm

8. Assessment (Rubric for Laboratory Performance):

Activity No.7
PROCEDURE
Course Code: CPE005
Course Code: CPE005
Course Title: Computer Systems Organization with Assembly Course Title: Computer Systems
Language
Organization with Assembly
Language
Section:
Section:
Name:
Name:

1. Objective:
This activity aims to demonstrate how stack works in Assembly Language
2. Intended Learning Outcomes (ILOs):
After completion of the activity the students should be able to:
1.1 Create a procedure in Assembly
1.2 Demonstrate push and pop operations
3. Discussion :
Stack
The stack is part of the memory that is used as a temporary storage of return addresses and
data. There are two most common types of stack: the FIFO (First-In, First-Out), also called queue and
LIFO (Last-In, Last-Out). The names of which are implied by the way data are stored and retrieved from
them.
The two operations on the stack are the PUSH and POP. The PUSH instruction is used to place
values on the stack and the POP instruction is used to remove values from the stack.
The Stack Pointer (SP) register points to the top of the stack at any given time as the Instruction
Pointer (IP) holds the address of the next instruction to be fetched and executed. The POP instruction
decrements the value of the SP by two and the POP instruction increments the SP by 2.
Since the stack is part of the memory we should specify the size of the stack. We specify the
size of the stack in our program as follows:
.stack 100h
Procedure
A procedure or subroutine is a special part of the program that can be called for execution from
any point in the program. The procedure is written to provide a function that must be performed
frequently at various points in the main program. Whenever the function must be performed, a single
instruction is inserted into the main body of the program to CALL the procedure. The RET instruction
must be included at the end of the procedure to return to the main program.
Whenever there is a CALL to the procedure the value of the IP is automatically push to the
stack, and the RET instruction later will pop the value from the stack to the IP.
In Assembly, a procedure is in the form:
<procedure name> PROC
<instruction 1>
<instruction 2>
<procedure name> ENDP

Calling a Procedure has the form:


CALL <procedure name>
Returning from a Procedure has the form:
BODY proc
call <procedure1>

call <procedure2>
BODY endp
PROCEDURE1 proc
:
ret
PROCEDURE1 endp
PROCEDURE2 proc
:
ret
PROCEDURE2 endp
4. Resources:
Computer with 32-bit Operating System
TASM
5. Procedure:
Sample Program A.
1. Type the following in Notepad.
TITLE proc1.asm
.model small
.stack 100h
.data
.code
main proc
mov ax,@data
mov ds,ax
xor al,al
mov cx,16
lp1: push ax
call out1hex
call pcrlf
pop ax
inc al
loop lp1
Mov ax, 4c00h
Int 21h
Main endp
Out1hex proc
And al,0fh
Cmp al,9
Ja ischar
Add al,30h
Jmp printit
Ischar: add al,37h
Printit: Mov dl,al
Mov ah,2

Int 21h
Ret
Out1hex endp
Pcrlf proc
Mov dl,0ah
Mov ah,2
Int 21h
Mov dl,0dh
Mov ah,2
Int 21h
Ret
Pcrlf endp
End main
2. Save the program as proc1.asm.
3. Assemble and execute the program.
4. Analyze the output and record the output in Table 7.1.
What does the procedure Pcrlf do?
____________________________________________________________________________
__
____________________________________________________________________________
__
____________________________________________________________________________
__
Sample Program B.
1. Modify proc1.asm, interchange the placement of procedure Out1hex with Pcrlf.
2. Save the program as proc2.asm.
3. Assemble and execute the program.
4. Analyze the output and record the output in Table 7.2.
How is your output different from before? Why?
___________________________________________________________________________
___________________________________________________________________________
____________________________________________________________________________
__
Sample Program C.
1. Modify proc1.asm, change line number 15 with inc al.
2. Save the program as proc3.asm.
3. Assemble and execute the program.
4. Analyze the output and record the output in Table 7.3.
How is your output different from before? Why?
___________________________________________________________________________
___________________________________________________________________________
Sample Program B.
1. Type the following in a Notepad.

dosseg
.model small
.stack
.data
msg1 db 13,10,"Enter first number:$"
msg2 db 13,10,"Enter second number:$"
msg3 db 13,10,"Sum in decimal number:$"
num1 db ?
sum db ?
res db 20 DUP('$')
.code
main proc
mov ax,@data
mov ds,ax
lea dx,msg1
mov ah,09h
int 21h
mov ah,01h
int 21h
sub al,'0'
mov num1,al
lea dx,msg2
mov ah,09h
int 21h
mov ah,01h
int 21h
sub al,'0'
add al,num1
mov sum,al
lea dx,msg3
mov ah,09h
int 21h
mov si,offset res
mov ax,00
mov al,sum
call addition
lea dx,res
mov ah,09h
int 21h
mov ax,4c00h

int 21h
main endp
addition proc near
push ax
push bx
push cx
push dx
push si
mov cx,00h
mov bx,0Ah
rpt1: mov dx,00
div bx
add dl,'0'
push dx
inc cx
cmp ax,0Ah
jge rpt1
add al,'0'
mov [si],al
rpt2: pop ax
inc si
mov [si],al
loop rpt2
inc si
mov al,'$'
mov [si],al
pop si
pop dx
pop cx
pop bx
pop ax
ret
addition endp
end
2. Save the program as proc4.asm.
3. Assemble and execute the program.
4. Analyze the output and record the output in Table 7.4.
6. DATA ANALYSIS:

Table 7.1 Output of proc1.asm

Table 7.3- Output of proc3.asm

Table 7.2 Output of proc2.asm

Table 7.4- Output of proc4.asm

PROBLEMS:
2. Create an assembly language program asks the user to enter a password formed from 10
characters. The program prints the password as stars on the screen. If the password is correct,
the program should print Password is CORRECT! otherwise, Password is INCORRECT!
3. Create a program that will accept number in decimal and convert it to hexadecimal, binary and
octal.
8. Assessment (Rubric for Laboratory Performance):