Code:
http://www.atelierweb.com/calling-64-bit-assembly-language-functions-lodged-inside-the-delphi-source-code/
http://www.codeproject.com/Articles/262819/Finally-Bit-Delphi-is-here-and-with-Bit-BASM

One thing you will notice immediately by looking at the code below is that 32-bit Assembly Language is totally different from 64-bit Assembly language. So, if you want to port 32-bit routines to 64-bit, forget about that and start new ones from scratch.

Code:
unit basmTestUnit;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type
TBasmTest = class(TForm)
GroupBox1: TGroupBox;
lblCaption: TLabel;
edCaption: TEdit;
lblInput: TLabel;
edInput: TEdit;
btGo: TButton; procedure btGoClick(Sender: TObject);
private public
{ Public declarations }
end; var
BasmTest: TBasmTest; implementation {$R *.dfm} var
myReturnString : string = 'I am back in Delphi!';
charCount : integer; type
bigarray = array[0..127] of char; function assemblyTestFunction(myCaption: string; myText : string): bigarray;
{$IFDEF CPUX86}
asm
// This is the 32-bit case with the default Register (Borland Fastcall) calling convention
// where the Result is an extra var parameter.
// Arguments are passed in EAX, EDX and ECX, left to right. So, the Result (i.e, the
// return value pointer) will come to the function in ECX.
push edi
push esi
push dword ptr 0
push dword ptr myCaption
push dword ptr myText
push dword ptr 0
mov edi, ecx; // Save the return pointer to EDI because we need ECX as a counter and
// EDI is the destination pointer in a rep movsw instruction
call MessageBox
mov esi, dword ptr myReturnString
mov ecx, [charCount]
rep movsw
pop esi
pop edi
ret
end;
{$ELSE}
{$IFDEF CPUX64}
// This is the 64-bit case
// General rule: Integer and pointer arguments are passed left to right in RCX, RDX, R8
// and R9. HOWEVER, when there is a large return value, this is the case, RCX contains
// a pointer to the return space when the callee is called and all Registers usage are
// pushed one to the right
//
asm
push rsi
push rdi
push rbx
push rbp // Yes, it is a kludge. No need to push rbp, it is just to align the stack.
// The alternative is 'and rsp,-16'
sub rsp, 28h xor r9, r9
mov rbx, rcx
mov rax, rdx
mov rdx, r8
mov r8, rax
xor rcx, rcx
call MessageBox mov rdi, rbx
mov rsi, qword ptr myReturnString
mov ecx, [charCount]
rep movsw
add rsp, 28h
pop rbp
pop rbx
pop rdi
pop rsi
ret
end;
{$ENDIF CPUX64}
{$ENDIF} procedure TBasmTest.btGoClick(Sender: TObject);
var
retValue : bigArray;
begin
fillchar(retValue, sizeof(bigArray),0);
charCount := length(myReturnString);
retValue := assemblyTestFunction(edCaption.Text, edInput.Text);
showMessage(retValue);
end;

Download Example:

Code:
http://www.atelierweb.com/downloads/BasmTest.zip

https://www.board4allcz.eu/showthread.php?t=618277

Calling 64-bit assembly language functions lodged inside the Delphi source code的更多相关文章

  1. 1.2 ASSEMBLY LANGUAGE

    People are much happier moving up the ladder,socially or even technically.So our profession has move ...

  2. An Assembly Language

    BUFFER OVERFLOW 3 An Assembly Language Introduction Basic of x86 Architecture Assembly Language Comp ...

  3. Notes on <Assembly Language step by step>

    By brant-ruan Yeah, I feel very happy When you want to give up, think why you have held on so long. ...

  4. PythonStudy——汇编语言 Assembly Language

    汇编语言 汇编语言(assembly language)是一种用于电子计算机.微处理器.微控制器或其他可编程器件的低级语言,亦称为符号语言.在汇编语言中,用助记符(Mnemonics)代替机器指令的操 ...

  5. Language and Compiler Features Since Delphi 7

    from: http://edn.embarcadero.com/cn/article/34324 Language and Compiler Features Since Delphi 7   In ...

  6. 《PC Assembly Language》读书笔记

    本书下载地址:pcasm-book. 前言 8086处理器只支持实模式(real mode),不能满足安全.多任务等需求. Q:为什么实模式不安全.不支持多任务?为什么虚模式能解决这些问题? A: 以 ...

  7. CS萌新的汇编学习之路(其实是老师作业呵呵哒)Learning of Assembly Language

    第一节课学习汇编语言,做笔记,做笔记 1.概念 首先是汇编语言这门课程的定义以及对于学习高级语言.深入理解计算机系统的作用 软硬件接口机器语言 汇编语言 高级语言 关系 机器语言和汇编语言可移植性差 ...

  8. 汇编语言教材assembly language

    https://en.wikipedia.org/wiki/Assembly_language https://baike.baidu.com/item/%E6%B1%87%E7%BC%96%E8%A ...

  9. 《汇编语言程序设计》(Professional Assembly Language)学习笔记(二)

    挖坑:学习笔记(一)讲述如何在 Windows Vmware 上安装 Ubuntu 20.04 实践环境 本文是基于Ubuntu 20.04平台进行实验,下文中的解决方法都基于此前提 问题记录 问题一 ...

随机推荐

  1. Session()

    如何使用 Session Java Api 只给我们一种方式来 获取 当前会话相关的 session: HttpSession session = request.getSession(); //或 ...

  2. BestCoder Round #61 (div.2)

    Numbers Accepts: 571 Submissions: 1212 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/26 ...

  3. sass基本语法

    sass是一种基于ruby语言开发的CSS预处理器.它可以使用变量,嵌套,混入,继承,运算,函数等编程语言具有的特性进行CSS的开发,使得CSS的开发变得简单粗暴清晰可维护. sass有两种后缀文件格 ...

  4. 移动Web开发小技巧

    移动Web开发小技巧 添加到主屏后的标题(IOS) name="apple-mobile-web-app-title" content="标题"> 启用  ...

  5. 如何通过java反射将数据库表生成实体类?

    首先有几点声明: 1.代码是在别人的基础进行改写的: 2.大家有什么改进的意见可以告诉我,也可以自己改好共享给其他人: 3.刚刚毕业,水平有限,肯定有许多不足之处: 4.希望刚刚学习java的同学能有 ...

  6. 2013 Changsha Regional 一样的木板一样的气球

    气球:      木板:   比赛现场: 场外: 曲线....  除了第一题出的太慢了,总体比成都好了很多.... 自此,今年两铜收场,再接再厉,明年要有更好的成绩.

  7. jquery自定义分页插件

    //每次只显示5个页码(function ($) { //设定页码方法,初始化 $.fn.setPager = function (options) { var opts = $.extend({}, ...

  8. IE6不支持<a>标签以外元素的hover的解决方案

    IE6以及更低版本的浏览器对“:hover”的支持不理想,对于类似的“p:hover”.“img:hover”.“#header:hover”...,今天给大家介绍一种新的方法,可以完美解决IE6不支 ...

  9. Qt探秘——谈ui文件的用法

    转载自:点击打开链接http://blog.csdn.net/luo_isaiah/article/details/5794973 相信用过Qt Designer的朋友,对Qt Project中的.u ...

  10. MySQL root密码重置报错:mysqladmin: connect to server at 'localhost' failed的解决方案!

    -- ==================================================================== --  mysqladmin: connect to s ...