求助!!数组逆序传送到另一数组
题目:要求在数据段中定义的数组ARY逆序传送到另一数组DEST。 // 要求在数据段中定义的数组ARY逆序传送到另一数组DEST#include <stdio.h>
int main()
{
int i, j = 0, k = 0, ARY = { 0 }, DEST = { 0 };
for (i = 0;i < 10;i++)
{
scanf("%d", &ARY);
j++;
}
k = j - 1;
for (i = 0;i < j;i++)
{
DEST = ARY;
k--;
}
for(i = 0;i < j;i++)
printf("%d ", DEST);
} 风过无痕1989 发表于 2020-12-15 12:12
能用汇编语言表示出来吗 我还可以学 发表于 2020-12-15 12:14
能用汇编语言表示出来吗
#include <stdio.h>
int main()
{
00B051A0push ebp
00B051A1mov ebp,esp
00B051A3sub esp,198h
00B051A9push ebx
00B051AApush esi
00B051ABpush edi
00B051AClea edi,
00B051B2mov ecx,66h
00B051B7mov eax,0CCCCCCCCh
00B051BCrep stos dword ptr es:
00B051BEmov eax,dword ptr
00B051C3xor eax,ebp
00B051C5mov dword ptr ,eax
int i, j = 0, k = 0, ARY = { 0 }, DEST = { 0 };
00B051C8mov dword ptr ,0
00B051CFmov dword ptr ,0
00B051D6mov dword ptr ,0
00B051DDpush 4Ch
00B051DFpush 0
00B051E1lea eax,
00B051E4push eax
00B051E5call _memset (0B010B4h)
00B051EAadd esp,0Ch
00B051EDmov dword ptr ,0
00B051F7push 4Ch
00B051F9push 0
00B051FBlea eax,
00B05201push eax
00B05202call _memset (0B010B4h)
00B05207add esp,0Ch
for (i = 0;i < 10;i++)
00B0520Amov dword ptr ,0
00B05211jmp main+7Ch (0B0521Ch)
00B05213mov eax,dword ptr
00B05216add eax,1
00B05219mov dword ptr ,eax
00B0521Ccmp dword ptr ,0Ah
00B05220jge main+0A2h (0B05242h)
{
scanf("%d", &ARY);
00B05222mov eax,dword ptr
00B05225lea ecx,ARY
00B05229push ecx
00B0522Apush offset string "%d" (0B06BF8h)
00B0522Fcall _scanf (0B013CFh)
00B05234add esp,8
j++;
00B05237mov eax,dword ptr
00B0523Aadd eax,1
00B0523Dmov dword ptr ,eax
}
00B05240jmp main+73h (0B05213h)
k = j - 1;
00B05242mov eax,dword ptr
00B05245sub eax,1
00B05248mov dword ptr ,eax
for (i = 0;i < j;i++)
00B0524Bmov dword ptr ,0
00B05252jmp main+0BDh (0B0525Dh)
00B05254mov eax,dword ptr
00B05257add eax,1
00B0525Amov dword ptr ,eax
00B0525Dmov eax,dword ptr
00B05260cmp eax,dword ptr
00B05263jge main+0E1h (0B05281h)
{
DEST = ARY;
00B05265mov eax,dword ptr
00B05268mov ecx,dword ptr
00B0526Bmov edx,dword ptr ARY
00B0526Fmov dword ptr DEST,edx
k--;
00B05276mov eax,dword ptr
00B05279sub eax,1
00B0527Cmov dword ptr ,eax
}
00B0527Fjmp main+0B4h (0B05254h)
for(i = 0;i < j;i++)
00B05281mov dword ptr ,0
00B05288jmp main+0F3h (0B05293h)
00B0528Amov eax,dword ptr
00B0528Dadd eax,1
00B05290mov dword ptr ,eax
00B05293mov eax,dword ptr
00B05296cmp eax,dword ptr
00B05299jge main+115h (0B052B5h)
printf("%d ", DEST);
00B0529Bmov eax,dword ptr
printf("%d ", DEST);
00B0529Emov ecx,dword ptr DEST
00B052A5push ecx
00B052A6push offset string "%d " (0B06B30h)
00B052ABcall _printf (0B01316h)
00B052B0add esp,8
00B052B3jmp main+0EAh (0B0528Ah)
}
00B052B5xor eax,eax
00B052B7push edx
00B052B8mov ecx,ebp
00B052BApush eax
00B052BBlea edx,ds:
00B052C1call @_RTC_CheckStackVars@8 (0B01253h)
00B052C6pop eax
00B052C7pop edx
00B052C8pop edi
00B052C9pop esi
00B052CApop ebx
00B052CBmov ecx,dword ptr
00B052CExor ecx,ebp
00B052D0call @__security_check_cookie@4 (0B01267h)
00B052D5add esp,198h
00B052DBcmp ebp,esp
00B052DDcall __RTC_CheckEsp (0B0110Eh)
00B052E2mov esp,ebp
00B052E4pop ebp
00B052E5ret
00B052E6xchg ax,ax
00B052E8add al,byte ptr
00B052EAadd byte ptr ,al
00B052EClock push edx
00B052EEmov al,0
00B052F0test bh,bh
00B052F2?? ??
00B052F3call dword ptr
00B052F6add byte ptr ,al
00B052F8or eax,2C00B053h
00B052FD?? ??
00B052FE?? ??
00B052FFcall dword ptr
00B05302add byte ptr ,al
00B05304or byte ptr ,dl
00B05307add byte ptr ,al
00B0530Bpush esp
00B0530Cadd byte ptr ,al
00B0530Fpop ecx
00B05310add ah,cl 风过无痕1989 发表于 2020-12-15 12:47
#include
int main()
大佬你是直接VC转的呀,我其实是想知道X86汇编写的。。 我还可以学 发表于 2020-12-15 13:24
大佬你是直接VC转的呀,我其实是想知道X86汇编写的。。
其实我是看错题了,汇编早就忘记完了,于是就从 VS2015 软件里翻出这段代码,复制给你,你能用就用,不能用,我也没办法 assume ds:data,cs:code
data segment
ARY DW12345,54321,9999,7654,8888,4728,8341,9527,123,32167
DEST DW10 DUP(0)
data ends
code segment
start:
MOV AX,DATA
MOV DS,AX
MOV ES,AX
;传10个数
MOV CX,10
DEC CX
SHL CX,1
;设置源数据地址
LEA SI,ARY
ADD SI,CX
;设置目的数地址
LEA DI,DEST
SHR CX,1
INC CX
_@1:
MOV AX,WORD PTR
MOV WORD PTR ,AX
SUB SI,2
ADD DI,2
LOOP _@1
MOV AX,4C00H
INT 21H
code ends
end start
xieglt 发表于 2020-12-15 13:59
谢谢老哥
页:
[1]