一个小程序的语句错误lds si, adr

popy007 2003-12-04 04:14:41
data1 segment
adr dw 1234h, 5678h, 0abcdh

data1 ends

code segment
assume ds:data1, cs:code

start:


mov ax, data1
mov ds, ax

lds si, adr




code ends

end start


这样写lds si, adr错在哪里阿?编译不过去。望大侠指教。
...全文
174 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
W32API 2003-12-06
  • 打赏
  • 举报
回复
Description:

Loads a far pointer (segment selector and offset) from the second operand (source operand) into a segment register and the first operand (destination operand). The source operand specifies a 48-bit or a 32-bit pointer in memory depending on the current setting of the operand-size attribute (32 bits or 16 bits, respectively). The instruction opcode and the destination operand specify a segment register/general-purpose register pair. The 16-bit segment selector from the source operand is loaded into the segment register specified with the opcode (DS, SS, ES, FS, or GS). The 32-bit or 16-bit offset is loaded into the register specified with the destination operand.

If one of these instructions is executed in protected mode, additional information from the segment descriptor pointed to by the segment selector in the source operand is loaded in the hidden part of the selected segment register.

Also in protected mode, a null selector (values 0000 through 0003) can be loaded into DS, ES, FS, or GS registers without causing a protection exception. (Any subsequent reference to a segment whose corresponding segment register is loaded with a null selector, causes a generalprotection exception (#GP) and no memory reference to the segment occurs.)

回复人: csdsjkk() ( ) 信誉:99 2003-12-04 16:48:00
lds si,dword ptr adr

或者 lds si,[1000] 这个在 debug 测试通过


popy007 2003-12-05
  • 打赏
  • 举报
回复
我学习的汇编教材对于lds指令写道:

LDS DEST, SRC

“SRC一定是存贮器操作数。该指令是把SRC指定的32位地址指针中的

的偏移量部分送入DEST所指定的通用寄存器中,而地址指针中的段

基值部分送入DS中。”

但我看他是把相应的存储器操作数中的第一个字放到DEST中,第二个字

放到DS中,怎么说是“把偏移量部分送入DEST,段基值部分送入DS”

而且在书后的练习中这样写的:

ADDR DW 1234H, 5678H, 0ABCDH
...
LDS SI, ADDR+1

根本就是有语法错误阿~~
popy007 2003-12-05
  • 打赏
  • 举报
回复
但为什么这样写,在汇编的时候没法通过呢?

W32API 2003-12-05
  • 打赏
  • 举报
回复
ADDR DW 1234H, 5678H, 0ABCDH
...
LDS SI, ADDR+1

这个语法没错。
W32API 2003-12-05
  • 打赏
  • 举报
回复
LDS/LES/LFS/LGS/LSS—Load Far Pointer

Opcode Instruction Description
C5 /r LDS r16,m16:16 Load DS:r16 with far pointer from memory
C5 /r LDS r32,m16:32 Load DS:r32 with far pointer from memory
0F B2 /r LSS r16,m16:16 Load SS:r16 with far pointer from memory
0F B2 /r LSS r32,m16:32 Load SS:r32 with far pointer from memory
C4 /r LES r16,m16:16 Load ES:r16 with far pointer from memory
C4 /r LES r32,m16:32 Load ES:r32 with far pointer from memory
0F B4 /r LFS r16,m16:16 Load FS:r16 with far pointer from memory
0F B4 /r LFS r32,m16:32 Load FS:r32 with far pointer from memory
0F B5 /r LGS r16,m16:16 Load GS:r16 with far pointer from memory
0F B5 /r LGS r32,m16:32 Load GS:r32 with far pointer from memory

Operation:

IF ProtectedMode
THEN IF SS is loaded
THEN IF SegementSelector = null
THEN #GP(0);
FI;
ELSE IF Segment selector index is not within descriptor table limits
OR Segment selector RPL ≠ CPL
OR Access rights indicate nonwritable data segment
OR DPL ≠ CPL
THEN #GP(selector);
FI;
ELSE IF Segment marked not present
THEN #SS(selector);
FI;
SS ← SegmentSelector(SRC);
SS ← SegmentDescriptor([SRC]);
ELSE IF DS, ES, FS, or GS is loaded with non-null segment selector
THEN IF Segment selector index is not within descriptor table limits
OR Access rights indicate segment neither data nor readable code segment
OR (Segment is data or nonconforming-code segment
AND both RPL and CPL > DPL)
THEN #GP(selector);
FI;
ELSE IF Segment marked not present
THEN #NP(selector);
FI;
SegmentRegister ← SegmentSelector(SRC) AND RPL;
SegmentRegister ← SegmentDescriptor([SRC]);
ELSE IF DS, ES, FS, or GS is loaded with a null selector:
SegmentRegister ← NullSelector;
SegmentRegister(DescriptorValidBit) ← 0; (*hidden flag; not accessible by software*)
FI;
FI;
IF (Real-Address or Virtual-8086 Mode)
THEN
SegmentRegister ← SegmentSelector(SRC);
FI;
DEST ← Offset(SRC);

Flags Affected
None.
csdsjkk 2003-12-04
  • 打赏
  • 举报
回复
lds si,dword ptr adr

21,458

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧