gas - Defining "variables" in assembly language -


i underdstand extremely stupid quiestion, can't figure answer time
how correctly declare , define "variables" in gas at&t assembly language?
example, want buffer 5 bytes, 2 1-byte variables (initially 0 value), 2-byte variable 0 , 2-byte variable 10.
code doesn't work correctly, @ least debugger says (on first line of program, after these declarations, nop instruction) b , c big numbers instead of zeros.

.bss     .lcomm r, 5  .data     a:  .byte 0     b:  .byte 0     c:  .word 0     d:  .word 10 

here's see in "watches" window:

a = 0 = 0x00 = 0x0000 = 0x00 0000 = 0x0000 0000  b = 167772160 = 16777216 * 10 = 0x1000000 * 0x0a = 0xa000000  c = 655360 = 65536 * 10 = 0x10000 * 0x0a = 0xa0000  d = 10 = 0x0a = 0x0000 000a 

what mean? means compiler did job, debugger reads c , b doublewords (4 bytes) instead of bytes.

when reads in b, reads value 0x00, c´s value 0x0000, , d´s value 0x0a on top, making 0xa000000.

similar thing happens c. a got lucky, next 4 bytes zero, a zero.

however, doesn't have case. nothing says there can't garbage after d, not mention variables equal 0 may appear in .bss (on different memory location).


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -