深入理解汇编函数中的寄存器使用与调用约定
在汇编编程中,正确使用寄存器和遵循调用约定是至关重要的。下面将通过几个具体的示例,详细介绍如何在MASM函数中使用非易失性通用寄存器和非易失性XMM寄存器,以及如何调用外部函数。
1. 使用非易失性通用寄存器
首先来看一个计算数组元素和与积的示例。以下是该示例的C++代码:
// Ch06_02.h
#pragma once
#include <cstdint>
extern "C" void CalcSumProd_avx(const int64_t* a, const int64_t* b, int32_t n,
int64_t* sum_a, int64_t* sum_b, int64_t* prod_a, int64_t* prod_b);
// Ch06_02.cpp
#include <iostream>
#include <iomanip>
#include "Ch06_02.h"
int main()
{
constexpr int n = 6;
constexpr int64_t a[n] = { 2, -2, -6, 7, 12, 5 };
constexpr int64_t b[n] = { 3, 5, -7, 8, 4, 9 };
int64_t sum_a, sum_b, prod_a, prod_b;
CalcSumProd_avx(a, b, n, &sum_a, &sum_b, &prod_a, &prod_b);
cons
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



