0% found this document useful (0 votes)
14 views1 page

Document 1

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

Document 1

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

include irvine32.

inc
section .data
input_msg db 'Enter an integer: ', 0
output_msg db 'You entered: ', 0
newline db 0xA, 0xD ; newline character for formatting

section .bss
user_input resb 10 ; reserve space for user input (up to 10 characters)

section .text
global _start

_start:
; Display input message
mov eax, 4 ; syscall number for sys_write
mov ebx, 1 ; file descriptor 1 (stdout)
mov ecx, input_msg ; pointer to input message
mov edx, 16 ; message length
int 0x80 ; call kernel

; Read user input


mov eax, 3 ; syscall number for sys_read
mov ebx, 0 ; file descriptor 0 (stdin)
mov ecx, user_input ; pointer to input buffer
mov edx, 10 ; maximum number of bytes to read
int 0x80 ; call kernel

; Display output message


mov eax, 4 ; syscall number for sys_write
mov ebx, 1 ; file descriptor 1 (stdout)
mov ecx, output_msg ; pointer to output message
mov edx, 14 ; message length
int 0x80 ; call kernel

; Display user input


mov eax, 4 ; syscall number for sys_write
mov ebx, 1 ; file descriptor 1 (stdout)
mov ecx, user_input ; pointer to user input
mov edx, 10 ; assuming input is within 10 characters
int 0x80 ; call kernel

; Print newline for formatting


mov eax, 4 ; syscall number for sys_write
mov ebx, 1 ; file descriptor 1 (stdout)
mov ecx, newline ; pointer to newline character
mov edx, 2 ; newline length
int 0x80 ; call kernel

; Exit the program


mov eax, 1 ; syscall number for sys_exit
xor ebx, ebx ; exit code 0
int 0x80 ; call kernel

You might also like