Intrinsic Data Types (Cont.)
Some examples of data type usage are given below:
.ascii |
.byte |
.data
s: .ascii "xyz"
.byte 0
.text
la $a0, s
li $v0, 4
syscall
|
|
.data
s: .byte 'x','y','z', 0
.text
la $a0, s
li $v0, 4
syscall
|
Output |
Output |
Output |
The directives
.half
and
.word
automatically align their data and preceding labels to a halfword and word boundary, respectively.
Halfword Alignment |
.space |
Word Alignment |
.data
X: .byte 1
Y: .half 2
.text
lb $a0, X+1
li $v0, 1
syscall
|
|
.data
X: .byte 1, 0
Y: .word 2
.text
lw $a0, X+1
li $v0, 1
syscall
|
Output |
Output |
Output |
100
|