使用汇编中的循环反转字符串

时间:2018-09-17 02:57:07

标签: assembly x86 reverse irvine32

我的教授最近给我分配了一个字符串并以相反的方式输出它的任务,他帮助我的班级编写了将代码的每个字符打印在单独的一行上的代码,如下所示:

INCLUDE Irvine32.inc

;// .386
;// .model flat,stdcall
;// .stack 4096
ExitProcess proto,dwExitCode:dword

.data       ;// write your data in this section 
    prompt BYTE "Enter a string", 0ah, 0dh, 0
    text BYTE 101 DUP(?)

.code       ;// write your program here
main proc
    mov edx, OFFSET prompt
    call WriteString        ;prompt for input

    mov edx, OFFSET text    ; setup for text
    mov ecx, 100            ; max characters
    call ReadString

    mov ebx, 0
    mov edx, OFFSET text    ; setup of output
    call StrLength          ; get number of characters
    mov ecx, eax            ; setup the count register
L1:                     
    mov al, text[ebx]       
    call WriteChar          
    call Crlf               
    inc ebx             
    loop L1
main endp
end main

然后他告诉我们操纵代码,以便它以相反的顺序打印字符串,他曾说过一些有关使用间接寻址和递减循环中地址的信息,任何人都可以帮忙详细说明一下,而不是寻找任何人为我做代码,只是一些指导

0 个答案:

没有答案