Group Assignment #1

To allow you to get your feet wet with assembly, here is our first group project:

Write an assembly program which prompts the user for their name, printing What is your name? and then accepts up to 255 characters of input, and then prints out Hello,name, nice to meet you! followed by a newline.

Here’s an example transcript:

What is your name? Andy
Hello, Andy, nice to meet you!

You’ll have to use both the SYS_WRITE (= 1) and SYS_READ (= 0) syscalls. Use the following .data section (do not modify the .data section):

section .data

prompt:       db      "What is your name? "
prompt_len:   equ     $-prompt

buffer:       times 255 db '!'

resp1:        db      "Hello, "
resp1_len:    equ     $-resp1
resp2:        db      ", nice to meet you!", 10
resp2_len:    equ     $-resp2

buffer is the input buffer to pass to the SYS_READ call; it consists of 255 ! characters. Note that SYS_READ will “return” the actual number of bytes read in rax, which you will then have to use when you print out the contents of the buffer. (If you get the length of the input wrong, you’ll see either the user’s name cut off, or with !!!!s added onto the end of it.)

The “fd” parameter to both SYS_READ and SYS_WRITE is a file descriptor, a number which identifies a file or stream. The standard file descriptors which are always available are

FD Number Stream
0 Standard input
1 Standard output
2 Standard error (output)

So you’ll SYS_READ from FD #0, and SYS_WRITE to FD #1 (as we did before).

Don’t forget to end your program with a SYS_EXIT (= 60) syscall, to gracefully end your program!

Submit your assignment by pasting the code into the Group Assignment 1 submission on Canvas.