Reverse print an array in assembly programming

天涯浪子 提交于 2019-12-08 07:58:15

问题


I need to reverse print a string array in assembly language. Following is my code.

proc reverseAr
    mov cl,count
    mov si,offset Ar
    mov si,3
    write2:

        mov dl,Ar[si]
        mov ah,02h
        int 21h
        dec si
    loop write2
ret
endp

But this doesnot give the answer. Can anybody tell me what is the exact meaning of si? Is it not the index of the array position?


回答1:


proc reverseArray
    mov cl,count
    dec cl
    dec si
    printRevArr:
        mov dl,arr[si]
        add dl,48
        mov ah,02h
        int 21h

        dec si

    loop printRevArr

    ret
endp

Do not use mov si,offset Ar .It will reset the array indexes.




回答2:


si means source index register. It can be used as pointer. it is Offset Register syntax will be:

SI Source index : General addressing, source offset in string ops



来源:https://stackoverflow.com/questions/17493133/reverse-print-an-array-in-assembly-programming

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!