arrays - 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
我需要array
为 10 个字节创建一个。然后我想填补这段记忆,我试着做一些这样的想法:
int array[10];
for(int i = 0; i < 10; i++)
array[i] = i;
我是否正确理解这resb
是一个静态字节(变量)?这些数据存在于程序的整个生命周期中。
解决方案
推荐阅读
- javascript - 使用分页时如何在 Webix 数据表中重新加载当前页面?
- java - 给定服务器端可用的字节数组和内容类型,如何使休息服务顺利下载?
- c# - 在 Visual Studio 中添加类时将默认类类型设置为 C# 类
- delphi - 错误消息 = 找不到 -lbz2 的库
- javascript - 使用jquery根据日期选择选项
- jquery - jquery 查询字符串为空
- winapi - 如何使用 win32 API 更改 ComboBox 的颜色
- r - 创建 Padovan 序列的函数
- html - 只需使用标签并希望在移动平台中对其进行自定义
- spring-boot - 在springboot2.0中使用ehcache时'sync = true'是否有效