You are on page 1of 9

TASK I : DISPLAY FULL NAME AND REGISTRATION NUMBER ON

THE STANDARD OUTPUT.

section .text

global main

main:

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_write)

int 0x80 ;call kernel

section .data

msg db 'Iheme Tobechukwu Progress', 0xa ;our dear string

msg2 db '20171030725', ;our dear string

len equ $ - msg ;length of our string

OUTPUT:

Iheme Tobechukwu Progress

20171030725

Process finished with exit code 1.


TASK II: CALCULATION OF TWO INTEGER
NUMBERS.

SYS_EXIT equ 1

SYS_READ equ 3

SYS_WRITE equ 4

STDIN equ 0

STDOUT equ 1

segment .data

msg1 db "Enter a digit ", 0xA,0xD

len1 equ $- msg1

msg2 db "Please enter a second digit", 0xA,0xD

len2 equ $- msg2

msg3 db "The sum is: "

len3 equ $- msg3

segment .bss

num1 resb 2

num2 resb 2

res resb 1

section .text

global main ;must be declared for using gcc

main: ;tell linker entry point

mov eax, SYS_WRITE

mov ebx, STDOUT

mov ecx, msg1

mov edx, len1

int 0x80

mov eax, SYS_READ

mov ebx, STDIN

mov ecx, num1


mov edx, 2

int 0x80

mov eax, SYS_WRITE

mov ebx, STDOUT

mov ecx, msg2

mov edx, len2

int 0x80

mov eax, SYS_READ

mov ebx, STDIN

mov ecx, num2

mov edx, 2

int 0x80

mov eax, SYS_WRITE

mov ebx, STDOUT

mov ecx, msg3

mov edx, len3

int 0x80

; moving the first number to eax register and second number to ebx

; and subtracting ascii '0' to convert it into a decimal number

mov eax, [number1]

sub eax, '0'

mov ebx, [number2]

sub ebx, '0'

; add eax and ebx

add eax, ebx

; add '0' to to convert the sum from decimal to ASCII

add eax, '0'

; storing the sum in memory location res

mov [res], eax

; print the sum


mov eax, SYS_WRITE

mov ebx, STDOUT

mov ecx, res

mov edx, 1

int 0x80

exit:

mov eax, SYS_EXIT

xor ebx, ebx

int 0x80

OUTPUT:
Enter a digit:

Please enter a second digit:

The sum is:

Process finished with exit code 1.

TASK III: INTERPRETING ASSEMBLY PROGRAM

section .text
global _start ;must be declared for linker (ld)
_start: ;tell linker entry point
; writing the name 'Eze prof '
mov edx,9 ;message length
mov ecx, name ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov [name], dword 'Oti ' ; Changed the name to Oti Prof
; writing the name 'Oti Prof'
mov edx,8 ; message length
mov ecx, name ; 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
name db 'Eze Prof' , 0xa

OUTPUT:

Eze Prof

Oti Prof

Process finished with exit code 1.

TASK I

Title:
Basic Assembly language syntax

Aim:
To introduce the student to basic structure and syntax of assembly language
program and basic assembly process
Definition:
 The text section: it contains the actual code. This section begins with
declaration "global main", which tells the kernel where the program execution
begins.
 The data section: This is used to declare initialized data. The data initialized in
this report are Full name and Registration number.
 The bss section: This is used to declare variables.

Observation:
1. NASM Environment was used.
2. No presence of variable, .bss section was not employed.
3. The 0xa (ZeroAphaApha) is used to make strings appear in separate line.
Comma (,) must end a string before it is applied.

Conclusion:
The program runs efficiently.

TASK II

Title:
I/O operation in assembly.

Aim:
To expose student to the basics of input/output operation

Definition:
 The text section: it contains the actual code. This section begins with
declaration "global main", which tells the kernel where the program execution
begins.
 The data section: This is used to declare initialized data. The data initialized in
this report prompt user to input two digits number.
 The bss section: This is used to declare variables.

Observation:
1. Reserved directives where used on .bss segment, this take a single operand and
specifies the number of units of space to be reserved.
2. Multiple definition statement was employed.
3. Register eax is used in I/O instruction.
4. Register edx is used for I/O operations.
5. Register ebx is used in indexed addressing.
6. Register ecx stores loop count.
7. ASCII and decimal value where used in calculation operations.

Conclusion:
The program aim was satisfied.

TASK III
Title:
Interpreting Assembly Language program

Aim:
To sharpen the student skill for interpreting assembly program.

Interpretation:
This program was meant to store the name 'Prof Eze ' in the data section of the
memory and then change its value to another name 'Prof Oti' programmatically and
display both names.

Accuracy of Interpretation:
The output was not accurate as program finished executing.

Reason for Inaccuracy:


In the initial execution of the program, only the name in the .data section
appeared twice and dword "Prof Oti" seems not to be recognized. For this effect to be
rendered properly, the name that is uncommon between the two should be written first
i.e. ("Prof" is common and "Eze” and “Oti" are uncommon) meaning that both
the .data section and dword should first begin with the uncommon name before the
common names.

Observation:
1. Only the first word (uncommon names) was switched.
2. The 0xa (ZeroAphaApha) is used to make strings appear in separate line.
Comma (,) must end a string before it is applied.

Conclusion:
The aim of this topic was ascertained as proper modifications was carried out
on the program.
FEDERAL UNIVERSITY OF TECHNOLOGY
OWERRI, IMO STATE (FUTO)

ASSIGNMENT

ON

ASSEMBLY AND MACHINE LANGUAGE


PROGRAMMING (CSC 306)

BY

IHEME TOBECHUKWU PROGRESS


20171030725

DEPARTMENT OF COMPUTER SCIENCE

SCHOOL OF COMPUTING AND INFORMATION


TECHNOLOGY (SCIT)

You might also like