Tabs to spaces

This commit is contained in:
Spencer Tipping 2017-03-09 19:50:37 -07:00
parent a79ecb4653
commit b54aa9ed0c
1 changed files with 77 additions and 77 deletions

154
README.md
View File

@ -182,101 +182,101 @@ code is a little circuitous):
```s ```s
interpret: interpret:
pushq %rbp pushq %rbp
movq %rsp, %rbp // standard x86-64 function header movq %rsp, %rbp // standard x86-64 function header
subq $48, %rsp // allocate space for local variables subq $48, %rsp // allocate space for local variables
movq %rdi, -40(%rbp) // callee saves %rsi and %rdi movq %rdi, -40(%rbp) // callee saves %rsi and %rdi
movq %rsi, -48(%rbp) movq %rsi, -48(%rbp)
jmp for_loop_condition jmp for_loop_condition
for_loop_body: for_loop_body:
<a bunch of stuff> <a bunch of stuff>
cmpl $43, %eax // case '+' cmpl $43, %eax // case '+'
je add_branch je add_branch
cmpl $61, %eax // case '=' cmpl $61, %eax // case '='
je assign_branch je assign_branch
cmpl $42, %eax // case '*' cmpl $42, %eax // case '*'
je mult_branch je mult_branch
jmp switch_default // default jmp switch_default // default
assign_branch: assign_branch:
// the "bunch of stuff" above calculated *src and *dst, which are // the "bunch of stuff" above calculated *src and *dst, which are
// stored in -24(%rbp) and -32(%rbp). // stored in -24(%rbp) and -32(%rbp).
movq -24(%rbp), %rax // %rax = src movq -24(%rbp), %rax // %rax = src
movsd (%rax), %xmm0 // %xmm0 = src.r movsd (%rax), %xmm0 // %xmm0 = src.r
movq -32(%rbp), %rax // %rax = dst movq -32(%rbp), %rax // %rax = dst
movsd %xmm0, (%rax) // dst.r = %xmm0 movsd %xmm0, (%rax) // dst.r = %xmm0
movq -24(%rbp), %rax // %rax = src movq -24(%rbp), %rax // %rax = src
movsd 8(%rax), %xmm0 // %xmm0 = src.i movsd 8(%rax), %xmm0 // %xmm0 = src.i
movq -32(%rbp), %rax // %rax = dst movq -32(%rbp), %rax // %rax = dst
movsd %xmm0, 8(%rax) // dst.i = %xmm0 movsd %xmm0, 8(%rax) // dst.i = %xmm0
jmp for_loop_step jmp for_loop_step
add_branch: add_branch:
movq -32(%rbp), %rax // %rax = dst movq -32(%rbp), %rax // %rax = dst
movsd (%rax), %xmm1 // %xmm1 = dst.r movsd (%rax), %xmm1 // %xmm1 = dst.r
movq -24(%rbp), %rax // %rax = src movq -24(%rbp), %rax // %rax = src
movsd (%rax), %xmm0 // %xmm0 = src.r movsd (%rax), %xmm0 // %xmm0 = src.r
addsd %xmm1, %xmm0 // %xmm0 += %xmm1 addsd %xmm1, %xmm0 // %xmm0 += %xmm1
movq -32(%rbp), %rax // %rax = dst movq -32(%rbp), %rax // %rax = dst
movsd %xmm0, (%rax) // dst.r = %xmm0 movsd %xmm0, (%rax) // dst.r = %xmm0
movq -32(%rbp), %rax // same thing for src.i and dst.i movq -32(%rbp), %rax // same thing for src.i and dst.i
movsd 8(%rax), %xmm1 movsd 8(%rax), %xmm1
movq -24(%rbp), %rax movq -24(%rbp), %rax
movsd 8(%rax), %xmm0 movsd 8(%rax), %xmm0
addsd %xmm1, %xmm0 addsd %xmm1, %xmm0
movq -32(%rbp), %rax movq -32(%rbp), %rax
movsd %xmm0, 8(%rax) movsd %xmm0, 8(%rax)
jmp for_loop_step jmp for_loop_step
mult_branch: mult_branch:
movq -32(%rbp), %rax movq -32(%rbp), %rax
movsd (%rax), %xmm1 movsd (%rax), %xmm1
movq -24(%rbp), %rax movq -24(%rbp), %rax
movsd (%rax), %xmm0 movsd (%rax), %xmm0
mulsd %xmm1, %xmm0 mulsd %xmm1, %xmm0
movq -32(%rbp), %rax movq -32(%rbp), %rax
movsd 8(%rax), %xmm2 movsd 8(%rax), %xmm2
movq -24(%rbp), %rax movq -24(%rbp), %rax
movsd 8(%rax), %xmm1 movsd 8(%rax), %xmm1
mulsd %xmm2, %xmm1 mulsd %xmm2, %xmm1
subsd %xmm1, %xmm0 subsd %xmm1, %xmm0
movsd %xmm0, -16(%rbp) // double r = src.r*dst.r - src.i*dst.i movsd %xmm0, -16(%rbp) // double r = src.r*dst.r - src.i*dst.i
movq -32(%rbp), %rax movq -32(%rbp), %rax
movsd (%rax), %xmm1 movsd (%rax), %xmm1
movq -24(%rbp), %rax movq -24(%rbp), %rax
movsd 8(%rax), %xmm0 movsd 8(%rax), %xmm0
mulsd %xmm0, %xmm1 mulsd %xmm0, %xmm1
movq -32(%rbp), %rax movq -32(%rbp), %rax
movsd 8(%rax), %xmm2 movsd 8(%rax), %xmm2
movq -24(%rbp), %rax movq -24(%rbp), %rax
movsd (%rax), %xmm0 movsd (%rax), %xmm0
mulsd %xmm2, %xmm0 mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0 addsd %xmm1, %xmm0
movsd %xmm0, -8(%rbp) // double i = src.r*dst.i + src.i*dst.r movsd %xmm0, -8(%rbp) // double i = src.r*dst.i + src.i*dst.r
movq -32(%rbp), %rax movq -32(%rbp), %rax
movsd -16(%rbp), %xmm0 movsd -16(%rbp), %xmm0
movsd %xmm0, (%rax) // dst.r = r movsd %xmm0, (%rax) // dst.r = r
movq -32(%rbp), %rax movq -32(%rbp), %rax
movsd -8(%rbp), %xmm0 movsd -8(%rbp), %xmm0
movsd %xmm0, 8(%rax) // dst.i = i movsd %xmm0, 8(%rax) // dst.i = i
jmp for_loop_step jmp for_loop_step
for_loop_step: for_loop_step:
addq $3, -48(%rbp) addq $3, -48(%rbp)
for_loop_condition: for_loop_condition:
movq -48(%rbp), %rax movq -48(%rbp), %rax
movzbl (%rax), %eax movzbl (%rax), %eax
testb %al, %al testb %al, %al
jne .L8 jne .L8
nop nop
leave // reset %rsp leave // reset %rsp
ret // pop and jmp ret // pop and jmp
``` ```