PDA

View Full Version : ریختن متغیر داخل ثبات cx



amir_pro
پنج شنبه 18 آبان 1385, 00:42 صبح
سلام
چه طوری میشه داخل ثبات cx متغیر r را مثلا ریخت؟ با توجه به اینکه cx 2 بایتی است و r 1 بایتی است
با تشکر

saalek
پنج شنبه 18 آبان 1385, 12:25 عصر
با سلام.
یک بایتی را باید در ch یا cl ریخت.نمیشه در دوبایتی ریخت.
.

amir_pro
پنج شنبه 18 آبان 1385, 14:17 عصر
ممنون از پاسخ
ولی مطمئنم که میشه فقط راهشا بلد نیستم حرف شما برای 8086 درسته تا 286 یا 386 ولی بعد از اون movzx movsx اومدند ولی نمیتونم از اونا استفاده کنم

Developer Programmer
پنج شنبه 18 آبان 1385, 16:46 عصر
You cannot put a different size piece of data into a register than its correct size and you cannot mix different register sizes,

mov eax, cl ; this fails as eax is 32 bit, cl is 8 bit

If you need to put the value in CL into a 32 bit register, you must convert it first using a number of different techniques,

movzx eax, cl ; zero extend unsigned integer

movsx eax, cl ; sign extend signed integer

In some instances you can use,

xor eax, eax ; clear eax
mov al, cl ; copy cl into al

and there are some older mnemonics that will do the conversions,

mov al, cl ; copy cl into al
cbw ; convert BYTE in AL to WORD in AX
cwde ; convert WORD in AX to DWORD in EAX

SMRAH1
چهارشنبه 31 مرداد 1386, 03:21 صبح
یا استفاده از
xor cx,cx
move cl,al