uni

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

lab3_ex1.asm (1555B)


      1 .eqv SYS_PRINT_WORD     1
      2 .eqv SYS_PRINT_STRING   4
      3 .eqv SYS_READ_WORD      5
      4 .eqv SYS_READ_STRING    8
      5 .eqv SYS_EXIT           10
      6 .eqv SYS_PRINT_CHAR     11
      7 .eqv SYS_READ_CHAR      12
      8 
      9 .macro endl()
     10 li      $v0, SYS_PRINT_CHAR
     11 li      $a0, 0xa
     12 syscall
     13 .end_macro
     14 
     15 .data
     16         str1: .asciiz "Hello\n"
     17         str2: .asciiz "TEI\n"
     18         name: .space 64
     19         
     20 .text
     21 .globl _main
     22 
     23 _main:
     24         # 1. print a character
     25         li      $v0, SYS_PRINT_CHAR
     26         li      $a0, 'C'
     27         syscall
     28         
     29         endl()
     30         
     31         # 2. print characters 'a' and 'd'
     32         li      $a0, 'a'
     33         syscall
     34         li      $a0, 'd'
     35         syscall
     36         
     37         endl()
     38         
     39         # 3. print 'Hello'
     40         li      $v0, SYS_PRINT_STRING
     41         la      $a0, str1
     42         syscall
     43         
     44         # 4. print 'Hello' and 'TEI'
     45         la      $a0, str1
     46         syscall
     47         la      $a0, str2
     48         syscall
     49         
     50         # 5. print 5
     51         li      $v0, SYS_PRINT_WORD
     52         li      $a0, 5
     53         syscall
     54         
     55         endl()
     56         
     57         # 6. read a word and print it
     58         li      $v0, SYS_READ_WORD
     59         syscall
     60         move    $t0, $v0
     61         li      $v0, SYS_PRINT_WORD
     62         la      $a0, 0($t0)
     63         syscall
     64         
     65         endl()
     66         
     67         # 7. read name, store in mem and print it
     68         li      $v0, SYS_READ_STRING
     69         la      $a0, name
     70         li      $a1, 64
     71         syscall
     72         li      $v0, SYS_PRINT_STRING
     73         syscall
     74         
     75         li      $v0, SYS_EXIT
     76         syscall