rep stosd 實驗

Home » 組合語言 » 指令 » rep stosd 實驗
2016-07-11 指令, 組合語言 尚無留言

rep stosd reverse 實驗。。。

stosd

include uni.inc ; see unicode subdir of ida for info on unicode

.686p
.mmx
.model flat


; Segment type: Pure code
; Segment permissions: Read/Execute
_text segment para public 'CODE' use32
assume cs:_text
;org 401000h
assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing
db 5 dup(0CCh)



_main_0 proc near
jmp     _main           ; Jump
_main_0 endp

align 10h


; Attributes: bp-based frame

_main proc near

var_48= byte ptr -48h
result= dword ptr -8
i= dword ptr -4

push    ebp
mov     ebp, esp
sub     esp, 48h        ; Integer Subtraction
push    ebx
push    esi
push    edi
lea     edi, [ebp+var_48] ; Load Effective Address
mov     ecx, 12h
mov     eax, 0CCCCCCCCh
rep stosd               ; Store String
mov     [ebp+result], 0
mov     edi, edi
mov     edi, edi
mov     [ebp+i], 0
jmp     short for_loop  ; Jump

jmp_loop:
mov     eax, [ebp+i]
add     eax, 1          ; Add
mov     [ebp+i], eax

for_loop:               ; Compare Two Operands
cmp     [ebp+i], 14h
jge     short end_loop  ; Jump if Greater or Equal (SF=OF)
mov     ecx, [ebp+result]
add     ecx, 2          ; Add
mov     [ebp+result], ecx
jmp     short jmp_loop  ; Jump

end_loop:
mov     eax, [ebp+result]
pop     edi
pop     esi
pop     ebx
add     esp, 48h        ; Add
cmp     ebp, esp        ; Compare Two Operands
call    __chkesp        ; Call Procedure
mov     esp, ebp
pop     ebp
retn                    ; Return Near from Procedure
_main endp

LEAVE A COMMENT

  ⁄  2  =  four

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料