Author Topic: Please help me with this code  (Read 356 times)

vohai2003

  • Regular Member
  • *
  • Posts: 7
Please help me with this code
« on: July 12, 2020, 06:25:23 PM »
I'm totally noob in assembly. I don't know anything about it.
Now I'm trying to recompile a x64 code into x86, which have a assembly inside that project.
I don't know how to convert it.
It may be sound silly, but can anyone help me to convert it?
P/s: This code is from citra source code. I'm trying to make a x86 version to compatible with older PC (like mine :thumbsup:)

felipe

  • Member
  • *****
  • Posts: 1323
  • Eagles are just great!
Re: Please help me with this code
« Reply #1 on: July 13, 2020, 12:30:03 AM »
since citra is software that gives you the source code for you to compile under license gpl i think this post is legitimate, but i'm not telling you that i will help you. Maybe i can help you (depends on my time), but the source you provided says:

Code: [Select]
include ksamd64.inc

Since that file is, most probably, in 64 bits assembly, then it would be needed too, to do the conversion. You should post that one too.  :icon_idea:
Felipe.

felipe

  • Member
  • *****
  • Posts: 1323
  • Eagles are just great!
Re: Please help me with this code
« Reply #2 on: July 13, 2020, 12:55:13 AM »
Also you should know that because 32 bits and 64 bits are different, even if you can compile all the c or c++ code for 32 bits easily (maybe),  it will be requiered (most likely) to know more about the project, for these 64 bits assembly files can work as intended after converting them to 32 bits files. So even after converting the files, there are no warranties that the files work as intended originally within the 64 bits original project in the converted 32 bits project.  :icon_idea:
Felipe.

vohai2003

  • Regular Member
  • *
  • Posts: 7
Re: Please help me with this code
« Reply #3 on: July 13, 2020, 12:08:35 PM »
Yes, you're right. I didn't even notice that.
C code are quite easy to recompile, but nothing warranty that it works, since some change have been made on my project automatically.
Even lastest build for x86 I found working quite laggy and can't run some game with unusual memory stack.
I can't find ksamd64.inc in that project. Weird. Maybe it's a build-in VS file. :dazzled:

jj2007

  • Member
  • *****
  • Posts: 10464
  • Assembler is fun ;-)
    • MasmBasic
Re: Please help me with this code
« Reply #4 on: July 13, 2020, 06:34:00 PM »
There is a file with this name here. However, it's also mentioned at Microsoft docs.

vohai2003

  • Regular Member
  • *
  • Posts: 7
Re: Please help me with this code
« Reply #5 on: July 13, 2020, 06:50:02 PM »
Nice, thanks! :thumbsup:
But the biggest problem is I can't find it anywhere.

TouEnMasm

  • Member
  • *****
  • Posts: 1295
    • EditMasm
Re: Please help me with this code
« Reply #6 on: July 16, 2020, 04:46:12 AM »
The ksamd64.inc is part of the sdk,recommended download.
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared\ksamd64.inc
That will be a little less dificult work If you have the source instead of a dissasembly X64 source code.
There is also
Quote
CallConv.Inc
ks386.inc
ksamd64.inc
ksamd64_stub.inc
kxamd64.inc
kxamd64_stub.inc
macamd64.inc
Little suprise,they are in masm langage



Fa is a musical note to play with CL

vohai2003

  • Regular Member
  • *
  • Posts: 7
Re: Please help me with this code
« Reply #7 on: July 16, 2020, 12:54:16 PM »
That's mean we can try to replace ksamd64.inc with ks386.inc right?
Is there any difficulty? :undecided:

TouEnMasm

  • Member
  • *****
  • Posts: 1295
    • EditMasm
Re: Please help me with this code
« Reply #8 on: July 16, 2020, 04:54:16 PM »
That's mean that your disassembly code was originally write in masm64 ,to be more precise ML64.exe.
I have recoqnize his macro.
The ks386.inc had only constants values in it.
The Ksamd64.inc had Include files and many macros in it.

see https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64?view=vs-2019
for more informations

Fa is a musical note to play with CL

vohai2003

  • Regular Member
  • *
  • Posts: 7
Re: Please help me with this code
« Reply #9 on: July 17, 2020, 12:47:06 AM »
So if we want it to run on 32 bit, we have to find replacement for that included libraries and re-make the macros. Understood :thup:.
I don't think there'll be so much difficulty but I think everything is possible.

vohai2003

  • Regular Member
  • *
  • Posts: 7
Re: Please help me with this code
« Reply #10 on: July 17, 2020, 06:05:55 PM »
Good news!!!
I've just successfully converted all C code in that project!!! Now the only problem is the asm file.

TouEnMasm

  • Member
  • *****
  • Posts: 1295
    • EditMasm
Re: Please help me with this code
« Reply #11 on: July 17, 2020, 10:22:18 PM »

If you can post the C code,this can be down easily by Visual Studio itself,cool no ?!
Fa is a musical note to play with CL

vohai2003

  • Regular Member
  • *
  • Posts: 7
Re: Please help me with this code
« Reply #12 on: July 19, 2020, 12:25:42 AM »
That's how I do it lol  :biggrin: