以下是引用multiple1902在2007-8-14 20:31:51的发言:
抱歉刚才瞎扯了……
不过我以为VB如此伪编译的东西真正运行的时候不会认真到如此简单地操作寄存器吧(今天刚在书店看了本单片机的书……)
要是说错了就当我继续扯淡吧……
这是一个在工程中的模块,模块中只有一个Main函数,一个简单的加法函数
Sub Main()
Dim X As Long
X = Add1(1, 1)
End Sub
Private Function Add1(ByVal NUM1 As Long, ByVal NUM2 As Long) As Long
Add1 = NUM1 + NUM2
End Function
'下面是VB生成的List文件(汇编格式)
TITLE I:\Text\Module1.bas
.386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA ENDS
CONST SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST ENDS
_BSS SEGMENT DWORD USE32 PUBLIC 'BSS'
_BSS ENDS
_TLS SEGMENT DWORD USE32 PUBLIC 'TLS'
_TLS ENDS
text$1 SEGMENT PARA USE32 PUBLIC ''
text$1 ENDS
; COMDAT ?Main@Module1@@AAGXXZ
text$1 SEGMENT PARA USE32 PUBLIC ''
text$1 ENDS
; COMDAT ?Add1@Module1@@AAGXXZ
text$1 SEGMENT PARA USE32 PUBLIC ''
text$1 ENDS
FLAT GROUP _DATA, CONST, _BSS
ASSUME CS: FLAT, DS: FLAT, SS: FLAT
endif
PUBLIC ?Main@Module1@@AAGXXZ ; Module1::Main
PUBLIC ?Add1@Module1@@AAGXXZ ; Module1::Add1
; COMDAT ?Main@Module1@@AAGXXZ
text$1 SEGMENT
?Main@Module1@@AAGXXZ PROC NEAR ; Module1::Main, COMDAT
; 5 : Dim X As Long
; 6 : X = Add1(1, 1)
push 1
push 1
call ?Add1@Module1@@AAGXXZ ; Module1::Add1
; 7 : End Sub
ret 0
?Main@Module1@@AAGXXZ ENDP ; Module1::Main
text$1 ENDS
EXTRN __imp____vbaErrorOverflow:NEAR
; COMDAT ?Add1@Module1@@AAGXXZ
text$1 SEGMENT
_NUM2$ = 12
_NUM1$ = 8
?Add1@Module1@@AAGXXZ PROC NEAR ; Module1::Add1, COMDAT
; 10 : Add1 = NUM1 + NUM2
mov eax, DWORD PTR _NUM1$[esp-4]
mov ecx, DWORD PTR _NUM2$[esp-4]
add eax, ecx '将ECX中的值与EAX的值相加,存入EAX
jo SHORT $L23
; 11 : End Function
ret 8
$L23:
call DWORD PTR __imp____vbaErrorOverflow
?Add1@Module1@@AAGXXZ ENDP ; Module1::Add1
text$1 ENDS
END
你自己对比一下两段代码吧
[此贴子已经被作者于2007-8-14 21:28:14编辑过]