Assembly Files - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Assembly Files

Description:

This must be present to tell the assembler to expect this to be called from external sources. ... ascii 'str' Allocates enough space for a string and initialises it. ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 10
Provided by: murraypear
Category:

less

Transcript and Presenter's Notes

Title: Assembly Files


1
Assembly Files
2
Sample program
  • .text
  • This is an assembler DIRECTIVE, it tells the
    compiler that this section contains assembly
    instructions
  • .global main
  • This must be present to tell the assembler to
    expect this to be called from external sources.
    It is customary to put it at the beginning of the
    program.
  • main
  • This is where your program goes.
  • init
  • Here go the steps to initialise memory locations,
    registers etc. used in the program. Your code
    needs to be sure everything is set correctly to
    begin execution.
  • j exit
  • This should be the last executable step in your
    program. It returns control of the REX board to
    the monitor program.
  • .data
  • Comprised of your data items, lookup tables, and
    the like. Initialised when the code is loaded.

3
Assembly Language Programs
  • Assembly Language Programs consist of
  • Assembly Instructions
  • Labels
  • Directives
  • Comments

4
Labels
  • Labels refer to a location in memory.
  • Can associate a label with a WRAMP instruction or
    memory allocated for storage
  • e.g.
  • All WRAMP programs must start with a main label
  • Labels are used so the programmer does not have
    to keep track of memory addresses.

.global main main add 3, 4, 5
5
Comments
  • WRAMP comments are on a line basis
  • Any text on a line after a is treated as
    comments
  • e.g.

add 3, 4, 5 This is a comment
6
Assembler Directives
  • Declarations are examples of Assembler Directives
  • Assembler Directives tell a program (assembler or
    compiler) how to create a program and not how to
    execute it
  • Directives also exist to allow data and
    instruction to be put in separate areas of Memory

WRAMP
C
.bss int1 .word int2 .word char1 .word
int int1, int2 char char1
7
Section Directives
  • .text Indicates that this section contains
    assembly instructions
  • .data This section contains data, i.e. allocates
    memory space and initialises it to some value.
  • .bss This section allocates memory but does not
    initialise it. This allows bigger chunks to be
    allocated than in .data. (bss block started by
    symbol).

8
Space Allocation Directives
  • .word n Allocates one word of memory and
    initialises it to the value n. Can be used in
    .bss without the n.
  • .ascii str Allocates enough space for a string
    and initialises it.
  • .asciiz strAllocates and initialises enough
    space for a string plus a null terminating
    character (0x0)
  • .space n Allocates n words but does not
    initialise the space in the .bss section

9
.global Directive
  • .global declares symbols to be accessible by
    outside the current file.
  • .global main defined the entry point into the
    program.
Write a Comment
User Comments (0)
About PowerShow.com