diff options
| author | Bond_009 <bond.009@outlook.com> | 2020-12-21 16:45:46 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2020-12-21 16:45:46 +0100 |
| commit | 48c6bd9e5263b7b3953e48afe6c5928514787a0f (patch) | |
| tree | 4e573cb6ee035ff61b163a43c798df99d8469359 /5 | |
| parent | 764bada19e30aae18287e97a9d7141ac78e1bb36 (diff) | |
Day 5: add assembly version seat_id using SSE3
Diffstat (limited to '5')
| -rw-r--r-- | 5/seat_id_sse3.asm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/5/seat_id_sse3.asm b/5/seat_id_sse3.asm new file mode 100644 index 0000000..40127bf --- /dev/null +++ b/5/seat_id_sse3.asm @@ -0,0 +1,25 @@ +global seat_id_sse3 + +section .data + align 16 + xmm_cmp: db 1, 'RBBBBBBB', 1, 1, 1, 1, 1, 1, 1 + xmm_shuf: db 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 10, 11, 12, 13, 14, 15 + + +section .text + +seat_id_sse3: + xor eax, eax ; set up return value + movq xmm0, qword [rdi] ; load first 8 bytes + pshufb xmm0, [rel xmm_shuf] ; reverse byte order and already shift left once + pcmpeqb xmm0, [rel xmm_cmp] + pmovmskb eax, xmm0 ; store mask in return value + xor ecx, ecx + cmp BYTE [rdi + 8], 'R' + sete cl + or eax, ecx + shl eax, 1 + cmp BYTE [rdi + 9], 'R' + sete cl + or eax, ecx + ret |
