section .text
global _start
_start:
mov edx, len_prompt
mov ecx, prompt
mov ebx, 1
mov eax, 4 ; 4 = sys_write
int 0x80 ; write prompt to user
mov edx, len_name
mov ecx, yourname
mov ebx, 1
mov eax, 3 ; 4 = sys_read
int 0x80 ; read name from user
mov ecx, len_name ; ecx is loop counter, starts at len_name
mov edx, hello
add edx, 6
add edx, len_name ; edx points to last letter of name in hello message
mov esi, yourname + len_name
dec esi ; esi points to last letter in name from user
next_char:
mov al, byte [esi] ; al is current letter of name
mov [edx], al ; copy letter to hello message
dec edx
dec esi
loop next_char ; loop ends when ecx = 0
mov edx, len_hello
mov ecx, hello
mov ebx, 1
mov eax, 4 ; 4 = sys_write
int 0x80
mov eax, 1
int 0x80
section .data
hello db "Hello, ", 10, 13
len_hello equ $ - hello
prompt db "What is your name?", 10, 13
len_prompt equ $ - prompt
yourname db " "
len_name equ $ - yourname
Compile and run the progam,
as shown below.
ASM 105.1: ASCII (5 pts)
Create a program that accepts a series of two-digit numbers terminated by "00" and builds a string from them, as shown below.Run your program on this string to see the flag:
8472693270766571327383328487799568737173848300
ASM 105.2: ASCII (15 pts extra)
Create a program that accepts a series of decimal numbers and builds a string from them, as shown below.Run your program on this string to see the flag:
84,104,105,115,32,116,105,109,101,32,116,104,101,32,102,108,97,103,32,105,115,32,72,85,78,68,82,69,68,83,46,,