Delphi + Asm TBits类的学习
技术交流,DH讲解. 在D2010的classes中有个TBits类,这个类主要是位操作的. TBits = class
private
FSize: Integer;
FBits: Pointer;
procedure Error;
procedure SetSize(Value: Integer);
procedure SetBit(Index: Integer; Value: Boolean);
function GetBit(Index: Integer): Boolean;
public
destructor Destroy; override;
function OpenBit: Integer;
property Bits[Index: Integer]: Boolean read GetBit write SetBit; default;
property Size: Integer read FSize write SetSize;
end;
这个类没有什么方法,我们看到了property Bits[Index: Integer]: Boolean read GetBit write SetBit; default;这个属性,就是读取和设置某一位的.
那我们看看它是怎么实现的?
//在类中Eax就是Self指针
procedure TBits.SetBit(Index: Integer; Value: Boolean); assembler;
asm
CMP Index,[EAX].FSize //如果Indx>=Size then 扩容
JAE @@Size
@@1: MOV EAX,[EAX].FBits
OR Value,Value
JZ @@2
BTS [EAX],Index //将Eax中第Index位赋值给CF,然后Eax第index位=1;
RET
@@2: BTR [EAX],Index //将Eax中第Index位赋值给CF,然后Eax第index位=0;
RET
@@Size: CMP Index,0 //if index
相关文档:
Delphi in a Unicode World Part II: New RTL Features and
Classes to Support Unicode
By: Nick
Hodges
原文链接:http://dn.codegear.com/article/38498
Abstract: This article will cover the new features of the Tiburon
Runtime Library that will help handle Unicode strings.
//
& ......
问题背景:
公司希望使用Magento来进行接单,而后把订单导入到一个ERP系统中(订单处理引擎)。
问题:
在使用WebService从Magento中获取Payment信息时,信用卡是被加密的(法律规定不允许在数据库中存储信用卡的明文信息)!
......
很奇怪,昨天在编译程序的时候,出现过,iphist.dat 文件。每次执行都出现,仔细查看代码,什么也没有啊!后来在网站找到原因:
使用了IPWatch 控件的
一般产生这个文件是因为使用了indy的 TIdIPWatch 控件
该控件有个
ip历史的功能。
historyfilename指定的是保存ip历史记录的文件名,默认是iphist.Dat
......
Delphi 创建目录及写日志文件
var
TF: TextFile;
LogFile: string;
txt :string;
sysDir:string;
//创建按钮
procedure TForm1.Button1Click(Sender: TObject);
begin
sysDir:=extractfilepath(application.ExeName );
if not directoryexists(sysdir+'log\') then
createdir(sysdir+'log ......
在Delphi中,Inifiles单元中有一个TStringHash的类,不过它的Value仅支持Integer(其实也不是问题,有其它类型可以将变量变为Pointer),有点不舒服,今天没事做就把它替换为variant了,其中Key的名称大小写无关,就是为了加快开发速度!
使用Hashtable,查找和删除复杂度都是常数级别的!
type
PPHashItem = ^PHashItem;
......