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

0801IT211098 Lab Assignment - 1: 1. Write Program To Print "Hello World"

This document contains 3 assembly language programs. The first program prints "hello world". The second program prints 9 stars. The third program prints the message "Hello, this is my first program" using two sections. Each program uses the sys_write and sys_exit system calls.

Uploaded by

yash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

0801IT211098 Lab Assignment - 1: 1. Write Program To Print "Hello World"

This document contains 3 assembly language programs. The first program prints "hello world". The second program prints 9 stars. The third program prints the message "Hello, this is my first program" using two sections. Each program uses the sys_write and sys_exit system calls.

Uploaded by

yash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

0801IT211098

Lab Assignment -1

1. Write program to print “hello world”.


segment .text ;code segment
global _start ;must be declared for linker
_start: ;tell linker entry point

mov edx,len ;message length


mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel

mov eax,1 ;system call number (sys_exit)


int 0x80 ;call kernel

segment .data ;data segment


msg db 'Hello, world!',0xa ;our msg string
len equ $ - msg ;length of our msg string

2. Write a program to print 9 stars


section .text
global _start ;must be declared for linker (gcc)
_start: ;tell linker entry point

mov edx,len ;message length


mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel

mov edx,9 ;message length


mov ecx,s2 ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel

mov eax,1 ;system call number (sys_exit)


int 0x80 ;call kernel

section .data
1
0801IT211098
msg db '9 stars are',0xa ;a message
len equ $ - msg ;length of message
s2 times 9 db '*'

3. Write a program to print hello, this is my first program using two sections
section .text
global _start ;must be declared for linker (gcc)
_start: ;tell linker entry point

mov edx,len ;message length


mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel

mov edx,len1 ;message length


mov ecx,msg1 ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel

mov eax,1 ;system call number (sys_exit)


int 0x80 ;call kernel

section .data
msg db 'Hello, ',0xa ;a message
len equ $ - msg ;length of message

section .data
msg1 db 'This is my first program ',0xa ;a message
len1 equ $ - msg ;length of message

You might also like