如何解决RESB:声明和填充未初始化的数据
我有此代码:
extern printf ; the C function,to be called
SECTION .bss
array resb 10
SECTION .data ; Data section,initialized variables
data times 10 db 0
a: dd 5 ; int a=5;
fmt: db "a=%d,eax=%d",10,0 ; The printf format,"\n",'0'
SECTION .text ; Code section.
global main ; the standard gcc entry point
mov eax,0
mov ebx,0
print:
push ebp ; set up stack frame
mov ebp,esp
inc ebx
mov eax,[array + ebx] ; put a from store into register
;add eax,1
push eax ; value of a+2 FIRST
push dword [a] ; value of variable a SECOND
push dword fmt ; address of ctrl string
call printf ; Call C function
add esp,12 ; pop stack 3 push times 4 bytes
mov esp,ebp ; takedown stack frame
pop ebp ; same as "leave" op
mov eax,0 ; normal,no error,return value
ret ; return
main: ; the program label for the entry point
call print
ret
我需要为10个字节创建一个array
。然后,我想填补这个记忆,我尝试做这样的事情:
int array[10];
for(int i = 0; i < 10; i++)
array[i] = i;
我是否正确理解resb
是静态字节(变量)?该数据存在于程序的整个生命周期中。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。