Loading documents preview...
COMPUTER ENGINEERING DEPARTMENT Computer Systems Organization and Architecture Manual
ACTIVITY 3: String Manipulation 3.1
Program Outcomes (POs) Addressed by the Activity a. ability to apply knowledge of mathematics and science to solve engineering problems b. ability to design and conduct experiments, as well as to analyze and interpret data c. ability to design a system, component, or process to meet desired needs within realistic constraints such as economic, environmental, social, political, ethical, health and safety, manufacturability, and sustainability, in accordance with standards d. ability to identify, formulate, and solve engineering problems e. ability to use techniques, skills, and modern engineering tools necessary for engineering practice. f. knowledge and understanding of engineering and management principles as a member and leader in a team, to manage projects and in multidisciplinary environments
3.2
Activity’s Intended Learning Outcomes (AILOs) At the end of this activity, the student shall be able to: a. Discuss the function of a LABEL, LOOP, INC, DEC, CMP and JUMP Instructions b. Apply and demonstrate the use of the Service Function Call 09H of INT 21H in assembly language. c. Execute of an assembly language program using service function call 09H, INT 21H
3.3
Objectives of the Activity The objectives of this activity are to: a. To learn how to print strings using service 9 of INT 21h b. To learn how to process string in assembly language level c. To apply loop and call & return instruction. d. To create a program that provides a simple screen output by using the string output service.
3.4
Principle of the Activity Strings can’t usually fit in a register, string are then placed in the memory and then pass the address of the string in memory of two of the registers, the segment address in DS and offset address in DX. The string output sends a string of characters to the standard output. On entry: AH = 09h. DS = segment address of the first character of the string DX = offset address of the first character of the string.
ACTIVITY 3: STRING MANIPULATION
1
Service 9 display string of character starting with the first character (address in DS: DX) output, but not including, the character “$” (ASCII24H) 3.5
Materials/Equipment 1 unit Personal Computer DOS / Command Prompt Text Editor (SK, Notrepad, Wordpad) Assembler (TASM.EXE) Linker (TLINK.EXE ) Storage unit
3.6
Circuit Diagrams / Figures / Source Codes (if Applicable)
Figure 1. Title 3.7
Procedure/s 1. Encode the given program. Compile and assign a filename sam3.asm .model small .stack .data x db "RED$" y db "BLUE$’" .code org 100h start: main proc mov ax,@data mov ds,ax mov ah, 9 lea dx, y int 21h
ACTIVITY 3: STRING MANIPULATION
2
call down mov ah, 9 mov dx, offset x int 21h mov ah,4ch int 21h main endp down proc mov ah, 2 mov dl,13 int 21h mov dl,10 int 21h ret down endp end start
2. Write down the output of the given program.
3. Modify sam3.asm. The output should be: (Note: Use the call/ret instructions) RED RED RED RED BLUE BLUE BLUE BLUE
ACTIVITY 3: STRING MANIPULATION
3
3.8
Activity Report Section:
Date Performed:
Course Code:
Date Submitted:
Course Title: Instructor: Group No.: Group Members:
Activity No.: Signature:
1. 2. 3. 4. 5.
3.8.1
Data and Results
1. Given the sample output coming from your instructor, write down and compile the required program that will provide the expected sample output using expt3.com as the filename.
2. Encode the program. 3. Ask your instructor to check your work 4. Save the program to your data disk. 5.
What are the requirements that must be satisfied before INT 21h service 9 prints the string? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________
ACTIVITY 3: STRING MANIPULATION
4
6. What are the advantages of using procedures? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ 7. What is the use of RET instruction? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ 8. Explain how the call and ret instruction works. _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________
3.8.2
Calculations
3.8.3
Observations (if applicable) __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________
ACTIVITY 3: STRING MANIPULATION
5
3.8.4
Conclusion/s __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________
3.8.5
Rating (include Rubric)
Format & Presentation
(5%
: ________
Timeliness
(20%) : ________
Correctness
(15% ) : ________
Summary &
Conclusion
(20%)
: ________
Machine Code (40%) : ________ Total
ACTIVITY 3: STRING MANIPULATION
6