uni

University stuff
git clone git://git.margiolis.net/uni.git
Log | Files | Refs | README | LICENSE

lab4_ex5.asm (822B)


      1 .eqv SYS_EXIT           10
      2 .eqv SYS_PRINT_CHAR     11
      3 .eqv OUTLOOP_ITER       5
      4 .eqv INLOOP_ITER        4
      5 
      6 .text
      7 .globl main
      8 
      9 main:
     10         # init outer loop counter
     11         li      $t0, 0
     12         
     13 outloop:
     14         # exit if t0 == 5
     15         beq     $t0, OUTLOOP_ITER, exit
     16         addi    $t0, $t0, 1
     17 
     18         # init inner loop counter
     19         li      $t1, 0
     20 
     21         # print newline
     22         li      $v0, SYS_PRINT_CHAR
     23         li      $a0, 0xa
     24         syscall
     25         j       inloop
     26         
     27         j       outloop 
     28         
     29 inloop:
     30         # break inner loop if t1 == 4
     31         beq     $t1, INLOOP_ITER, outloop
     32         addi    $t1, $t1, 1
     33         
     34         li      $v0, SYS_PRINT_CHAR
     35         li      $a0, '*'
     36         syscall
     37         
     38         j       inloop
     39         
     40 exit:
     41         li      $v0, SYS_EXIT
     42         syscall