0% found this document useful (0 votes)
132 views14 pages

TIP-Quezon City College of Information Technology Education Bachelor of Science in Information Technology

This document contains assembly language code for 4 programs that perform basic math operations (addition, subtraction, multiplication, division) on two user-input numbers. It also includes a batch file program that allows a user to select which math operation they want to perform and then inputs and displays the calculation. The programs take in two numeric values, perform the selected math operation, and display the result.

Uploaded by

Jerome Vargas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views14 pages

TIP-Quezon City College of Information Technology Education Bachelor of Science in Information Technology

This document contains assembly language code for 4 programs that perform basic math operations (addition, subtraction, multiplication, division) on two user-input numbers. It also includes a batch file program that allows a user to select which math operation they want to perform and then inputs and displays the calculation. The programs take in two numeric values, perform the selected math operation, and display the result.

Uploaded by

Jerome Vargas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

TIP-Quezon City

College of Information Technology Education


Bachelor of Science in Information Technology

Simple As Possible 1 Computer


(SAP 1)

In Partial Fulfillment
of the Requirement of the Subject
Computer System Organization
With Assembly Language
(CSO002L1)

Presented by:
Betchie Rose Dahili
Tere Pasquil
Kev Angel
Eniel Peter Marcelo
Vargas Jerome
Kevin Cachuela
Gregy Conti
Presented to:
Junnel E. Avestro
Adviser

August 2014

Program 1 (ADD)
.model small
.stack 100h
.data
prompt1 DB 10,13, 'First number $'
prompt2 DB 10,13, 'Second number $'
result DB 13, 10, 'the sum is $'
;Variables
num1 dw ?
num2 dw ?
sum dw ?
.code
main proc
mov ax,
mov ds,

@data
;get data segment address
ax ;initialize ds

;Display Prompt
mov ah, 9
;print string function
mov dx, offset prompt1
;ds:dx points to string
int 21h
mov ah, 1
int 21h
xor ah, ah
mov num1, ax

;input function
;clear the top 8 bits of ax
;save the value from input

mov ah, 9
mov dx, offset prompt2
int 21h
mov ah, 1
int 21h
xor ah, ah
mov num2, ax
;Addition
sub num1, '0'
sub num2, '0'
mov ax, num1

;print prompt

;input second function


;clear the top 8 bits of ax
;save the value from second input

;move num1 into ax

add ax, num2


mov sum, ax
add sum, '0'

;add first and second numbers together


;move the total sum of numbers in sum

;Print Sum
mov ah,9
lea dx, result
int 21h
mov ah,2
mov dx, sum
int 21h

mov ah,4ch
int 21h
main endp

end main

; print result

Program 2 (SUBTRACTION)
.model small
.stack 100h
.data
prompt1 DB 10,13, 'First number $'
prompt2 DB 10,13, 'Second number $'
result DB 13, 10, 'the difference is $'
;Variables
num1 dw ?
num2 dw ?
dif dw ?
.code
main proc
mov ax,
mov ds,

@data
;get data segment address
ax ;initialize ds

;Display Prompt
mov ah, 9
;print string function
mov dx, offset prompt1
;ds:dx points to string
int 21h
mov ah, 1
int 21h
xor ah, ah
mov num1, ax

;input function
;clear the top 8 bits of ax
;save the value from input

mov ah, 9
mov dx, offset prompt2
int 21h

;print prompt

mov ah, 1
int 21h
xor ah, ah
mov num2, ax

;input second function


;clear the top 8 bits of ax
;save the value from second input

;difference
sub num1, '0'
sub num2, '0'
mov ax, num1
sub ax, num2

;move num1 into ax


;sub first and second numbers together

mov dif, ax
add dif, '0'

;move the total dif of numbers in dif

;Print Sum
mov ah,9
lea dx, result
int 21h
mov ah,2
mov dx, dif
int 21h

mov ah,4ch
int 21h
main endp

end main

; print result

Program 3 (MULTIPLICATION)
.model small
.stack 100h
.data
prompt1 DB 10,13, 'First number $'
prompt2 DB 10,13, 'Second number $'
result DB 13, 10, 'the product is $'
;Variables
num1 dw ?
num2 dw ?
prod dw ?
.code
main proc
mov ax,
mov ds,

@data
;get data segment address
ax ;initialize ds

;Display Prompt
mov ah, 9
;print string function
mov dx, offset prompt1
;ds:dx points to string
int 21h
mov ah, 1
int 21h
xor ah, ah
mov num1, ax

;input function
;clear the top 8 bits of ax
;save the value from input

mov ah, 9
mov dx, offset prompt2
int 21h
mov ah, 1
int 21h
xor ah, ah
mov num2, ax
;product
sub num1, '0'
sub num2, '0'
mov ax, num1
mov dx, num2

;print prompt

;input second function


;clear the top 8 bits of ax
;save the value from second input

;move num1 into ax


;move num2 into dx

mul dx
mov prod, ax
add prod, '0'

;multiply first (ax) and second (dx) numbers together


;move the total product of numbers in mul

;Print Sum
mov ah,9
lea dx, result
int 21h
mov ah,2
mov dx, prod
int 21h

mov ah,4ch
int 21h
main endp

end main

; print result

Program 4 (DIVISION)
.model small
.stack 100h
.data
prompt1 DB 10,13, 'First number $'
prompt2 DB 10,13, 'Second number $'
result DB 13, 10, 'the quotient is $'
;Variables
num1 dw ?
num2 dw ?
quo dw ?
.code
main proc
mov ax,
mov ds,

@data
;get data segment address
ax ;initialize ds

;Display Prompt
mov ah, 9
;print string function
mov dx, offset prompt1
;ds:dx points to string
int 21h
mov ah, 1
int 21h
xor ah, ah
mov num1, ax

;input function
;clear the top 8 bits of ax
;save the value from input

mov ah, 9
mov dx, offset prompt2
int 21h
mov ah, 1
int 21h
xor ah, ah
mov num2, ax
;quotient
sub num1, '0'
sub num2, '0'
mov ax, num1
mov bx, num2

;print prompt

;input second function


;clear the top 8 bits of ax
;save the value from second input

;move num1 into ax


;move num2 into bx

div bx
mov quo, ax
add quo, '0'

;divide first (ax) and second (bx) numbers together


;move the total quotient of numbers in quo

;Print Sum
mov ah,9
lea dx, result
int 21h
mov ah, 2
mov dx, quo
int 21h

mov ah,4ch
int 21h
main endp

end main

; print result

Program 6
@echo off
:start
Echo Press 1 for Addition
echo Press 2 for Subtraction
echo Press 3 for Multiplication
echo Press 4 for Division
echo Press 5 to Quit
set /p type=
if %type%==1 goto a
if %type%==2 goto b
if %type%==3 goto c
if %type%==4 goto d
if %type%==5 goto e
:a
echo Addition
echo Please choose the 2 numbers you wish to add
set /p num1=
set /p num2=
echo %num1%+%num2%?
pause
set /a Answer=%num1%+%num2%
echo %Answer%
pause
goto start
:b
echo Subtraction
echo Please choose the 2 numbers you wsh to subtract
set /p num1=
set /p num2=
echo %num1%-%num2%?
pause
set /a Answer=%num1%-%num2%

echo %Answer%
pause
goto start
:c
echo Multiplication
echo Please choose the 2 numbers you wish to multiply
set /p num1=
set /p num2=
echo %num1%*%num2%?
pause
set /a Answer=%num1%*%num2%
echo %Answer%
pause
goto start
:d
echo Division
echo Please choose the 2 numbers you wish to divide
set /p num1=
set /p num2=
echo %num1%/%num2%?
pause
set /a Answer=%num1%/%num2%
echo %Answer%
pause
goto start
:e
echo.

You might also like