簡體   English   中英

為什么我不能在匯編中打印數字?

[英]Why can't I print numbers in assembly?

我的代碼正確,但是linux不會打印我指定的ascii字符

我沒有做太多嘗試,因為我的代碼是正確的,並且我遵循了一個教程。

mov rcx, [digitSpacePos]
mov rax, 1
mov rdi, 1
mov rsi, rcx
mov rdx, 1
syscall

它應該打印123,因為digitSpace是123,但是什么也不打印。

這應該工作:

        global    _start

           section   .data
message:  db        "123", 10               ; note the newline at the end

         section   .text
_start:   mov       rax, 1                  ; system call for write
          mov       rdi, 1                  ; file handle 1 is stdout
          mov       rsi, message            ; address of string to output
          mov       rdx, 4                  ; number of bytes
          syscall                           ; invoke operating system to do the write
          mov       rax, 60                 ; system call for exit
          xor       rdi, rdi                ; exit code 0
          syscall                           ; invoke operating system to exit

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM