-
Notifications
You must be signed in to change notification settings - Fork 2
/
vmx86.cfg
114 lines (90 loc) · 3.84 KB
/
vmx86.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
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
// minimal basic x86-like instructions :D
// by Blub\0
// An AOP - "Alias"-Oriented Programming language
set _ver_vmx86 2
// version 2:
// + movd dereferencing mov
// + pushv push a variable
alias nop ""
alias on_z "on_${flag_z}"
alias on_g "on_${flag_g}"
alias on_l "on_${flag_l}"
alias on_tmp "on_${flag_tmp}"
alias on_0 ""
alias on_1 ""
alias son_1 "alias on_0 \"\"; alias on_1 $*"
alias son_0 "alias on_1 \"\"; alias on_0 $*"
alias nop_0 "alias on_0 \"\""
alias nop_1 "alias on_1 \"\""
alias clf "set flag_z 0; set flag_g 0; set flag_l 0; set flag_tmp 0"
alias clft "set flag_z 0; set flag_g 0; set flag_l 0"
clf
alias cmp "menu_cmd rpn /flag_z $1 $2 eq def /flag_l $1 $2 lt def /flag_g $1 $2 gt def"
alias test "menu_cmd rpn /flag_z $1 0 eq def"
alias jz "son_1 \"$1\"; on_z"
alias jnz "son_0 \"$1\"; on_z"
alias jg "son_1 \"$1\"; on_g"
alias jl "son_1 \"$1\"; on_l"
alias jge "menu_cmd rpn /flag_tmp flag_z flag_g max 1 min def; son_1 \"$1\"; on_tmp"
alias jle "menu_cmd rpn /flag_tmp flag_z flag_l max 1 min def; son_1 \"$1\"; on_tmp"
alias setz "set $1 $flag_z"
alias setnz "set $1 $flag_z; toggle $1"
alias setg "set $1 $flag_g"
alias setl "set $1 $flag_l"
alias setge "menu_cmd rpn /$1 flag_z flag_g max 1 min def;"
alias setle "menu_cmd rpn /$1 flag_z flag_l max 1 min def;"
alias cmovz "son_1 \"mov $*\"; on_z"
alias cmovnz "son_0 \"mov $*\"; on_z"
alias cmovg "son_1 \"mov $*\"; on_g"
alias cmovl "son_1 \"mov $*\"; on_l"
alias cmovge "son_1 \"mov $*\"; menu_cmd rpn /flag_tmp flag_z flag_g max 1 min def; on_tmp"
alias cmovle "son_1 \"mov $*\"; menu_cmd rpn /flag_tmp flag_z flag_l max 1 min def; on_tmp"
alias inc "menu_cmd rpn /$1 $1 1 add def; test $1"
alias dec "menu_cmd rpn /$1 $1 1 sub def; test $1"
alias add "menu_cmd rpn /$1 $1 $2 add def; test $1"
alias sub "menu_cmd rpn /$1 $1 $2 sub def; test $1"
alias mul "menu_cmd rpn /$1 $1 $2 mul def; test $1"
alias div "menu_cmd rpn /$1 $1 $2 div def; test $1"
alias mov "set $1 \"$2\""
alias movd "set $1 \"${$2}\""
set eax 0
set ecx 0
set edx 0
set ebx 0
// esi and edi are used by vmx aliases!
set esi 0
set edi 0
// now a helper variable, whatever was poped off last using popz
set stack ""
alias push "menu_cmd rpn /$1 dbpush"
alias popz "menu_cmd rpn /stack dbpop def"
alias pop "menu_cmd rpn /$1 dbpop def"
alias pushv "menu_cmd rpn $1 dbpush"
alias writestack "menu_cmd rpn /$1 dbsave"
alias loadstack "menu_cmd rpn /$1 dbload"
alias newstack "menu_cmd rpn dbclr"
alias _vmx_xesi "$esi ${* asis}"
// pushvn A B C D E ... -> pushv A, pushv B, pushv C, ...
alias pushvn "_vmx_pushvn ${* asis} \"<END OF PUSH>\""
alias _vmx_pushvn "set esi \"$1\"; toggle esi _vmx_pushvn1 \"<END OF PUSH>\" _vmx_pushvnE; _vmx_xesi ${* asis}"
alias _vmx_pushvn1 "pushv ${1 asis}; _vmx_pushvn ${2- asis}"
alias _vmx_pushvnE nop
// popvnr A B C D E -> pop A, pop B, pop C, ...
alias popvn "_vmx_popvn ${* asis} \"<END OF POP>\""
alias _vmx_popvn "set esi \"$1\"; toggle esi _vmx_popvn1 \"<END OF POP>\" _vmx_popvnE; _vmx_xesi ${* asis}"
alias _vmx_popvn1 "pop ${1 asis}; _vmx_popvn ${2- asis}"
alias _vmx_popvnE nop
// popvn A B C D E ... -> ... pop E, pop D, pop C, pop B, pop A
alias popvnr "_vmx_popvnr ${* asis} \"<END OF POP>\""
alias _vmx_popvnr "set esi \"$1\"; toggle esi _vmx_popvnr1 \"<END OF POP>\" _vmx_popvnrE; _vmx_xesi ${* asis}"
alias _vmx_popvnr1 "_vmx_popvnr ${2- asis}; pop ${1 asis}"
alias _vmx_popvnrE nop
// instructions which need 2 "CPU cycles" minimum :P
alias _loop "_loop_do; dec ecx; cmp ecx 0; jg _loop"
alias loop "alias _loop_do \"$1\"; dec ecx; cmp ecx 0; jg _loop"
alias _loopnz_1 "test _loop_cond; jz _loopnz"
alias _loopnz "_loop_do; setnz _loop_cond; dec ecx; jnz _loopnz_1"
alias loopnz "alias _loop_do \"$1\"; dec ecx; jnz _loopnz"
alias _loopz_1 "test _loop_cond; jz _loopz"
alias _loopz "_loop_do; setz _loop_cond; dec ecx; jnz _loopz_1"
alias loopz "alias _loop_do \"$1\"; dec ecx; jnz _loopz"