- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
what happens to the upper bits of rax in the following instruction.
mov eax, 1;
what about reading from memory?
mov eax, [0x12345678].
is it possible to say something like
mov rax, ecx # sign extend the values of ecx. or pad it with zeros
i am writting a compiler with uses 64 bit pointers but 32 bit integers and i need to interconvert between 32 and 64 bits because its not a statically typed language. any special instructions which can be helpful.
		1 Solution
	
		
			- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
			
				
					
						
					
					
						3.4.1 is volume 1
"When in 64-bit mode, operand size determines the number of valid bits in the destination
general-purpose register:
64-bit operands generate a 64-bit result in the destination general-purpose
register.
32-bit operands generate a 32-bit result, zero-extended to a 64-bit result in the
destination general-purpose register.
8-bit and 16-bit operands generate an 8-bit or 16-bit result. The upper 56 bits or
48 bits (respectively) of the destination general-purpose register are not be
modified by the operation. If the result of an 8-bit or 16-bit operation is intended
for 64-bit address calculation, explicitly sign-extend the register to the full
64-bits."
					
				
			
			
				
			
			
			
				
			
			
			
			
			
		
		
		
	
	
	
"When in 64-bit mode, operand size determines the number of valid bits in the destination
general-purpose register:
64-bit operands generate a 64-bit result in the destination general-purpose
register.
32-bit operands generate a 32-bit result, zero-extended to a 64-bit result in the
destination general-purpose register.
8-bit and 16-bit operands generate an 8-bit or 16-bit result. The upper 56 bits or
48 bits (respectively) of the destination general-purpose register are not be
modified by the operation. If the result of an 8-bit or 16-bit operation is intended
for 64-bit address calculation, explicitly sign-extend the register to the full
64-bits."
Link Copied
		4 Replies
	
		
		
			
			
			
					
	
			- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
			
				
					
					
						
Upper 32 bits of the dst register are zeroed if you use 32 bit variant of the instruction (REX.W = 0 or no REX), mov eax,-1 willcause rax to hold 0x00000000ffffffff.
if you need sign extending 32->64, use movsxd
					
				
			
			
				
			
			
			
			
			
			
			
		
		
		
	
	
	
if you need sign extending 32->64, use movsxd
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
Quoting - neni
 Upper 32 bits of the dst register are zeroed if you use 32 bit variant of the instruction (REX.W = 0 or no REX), mov eax,-1 willcause rax to hold 0x00000000ffffffff.
if you need sign extending 32->64, use movsxd
if you need sign extending 32->64, use movsxd
where can I find this type of information ?
I couldn't find such a definition for MOV and 64 bit register in the Software Developer Manual.
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
			
				
					
						
					
					
						3.4.1 is volume 1
"When in 64-bit mode, operand size determines the number of valid bits in the destination
general-purpose register:
64-bit operands generate a 64-bit result in the destination general-purpose
register.
32-bit operands generate a 32-bit result, zero-extended to a 64-bit result in the
destination general-purpose register.
8-bit and 16-bit operands generate an 8-bit or 16-bit result. The upper 56 bits or
48 bits (respectively) of the destination general-purpose register are not be
modified by the operation. If the result of an 8-bit or 16-bit operation is intended
for 64-bit address calculation, explicitly sign-extend the register to the full
64-bits."
					
				
			
			
				
			
			
			
			
			
			
			
		
		
		
	
	
	
"When in 64-bit mode, operand size determines the number of valid bits in the destination
general-purpose register:
64-bit operands generate a 64-bit result in the destination general-purpose
register.
32-bit operands generate a 32-bit result, zero-extended to a 64-bit result in the
destination general-purpose register.
8-bit and 16-bit operands generate an 8-bit or 16-bit result. The upper 56 bits or
48 bits (respectively) of the destination general-purpose register are not be
modified by the operation. If the result of an 8-bit or 16-bit operation is intended
for 64-bit address calculation, explicitly sign-extend the register to the full
64-bits."
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
			
				
					
					
						Thanks, this is what I was looking for !
					
				
			
			
				
			
			
			
			
			
			
			
		
		
		
	
	
	
					
					Reply
					
						
	
		
				
				
				
					
						
					
				
					
				
				
				
				
			
			Topic Options
			
				
					
	
			
		
	- Subscribe to RSS Feed
 - Mark Topic as New
 - Mark Topic as Read
 - Float this Topic for Current User
 - Bookmark
 - Subscribe
 - Printer Friendly Page