/*---------------------------------------------------------------------------- ChucK Concurrent, On-the-fly Audio Programming Language Compiler and Virtual Machine Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved. http://chuck.stanford.edu/ http://chuck.cs.princeton.edu/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U.S.A.-----------------------------------------------------------------------------*/ //-----------------------------------------------------------------------------// file: chuck_instr.cpp// desc: chuck virtual machine instruction set//// author: Ge Wang (ge@ccrma.stanford.edu | gewang@cs.princeton.edu)// date: Autumn 2002//-----------------------------------------------------------------------------#include "chuck_instr.h"#include "chuck_type.h"#include "chuck_lang.h"#include "chuck_vm.h"#include "chuck_ugen.h"#include "chuck_dl.h"#include "chuck_errmsg.h"#include "chuck_globals.h" // added 1.4.1.0#include "util_math.h"#include "util_string.h" #include <math.h>#include <limits.h>#include <typeinfo>using namespace std; //-----------------------------------------------------------------------------// name: Chuck_Instr()// desc: base class constructor//-----------------------------------------------------------------------------Chuck_Instr::Chuck_Instr(){ // set linepos to 0 so we can tell later whether it has been set properly m_linepos = 0; // default codestr m_codestr = NULL;} //-----------------------------------------------------------------------------// name: name()// desc: ...//-----------------------------------------------------------------------------const char * Chuck_Instr::name() const{#ifndef __CHUNREAL_ENGINE__ return mini_type( typeid(*this).name() );#else // 1.5.0.0 (ge) | #chureal // Unreal Engine seems to disable C++ run time type information return "[chunreal type info disabled]";#endif // #ifndef __CHUNREAL_ENGINE__} //-----------------------------------------------------------------------------// name: set_codestr()// desc: set codestr associated with this instruction// only certain instructions (e.g., start of stmts) have this//-----------------------------------------------------------------------------void Chuck_Instr::set_codestr( const string & str ){ // cleanup SAFE_DELETE( m_codestr ); // allocate m_codestr = new string( str );} //-----------------------------------------------------------------------------// name: set_linepos()// desc: store line position for error messages//-----------------------------------------------------------------------------void Chuck_Instr::set_linepos(t_CKUINT linepos){ m_linepos = linepos;} //-----------------------------------------------------------------------------// name: handle_overflow()// desc: stack overflow//-----------------------------------------------------------------------------static void handle_overflow( Chuck_VM_Shred * shred, Chuck_VM * vm ){ // we have a problem CK_FPRINTF_STDERR( "[chuck](VM): Exception StackOverflow in shred[id=%lu:%s], PC=[%lu]\n", shred->xid, shred->name.c_str(), shred->pc ); // do something! shred->is_running = FALSE; shred->is_done = TRUE;} #pragma mark === Integer Arithmetic === //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Add_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) + val_(sp+1) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_PreInc_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ // t_CKBYTE *& mem_sp = (t_CKBYTE *&)shred->mem->sp; t_CKINT **& reg_sp = (t_CKINT **&)shred->reg->sp; t_CKINT *& the_sp = (t_CKINT *&)shred->reg->sp; // pointer pop_( reg_sp, 1 ); // increment value (**(reg_sp))++; // value on stack push_( the_sp, **(reg_sp) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_PostInc_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ // t_CKBYTE *& mem_sp = (t_CKBYTE *&)shred->mem->sp; t_CKINT **& reg_sp = (t_CKINT **&)shred->reg->sp; t_CKINT *& the_sp = (t_CKINT *&)shred->reg->sp; t_CKINT * ptr; // pointer pop_( reg_sp, 1 ); // copy ptr = *reg_sp; // value on stack push_( the_sp, **(reg_sp) ); // increment value (*(ptr))++;} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_PreDec_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ // t_CKBYTE *& mem_sp = (t_CKBYTE *&)shred->mem->sp; t_CKINT **& reg_sp = (t_CKINT **&)shred->reg->sp; t_CKINT *& the_sp = (t_CKINT *&)shred->reg->sp; // pointer pop_( reg_sp, 1 ); // decrement value (**(reg_sp))--; // value on stack push_( the_sp, **(reg_sp) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_PostDec_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ // t_CKBYTE *& mem_sp = (t_CKBYTE *&)shred->mem->sp; t_CKINT **& reg_sp = (t_CKINT **&)shred->reg->sp; t_CKINT *& the_sp = (t_CKINT *&)shred->reg->sp; t_CKINT * ptr; // pointer pop_( reg_sp, 1 ); // copy ptr = *reg_sp; // value on stack push_( the_sp, **(reg_sp) ); // decrement value (*(ptr))--;} //-----------------------------------------------------------------------------// name: class Chuck_Instr_Dec_int_Addr// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Dec_int_Addr::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ // decrement value (*((t_CKINT *)(m_val)))--;} //-----------------------------------------------------------------------------// name: exexute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Complement_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; (*(sp-1)) = ~(*(sp-1));} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Mod_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) % val_(sp+1) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Mod_int_Reverse::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp+1) % val_(sp) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Minus_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) - val_(sp+1) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Minus_int_Reverse::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp+1) - val_(sp) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Times_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) * val_(sp+1) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Divide_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); if( val_(sp+1) == 0 ) goto div_zero; push_( sp, val_(sp) / val_(sp+1) ); return;div_zero: // we have a problem CK_FPRINTF_STDERR( "[chuck](VM): DivideByZeroException: on line[%lu] in shred[id=%lu:%s]\n", m_linepos, shred->xid, shred->name.c_str()); goto done; done: // do something! shred->is_running = FALSE; shred->is_done = TRUE;} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Divide_int_Reverse::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); if( val_(sp) == 0 ) goto div_zero; push_( sp, val_(sp+1) / val_(sp) ); return;div_zero: // we have a problem CK_FPRINTF_STDERR( "[chuck](VM): DivideByZeroException: on line[%lu] in shred[id=%lu:%s]\n", m_linepos, shred->xid, shred->name.c_str()); goto done; done: // do something! shred->is_running = FALSE; shred->is_done = TRUE;} #pragma mark === Float Arithmetic === //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Add_double::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) + val_(sp+1) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Minus_double::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) - val_(sp+1) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Minus_double_Reverse::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp+1) - val_(sp) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Times_double::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) * val_(sp+1) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Divide_double::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) / val_(sp+1) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Divide_double_Reverse::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp+1) / val_(sp) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Mod_double::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, ::fmod( val_(sp), val_(sp+1) ) );} //-----------------------------------------------------------------------------// name: execute()// desc: ...//-----------------------------------------------------------------------------void Chuck_Instr_Mod_double_Reverse::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ){ t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, ::fmod( val_(sp+1), val_(sp) ) );} Lines 1–500 of 8014. Load more
/*---------------------------------------------------------------------------- ChucK Concurrent, On-the-fly Audio Programming Language Compiler and Virtual Machine Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved. http://chuck.stanford.edu/ http://chuck.cs.princeton.edu/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U.S.A. -----------------------------------------------------------------------------*/ //----------------------------------------------------------------------------- // file: chuck_instr.cpp // desc: chuck virtual machine instruction set // // author: Ge Wang (ge@ccrma.stanford.edu | gewang@cs.princeton.edu) // date: Autumn 2002 //----------------------------------------------------------------------------- #include "chuck_instr.h" #include "chuck_type.h" #include "chuck_lang.h" #include "chuck_vm.h" #include "chuck_ugen.h" #include "chuck_dl.h" #include "chuck_errmsg.h" #include "chuck_globals.h" // added 1.4.1.0 #include "util_math.h" #include "util_string.h" #include <math.h> #include <limits.h> #include <typeinfo> using namespace std; //----------------------------------------------------------------------------- // name: Chuck_Instr() // desc: base class constructor //----------------------------------------------------------------------------- Chuck_Instr::Chuck_Instr() { // set linepos to 0 so we can tell later whether it has been set properly m_linepos = 0; // default codestr m_codestr = NULL; } //----------------------------------------------------------------------------- // name: name() // desc: ... //----------------------------------------------------------------------------- const char * Chuck_Instr::name() const { #ifndef __CHUNREAL_ENGINE__ return mini_type( typeid(*this).name() ); #else // 1.5.0.0 (ge) | #chureal // Unreal Engine seems to disable C++ run time type information return "[chunreal type info disabled]"; #endif // #ifndef __CHUNREAL_ENGINE__ } //----------------------------------------------------------------------------- // name: set_codestr() // desc: set codestr associated with this instruction // only certain instructions (e.g., start of stmts) have this //----------------------------------------------------------------------------- void Chuck_Instr::set_codestr( const string & str ) { // cleanup SAFE_DELETE( m_codestr ); // allocate m_codestr = new string( str ); } //----------------------------------------------------------------------------- // name: set_linepos() // desc: store line position for error messages //----------------------------------------------------------------------------- void Chuck_Instr::set_linepos(t_CKUINT linepos) { m_linepos = linepos; } //----------------------------------------------------------------------------- // name: handle_overflow() // desc: stack overflow //----------------------------------------------------------------------------- static void handle_overflow( Chuck_VM_Shred * shred, Chuck_VM * vm ) { // we have a problem CK_FPRINTF_STDERR( "[chuck](VM): Exception StackOverflow in shred[id=%lu:%s], PC=[%lu]\n", shred->xid, shred->name.c_str(), shred->pc ); // do something! shred->is_running = FALSE; shred->is_done = TRUE; } #pragma mark === Integer Arithmetic === //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Add_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) + val_(sp+1) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_PreInc_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { // t_CKBYTE *& mem_sp = (t_CKBYTE *&)shred->mem->sp; t_CKINT **& reg_sp = (t_CKINT **&)shred->reg->sp; t_CKINT *& the_sp = (t_CKINT *&)shred->reg->sp; // pointer pop_( reg_sp, 1 ); // increment value (**(reg_sp))++; // value on stack push_( the_sp, **(reg_sp) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_PostInc_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { // t_CKBYTE *& mem_sp = (t_CKBYTE *&)shred->mem->sp; t_CKINT **& reg_sp = (t_CKINT **&)shred->reg->sp; t_CKINT *& the_sp = (t_CKINT *&)shred->reg->sp; t_CKINT * ptr; // pointer pop_( reg_sp, 1 ); // copy ptr = *reg_sp; // value on stack push_( the_sp, **(reg_sp) ); // increment value (*(ptr))++; } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_PreDec_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { // t_CKBYTE *& mem_sp = (t_CKBYTE *&)shred->mem->sp; t_CKINT **& reg_sp = (t_CKINT **&)shred->reg->sp; t_CKINT *& the_sp = (t_CKINT *&)shred->reg->sp; // pointer pop_( reg_sp, 1 ); // decrement value (**(reg_sp))--; // value on stack push_( the_sp, **(reg_sp) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_PostDec_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { // t_CKBYTE *& mem_sp = (t_CKBYTE *&)shred->mem->sp; t_CKINT **& reg_sp = (t_CKINT **&)shred->reg->sp; t_CKINT *& the_sp = (t_CKINT *&)shred->reg->sp; t_CKINT * ptr; // pointer pop_( reg_sp, 1 ); // copy ptr = *reg_sp; // value on stack push_( the_sp, **(reg_sp) ); // decrement value (*(ptr))--; } //----------------------------------------------------------------------------- // name: class Chuck_Instr_Dec_int_Addr // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Dec_int_Addr::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { // decrement value (*((t_CKINT *)(m_val)))--; } //----------------------------------------------------------------------------- // name: exexute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Complement_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; (*(sp-1)) = ~(*(sp-1)); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Mod_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) % val_(sp+1) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Mod_int_Reverse::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp+1) % val_(sp) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Minus_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) - val_(sp+1) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Minus_int_Reverse::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp+1) - val_(sp) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Times_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) * val_(sp+1) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Divide_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); if( val_(sp+1) == 0 ) goto div_zero; push_( sp, val_(sp) / val_(sp+1) ); return; div_zero: // we have a problem CK_FPRINTF_STDERR( "[chuck](VM): DivideByZeroException: on line[%lu] in shred[id=%lu:%s]\n", m_linepos, shred->xid, shred->name.c_str()); goto done; done: // do something! shred->is_running = FALSE; shred->is_done = TRUE; } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Divide_int_Reverse::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKINT *& sp = (t_CKINT *&)shred->reg->sp; pop_( sp, 2 ); if( val_(sp) == 0 ) goto div_zero; push_( sp, val_(sp+1) / val_(sp) ); return; div_zero: // we have a problem CK_FPRINTF_STDERR( "[chuck](VM): DivideByZeroException: on line[%lu] in shred[id=%lu:%s]\n", m_linepos, shred->xid, shred->name.c_str()); goto done; done: // do something! shred->is_running = FALSE; shred->is_done = TRUE; } #pragma mark === Float Arithmetic === //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Add_double::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) + val_(sp+1) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Minus_double::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) - val_(sp+1) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Minus_double_Reverse::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp+1) - val_(sp) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Times_double::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) * val_(sp+1) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Divide_double::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp) / val_(sp+1) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Divide_double_Reverse::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, val_(sp+1) / val_(sp) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Mod_double::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, ::fmod( val_(sp), val_(sp+1) ) ); } //----------------------------------------------------------------------------- // name: execute() // desc: ... //----------------------------------------------------------------------------- void Chuck_Instr_Mod_double_Reverse::execute( Chuck_VM * vm, Chuck_VM_Shred * shred ) { t_CKFLOAT *& sp = (t_CKFLOAT *&)shred->reg->sp; pop_( sp, 2 ); push_( sp, ::fmod( val_(sp+1), val_(sp) ) ); }