페이지

2014. 10. 29.

[MASM] 문자열의 역방향 복사

TITLE 문자열 역순구하기

COMMENT ?
인덱스 피연산자를 활용
?

INCLUDE Irvine32.inc


.data
source BYTE "This is the source string",0
target BYTE SIZEOF source DUP(0)

.code
main PROC

 
mov esi, LENGTHOF source -2
mov edi, 0
mov ecx, SIZEOF source

L1:
    mov  al,source[esi]
    mov  target[edi],al
    dec  esi
    inc  edi
loop L1
 
mov esi, OFFSET target-1
mov ebx, 1
mov ecx, SIZEOF target
call DumpMem

mov edx, OFFSET target
call WriteString
call Crlf

exit

main ENDP
END main




-----------------------------------------------------------

TITLE 문자열 역순구하기

COMMENT ?
직접 피연산자를 활용
?

INCLUDE Irvine32.inc


.data
source BYTE "This is the source string",0
target BYTE SIZEOF source DUP(0)

.code
main PROC

mov esi, 0
mov ecx, LENGTHOF source
dec ecx

L1:
    mov al,source[ecx-1]
    mov target[esi],al
    inc esi
loop L1

mov esi,OFFSET target
mov ebx,1
mov ecx,SIZEOF target-1
mov edx,OFFSET target
call DumpMem
call writeString
call Crlf
 exit

main ENDP
END main