-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasm_insert.txt
More file actions
456 lines (417 loc) · 14.9 KB
/
Copy pathasm_insert.txt
File metadata and controls
456 lines (417 loc) · 14.9 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
13G0i1laG2f9v$y@0|13Gyy0i0@09G0i14Gyy@0 n9G0i021Gyy@0 d9G0i026Gyy@0 o9G0i127Gyy@0 X9G0i128Gyy@0
1
13G0x9G0P12Gyy@0o9Gi @ X9Gi @ d9Gi @ n9Gi @
6G$x5G0P7G$x5G0p0laGyy@0|5Gyy@0
6Gf>2li0lv$y0PJi <-f-3x0i 7Gf>2li3lv$y0PJi <-f-3x0i 8G$vhy20GpaGyy@0yy@0
input1 -> xxxxxxxxxxxxxxxxxxxxxx
input2 -> xxxxxxxxxxxxxxxxxxxxxx
optput -> xxxxxxxxxxxxxxxxxxxxxx
<- output
13G0i1laG2f9v$y@0|13Gyy0i0@09G0i14Gyy@0 d9G0i026Gyy@0 o9G0i127Gyy@0 X9G0i128Gyy@0
13G0i0laG2f9v$y@0|13Gyy0i1@0913G0i19G0i04Gyy@0 d9G0i126Gyy@0 o9G0i127Gyy@0 X9G0i028Gyy@0
15GddO1x128p16GddO9G0vey16GP0ea1kr016G0f1kvy9G$p2G12G
0
--------------------------------------------------------------------------------------------------------------------------
[vim-vm fast start]
127Gyy@0 to generate d to b, 135Gyy@0 to run test program(takes about 1 min to end), jump to G100 for more usage
[alu manual(just an archive ,you dont need this)] 21 for NOT(input 2), 26 for AND, 27 for OR, 28 for XOR
04 for plusing, 23 for minus, 25 for +1, 22 for <<, 29 for arithmetic >>, 30 for logic >> (last 3 input 2)
--------------------------------------------------------------------------------------------------------------------------
7G$x22G0PaGfnlv$y@0|yy@0
7G$vF llx9G0P0xf i00i 12Gyy@0
3G$i9Gvf hx7G$a3p12G8f1xa5fGayy@025G0i9Gf x9Gvf hx7G$a3p12G3f2i12lxl4x3GvfPd13G0r04Gyy@021Gyy@0
7G$x5G0Pi0laGyy@0|5Gyy@0
11Gf4i2Gf4i210Gf4i21Gf4i27G$x5G0Pi1laGyy@0|5Gyy@0
6G$x22G0P7G$x22G0p0laGfdlv$y@0|yy@0
6G$x22G0P7G$x22G0p0laGfolv$y@0|yy@0
6G$x22G0P7G$x22G0p0laGfXlv$y@0|yy@0
7G$vF llx9G0P0vyPf hx0i 12Gyy@0
7G$vF llx9G0P0i0f hx0i 12Gyy@0
--------------------------------------------------------------------------------------------------------------------------
[ASM_manual] or for 58 add for 54 sub for 56 and for 57 mov for 49 end for 51 out for 52 dmov for 63 dout for 64 jnc for 59 shl for 66 sar for 67 slr for 68 not for 73 xor for 74 malloc for 80 free for 81 store for 82 load for 83 insert for 85
rax for 37 rbx for 38 rcx for 39 rdx for 40 r5 for 41 r6 for 42 r7 for 43 r8 for 44 r9 for 87 r10 for 88 r11 for 89 r12 for 90 r13 for 91 r14 for 92 r15 for 93 r16 for 94 __ for 60 ;; for 60 jmp for 61 cmp for 65 jz for 69 call for 75 ret for 77 push for 78 pop for 79
--------------------------------------------------------------------------------------------------------------------------
49Gyy@0jdiwdjiwjdiwdjiwdjw
--------------------------------------------------------------------------------------------------------------------------
1
2
3
4
5
6
7
8
--------------------------------------------------------------------------------------------------------------------------
G?__ startmAggV29j"ayGV"by47Gyy@0
`Aj0 bmAvey48G0igg/ASM_manual/pa2wvey35GPaGyy@0yy@0yy@0
buffer
`Awvey50G0igg/ASM_manual/pa2wvey35GPaGddOmB`A3wvey`Bp47Gyy@0yy@0yy@0
buffer
G?STDOUT@
`Awvey53G0igg/ASM_manual/pa2wvey35GPaG0veyG?STDOUT$a p47Gyy@0yy@0yy@0
buffer
ggV29j"apGV"bp8G$vbc04`Awvey55G0igg/ASM_manual/pa2wvey35GPaGvey6G$vbpyy@0`A3wvey55G0igg/ASM_manual/pa2wvey35GPaGvey7G$vbp`Awvey55G0igg/ASM_manual/pa2wvey12GA`Awvey55G0igg/ASMM_manual/pa2wvey35GPaGmB9Glvey`Bvep47Gyy@0yy@055Gyy@05Gyy@055Gyy@0yy@0
buffer
ggV29j"apGV"bp8G$vbc23`Awvey55G0igg/ASM_manual/pa2wvey35GPaGvey6G$vbpyy@0`A3wvey55G0igg/ASM_manual/pa2wvey35GPaGvey7G$vbp`Awvey55G0igg/ASM_manual/pa2wvey12GA`Awvey55G0igg/ASMM_manual/pa2wvey35GPaGmB9Glvey`Bvep47Gyy@0yy@055Gyy@05Gyy@055Gyy@0yy@0
ggV29j"ap3Gfdf@cl12Gyy@0GV"bp8G$vbc26`Awvey55G0igg/ASM_manual/pa2wvey35GPaGvey6G$vbpyy@0`A3wvey55G0igg/ASM_manual/pa2wvey35GPaGvey7G$vbp`Awvey55G0igg/ASM_manual/pa2wvey12GA`Awvey55G0igg/ASMM_manual/pa2wvey35GPaGmB9Glvey`Bvep47Gyy@0yy@055Gyy@05Gyy@055Gyy@0yy@0
ggV29j"ap3Gfof@cl12Gyy@0GV"bp8G$vbc27`Awvey55G0igg/ASM_manual/pa2wvey35GPaGvey6G$vbpyy@0`A3wvey55G0igg/ASM_manual/pa2wvey35GPaGvey7G$vbp`Awvey55G0igg/ASM_manual/pa2wvey12GA`Awvey55G0igg/ASMM_manual/pa2wvey35GPaGmB9Glvey`Bvep47Gyy@0yy@055Gyy@05Gyy@055Gyy@0yy@0
9G0vy62G0i6paGyy@0yy@0
47Gyy@0
`Aw vey62G0iG?pleease wrrite aasm beelow heere/__ pamA47Gyy@0yy@0
buffer
`Awvey50G0igg/ASM_manual/pa2wvey35GPaGddOmB`A3wvey50G0iG2k/pa2bvey`Bp47Gyy@0yy@0yy@0yy@0
`Awvey53G0igg/ASM_manual/pa2wvey35GPaG0vey50G0iG2k/pa2wveyG?STDOUT$a p47Gyy@0yy@0yy@0yy@0
ggV29j"apGV"bp8G$vbc23`Awvey55G0igg/ASM_manual/pa2wvey35GPaGvey6G$vbpyy@0`A3wvey55G0igg/ASM_manual/pa2wvey35GPaGvey7G$vbp`Awvey55G0igg/ASM_manual/pa2wvey12GA`Awvey55G0igg/ASMM_manual/pa47Gyy@0yy@055Gyy@05Gyy@055Gyy@0yy@0
ggV29j"apGV"bp8G$vbc22`Awvey55G0igg/ASM_manual/pa2wvey35GPaGvey6G$vbpyy@0`Awvey55G0igg/ASM_manual/pa2wvey35GPaGvey7G$vbp`Awvey55G0igg/ASM_manual/pa2wvey12GA`Awvey55G0igg/ASMM_manual/pa2wvey35GPaGmB9Gvey`Bvep47Gyy@0yy@055Gyy@05Gyy@055Gyy@0yy@0
ggV29j"apGV"bp8G$vbc29`Awvey55G0igg/ASM_manual/pa2wvey35GPaGvey6G$vbpyy@0`Awvey55G0igg/ASM_manual/pa2wvey35GPaGvey7G$vbp`Awvey55G0igg/ASM_manual/pa2wvey12GA`Awvey55G0igg/ASMM_manual/pa2wvey35GPaGmB9Gvey`Bvep47Gyy@0yy@055Gyy@05Gyy@055Gyy@0yy@0
ggV29j"apGV"bp8G$vbc30`Awvey55G0igg/ASM_manual/pa2wvey35GPaGvey6G$vbpyy@0`Awvey55G0igg/ASM_manual/pa2wvey35GPaGvey7G$vbp`Awvey55G0igg/ASM_manual/pa2wvey12GA`Awvey55G0igg/ASMM_manual/pa2wvey35GPaGmB9Gvey`Bvep47Gyy@0yy@055Gyy@05Gyy@055Gyy@0yy@0
9G$vy62G0i7paGyy@0yy@0
`Aw vey72G0iG?pleease wrrite aasm beelow heere/__ pamA47Gyy@0yy@0
47Gyy@0
buffer
ggV29j"ap3G$cl12Gyy@0GV"bp8G$vbc21`Awvey55G0igg/ASM_manual/pa2wvey35GPaGvey6G$vbpyy@0`Awvey55G0igg/ASM_manual/pa2wvey35GPaGvey7G$vbp`Awvey55G0igg/ASM_manual/pa2wvey12GA`Awvey55G0igg/ASMM_manual/pa2wvey35GPaGmB9Gvey`Bvep47Gyy@0yy@055Gyy@05Gyy@055Gyy@0yy@0
ggV29j"ap3GfXf@cl12Gyy@0GV"bp8G$vbc28`Awvey55G0igg/ASM_manual/pa2wvey35GPaGvey6G$vbpyy@0`A3wvey55G0igg/ASM_manual/pa2wvey35GPaGvey7G$vbp`Awvey55G0igg/ASM_manual/pa2wvey12GA`Awvey55G0igg/ASMM_manual/pa2wvey35GPaGmB9Gvey`Bvep47Gyy@0yy@055Gyy@05Gyy@055Gyy@0yy@0
`Awwwvey?STAACK$a,p76Gyy@0
`Aw vey62G0iG?__ start?__ pamA47Gyy@0yy@0
G?STAACK$vbhx62G0iG?pleease wrrite aasm beelow heere/pamA47Gyy@0yy@0
`Awvey50G0Igg/ASM_manual/pa2wvey35GPaGveyG?STAACK$a,p47Gyy@0yy@0yy@0
`Awvey50G0igg/ASM_manual/pa2wvey35GPaGddOmB?STAACK$vbhx`Bp0x47Gyy@0yy@0yy@0
`Awvey50G0Igg/ASM_manual/pa2wvey35GPaGvey50G0iGkk/pawwveoly84G0iG?ASM__usage?HEAAP$vby$pap47Gyy@0yy@0yy@0yy@0yy@0
`Awvey50G0Igg/ASM_manual/pa2wvey35GPaGvey50G0iGkk/pawwveoly84G0iG?ASM__usage?HEAAP0wpawD47Gyy@0yy@0yy@0yy@0yy@0
`Awwvey50G0Igg/ASM_manual/pa2wvey35GPaGvey50G0iGkk/pawwveoly84G0iG?ASM__usage?HEAAP0wpawbmB`Awwwwvey84G0Igg/ASM_manual/pa2wvey35GPaGvey`Bviwp47Gyy@0yy@0yy@0yy@0yy@0yy@0yy@0
`Awvey50G0Igg/ASM_manual/pa2wvey35GPaGmB`Awwwvey50G0igg/ASM_manual/pa2wvey35GPaGvey50G0iGkk/pawwveoly84G0iG?ASM__usage?HEAAP0wpawbyiw`Bviwp47Gyy@0yy@0yy@0yy@0yy@0yy@0yy@0
buffer
`Awvey50G0Igg/ASM_manual/pa2wvey35GPaGvey50G0iGkk/pawwveoly84G0iG?ASM__usage?HEAAP0wpawmB`Awwwv$hy`BPa 47Gyy@0yy@0yy@0yy@0yy@0
--------------------------------------------------------------------------------------------------------------------------
1
2
3
4
5
6
7
8
--------------------------------------------------------------------------------------------------------------------------
STACK
--------------------------------------------------------------------------------------------------------------------------
HEAP
--------------------------------------------------------------------------------------------------------------------------
[ASM_usage]
supported:
or add sub and mov end out dmov dout jnc shl sar slr not xor malloc free store load jmp cmp jz call ret push pop insert rax rbx rcx rdx r5~16 ;;
fast start:
127Gyy@0 to generate d to b, 135Gyy@0 to run test program(takes about 1 min to end)
every action ends with a red error sign from vim, its a design on perpose
if you didnt see the red sign but the program stopped at a wired place, its an error
__<space>word to set flags, and __word to use it,
only support one blank line between codes,
use ;;<space>sentence as comments,
if just comment in line, no space before comments, if after code, code<space>;;<space>comment
only support tabs for indentation,
only support mov register,number,
so if you need mov rax,rbx , you write mov rax,0000 add rax,rbx,
only support add,sub,xor.... register,register,
only support load/save register,register,
we now support decimal now, but you must decide how much digits you need in this program
change counts of zeros in the very front of bit setting area and yy@0 there to generate chart
dmov and dout is supported now for decimal, it will convert d to b and store, so you can dmov and out, its ok
use dmov <register>,d<number> to use dmov
__<space>start and end must be set.
call and ret are supported now, but you must write a unique flage after each call so that program can find way back
use like this: call __aimflag,__uniqueflag
we support heap now, but malloc and free means changing the size of heap
a d to b chart must be generated before using heap
--------------------------------------------------------------------------------------------------------------------------
please set bit width here,
000000000 0veyA GkkkkkpI 0b0A for d0 0v$hyGkkp0lxxxkkyy@0 <- yy@0 here to generate
k$xjjddGkkddOkkkddO?STDDOUT@ <- yy@0 here to clear
--------------------------------------------------------------------------------------------------------------------------
STDOUT
--------------------------------------------------------------------------------------------------------------------------
please write asm below here,
46G$yy@0
kAyou didnt resetyy@0 yy@0 here to run
__ log2
sar r6
out r6
jz __collect
call __log2,__call0002
__ collect
add r8,r7
dout r8
ret
__ countdown
push r6
dmov r7,d1
add r6,r7
cmp r8,r6
jz __popback
call __countdown,call0004
__ popback
pop r6
dout r6
ret
__ start
dmov rbx,d10
malloc rbx
dmov rbx,d10
mov rax,data
store [rbx],rax
dmov rbx,d2
store [rbx],rax
dmov rax,d7
free rax
load rcx,[rbx]
out rcx
__ start
dmov rax,d9
malloc rax
dmov rax,d2
insert rax,one two three four five six seven eight nine ten
dmov rax,d0
dmov r16,d10
__ catheap
dmov r12,d1
add rax,r12
load r9,[rax]
out r9
cmp r16,rax
jz __endl
jmp __catheap
__ endl
mov r6,101010101
push r6
mov r6,rubbish
pop r6
out r6
dmov r6,d0
dmov r8,d8
call __countdown,call0003
mov r6,101010101
mov r8,010101010
dmov r7,d1
or r8,r6
out r8
not r8
out r8
dmov r6,d128
call __log2,__call0001
__ sssss
mov r6,01100
out r6
mov r7,00001
add r7,r6
xor r6,r7
out r6
not r6
out r6
not r6
out r6
not r6
out r6
sar r6
shl r6
out r6
shl r6
shl r6
out r6
sar r6
out r6
slr r6
out r6
dmov rax,d5 ;; store d numbers
dmov rbx,d3 ;; this is comment
cmp rax,rbx
jnc __small
end
__ small
dout rax
dmov rax,d3
cmp rax,rbx
jz __equal
end
__ equal
mov rdx,equal
out rdx
jmp __fbnq
end
sub rax,rbx
end
;; this is comment
cmp rax,rbx
jnc __carry
out rax
dout rbx
__ carry
end
__ fbnq
dmov rax,d1 ;; store d numbers
dmov rbx,d1 ;; this is comment
dmov rcx,d12
mov r5,现在开始计算斐波那契 ;; everything is a string because its vim, a text editer
;; so actually you can just store string into regesters, no one cares if you dont put them in alu
out r5
dout rax
__ loop ;; you can add comment after flags it doesn't matter
dout rax
dmov rdx,d0
add rdx,rax
add rax,rbx
mov rbx,000000000 ;; you can still use bin if you like
add rbx,rdx
mov rdx,000000001
sub rcx,rdx
jnc __loop ;; jump back
end
dmov rbx,d100 ;; this wont be ran, and we dont care
dout rbx
end
please write asm above here,
--------------------------------------------------------------------------------------------------------------------------
Fjjyy@0 F GkkkkkVy?STDDOUTkkp0Iset complete, must be smaller than:A(not included)@ notsb
k0leww0lvwwelyjjj$p$bbbxxxk0I$pakkkb FFlv$hy@0lDyy@0
$1kkkb FFlv$hy@0
13G0i0laG2f9v$y@0|13Gyy0i0@09G0i04Gyy@0 n9G0i121Gyy@0 d9G0i026Gyy@0 o9G0i027Gyy@0 X9G0i028Gyy@0