All pastes #738550 Raw Edit

Moddy

public text v1 · immutable
·published 2007-10-16 13:30 UTC
rendered paste body
.486                                           
.model flat, stdcall                           
option casemap :none                         

include \masm32\include\windows.inc       
include \masm32\include\kernel32.inc     
include \masm32\include\masm32.inc       

includelib \masm32\lib\kernel32.lib       
includelib \masm32\lib\masm32.lib         

.data
str1 db "String: ", 0
str2 db "One", 0
str3 db "Two", 0
newline db 13,10,"$"

.data?
strtemp db ?

.code
start:

invoke StdOut, addr str1
invoke StdOut, addr str2
invoke StdOut, addr newline

invoke StdOut, addr str1
invoke StdOut, addr str3
invoke StdOut, addr newline

;Code to swap the strings [We're putting str 2 into strtemp]
cld                          ; sets the direction flag to forward
mov esi, offset str2         ; move the source address in to esi
mov edi, offset strtemp      ; move the destination address in to edi
mov ecx, 3                   ; move the length to copy in to ecx
rep movsb                    ; copy length bytes from esi to edi

;Code to swap the strings [We're putting str3 into str2]
cld                          ; sets the direction flag to forward
mov esi, offset str3         ; move the source address in to esi
mov edi, offset str2         ; move the destination address in to edi
mov ecx, 3                   ; move the length to copy in to ecx
rep movsb                    ; copy length bytes from esi to edi

;Code to swap the strings [We're putting strtemp into str3]
cld                          ; sets the direction flag to forward
mov esi, offset strtemp      ; move the source address in to esi
mov edi, offset str3         ; move the destination address in to edi
mov ecx, 3                   ; move the length to copy in to ecx
rep movsb                    ; copy length bytes from esi to edi

invoke StdOut, addr str1
invoke StdOut, addr str2
invoke StdOut, addr newline

invoke StdOut, addr str1
invoke StdOut, addr str3
invoke StdOut, addr newline

invoke ExitProcess, 0                                   

end start