文档详情

Delphi中使用汇编例子(国外英文资料).doc

发布:2017-06-10约9.5千字共32页下载文档
文本预览下载声明
Delphi中使用汇编例子(国外英文资料) Use assembly examples in Delphi -- -- -- -- -- is a sophomore, and then an example. Well, the program was a little messy, please excuse me. Using assembly in Delphi for hybrid programming is an unusual convenience. This way, when you want to be productive, you can choose to compile, but most of the work, youre still enjoying the convenience of visualizing, object-oriented programming. Delphi language, by using asm... The end program section writes the assembly code section, which can call the variables of the high-level language in the assembly code segment; What you need to be aware of is to protect some register variables, and then, some of the details are different from those in DOS. So lets look at this example. Lets start with a general idea: One, the Delphi call assembles, there are two ways. As -- - PRocedure TForm1. DrawRain; var X1, y1, x2, y2, d, I: integer; Begin / / Delphi program begins For I: = 0 to 100 do The begin The x1: = the random (537); Y1: = the random (280); D: = the random (7); Asm / / embedded assembly begins Push eax Mov eax, x1 Sub eax, d Mov x2, eax Mov eax, y1 The add eax, d Mov y2, eax Pop eax The end;; / / embedded assembly finishes Times: = times + 1; DrawLine2 (x1, y1, x2, y2, clmedGray); Wait (); If (I div 2) = 0 then drawLine2 (x1, y1, x2, y2, clwindow); The end; The end; / / Delphi program is over And one of them, begin... End of end, through asm... End goes directly into assembly. Procedure TForm1. Wait (); Asm / / embedded assembly begins Push eax Mov eax, 0 @ loop: The add eax, 1 CMP eax, 1000000 JNZ @ loop Pop eax The end; / / embedded assembly finishes Second, use the Delphi variable in the assembly If you look at the first example of the code, its easy to understand: Asm / / embedded assembly begins Push eax Mov eax, x1 / / x1 is the Delphi local variable, which is used here as a value Sub eax, d Mov x2, eax / / x2 is the Delphi local variable, which is also used as memory address Mov eax, y1 The add ea
显示全部
相似文档