Write an Assembly Language code that rearranges any four (2) strings of doubleword values in an array expressing yourself during MCO with this Covid-19 pandemic. Then request a user to enter a name, before the program will reverse the name. All strings should be present in different colors. Repeat the output 2 times.
; nasm
string_length:
xor rax, rax
.iter:
cmp byte[rdi+rax], 0x0
je .break
inc rax
jmp .iter
.break:
ret
print_string:
call string_length
.print:
mov rsi, rdi
mov rdi, 0x1
mov rdx, rax
mov rax, 0x1
syscall
ret
print_char:
push rdi
mov rax, 0x1
mov rdi, 0x1
mov rsi, rsp
mov rdx, 0x1
syscall
pop rdi
ret
read_char:
push 0x0
xor rax, rax
xor rdi, rdi
mov rsi, rsp
mov rdx, 0x1
syscall
pop rax
ret
read_word:
push rsi-0x1
push rdi
xor r8, r8
xor r9, r9
.iter:
call read_char
mov rdi, [rsp]
mov rsi, [rsp+0x1]
cmp rax, 0x9
je .check
cmp rax, 0xa
je .check
cmp rax, 0x20
je .check
mov r9, 0x1
cmp rax, 0x0
je .check
cmp r8, rsi
je .err
mov [rdi+r8], al
inc r8
jmp .iter
.check:
test r9, r9
je .iter
mov [rdi+r8], byte 0x0
mov rax, rdi
mov rdx, r8
jmp .end
.err:
xor rax, rax
.end:
pop rdi
pop rsi
ret
Comments
Leave a comment