News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Newbie

Started by tootoo, October 02, 2006, 04:33:43 PM

Previous topic - Next topic

tootoo

Hello everyone, I just started studying assembly language this semester and I am having trouble following the book.  I want to write a program that initializes each data type to a variable.  Its not something that I have to do for school I just want to try some of the projects from the textbook.  I have given each data type a definition, but don't know where to start as far as actually getting the information to show on the screen. Any information is greatly appreciated.

PBrennick

tootoo,
Welcome to the forum.  This is the place to get answers to assembly related questions.

Show us what you have so far so we can give you good help.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

tootoo

Okay here is what I have so far, i have defined each data type, now I need a way to write the program to initialize the data types and show them to the user

.data
value1  BYTE  'A'
value2  BYTE   0
value3  BYTE   255
value4  SBYTE  -128
value5  SBYTE  +127
value6  BYTE   ?

list1   BYTE  10, 32, 41h, 00100010b
list2   BYTE  0Ah, 20h, 'A', 22h
array1  BYTE  20 DUP(0)

greeting1 BYTE "Good afternoon",0

stanhebben

I'd recommend using doublewords (dword, dd) as data types. They are 32 bits long and are easier to handle.

Of course, you can use bytes too, but I guess you want to begin with the simplest things.

The masm32 runtime (\masm32\include\masm32rt.inc) can be very useful in your first steps in assembly. It includes all windows functions, as well as a bunch of useful macros. The print macro, for example, allows you to print strings and values in the console window.

For example:

include \masm32\include\masm32rt.inc

.data
value1  dd  'A'
value2  dd  0
value3  dd  255
value4  dd  -128
value5  dd  +127
value6  dd  ?

list1   dd  10, 32, 41h, 00100010b
list2   dd  0Ah, 20h, 'A', 22h
array1  dd  20 DUP(0)

greeting1 db "Good afternoon",0

.code
start:
  print "Value 3: "
  print ustr$(value3), 10
  print "Value 4: "
  print str$(value4), 10
 
  print offset greeting1, 10
 
  inkey
  exit

end start


tootoo

That didn't work, I'm actually trying to compile the program in Visual C++ 2005, I dont have any experience with MASM32.  I downloaded the program but don't know exactly how it works.
I also downloaded the examples from the textbook and I'm using them as templates for programming.  Any other suggestions.

PBrennick

tootoo,
Stan's work is always reliable so you need to work it in a proper manner.  Open a text editor, \masm32\qeditor.exe will work just fine.  Highlight Stan's code and then click CTRL+C to copy it into the clipboard and then paste it into the editor.  Then save it as test.asm, remember where you save it.  Then using the menu click Project and then assemble and link and an exe will be created in the same folder as test.asm.  Now you can run the program.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

gabor

Hi friends!

Quote from: Stan Hebben on October 02, 2006, 07:18:56 PM
I'd recommend using doublewords (dword, dd) as data types. They are 32 bits long and are easier to handle.
Of course, you can use bytes too, but I guess you want to begin with the simplest things.

I believe that bytes are the simpliest units in coding. Bits would be the simpliest but storage is based on bytes so they win...

As a (wanna-be) assembly coder who started on a C64 with very small memory space, I am used to save the bytes. After that memory has become very cheap, the processors have become more and more complex and handle huge quantity of memory persuading every single byte is no more usefull (except some special tasks).

Okay, the important stuff I'd like to add is that on a Pentium it is very recommended that the data is dword aligned. If you use dwords only this won't be broken for sure!
BTW, is it true, that the Pentiums can access memory in 32 bit width in one memory cycle? In other words, reading/writing a dword does not take more cycles than reading/writing a single byte?

Greets, Gábor

tootoo

Okay, I did everything that PBrennick advised (thanks), but it still did not work.  A test.exe was created but when I try to run the program nothing happens.  Can someone tell me what I'm doing wrong here. 
Am I supposed to open the test.exe and run that are the test.asm file?

Thanks

tootoo

Okay disregard last post, I got it to work  :clap: Just did a little toying with it and figured out I needed to do it in console.

Thanks for all the help provided!