944,142 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 1415
  • Assembly RSS
Dec 4th, 2007
0

I Desperately need help with this assignment!!

Expand Post »
Hi All!

I have a programming assignment that ive been trying to work on. Recently, ive successfully wrote it in java, but im trying to use that as psuedocode so that i can transcribe it into mips - but i dont understand this stuff! ive been reading this book but it honestly doesnt help!

the assignment reads:

1. In the data segment, allocate static space for a long vector of integers.
2. Assign values from x1 to x2 (increment for the next value through the entire vector), where x1 and x2 must be obtained through a dialog with a user. Check for errors in the input (such as x2 greater or equal to x1; Too long vector; etc.)
3. Ask the user to input a number, which will indicate the number of rows of a matrix the stored vector will be converted into.
4. Find out, through a division operation, the number of columns of this matrix.
5. Print the matrix
6. Transpose this matrix – use indexed addressing mode.
7. Print the transposed matrix.
8. Terminate the program.

also, i do not understand the compiler used - im using PCSpim - any clues would help..

any help would be greatly apprciated! Thanks in advance
Last edited by hsanjakd; Dec 4th, 2007 at 9:11 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hsanjakd is offline Offline
1 posts
since Dec 2007
Dec 4th, 2007
0

Re: I Desperately need help with this assignment!!

Here's some desperate help:

If I understand your problem correctly, you must get two numbers from the user, x1 and x2, then make an array (or vector) of values from x1 to x2 inclusive?

PCSpim is neither a compiler nor a proper assembler. It is a simulator for a virtual machine.

Write your tal program using your favorite plain-text editor (like emacs or notepad or whatever), load it into spim, and run it with the "Go" button. The only caveat to using Spim is that your program must begin with the label "main" instead of "__start".

Try typing in some simple examples from your textbook. Then try creating some simple examples of your own design.

Here's a simple example designed to help you in your project:
Assembly Syntax (Toggle Plain Text)
  1. # Example program to print a friendly
  2. # message five times, then quit.
  3.  
  4.  
  5. .data
  6.  
  7. # This is static data.
  8. # Its size does not change.
  9.  
  10. # This is the string to print
  11. str_hello: .asciiz "Hello world!\n"
  12.  
  13. # These are syscall argument values
  14. # (I like to name them for easy use)
  15. print_string: .word 4 # $a0 : address of string to print
  16. exit: .word 10
  17.  
  18.  
  19. .text
  20.  
  21. # print_n_times( str_hello, 5 )
  22. main: la $a0, str_hello
  23. li $a1, 5
  24. jal print_n_times
  25.  
  26. # quit
  27. lw $2, exit
  28. syscall
  29.  
  30. # subroutine
  31. # arguments:
  32. # $a0 : address of string to print
  33. # $a1 : number of times to print it
  34. #
  35. # preserve return address on stack
  36. print_n_times: sub $sp, 4
  37. sw $ra, 4($sp)
  38.  
  39. # can't print < 0 times...
  40. bltz $a1, pnt_end
  41.  
  42. # done if no more to print
  43. loop: beq $a1, $0, pnt_end
  44.  
  45. # print the string at m[$a0]
  46. lw $2, print_string
  47. syscall
  48.  
  49. # number of times to print -= 1
  50. sub $a1, $a1, 1
  51.  
  52. # next
  53. b loop
  54.  
  55. # pop return address and return
  56. pnt_end: lw $ra, 4($sp)
  57. add $sp, 4
  58. jr $ra
  59.  

The WikiPedia article has a section on MIPS Assembly Language that lists all the syscall arguments and return values and all the opcodes you'll need.

Hope this helps.
Featured Poster
Reputation Points: 1140
Solved Threads: 229
Postaholic
Duoas is offline Offline
2,039 posts
since Oct 2007
Dec 5th, 2007
0

Re: I Desperately need help with this assignment!!

You can first write in c/c++ and decompile it to assembly and get some idea how to code it
Reputation Points: 769
Solved Threads: 128
Banned
ithelp is offline Offline
1,910 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: strcat in MIPS
Next Thread in Assembly Forum Timeline: Simple EEPROM Programmer Through Parallel PC Port (also posted in Developers lounge)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC