| Extended Assembler | |||||||||||||
| ## Program to add two plus three | |||||||||||||
| .text | |||||||||||||
| .globl main | |||||||||||||
| main: | |||||||||||||
| ori $8,$0,0x2 # put two's comp. two into register 8 | |||||||||||||
| ori $9,$0,0x3 # put two's comp. three into register 9 | |||||||||||||
| addu $10,$8,$9 # add register 8 and 9, put result in 10 | |||||||||||||
| ## End of file | |||||||||||||
| Directives | |||||||||||||
| .text | defines beginning of source code | ||||||||||||
| .globl | identifies global label | ||||||||||||
| Label (symbolic address) | |||||||||||||
| main | |||||||||||||
| Defining data | |||||||||||||
| .data | # defines beginning of data area | ||||||||||||
| arr: | .word | 2, 4, 6 | # defines array of 3 words (int) | ||||||||||
| chr: | .byte | 65 | # defines 1 byte (char) | ||||||||||
| str: | .asciiz | "a string" | # defines a C-type character string | ||||||||||