Fix some places that could have caused panics, update example assembly in readme

This commit is contained in:
Jef
2019-03-27 12:44:51 +01:00
parent d50f075078
commit 652e2fdeec
4 changed files with 108 additions and 29 deletions

View File

@@ -127,37 +127,32 @@ fib:
ret
```
Whereas Lightbeam produces code with far fewer memory accesses than both (and fewer blocks than FireFox's output):
Whereas Lightbeam produces smaller code with far fewer memory accesses than both (and fewer blocks than FireFox's output):
```asm
fib:
xor eax, eax
cmp esi, 2
setb al
mov ecx, 1
test eax, eax
jne .Lreturn
mov eax, 1
jb .Lreturn
mov eax, 1
.Lloop:
mov rcx, rsi
add ecx, 0xffffffff
push rsi
push rax
push rax
mov rsi, rcx
call 0
add eax, dword ptr [rsp]
mov rcx, qword ptr [rsp + 8]
call fib
add eax, dword ptr [rsp + 8]
mov rcx, qword ptr [rsp + 0x10]
add ecx, 0xfffffffe
xor edx, edx
cmp ecx, 1
seta dl
mov rsi, rcx
add rsp, 0x10
test edx, edx
jne .Lloop
mov rcx, rax
pop rcx
pop rcx
pop rcx
ja .Lloop
.Lreturn:
mov rax, rcx
ret
```