## LSU EE 3755 -- Fall 2001 -- Computer Organization
#
## Note Set 11 -- Object Files and System Calls

## Under Construction
# Time-stamp: <7 November 2001, 17:47:15 CST, koppel@sol>
#
# Coming Soon (Maybe)
#
# System Calls
# Program Preparations Steps

These notes are outdated. The lectures page contains links to the latest versions of these notes.

## Contents # ## References # # :PH: Patterson & Hennessy, "Computer Organization & Design" # :Mv1: MIPS Technologies, "MIPS32 Architecture for Programmers Vol I: Intro" # :Mv2: MIPS Technologies, "MIPS32 Architecture for Programmers Vol II: Instr" ################################################################################ ## Structure of SPIM Assembly Language File # Simplified form of a real assembly language program. ## What an Assembler Does # # Creates an object file consisting of a number of sections # Some sections are: # # :Def: Section Header # A directory to the other sections. # Used by programs that read the object file. # # :Def: Text Segment # The program. (Encoded instructions, we know about these.) # Stuff that gets loaded into memory before the program is run. # # :Def: Data Segment # Encoded data. (Haven't seen this yet. Not much to it.) # Stuff that gets loaded into memory before the program is run. # # :Def: Symbol Table # A list of symbols used in the assembler file. # These are used for linking object files together. # # :Def: Relocation Information # Places in object file that refer to as yet undetermined memory locations. # # ## Relevant Sections for this Class # # Text # Data ## Assembly Program Elements # # Instructions # These should be familiar # # Line Labels # These should be familiar # # Assembler Directives # Tell the assembler how to interpret what follows. ## Assembler Directives # # These are a subset of directives recognized by real assemblers. # .text # Tells the assembler that what follows is program code. # The assembler encodes instructions and places them in the text segment. # .data # Tells the assembler that what follows is data. # The encoded data is placed in the data segment. # .globl FOOBAR # Tells assembler that other files may refer to symbol FOOBAR. # In real assemblers, this is needed so files can be linked together. # In SPIM use globl to SPIM can "see" __start, the entry point. # .byte 1, 2, 3, ... .half 1, 2, 3, ... .word 1, 2, 3, ... .float 1.1, 2.2, 3.3, ... .double 1.1, 2.2, 3.3, ... # Tell the assembler to include the specified data. The # specified data is converted into the indicated format: # .word, 32-bit integers; .byte, 8-bit integers. # .ascii "Hello class. I am an ascii string. I'm not terminated." .asciiz "Hello class. I am an ascii string, null-terminated as in C." # Tell the assembler to include the specified data. Each # character takes up one byte of memory. For .asciiz a zero # is written after the last character (which is the way it's done # in c). # :Example: # # A short assembly language program illustrating: .data, .text, .asciiz, .globl .data happy_msg: .asciiz "Hello, class!!" .text .globl __start __start: la $a0, happy_msg addi $v0, 4 syscall addi $v0, 10 syscall #### .text .globl __start __start: li $a0, 0x12345678 addi $t0, $0, 7 add $t1, $a0, $0 add $v0, $0, $0 LOOP: andi $t2, $t1, 0xf sll $v0, $v0, 4 srl $t1, $t1, 4 or $v0, $v0, $t2 bne $t0, $0 LOOP addi $t0, $t0, -1 ## Under Construction Below, an above too. # Prep steps: code, compile, assemble, link, load # HLL to Assembly to Machine # loads and stores. Ex: array traversal. # Working with characters.