0% found this document useful (0 votes)
19 views2 pages

4085 Cao Ass2

This document contains an assignment for a student named Manasi Bharati to write a 64-bit assembly language program in NASM to print "Hello World" and include: 1) A description of the instructions used in the code 2) The code itself with comments 3) A screenshot of the output It provides the structure of a typical NASM program and explains the instructions used in a "Hello World" program like loading system call numbers, writing the string to stdout, and exiting the program.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

4085 Cao Ass2

This document contains an assignment for a student named Manasi Bharati to write a 64-bit assembly language program in NASM to print "Hello World" and include: 1) A description of the instructions used in the code 2) The code itself with comments 3) A screenshot of the output It provides the structure of a typical NASM program and explains the instructions used in a "Hello World" program like loading system call numbers, writing the string to stdout, and exiting the program.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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

You might also like