MIPS Assembly Program Analysis: Data Segment and Execution Flow
This study material is compiled from a MIPS assembly exercise (copy-pasted text) and an accompanying lecture audio transcript. It aims to provide a comprehensive understanding of MIPS data segment organization and instruction execution.
📚 Introduction to MIPS Assembly Program Analysis
This document offers an in-depth analysis of a MIPS assembly program, focusing on its data segment and execution flow. Understanding these core concepts is crucial for anyone delving into computer architecture, operating systems, or low-level programming. We will dissect a specific MIPS assembly exercise, exploring how data is declared and stored in memory, and how a sequence of MIPS instructions manipulates this data and controls program execution.
📝 MIPS Assembly Program
The following MIPS assembly code will be analyzed:
.data
z1 : .word 1, 0xAABB
z2 : .asciiz "abcd"
z3 : .byte 0x6F, 0x6B, 0x00
z4 : .half 1, 0xAABB
.text
lui $8, 0x1001
lw $10, 0($8)
lw $11, 4($8)
addu $12, $10, $11
sw $12, 0($8)
lh $20, 18($8)
lhu $21, 18($8)
slt $22, $21, $20
bgtz $22, neg
addiu $4, $8, 13
j suite
neg : addiu $4, $8, 8
suite : ori $2, $0, 4 # $22 = 1 if $21 < $20
syscall # display
ori $2, $0, 10
syscall # end of program
📊 Deconstructing the Data Segment: Memory Layout and Directives
The .data directive marks the beginning of the data segment, where initialized data variables are stored. These variables are allocated specific memory locations and hold values used during program execution. The starting address for this data segment is 0x10010000. For MIPS architecture, a big-endian byte ordering is assumed, meaning the most significant byte of a multi-byte value is stored at the lowest memory address.
📚 Data Directives Explained:
.word: Reserves four bytes (one word) for each specified 32-bit value..asciiz: Stores an ASCII string, automatically appending a null terminator (0x00) at the end..byte: Reserves a single byte for each specified 8-bit value..half: Reserves two bytes (one halfword) for each specified 16-bit value.
📋 Data Segment Content: Byte and Word View
Below is the detailed content of the data segment, showing both byte-level and word-level views, starting from address 0x10010000. Subsequent data directives are typically aligned to word boundaries.
| Address (Word) | +0 | +1 | +2 | +3 | Word View | Variable | Description …








