SlideShare a Scribd company logo
1 of 2
COMPUTER ORGANISATION
ASSIGNMENT
.data
a : .word 1 # the first term of the GP
r : .word 2 # the common ratio of the GP
n : .word 4 # the number of terms in the GP
# Function to compute the sum of a geometric progression
.text
.globl main
main:
lw $t5, a # load the address of the first term into $a0
lw $t6, r # load the address of the common ratio into $a1
lw $t7, n # load the number of terms into $a2
li $t2 , 1
pow:
beqz $t7, print # branch to print if y = 0
mult $t2, $t6 # multiply result by x
mflo $t2
addi $t7, $t7, -1 # decrement y
j pow # jump to loop
print:
sub $t2 , $t2 , 1
mult $t2, $t5 # multiply result by x
mflo $t2
sub $t6 , $t6 , 1
mtc1 $t2, $f6 # move to flt reg
cvt.s.w $f6, $f6 # cvt to flt format
mtc1 $t6, $f8 # move to float reg
cvt.s.w $f8, $f8 # cvt to float format
div.s $f12, $f6, $f8
li $v0 , 2
syscall
li $v0, 10 # load system call for exit
syscall
.end main

More Related Content

Similar to Final assignment sem2.docx

32 shell-programming
32 shell-programming32 shell-programming
32 shell-programming
kayalkarnan
 
Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Phpをいじり倒す10の方法
Phpをいじり倒す10の方法
Moriyoshi Koizumi
 
An Assembly program to find the factorial of decimal number given by.pdf
An Assembly program to find the factorial of decimal number given by.pdfAn Assembly program to find the factorial of decimal number given by.pdf
An Assembly program to find the factorial of decimal number given by.pdf
krram1989
 
C:\Fakepath\Chapter 2 Part2 B
C:\Fakepath\Chapter 2 Part2 BC:\Fakepath\Chapter 2 Part2 B
C:\Fakepath\Chapter 2 Part2 B
ececourse
 

Similar to Final assignment sem2.docx (10)

Plsql programs(encrypted)
Plsql programs(encrypted)Plsql programs(encrypted)
Plsql programs(encrypted)
 
Lecture19-20
Lecture19-20Lecture19-20
Lecture19-20
 
Lecture19-20
Lecture19-20Lecture19-20
Lecture19-20
 
32 shell-programming
32 shell-programming32 shell-programming
32 shell-programming
 
Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Phpをいじり倒す10の方法
Phpをいじり倒す10の方法
 
Creating a compiler in Perl 6
Creating a compiler in Perl 6Creating a compiler in Perl 6
Creating a compiler in Perl 6
 
Perl6 for-beginners
Perl6 for-beginnersPerl6 for-beginners
Perl6 for-beginners
 
An Assembly program to find the factorial of decimal number given by.pdf
An Assembly program to find the factorial of decimal number given by.pdfAn Assembly program to find the factorial of decimal number given by.pdf
An Assembly program to find the factorial of decimal number given by.pdf
 
Tutorial perl programming basic eng ver
Tutorial perl programming basic eng verTutorial perl programming basic eng ver
Tutorial perl programming basic eng ver
 
C:\Fakepath\Chapter 2 Part2 B
C:\Fakepath\Chapter 2 Part2 BC:\Fakepath\Chapter 2 Part2 B
C:\Fakepath\Chapter 2 Part2 B
 

Recently uploaded

Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..
MaherOthman7
 

Recently uploaded (20)

Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..
 
BURGER ORDERING SYSYTEM PROJECT REPORT..pdf
BURGER ORDERING SYSYTEM PROJECT REPORT..pdfBURGER ORDERING SYSYTEM PROJECT REPORT..pdf
BURGER ORDERING SYSYTEM PROJECT REPORT..pdf
 
Lab Manual Arduino UNO Microcontrollar.docx
Lab Manual Arduino UNO Microcontrollar.docxLab Manual Arduino UNO Microcontrollar.docx
Lab Manual Arduino UNO Microcontrollar.docx
 
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisSeismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
 
analog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptxanalog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptx
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
 
Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility Applications
 
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
 
How to Design and spec harmonic filter.pdf
How to Design and spec harmonic filter.pdfHow to Design and spec harmonic filter.pdf
How to Design and spec harmonic filter.pdf
 
Software Engineering - Modelling Concepts + Class Modelling + Building the An...
Software Engineering - Modelling Concepts + Class Modelling + Building the An...Software Engineering - Modelling Concepts + Class Modelling + Building the An...
Software Engineering - Modelling Concepts + Class Modelling + Building the An...
 
ChatGPT Prompt Engineering for project managers.pdf
ChatGPT Prompt Engineering for project managers.pdfChatGPT Prompt Engineering for project managers.pdf
ChatGPT Prompt Engineering for project managers.pdf
 
Piping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdfPiping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdf
 
RM&IPR M5 notes.pdfResearch Methodolgy & Intellectual Property Rights Series 5
RM&IPR M5 notes.pdfResearch Methodolgy & Intellectual Property Rights Series 5RM&IPR M5 notes.pdfResearch Methodolgy & Intellectual Property Rights Series 5
RM&IPR M5 notes.pdfResearch Methodolgy & Intellectual Property Rights Series 5
 
Multivibrator and its types defination and usges.pptx
Multivibrator and its types defination and usges.pptxMultivibrator and its types defination and usges.pptx
Multivibrator and its types defination and usges.pptx
 
Fabrication Of Automatic Star Delta Starter Using Relay And GSM Module By Utk...
Fabrication Of Automatic Star Delta Starter Using Relay And GSM Module By Utk...Fabrication Of Automatic Star Delta Starter Using Relay And GSM Module By Utk...
Fabrication Of Automatic Star Delta Starter Using Relay And GSM Module By Utk...
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
Theory for How to calculation capacitor bank
Theory for How to calculation capacitor bankTheory for How to calculation capacitor bank
Theory for How to calculation capacitor bank
 
Intelligent Agents, A discovery on How A Rational Agent Acts
Intelligent Agents, A discovery on How A Rational Agent ActsIntelligent Agents, A discovery on How A Rational Agent Acts
Intelligent Agents, A discovery on How A Rational Agent Acts
 
Circuit Breaker arc phenomenon.pdf engineering
Circuit Breaker arc phenomenon.pdf engineeringCircuit Breaker arc phenomenon.pdf engineering
Circuit Breaker arc phenomenon.pdf engineering
 
Introduction to Arduino Programming: Features of Arduino
Introduction to Arduino Programming: Features of ArduinoIntroduction to Arduino Programming: Features of Arduino
Introduction to Arduino Programming: Features of Arduino
 

Final assignment sem2.docx

  • 1. COMPUTER ORGANISATION ASSIGNMENT .data a : .word 1 # the first term of the GP r : .word 2 # the common ratio of the GP n : .word 4 # the number of terms in the GP # Function to compute the sum of a geometric progression .text .globl main main: lw $t5, a # load the address of the first term into $a0 lw $t6, r # load the address of the common ratio into $a1 lw $t7, n # load the number of terms into $a2 li $t2 , 1 pow: beqz $t7, print # branch to print if y = 0 mult $t2, $t6 # multiply result by x mflo $t2 addi $t7, $t7, -1 # decrement y j pow # jump to loop
  • 2. print: sub $t2 , $t2 , 1 mult $t2, $t5 # multiply result by x mflo $t2 sub $t6 , $t6 , 1 mtc1 $t2, $f6 # move to flt reg cvt.s.w $f6, $f6 # cvt to flt format mtc1 $t6, $f8 # move to float reg cvt.s.w $f8, $f8 # cvt to float format div.s $f12, $f6, $f8 li $v0 , 2 syscall li $v0, 10 # load system call for exit syscall .end main