Implemented G instruction

This commit is contained in:
Luxferre
2022-08-11 09:29:05 +03:00
parent 23b39f036a
commit c0ee893f25
2 changed files with 6 additions and 1 deletions
+1
View File
@@ -91,6 +91,7 @@ CR |`( -- )` |In the command mode, output a line break an
`J`|`( rel -- )` |**J**ump: increase or decrease PC according to the relative value (treated as signed, from -32768 to 32767) `J`|`( rel -- )` |**J**ump: increase or decrease PC according to the relative value (treated as signed, from -32768 to 32767)
`I`|`( cond rel -- ) ` |Pop relative value and condition. **I**f the condition value is not zero, `J` to the relative value `I`|`( cond rel -- ) ` |Pop relative value and condition. **I**f the condition value is not zero, `J` to the relative value
`X`|`( -- pc )` |Locate e**X**ecution point: push PC+1 value onto the main stack `X`|`( -- pc )` |Locate e**X**ecution point: push PC+1 value onto the main stack
`G`|`( -- gpd_start )` |Locate **G**PD area start: push its flat offset onto the main stack
`>`|`( a b -- a>b )` |Push 1 onto the stack if the second popped value is greater than the first, 0 otherwise `>`|`( a b -- a>b )` |Push 1 onto the stack if the second popped value is greater than the first, 0 otherwise
`<`|`( a b -- a>b )` |Push 1 onto the stack if the second popped value is less than the first, 0 otherwise `<`|`( a b -- a>b )` |Push 1 onto the stack if the second popped value is less than the first, 0 otherwise
`=`|`( a b -- a==b )` |Push 1 onto the stack if the two popped values are equal, 0 otherwise `=`|`( a b -- a==b )` |Push 1 onto the stack if the two popped values are equal, 0 otherwise
+5 -1
View File
@@ -182,6 +182,7 @@ enum EquiInstructions {
INS_JUMP='J', INS_JUMP='J',
INS_IF='I', INS_IF='I',
INS_EXPOINT='X', /* locate execution point */ INS_EXPOINT='X', /* locate execution point */
INS_GPDSTART='G', /* locate GPD area start */
INS_GT='>', INS_GT='>',
INS_LT='<', INS_LT='<',
INS_EQ='=', INS_EQ='=',
@@ -436,6 +437,9 @@ void equi_main_loop() {
case INS_EXPOINT: /* Locate execution point */ case INS_EXPOINT: /* Locate execution point */
pushMain(ram.pc + 1); pushMain(ram.pc + 1);
break; break;
case INS_GPDSTART: /* Locate GPD area start */
pushMain(ram.gpd_start);
break;
case INS_GT: /* ( a b -- a>b ) */ case INS_GT: /* ( a b -- a>b ) */
pushMain((popMain() < popMain()) ? 1u : 0u); pushMain((popMain() < popMain()) ? 1u : 0u);
break; break;
@@ -536,7 +540,7 @@ int main(int argc, char* argv[]) {
/* Start both execution and input buffering from the start of command buffer (-1 because we use prefix increment) */ /* Start both execution and input buffering from the start of command buffer (-1 because we use prefix increment) */
ram.pc = ram.ibp = 65535U; ram.pc = ram.ibp = 65535U;
printf("Welcome to Equi v" EQUI_VER " by Luxferre, 2022\n\nCLT: 0x%X (%d bytes)\nGPD: 0x%X (%d bytes)\nCommand buffer: 0x%X (%d bytes)\nEqui ready\n\n", printf("Welcome to Equi v" EQUI_VER " by Luxferre, 2022\n\nCLT: 0x%04X (%d bytes)\nGPD: 0x%04X (%d bytes)\nCommand buffer: 0x%04X (%d bytes)\nEqui ready\n\n",
(unsigned int) ((uchar *)&ram.clt - (uchar *)&ram.main_stack), (unsigned int) ((uchar *)&ram.clt - (uchar *)&ram.main_stack),
(unsigned int) ((uchar *)&ram.gpd - (uchar *)&ram.clt), (unsigned int) ((uchar *)&ram.gpd - (uchar *)&ram.clt),
ram.gpd_start, ram.gpd_start,