这将会是一篇比较硬核的文章,下面是用来演示的动画组件(其实是个栈机汇编Runtime)
目前可以打开devtool执行以下代码,可以看到一个运行后的寄存器和栈数据,当然这只是Runtime完工,动画组件还没写js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| let code =` push 8 mov eax, 6 mov ebx, 7 add eax, ebx pop ecx push 7 add esp,1 push eax sub eax, ecx` let cutevm = new CuteVM(code) for (; cutevm.reg.EIP < cutevm.code.length;) { cutevm.Next() } console.log(cutevm.reg) console.log(cutevm.stack)
|
这里用到的汇编就是
1 2 3 4 5 6 7 8
| mov eax, 6 mov ebx, 7 add eax, ebx pop ecx push 7 add esp,1 push eax sub eax, ecx
|
a:
push 8
mov eax, 6
mov ebx, 7
add eax, ebx
pop ecx
ret