Hello,
Some parts of the computer program could benefit from being flexible for example:
If the some parts of the computer could turn itself from 32 bit into 64 bit at runtime that could be very handy, then that code does not have to be re-written or added, it's simply the same code/instructions.
However other parts of the program must remain compatible with todays designs which could require 8 bit, 16 bit, 32 bit data types and instructions.
So the idea is to extend the current intel/amd instruction set with a flexible instruction set encoding it works like this:
The CPU has an extra variable for example called "BitMode".
The BitMode is set to whatever the section of the code needs for example 16 bit, 32 bit, 64 bit.
It might also be pushed onto the stack so that each procedure could actually have it's own BitMode, so that procedures can even call other procedures with mixing things up.
Then the new flexible instruction encoding examine this variable.
The CPU then does the following "underwater":
Let's first give program example:
instruction: SetBitMode, 64 instruction: move register A, register B instruction: add register A, register B instruction: compare register A, register B instruction: jumpifgreater to etc.
Now what the cpu "underwater" does is for each instruction is:
// first move instruction:
if BitMode = 8 then begin mov8bit register A8bit, register B8bit end else if BitMode = 16 then begin mov16bit register A16bit, register B16bit end else if BitMode = 32 then begin mov32bit register A32bit, register B32bit end else if BitMode = 64 then begin mov8bit register A64bit, register B64bit end;
// second add instruction:
if BitMode = 8 then begin add8bit register A8bit, register B8bit end else if BitMode = 16 then begin add16bit register A16bit, register B16bit end else etc
I just had this idea, I didn't try coding it in Delphi (with operator overloading or whatever).
But ofcourse I can already see that if I would code this with existing instruction sets all the if statement could/would (?) Kill performs somewhat...
I might not even be that bad compared to other solutions... but there is still some overhead.... Maybe a lookup table and calls might help who knows ? ;)
For example:
BitMode = 0; // 8 bit BitMode = 1; // 16 bit BitMode = 2; // 32 bit BitMode = 3; // 64 bit;
MovRoutine : array[0..3] of TmovProcedure; // lookup table of procedures.
MovRoutine[BitMode]( A, B ); // calls some mov procedure.. AddRoutine[BitMode]( A, B );
This way all the compares and jumps can be avoided and it's replaced with a table lookup and a single call, and possible some register moves or whatever.
If the number of bit modes increases this might turn out to be faster ? or maybe there are other techniques....
I am hoping that if the CPU implement this flexible instruction set encoding idea, this overhead might be prevented ;)
Thus my and yours flexible computer program parts might execute at pretty much the same speed without any penalities ! and still being able to update to future requirements without even having to recompile ! that would be nice.... just one variable needs to set at runtime which other code can figure out what to do, for example:
If FileSize(SomeFile) > Max32Bit then begin BitMode := 64bit; end;
Something like that... then file handling or whatever can be flexibly coded.
Other benefits are for the compilers the have a generic or flexible integer type:
procedure Example: var A : TflexibleInteger; B : TflexibleInteger; C : TflexibleInteger; begin // whatever... A := B * C; end;
More suited for flexible math me thinks ;) Programmer doesn't have to mess around with different data types... just concentrates on the math where appriorate.
Only one version needed not many ! VERY NICE ! =D
Now I go eat my breakfast ! :)
Bye, Later, Skybuck !