Assembler Developer

Moderators: None (Apply to moderate this forum)
Number of threads: 960
Number of posts: 1752

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
MIPS code Posted by hrp2010 on 28 Jan 2012 at 10:28 PM
I am a newbie. i wrote a code so experts help me to verify where code i wrote is good or needs to be modified and if so what needs to be modified ? thank you


Problem statement: read a string (<=4 bytes), copy string to a word in memory, display the word as an integer

########################## Data segment #######################
.data

str: .space 4 # array of 4 bytes


########################### Code Segment ######################

.text
.global main

main: # main program entry

la $a0, str # $a0 = address of str
li #a1, 4 # $a1 = max string length
li $vo, 8 # $ read string
move $s0, $a0 # copy to $so
syscall

la $a0, str
li $v0,4 # read integer 4 ( 4 is the print_string syscall ) print string str
syscall
move $a0, $s0 # copy string to $a0 and print
la $v0,1
syscall


li $vo, 10 # exit program
syscall




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.