+;; Takes a string on the stack and replaces it with the decimal number that the
+;; string represents.
+PARSE_NUMBER:
+ dq .start
+.start:
+ pop [.length] ; Length
+ pop rdi ; String pointer
+ mov r8, 0 ; Result
+
+ ;; Add (10^(rcx-1) * parse_char(rdi[length - rcx])) to the accumulated value
+ ;; for each rcx.
+ mov rcx, [.length]
+.loop:
+ ;; First, calcuate 10^(rcx - 1)
+ mov rax, 1
+
+ mov r9, rcx
+ .exp_loop:
+ dec r9
+ jz .break
+ mov rbx, 10
+ mul rbx
+ jmp .exp_loop
+ .break:
+
+ ;; Now, rax = 10^(rcx - 1).
+
+ ;; We need to calulate the value of the character at rdi[length - rcx].
+ mov rbx, rdi
+ add rbx, [.length]
+ sub rbx, rcx
+ movzx rbx, byte [rbx]
+ sub rbx, '0'
+
+ ;; Multiply this value by rax to get (10^(rcx-1) * parse_char(rdi[length - rcx])),
+ ;; then add this to the result.
+ mul rbx
+
+ ;; Add that value to r8
+ add r8, rax
+
+ dec rcx
+ jnz .loop
+
+ push r8
+
+ next
+
+READ_NUMBER:
+ dq docol
+ dq READ_WORD
+ dq PARSE_NUMBER
+ dq EXIT
+