The MASM Forum

General => The Workshop => Topic started by: Drakasm on January 25, 2013, 03:28:15 AM

Title: Future with Masm32 >>> 64 ??? project
Post by: Drakasm on January 25, 2013, 03:28:15 AM
Hi all.
I wanted to know if there is a development project for Masm32
towards Masm32 - 64.
In fact the architecture of the processors gets more complicated and i have a clear sensation that we missing features.
My question includes if there are existing tutorials about programming in Windows64.

Thanks in advance.
Title: Re: Future with Masm32 >>> 64 ??? project
Post by: qWord on January 25, 2013, 03:59:16 AM
If you aware of 32 Bit assembly, the step into 64 Bit isn't that hard. In that case, AMD's documentation (Volume 1) is the way to read in. For windows, the calling convection and stack usage (http://msdn.microsoft.com/en-us/library/ms235286.aspx) has changed (more complicated).
As an Assembler, I would suggest you to use Japheth's jWasm (http://www.japheth.de/JWasm.html) with WinInc (http://www.japheth.de/WinInc.html).

qWord
Title: Re: Future with Masm32 >>> 64 ??? project
Post by: Drakasm on January 25, 2013, 04:06:01 AM
Exist's an IDE for jwasm ?
Till now i was using MasmEd - or Radasm .
Title: Re: Future with Masm32 >>> 64 ??? project
Post by: qWord on January 25, 2013, 04:10:25 AM
I use a slightly modified version of RadASM (http://masm32.com/board/index.php?topic=994.0).
Title: Re: Future with Masm32 >>> 64 ??? project
Post by: Drakasm on January 25, 2013, 04:25:20 AM
Many thanks qWord i :t
I think that there is a lot of homework for me to do.
I've seen only good comments about jwasm and this is encouraging, is always a challenge to integrate another assembler.
Title: Re: Future with Masm32 >>> 64 ??? project
Post by: Vortex on January 25, 2013, 05:40:34 AM
GoAsm is another good choice for 64-bit programming.
Title: Re: Future with Masm32 >>> 64 ??? project
Post by: Gunther on January 25, 2013, 05:46:19 AM
Hi  Drakasm,

jWasm has the advantage that it'll work under 64 bit Linux, too.

Gunther
Title: Re: Future with Masm32 >>> 64 ??? project
Post by: Drakasm on January 26, 2013, 05:49:50 AM
Hi Gunther,Vortex,qWord
Just assembled a small project32 with Jwasm and with a small modification in mmx syntax has worked just fine !!!!!!
Excellent masm syntax compatibility !!!
Only issue with the resource compiler which increased the size of the executable 1Kbyte ?
I've used wrc with an already existing .RES file and combined them with the executable generated by the jwlink.
Previous executable created with the IDE MasmEd was 1Kbyte smaller.
Title: Re: Future with Masm32 >>> 64 ??? project
Post by: qWord on January 26, 2013, 06:00:49 AM
Quote from: Drakasm on January 26, 2013, 05:49:50 AMOnly issue with the resource compiler which increased the size of the executable 1Kbyte ?
I've used wrc with an already existing .RES file and combined them with the executable generated by the jwlink.
Previous executable created with the IDE MasmEd was 1Kbyte smaller.
maybe has something to do with the section alignment (linker) ... however who cares about ±1KB ;)
Title: Re: Future with Masm32 >>> 64 ??? project
Post by: Drakasm on January 27, 2013, 08:15:07 PM
Testing some examples and adding some options. >>>

;--- Win32_7 - Shows how to use OPTION DLLIMPORT and cmdline option -Fd.
;---           As a result, no import libraries are needed in the link step.
;---
;--- assemble: JWasm -coff -Fd Win32_7.ASM
;--- link:     JWlink format windows pe f Win32_7.OBJ

    .386
    .MODEL FLAT, stdcall
    option casemap:none

STD_OUTPUT_HANDLE equ -11

   option dllimport:<kernel32>
WriteConsoleA proto :dword, :dword, :dword, :dword, :dword
GetStdHandle  proto :dword
ExitProcess   proto :dword
   option dllimport:<user32>
MessageBoxA   proto :dword, :dword, :dword, :dword
 
option dllimport:<openal32>
alcOpenDevice         proto :dword
alcCreateContext      proto :dword, :dword
alcMakeContextCurrent proto :dword
alcDestroyContext     proto :dword
alcCloseDevice        proto :dword
   option dllimport:<none>
    .CONST

string  db 13,10,"hello, world.",13,10
    db 0

    .CODE

main proc

      LOCAL dwWritten:DWORD
      LOCAL Hxos:DWORD
      LOCAL Contesto:DWORD
     
      invoke alcOpenDevice,0
       mov Hxos,eax
       invoke alcCreateContex,Hxos,0
       mov Contesto,eax
       invoke alcMakeContexCurrent,Contesto
       invoke alcDestroyContex,Contesto
       invoke alcCloseDevice,Hxos
    invoke  GetStdHandle, STD_OUTPUT_HANDLE
    mov     ebx, eax
    invoke  WriteConsoleA, ebx, addr string, sizeof string, addr dwWritten, 0
    invoke  MessageBoxA, 0, addr string, 0, 0
    ret

main endp

;--- entry

start:

    invoke  main
    invoke  ExitProcess, 0

    END start


Keeps giving me error invoke requires prototype for procedure. :(
Title: Re: Future with Masm32 >>> 64 ??? project
Post by: japheth on January 27, 2013, 09:47:02 PM
Quote from: Drakasm on January 27, 2013, 08:15:07 PM
Keeps giving me error invoke requires prototype for procedure. :(

I'd recommend to buy a pair of glasses - and then to read carefully.
Title: Re: Future with Masm32 >>> 64 ??? project
Post by: frktons on January 28, 2013, 07:38:22 AM
Quote from: Drakasm on January 27, 2013, 08:15:07 PM

start:

    invoke  main
    invoke  ExitProcess, 0

    END start


Keeps giving me error invoke requires prototype for procedure. :(


Probably a CALL main will suffice.
I don't know JWasm syntax, but this instruction looks strange.

Frank
Title: Re: Future with Masm32 >>> 64 ??? project
Post by: Drakasm on February 01, 2013, 10:19:06 PM
 :biggrin: Finally i have corrected my errors and now my beloved jwasm is not complaining.

QuoteProbably a CALL main will suffice.
I don't know JWasm syntax, but this instruction looks strange.
Thank you frktons for your reply, but the problem was that i didn't supply Jwasm the correct prototypes for
the functions i was calling. :(
OpenAL.dll uses the cdelc  calling convention.



;--- Win32_7 - Shows how to use OPTION DLLIMPORT and cmdline option -Fd.
;---           As a result, no import libraries are needed in the link step.
;---
;--- assemble: JWasm -coff -Fd Win32_7.ASM
;--- link:     JWlink format windows pe f Win32_7.OBJ

    .386
    .MODEL FLAT,stdcall
    option casemap:none

STD_OUTPUT_HANDLE equ -11

   option dllimport:<kernel32>
WriteConsoleA proto :dword, :dword, :dword, :dword, :dword
GetStdHandle  proto :dword
ExitProcess   proto :dword
Beep          proto :dword, :dword
   option dllimport:<user32>
MessageBoxA   proto :dword, :dword, :dword, :dword

option dllimport:<openal32>
alcOpenDevice         proto  c : ptr dword
alcCreateContext      proto  c : ptr dword,: ptr dword
alcMakeContextCurrent proto  c : ptr dword
alcDestroyContext     proto  c : ptr dword
alcCloseDevice        proto  c : ptr dword 
   ;option dllimport:<none>
    .CONST

string  db 13,10,"hello, world.",13,10
    db 0
ProgramTitle db "jwasm",0
Infomation db "Love Jwasm",0
    .CODE

main proc

     LOCAL   dwWritten:dword
LOCAL   aldevice:dword
LOCAL   alcontext:dword
    invoke alcOpenDevice,0
    mov aldevice,eax
    cmp eax,0
jne @F
invoke MessageBoxA,0,ADDR Infomation,ADDR ProgramTitle,0
    @@:
    invoke alcCreateContext,eax,0
    mov alcontext,eax
    invoke alcMakeContextCurrent,eax
    invoke alcDestroyContext,alcontext
    invoke alcCloseDevice,aldevice
    invoke  GetStdHandle, STD_OUTPUT_HANDLE
    mov     ebx, eax
    invoke  WriteConsoleA, ebx, addr string, sizeof string, addr dwWritten, 0
    invoke Beep,5000,1000
    invoke  MessageBoxA, 0, ADDR Infomation, ADDR ProgramTitle, 0
    ret

main endp

;--- entry

start:

    invoke  main
    invoke  ExitProcess, 0

    END start


:icon_eek:
QuoteI'd recommend to buy a pair of glasses - and then to read carefully.
japheth
I don't  wear glasses but with all the information i read probably i'am going to need them.
Jwasm is a fabulous assembler and by no means i was referring to a possible Jwasm problem.
As a matter  of fact the problem is certainly mine "New to assembler".
When i have seen the beautiful possibility jwasm offers to link without the necessity of import libraries...... :greenclp:
but  being hasty is equivalent to making mistakes.
Thank you for your reply and for Jwasm. :t

Title: Re: Future with Masm32 >>> 64 ??? project
Post by: japheth on February 02, 2013, 09:24:02 PM
Quote from: Drakasm on February 01, 2013, 10:19:06 PM
Thank you for your reply

It was my pleasure.  :P Btw, the glasses-remark was targeted to the missing 't' in several locations of the source that you posted (" invoke alcCreateContex,Hxos,0" ).
Title: Re: Future with Masm32 >>> 64 ??? project
Post by: Vortex on February 02, 2013, 10:01:08 PM
Hi Japheth,

About the Win32_7.asm example, I tried to insert the equates in the option dllimport section and this worked fine :t

  option dllimport:<kernel32>
WriteConsoleA proto :dword, :dword, :dword, :dword, :dword
GetStdHandle  proto :dword
ExitProcess   proto :dword
   option dllimport:<user32>
MessageBoxA   proto :dword, :dword, :dword, :dword
MessageBox equ <MessageBoxA>
WriteConsole equ <WriteConsoleA>
   option dllimport:<none>
.
.
.
invoke  GetStdHandle, STD_OUTPUT_HANDLE
mov     ebx, eax
invoke  WriteConsole, ebx, addr string, sizeof string, addr dwWritten, 0
invoke  MessageBox, 0, addr string, 0, 0
ret


JWasm assembled the same example with the modifications above and didn't report any error message.