Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

python help needed

I am a newbie in python programming and need someone to verify whether the code i wrote is correct ? if not what is required to modify and what's the logic behind it ? Thank you in advace

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

My code:
########################## 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
Sign In or Register to comment.