The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Other Programming Languages
|
Assembly - How to write this prog in MIPS(Mars)??
Discuss How to write this prog in MIPS(Mars)?? in the Other Programming Languages forum on Dev Shed. How to write this prog in MIPS(Mars)?? A place for discussing programming languages not covered in specific forums such as Assembler, COBOL, etc. - you get the idea.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

April 24th, 2011, 03:03 PM
|
|
Registered User
|
|
Join Date: Apr 2011
Posts: 2
Time spent in forums: 16 m 13 sec
Reputation Power: 0
|
|
|
Assembly - How to write this prog in MIPS(Mars)??
hi gents
i can't start to resolve this progarm it's so deficult ...
....Write program can be used to generate (n) random number (0<= x <1).
Show a sample output for 10 numbers????
|

April 25th, 2011, 10:06 AM
|
 |
Lord of the Dance
|
|
|
|
|
To answer your question - How to write this prog in MIPS(Mars)?):
Start learning the assemble language.. everything is difficult at the beginning.
Unless you read the sticky and have a more "direct"/precise question, the best we can do is redirect you to google and/or a assemble "manual".
Like this one: http://logos.cs.uic.edu/366/notes/mips%20quick%20tutorial.htm
You can also take at look at http://en.wikibooks.org/wiki/MIPS_Assembly
|

April 29th, 2011, 05:49 AM
|
|
Registered User
|
|
Join Date: Apr 2011
Posts: 2
Time spent in forums: 16 m 13 sec
Reputation Power: 0
|
|
here is my work but i can't find the problem
the problem when i do run only
but when i do assemple it shows me is sucssefully
Quote: a: .word 673
c: .word 37 x: .word 1
.text
lcm: ## argument: none, returns X(n+1) in $v0
lw $t1, a # const a
lw $t2, c # const c
lw $t3, x # current X
multu $t3, $t1 # HILO <- X * a
mflo $v0 # v0 <- Lo
addu $v0, $v0, $t2 # v0 += c
sw $v0, x
jr $ra
# lcminit - sets initial X for LCM RNG
# X = $a0, return#
lcminit:sw, $a0, x # save $a0 in x
jr $ra
lcmmod:
# $v0 = lcm() % $a0; return $v0
addi $sp, $sp, -4 # push return address
sw $ra, 0($sp) #
jal lcm # v0 <- lcm (32 bit word)
divu $v0, $a0
mfhi $v0 # v0 <- lcm % a0
lw $ra, 0($sp) # pop return address
addi $sp, $sp, 4 #
jr $ra
# main program
.text # main MUST BE GLOBAL
.globl main
main:
loop: # PRINT prompt
.data
prompt: .asciiz "\nX(0)(-1 to exit): "
.text
la $a0, prompt
li $v0, 4
syscall
li $v0, 5 # read i
syscall
sw $v0, -12($fp)
move $a0, $v0
jal lcminit #initialize thge LCM RNG
blt $v0, 0, exit # If i<0, exit
.data # PRINT ans
ans: .asciiz "lcm is: "
modulus:.word 1000
.text
la $a0, ans ###replaced
li $v0, 4
syscall
li $s3, 3 # loop 3 times
lcmloop:
blt $s3, 1, prompt # if done loop, get new X(0)
sub $s3, $s3, 1
lw $a0, modulus
# CALL lcmmod
jal lcmmod
# PRINT lccmod
move $a0, $v0
li $v0, 1
syscall
.data # print comma
comma: .asciiz ","
.text
la $a0, comma
li $v0, 4
syscall
b lcmloop # next lcm
exit:
li $v0, 10 # Appropriate way to end assembly code
syscall |
|

April 29th, 2011, 02:13 PM
|
 |
Lord of the Dance
|
|
|
|
|
You have to be more descriptive.
When/where (in code) does it start to fail?
What did you expect?
What actually happen?
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|