The MASM Forum

Miscellaneous => 16 bit DOS Programming => Topic started by: buli on April 24, 2016, 06:50:01 PM

Title: DI and SI
Post by: buli on April 24, 2016, 06:50:01 PM
I am confused that DI and SI can point to the same address
below it's my code
Code: [Select]
.MODEL SMALL
.STACK
.DATA
   NUM1 DB 10,11,12,14
.CODE
MAIN:
    MOV AX,@DATA
    MOV DS,AX
    MOV DI,OFFSET NUM1
    MOV SI,OFFSET NUM1
    MOV DL,[DI]
    ADD DL,30H
    MOV AH,02H
    INT 21H
    MOV DL,[SI]
    ADD DL,30H
    MOV AH,02H
    INT 21H
    MOV AH,4CH
    INT 21H
END MAIN
I used the debug tool and saw that DI and SI are shifted into same address,when i print the content they are same!! But i know that DI belongs to ES and SI belongs to DS. But OFFSET just calculate the variable's offset. Why they can print the same content? 
Title: Re: DI and SI
Post by: nidud on April 24, 2016, 07:47:41 PM
DI only "belongs to ES" on a selective set of string instructions, like SCAS, MOVS, CMPS. Else DI (and SI) will default to @Data.
Title: Re: DI and SI
Post by: buli on April 25, 2016, 12:16:38 AM
Thanks a lot~~
By the way
I begin to suspect that my book is .........