问题描述
我正在尝试为C ++创建一个Assembly(FASM)函数,该函数添加2个具有32位元素的数组,但是它似乎无法正常工作。它返回{409,0,0}而不是{0x99999999,0x06000001,0x00000000}。可能是什么原因造成的?
调用该函数的C ++程序:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
extern "C"
{
unsigned int __stdcall long_add(int*,int*,int*);
}
int main()
{
int testOne[3] = { 0x12345678,0x04000000,0xFFFFFFFF };
int testTwo[3] = { 0x87654321,0x02000000,0x00000001 };
int testOut[3] = {};
long_add(testOne,testTwo,testOut);
scanf;
Assembly函数本身:
include 'include\win32a.inc'
format MS COFF
public long_add as '_long_add@12'
section '.code' code readable executable
proc long_add IN_NUM1,IN_NUM2,OUT_NUM
start:
mov ecx,3
clc
mov edi,[IN_NUM1]
mov esi,[IN_NUM2]
ADDING:
mov eax,[edi+(ecx-1)*4]
mov ebx,[esi+(ecx-1)*4]
adc eax,ebx
push eax
loop ADDING
mov esi,[OUT_NUM]
mov ecx,3
POPPING:
pop eax
mov [esi],eax
inc esi
loop POPPING
ret
endp
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)