assembly - Printing "array" from .bss in gdb -
my nasm x86 assembly code contains following:
; code should mimic following c-code: ; int a[10]; ; (int = 0; < 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
now want check whether code works in gdb. however, how print array
?
print array
returns $1 = 1
.
print array + x
unfortunately arithmetical operation, i.e. e.g. print array + 50
prints 1+50 = 51
, not non-existent 51st array element.
you can do:
(gdb) x/10 &array 0x8049618: 1 2 3 4 0x8049628: 5 6 7 8 0x8049638: 9 10
ps: code broken, need cmp ecx, [arraylen]
.
Comments
Post a Comment