Hi guys
I'm busy reading through some assembly code and trying to understand what the opcodes are doing. I ran into opcode C5 with no prefixes which is LDS /r.
The modr/m byte is &H10 (00-010-000), which gives me DX from the reg field (010) and [BX+SI] from the mod (00) and r/m (000) fields.
The intel manual says that the default segment register is SS for effective addresses containing a BP index, and DS for other effective addresses.
I'm having trouble firguring out what the address pointer is supposed to be. Is it DS:[BX+SI]? Cos then that would mean that DS stays the same (or is loaded with the same value again) and DX is loaded with [BX+SI], wouldn't it?
Please help me understand this...
(C5) LDS opcode
Re: (C5) LDS opcode
The manual says:
EDIT: fixed typo
So, if the current op size is 16-bit, it's DS:=OLD_DS:[BX+SI], DX:=OLD_DS:[BX+SI+2]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).
EDIT: fixed typo
Last edited by bluemoon on Mon Aug 27, 2012 7:28 am, edited 3 times in total.
-
- Posts: 3
- Joined: Mon Aug 27, 2012 6:30 am
Re: (C5) LDS opcode
Thanks very much for the response. Still not sure how you got to those values.
By my calculation, the current value for BX would be &H0000 and SI would be &H7E00. The byte code looks like this C5 10 E2 F4. I don't understand where the +2 comes from. Presumably some immediate value? imm8/imm16?
I don't get how that works then either because it doesn't specify any immediate values in the manual ... does it?
EDIT: To give context to the whole endeavour, the source file is a boot sector.
By my calculation, the current value for BX would be &H0000 and SI would be &H7E00. The byte code looks like this C5 10 E2 F4. I don't understand where the +2 comes from. Presumably some immediate value? imm8/imm16?
I don't get how that works then either because it doesn't specify any immediate values in the manual ... does it?
EDIT: To give context to the whole endeavour, the source file is a boot sector.
Re: (C5) LDS opcode
The +2 come from the pointer structure, as defined at IA manual Volume#1, Section 4.3 POINTER DATA TYPES.
Re: (C5) LDS opcode
You should fix again: DX:=OLD_DS:[BX+SI], DS:=OLD_DS:[BX+SI+2].bluemoon wrote:EDIT: fixed typo
Re: (C5) LDS opcode
Thanks for the correction, I haven't use LDS since DOS time.
-
- Posts: 3
- Joined: Mon Aug 27, 2012 6:30 am
Re: (C5) LDS opcode
So then, if BX = 0000 and SI = 7E00, should my values be:
a)
DS = 7E00
DX = 7E02
or
b)
DS = 16-bit value at OLD_DS:[BX+SI+2] = 0000
DX = 16-bit value at OLD_DS:[BX+SI] = 0000
a)
DS = 7E00
DX = 7E02
or
b)
DS = 16-bit value at OLD_DS:[BX+SI+2] = 0000
DX = 16-bit value at OLD_DS:[BX+SI] = 0000
Re: (C5) LDS opcode
I'll just leave it here one more time: ftp://mipt.cc/Opcode.txt