Advertisement
Frads01

lab6_es1

May 12th, 2022
2,579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .data
  2.     msgTRI:     .asciiz "Triangolo rettangolo isoscele di lato 8:\n"
  3.     msgSQR:     .asciiz "\nQuadrato di lato 8:\n"
  4.  
  5. .text
  6. #----------------------------------------------------------------------------------#
  7. .globl main
  8. .ent main
  9. main:
  10.     li $v0, 4
  11.     la $a0, msgTRI
  12.     syscall
  13.     jal triangle
  14.  
  15.     li $v0, 4
  16.     la $a0, msgSQR
  17.     syscall
  18.     jal square
  19.  
  20.     li $v0, 10
  21.     syscall
  22. .ent main
  23. #----------------------------------------------------------------------------------#
  24. .globl triangle
  25. .ent triangle
  26. triangle:
  27.     li $t0, 1
  28.  
  29. outerLoop1:
  30.     beq $t0, 9, exitT
  31.     li $t1, 0
  32.  
  33. innerLoop1:
  34.     addi $t1, $t1, 1
  35.     li $v0, 11
  36.     li $a0, '*'
  37.     syscall
  38.     bne $t1, $t0, innerLoop1
  39.  
  40.     li $v0, 11
  41.     li $a0, '\n'
  42.     syscall
  43.     addi $t0, $t0, 1
  44.     j outerLoop1
  45.  
  46. exitT:
  47.     jr $ra
  48. .ent triangle
  49. #----------------------------------------------------------------------------------#
  50. .globl square
  51. .ent square
  52. square:
  53.     li $t0, 1
  54.  
  55. outerLoop2:
  56.     beq $t0, 9, exitS
  57.     li $t1, 0
  58.  
  59. innerLoop2:
  60.     addi $t1, $t1, 1
  61.     li $v0, 11
  62.     li $a0, '*'
  63.     syscall
  64.     bne $t1, 8, innerLoop2
  65.  
  66.     li $v0, 11
  67.     li $a0, '\n'
  68.     syscall
  69.     addi $t0, $t0, 1
  70.     j outerLoop2
  71.  
  72. exitS:
  73.     jr $ra
  74. .ent square
  75. #----------------------------------------------------------------------------------#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement