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. 为Firefox 添加自定义搜索引擎

    网上流传的 about:config[对于新版已经失效] 以及到Firefox安装目录中修改 的方式不知道为什么我没有成功 现在来个简单点得! 首先我们需要一个可以自定义搜索引擎的插件 Organiz ...

  2. 转:alphaImageLoader滤镜加载后 链接不能点击

    我是一个很少使用IE滤镜,也是一个不赞成使用IE滤镜的前端工程师.不过今天有一个朋友给我发来了一个有关于IE6的BUG,就是在IE6中使用了AlphaPNG透明的IE滤镜之后,a链接不能够点击.具体情 ...

  3. ElasticSearch基本用法

    最大的特点: 1. 数据库的 database, 就是  index 2. 数据库的 table,  就是 tag 3. 不要使用browser, 使用curl来进行客户端操作.  否则会出现 jav ...

  4. Protel99se教程四:将SCH转为PCB文件

    本节课,我们介绍,如何快速的将绘制好的SCH文件转为PCB文件,首先,我们打开刚开始时我们绘制的SCH原理图,我们可以使用protel99se菜单栏的view-Fit All Objects命令,以查 ...

  5. docpad建站记录

    记一下用docpad建站的过程作为备忘.不定时更新 why docpad wordpress对我来说太过于臃肿,我就想要个代码干净的小站来写东西.想要个markdown为基础的静态站. 比较流行的St ...

  6. mac下的搭建本地discuz论坛

    本地是php+mysql+apache的环境.也可以用xampp一键安装的东西,那个貌似比较省事.因为我的本地php环境已经装好了,就直接下了discuz的代码安装. 打开web共享 将discuz代 ...

  7. DontDestroyOnLoad(Unity3D开发之五)

    Unity中我们从A场景切换到B场景的时候,A场景全部对象都会销毁,但有时候我不须要销毁某些东西. 比方一个简单的游戏的背景音乐,我不须要多次反复创建,多个场景播放这一个即可了.这个时候就须要用到Do ...

  8. Task线程 同时执行多个任务

    Task taskTest = Task.Factory.StartNew(() => { Console.WriteLine("); },TaskCreationOptions.No ...

  9. unity之uv贴图画圆弧,圆弧面,不规则图形

    由于最近一直没有时间,所以这篇博客一直没发,下面我说说uv画圆弧,圆面,不规则面拼接. 先来两张效果图 图截的不咋滴,凑合着看吧,画圆弧主要用的贝塞尔曲线画的,我感觉这个比较简单,当然大家也可以使用圆 ...

  10. HTML5 音频视频

    HTML5 视频和音频的 DOM 参考手册 HTML5 DOM 为 <audio> 和 <video> 元素提供了方法.属性和事件. 这些方法.属性和事件允许您使用 JavaS ...