been using gas assembler and here is code below that moves a data between register and memory
3 .section .data
4 constant:
5 .int 10
6
7 .section .text
8 .globl _start
9
10 _start:
11 nop
12
13 mov_immediate_data_between_reg_and_mem:
14 movl $777, %eax
15 movl %eax, constant
16
17 exit:
18 movl $1, %eax
19 movl $0, %ebx
20 int $0x80
then created executable file and linker and then i debug that code below, i want to to print a changed value of variable and then error appears:
Breakpoint 1, 0x08049000 in _start ()
(gdb) si
0x08049001 in mov_immediate_data_between_reg_and_mem ()
(gdb) si
0x08049006 in mov_immediate_data_between_reg_and_mem ()
(gdb) si
0x0804900b in exit ()
(gdb) print constant
'constant' has unknown type; cast it to its declared type
but when i cast it with its type it works perfect:
(gdb) print (int)constant
$1 = 777
and if i try to assign new value to a variable it push the same error and if i try to set a new value to variable with its type it push the error below:
(gdb) set (int)constant = 666
Left operand of assignment is not an lvalue.
set *(int *)&constant = ....debug_infosection. See also this question