1 / 9

Assembly Files

Assembly Files. Sample program. .text This is an assembler DIRECTIVE, it tells the compiler that this section contains assembly instructions .global main

gene
Download Presentation

Assembly Files

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 “str”Allocates 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.

More Related