64位win汇编之心得与笔记【4】

文章目录

  • c++与asm互调函数
  • debug
  • 参考文献

c++与asm互调函数

#include 
using namespace std;
extern "C"
{
    void asmLearn(void);
    void addNumber(long a,long b,long *result);
}
void addNumber(long a,long b,long *result){
    *result=a+b;
}
int main(){
    cout<<"starting"<<endl;
    asmLearn();
    cout<<"ended"<<endl;
}
    option casemap:none
    .data
hStrFmt byte 'result:%ld',10,0
x sqword 10000
y sqword 30000
result sqword ?
	.code
externdef printf:proc 
externdef addNumber:proc 
public asmLearn  
asmLearn PROC
    mov rcx,x
    mov rdx,y
    lea R8,result
    sub rsp,120
    call addNumber
    lea rcx,hStrFmt
    mov rdx,result
    call printf
    add rsp,120
	ret
asmLearn ENDP

END

E:\learn\masmlearn>l1
starting
result:40000
ended

debug

启用调试信息:

/Zi:生成完整的调试信息(PDB 文件)。

E:\learn\masmlearn>ml64 /c /Zi l11.asm
E:\learn\masmlearn>cl /EHa /Zi /DEBUG l1.cpp l11.obj
.sympath SRV*C:\Symbols*https://msdl.microsoft.com/download/symbols

windbg进行调试

参考文献

  1. chatgpt
  2. deepseek
  3. 《64位汇编语言的编程艺术》

你可能感兴趣的:(Game,Engine,汇编,笔记)