混合编程求助
c语言代码#include<stdio.h>
typedef struct {
char name[20];
char address[50];
int age;
} Employee;
void Memxchg(void* v1, void* v2, int n);
int main() {
public Employee emp1 = {"zhang","a",18};
public Employee emp2 = {"li","b",18};
Memxchg(&emp1, &emp2,sizeof(Employee));
printf("%s\t%s\t%d",emp1.name,emp1.address,emp1.age);
printf("%s\t%s\t%d",emp2.name,emp2.address,emp2.age);
}
汇编代码
.MODEL FLAT, C
.CODE
Memxchg PROC PUBLIC
xor si,si
xor cx,cx
xor dx,dx
xor bl,bl
xor bh,bh
xor ax,ax
mov ax,n
lea bl,v1
lea bh,v2
s: mov cx,[bl+si]
mov dx,[bh+si]
xchg cx,dx
mov [bl+si],cx
mov [bh+si],dx
add si,2
sub ax,2
cmp ax,2
jnl L1
jl L2
L1:
jmp s
L2:
mov cl,[bl+si]
mov dl,[bh+si]
xchg cl,dl
mov [bl+si],cl
mov [bh+si],dl
end s
Memxchg ENDP
报错信息
1>_MASM:
1> Assembling [Inputs]...
1>asm.asm(38): fatal error A1010: unmatched block nesting : Memxchg
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\masm.targets(49,5): error MSB3721: 命令“ml.exe /c /nologo /Zi /Fo"Debug\asm.obj" /W3 /errorReport:prompt /Taasm.asm”已退出,返回代码为 1。
1>
1>生成失败。
1>