The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: etow on January 19, 2008, 09:21:21 PM

Title: How do you set up the .ASM file so that you can do mathematical calculations?
Post by: etow on January 19, 2008, 09:21:21 PM
Hi

I learned different program languages like Java, Turbo Pascal, Visual Basic, Visual C++, and Micrsoft Assembly Language MASM (the older version).

I am planning to relearn MASM again.  I am having trouble with MASM32 version 9 because I do not know how to set up the declarations in the .ASM file to correctly do the mathematical calculations with loop structures without getting the error messages.

I want to know how and where you put the constants, variables, library references, code, and procedures and function calls.

-----------------------------------------------------------------------------------------------------------------------------------------
I know in Visual Basic 6.0,
the setup for the VB code file is:

Option Explicit

Private Sub cmdCancel_Click()
  'This procedure exits the program.
  End
End Sub

Private Sub cmdClear_Click()
   'This procedure clears the label and the text box.
   lblAddition.Caption = ""
   txtInteger.Text = ""
End Sub

Private Sub cmdAddSingleNumberTenTimes_Click()
  'This procedure will add a number to itself 10 times
 
  Dim Number As Long     'first number from textbox
  Dim Counter As Integer   'count the loop
  Dim Result As Long         'result of the addition

  Number = Val(txtInteger.Text)
  Counter = 1
  Result = 0

  Do While (Counter <= 10)
      Result = Result + Number
      Counter = Counter + 1     
  Loop
lblAddition.Caption = "The Value = "  &  Result

End Sub

----------------------------------------------------------------------------------

How do you convert the above Visual Basic 6 code into MASM32 Version 9 code?

Please help!!

Much Help Appreciated!

Thanks


Title: Re: How do you set up the .ASM file so that you can do mathematical calculations?
Post by: jdoe on January 19, 2008, 10:24:20 PM
etow,

Nobody will do the translation for you.

Post the MASM source code you have so far and then you'll get help.

:wink

Title: Re: How do you set
Post by: Tight_Coder_Ex on January 19, 2008, 10:45:07 PM
Quote from: jdoe on January 19, 2008, 10:24:20 PM
Nobody will do the translation for you.

That's not entirely true. MASM has dozens of examples that show you maybe not exactly what you want specifically, but near enough to understand especially as to the structure of an assembly application.  Study the examples and when you get your window up and running similar to the look and feel your VB gives you then you'll be ready to have this question answered and in all likely hood won't need help by that time.

jdoe has a point in so much as nobody is going to hand you this on a platter, especially when there are so many resource available already to help get you started.

:U
Title: Re: How do you set up the .ASM file so that you can do mathematical calculations
Post by: hutch-- on January 20, 2008, 03:26:55 AM
etow,

Welcome on board. To do what you are after means you have to start learning a couple of diferent things, how assembler mnemonics work and how to display the data in a window or alternatively at least at the console window which is a lot simpler.

Be warned that VB is not a good base to learn assembler as it is structured very differently. The loop code you have in mind is very simple but you must at least understand how the basic assembler instructions work.

here is a simple console example that shows two ways of doing what your VB DO loop does.


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

comment * -----------------------------------------------------
                        Build this  template with
                       "CONSOLE ASSEMBLE AND LINK"
        ----------------------------------------------------- *

    .code

start:
   
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    call main
    inkey
    exit

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

main proc

    LOCAL counter   :DWORD

  ; --------------------------------

    mov counter, 0

    .while counter < 10
      add counter, 1
    .endw

    print str$(counter),13,10

  ; --------------------------------

    mov counter, 0
  @@:
    add counter, 1
    cmp counter, 10
    jne @B

    print str$(counter),13,10

  ; --------------------------------

    ret

main endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end start
Title: Re: How do you set up the .ASM file so that you can do mathematical calculations?
Post by: ossama on January 20, 2008, 12:08:04 PM
if you want to learn how to put libraries,declarations,code,... read this GOOD TUTORS by aczelion:
http://win32assembly.online.fr/files/icz-tuts.zip
Title: Re: How do you set up the .ASM file so that you can do mathematical calculations?
Post by: etow on January 20, 2008, 09:57:38 PM
Thanks Hutch for the basic outline.  I know I have a lot to learn about MASM and Assembly language.

Do anyone know where I can get a great MASM IDE program to help me debug and complie and create 32 bit Windows applications visually?
Title: Re: How do you set up the .ASM file so that you can do mathematical calculations
Post by: hutch-- on January 20, 2008, 10:42:51 PM
Have a look at RadASM, its well written and works well. Beware that this approach will not give you the experience you need first to properly understand how assembler programming works. i would advise you to first learn your basics, instructions, command line tools like the assembler, resource compiler and the linker and then you will know enogh to use a tool like RadASM.

Note there are other also very good IDEs like EasyCode and WinAsm. Check them all out to see if this is the direction you want to go in.
Title: Re: How do you set up the .ASM file so that you can do mathematical calculations?
Post by: etow on January 21, 2008, 12:48:12 AM
Hi Hutch,

Where is the best tutorials for MASM32 with many examples from beginner level to expert level programming?

Please reply back soon.

Thanks
Title: Re: How do you set up the .ASM file so that you can do mathematical calculations
Post by: TNick on January 21, 2008, 06:18:44 AM
As already pointed out, Iczelion's tutorials (http://win32assembly.online.fr/tutorials.html) are the best place to start learning asm targeting Windows OS. IMO.

Nick
Title: Re: How do you set up the .ASM file so that you can do mathematical calculations
Post by: hutch-- on January 21, 2008, 11:32:53 AM
etow,

Have a good look at the example code in the masm32 project, it addreses much of what you are after ranging from very simple to reasonaby complex.
Title: Re: How do you set up the .ASM file so that you can do mathematical calculations?
Post by: etow on January 21, 2008, 12:16:17 PM
Thanks everyone for helping me.