ia-32_volume1_basic-arch

Source operand in the eax register and a destination

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: e ESP register (see Figure 7-4). If the operand-size attribute is 32, the doublewords on the stack are transferred to the registers in the following order: EDI, ESI, EBP, ignore doubleword, EBX, EDX, ECX, and EAX. The ESP register is restored by the action of popping the stack. If the operand-size attribute is 16, the words on the stack are transferred to the registers in the following order: DI, SI, BP, ignore word, BX, DX, CX, and AX. 7-8 Vol. 1 PROGRAMMING WITH GENERAL-PURPOSE INSTRUCTIONS Stack Stack Growth Before Popping Registers 0 31 After Popping Registers 0 31 ESP n n-4 n-8 n - 12 n - 16 n - 20 n - 24 n - 28 n - 32 n - 36 EAX ECX EDX EBX Ignored EBP ESI EDI ESP Figure 7-4. Operation of the POPA Instruction 7.3.1.5 Stack Manipulation Instructions in 64-Bit Mode In 64-bit mode, the stack pointer size is 64 bits and cannot be overridden by an instruction prefix. In implicit stack references, address-size overrides are ignored. Pushes and pops of 32-bit values on the stack are not possible in 64-bit mode. 16-bit pushes and pops are supported by using the 66H operand-size prefix. PUSHA, PUSHAD, POPA, and POPAD are not supported. 7.3.1.6 Type Conversion Instructions The type conversion instructions convert bytes into words, words into doublewords, and doublewords into quadwords. These instructions are especially useful for converting integers to larger integer formats, because they perform sign extension (see Figure 7-5). Two kinds of type conversion instructions are provided: simple conversion and move and convert. Vol. 1 7-9 PROGRAMMING WITH GENERAL-PURPOSE INSTRUCTIONS 15 0 S N N N N N N N N N N N N N N N 31 15 0 Before Sign Extension After Sign Extension S S S S S S S S S S S S S S S S S N N N N N N N N N N N N N N N Figure 7-5. Sign Extension Simple conversion -- The CBW (convert byte to word), CWDE (convert word to doubleword extended), CWD (convert word to doubleword), and CDQ (convert doubleword to quadword) instructions perform sign extension to double the size of the source operand. The CBW instruction copies the sign (bit 7) of the byte in the AL register into every bit position of the upper byte of the AX register. The CWDE instruction copies the sign (bit 15) of the word in the AX register into every bit position of the high word of the EAX register. The CWD instruction copies the sign (bit 15) of the word in the AX register into every bit position in the DX register. The CDQ instruction copies the sign (bit 31) of the doubleword in the EAX register into every bit position in the EDX register. The CWD instruction can be used to produce a doubleword dividend from a word before a word division, and the CDQ instruction can be used to produce a quadword dividend from a doubleword before doubleword division. Move with sign or zero extension -- The MOVSX (move with sign extension) and MOVZX (move with zero extension) instructions move the source operand into a register then perform the sign extension. The MOVSX instruction extends an 8-...
View Full Document

This note was uploaded on 10/01/2013 for the course CPE 103 taught by Professor Watlins during the Winter '11 term at Mississippi State.

Ask a homework question - tutors are online