Author Topic: starter with masm32 help  (Read 4469 times)

ratten

  • Regular Member
  • *
  • Posts: 15
Re: starter with masm32 help
« Reply #15 on: February 26, 2018, 10:19:47 AM »
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

  • Regular Member
  • *
  • Posts: 15
Re: starter with masm32 help
« Reply #16 on: February 26, 2018, 10:43:25 AM »
and also I am on windows 10, I dont know if that has anything to do with it

jj2007

  • Member
  • *****
  • Posts: 10456
  • Assembler is fun ;-)
    • MasmBasic
Re: starter with masm32 help
« Reply #17 on: February 26, 2018, 10:45:27 AM »
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

  • Member
  • ****
  • Posts: 650
Re: starter with masm32 help
« Reply #18 on: February 26, 2018, 10:54:56 AM »
Check your task manager and see if your exe is running in tjee background and that's why qeditor cannot open the exe

ratten

  • Regular Member
  • *
  • Posts: 15
Re: starter with masm32 help
« Reply #19 on: February 26, 2018, 11:00:10 AM »
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

  • Member
  • *****
  • Posts: 10456
  • Assembler is fun ;-)
    • MasmBasic
Re: starter with masm32 help
« Reply #20 on: February 26, 2018, 11:05:00 AM »
Try \Masm32\tutorial\console\ and \Masm32\help\
There are also many small demos in \Masm32\examples

ratten

  • Regular Member
  • *
  • Posts: 15
Re: starter with masm32 help
« Reply #21 on: February 26, 2018, 11:50:07 AM »
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

  • Member
  • *****
  • Posts: 10456
  • Assembler is fun ;-)
    • MasmBasic
Re: starter with masm32 help
« Reply #22 on: February 26, 2018, 12:13:10 PM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 7455
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: starter with masm32 help
« Reply #23 on: February 26, 2018, 12:25:01 PM »
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 at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7455
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: starter with masm32 help
« Reply #24 on: February 26, 2018, 12:58:37 PM »
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
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

felipe

  • Member
  • *****
  • Posts: 1323
  • Eagles are just great!
Re: starter with masm32 help
« Reply #25 on: February 27, 2018, 02:34:45 PM »
Nice! Ratten, you should also use comments in some parts. For example:

Code: [Select]

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


 :biggrin:
Felipe.

daydreamer

  • Member
  • *****
  • Posts: 1318
  • building nextdoor
Re: starter with masm32 help
« Reply #26 on: March 04, 2018, 07:30:15 PM »
laziness?

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?

Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D
I love assembly,because its legal to write
princess:lea eax,luke
:)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7455
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: starter with masm32 help
« Reply #27 on: March 05, 2018, 03:56:47 PM »
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.



hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

ratten

  • Regular Member
  • *
  • Posts: 15
Re: starter with masm32 help
« Reply #28 on: March 11, 2018, 11:35:53 AM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 7455
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: starter with masm32 help
« Reply #29 on: March 11, 2018, 11:58:11 AM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: