欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

汇编语言实现数组倒序

程序员文章站 2024-02-02 15:46:34
...
.686
.MODEL flat, stdcall
option casemap : none

;//========================================
includelib ucrt.lib
includelib legacy_stdio_definitions.lib
;//========================================

.data
	array dd 1h,2h,3h,4h

.code
 main proc
   pushad

   mov ecx,(lengthof array)/2
   mov esi,0
   mov edi,((lengthof array)-1)

L1:
	MOV EAX,array[esi*4]
	MOV EBX,array[edi*4]

	MOV array[esi*4],EBX
	MOV array[edi*4],EAX

	INC ESI
	DEC EDI
loop L1

   popad
	ret
	
 main endp
 end main

注:LENGTHOF 不是LENGTH