![]() |
|
#1
|
|||
|
|||
ASM programHey
Im currently trying to learn the asm language but im struggling to edit this program to make it do what i want. Atm it just tells me the number of a chosen letter in the string given but i want it to count the number of more than 1 letters if it makes sense Iv tried changing it but it gives me the wrong number. Can anyone help please? ## t0 - holds each byte from string in turn ## t1 - index into array: k in str(k) ## t2 - count of occurences ## t3 - holds the character to search for ## .text .globl main main: nop # initialise loop variables [no operation 'instruction'] li $t1,0 # $t1 will be the array index li $t2,0 # $t2 will be the counter lb $t3,char # $t3 holds the search-for character # loop: lb $t0,str($t1) # fetch next character # from location: str + ($t1) i.e. " str(k)" # indexed addressing (= base + offset) # (psuedo instruction; assembles as two actual instructions) beqz $t0,strEnd # if it's a null, then exit loop bne $t0,$t3,con # else not null; is it same as target char? add $t2,$t2,1 # yes, so increment counter con: add $t1,$t1,1 # and either way increment index: "k = k + 1" j loop # then continue to work along string # strEnd: # string search all done so deliver output la $a0,str # system call to print the string li $v0,4 syscall la $a0,txt1 # then print output message syscall la $a0,char # with target char in syscall la $a0,txt2 # then print output link message syscall move $a0,$t2 # system call to print [ = 'copy'] li $v0,1 # out the count worked out syscall la $a0,endl # system call to print li $v0,4 la $a0,txt1 syscall la $a0,char2 syscall la $a0,txt2 # then print output link message syscall move $a0,$t2 # system call to print [ = 'copy'] li $v0,1 # out the count worked out syscall la $a0,endl # system call to print li $v0,4 # out a newline and identity sign-off syscall li $v0,10 # (usual quit) syscall # au revoir... ### .data str: .asciiz "abcde" # char: .asciiz "a" # char2: .asciiz "z" # txt1: .asciiz "\n\n the number of " txt2: .asciiz " in the above string is:: " endl: .asciiz "\n Bye, please test again! \n" # ## end |
|||
|
#2
|
|||
|
|||
Re: ASM programWhat assembler? What OS?
|
|
#3
|
|||
|
|||
Re: ASM programPCSpim on XP/vista
|
|
#4
|
|||
|
|||
Re: ASM programMIPs assembler!
Sorry I don't know anything about that and don't have time to learn it right now... Maybe someone else would happen by and enlighten us both? |
|
#5
|
|||
|
|||
Re: ASM programoh ok Howard, thank you for looking though
Yes i hope someone can help me with my problem |
|
#6
|
|||
|
|||
Re: ASM programAlright , you talked me into it...
It is a quick install for windows and I am reading up on MIPs assembly with this: chortle.ccsu.edu/AssemblyTutorial/TutorialContents.html I just opened the chapter 9 sample program ... and LOOK AT ALL THOSE REGISTERS!!! This should be interesting. Maybe I can catch up to you in a day or so... I need to get familiar with the cpu and assembler syntax etc. |
|
#7
|
|||
|
|||
Re: ASM programoo interesting site youve found there..might take a look myself too!
haha yup this is terrible. Ah thank you! |
|
#8
|
|||
|
|||
Re: ASM programWell it turns out that your program runs about how I think you wanted it to:
Code:
So what was it you were having trouble with? Above you had said: Quote:
I did have trouble getting the program to load in PCSpim at first. The problem seemed to be with the commands like li. Then I was scanning in the code samples at the chortle.ccsu.edu tutorials and found that they begin using those commands in chapter 22. In the 'programs' part of that chapter they say this: Quote:
I don't have the delayed branches setting available in my PCSpim... which (according to the help info) is: PCSpim Version 1.0 SPIM Version 6.2 of January 6, 1999 .... But it runs. If I open the register, text, data, windows and situate them just so in the main window I get a pretty good view of things. It's easy to see your register values change. Pretty neat little program. The console window on the other hand kept disappearing although I could open it up (even after the program was finished) from the "Window" menu. So what , are you going to work on Nintendo games? Last edited by Howard_L : 19-Feb-2009 at 22:26.
|
|
#9
|
|||
|
|||
Re: ASM programQuote:
Do you know how to fix it so it checks char2 aswell and give the correct result at all? Well im just trying to get to grips with similar programs like this and for example using asm for useful programs like converting things like metres into inches etc...maybe soon I can develop more advanced stuff. |
|
#10
|
|||
|
|||
Re: ASM programSo you didn't write this did you... great.
There is already a test in place for char. You would do the same thing for char2. If you do not know how , you should go through the tutorial listed above and learn how. It's all there. |
Recent GIDBlog
Problems with the Navy (Chiefs) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Equation solver | RazoR | C Programming Language | 3 | 18-May-2008 10:24 |
| Two-Tier data dissemination code installation problem | nidhibansal1984 | Computer Software Forum - Linux | 6 | 16-Sep-2007 11:13 |
| BOOKEEPING program, HELP!! | yabud | C Programming Language | 10 | 17-Nov-2006 04:48 |
| Help with a complex program | lordfuoco | C++ Forum | 5 | 24-Jun-2006 07:03 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The