implemented spec change: now cell 127 always return 1
This commit is contained in:
@@ -14,8 +14,8 @@ programs and data. The only available data type is a floating point number,
|
|||||||
although some implementations may use fixed point numbers instead.
|
although some implementations may use fixed point numbers instead.
|
||||||
|
|
||||||
Unlike 808UL, mu808 strictly defines support of up to 16384 data cells and
|
Unlike 808UL, mu808 strictly defines support of up to 16384 data cells and
|
||||||
up to 16383 program steps, with the program step 0 being unavailable and the
|
up to 16383 program steps, with the program step 0 being unavailable, the
|
||||||
data cell 0 always returning 0.
|
data cell 0 always returning 0 and the data cell 127 always returning 1.
|
||||||
|
|
||||||
On the machine start, both memory areas are initialized with zeroes and the
|
On the machine start, both memory areas are initialized with zeroes and the
|
||||||
interactive mode is entered which accepts instructions from the platform's
|
interactive mode is entered which accepts instructions from the platform's
|
||||||
@@ -27,7 +27,8 @@ standard input.
|
|||||||
* ability to enter integer commands (positive and negative) into program memory;
|
* ability to enter integer commands (positive and negative) into program memory;
|
||||||
* ability to enter floating (or fixed) point numbers (positive and negative) at
|
* ability to enter floating (or fixed) point numbers (positive and negative) at
|
||||||
program runtime;
|
program runtime;
|
||||||
* immutability of the data address 0 (must always return 0 when accessed).
|
* immutability of the data address 0 (must always return 0 when accessed);
|
||||||
|
* immutability of the data address 127 (must always return 1 when accessed).
|
||||||
|
|
||||||
The following things are implementation-dependent:
|
The following things are implementation-dependent:
|
||||||
|
|
||||||
@@ -191,6 +192,7 @@ The shortcut mnemonics for other operations are as follows:
|
|||||||
* `dca` is a shortcut to `cpy 0` (direct constant assignment)
|
* `dca` is a shortcut to `cpy 0` (direct constant assignment)
|
||||||
* `dva` is a shortcut to `cpy 1` (direct value assignment)
|
* `dva` is a shortcut to `cpy 1` (direct value assignment)
|
||||||
* `iva` is a shortcut to `cpy 2` (indirect value assignment)
|
* `iva` is a shortcut to `cpy 2` (indirect value assignment)
|
||||||
|
* `inc` is a shortcut to `fma 127 127` (increment)
|
||||||
* `mul` is a shortcut to `fma 0` (multiplication)
|
* `mul` is a shortcut to `fma 0` (multiplication)
|
||||||
* `exp` is a shortcut to `nel 0` (natural exponent)
|
* `exp` is a shortcut to `nel 0` (natural exponent)
|
||||||
* `log` is a shortcut to `nel 1` (natural logarithm)
|
* `log` is a shortcut to `nel 1` (natural logarithm)
|
||||||
@@ -475,8 +477,8 @@ to store a constant 1 into some unused location, like 99. You can do this e.g.
|
|||||||
with the `set 1 0 99` operation. Then, let's go with three cases (assuming we
|
with the `set 1 0 99` operation. Then, let's go with three cases (assuming we
|
||||||
have stored 1 into the data memory location 99):
|
have stored 1 into the data memory location 99):
|
||||||
|
|
||||||
1. Incrementing a memory location is as easy as `fma 99 99 [loc]`.
|
1. Incrementing a memory location is as easy as `fma 127 127 [loc]`.
|
||||||
2. Adding two numbers at loc1 and loc2 into loc2: `fma [loc1] 99 [loc2]`.
|
2. Adding two numbers at loc1 and loc2 into loc2: `fma [loc1] 127 [loc2]`.
|
||||||
3. Multiplying two numbers at loc1 and loc2 into loc2: `fma 0 [loc1] [loc2]`.
|
3. Multiplying two numbers at loc1 and loc2 into loc2: `fma 0 [loc1] [loc2]`.
|
||||||
|
|
||||||
The only inconvenience with the FMA operation is that you need to sacrifice one
|
The only inconvenience with the FMA operation is that you need to sacrifice one
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ function ilexec(lno, cmd, x, y, z, halt, data_override, bcheck, i, v1, v2, v3)
|
|||||||
while(halt == 0) {
|
while(halt == 0) {
|
||||||
if(traceflag) printf("PC: %hu INSTR: %hu %hu %hu %hu\n", lno, cmd, x, y, z)
|
if(traceflag) printf("PC: %hu INSTR: %hu %hu %hu %hu\n", lno, cmd, x, y, z)
|
||||||
DMEM[0] = data_override = 0 # force the value at 0 to be always 0
|
DMEM[0] = data_override = 0 # force the value at 0 to be always 0
|
||||||
|
DMEM[127] = 1 # force the value at 127 to always be 1
|
||||||
bcheck = (x < MEMLIMIT) && (y < MEMLIMIT) && (z < MEMLIMIT)
|
bcheck = (x < MEMLIMIT) && (y < MEMLIMIT) && (z < MEMLIMIT)
|
||||||
if(bcheck) {
|
if(bcheck) {
|
||||||
v1 = DMEM[x]; v2 = DMEM[y]; v3 = DMEM[z] # prefetch the memory values
|
v1 = DMEM[x]; v2 = DMEM[y]; v3 = DMEM[z] # prefetch the memory values
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
210 IF IAT=1 THEN 220 ELSE 230
|
210 IF IAT=1 THEN 220 ELSE 230
|
||||||
220 X=INT(V1):Y=INT(V2):Z=INT(V3):IAT=0:GOTO 240
|
220 X=INT(V1):Y=INT(V2):Z=INT(V3):IAT=0:GOTO 240
|
||||||
230 X=A-CMD*10000:Y=INT(B/10000):Z=B-Y*10000
|
230 X=A-CMD*10000:Y=INT(B/10000):Z=B-Y*10000
|
||||||
240 V1,V2,V3,DMEM(0)=0
|
240 V1,V2,V3,DMEM(0)=0:DMEM(127)=1
|
||||||
250 IF CMD=5 THEN DMEM(Z)=X+(Y/10000):GOTO 180
|
250 IF CMD=5 THEN DMEM(Z)=X+(Y/10000):GOTO 180
|
||||||
260 V1=DMEM(X):V2=DMEM(Y):V3=DMEM(Z)
|
260 V1=DMEM(X):V2=DMEM(Y):V3=DMEM(Z)
|
||||||
270 IF CMD=1 THEN 280 ELSE 420
|
270 IF CMD=1 THEN 280 ELSE 420
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ void ilexec(ushort lno, ushort cmd, ushort x, ushort y, ushort z) {
|
|||||||
while(halt == 0) {
|
while(halt == 0) {
|
||||||
if(traceflag) printf("PC: %hu INSTR: %hu %hu %hu %hu" NLC, lno, cmd, x, y, z);
|
if(traceflag) printf("PC: %hu INSTR: %hu %hu %hu %hu" NLC, lno, cmd, x, y, z);
|
||||||
DMEM[0] = data_override = 0; /* force the value at 0 to be always 0 */
|
DMEM[0] = data_override = 0; /* force the value at 0 to be always 0 */
|
||||||
|
DMEM[127] = 1; /* force the value at 127 to always be 1 */
|
||||||
bcheck = (x < MEMLIMIT) && (y < MEMLIMIT) && (z < MEMLIMIT);
|
bcheck = (x < MEMLIMIT) && (y < MEMLIMIT) && (z < MEMLIMIT);
|
||||||
if(bcheck) {
|
if(bcheck) {
|
||||||
v1 = DMEM[x]; v2 = DMEM[y]; v3 = DMEM[z]; /* prefetch the memory values */
|
v1 = DMEM[x]; v2 = DMEM[y]; v3 = DMEM[z]; /* prefetch the memory values */
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ def ilexec(lno:int, cmd:int=0, x:int=0, y:int=0, z:int=0):
|
|||||||
if traceflag:
|
if traceflag:
|
||||||
print(f'PC: {lno} INSTR: {cmd} {x} {y} {z}')
|
print(f'PC: {lno} INSTR: {cmd} {x} {y} {z}')
|
||||||
DMEM[0] = 0.0 # force the value at 0 to always be 0
|
DMEM[0] = 0.0 # force the value at 0 to always be 0
|
||||||
|
DMEM[127] = 1.0 # force the value at 127 to always be 1
|
||||||
data_override = False
|
data_override = False
|
||||||
# perform a boundary check and prefetch the memory values
|
# perform a boundary check and prefetch the memory values
|
||||||
bcheck = True
|
bcheck = True
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ jmpfunc_shorts = {
|
|||||||
'dca': 'cpy 0', # direct constant assignment
|
'dca': 'cpy 0', # direct constant assignment
|
||||||
'dva': 'cpy 1', # direct value assignment
|
'dva': 'cpy 1', # direct value assignment
|
||||||
'iva': 'cpy 2', # indirect value assignment
|
'iva': 'cpy 2', # indirect value assignment
|
||||||
|
'inc': 'fma 127 127', # increment
|
||||||
'mul': 'fma 0', # multiplication
|
'mul': 'fma 0', # multiplication
|
||||||
'exp': 'nel 0', # natural exponent
|
'exp': 'nel 0', # natural exponent
|
||||||
'log': 'nel 1', # natural logarithm
|
'log': 'nel 1', # natural logarithm
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ function createmu808(lineOut, charOut, lineIn) {
|
|||||||
var halt = 0, data_override = 0, bcheck, i, v1, v2, v3
|
var halt = 0, data_override = 0, bcheck, i, v1, v2, v3
|
||||||
while(halt == 0) {
|
while(halt == 0) {
|
||||||
v1 = v2 = v3 = data_override = DMEM[0] = 0 /* force the value at 0 to be always 0 */
|
v1 = v2 = v3 = data_override = DMEM[0] = 0 /* force the value at 0 to be always 0 */
|
||||||
|
DMEM[127] = 1 /* force the value at 127 to be always 1 */
|
||||||
if(lno == 0) halt = 1 /* immediate instruction */
|
if(lno == 0) halt = 1 /* immediate instruction */
|
||||||
if(runlimit > 0 && runcount > runlimit) {
|
if(runlimit > 0 && runcount > runlimit) {
|
||||||
halt = 1
|
halt = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user