Category Archives: MMIX (RISC processor)

MMIX assembly language floating point number preprocessor – GNU Bison and GNU Flex version

Here’s a GNU Bison and GNU Flex version of my MMIX assembly language floating point number preprocessor. The code was developed using GNU Bison version 1.875d and GNU Flex version 2.5.

This version allows for entering more complex expressions of floating point numbers involving addition, subtraction, multiplication and division. Extending the grammar to cover trigonometric functions and square root is left as an exercise to the reader.

* Here are some constants from Don Knuth's world:
MIX			FLOAT	1009	comments are still allowed
MMIX			FLOAT	2009	after the operand field

* Here are some well known constants from the mathematical world:
Pi			FLOAT	3.14159265358979323846	TeX's ultimate version number
e			FLOAT	2.7182818284590452354	ditto for METAFONT

* Here are lists of simple numbers and some irrational numbers:
ListOfNumbers		FLOAT	1,2,3
Expressions		FLOAT	1/3,2/3

* 32-bit floating point numbers are also available.
* But do not use them if you do not need them,
* FLOATs have better properties than SINGLEs.
MIX32			SINGLE	1009
MMIX32			SINGLE	2009
NextMMIX		SINGLE	2009+1000	the next MMIX?

Continue reading MMIX assembly language floating point number preprocessor – GNU Bison and GNU Flex version

MMIX assembly language floating point number preprocessor – initial C version

Here’s the code for a C program I conceived during a rather boring night shift while performing national service some years back. The code was later refined using GNU Bison and GNU Flex for parsing the operand field, yielding the possibility of processing whole expressions involving addition, subtraction, multiplication and division.

Instead of specifying IEEE 754 floating point constants in hexadecimal using the pseudo operators OCTA or TETRA, like this:

* Here are some constants from Don Knuth's world:
MIX			OCTA	#408f880000000000	comments are still allowed
MMIX			OCTA	#409f640000000000	after the operand field

* Here are some well known constants from the mathematical world:
Pi			OCTA	#400921fb54442d18	TeX's ultimate version number
e			OCTA	#4005bf0a8b145769	ditto for METAFONT

* Here is a list of simple numbers:
ListOfNumbers		OCTA	#3ff0000000000000,#4000000000000000,#4008000000000000

* 32-bit floating point numbers are also available.
* But do not use them if you do not need them,
* FLOATs have better properties than SINGLEs.
MIX32			TETRA	#447c4000
MMIX32			TETRA	#44fb2000

you can write these numbers a lot simpler using one of the new pseudo operations FLOAT and SINGLE I made up, like this:

* Here are some constants from Don Knuth's world:
MIX			FLOAT	1009	comments are still allowed
MMIX			FLOAT	2009	after the operand field

* Here are some well known constants from the mathematical world:
Pi			FLOAT	3.14159265358979323846	TeX's ultimate version number
e			FLOAT	2.7182818284590452354	ditto for METAFONT

* Here is a list of simple numbers:
ListOfNumbers		FLOAT	1,2,3

* 32-bit floating point numbers are also available.
* But do not use them if you do not need them,
* FLOATs have better properties than SINGLEs.
MIX32			SINGLE	1009
MMIX32			SINGLE	2009

and preprocess your assembly code with mmixalfpp0 prior to running mmixal. Continue reading MMIX assembly language floating point number preprocessor – initial C version

dec2dms.mms and tri_area.mms

I was looking at some old files and found these files containing MMIX assembly code.

The first file is a program for converting angles from a single value to sexagesimal notation, and back. The second file is a program for calculating the area of a triangle.

I have more MMIX code dating back at least 9 years, and some files are maybe close to 14 years old. I’ll see if I can manage to post those files too. Continue reading dec2dms.mms and tri_area.mms