Online Compiler Nasm

%include "io.inc" section .bss let1 resb 1 num1 resb 1 let2 resb 1 num2 resb 1 prob resb 1 section .text global main main: GET_CHAR let1 GET_CHAR num1 GET_CHAR prob GET_CHAR let2 GET_CHAR num2 movzx eax, byte [let1] sub eax, 'A' - 1 movzx ebx, byte [num1] sub ebx, '0' movzx ecx, byte [let2] sub ecx, 'A' - 1 movzx edx, byte [num2] sub edx, '0' sub eax, ecx sub ebx, edx xor ecx, ecx xor edx, edx cdq xor eax, edx sub eax, edx xor edx, edx mov ecx, eax mov eax, ebx cdq xor eax, edx sub eax, edx add eax, ecx PRINT_DEC 4, eax NEWLINE xor eax, eax xor ebx, ebx xor ecx, ecx xor edx, edx ret
1) This code reads two chess coordinates (like A1 B2), converts them to numeric values, calculates the Manhattan distance between the two squares on a chessboard, and prints the result.

2) Hint 1: The `cdq` instruction sign-extends EAX into EDX:EAX - think about how this is used with the XOR/SUB sequence to calculate absolute values.
Hint 2: The Manhattan distance formula is |x₁ - x₂| + |y₁ - y₂| - trace how the code computes the absolute differences for both the letter and number coordinates separately before adding them.