Author Topic: converting 32 bit code to 64 bit  (Read 1755 times)

AW

  • Member
  • *****
  • Posts: 1476
  • Let's Make ASM Great Again!
Re: converting 32 bit code to 64 bit
« Reply #15 on: May 24, 2018, 04:20:12 AM »
Quote
Why plus 7, shouldn't be plus 8
Felipe,
lea rax, [$+7] is 7 bytes long or is it 8 bytes long?

felipe

  • Member
  • ****
  • Posts: 926
  • Eagles are just great!
Re: converting 32 bit code to 64 bit
« Reply #16 on: May 24, 2018, 04:28:35 AM »
Oh ok, i think i understand now. I was confusing my mind with the addressing of data, but this are opcodes we are talking about... :idea:  :biggrin:
Felipe.

felipe

  • Member
  • ****
  • Posts: 926
  • Eagles are just great!
Re: converting 32 bit code to 64 bit
« Reply #17 on: May 24, 2018, 04:51:08 AM »
I remember when i used the debug program (from DOS). It was very usefull for some cases, like writting whatever code (without assembler directives) and to see the opcodes and operands (of course) almost inmmediately. Counting bytes there were easier...Is there a tool like this one for 64 bits or 32 bits? Olly support this kind of feature? I mean like opening your debugger, write a command like -a to start writing assembly instructions. Then save this and then see the opcodes with operands in each line, along with the assembly instructions. I know you can produce an assembly listing with opcodes, but that involves writting a program with at least some directives, etc. I'm not trying to be lazy  :biggrin:  , i'm just having an appetite for some utility like this. If anybody knows one, please let me know.  :idea:
I think may be useful to look this kind of things in a fast way.  :idea:
Felipe.

zedd151

  • Member
  • ****
  • Posts: 847
Re: converting 32 bit code to 64 bit
« Reply #18 on: May 25, 2018, 07:28:27 AM »

Code: [Select]

    include \masm32\include64\masm64rt.inc
    .data
    .data?
    .code

   

    entry_point proc
    invoke MessageBox,0,"Hello World","Title",MB_OK
    invoke ExitProcess, 0
    entry_point endp
   
    end


disassembles to this: (x64dbg.exe)

Code: [Select]

.code
00007FF60F181000 | enter 80,0                                |
00007FF60F181004 | sub rsp,60                                |
00007FF60F181008 | mov rcx,0                                 |
00007FF60F18100F | mov rdx,qword ptr ds:[7FF60F18306C]       | rdx:EntryPoint, 00007FF60F18306C:&"Hello World"
00007FF60F181016 | mov r8,qword ptr ds:[7FF60F183086]        | 00007FF60F183086:&"Title"
00007FF60F18101D | mov r9,0                                  | r9:EntryPoint
00007FF60F181024 | call qword ptr ds:[<&MessageBoxA>]        |
00007FF60F18102A | mov rcx,0                                 |
00007FF60F181031 | call qword ptr ds:[<&ExitProcess>]        |

.data
00007FF60F183000  0D 0A 00 00 30 18 0F F6 7F 00 00 0D 0A 00 0B 30  ....0..ö.......0 
00007FF60F183010  18 0F F6 7F 00 00 09 00 16 30 18 0F F6 7F 00 00  ..ö......0..ö... 
00007FF60F183020  22 00 20 30 18 0F F6 7F 00 00 3C 00 2A 30 18 0F  ". 0..ö...<.*0.. 
00007FF60F183030  F6 7F 00 00 3E 00 34 30 18 0F F6 7F 00 00 21 00  ö...>.40..ö...!. 
00007FF60F183040  3E 30 18 0F F6 7F 00 00 28 00 48 30 18 0F F6 7F  >0..ö...(.H0..ö. 
00007FF60F183050  00 00 29 00 52 30 18 0F F6 7F 00 00 00 00 00 00  ..).R0..ö....... 
00007FF60F183060  48 65 6C 6C 6F 20 57 6F 72 6C 64 00 60 30 18 0F  Hello World.`0.. 
00007FF60F183070  F6 7F 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ö............... 
00007FF60F183080  54 69 74 6C 65 00 80 30 18 0F F6 7F 00 00 00 00  Title..0..ö..... 


So, the converting of the arguments to registers is automatically done by the ?? preprocessor?
And what about the text strings, how and when are they put into the data section. I don't
fully understand.

Ooops, I see that I didn't put a "ret"
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

zedd151

  • Member
  • ****
  • Posts: 847
Re: converting 32 bit code to 64 bit
« Reply #19 on: May 25, 2018, 09:37:07 AM »
Here's a 'converted' example that doesn't fully work. It has been literally converted from 32 bit. It assembles and links okay with the bat file
but hangs during 'board' creation while trying to run.   :(

This very same program was used as a compatibility test for os's other than windows xp. It ran well as 32 bit program, and I can't figure out
what the exact problem. I know its stuck in a loop, and I tried changing rip to get out of the loop in debugger, window displays, but just a
black background.


Code: [Select]


        include \masm32\include64\masm64rt.inc


; ##############################################################################

        WinMain         proto :qword
        WndProc         proto :qword, :qword, :qword, :qword
        randb           proto :qword
        set_board       proto :qword, :qword
        find_mt         proto :qword, :qword
        painting        proto :qword, :qword, :qword
        moveit          proto :qword, :qword, :qword, :qword, :qword, :qword, :qword

; ##############################################################################

    .data
        CommandLine     dq 0
        hWnd            dq 0
        hInstance       dq 0
       
        Wwd             dq 262
        Wht             dq 288
       
        hBmp0           dq 0
        hBmp1           dq 0
        hBmp2           dq 0
        hBmp3           dq 0
        hBmp4           dq 0
        hBmp5           dq 0
        hBmp6           dq 0
        hBmp7           dq 0
        hBmp8           dq 0
        hBmp9           dq 0
        hBmp10          dq 0
        hBmp11          dq 0
        hBmp12          dq 0
        hBmp13          dq 0
        hBmp14          dq 0
        hBmp15          dq 0
       
        sqct            db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                       
        board           db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0
                        db 0

        mtoffset        db 0
                       
        szClassName     db "Game_Class", 0
        szDisplayName   db "4x4 Game", 0

; ##############################################################################

    .code

    entry_point proc
        invoke GetModuleHandle, 0
        mov hInstance, rax
        invoke WinMain, hInstance
        invoke ExitProcess, 0
    entry_point endp
; ##############################################################################

    WinMain proc hInst:qword
    local wc:WNDCLASSEX, msg:MSG, Wtx:qword, Wty:qword
   
    ; --------------------------------------------------
    ; fill the WNDCLASSEX structure with needed data
    ; --------------------------------------------------
   
        mov wc.cbSize, sizeof WNDCLASSEX
        mov wc.style, CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
        lea rax, WndProc
        mov wc.lpfnWndProc, rax
        mov wc.cbClsExtra, 0
        mov wc.cbWndExtra, 0
        push hInst
        pop wc.hInstance
        mov wc.lpszMenuName, 0
        lea rax, szClassName
        mov wc.lpszClassName, rax
       
    ; --------------------------------------------------
    ; set background color
    ; --------------------------------------------------
   
        invoke CreateSolidBrush, 0
        mov wc.hbrBackground, rax

    ; --------------------------------------------------
    ; load icon
    ; --------------------------------------------------
   
        invoke LoadIcon, hInst, 1234
        mov wc.hIcon, rax

        ; use same handle for small icon
   
        push wc.hIcon
        pop wc.hIconSm
       
    ; --------------------------------------------------
    ; load cursor
    ; --------------------------------------------------
   
        invoke LoadCursor, 0, IDC_ARROW
        mov wc.hCursor, rax


    ; --------------------------------------------------
    ; register class
    ; --------------------------------------------------
   
        invoke RegisterClassEx, addr wc

    ; --------------------------------------------------
    ; center window to screen
    ; --------------------------------------------------
   
        invoke GetSystemMetrics, SM_CXSCREEN
        shr rax, 1
        mov rdx, Wwd
        shr rdx, 1
        sub rax, rdx
        mov Wtx, rax
       
        invoke GetSystemMetrics, SM_CYSCREEN
        shr rax, 1
        mov rdx, Wht
        shr rdx, 1
        sub rax, rdx
        mov Wty, rax

    ; --------------------------------------------------
    ; create main window
    ; --------------------------------------------------
   
        invoke CreateWindowEx, 0, addr szClassName, addr szDisplayName, \
                                WS_CAPTION or WS_SYSMENU or WS_VISIBLE, \
                                Wtx, Wty, Wwd, Wht, 0, 0, hInst, 0
           
        mov hWnd, rax
       
    ; --------------------------------------------------
    ; show & update window
    ; --------------------------------------------------

        invoke ShowWindow, hWnd, SW_SHOWNORMAL
        invoke UpdateWindow, hWnd
       
    ; --------------------------------------------------
    ; message dispatcher
    ; --------------------------------------------------
   
    StartLoop:
        invoke GetMessage, addr msg, 0, 0, 0
        cmp rax, 0
       
        je ExitLoop
            invoke TranslateMessage, addr msg
            invoke DispatchMessage, addr msg
    jmp StartLoop
        ExitLoop:
       
    ; --------------------------------------------------
    ; exit winmain
    ; --------------------------------------------------
 ;         mov rax, msg.wParam
        ret
    WinMain endp
   
; ##############################################################################
align 10h
    WndProc proc hWin:qword, uMsg:qword, wParam:qword, lParam:qword
   
        .if uMsg == WM_CREATE
       
        invoke seed_rrand, 123456786   ;;;;; <--- for use with rrand
       
; ------------------------------------------------------------------------------
; load bitmaps, obtain handles
; ------------------------------------------------------------------------------

        invoke LoadBitmap, hInstance, 100
        mov hBmp0, rax          ; for the 'empty' square
       
        invoke LoadBitmap, hInstance, 101
        mov hBmp1, rax          ; handle # is also the pieces' number,
                                ; for this one and the rest
                               
        invoke LoadBitmap, hInstance, 102
        mov hBmp2, rax
       
        invoke LoadBitmap, hInstance, 103
        mov hBmp3, rax
       
        invoke LoadBitmap, hInstance, 104
        mov hBmp4, rax
       
        invoke LoadBitmap, hInstance, 105
        mov hBmp5, rax
       
        invoke LoadBitmap, hInstance, 106
        mov hBmp6, rax
       
        invoke LoadBitmap, hInstance, 107
        mov hBmp7, rax
       
        invoke LoadBitmap, hInstance, 108
        mov hBmp8, rax
       
        invoke LoadBitmap, hInstance, 109
        mov hBmp9, rax
       
        invoke LoadBitmap, hInstance, 110
        mov hBmp10, rax
       
        invoke LoadBitmap, hInstance, 111
        mov hBmp11, rax
       
        invoke LoadBitmap, hInstance, 112
        mov hBmp12, rax
       
        invoke LoadBitmap, hInstance, 113
        mov hBmp13, rax
       
        invoke LoadBitmap, hInstance, 114
        mov hBmp14, rax
       
        invoke LoadBitmap, hInstance, 115
        mov hBmp15, rax

; ------------------------------------------------------------------------------
; randomly set board with random numbered game pieces
; ------------------------------------------------------------------------------

        invoke set_board, addr board, addr sqct
       
; ------------------------------------------------------------------------------
; locate the empty square and save the offset to it
; ------------------------------------------------------------------------------

        invoke find_mt, addr board, addr mtoffset

        .elseif uMsg == WM_KEYDOWN
       
            .if wParam == VK_LEFT
           
                ; moveit - arguments:
                ; ptr Board
                ; offset of empty square
                ; illegal move # 1
                ; illegal move # 2
                ; illegal move # 3
                ; illegal move # 4
                ; offset of piece to move (relative to mt square)
               
                invoke moveit, addr board, mtoffset, 3, 7, 11, 15, 1
               
            .elseif wParam == VK_UP
                invoke moveit, addr board, mtoffset, 12, 13, 14, 15, 4
   
            .elseif wParam == VK_RIGHT
                invoke moveit, addr board, mtoffset, 0, 4, 8, 12, -1
   
            .elseif wParam == VK_DOWN
                invoke moveit, addr board, mtoffset, 0, 1, 2, 3, -4
   
            .elseif wParam == VK_ESCAPE
                invoke SendMessage, hWin, WM_CLOSE, 0, 0
            .endif
           
            invoke find_mt, addr board, addr mtoffset
            invoke painting, hWin, addr board, addr hBmp0
           
        .elseif uMsg == WM_PAINT
            invoke painting, hWin, addr board, addr hBmp0
           
        .elseif uMsg == WM_CLOSE
            invoke PostQuitMessage, 0
           
        .endif
       
        invoke DefWindowProc, hWin, uMsg, wParam, lParam
        ret
    WndProc endp
   
; ##############################################################################
align 10h
    randb proc base:qword           ; simplified version of 'nrand'
    local random_seed:qword         ; not fast, but small and
        invoke GetTickCount         ; adequate for our purposes here.
        add rax, random_seed
        xor rdx, rdx
        mov rcx, 127773
        div rcx
        mov rcx, rax
        mov rax, 432836
        mul rdx
        sub rcx, rax
        xor rdx, rdx
        mov rax, rcx
        mov random_seed, rcx
        div base
        mov rax, rdx
        inc rax
        ret
    randb endp
   
; ##############################################################################
align 10h
    set_board proc pbrd:qword, psqct:qword
        push rsi
        push rdi
        push rbx
        mov rsi, pbrd       ; pointer to byte values representing the game board
        mov rdi, psqct      ; pointer to byte array acting as 'valid piece' counter

; ***************** hangs here*********************

    toppa:
        push rcx

        invoke randb, 16    ; generate random value for location
        pop rcx
        mov rdx, rax
        dec rdx
        push rdx

        invoke randb, 15    ; generate random value for game piece
        pop rdx
        mov rcx, rax
        dec rcx
        ; both of these values must be zero to create a new valid game piece
       
        cmp byte ptr [rdi+rcx], 0   ; check if location is empty
        jnz @f
        cmp byte ptr [rsi+rdx], 0   ; check if piece value is not already used
        jnz @f
       
        mov byte ptr [rsi+rdx], al  ; write new piece value to location
        mov byte ptr [rdi+rcx], 1   ; set counter for piece value to 1
                                    ; indicating the value has been used already

    @@:
        xor rax, rax                ; clear eax for the next step
        xor rcx, rcx                ; clear ecx for the next step
    @@:
        add al, byte ptr [rdi+rcx]  ; adding up all of the piece value counters
        inc rcx
        cmp rcx, 16                 ; check all 16 possible locations
        jl @b
        cmp rax, 15                 ; check all possible piece values
        jnz toppa

;***************************************************
 ; hangs above this line, in the loop
;***************************************************
        pop rbx
        pop rdi
        pop rsi
        ret
    set_board endp

; ##############################################################################
align 10h
    find_mt proc pbrd:qword, pmtoffs:qword
        xor rax, rax                ; simple proc that scans all locations
        mov rcx, pbrd               ; to locate the empty square
    @@:
        cmp byte ptr [rcx+rax], 0
        jz @f
        inc rax
        jmp @b
    @@:
        mov rcx, pmtoffs
        mov [rcx], rax              ; saving the location of the empty square
        ret
    find_mt endp
   
; ##############################################################################
align 10h
    painting proc hWin:qword, pbrd:qword, phndl:qword
    local tX:qword, tY:qword, hDC:qword, hMemDC:qword, ps:PAINTSTRUCT, numb:qword
        push rsi
        push rdi
        push rbx
       
        invoke GetDC, hWin
        mov hDC, rax
        invoke CreateCompatibleDC, NULL
        mov hMemDC, rax

        mov numb, 0
        mov tX, 0
        mov tY, 0
       
    top0:
       
        mov rcx, numb           ; index to location
        mov rdi, phndl          ; pointer to handle array
        mov rsi, pbrd           ; pointer to game board
        xor rdx, rdx            ; counter
        mov dl, [rsi+rcx]       ; get piece value (to be used as index)
        mov eax, [rdi+rdx*8]    ; get handle from array

        invoke SelectObject, hMemDC, rax
        invoke BitBlt, hDC, tX, tY, 64, 64, hMemDC, 0, 0, SRCCOPY
        inc numb
        add tX, 64              ; incrementing tX and tY as dictated
        cmp tX, 256             ; by the location being processed
        jnz @f
        add tY, 64
        mov tX, 0
    @@:
        cmp numb, 16            ; compare if all squares have been processed
        jnz top0

        invoke DeleteDC, hMemDC
        invoke DeleteDC, hDC
        pop rbx
        pop rdi
        pop rsi
        ret
    painting endp

; ##############################################################################
align 10h
    moveit proc pbrd:qword, mt:qword, i1:qword, i2:qword, i3:qword, i4:qword, v7:qword
        push rsi
        push rdi
        mov rsi, pbrd               ; pointer to game board
        mov rcx, mt                 ; pointer to empty square
        cmp rcx, i1                 ; check against illegal move #1
        jz @f
        cmp rcx, i2                 ; check against illegal move #2
        jz @f
        cmp rcx, i3                 ; check against illegal move #3
        jz @f
        cmp rcx, i4                 ; check against illegal move #4
        jz @f
        mov rdi, rcx                ; move empty location to edi
        add rdi, v7                 ; add movement offset
        mov al, [rsi+rcx]           ; swap values of the two squares
        mov dl, [rsi+rdi]           ; source square now becomes the empty square
        mov [rsi+rdi], al           ; empty square now becomes filled with source value
        mov [rsi+rcx], dl
    @@:
        pop rdi
        pop rsi
        ret
    moveit endp

; ##############################################################################
end


The attachment 4x4  Windows Game is for this code (64 bit) The code shows the problem area

The 2nd attachment 4x4 Windows compat test is the original (32 bit) which is fully operational

Running this code in the debugger everything else seems to be in order, but always gets stuck in the same loop 
« Last Edit: July 19, 2018, 05:29:38 PM by zedd151 »
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

zedd151

  • Member
  • ****
  • Posts: 847
Re: converting 32 bit code to 64 bit
« Reply #20 on: May 25, 2018, 09:43:31 AM »
looking at it again, the bitmaps are also not getting loaded. I'm trying to figure this out  :icon_confused:

edit --

Probably a register preservation issue.  ;) The code above only preserves registers 32 bit style. lemme see if I can rewrite some of the code...
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

zedd151

  • Member
  • ****
  • Posts: 847
Re: converting 32 bit code to 64 bit
« Reply #21 on: May 25, 2018, 03:53:20 PM »
I've decided to scrap this idea. I will recreate the game one small step at a time, using tried and true code.   :biggrin:
Trying to convert existing 32 bit code is rather complex it seems. I may have better luck building up slowly.

To simplify things, I've borrowed a rather generic window.

Code: [Select]

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

    include \buildx64\include64\masm64rt.inc

    .data?
      hBrush    dq ?
      hCursor   dq ?
      hFont     dq ?
      hIcon     dq ?
      hInstance dq ?
      hWnd      dq ?
      sHgt      dq ?
      sWid      dq ?

    .data
      classname db "got_no_class",0
      caption db "4x4 Game (64 bit)",0

    .code
etc., etc., etc., ad nauseous


   :P

The remainder of this project will be in the Game Development forum..
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

zedd151

  • Member
  • ****
  • Posts: 847
Re: converting 32 bit code to 64 bit
« Reply #22 on: May 25, 2018, 04:36:35 PM »
from  (masm64.chm) "MASM64 Library And Macro Reference"...

"ML64.EXE is a lower level assembler than the 32 bit version of ML.EXE and it does not support prototypes or parameter and size checking"

So that means that this:

Code: [Select]
        WinMain         proto :qword
        WndProc         proto :qword, :qword, :qword, :qword
        randb           proto :qword
        set_board       proto :qword, :qword
        find_mt         proto :qword, :qword
        painting        proto :qword, :qword, :qword
        moveit          proto :qword, :qword, :qword, :qword, :qword, :qword, :qword



Is totally unnecessary with 64 bit ML?
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

jj2007

  • Member
  • *****
  • Posts: 8728
  • Assembler is fun ;-)
    • MasmBasic
Re: converting 32 bit code to 64 bit
« Reply #23 on: May 25, 2018, 05:10:41 PM »
So that means that this:

        WinMain         proto :qword

Is totally unnecessary with 64 bit ML?

Yes, exactly. And if you pass 12 arguments to CreateWindowEx instead of 11, no problem, your source will build fine with ML64 8)

zedd151

  • Member
  • ****
  • Posts: 847
Re: converting 32 bit code to 64 bit
« Reply #24 on: May 25, 2018, 05:18:57 PM »

... your source will build fine with ML64 8)


 :badgrin:

They made something that should be simple into something more complicated. I noticed too, that the ".if, .elseif, .else, .endif" block is not fully supported without the use of external macros. More reading to do ...
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

jj2007

  • Member
  • *****
  • Posts: 8728
  • Assembler is fun ;-)
    • MasmBasic
Re: converting 32 bit code to 64 bit
« Reply #25 on: May 25, 2018, 06:07:09 PM »
exchange of views, over 11 years ago, between Microsoft (Kang Su Gatlin, Visual C++ Program Manager) and some members of this forum titled MASM on x64:

M$: how important is "INVOKE" for x64 MASM? ... Would you rank INVOKE as more or less important than the high-level control flow directives such as .WHILE, .IF, etc...?

Randy Hyde: The *vast* majority of MASM32 projects I've ever seen certainly use both.

Eugen: I am using MASM for writing fairly complex commercial applications (mainly shareware games) and i consider critical to be able to use both invoke and if/else HLL constructs.

hutch--: a properly designed INVOKE style syntax becomes critical to this range of users. Particularly for C/C++ programmers who are used to prototyping and the reliability of size and parameter count checking, bare mnemonics are very unpalatable to them.

Tedd: rough guesses on what I personally use, though I dare say others are similar.. invoke - LOTS, proc/endproc - lots, .IF/.ELSEIF/.ELSE - very often

GregL: PROTO / INVOKE are very important to me, as well as .IF. .WHILE and .LOOP would be next in importance.

BogdanOntanu: I will never use an assembler that has no invoke or extended call syntax and .IF .ELSEIF .ELSE .ENDIF constructs included in the assembler.

hutch--: In terms of priority of pseudo high level constructions, I would tend to place them in this order.
1. INVOKE  Critical for C/C++ programmer who are used to prototyping and who have little chance of writing bare mnemonic code.
2. .IF block syntax for sequential conditional testing. Nearly as critical for reliable higher level code.
3.  .WHILE / .REPEAT loop code syntax.  Useful but can generally be replaced with manual loop code.

M$: I'd like to thank EVERYONE for their feedback.

zedd151

  • Member
  • ****
  • Posts: 847
Re: converting 32 bit code to 64 bit
« Reply #26 on: May 25, 2018, 06:13:46 PM »
 8)  I'll stick around in 32-bit land for a while. It will probably outlive my existence.

While there is still an abundance of 32 bit software available that's how long I'll stick with 32 bits.   :bgrin:
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5756
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: converting 32 bit code to 64 bit
« Reply #27 on: May 25, 2018, 07:18:27 PM »
You need to know a bit of the history of MASM. When Microsoft introduced MASM version 6.0 in about 1990, it was a full development environment aimed at the programming consumer market, they did an update a couple of years later with MASM 6.1 which was the last consumer version they ever sold. They tried to drop it after that in the middle 90s but after consumer demand did not drop off they re-introduced it as a free add on to the version of VC at the time, it was version 6.15.

By the time 64 bit started to hit the market they started to look around and the drift at the time was "Don't mess up ML.EXE" as it was a decent reliable tool and due to its age it still retained all of the consumer capacity it started with in 1990.

ML64.EXE is a different animal, its a boiler room low level tool that was never pointed at the consumer market, its not far off an "in house" low level tool for the stuff they needed to make OS bits but fortunately it still retained the old pre-processor which made at least some of the missing capacity possible. It is an unconfigured raw assembler which has both virtues and vices. Prototyping disappeared, the .IF block notation went and the pseudo high level loop techniques did not survive either.

With the work I have done with ML64, the invoke style notation is up and running, I have used Vasily's .IF block notation which does the job and produced a stackframe macro that handles the quirks of the Win64 ABI so its no big deal to write once you are used to it. From one who remembered the crap back in the middle to late 90s about MASM, ML.EXE was just as badly understood and heavily criticised by the TASM guys until it was developed and supported properly.

I have much the same view on ML64, it is a pretty bare bones tool but you can get results with it if you know what you are doing with it. Import libraries, include files, a range of macros and a custom library seem to be the way and it is complete application capable at the moment, library modules can be added ad infinitum so I don't see any real problems here.

ML64 is not the only low level assembler, FASM is at least as low level as MASM yet it is an excellent tool. The main gain in using ML64 has been that it no longer requires prototypes and this improved my coding speed and flexibility by a reasonable amount.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

zedd151

  • Member
  • ****
  • Posts: 847
Re: converting 32 bit code to 64 bit
« Reply #28 on: May 25, 2018, 07:41:33 PM »
@hutch..
Your points are well taken.  But it seems like I'm a fish out of water, floundering around with ml64.

I'll stick with ml (32 bit),  but I still have the capability to try 64 bit again in the future.   8)

I've bitten off more than I can chew with ml64. I still have a lot to learn with ml 32 bit programming, and probably have no business attempting coding for 64 bit.   :P
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5756
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: converting 32 bit code to 64 bit
« Reply #29 on: May 25, 2018, 09:05:45 PM »
Z,

It will come with practice, working with 32 bit will get you back up to pace and this much, mnemonics in win64 are much the same as in 32 bit, just a bit bigger. When you have another go at 64 bit, start with the higher level stuff and when you have got the swing of it you can play with the lower level stuff if you need to. Starting with the bottom line low level stuff in win64 is the wrong way to go as its messy and complicated but the higher level stuff with a stack frame is very similar to working with 32 bit MASM.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin: