What does SEG directive do in 8086?

落爺英雄遲暮 提交于 2019-12-31 03:47:53

问题


SEG A :

Assigns the content held in segment register corresponding to the segment in which A resides to the operand.

I guess that means that if A lies in Data Segment, SEG A is the same as DS.

Since DS holds the base address of the Data Segment, does

MOV AX, LEA A
MOV DX, SEG A
MOV AX, [AX + DX]

copy the physical address of A to AX?


回答1:


I guess that means that if A lies in Data Segment, SEG A is the same as DS.

Correct, if DS points to Data Segment.

does
MOV AX, LEA A
MOV DX, SEG A
MOV AX, [AX + DX]
copy the physical address of A to AX?

The last instruction is invalid, it does not exist in any of x86 CPUs. As such, this code does nothing at all. If anything, it just sits in an .asm file waiting to be corrected and assembled.




回答2:


It copies the content of AX + DX address (which is A) to AX.

MOV AX, LEA A ; Copy A offset to AX
MOV DX, SEG A ; Copy A segment to DX
MOV AX, [AX + DX] ; Copy A to AX



回答3:


SEG provides the operand segment. If the variable segment is referenced by no segment register, you can use SEG. But otherwise you should use LEA, LDS. example:

 .data

var db ? .code x db ?

start: ...

for var SEG is DS and for x SEG is CS, their segment addresses.



来源:https://stackoverflow.com/questions/14528646/what-does-seg-directive-do-in-8086

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