Skip to contentSkip to conversation

x86 asm cleanups

PATCH New Brian Gerst 1 participant 1 message May 29, 2001

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86 asm cleanups

This patch replaces several hardcoded .byte sequences with the proper mnemonics or macros. I have tested this patch with the minimum required binutils and current binutils.

Signature · 1 line
						Brian Gerst
arch/i386/boot/video.S +2 -2
diff -urN linux-2.4.5/arch/i386/boot/video.S linux/arch/i386/boot/video.S
@@ -496,7 +496,7 @@
 	jnc	setbad
 	
 	addw	%bx, %bx
-	.word	0xa7ff, spec_inits		# JMP [BX+spec_inits]
+	jmp	*spec_inits(%bx)
 
 setmenu:
 	orb	%al, %al			# 80x25 is an exception
@@ -1008,7 +1008,7 @@
 vesa1:
 # gas version 2.9.1, using BFD version 2.9.1.0.23 buggers the next inst.
 # XXX:	lodsw	%gs:(%si), %ax			# Get next mode in the list
-	.byte	0x65, 0xAD			# %gs seg prefix + lodsw
+	gs; lodsw
 	cmpw	$0xffff, %ax			# End of the table?
 	jz	vesar
 	
arch/i386/math-emu/reg_u_div.S +2 -4
diff -urN linux-2.4.5/arch/i386/math-emu/reg_u_div.S linux/arch/i386/math-emu/reg_u_div.S
@@ -89,10 +89,8 @@
 	movl	REGB,%ebx
 	movl	DEST,%edi
 
-	movw	EXP(%esi),%dx
-	movw	EXP(%ebx),%ax
-	.byte	0x0f,0xbf,0xc0	/* movsx	%ax,%eax */
-	.byte	0x0f,0xbf,0xd2	/* movsx	%dx,%edx */
+	movswl	EXP(%esi),%edx
+	movswl	EXP(%ebx),%eax
 	subl	%eax,%edx
 	addl	EXP_BIAS,%edx
 
drivers/char/random.c +1 -2
diff -urN linux-2.4.5/drivers/char/random.c linux/drivers/char/random.c
@@ -712,8 +712,7 @@
 #if defined (__i386__)
 	if ( test_bit(X86_FEATURE_TSC, &boot_cpu_data.x86_capability) ) {
 		__u32 high;
-		__asm__(".byte 0x0f,0x31"
-			:"=a" (time), "=d" (high));
+		rdtsc(time, high);
 		num ^= high;
 	} else {
 		time = jiffies;
drivers/char/rocket.c +3 -11
diff -urN linux-2.4.5/drivers/char/rocket.c linux/drivers/char/rocket.c
@@ -485,14 +485,10 @@
 	unsigned char CtlMask, AiopMask;
 
 #ifdef TIME_STAT
-	unsigned long low=0, high=0, loop_time;
+	unsigned long loop_time;
 	unsigned long long time_stat_tmp=0, time_stat_tmp2=0;
 
-	__asm__(".byte 0x0f,0x31"
-		:"=a" (low), "=d" (high));
-	time_stat_tmp = high;
-	time_stat_tmp <<= 32;
-	time_stat_tmp += low;
+	rdtscll(time_stat_tmp);
 #endif /* TIME_STAT */
 
 	for (ctrl=0; ctrl < max_board; ctrl++) {
@@ -532,11 +528,7 @@
 		mod_timer(&rocket_timer, jiffies + 1);
 	}
 #ifdef TIME_STAT
-	__asm__(".byte 0x0f,0x31"
-		:"=a" (low), "=d" (high));
-	time_stat_tmp2 = high;
-	time_stat_tmp2 <<= 32;
-	time_stat_tmp2 += low;
+	rdtscll(time_stat_tmp2);
 	time_stat_tmp2 -= time_stat_tmp;
 	time_stat += time_stat_tmp2;
 	if (time_counter == 0) 
drivers/net/hamradio/soundmodem/sm.h +5 -3
diff -urN linux-2.4.5/drivers/net/hamradio/soundmodem/sm.h linux/drivers/net/hamradio/soundmodem/sm.h
@@ -299,6 +299,8 @@
 
 #ifdef __i386__
 
+#include <asm/msr.h>
+
 /*
  * only do 32bit cycle counter arithmetic; we hope we won't overflow.
  * in fact, overflowing modems would require over 2THz CPU clock speeds :-)
@@ -307,10 +309,10 @@
 #define time_exec(var,cmd)                                              \
 ({                                                                      \
 	if (cpu_has_tsc) {                                              \
-		unsigned int cnt1, cnt2, cnt3;                          \
-		__asm__(".byte 0x0f,0x31" : "=a" (cnt1), "=d" (cnt3));  \
+		unsigned int cnt1, cnt2;                                \
+		rdtscl(cnt1);                                           \
 		cmd;                                                    \
-		__asm__(".byte 0x0f,0x31" : "=a" (cnt2), "=d" (cnt3));  \
+		rdtscl(cnt2);                                           \
 		var = cnt2-cnt1;                                        \
 	} else {                                                        \
 		cmd;                                                    \
include/asm-i386/page.h +1 -1
diff -urN linux-2.4.5/include/asm-i386/page.h linux/include/asm-i386/page.h
@@ -88,7 +88,7 @@
  */
 #define BUG() do { \
 	printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
-	__asm__ __volatile__(".byte 0x0f,0x0b"); \
+	__asm__ __volatile__("ud2"); \
 } while (0)
 
 #define PAGE_BUG(page) do { \