此汇编代码中的此步骤需要什么 - x86

What is the need for this step in this assembly code - x86

这是一个程序,让用户输入一些字符,它会输出用户输入的任何内容。

    ; Section to store variables
    section .data
    string_msg: db "Enter a string (Max=64 Characters)", 0xD, 0
    string_in: times 65 db 0h ; max = 64 char, last ch=null
    string_out: times 65 db 0h ; max = 64 char, last ch=null

    ; Start of program
    global _main
    section .text
    _main:
    mov ebp, esp; for correct debugging

    PRINT_STRING string_msg
    NEWLINE
    GET_STRING string_in, 65

   ; init value to process input string
   xor ebx, ebx

   start:
   mov al, byte[string_in  + ebx]
   mov byte[string_out + ebx], al

   PRINT_CHAR al
   cmp al, 0h
   je end
   inc ebx
   jmp start

   end: 
   xor eax, eax    ; terminate program
   ret 

我不明白的是为什么 mov byte[string_out + ebx], al 在那里?这是什么意思?

非常感谢您的帮助!

您所指的指令 (mov byte[string_out + ebx], al) 只是复制输入的字符串。

由于字符串使用 PRINT_CHAR 一次显示一个字符,因此显示器并不真正需要它。

如果此程序被扩展为使用替代输出方法,那么此副本可能正是所需要的。

PRINT_STRING string_out

PRINT_CHAR al
cmp al, 0h
je end

这可能是个小错误!终止零通常不应显示在屏幕上。测试最好在 打印前 完成。

cmp al, 0
je  end
PRINT_CHAR al