News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

starter with masm32 help

Started by ratten, February 26, 2018, 07:37:17 AM

Previous topic - Next topic

ratten

when I click assembly/link it goes through but then I click run and the qeditor goes to not responding and the .exe is still in the background but not showing up then I click build and gives me the link error I just installed it in my laptop and it is doing the same thing.

ratten

and also I am on windows 10, I dont know if that has anything to do with it

jj2007

It works fine for me, see attachment.

- open in qEditor
- menu Project/CONSOLE build all
- menu Project/run program

I am on Win7-64, but I'll test it on Win10, too.

LordAdef

Check your task manager and see if your exe is running in tjee background and that's why qeditor cannot open the exe

ratten

THANK YOU SO MUCH! it finally work out for me I restarted my computer and it finally did it!, also I tried to download the file it chrome wouldnt let me, but thanks anyway both helped me a lot! and my professor is not the best one out there to say the least(really old guy), so I tried to read the class book (Assembly Language for x86 Processors (7th Edition) by K. R. Irvine) but it hasnt helped me a lot so I was looking to learn by my self where are the tutorials on the masm32 files?

jj2007

Try \Masm32\tutorial\console\ and \Masm32\help\
There are also many small demos in \Masm32\examples

ratten

thank you, now that I can run it I am trying to improve what the program displays but is given me some strange errors I dont know if you can help me but I kinda want to print each of the the results and diis play the numbers like after adding eax and ebx show the number that eax is holding thisis what I tried but is displaying large extrange numbers:

add eax,ebx
    mov A,eax
    print str$(A)
    mov eax,A
    add ecx,edx
    mov F,ecx
    print str$(F)
    mov ecx,F

jj2007

First, read the Tips, Tricks and Traps part here.

Second, I will not touch or look at any code that does not have all headers and stops at "end start". It must be ready for copy & paste.

hutch--

This is why the MASM32 SDK is full compliant with the specification of both Intel and Microsoft with what is called the Intel ABI.

add eax,ebx
    mov A,eax
    print str$(A)
    mov eax,A
    add ecx,edx
    mov F,ecx
    print str$(F)
    mov ecx,F

The "print" macro calls Windows functions that will overwrite the EAX ECX and EDX registers and the EBX register has a special purpose in the OS so it needs to be protected.

You will not be able to mix Irvine code and MASM32 code for reasons JJ has already explained, the Irvine book is designed to get a student through a semester where the MASM32 SDK is designed for production quality code which must work safely in a Win32 environment.

hutch--

Here is a simple example of using ADD and SUB in 32 bit MASM.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    include \masm32\include\masm32rt.inc
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

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

    .code

start:
   
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    call main
    inkey
    exit

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

main proc

    push ebx
    push esi
    push edi

    mov ebx, 4
    mov esi, 8
    mov edi, 10

    mov eax, ebx
    add eax, esi
    sub eax, edi
    add eax, eax

    print str$(eax),13,10

    print "---------------------------",13,10

    mov ebx, 4
    print str$(ebx),13,10

    add ebx, esi
    print str$(ebx),13,10

    sub ebx, edi
    print str$(ebx),13,10

    add ebx, ebx
    print str$(ebx),13,10

    pop edi
    pop esi
    pop ebx

    ret

main endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

end start

felipe

Nice! Ratten, you should also use comments in some parts. For example:

Quote from: hutch-- on February 26, 2018, 12:58:37 PM


    mov ebx, 4                        ; Size of foo...
    mov esi, 8                         ; 8 times loop...
    mov edi, 10                      ; Imagine something else...
                   



:biggrin:

daydreamer

Quote from: jj2007 on February 26, 2018, 08:44:24 AM
Quote from: LordAdef on February 26, 2018, 08:36:32 AMlaziness?

Most probably they are proficient in several popular languages like Java, C, Python, but they suddenly find out that they are obliged to teach assembly. So they find the Irvine book in the university library and hack together some exercises. Look at the example above: single letter variables A, B, CF, D - really, really old members here may remember Dartmouth BASIC 8)

But it works to a certain degree - why drive a Ferrari (Masm32) if you can ride a bicycle (Irvine)?  ;)
well it was worse many years they still wanted students to drive an old T-Ford(16bitdos), even when windows 32bit existed many years, I guess windows10 not supporting 16bit mode,forced them to quit with16bit programming
I prefer Randall Hyde's book for the assembler bit and ichelions tutorials for get started with masm32 windows  api programming
http://www.plantation-productions.com/Webster/
why do they not use his book, he has been assembly language teacher,LISA assembler he wrote among things
hope he is still alive and well, do you know anything about that Hutch?

my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

hutch--

The problem with Randy Hyde's work is it is an old architecture from the DOS era where the assumptions of a segmented architecture are of negative value to anyone wanting to learn modern protected mode programming where FLAT memory model architecture is the only way to design code. The book by Daniel Kusswurm is a modern well designed work that is worth the effort to learn.

Kip Irvine's book is for another purpose, to get undergraduate students through a semester, it is not designed to produce production code for viable applications. The MASM32 SDK was designed from scratch to produce production code that is fully complaint with the 32 bit Intel ABI. It is a bit more difficult to start with but if a leaner is not misled by nonsense and learns to ABI, instruction sets and general coding techniques, they will produce reliable code that runs on all 32 and 64 bit versions of Windows.




ratten

Hi I am trying to do another program in assembly and my professor gave me a program that uses 32 bit variables and want us to make the same program using 64 bit variables, and I can't make it work here is the original program with 32 bit variables:

include \masm32\include\masm32rt.inc

.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD

.data
firstval DWORD 20002000h
secondval DWORD 11111111h
thirdval DWORD 22222222h
sum DWORD 0

.code
main PROC
mov eax,firstval
add eax,secondval
add eax,thirdval
mov sum,eax

  inkey str$(sum), " is the result in decimal" 
  exit
main ENDP
END main

And here is the program that I made:

include \masm32\include\masm32rt.inc

    .386
    .model flat,stdcall
    .stack 4096
    ExitProcess PROTO, dwExitCode:QWORD

    .data
    firstval     QWORD 1111000000001100h
    secondval QWORD 2222111100000011h
    thirdval    QWORD 3333222200001111h
    sum         QWORD 0

    .code
    main PROC

        mov rax,firstval
        add rax,secondval
        add rax,thirdval
        mov sum,rax
       
        inkey str$(sum), " is the result in decimal"
        exit
        main ENDP

    END main

I just changed the register eax for rax because thats what I found for 64 bit registers, and also change the DWORD declarations for QWORD the first program functions just fine but the second one just wont work, hope someone can help me out, Thanks!


hutch--

If its 64 bit MASM you are looking for, look at the subforum for 64 bit MASM, the modified code will not work as the architecture is different.