Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 为什么此汇编代码显示的数字与我指定的不同?_Assembly_Numbers - Fatal编程技术网

Assembly 为什么此汇编代码显示的数字与我指定的不同?

Assembly 为什么此汇编代码显示的数字与我指定的不同?,assembly,numbers,Assembly,Numbers,我正在学习如何使用常量,并且能够将字符串和整数加载到不同的寄存器中。唯一的问题是,显示的不是42,而是16777258。这一直是同一个数字。如果我将编号更改为不同的值,我也会显示不同的编号 为什么会这样?我需要做什么 这是我的汇编代码: .section __TEXT,__text,regular,pure_instructions .globl _main _main: #Backup base and stack pointer pushq %rbp movq %r

我正在学习如何使用常量,并且能够将字符串和整数加载到不同的寄存器中。唯一的问题是,显示的不是
42
,而是
16777258
。这一直是同一个数字。如果我将编号更改为不同的值,我也会显示不同的编号

为什么会这样?我需要做什么

这是我的汇编代码:

  .section  __TEXT,__text,regular,pure_instructions
  .globl  _main
_main:
  #Backup base and stack pointer
  pushq %rbp
  movq  %rsp, %rbp

  #Move arguments
  leaq  L_.str(%rip), %rdi
  movl  _number(%rip), %esi
  #Should calll printf("%d", 42)
  callq _printf

  #return 0
  xorl  %eax, %eax

  popq  %rbp
  retq
  .section  __TEXT,__cstring,cstring_literals
L_.str:
  .asciz  "%d"
  _number:
  .long 42

我要做的就是移动下面的代码

_number:
.long 42
.section\uuu TEXT、\uu cstring、cstring\u literals
.data
。我的代码如下所示:

  .section  __TEXT,__text,regular,pure_instructions
  .globl  _main
_main:
  #Backup base and stack pointer
  pushq %rbp
  movq  %rsp, %rbp

  #Move arguments
  leaq  L_.str(%rip), %rdi
  movl  _number(%rip), %esi
  #Should calll printf("%d", 42)
  callq _printf

  #return 0
  xorl  %eax, %eax

  popq  %rbp
  retq

  .data
  _number:
  .long 42

  .section  __TEXT,__cstring,cstring_literals
L_.str:
  .asciz  "%d"