Advertisement
Frads01

lab6_es2

May 12th, 2022
2,880
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .data
  2.     msgTRI:     .asciiz "\nTriangolo rettangolo isoscele di lato "
  3.     msgSQR:     .asciiz "\nQuadrato di lato "
  4.     msgDIM:     .asciiz "Inserire dimensione lato: "
  5.     msgEND:     .asciiz ":\n"
  6.  
  7. .text
  8. #----------------------------------------------------------------------------------#
  9. .globl main
  10. .ent main
  11. main:
  12.     li $v0, 4
  13.     la $a0, msgDIM
  14.     syscall
  15.  
  16.     li $v0, 5
  17.     syscall
  18.     move $s0, $v0
  19.  
  20.     li $v0, 4
  21.     la $a0, msgTRI
  22.     syscall
  23.     li $v0, 1
  24.     move $a0, $s0
  25.     syscall
  26.     li $v0, 4
  27.     la $a0, msgEND
  28.     syscall
  29.  
  30.     move $a0, $s0
  31.     jal triangle
  32.  
  33.     li $v0, 4
  34.     la $a0, msgSQR
  35.     syscall
  36.     li $v0, 1
  37.     addi $s0, $s0, -1
  38.     move $a0, $s0
  39.     syscall
  40.     li $v0, 4
  41.     la $a0, msgEND
  42.     syscall
  43.  
  44.     move $a0, $s0
  45.     jal square
  46.  
  47.     li $v0, 10
  48.     syscall
  49. .ent main
  50. #----------------------------------------------------------------------------------#
  51. .globl triangle
  52. .ent triangle
  53. triangle:
  54.     li $t0, 1
  55.     move $s0, $a0
  56.     addi $s0, $s0, 1
  57.  
  58. outerLoop1:
  59.     beq $t0, $s0, exitT
  60.     li $t1, 0
  61.  
  62. innerLoop1:
  63.     addi $t1, $t1, 1
  64.     li $v0, 11
  65.     li $a0, '*'
  66.     syscall
  67.     bne $t1, $t0, innerLoop1
  68.  
  69.     li $v0, 11
  70.     li $a0, '\n'
  71.     syscall
  72.     addi $t0, $t0, 1
  73.     j outerLoop1
  74.  
  75. exitT:
  76.     jr $ra
  77. .ent triangle
  78. #----------------------------------------------------------------------------------#
  79. .globl square
  80. .ent square
  81. square:
  82.     li $t0, 1
  83.     move $s0, $a0
  84.     addi $s1, $s0, 1
  85.  
  86. outerLoop2:
  87.     beq $t0, $s1, exitS
  88.     li $t1, 0
  89.  
  90. innerLoop2:
  91.     addi $t1, $t1, 1
  92.     li $v0, 11
  93.     li $a0, '*'
  94.     syscall
  95.     bne $t1, $s0, innerLoop2
  96.  
  97.     li $v0, 11
  98.     li $a0, '\n'
  99.     syscall
  100.     addi $t0, $t0, 1
  101.     j outerLoop2
  102.  
  103. exitS:
  104.     jr $ra
  105. .ent square
  106. #----------------------------------------------------------------------------------#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement