Advertisement
pashok3ddd

mirroring_char

Oct 29th, 2018
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #mirroring_char
  2. .data
  3. buffer: .space 100
  4. .text
  5. main:
  6.     #---Input------
  7.     li $v0, 8
  8.     la $a0,buffer
  9.     li $a1,100
  10.     syscall
  11.     #inicialization
  12.     move $s0,$a0 # s0 - buffer base adress
  13.     move $s1,$a1 # s1 - buffer size
  14.     #t0 = 0      # t0 - iterator   
  15.     #t1          # t1 - current symbol
  16.     move $t2,$s0 # t2 - current adress
  17.     #t3      # t3 - mirrored symbol
  18.     li $t4, 219  # t4 - mirror center
  19.     #li $t5, '\n' # t5 - \n symbol
  20.     li $t6, 96  # t6 - mirror center
  21.     #--------------
  22. loop:
  23.         lb $t1,0($t2)
  24.        
  25.         sle $t5, $t1, $t6 #if loaded symbol != alpha
  26.         bne $t5, $zero, endloop
  27.        
  28.         sub $t3, $t4, $t1      
  29.         sb $t3,0($t2)  
  30.        
  31.         beq $t0,$s1,endloop #if t0 == s1
  32.         addi $t0,$t0,1
  33.         addi $t2,$t2,1
  34.         j loop
  35. endloop:   
  36.  
  37.     li $v0, 4
  38.     move $a0, $s0
  39.     # output
  40.     syscall
  41.        
  42.     li $v0, 10
  43.     # terminate program
  44.     syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement