What do ds:si and es:di mean in assembly?

こ雲淡風輕ζ 提交于 2020-07-18 04:19:19

问题


The movsb (move string, bytes) instruction fetches the byte at address ds:si, stores it at address es:di, and then increments or decrements the si and di registers by one.

I know esi,si and edi,di registers,

but not ds:si and es:di ,

what do they mean?


回答1:


ds:si and es:di mean the segment:offset referred to by the registers in question. This is primarily important when you're working in real mode (where offsets are a maximum of 64K apiece).

In real mode, the segment are offset are combined as segment * 16 + offset.

In protected mode, a segment register holds a "selector". The base address of the memory referred to by the selector isn't directly related to the value of the selector itself -- rather, the selector just acts as an index to look up data in a table. In the usual case, however, this means very little -- most (current) protected mode environments are set up with CS, DS, ES and SS all set up with base addresses of 0 and maximum offsets of 4 Gigabytes, so addressing via DS vs. ES makes no difference.




回答2:


These are 16 bit registers, they are used for operations like LODSB or others that loop trough memory and either apply or copy data. You load an address into es:di or ds:si and set the cx to whatever count of bytes or words you need top copy and call the LODSB LOADSW or whatever. You can even copy from one memory location to another this way using both. See an example here where they copy a string to a serial port: http://vitaly_filatov.tripod.com/ng/asm/asm_000.71.html



来源:https://stackoverflow.com/questions/7961606/what-do-dssi-and-esdi-mean-in-assembly

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