1 Replies - 560 Views - Last Post: 04 November 2017 - 10:01 AM

#1 sunshine33  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 15-September 17

Some questions about declaring and initializing variables .

Posted 23 September 2017 - 09:30 PM

Quote

The data stored in a memory byte are called its contents

Quote

Variable names such as count1 and count2 represent addresses


So this is actually ,

myvar1     DB 3
anothervar DW 03FAh
someval    DD 721099
repeatvar  DB 7 dup(12,28)
string1    DB 'This is a string'


initialize address called  myvar1        DB 3
initialize address called  anothervar    DW 03FAh
initialize address called  someval       DD 721099
initialize address called  repeatvar     DB 7 dup(12,28)
initialize address called  string1       DB 'This is a string'


Then , what exactly is this ?

Posted Image

memory address 0x45B0F0
memory address 0x489940

??

Is This A Good Question/Topic? 0
  • +

Replies To: Some questions about declaring and initializing variables .

#2 turboscrew  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 152
  • View blog
  • Posts: 1,032
  • Joined: 03-April 12

Re: Some questions about declaring and initializing variables .

Posted 04 November 2017 - 10:01 AM

Well, the first part is about assembly "variables". In assembly there are really no variables - only memory locations whose address can be thought of as a "variable name".

The picture shows initialization of higher programming language variables. In languages like C or Ada or ... the local variables are created in stack and their "addresses" are offsets from the SP. Remember that stack usually grows downwards, so adding, say, 16 to SP makes room for 4 32-bit variables: SP+0, SP+4, SP+8 and SP+12 (= SP+0x0C), or SP+4, SP+8, SP+12 and SP+16 if the stack is post-decrementing (SP points to first free) instead of pre-decrementing (SP points to the last used).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1