Sei sulla pagina 1di 8

COMPUTER ENGINEERING DEPARTMENT

Computer Systems Organization and Architecture Manual

ACTIVITY7: Working with Numbers

7.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

7.2 Activity’s Intended Learning Outcomes (AILOs)


At the end of this activity, the student shall be able to:
a. Discuss the functions of ADD, SUB INC and DEC.
b. Apply and Demonstrate the different Arithmetic Instructions in Assembly Language
Code.

7.3 Objectives of the Activity


The objectives of this activity are to:
a. Understand how math works in assembly language programming.
b. Create a program that can perform numeric operations.

7.4 Principle of the Activity


An assembly program consists of a set of statements. The two type of statements are the
instructions and directives.

ACTIVITY 7: WORKING WITH NUMBERS 1


Instruction:
Such as MOV and ADD, which the assembler that translate to object code

Directives:
Which tell the assembler to perform specific action, such as define a data item.

An assembly language supports a number of statements that enable you to control


the way in which a source program assembles and list.

An operator provides a facility for changing or analyzing operands during assembly.


Operators are divided into various categories:

Calculation Operators: Arithmetic, index, logic, shift and structure field name.
Record Operators: MASK and WIDTH
Relational Operators: EQ, GE, GT, LE, LT and NE
Segment Operators: OffSET, SEG, and segment override
Type (or attribute) HIGH, HIGHWORD, LENGTH, LOW, LOWWORD, PTR,
operators) SHORT, SIZE THIS and TYPE.

Arithmetic Operators
These operators include the familiar arithmetic signs and perform arithmetic during the
assembly. In most cases, you could perform the calculation yourself, although the advantage of
using these operators is that every time you change the program and reassemble it, the assembler
automatically recalculate with an example or their use.

7.5 Materials/Equipment

1 unit Personal Computer


DOS / Command Prompt
Text Editor (SK, Notrepad, Wordpad)
Assembler (TASM.EXE)
Linker (TLINK.EXE )
Storage unit

7.6 Circuit Diagrams / Figures / Source Codes (if Applicable)

ACTIVITY 7: WORKING WITH NUMBERS 2


Figure 1. Title

7.7 Procedure/s

1. Encode the given program.


(Filename: sam7.asm)

2. Write the following program using SK’s notepad or any of your text editor using the
filename sam7.asm

.model small
.code
org 100h

start: jmp main


x db “INPUT A SINGLE DIGIT NUMBER : $”
y db “INPUT ANOTHER SINGLE DIGIT NUMBER : $”
z db “THEIR SUM IS : $”
main proc near
mov dx, offset x
call print
call input_ok
mov cl, al
call down
mov dx, offset y
call print
call input_ok
mov ch, al
call down
mov dx, offset z
call print
add ch, cl
mov ah, 2
mov dl, ch
add dl, ch
mov ah, 2
mov dl, ch
add dl, ‘0’
int 21h
ACTIVITY 7: WORKING WITH NUMBERS 3
int 20h
main endp

down proc near


mov ah, 2
mov dl, 13
int 21h
mov dl, 10
int 21h
ret
down endp

print proc near


mov ah, 9
int 21h
ret
print endp

input _ok proc near


mov ah,1
int 21h
sub al, ‘0’
ret
input_ok endp

end start

3. Execute the given program, then input 2 and 6 respectively.

4. Does the expected output appear?


-08

ACTIVITY 7: WORKING WITH NUMBERS 4


5. Execute the program again, then input 5 and 7.

6. Does the expected sum appears?


-12

7. Input other set of single digit numbers which will give a sum above nine. What do you
observed?
- It adds the two input numbers

8. Modify the program so that it will be able to display the sum of two input numbers even
if their sum is double-digit.

9. Write your new program in a separate paper.

7.8 Activity Report

Section: Date Performed:


Course Code: Date Submitted:
Course Title:
Instructor:
Group No.: Activity No.:
Group Members: Signature:
1.
2.

ACTIVITY 7: WORKING WITH NUMBERS 5


3.
4.
5.

7.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 expt7.com as
the filename.

num.asm

ASM FILE

2. Encode the program.

3. Ask your instructor to check your work

4. Save the program to your data disk..

ANSWER THE FOLLOWING QUESTIONS:

5. From your ASCII table, write the ASCII code for the following characters.

Character Decimal Hexadecimal


0
1
2
3
4

ACTIVITY 7: WORKING WITH NUMBERS 6


5
6
7
8
9
+
-
*

6. Compare the arrangement of the ASCII codes of numbers and letters. What have you
observe?

The output is ramdomly give a value number to sum

7. What method is used in getting the actual value of the input number?
add ch, cl

7.8.3 Observations

We’ve been observing that we can perform such task like mathematical addition to
out computer and it’s in a matter millisecond to get result, even though we just perform
simple mathematical programs it proves the capability of our system or cpu.

7.8.4 Conclusion/s
In conclusion with the help of our computer along with our systems and others, we can
achieve or even solve complicated mathematical programs in flexible way.

ACTIVITY 7: WORKING WITH NUMBERS 7


7.8.5 Rating (include Rubric)
Criteria Grade

Activity Conduct (1-5)

Correctness of Command(s)/Program(s) (1-5) x 2

Completeness of Tasks (1-5)

Data Analysis and Results Interpretation (1-5)

Total Score

Mean Score = (Total Score / 5)

Percentage Score = (Total Score/25) * 100


Other Comments:

ACTIVITY 7: WORKING WITH NUMBERS 8

Potrebbero piacerti anche