Author Topic: DI and SI  (Read 1120 times)

buli

  • Regular Member
  • *
  • Posts: 7
DI and SI
« 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? 

nidud

  • Member
  • *****
  • Posts: 1370
    • https://github.com/nidud/asmc
Re: DI and SI
« Reply #1 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.

buli

  • Regular Member
  • *
  • Posts: 7
Re: DI and SI
« Reply #2 on: April 25, 2016, 12:16:38 AM »
Thanks a lot~~
By the way
I begin to suspect that my book is .........