How do you set up the .ASM file so that you can do mathematical calculations?

Started by etow, January 19, 2008, 09:21:21 PM

Previous topic - Next topic

etow

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



jdoe

etow,

Nobody will do the translation for you.

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

:wink


Tight_Coder_Ex

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

hutch--

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
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ossama


etow

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?

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

etow

Hi Hutch,

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

Please reply back soon.

Thanks

TNick

As already pointed out, Iczelion's tutorials are the best place to start learning asm targeting Windows OS. IMO.

Nick

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php