Noober
Noober

Reputation: 1626

Move Pointers backward in assembly language

I am trying to move file pointers backward relative to the end of the file.This is waht I am doing-

.model tiny
.386
.data
fil1    db      'testing.txt',0
dat1    db      100 dup('$')
dat2    db      100 dup('$')
.code
.startup
        mov     al,02h
        lea     dx,fil1
        mov     ah,3dh
        int     21h



        mov     bx,ax
        mov     al,2    
        mov     cx,0
        mov     dx,-3
        mov     ah,42h
        int     21h



        lea     dx,dat1
        mov     cx,2
        mov     ah,3fh
        int     21h


        lea     dx,dat1
        mov     ah,09h
        int     21h



        mov     ah,3eh
        int     21h
.exit
end

But this is not displaying anything on the console.I dont know where I am going wrong.

Upvotes: 0

Views: 1059

Answers (1)

Michael
Michael

Reputation: 58487

The description of INT 21H / AH=42H says:

CX:DX = (signed) offset from origin of new file position

By setting cx = 0 you're specifying the positive offset 0x0000FFFD (65533) rather than the negative offset -3 (0xFFFFFFFD). You should set cx = 0xFFFF instead (which can also be expressed as cx = -1).

Upvotes: 3

Related Questions