如何在x86汇编中创建全局数组和dwords?

时间:2015-04-14 00:02:10

标签: arrays assembly x86 global-variables dword

如何在x86中创建多个全局字节数组和多个dword?另外,如何将它们全部初始化为0?这会在_start:或.data中完成吗?要使用的汇编程序是NASM。

1 个答案:

答案 0 :(得分:0)

Nasm语法 - 100字节/双字:

section .bss
    byte_array resb 100
    dword_array resd 100

; or...
section .data
    byte_array_2 times 100 db 0
    dword_array_2 times 100 dd 0

global _start  ; ask Nasm to tell linker about this
section .text
    _start:
    ; do something intelligent...

section .bss byte_array resb 100 dword_array resd 100 ; or... section .data byte_array_2 times 100 db 0 dword_array_2 times 100 dd 0 global _start ; ask Nasm to tell linker about this section .text _start: ; do something intelligent...

名义上是“未初始化”,但实际上在任何合理的平台上都被初始化为零。 Fasm使用section .bssrb代替rdresb。你没有说“什么是汇编程序”。