Re: [livecode] Hello (& chaos)

From: Ge Wang <gewang_at_CS.Princeton.EDU>
Date: Mon, 13 Sep 2004 19:52:00 -0400

>> The idea is that you can program ChucK virtual instructions
>> directly. In the "Turing Machine" sense, the virtual instructions
>> are identical to native machine code, but have the added benefit of
>> being run in a controllable environment (VM).
>
> ah, all the documentation I'd read looked like a high level scripting
> language
> - I haven't seen the machine instructions.

We haven't documented them yet. =) But here they are:
All ChucK programs are type-checked and emitted into
byte-code consisting of the following, which are really no
different than native machine instructions. At the end, there
is an example of a ChucK program and the corresponding
ChucK VM program.

The VM uses two stacks for each concurrent shred: one for memory
and one as registers. Also note the operations dealing with time.
One the reasons we implemented the VM with such an IS is so we
may later optimize and also replace sections of code at runtime.
Though the interface needs inventing, on-the-fly byte-coding is
very possible in the current VM.


arithmetic
---
Chuck_Instr_Add_int
Chuck_Instr_Inc_int
Chuck_Instr_Dec_int
Chuck_Instr_Complement_int
Chuck_Instr_Mod_int
Chuck_Instr_Minus_int
Chuck_Instr_Times_int
Chuck_Instr_Divide_int
Chuck_Instr_Add_uint
Chuck_Instr_Inc_uint
Chuck_Instr_Dec_uint
Chuck_Instr_Complement_uint
Chuck_Instr_Mod_uint
Chuck_Instr_Minus_uint
Chuck_Instr_Times_uint
Chuck_Instr_Divide_uint
Chuck_Instr_Add_single
Chuck_Instr_Minus_single
Chuck_Instr_Times_single
Chuck_Instr_Divide_single
Chuck_Instr_Mod_single
Chuck_Instr_Add_double
Chuck_Instr_Minus_double
Chuck_Instr_Times_double
Chuck_Instr_Divide_double
Chuck_Instr_Mod_double
Chuck_Instr_Add_dur
Chuck_Instr_Add_dur_time
control:
---
Chuck_Instr_Branch_Lt_int
Chuck_Instr_Branch_Gt_int
Chuck_Instr_Branch_Le_int
Chuck_Instr_Branch_Ge_int
Chuck_Instr_Branch_Eq_int
Chuck_Instr_Branch_Neq_int
Chuck_Instr_Branch_Lt_uint
Chuck_Instr_Branch_Gt_uint
Chuck_Instr_Branch_Le_uint
Chuck_Instr_Branch_Ge_uint
Chuck_Instr_Branch_Eq_uint
Chuck_Instr_Branch_Neq_uint
Chuck_Instr_Branch_Lt_single
Chuck_Instr_Branch_Gt_single
Chuck_Instr_Branch_Le_single
Chuck_Instr_Branch_Ge_single
Chuck_Instr_Branch_Eq_single
Chuck_Instr_Branch_Neq_single
Chuck_Instr_Branch_Lt_double
Chuck_Instr_Branch_Gt_double
Chuck_Instr_Branch_Le_double
Chuck_Instr_Branch_Ge_double
Chuck_Instr_Branch_Eq_double
Chuck_Instr_Branch_Neq_double
compare:
---
Chuck_Instr_Lt_int
Chuck_Instr_Gt_int
Chuck_Instr_Le_int
Chuck_Instr_Ge_int
Chuck_Instr_Eq_int
Chuck_Instr_Neq_int
Chuck_Instr_Not_int
Chuck_Instr_Negate_int
Chuck_Instr_Negate_uint
Chuck_Instr_Negate_single
Chuck_Instr_Negate_double
Chuck_Instr_Lt_uint
Chuck_Instr_Gt_uint
Chuck_Instr_Le_uint
Chuck_Instr_Ge_uint
Chuck_Instr_Eq_uint
Chuck_Instr_Neq_uint
Chuck_Instr_Lt_single
Chuck_Instr_Gt_single
Chuck_Instr_Le_single
Chuck_Instr_Ge_single
Chuck_Instr_Eq_single
Chuck_Instr_Neq_single
Chuck_Instr_Lt_double
Chuck_Instr_Gt_double
Chuck_Instr_Le_double
Chuck_Instr_Ge_double
Chuck_Instr_Eq_double
Chuck_Instr_Neq_double
bitwise | logical
---
Chuck_Instr_Binary_And
Chuck_Instr_Binary_Or
Chuck_Instr_Binary_Xor
Chuck_Instr_Binary_Shift_Right
Chuck_Instr_Binary_Shift_Left
Chuck_Instr_And
Chuck_Instr_Or
Chuck_Instr_Goto
register/memory stack manipulation
---
Chuck_Instr_Reg_Pop_Word
Chuck_Instr_Reg_Pop_Word2
Chuck_Instr_Reg_Pop_Mem
Chuck_Instr_Reg_Pop_Mem2
Chuck_Instr_Reg_Push_Imm
Chuck_Instr_Reg_Push_Imm2
Chuck_Instr_Reg_Push_Now
Chuck_Instr_Reg_Push_Mem
Chuck_Instr_Reg_Push_Mem2
Chuck_Instr_Reg_Push_Deref
Chuck_Instr_Reg_Push_Deref2
Chuck_Instr_Mem_Push_Imm
Chuck_Instr_Mem_Push_Imm2
Chuck_Instr_Mem_Pop_Word
Chuck_Instr_Mem_Pop_Word2
special
---
Chuck_Instr_Nop
Chuck_Instr_EOC
higher level
---
Chuck_Instr_Chuck_Assign
Chuck_Instr_Chuck_Assign2
Chuck_Instr_Chuck_Assign_Deref
Chuck_Instr_Chuck_Assign_Deref2
Chuck_Instr_Chuck_Assign_Object
Chuck_Instr_Chuck_Assign_Object_Deref
Chuck_Instr_Chuck_Assign_Object2
Chuck_Instr_Chuck_Release_Object
func call
---
Chuck_Instr_Func_Call
Chuck_Instr_Func_Call2
Chuck_Instr_Func_Call3
Chuck_Instr_Func_Call0
Chuck_Instr_Func_Return
Chuck_Instr_Spork
more higher level shreduling/io
---
Chuck_Instr_Print_Console
Chuck_Instr_Print_Console2
Chuck_Instr_Time_Advance
Chuck_Instr_Midi_Out
Chuck_Instr_Midi_Out_Go
Chuck_Instr_Midi_In
Chuck_Instr_Midi_In_Go
Chuck_Instr_ADC
Chuck_Instr_DAC
Chuck_Instr_Bunghole
Chuck_Instr_UGen_Link
Chuck_Instr_UGen_UnLink
Chuck_Instr_UGen_Alloc
Chuck_Instr_UGen_DeAlloc
Chuck_Instr_UGen_Ctrl
Chuck_Instr_UGen_CGet
Chuck_Instr_UGen_Ctrl2
Chuck_Instr_UGen_CGet2
Chuck_Instr_UGen_PMsg
Chuck_Instr_UGen_Ctrl_Op
Chuck_Instr_UGen_CGet_Op
Chuck_Instr_UGen_CGet_Gain
Chuck_Instr_UGen_Ctrl_Gain
Chuck_Instr_UGen_CGet_Last
Chuck_Instr_DLL_Load
Chuck_Instr_DLL_Unload
casting
---
Chuck_Instr_Cast_single2int
Chuck_Instr_Cast_int2single
Chuck_Instr_Cast_double2int
Chuck_Instr_Cast_int2double
Chuck_Instr_Cast_single2double
Chuck_Instr_Cast_double2single
example:
---
// connect sine oscillator to d/a convertor
sinosc s => dac;
// infinite time-loop
while(true)
{
     // randomly set a frequency
     std.rand2f( 30.0, 1000.0 ) => s.freq;
     // advance time
     100::ms => now;
}
this becomes:
[chuck]: dumping src/shred 'osc.ck'...
...
'0' 24Chuck_Instr_Mem_Push_Imm( 28 )
'1' 24Chuck_Instr_Reg_Push_Imm( 24 )
'2' 24Chuck_Instr_Reg_Push_Imm( 5350240 )
'3' 22Chuck_Instr_UGen_Alloc(  )
'4' 32Chuck_Instr_Chuck_Assign_Object2(  )
'5' 15Chuck_Instr_DAC(  )
'6' 21Chuck_Instr_UGen_Link(  )
'7' 24Chuck_Instr_Reg_Pop_Word(  )
'8' 24Chuck_Instr_Reg_Push_Imm( 1 )
'9' 24Chuck_Instr_Reg_Push_Imm( 0 )
'10' 26Chuck_Instr_Branch_Eq_uint( 31 )
'11' 25Chuck_Instr_Reg_Push_Imm2( 30.000000 )
'12' 25Chuck_Instr_Reg_Push_Imm2( 1000.000000 )
'13' 24Chuck_Instr_Reg_Push_Imm( 16 )
'14' 24Chuck_Instr_Reg_Push_Imm( 375076 )
'15' 24Chuck_Instr_Reg_Push_Imm( 28 )
'16' 22Chuck_Instr_Func_Call3(  )
'17' 24Chuck_Instr_Reg_Push_Mem( 24 )
'18' 24Chuck_Instr_Reg_Push_Imm( 171168 )
'19' 24Chuck_Instr_Reg_Push_Imm( 171380 )
'20' 22Chuck_Instr_UGen_Ctrl2(  )
'21' 25Chuck_Instr_Reg_Pop_Word2(  )
'22' 24Chuck_Instr_Reg_Push_Imm( 100 )
'23' 27Chuck_Instr_Cast_int2double(  )
'24' 25Chuck_Instr_Reg_Push_Imm2( 44.100000 )
'25' 24Chuck_Instr_Times_double(  )
'26' 24Chuck_Instr_Reg_Push_Now(  )
'27' 24Chuck_Instr_Add_dur_time(  )
'28' 24Chuck_Instr_Time_Advance(  )
'29' 25Chuck_Instr_Reg_Pop_Word2(  )
'30' 16Chuck_Instr_Goto( 8 )
'31' 15Chuck_Instr_EOC(  )
Best,
Ge!
Received on Mon Sep 13 2004 - 23:48:18 BST

This archive was generated by hypermail 2.4.0 : Sun Aug 20 2023 - 16:02:24 BST