1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
/* $Id: variable.c,v 1.3 2000/07/05 15:20:34 jholder Exp $
* --------------------------------------------------------------------
* see doc/License.txt for License Information
* --------------------------------------------------------------------
*
* File name: $Id: variable.c,v 1.3 2000/07/05 15:20:34 jholder Exp $
*
* Description:
*
* Modification history:
* $Log: variable.c,v $
* Revision 1.3 2000/07/05 15:20:34 jholder
* Updated code to remove warnings.
*
* Revision 1.2 2000/05/25 22:28:56 jholder
* changes routine names to reflect zmachine opcode names per spec 1.0
*
* Revision 1.1.1.1 2000/05/10 14:21:34 jholder
*
* imported
*
*
* --------------------------------------------------------------------
*/
/*
* variable.c
*
* Variable manipulation routines
*
*/
#include "ztypes.h"
/*
* z_load
*
* Load and store a variable value on stack.
*
*/
void z_load( zword_t variable )
{
store_operand( load_variable( variable ) );
} /* load */
/*
* z_push
*
* Push a value onto the stack
*
*/
void z_push( zword_t value )
{
stack[--sp] = value;
} /* push_var */
/*
* z_pull
*
* Pop a variable from the stack.
*
*/
void z_pull( zword_t variable )
{
z_store( variable, stack[sp++] );
} /* pop_var */
/*
* z_inc
*
* Increment a variable.
*
*/
void z_inc( zword_t variable )
{
z_store( variable, (zword_t)(load_variable( variable ) + 1) );
} /* increment */
/*
* z_dec
*
* Decrement a variable.
*
*/
void z_dec( zword_t variable )
{
z_store( variable, (zword_t)(load_variable( variable ) - 1) );
} /* decrement */
/*
* z_inc_chk
*
* Increment a variable and then check its value against a target.
*
*/
void z_inc_chk( zword_t variable, zword_t target )
{
ZINT16 value;
value = ( ZINT16 ) load_variable( variable );
z_store( variable, ++value );
conditional_jump( value > ( ZINT16 ) target );
} /* increment_check */
/*
* z_dec_chk
*
* Decrement a variable and then check its value against a target.
*
*/
void z_dec_chk( zword_t variable, zword_t target )
{
ZINT16 value;
value = ( ZINT16 ) load_variable( variable );
z_store( variable, --value );
conditional_jump( value < ( ZINT16 ) target );
} /* decrement_check */
|