MIPS Assembly Language Programming

Directives

Syntax Meaning
.data Introduces the data (i.e. global variables) section of the program.
.text Introduces the text (i.e. code) section of the program.

Directives which can only be used in a .data section of an assembly language program file:

Syntax Meaning Example
.asciiz "characters" characters will be stored in memory as a zero byte terminated string constant. .asciiz "Hello world"
.space number number of bytes is reserved in memory. .space 400
.word number The 32-bit number number is stored in memory. .word 1234

Labels

Syntax Meaning
identifier: identifier is associated with the address of the item following the label

Convenient ways to refer to addresses. Can be used in .data and .text sections.

For global variables:
The address associated with a label of a global variable can be interpreted directly as an offset because it is as though we start addressing the global variables from address 0. They are actually addressed starting from the address that is held in the global pointer register $gp. However the actual address is not known until the program starts executing. We do know what the offset should be however.

For instructions:
The address associated with a label of an instruction is used to calculate the number of instructions to branch forwards or backwards by in a branch instruction. It is used to calculate the instruction number to jump instruction.


CSE 378 Spring 2002 - Section 3
First Previous Page 1 Next Last