Author Topic: Future with Masm32 >>> 64 ??? project  (Read 11962 times)

Drakasm

  • Guest
Future with Masm32 >>> 64 ??? project
« 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.

qWord

  • Member
  • *****
  • Posts: 1475
  • The base type of a type is the type itself
    • SmplMath macros
Re: Future with Masm32 >>> 64 ??? project
« Reply #1 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 has changed (more complicated).
As an Assembler, I would suggest you to use Japheth's jWasm with WinInc.

qWord
MREAL macros - when you need floating point arithmetic while assembling!

Drakasm

  • Guest
Re: Future with Masm32 >>> 64 ??? project
« Reply #2 on: January 25, 2013, 04:06:01 AM »
Exist's an IDE for jwasm ?
Till now i was using MasmEd - or Radasm .

qWord

  • Member
  • *****
  • Posts: 1475
  • The base type of a type is the type itself
    • SmplMath macros
Re: Future with Masm32 >>> 64 ??? project
« Reply #3 on: January 25, 2013, 04:10:25 AM »
I use a slightly modified version of RadASM.
MREAL macros - when you need floating point arithmetic while assembling!

Drakasm

  • Guest
Re: Future with Masm32 >>> 64 ??? project
« Reply #4 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.

Vortex

  • Member
  • *****
  • Posts: 2716
Re: Future with Masm32 >>> 64 ??? project
« Reply #5 on: January 25, 2013, 05:40:34 AM »
GoAsm is another good choice for 64-bit programming.

Gunther

  • Member
  • *****
  • Posts: 4115
  • Forgive your enemies, but never forget their names
Re: Future with Masm32 >>> 64 ??? project
« Reply #6 on: January 25, 2013, 05:46:19 AM »
Hi  Drakasm,

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

Gunther
You have to know the facts before you can distort them.

Drakasm

  • Guest
Re: Future with Masm32 >>> 64 ??? project
« Reply #7 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.

qWord

  • Member
  • *****
  • Posts: 1475
  • The base type of a type is the type itself
    • SmplMath macros
Re: Future with Masm32 >>> 64 ??? project
« Reply #8 on: January 26, 2013, 06:00:49 AM »
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.
maybe has something to do with the section alignment (linker) ... however who cares about ±1KB ;)
MREAL macros - when you need floating point arithmetic while assembling!

Drakasm

  • Guest
Re: Future with Masm32 >>> 64 ??? project
« Reply #9 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. :(

japheth

  • Guest
Re: Future with Masm32 >>> 64 ??? project
« Reply #10 on: January 27, 2013, 09:47:02 PM »
Keeps giving me error invoke requires prototype for procedure. :(

I'd recommend to buy a pair of glasses - and then to read carefully.

frktons

  • Member
  • ****
  • Posts: 512
Re: Future with Masm32 >>> 64 ??? project
« Reply #11 on: January 28, 2013, 07:38:22 AM »

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
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

Drakasm

  • Guest
Re: Future with Masm32 >>> 64 ??? project
« Reply #12 on: February 01, 2013, 10:19:06 PM »
 :biggrin: Finally i have corrected my errors and now my beloved jwasm is not complaining.
 
Quote
Probably 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.



Code: [Select]
;--- 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:
Quote
I'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
 
 

japheth

  • Guest
Re: Future with Masm32 >>> 64 ??? project
« Reply #13 on: February 02, 2013, 09:24:02 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" ).

Vortex

  • Member
  • *****
  • Posts: 2716
Re: Future with Masm32 >>> 64 ??? project
« Reply #14 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

Code: [Select]
  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.