Re: variables?

Ed Casas (edc@ece.ubc.ca) Mon, 11 Dec 2000 09:00:32 -0800


Date: Mon, 11 Dec 2000 09:00:32 -0800
From: Ed Casas <edc@ece.ubc.ca>
Subject: Re: variables?

> Is this the correct way of initializing a variable and then > giving it a value? If I am wrong please correct me (I want to > do this: int count = 4) > mov ax, 4 > mov count, ax > .... > > count db 1 dup (?) This is the correct way of declaring a variable and initializing it at run-time (e.g. if the variable has what C calls "automatic" storage class). For example: void foo(void) { int count = 4 ; } Then "count" gets initialized each time foo is called. On the other hand, if you wanted the variable to be initialized only once ("static" storage), then in C you would write: static int count = 4 ; and in assembly you would write: count db 4 -- Ed Casas edc@ece.ubc.ca http://casas.ece.ubc.ca +1 604 822-2592