Dinithi De Silva
Dinithi De Silva

Reputation: 1182

Reverse print an array in assembly programming

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?

Upvotes: 1

Views: 3576

Answers (2)

yash44
yash44

Reputation: 11

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

Upvotes: 1

Madusanka
Madusanka

Reputation: 3018

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.

Upvotes: 1

Related Questions