The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Vineel Kumar Reddy Kovvuri on May 03, 2007, 04:36:30 PM

Title: plz tell me whats wrong with the following code
Post by: Vineel Kumar Reddy Kovvuri on May 03, 2007, 04:36:30 PM

I am a new to assembly language

plz tell me what is the error in the following program

include c:\masm32\include\masm32rt.inc

.data
a dw 0

.code
start:
cls

lea esi,a
mov eax,5
mov [esi],eax

print str$(a)
   

exit
end start


i am trying to change the value of a to 5 and trying to print the modified value

:'(
Title: Re: plz tell me whats wrong with the following code
Post by: dsouza123 on May 03, 2007, 06:52:30 PM
The code is fine, it is the variable type that is the problem change it from dw ( word)
to dd (dword) and assemble as a console program and it works.

It is fine to use print the way you did, at least with a 32 bit item,
print takes a dword value either a register or variable and does the conversion to a string itself.


include c:\masm32\include\masm32rt.inc

.data
  a dd 0   ; use dd (32 bit) instead of dw (16 bit)

.code
start:
  cls

  lea esi,a
  mov eax,5
  mov [esi],eax

  print str$(a)

  exit
end start
Title: Re: plz tell me whats wrong with the following code
Post by: Vineel Kumar Reddy Kovvuri on May 04, 2007, 06:01:32 AM


thanks you   for your suggestions