Printing “array” from .bss in gdb

后端 未结 3 618
眼角桃花
眼角桃花 2021-01-19 10:08

my nasm x86 assembly code contains the following:

; The code should mimic the following C-code:
; int a[10];
; for (int i = 0; i < 10; i++){
;    a[i] = i         


        
3条回答
  •  情深已故
    2021-01-19 10:43

    ARM example

    x86 should be analogous:

    .data:
    a1:
        .float 0.0, 0.1, 0.2, 0.3
    a2:
        .word 1, 2, 3, 4
    .text
        /* Register r1 contains the address of a1. */
        ldr r1, =a1
        ldr r2, =a2
    

    GDB session:

    (gdb) p (float[4])a1
    $1 = {0, 0.100000001, 0.200000003, 0.300000012}
    (gdb) p (int[4])a2
    $2 = {1, 2, 3, 4}
    (gdb) p (float[4])*$r1
    $5 = {0, 0.100000001, 0.200000003, 0.300000012}
    (gdb) p (int[4])*$r2
    $7 = {1, 2, 3, 4}
    

    Tested on GDB 8.1, Ubuntu 18.04.

提交回复
热议问题