summaryrefslogtreecommitdiff
path: root/5/seat_id.asm
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2020-12-22 01:09:34 +0100
committerBond_009 <bond.009@outlook.com>2020-12-22 01:09:34 +0100
commit9ebb70dd2a57d4b2ac4b53efa644a77b6079fc2c (patch)
treedc872b8838eb6b8c4c930c44418300bef452b6dd /5/seat_id.asm
parent1e0092d454d4243da23d421b35a02a5d80ec9d30 (diff)
Use NASM preprocessor to reduce code duplication
Diffstat (limited to '5/seat_id.asm')
-rw-r--r--5/seat_id.asm59
1 files changed, 19 insertions, 40 deletions
diff --git a/5/seat_id.asm b/5/seat_id.asm
index c9ca8b8..6b927ed 100644
--- a/5/seat_id.asm
+++ b/5/seat_id.asm
@@ -5,44 +5,23 @@ section .data
section .text
seat_id:
- xor eax, eax ; set up return value
- cmp BYTE [rdi], 'B'
- sete al
- shl eax, 1
- xor ecx, ecx
- cmp BYTE [rdi + 1], 'B'
- sete cl
- or eax, ecx
- shl eax, 1
- cmp BYTE [rdi + 2], 'B'
- sete cl
- or eax, ecx
- shl eax, 1
- cmp BYTE [rdi + 3], 'B'
- sete cl
- or eax, ecx
- shl eax, 1
- cmp BYTE [rdi + 4], 'B'
- sete cl
- or eax, ecx
- shl eax, 1
- cmp BYTE [rdi + 5], 'B'
- sete cl
- or eax, ecx
- shl eax, 1
- cmp BYTE [rdi + 6], 'B'
- sete cl
- or eax, ecx
- shl eax, 1
- cmp BYTE [rdi + 7], 'R'
- sete cl
- or eax, ecx
- shl eax, 1
- cmp BYTE [rdi + 8], 'R'
- sete cl
- or eax, ecx
- shl eax, 1
- cmp BYTE [rdi + 9], 'R'
- sete cl
- or eax, ecx
+ xor eax, eax ; set up return value
+ cmp BYTE [rdi], 'B'
+ sete al
+ xor ecx, ecx
+%assign i 1
+%rep 6
+ shl eax, 1
+ cmp BYTE [rdi + i], 'B'
+ sete cl
+ or eax, ecx
+%assign i i+1
+%endrep
+%rep 3
+ shl eax, 1
+ cmp BYTE [rdi + i], 'R'
+ sete cl
+ or eax, ecx
+%assign i i+1
+%endrep
ret