|
// // hello-egtapi.s: hello world in ARM assembler for EGTAPI // // How to compile: // // as -o hello-egtapi.o hello-egtapi.s // gcc -o hello-egtapi.arm hello-egtapi.o // .global main .global Stop, CodeEnd, DataStart, DataEnd // ************************ Starting computer instruction **************** .text // *********************************************************************** main: push {lr} // Save the return address on the stack push {fp} // Save the return address on the stack // Explained later in CS255 /* ---------------------------------------- Pass the string to printf function ---------------------------------------- */ movw r0, #:lower16:HelloStr movt r0, #:upper16:HelloStr /* ---------------------------------------- Call the printf function ---------------------------------------- */ bl printf pop {fp} // Pop the frame pointer pop {pc} // Pop the return address // Explained later in CS255 Stop: CodeEnd: nop // ************************ Starting variable definition ***************** .data // *********************************************************************** DataStart: HelloStr: // Label marking this location in memory .asciz "Hello World\n" // ASCII codes for the string DataEnd: .end |
I need to add a nop (no operation) instruction so that the markers Stop and CodeEnd can be recognized by the assembler.
How to compile the program:
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 |
This version of the "Hello World" program can be shown with the EGTAPI tool
http://www.cs.emory.edu/~egtapi |
make sure you download the correct version for your laptop (there are version for Linux 64 bits (x64), Linux 32 bits (x86), Mac, Windows 64 bits (x64) and Windows 32 bits (x86))
You will download a zip file
Unzip the zip file and you will find the EGTAPI tool inside.
Click on the icon to run it.
LabMachine>> /home/cs255001/bin/egtapi Instruction to run Hello World on cs255host1: 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 LOAD |
I will demo the EGTAPI tool using the hello-egtapi.arm program.
In the demo, you will see the following screen in the memory area in the EGTAPI tool:
This picture shows you that:
|
So you can see for yourself that this is true:
|
Answer:
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) |