Created
May 13, 2012 17:16
-
-
Save mamprogr/2689350 to your computer and use it in GitHub Desktop.
bonian home work
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.data | |
wmsg : .asciiz "welcome \nstudent : Mohmmad Eyad Arnabeh \nNum : 345 \n" | |
getmsg : .asciiz "Please Enter a statment : \n" | |
msg0 : .asciiz "your sentence is : " | |
msg1 : .asciiz "Please Enter a character :\n" | |
msg2 : .asciiz "your char is :\n" | |
msg3 : .asciiz "\nnot found \n" | |
str : .space 256 | |
chr : .space 1 | |
.text | |
.globl main | |
main: | |
#printing the welcome message . | |
la $a0,wmsg | |
li $v0,4 | |
syscall | |
#ask the user to insert a statment . | |
la $a0,getmsg | |
li $v0,4 | |
syscall | |
#get user string | |
li $v0,8 | |
syscall | |
move $s0,$a0 | |
move $s2,$a1 #get string length | |
#print it | |
li $v0,4 | |
la $a0,msg0 | |
syscall | |
li $v0,4 | |
move $a0,$s0 | |
syscall | |
#ask the user to enter a char | |
la $a0,msg1 | |
li $v0,4 | |
syscall | |
#get user char | |
li $v0,8 | |
la $a0,chr | |
syscall | |
#print usr char | |
li $v0,4 | |
la $a0,msg2 | |
syscall | |
la $a0,chr | |
li $v0,4 | |
syscall | |
# search | |
search : | |
lb $t0,0($s0) | |
beq $t1,0,nfound | |
bne $t0,$s1,search | |
beq $t0,$s1,found | |
found : | |
li $v0,4 | |
move $a0,$t0 | |
syscall | |
nfound : | |
la $a0,msg3 | |
li $v0,4 | |
syscall | |
li $v0,10 | |
syscall | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment