160 likes | 341 Views
Decoding MIPS Assembly. MIPS Memory. MIPS 32 and 64 bit versions 32 bits for Data width Instruction size Address space 2 32 ~ 4 billion addresses. MIPS Memory. 2 32 ~ 4 billion addresses Assigned to bytes 32 bits : 4 GB addressable memory. OS & Memory.
E N D
MIPS Memory • MIPS • 32 and 64 bit versions • 32 bits for • Data width • Instruction size • Address space • 232 ~ 4 billion addresses
MIPS Memory • 232 ~ 4 billion addresses • Assigned to bytes • 32 bits : 4 GB addressable memory
OS & Memory • OS generallyreserves memory fordevices andcritical OS code
MIPS Memory • MIPS takes top half of space • Program space • 0x00000000-0x7FFFFFFF • ~2GB
MIPS Memory • Text : code • Data : • Static : allocated by assembler • Dynamic : allocated by OSat run time (heap) • Stack : local variable storage • Managed by compiler
Memory Units byte — eight bits. word — four bytes, 32 bits double word — eight bytes, 64 bits • Addresses in bytes, instructions/data often words
Dissection • A simple program: • #XXX Comment • .XXX Assembler directive • XXX: Label
Directives • Common directives: • .text # the succeeding lines contain instructions • .data # the succeeding lines contain data • .globl name # name is global symbol (visible to code in other files) • .asciiz# store a null terminated string
Labels • Label : human readable alias for location in code • Can be on same line or line before named code • Assembler replaces label with named thing/address:
Main • Global main tells OS whereto start • MARS doesn't need • Well behaved program should also tell OS when it is done… later
An Instruction • Instructions combine registers or literal valuesput results in registers
Instruction • Registers • Can use register #or memnonic • Don't use 0 or 1!!!
Instruction • An instruction:
Standardized Format • Op Operation code • RsFirst source register operand • RtSecond source register operand • Rd Destination register operand • ShamtShift amount - used in shift instructions • FunctSelect the variant of the operation in the op code field
Instruction • An instruction: