Activity No 7 Procedure
Activity No 7 Procedure
7
PROCEDURE
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 how stack works in Assembly Language
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
movax,@data
movds,ax
xoral,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
Jmpprintit
Ischar: add al,37h
Printit: Movdl,al
Mov ah,2
Int 21h
Ret
Out1hex endp
Pcrlfproc
Mov dl,0ah
Mov ah,2
Int 21h
Mov dl,0dh
Mov ah,2
Int 21h
Ret
Pcrlfendp
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 Pcrlfdo?
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
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
movax,@data
movds,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
movsum,al
lea dx,msg3
mov ah,09h
int 21h
movsi,offset res
mov ax,00
moval,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
add dl,'0'
push dx
inc cx
cmp ax,0Ah
jge rpt1
add al,'0'
mov [si],al
rpt2: pop ax
incsi
mov [si],al
loop rpt2
incsi
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:
7. PROBLEMS:
1. 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!”
Create a program that will accept number in decimal and convert it to hexadecimal, binary and octal.
8. CONCLUSIONS: