如何向后写字符?

时间:2013-10-22 19:07:05

标签: assembly x86 masm irvine32

我用汇编语言写了我的名字,我想向后打印。我不知道如何向后写它。

这是我需要向后打印的代码。

TITLE this is a a-to-z program      (backchar.asm)
; Penpa Gyaltsen

INCLUDE Irvine32.inc
.data
space byte ' ',0
myname byte "Penpa Gyaltsen",0
copyofname byte lengthof myname dup(?)

.code
main PROC
        mov eax,0
    mov ecx,lengthof myname
    mov esi,0

backloop:

    mov al,myname[esi]
    mov copyofname[esi],al
    call writechar
    mov edx,offset space
    call writestring
    inc esi
loop backloop;

    call crlf
    exit
main ENDP
END main

1 个答案:

答案 0 :(得分:0)

TITLE this is a a-to-z program      (backchar.asm)
; Penpa Gyaltsen

INCLUDE Irvine32.inc
.data
space byte ' ',0
myname byte "Penpa Gyaltsen",0

.code
main PROC
        mov eax,0
        mov ecx,lengthof myname
        mov esi,lengthof myname
        mov edi,0

backloop:

    mov al,myname[esi]
    call writechar
    mov edx,offset space
    call writestring
    dec esi
loop backloop;

    call crlf
    exit
main ENDP
END main

我得到了答案,但却错过了字符“P”

打印出来像:nestlayg apne