一、逆转字符串
逆转一个字符串可以利用栈这个数据结果,顺次读取所有元素压栈,再出栈所有元素即可逆序
二、push和pop指令
三、pushfd和popfd
四、pushad和popad
五、代码以及结果
1 TITLE String Reverse 2 3 INCLUDE Irvine32.inc 4 includelib Irvine32.lib 5 includelib kernel32.lib 6 includelib user32.lib 7 8 .data 9 aNAme BYTE "Hello,World",0 10 nameSize = ($ - aNAme) - 1 11 12 .code 13 14 main PROC 15 16 mov ecx,nameSize 17 mov esi,0 18 L1: 19 movzx eax,aNAme[esi] 20 push eax 21 inc esi 22 loop L1 23 24 mov esi,0 25 mov ecx,nameSize 26 L2: 27 pop eax 28 mov aNAme[esi],al 29 inc esi 30 loop L2 31 mov edx,OFFSET aNAme 32 call WriteString 33 call Crlf 34 exit 35 36 main endp 37 38 END main
结果: