From 24247e1ac6323999b38a721fa258b233dcfaf517 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 2 Dec 2016 00:16:56 -0500 Subject: Day 1 --- day01.asm | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 day01.asm (limited to 'day01.asm') diff --git a/day01.asm b/day01.asm new file mode 100644 index 0000000..725c9b2 --- /dev/null +++ b/day01.asm @@ -0,0 +1,72 @@ +%include "sys.asm" +global _start + +section .bss +input: resb 1 + +section .data +position: + .x: dd 0 + .y: dd 0 +direction: + .x: dd 0 + .y: dd -1 + +section .text +_start: + .loopTurn: + syscall SYS_READ, FD_STDIN, input, 1 + test rax, rax + jz .breakTurn + + cmp byte [input], 'R' + jne .elseLeft + .thenRight: + rol qword [direction], 32 + neg dword [direction.x] + jmp .endLeft + .elseLeft: + neg dword [direction.x] + rol qword [direction], 32 + .endLeft: + + xor r12, r12 + .loopDigit: + syscall SYS_READ, FD_STDIN, input, 1 + test rax, rax + jz .breakDigit + movzx rax, byte [input] + + cmp al, ',' + je .breakDigit + + shl r12, 1 + lea r12, [r12 + r12 * 4 - '0'] + add r12, rax + jmp .loopDigit + .breakDigit: + + syscall SYS_READ, FD_STDIN, input, 1 + + mov eax, r12d + imul eax, [direction.x] + add [position.x], eax + imul r12d, [direction.y] + add [position.y], r12d + jmp .loopTurn + .breakTurn: + + mov eax, [position.x] + sar eax, 31 + mov ecx, eax + xor ecx, [position.x] + sub ecx, eax + + mov eax, [position.y] + sar eax, 31 + mov edx, eax + xor edx, [position.y] + sub edx, eax + + add ecx, edx +syscall SYS_EXIT, rcx -- cgit 1.4.1 cb6c6d42d8e0a9284897c90d6047f8ad8842'/>
path: root/www/text.causal.agency/010-irc-suite.7 (unfollow)
Commit message (Expand)Author
2021-09-08Handle dirty lines in git-commentJune McEnroe
2021-09-08Document and install git-commentJune McEnroe
2021-09-08Add repeat and all options to git-commentJune McEnroe
2021-09-08Add group threshold to git-commentJune McEnroe