Assignment-01
Name : Manasi bharati
Roll no. : 224085
PRN NO : 22320136
Class : Comp SY-D2
Subject : Computer Architecture and Organization
Title: Write 64-bit ALP to “Hello World” in NASM
1) Description of Instructions used in this code.
2) Code with comments.
3) Screen shot of output
Theory:
Structure of a NASM Program:
NASM is line-based. Most programs consist of directives followed by one or more sections.
Lines can have an optional label. Most lines have an instruction followed by zero or
more operands.
1. section .data: This section defines the data section where we store the "Hello, World!"
string.
2. hello db 'Hello, World!',0: This line declares a null-terminated string 'Hello, World!' and
stores it in memory.
3. section .text: This section contains the code or instructions.
4. global _start: This line declares the entry point of the program as "_start," which is a
convention in Linux assembly programming.
5. _start:: This is a label indicating the start of our program.
6. mov rax, 1: This instruction loads the system call number for sys_write (1) into the RAX
register.
7. mov rdi, 1: It loads the file descriptor for stdout (1) into the RDI register.
8. mov rsi, hello: This instruction loads the memory address of the "hello" string into the
RSI register.
9. mov rdx, 13: It loads the length of the string (13 characters) into the RDX register.
10. syscall: This instruction makes a system call to write the string to the standard output.
11. mov rax, 60: This instruction loads the system call number for sys_exit (60) into RAX.
12. xor rdi, rdi: It sets the exit code to 0 by XORing RDI with itself.
13. syscall: This syscall instruction exits the program.
2) Code with comments:
3) Screen shot of output