EGTAPI's location marking labels
 

The EGTAPI tool requires the assembler program to provide 5 location markers (= labels) to location the necessary information:

  • main: this is the location where the program starts its execution
  • Stop: this is the location where the program ends its execution
  • CodeEnd: this is the location of the last program instruction


  • DataStart: this is the location of the first constant/variable defined in the assembler program
  • DataEnd: this is the location of the last constant/variable defined in the assembler program

The main: label is already part of an assembler program

We must add the other 4 labels to an assembler program to make it run with EGTAPI.

The "Hello World" assembler program adapted for EGTAPI
  .global main
  .global Stop, CodeEnd, DataStart, DataEnd


   .text
main:      // marks the start point of the program
     push    {lr}   // Save the return address on the stack
     push    {fp}   // Save the return address on the stack
                    // Explained later in CS255

     movw    r0, #:lower16:HelloStr
     movt    r0, #:upper16:HelloStr

     bl      printf

     pop     {fp}   // Pop the frame pointer
     pop     {pc}   // Pop the return address
                    // Explained later in CS255
Stop:     // marks the stop point of the program
CodeEnd:  // mark the end of the code (= instructions)
     nop

   .data

DataStart:   // marks the start of the data
HelloStr:    // Label marking this location in memory
        .asciz "Hello World\n"  // ASCII codes for the string
DataEnd:     // marks the end of the data
        .end   

DEMO: the Hello World in EGTAPI
 

DEMO: /home/cs255/cs255/hello/hello-egtapi.s on cs255host1

 LabMachine>>  /home/cs255001/bin/egtapi               

  1. Login in as:  cs255001  or  use your own NetID)

  2. Select host "cs255host1"  at the end of machine list 

  3. Login: cs255,   pw: abc123

  4. File Browser, go to "hello" directory

  5. Select  hello-egtapi.arm  and  click COMPILE
   

 

Note:   do not use cs255host1 to run your ARM assembler projects

For CS255 Assembler projects:   use some lab machine (e.g.: lab1a)

Observed information on the Hello World program

Content of the memory:

  • The program instructions of the program are stored starting at the memory address 10424 Hex

  • The constants and permanent variables of the program are stored starting at the memory address 21028 Hex - which is below the program instructions

Observed information on the Hello World program

This is how the "Hello" program is stored in memory:

Quiz
 

Can you see the string "Hello World\n" in the Data segment:

Quiz
 

Can you see the string "Hello World\n" in the Data segment:

   48 hex = ASCII code for 'H'
   65 hex = ASCII code for 'e'
   6c hex = ASCII code for 'l'
   6c hex = ASCII code for 'l'
   6f hex = ASCII code for 'o'
   20 hex = ASCII code for ' '   (space)      
   57 hex = ASCII code for 'W'
   6f hex = ASCII code for 'o'
   72 hex = ASCII code for 'r'
   6c hex = ASCII code for 'l'
   64 hex = ASCII code for 'd'
   0a hex = ASCII code for '\n'  (newline)