tag:blogger.com,1999:blog-1532151022505671498.post2188866999900199596..comments2023-11-24T22:28:36.140+01:00Comments on Delphi sorcery: Creating a delegate at runtimeStefan Glienkehttp://www.blogger.com/profile/05509404049325709406noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-1532151022505671498.post-46804488021903290032012-12-13T20:10:12.774+01:002012-12-13T20:10:12.774+01:00x64 assembly:
PUSH RBP
SUB RSP,$20
MOV RBP,R...x64 assembly:<br /> PUSH RBP<br /> SUB RSP,$20<br /> MOV RBP,RSP<br /> MOV RAX,Self.FMethod.Code<br /> MOV RCX,Self.FMethod.Data<br /> CALL RAX<br /> LEA RSP,[RBP+$20]<br /> POP RBPAnonymoushttps://www.blogger.com/profile/05949929110910422415noreply@blogger.comtag:blogger.com,1999:blog-1532151022505671498.post-79421192659483048742012-06-04T01:21:11.532+02:002012-06-04T01:21:11.532+02:00Thanks! In my tests I had no problems with the EBX...Thanks! In my tests I had no problems with the EBX register but that was just coincidence then I think.Stefan Glienkehttps://www.blogger.com/profile/09320735081289619570noreply@blogger.comtag:blogger.com,1999:blog-1532151022505671498.post-72257432980376383412012-06-03T18:49:25.887+02:002012-06-03T18:49:25.887+02:00About interface "fake" class generation,...About interface "fake" class generation, you may take a look at our Open Source implementation, as integrated within mORMot.<br />It works for Delphi 6 up to XE2, and IMHO it is more easy to follow and use that the one integrated in the SOAP good old implementation, or the latest version of the RTTI. It is also more optimized.<br />See for instance how we wrote the interface wrapper asm content, at http://blog.synopse.info/post/2012/03/07/Interface-based-services-implementation-details<br />I'll certainly use it to create stub and mocks interface for Delphi, in the next months.Arnaudhttps://www.blogger.com/profile/00421394020248758254noreply@blogger.comtag:blogger.com,1999:blog-1532151022505671498.post-32572178648364618432012-06-03T18:42:40.723+02:002012-06-03T18:42:40.723+02:00I suspect your asm code won't work either with...I suspect your asm code won't work either with good old x86!<br />You are using the EBX register, which shall be preserved.<br />A call to PUSH EBX + POP EBX at the end to preserve it would work.<br /><br />Or perhaps<br /><br />procedure TDelegate.Invoke;<br />asm<br /> push [EAX].FMethod.Code<br /> MOV EAX,[EAX].FMethod.Data<br />end; // here RET will go to FMethod.CodeArnaudhttps://www.blogger.com/profile/00421394020248758254noreply@blogger.com