uni

University stuff
git clone git://git.christosmarg.xyz/uni-assignments.git
Log | Files | Refs | README | LICENSE

lab5_ex4.asm (854B)


      1 .eqv SYS_EXIT 10
      2 
      3 .data
      4         val:    .word 0xabcd
      5         # 'val' is 2 bytes
      6         first:  .space 2
      7         second: .space 2
      8         third:  .space 2
      9         fourth: .space 2
     10 
     11 .text
     12 .globl main
     13 
     14 main:
     15         # init loop counter
     16         li      $t0, 0
     17         # 4 iterations because we'll store 'val' 4 times
     18         li      $t1, 4
     19         # this is our offset, we'll increment it by 2
     20         # in each iteration so that we store 0xabcd in
     21         # the appropriate label
     22         li      $t2, 0
     23         lh      $t3, val
     24         
     25 loop:
     26         beq     $t0, $t1, exit
     27         # store it as half word so that it and doesn't
     28         # there aren't any zeros between that and the next 'val'
     29         sh      $t3, first($t2)
     30         addi    $t0, $t0, 1
     31         addi    $t2, $t2, 2
     32         j       loop
     33 
     34 exit:
     35         li      $v0, SYS_EXIT
     36         syscall