0

I started programming in Assembly! And so far I understood how to output, but now in the input... I don't understand...

It's not understandable. I'm gonna explain

First of all: I use Kali Linux, linker: ld; and Assembler: NASM

Here is the code so far:

global _start
section .data
        text1: db "What's your name? "
        text2: db "Hello, "
        text1l: equ $-text1
        text2l: equ $-text2

section .bss
        name resb 16
section .text
_start:
        call _printText1
        call _getName
        call _printText2
        call _printName
        call _exit

_printText1:
        mov rax, 1
        mov rdi, 1
        mov rsi, text1
        mov rdx, text1l
        syscall
        ret
_getName:
        mov rax, 0
        mov rdi, 0
        mov rsi, name
        mov rdx, 16
        syscall
        ret
_printText2:
        mov rax, 1
        mov rdi, 1
        mov rsi, text2
        mov rdx, text2l
        syscall
        ret
_printName:
        mov rax, 1
        mov rdi, 1
        mov rsi, name
        mov rdx, 16
        syscall
        ret
_exit:
        mov rax, 60
        mov rdi, 0
        syscall
        ret

The output I expected would be: What's your name? <INPUT> Hello, <OUTPUT OF THE VARIABLE NAME ON .DATA>

But the output i got was this: What's your name? Hello, <INPUT>

Devilas
  • 1
  • 1
  • 1
    Your `text1l: equ $-text1` is in the wrong place. It includes `text2`. Move it up. – Jester Feb 13 '23 at 18:36
  • 1
    THAT WAS IT! SO THAT WHAT WAS WRONG, And i actually understand why it didn't work, but never saw that was that the error... Thank you! – Devilas Feb 13 '23 at 19:11

0 Answers0