943,924 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 551
  • Assembly RSS
Sep 15th, 2009
0

why is it not printing out.. please help

Expand Post »
[code]
.txt
.globl main

main:

# f= (g+h)-(i+j);

li $s0,0
li $t1,0
li $t2,0
li $s1,4
li $s2,5
li $s3,6
li $s4,7

add $t1, $s1, $s2 # sum of s1,s2 is stored in t1 or temporary variable
t1 contains g+h

add $t2, $s3, $s4 # sum of s3,s4 is stored in t2 or temporary variable
t2 contains i+j

sub $s0, $t1, $t2 # s0 gets $t1- $t2, which is (g+h)-(i+j)
li $v0,1
move $ao, $s0 # suppose to printf("f=%d\n",f)
li $v0, 10
syscall
#it is giving me syntax error
[icode]
Last edited by shopnobhumi; Sep 15th, 2009 at 3:04 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
shopnobhumi is offline Offline
37 posts
since Sep 2008
Sep 15th, 2009
1

Re: why is it not printing out.. please help

You have a problem with the MARS library.

li $v0,1 Print integer
mov $a0,$s0 a0 is integer
syscall <--- MISSING

li $v0,10
syscall #exit
Reputation Points: 546
Solved Threads: 99
Practically a Posting Shark
wildgoose is offline Offline
891 posts
since Jun 2009
Sep 15th, 2009
0

Re: why is it not printing out.. please help

Click to Expand / Collapse  Quote originally posted by wildgoose ...
You have a problem with the MARS library.

li $v0,1 Print integer
mov $a0,$s0 a0 is integer
syscall <--- MISSING

li $v0,10
syscall #exit
oh thank you but i am still getting syntax error while trying to load on PCSpim as it is saying problem with line where it says .globl main
Reputation Points: 10
Solved Threads: 0
Light Poster
shopnobhumi is offline Offline
37 posts
since Sep 2008
Sep 15th, 2009
0

Re: why is it not printing out.. please help

i meant to say it is not running
Reputation Points: 10
Solved Threads: 0
Light Poster
shopnobhumi is offline Offline
37 posts
since Sep 2008
Sep 15th, 2009
0

Re: why is it not printing out.. please help

here is the code but it is giving me syntax error on function main. Can anyone tell me why please
[code].txt
.globl main

main:
# f= (g+h)-(i+j);

li $s0,0
li $t1,0
li $t2,0
li $s1,4
li $s2,5
li $s3,6
li $s4,7

add $t1, $s1, $s2

add $t2, $s3, $s4

sub $s0, $t1, $t2
li $v0,1
move $a0, $s0
syscall
li $v0, 10
syscall [icode]
Reputation Points: 10
Solved Threads: 0
Light Poster
shopnobhumi is offline Offline
37 posts
since Sep 2008
Sep 15th, 2009
0

Re: why is it not printing out.. please help

I downloaded the PCSPIM simulator and it doesn't like the system calls or the .txt label. I typically use a real MIPS processor, with real tools. Were you instructed to use this simulator, and where did the sample program or the control syntax of your sample program come from? I see no reference to those declarations in PCPSIM's help file!
And no MARS library reference.
Reputation Points: 546
Solved Threads: 99
Practically a Posting Shark
wildgoose is offline Offline
891 posts
since Jun 2009
Sep 15th, 2009
0

Re: why is it not printing out.. please help

Okay, had to get away from it, download and read the Appendix A document, twiddle and retry. It ran. Answer -4.
I also tabbed the text as normally it isn't suppose to be in column 1 but not sure if that was it or not!

Asm Syntax (Toggle Plain Text)
  1. .text
  2. .align 2
  3. .globl main
  4.  
  5. main:
  6. # f= (g+h)-(i+j);
  7.  
  8. li $s0,0
  9. li $t1,0
  10. li $t2,0
  11. li $s1,4
  12. li $s2,5
  13. li $s3,6
  14. li $s4,7
  15.  
  16. add $t1, $s1, $s2
  17.  
  18. add $t2, $s3, $s4
  19.  
  20. sub $s0, $t1, $t2
  21. li $v0,1
  22. move $a0, $s0
  23. syscall
  24.  
  25. li $v0, 10
  26. syscall
Reputation Points: 546
Solved Threads: 99
Practically a Posting Shark
wildgoose is offline Offline
891 posts
since Jun 2009

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: Assembly in ARM Devices
Next Thread in Assembly Forum Timeline: Nohau Emulator Problem





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


Follow us on Twitter


© 2011 DaniWeb® LLC