#196·blink

Blink executes FDIV as FDIVR and FDIVR as FDIV

Author: alxrmorozovCreated Jun 13, 2025Updated Jun 13, 2025

This test succeeds on real CPU but fails in blink:

asm
#include "test/asm/mac.inc"
.globl	_start
_start:

//	make -j8 o//blink o//test/asm/fdiv.elf
//	o//blink/blinkenlights o//test/asm/fdiv.elf

	.test	"fdiv"
	fld1
	fldz
	fdiv	%st,%st(1)
	fistpq	-8(%rsp)
	fistpq	-8(%rsp)
	cmpq	$0,-8(%rsp)
	.e

	.test	"fdivr"
	fldz
	fld1
	fdivr	%st,%st(1)
	fistpq	-8(%rsp)
	fistpq	-8(%rsp)
	cmpq	$0,-8(%rsp)
	.e

"test succeeded":
	.exit

If I replace fdiv with fdivr and fdivr with fdiv it succeeds in blink. It looks like this is connected with this AT&T assembler feature: https://sourceware.org/binutils/docs/as.html#i386_002dBugs But FSUB and FSUBR work correctly.