Pelles C forum

Assembly language => Assembly discussions => Topic started by: HellOfMice on January 24, 2025, 09:37:22 AM

Title: We have been stolen
Post by: HellOfMice on January 24, 2025, 09:37:22 AM
Going to 64 bits we loose 4/2 registers


Look at:


MOV CH,127 ; No error
MOV DIL,254 ; No Error


MOV AL,CH ; No Error
MOV DL,DIL ; No Error


MOV CH,DIL ; Forbidden !
In this instruction we suppose that REX = 0 so the use of DIL is forbidden


Idem for  AH/SPL CH/BPL DH/SIL & BH/DIL


SPL, BPL, SIL and DIL have a 40h prefix (REX)


AH & SPL have the same opcode except that SPL has a REX prefix


The REX prefix allows to use 64 bits properties


I thought it was funny


A+


Philippe

Title: Re: We have been stolen
Post by: Vortex on January 24, 2025, 11:29:09 AM
Maybe using a third register as a helper?

Code: [Select]
MOV DL,DIL
MOV CH,DL
Title: Re: We have been stolen
Post by: HellOfMice on January 24, 2025, 11:30:33 AM
Yes in 64 bit mode, we have no choice
Title: Re: We have been stolen
Post by: WiiLF23 on February 08, 2025, 11:19:58 PM
Going to 64 bits we loose 4/2 registers


Look at:


MOV CH,127 ; No error
MOV DIL,254 ; No Error


MOV AL,CH ; No Error
MOV DL,DIL ; No Error


MOV CH,DIL ; Forbidden !
In this instruction we suppose that REX = 0 so the use of DIL is forbidden


Idem for  AH/SPL CH/BPL DH/SIL & BH/DIL


SPL, BPL, SIL and DIL have a 40h prefix (REX)


AH & SPL have the same opcode except that SPL has a REX prefix


The REX prefix allows to use 64 bits properties


I thought it was funny


A+


Philippe

This is one of those quirks introduced in x86-64 due to backward compatibility while expanding the register set.