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

jj2007

  • Member
  • *****
  • Posts: 10644
  • Assembler is fun ;-)
    • MasmBasic
Re: converting 32 bit code to 64 bit
« Reply #45 on: May 27, 2018, 02:50:16 AM »
64 bit code.


mov eax, rct.left    : DWORD sized structure member


Run the register equates and watch it go BANG !  :P

There is absolutely no reason why it should go BANG.

Code: [Select]
jinvoke GetWindowRect, hWnd, addr rc
mov eax, rc.left
jinvoke TextOut, PtDC, 7, 2, Str$("rc.left: \t%i", eax), s$Len
mov eax, rc.top
jinvoke TextOut, PtDC, 7, 22, Str$("rc.top: \t%i", eax), s$Len
mov eax, rc.right
jinvoke TextOut, PtDC, 7, 42, Str$("rc.right: \t%i", eax), s$Len
mov eax, rc.bottom
jinvoke TextOut, PtDC, 7, 62, Str$("rc.bottom: \t%i", eax), s$Len
Builds and runs just fine, as 32- or 64-bit code. Project attached (exe assembled with ML64, but it builds with UAsm, too).

nidud

  • Member
  • *****
  • Posts: 1991
    • https://github.com/nidud/asmc
Re: converting 32 bit code to 64 bit
« Reply #46 on: May 27, 2018, 02:53:19 AM »
:biggrin:

> You can only use these register equates in 32-bit.

So its about as useful as a hip pocket in a T shirt.

> Using the Windows API, you can . . . .

Fine in a C/C++ compiler but hopeless in an assembler.

The two (identical) samples provided above do actually work.

Quote
After years of dealing with people who get confused by not knowing what the data size is, using native data sizes dictated by the hardware is reliable and confusion free. Scour you way through a collection of Microsoft .H files to track down the typedefs to eventually find what SIZE the data is.  :P

The source provided is 89 lines of confusing code so it would be interesting to see the Masm32/64 confusing free version of the same.  :P

jj2007

  • Member
  • *****
  • Posts: 10644
  • Assembler is fun ;-)
    • MasmBasic
Re: converting 32 bit code to 64 bit
« Reply #47 on: May 27, 2018, 03:03:02 AM »
My code (see previous post) is equally confusing, of course, but it's only 82 lines. And good to know that AsmC can still be used to build assembly sources :badgrin:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7608
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: converting 32 bit code to 64 bit
« Reply #48 on: May 27, 2018, 03:52:53 AM »

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

    include \masm32\include64\masm64rt.inc

    rax equ <eax>

    .code

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

entry_point proc

    LOCAL rct   :RECT           ; 4 x DWORD members

  ; -----------------
    mov rax, rct.left           ; goes BANG here !!!!
  ; -----------------

    waitkey
    .exit

entry_point endp

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

    end

Build

 Assembling: jjxxx.asm
jjxxx.asm(5) : error A2008:syntax error : rax
jjxxx.asm(16) : error A2022:instruction operands must be the same size
POLINK: fatal error: File not found: 'jjxxx.obj'.
 Volume in drive K is disk3_k
 Volume Serial Number is 68C7-4DBB
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

nidud

  • Member
  • *****
  • Posts: 1991
    • https://github.com/nidud/asmc
Re: converting 32 bit code to 64 bit
« Reply #49 on: May 27, 2018, 04:17:11 AM »
include windows.inc

    rax equ <eax>

.code

main proc

  local rct:RECT

    mov rax,rct.left
    ret

main endp

    end


Build: asmc -win64 test.asm

 Assembling: test.asm
test.asm(3) : error A2008: syntax error : rax
test.asm(11) : error A2022: instruction operands must be the same size : 8 - 4

zedd151

  • Member
  • ****
  • Posts: 871
Re: converting 32 bit code to 64 bit
« Reply #50 on: May 27, 2018, 05:53:58 AM »
I've created a monster with this thread.  8)

Funny thing is, I've temporarily at least given up the idea of programming in Masm64, and the thread has taken a tangent from its original purpose.   :icon_confused:  And the debate goes on..
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

jj2007

  • Member
  • *****
  • Posts: 10644
  • Assembler is fun ;-)
    • MasmBasic
Re: converting 32 bit code to 64 bit
« Reply #51 on: May 27, 2018, 06:33:40 AM »
Don't worry, zedd, we are just teasing each other a little bit :icon_mrgreen:

mov rax, rct.left is certainly bad code. It should be mov eax, rct.left - in 32-bit as well as in 64-bit land ;)

Btw my includes do contain rax equ eax. And my source above builds with ML, UAsm and Asm, as 32- or 64-bit code. Which doesn't imply that I would seriously consider to start a 64-bit career. Unless you need to address more than 2 gigabytes of RAM, there is absolutely no advantage using 64-bit code. Slow and messy :biggrin:

zedd151

  • Member
  • ****
  • Posts: 871
Re: converting 32 bit code to 64 bit
« Reply #52 on: May 27, 2018, 12:31:38 PM »
The way that it's going, Micro$**t might even kill macro support altogether. Along with the other niceties that made it very easy and fun to work with. If that does happen,  might as well assemble your code with Olly.    :biggrin:

Just create a file filled with 0x0h bytes,  slap on a generic header,  adjust  section headers and import infos accordingly.  And don't forget to build your resources with resource hacker.    8)

(actually it's a lot more involved than that..  But you get the idea)     :greensml:
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7608
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: converting 32 bit code to 64 bit
« Reply #53 on: May 27, 2018, 01:54:17 PM »
One of the reasons why you don't need to worry about Microsoft trashing MASM is that they need it, that is why it still exists. The last commercial version was 6.1 about 1993 (I still have the box, manuals and probably even the disks) but it has continued in VC/VS for no other reason than there are things in an OS that cannot be done with ultra high level visual garbage generators. ML was consumer software where ML64 in close to being an "in house" scruffy that does the job they need but with few frills and conveniences. The ancient pre-processor survives because it already existed and it is (in their terms) useful at times.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

daydreamer

  • Member
  • *****
  • Posts: 1385
  • building nextdoor
Re: converting 32 bit code to 64 bit
« Reply #54 on: May 27, 2018, 03:55:14 PM »
64 bit code.


mov eax, rct.left    : DWORD sized structure member


Run the register equates and watch it go BANG !  :P

There is absolutely no reason why it should go BANG.

Code: [Select]
jinvoke GetWindowRect, hWnd, addr rc
mov eax, rc.left
jinvoke TextOut, PtDC, 7, 2, Str$("rc.left: \t%i", eax), s$Len
mov eax, rc.top
jinvoke TextOut, PtDC, 7, 22, Str$("rc.top: \t%i", eax), s$Len
mov eax, rc.right
jinvoke TextOut, PtDC, 7, 42, Str$("rc.right: \t%i", eax), s$Len
mov eax, rc.bottom
jinvoke TextOut, PtDC, 7, 62, Str$("rc.bottom: \t%i", eax), s$Len
Builds and runs just fine, as 32- or 64-bit code. Project attached (exe assembled with ML64, but it builds with UAsm, too).
its feels so unneccerary to type extra chars,like in jinvoke,coinvoke, etc,when masm has capabilities to reprogram keywords
and why dont anyone dare to use equates like this:  :P
rax equ <al> etc
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
:)

daydreamer

  • Member
  • *****
  • Posts: 1385
  • building nextdoor
Re: converting 32 bit code to 64 bit
« Reply #55 on: May 27, 2018, 04:13:51 PM »
you are all way late when it comes to code 64bit coding,pentium MMX(1993) came with 64bit coding although very limited to 64bit qword operations but still,nintendo64bit,PS2 had 128bit cpu ,SSE came shortly afterwards with 128bit xmm regs,also the first pixelshaders hardware was compiled with nvasm (nvidias assembler)  :P
today its time for you to code with 256/512 bit hardware,pixelshaders or avx
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
:)

jj2007

  • Member
  • *****
  • Posts: 10644
  • Assembler is fun ;-)
    • MasmBasic
Re: converting 32 bit code to 64 bit
« Reply #56 on: May 27, 2018, 05:34:32 PM »
its feels so unneccerary to type extra chars,like in jinvoke,coinvoke, etc,when masm has capabilities to reprogram keywords

masm has capabilities to reprogram keywords? It is not that easy...

Note that Hutch & Vasily do have a macro that's called invoke. But their invoke doesn't check the type and number of parameters; jinvoke does, and will throw an error if you pass 10 arguments to CreateWindowEx instead of the 11 required.

Furthermore, it's a matter of taste if you want to write
  .if eax<=ecx
or
  .if eax{=ecx

There is a simple solution to such problems, it's called UAsm - same syntax as ML32, all HLL elements intact... it has been discussed before, and compromises are on the table (i.e. a switch that disables the HLL macros), but as it stands, you can pick either

- an assembler that understands eax<=ecx but has no libraries attached (UAsm, AsmC)
or
- an assembler that has libraries but forces you to use eax{=ecx (ML64)

My personal solution is to avoid 64-bit coding.

nidud

  • Member
  • *****
  • Posts: 1991
    • https://github.com/nidud/asmc
Re: converting 32 bit code to 64 bit
« Reply #57 on: May 27, 2018, 07:14:13 PM »
- an assembler that understands eax<=ecx but has no libraries attached (UAsm, AsmC)

 :biggrin:

Small correction.

The Asmc package currently include the following:
- assembler, linker and library manager for 16/32/64-bit
- 239 include files (203642 lines) with 3000 macros
- 109 win32 import libraries
- 670 win64 import libraries
- libc.lib (16-bit) – 403 files
- libc.lib (32-bit) – 493 files
- libc.lib (64-bit) – 214 files
- quadmath.lib (32/64-bit) 69 files
- directxmath.lib (64-bit) - 285 files
- 1240 test/sample files


LordAdef

  • Member
  • ****
  • Posts: 655
Re: converting 32 bit code to 64 bit
« Reply #58 on: May 27, 2018, 10:05:24 PM »
I am particularly happy I'm still getting to learn everything I can in masm32, and am not going into 64bits.
One thing I always thought to be bad for asm is the forking numbers of dialects. A unified MASM with joined forces would be so much better for the language, but we ended up having all these flavours hanging around and dividing. Imagine C with that many forks..


jj2007

  • Member
  • *****
  • Posts: 10644
  • Assembler is fun ;-)
    • MasmBasic
Re: converting 32 bit code to 64 bit
« Reply #59 on: May 27, 2018, 10:15:01 PM »
The Asmc package
Is there an installer? I tried "asmc" download installer but the first link that looks relevant is HOW TO REMOVE TROJAN.WIN32.AGENT.ASMC EASILY FROM YOUR COMPUTER ::)
Quote
Trojan.Win32.Agent.asmc is a malicious backdoor Trojan that endangers target computers terribly. It is a risky computer infection designed by cyber criminals to attack computer users all over the world. The backdoor Trojan is capable to take over the whole contaminated system upon its arrival. It is designed to perform malicious actions on victimized computers. To illustrate, the Trojan virus leads serious computer damages and data loss to victims. It has the ability to change your system files and entries and even drop harmful files in your system. Besides, this Trojan comes bundled with many potential threats like malware and adware to invade the victimized computer deeply in every possible way.