-
Notifications
You must be signed in to change notification settings - Fork 2
/
vmcc_c.cfg
83 lines (67 loc) · 3.95 KB
/
vmcc_c.cfg
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
///////////////////////////////////////////////////////////////////////
// execution functions
set _vm_ex 0
alias _vmx_try "set _cc_func $_vm_ex; toggle _cc_func _vmx_err 0 \"$*\" 99 nop; __cc_dofunc"
alias _vmx_catch "set _cc_func $_vm_ex; toggle _cc_func \"$*\" 0 nop"
alias _vmx_err "set _vm_ex 99; echo ^1Execution error."
alias _vmx_init "set _vm_ex 0; echo $*"
// this needs to be a 2 step process due to the quotes
alias _vmxc "set _cc_new $*; _vmxc2"
alias _vmxc2 "set _cc_obj \"${_cc_obj}; ${_cc_new}\""
alias "_vmx_op+" "add $1 $2"
alias "_vmx_op-" "sub $1 $2"
alias "_vmx_op*" "mul $1 $2"
alias "_vmx_op/" "div $1 $2"
alias printv "_vmx_clear; _vmx_print _vmx_printE ${* asis}"
alias _vmx_printE "echo \"$eax\"; mov eax 0; mov ebx 0"
alias sayv "_vmx_clear; _vmx_print _vmx_sayvE ${* asis}"
alias _vmx_sayvE "say \"$eax\"; mov eax 0; mov ebx 0"
alias cmdv "_vmx_clear; set ecx $1; _vmx_print _vmx_cmdvE ${2- asis}"
alias _vmx_cmdvE "$ecx \"$eax\"; mov eax 0; mov ebx 0; mov ecx 0"
// print to eax:
alias _vmx_clear "set eax \"\""
alias _vmx_print "_vmx_print0 ${* asis} \"<END OF PRINT>\""
alias _vmx_print0 "set _cc_func \"$2\"; toggle _cc_func _vmx_printS \"@\" _vmx_printV \"<END OF PRINT>\" $1; __cc_dofunc ${* asis}"
alias _vmx_printS "set eax \"${eax asis}${2 asis}\"; _vmx_print0 ${1 asis} ${3- asis}"
alias _vmx_printV "movd ebx ${3 asis}; _vmx_printV2 ${1 asis} ${4- asis}"
alias _vmx_printV2 "set eax \"${eax asis}${ebx asis}\"; _vmx_print0 ${* asis}"
///////////////////////////////////////////////////////////////////////
// various commands as compilation commands
// compile:
alias cs "alias _cc_do \"cc ${* asis}\""
alias cs "echo ^1cs not working"
alias ccnew "set _cc_func \"$1\"; toggle _cc_func _ccnew \"$$1\" _ccnew1; __cc_dofunc $1"
alias _ccnew "mov _cc_obj \"\"; set _cc_objname $1"
alias _ccnew1 "echo ^1Usage: ccnew <function name>"
alias cc "mov eax 0; _cc_assign ${* asis} _ _; _cc_link"
alias ccput "_vmxc \"${1}\"; _cc_link"
alias ld "set _cc_func \"$1\"; toggle _cc_func _ld \"$$1\" _ld1; __cc_dofunc $1"
alias _ld "echo \"^3Storing to vmx86_code_$1\"; menu_cmd rpn dbclr _cc_obj dbpush /vmx86_code_$1 dbsave"
alias _ld1 "echo ^1Usage: ld <objectname>"
alias cx "set _cc_func \"$1\"; toggle _cc_func _cx \"$$1\" _cx1; __cc_dofunc ${* asis} \"<VMCC PARAMS END>\""
alias _cx "echo \"^3Executing vmx86_code_$1\"; menu_cmd rpn dbclr /vmx86_code_$1 dbload /_cc_obj dbpop def; _cx2 ${2- asis}"
alias _cx1 "echo ^1Usage: cx <objectname>"
alias _cx2 "_cc_link; _cc_prepcmd ${* asis}; _cc_do"
// also ceate paramX variables
alias _cc_prepcmd "mov paramc 0; _cc_prepcmd1 ${* asis}"
alias _cc_prepcmd1 "set _cc_func \"$1\"; toggle _cc_func _cx4 \"<VMCC PARAMS END>\" _cx5; __cc_dofunc ${* asis}"
alias _cx4 "mov param$paramc $1; inc paramc; _cc_prepcmd1 ${2- asis}"
alias _cx5 " "
set paramc 0
alias _cc_link "alias _cc_do \"$_cc_obj\"; alias $_cc_objname \"$_cc_obj\""
alias xx "_cc_prepcmd ${2- asis} \"<VMCC PARAMS END>\"; $1"
///////////////////////////////////////////////////////////////////////
// Actual compiler code
alias _cc_assign2 "_vmxc \"movd $1 eax\""
alias _cc_opend "_vmxc \"_vmx_op$1 eax $2\""
alias _cc_addopB "_vmxc \"menu_cmd rpn /eax $1 def\"; _cc_addop1 ${2- asis}"
alias _cc_addsub1 "_vmxc \"_vmx_op$1 eax $2\"; _cc_addop1 ${3- asis}"
alias _cc_addsubend "_vmxc \"pushv eax\"; _cc_ifterm $2 _cc_term _cc_mulop ${2- asis}; _cc_addsubend1 $1"
alias _cc_addsubend1 "_vmxc \"pop ebx\"; _vmxc \"menu_cmd rpn /eax ebx eax $1 def\"; _cc_addsubend2"
alias _cc_mulopB "_vmxc \"menu_cmd rpn /eax $1 def\"; _cc_mulop1 ${2- asis}"
alias _cc_muldiv1 "_vmxc \"_vmx_op$1 eax $2\"; _cc_mulop1 ${3- asis}"
alias _cc_muldivend "_vmxc \"pushv eax\"; _cc_ifterm $2 _cc_term _cc_NEXTop ${2- asis}; _cc_muldivend1 $1"
alias _cc_muldivend1 "_vmxc \"pop ebx\"; _vmxc \"menu_cmd rpn /eax ebx eax $1 def\"; _cc_muldivend2"
alias _cc_NEXTop "_vmxc \"menu_cmd rpn /eax $1 def\"; _cc_NEXTop1 ${2- asis}"
cmp ebx 1010
jnz "echo \"^2You can switch to interpreter mode using ^3vmcc_int\""