删除MIPS中的换行符

时间:2014-02-16 17:09:14

标签: arrays assembly newline mips

我正在用MIPS编写一个程序,我将篮球运动员的名字存储在一个数组中。我查看了Stackoverflow上的现有代码,看看我如何删除从控制台读入的每个名称的换行符;但是,代码似乎对我不起作用。有人能帮我查明错误吗?这是相关代码的一部分:

.align 2 

.text
.globl main 

#PART ONE: READ INPUT, CREATE ARRAY OF STRUCTS 
#$t0 stores number of players
#$t1 is loop counter 
#$s0 stores memory allocation of entry
#$s1 also stores memory allocation, but will be used as array counter 

main: 
la      $a0, num                    
li      $v0, 4                      
syscall                             

li      $v0, 5                      
syscall                             
move    $a0, $v0                    

move    $t0, $a0                     
move    $t1, $a0                    
mul     $a0, $a0, 20        

li      $v0, 9                      
syscall                             
move    $s0, $v0                    
move    $s1, $v0                    

input:
beqz    $t1, set_counter            
la      $a0, name                   
li      $v0, 4                      
syscall                             

la      $a0, ($s1)                  
li      $a1, 16                     

li      $v0, 8                      
syscall                             

li      $t3, 0                      

strip: 
lb      $a2, ($a0)                  
addi    $t3, $t3, 1                 
addi    $a0, $a0, 1                 
bnez    $a2, strip                  
beq     $a1, $t3, continue_prompt   
sub     $a0, $a0, 2                 
sb      $0, ($a0)   

continue_prompt: 
la      $a0, points                 
li      $v0, 4                      
syscall                             

#read points per game 
li      $v0, 6                      
syscall                             
mov.s   $f2, $f0                     

la      $a0, minutes                
li      $v0, 4                      
syscall                             

#read minutes in game 
li      $v0, 6                  
syscall                             
mov.s   $f4, $f0                     

#compute points/minute 
div.s   $f0, $f2, $f4                
s.s     $f0, 16($s1)                
addi    $s1, $s1, 20                
addi    $t1, -1                     
b       input                       

.data 
num:        .asciiz    "Enter number of basketball players: "
name:       .asciiz    "Last name of player: "
points:     .asciiz     "Points per game: "
minutes:    .asciiz     "Minutes per game: "
space:      .ascii       " "
newline:    .asciiz      "\n"

0 个答案:

没有答案