basm

Delphi/ASM code incompatible with 64bit?

拥有回忆 提交于 2019-12-21 16:59:23
问题 I have some sample source code for OpenGL, I wanted to compile a 64bit version (using Delphi XE2) but there's some ASM code which fails to compile, and I know nothing about ASM. Here's the code below, and I put the two error messages on the lines which fail... // Copy a pixel from source to dest and Swap the RGB color values procedure CopySwapPixel(const Source, Destination: Pointer); asm push ebx //[DCC Error]: E2116 Invalid combination of opcode and operands mov bl,[eax+0] mov bh,[eax+1]

Porting Assembler x86 CPU ID code to AMD64

不问归期 提交于 2019-12-13 11:43:32
问题 I have a problem. I have following x86 delphi code which is written in ASM. I need to port this to AMD64? type TCPUID = array[1..4] of Longint; function GetCID : TCPUID; assembler; register; asm push ebx push edi mov edi, eax mov eax, 1 dw $A20F stosd mov eax, ebx stosd mov eax, ecx stosd mov eax, edx stosd pop edi pop ebx end; I have never programmed in assembly, does anyone know what the port would be or how I would go about changing it. 回答1: I am not Win64 assembler guru, but the next

Delphi assembler: understanding the Result register

人盡茶涼 提交于 2019-12-13 04:48:11
问题 I'm messing around with ASM in Delphi. From my understanding, EAX holds Result. In the following, I have to put RET at the end, otherwise Result is not correct (it is correct if the input is 0). What am I doing wrong, or should I say, what don't I understand about this? function MSb(const Val: Integer): Integer; label Go; asm CMP EAX, 0 JNZ Go MOV EAX, -1 RET Go: BSR EBX, EAX MOV EAX, EBX RET end; If I say the following: MOV Result, EBX Then I get the following compilation: MOV [EPB-$04], EBX

Assembly calls to System unit functions on FreePascal x64

对着背影说爱祢 提交于 2019-12-10 15:40:01
问题 I have some Delphi/assembly code that compiles and works fine (XE2) for Win32, Win64, and OSX 32. However, since I need it to work on Linux, I have been looking at compiling FPC versions of it (so far, Win32/64, Linux32/64). By and large, it works well, but the one thing I have not been able to get to work are calls/jumps to Delphi System unit functions, like such: jmp System.@FillChar This appears to have the desired effect on FPC Win32/Linux32, but fails with an exception on FPC Win64

Call Object Method using ASM

谁都会走 提交于 2019-12-07 13:18:51
问题 To better explain what I'm trying to accomplish, I'm going to start with something that works. Say we have a procedure that can call another procedure and pass a string parameter to it: procedure CallSaySomething(AProc: Pointer; const AValue: string); var LAddr: Integer; begin LAddr := Integer(PChar(AValue)); asm MOV EAX, LAddr CALL AProc; end; end; This is the procedure that we will call: procedure SaySomething(const AValue: string); begin ShowMessage( AValue ); end; Now I can call

Call Object Method using ASM

▼魔方 西西 提交于 2019-12-06 00:57:44
To better explain what I'm trying to accomplish, I'm going to start with something that works. Say we have a procedure that can call another procedure and pass a string parameter to it: procedure CallSaySomething(AProc: Pointer; const AValue: string); var LAddr: Integer; begin LAddr := Integer(PChar(AValue)); asm MOV EAX, LAddr CALL AProc; end; end; This is the procedure that we will call: procedure SaySomething(const AValue: string); begin ShowMessage( AValue ); end; Now I can call SaySomething like so(tested and works (: ): CallSaySomething(@SaySomething, 'Morning people!'); My question is,

Delphi/ASM code incompatible with 64bit?

╄→尐↘猪︶ㄣ 提交于 2019-12-04 07:44:18
I have some sample source code for OpenGL, I wanted to compile a 64bit version (using Delphi XE2) but there's some ASM code which fails to compile, and I know nothing about ASM. Here's the code below, and I put the two error messages on the lines which fail... // Copy a pixel from source to dest and Swap the RGB color values procedure CopySwapPixel(const Source, Destination: Pointer); asm push ebx //[DCC Error]: E2116 Invalid combination of opcode and operands mov bl,[eax+0] mov bh,[eax+1] mov [edx+2],bl mov [edx+1],bh mov bl,[eax+2] mov bh,[eax+3] mov [edx+0],bl mov [edx+3],bh pop ebx //[DCC

What CPU registers are to be restored at the end of an asm procedure in Delphi

断了今生、忘了曾经 提交于 2019-12-03 17:31:31
问题 When writing a Delphi procedure or function in assembly code, which registers must be saved and restored to the original value at the end of the procedure? When calling another Delphi procedure or function from (inline) assembly code, what can I expect that other function to do with the registers? Which registers will be restored to their original values and which may not? (Obviously, the same answer would apply to both questions) I am assuming the default calling convention of Delphi. I know

What CPU registers are to be restored at the end of an asm procedure in Delphi

∥☆過路亽.° 提交于 2019-12-03 05:40:54
When writing a Delphi procedure or function in assembly code, which registers must be saved and restored to the original value at the end of the procedure? When calling another Delphi procedure or function from (inline) assembly code, what can I expect that other function to do with the registers? Which registers will be restored to their original values and which may not? (Obviously, the same answer would apply to both questions) I am assuming the default calling convention of Delphi. I know that EAX is used for 32-bit return values. And looking at the asm code in SysUtils.pas, it seems that

FLD instruction x64 bit

倖福魔咒の 提交于 2019-12-01 17:59:08
I have a little problem with FLD instruction in x64 bit ... want to load Double value to the stack pointer FPU in st0 register, but it seem to be impossible. In Delphi x32, I can use this code : function DoSomething(X:Double):Double; asm FLD X // Do Something .. FST Result end; Unfortunately, in x64, the same code does not work. In x64 mode floating point parameters are passed in xmm-registers. So when Delphi tries to compile FLD X, it becomes FLD xmm0 but there is no such instruction. You first need to move it to memory. The same goes with the result, it should be passed back in xmm0. Try