⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swap.asm

📁 想学习汇编语言的
💻 ASM
字号:
TITLE Swap Procedure Example                 (Swap.asm)

; Demonstration of the Swap procedure, using
; PROTO, PROC, and INVOKE.
; Chapter 5 example. Last update: 07/22/01

INCLUDE Irvine32.inc

Swap PROTO,		; procedure prototype
	pValX:PTR DWORD,
	pValY:PTR DWORD

.data
Array  DWORD  10000h,20000h

.code
main PROC
	; Display the array before the exchange:
	mov  esi,OFFSET Array
	mov  ecx,2		; count = 2
	mov  ebx,TYPE Array
	call DumpMem		; dump the array values

	INVOKE Swap,ADDR Array, ADDR [Array+4]

	; Display the array after the exchange:
	call DumpMem

	exit
main ENDP

;-------------------------------------------------------
Swap PROC USES eax esi edi,
	pValX:PTR DWORD,	; pointer to first integer
	pValY:PTR DWORD	; pointer to second integer
;
; Exchange the values of two 32-bit integers
; Returns: nothing
;-------------------------------------------------------
	mov esi,pValX	; get pointers
	mov edi,pValY
	mov eax,[esi]	; get first integer
	xchg eax,[edi]	; exchange with second
	mov [esi],eax	; replace first integer
	ret
Swap ENDP

END main

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -