【发布时间】:2015-11-24 20:47:50
【问题描述】:
我的 nasm x86 汇编代码包含以下内容:
; The code should mimic the following C-code:
; int a[10];
; for (int i = 0; i < 10; i++){
; a[i] = i;
; }
SECTION .data
arraylen dd 10
SECTION .bss
array RESD 10
SECTION .text
global main
main:
mov ecx, 0
mov eax, 0
loop:
inc ecx
mov dword [array+eax*4], ecx
inc eax
cmp ecx, arraylen
jl loop
end:
mov ebx, 0
mov eax, 1
int 0x80
现在我想要检查此代码是否在 gdb 中有效。
但是,我如何打印array?
print array 只返回$1 = 1。
print array + X 不幸的是是算术运算,即
例如print array + 50 实际上打印 1+50 = 51 而不是不存在的第 51 个数组元素。
【问题讨论】: