You are on page 1of 3

Name: Kiran Suryakant Khamkar

PRN No.: 22210084


Roll No.: 221035
Class: SY-A (A2)
Subject: CAO

ASSIGNMENT NO 2

TITLE: Write 64-bit ALP to “Hello World” in NASM.

THEORY:
• DESCRIPTION OF INSTRUCTIONS USED IN THIS CODE –
1. section: This directive is used to define sections of the executable
file. In this code, the data section (.data) is used to define the
string to be printed, and the text section (.text) is used for the
main program.

2. db: This directive is used to define bytes in the data section. It is


used to declare a string that will be printed.

3. mov: This instruction moves data between registers and


memory. It is used to move values into registers, which can then
be used for various operations.

4. int: This instruction generates a software interrupt. In this case,


it is used to make a system call to the kernel. The value in the
register eax determines the specific system call to be made.

5. global: This directive is used to make labels visible to the linker


so that they can be referenced from other files.
• CODE WITH COMMENTS-

section .data
msg db "Hello world!", 0ah

section .text
global _start

_start:
mov rax, 1 ;function no.
mov rdi, 1 ;file descriptor for std_out devices
mov rsi, msg ;address of variable
mov rdx, 13 ;count of bytes to display
syscall
mov rax, 60 ;function no. for sys_exit
mov rdi, 0 ;Exit with return code of zero(no error)
syscall

• SCREENSHOT OF OUTPUT-

You might also like