Skip to content

Commit 7c35fc4

Browse files
diseanbinarymaster
authored andcommitted
[VCRUNTIME] Fix string I/O inline asm
Avoid clobbering buffer operands when performing string I/O operations. CORE-20078
1 parent fa3616e commit 7c35fc4

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

sdk/include/vcruntime/mingw32/intrin_x86.h

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,9 +1556,9 @@ __INTRIN_INLINE void __inbytestring(unsigned short Port, unsigned char * Buffer,
15561556
{
15571557
__asm__ __volatile__
15581558
(
1559-
"rep; insb" :
1560-
[Buffer] "=D" (Buffer), [Count] "=c" (Count) :
1561-
"d" (Port), "[Buffer]" (Buffer), "[Count]" (Count) :
1559+
"rep insb" :
1560+
"+D" (Buffer), "+c" (Count) :
1561+
"d" (Port) :
15621562
"memory"
15631563
);
15641564
}
@@ -1567,9 +1567,9 @@ __INTRIN_INLINE void __inwordstring(unsigned short Port, unsigned short * Buffer
15671567
{
15681568
__asm__ __volatile__
15691569
(
1570-
"rep; insw" :
1571-
[Buffer] "=D" (Buffer), [Count] "=c" (Count) :
1572-
"d" (Port), "[Buffer]" (Buffer), "[Count]" (Count) :
1570+
"rep insw" :
1571+
"+D" (Buffer), "+c" (Count) :
1572+
"d" (Port) :
15731573
"memory"
15741574
);
15751575
}
@@ -1578,9 +1578,9 @@ __INTRIN_INLINE void __indwordstring(unsigned short Port, unsigned long * Buffer
15781578
{
15791579
__asm__ __volatile__
15801580
(
1581-
"rep; insl" :
1582-
[Buffer] "=D" (Buffer), [Count] "=c" (Count) :
1583-
"d" (Port), "[Buffer]" (Buffer), "[Count]" (Count) :
1581+
"rep insl" :
1582+
"+D" (Buffer), "+c" (Count) :
1583+
"d" (Port) :
15841584
"memory"
15851585
);
15861586
}
@@ -1602,17 +1602,35 @@ __INTRIN_INLINE void __outdword(unsigned short Port, unsigned long Data)
16021602

16031603
__INTRIN_INLINE void __outbytestring(unsigned short Port, unsigned char * Buffer, unsigned long Count)
16041604
{
1605-
__asm__ __volatile__("rep; outsb" : : [Port] "d" (Port), [Buffer] "S" (Buffer), "c" (Count));
1605+
__asm__ __volatile__
1606+
(
1607+
"rep outsb" :
1608+
"+S" (Buffer), "+c" (Count) :
1609+
"d" (Port) :
1610+
"memory"
1611+
);
16061612
}
16071613

16081614
__INTRIN_INLINE void __outwordstring(unsigned short Port, unsigned short * Buffer, unsigned long Count)
16091615
{
1610-
__asm__ __volatile__("rep; outsw" : : [Port] "d" (Port), [Buffer] "S" (Buffer), "c" (Count));
1616+
__asm__ __volatile__
1617+
(
1618+
"rep outsw" :
1619+
"+S" (Buffer), "+c" (Count) :
1620+
"d" (Port) :
1621+
"memory"
1622+
);
16111623
}
16121624

16131625
__INTRIN_INLINE void __outdwordstring(unsigned short Port, unsigned long * Buffer, unsigned long Count)
16141626
{
1615-
__asm__ __volatile__("rep; outsl" : : [Port] "d" (Port), [Buffer] "S" (Buffer), "c" (Count));
1627+
__asm__ __volatile__
1628+
(
1629+
"rep outsl" :
1630+
"+S" (Buffer), "+c" (Count) :
1631+
"d" (Port) :
1632+
"memory"
1633+
);
16161634
}
16171635

16181636
__INTRIN_INLINE int __cdecl _inp(unsigned short Port)

0 commit comments

Comments
 (0)