; Return in register RAX a MAC-address obtained from an ASCIIZ string starting ; at an address in register RDI. The string is in hexadecimal format with a ; punctuation mark as a delimiter between the bytes, e.g. 00-0C-76-1F-C5-EB. option prologue:none, epilogue:none .code getmacst proc _getmacst proc MOV RSI,RDI ; LODSB works with RSI XOR RDX,RDX ; Start from zeros .repeat .for (AH = 0 : : ) ; New byte - start accumulating from 0 LODSB ; Load the next character .break .if (AL < '0') ; Punctuation mark .if (AL > '9') ; Not a digit AND AL,NOT ('a'-'A'); Convert to uppercase .break .if (AL < 'A' || AL > 'F') ; Delimiter SUB AL,'A'-10-'0';Convert from ASCII/step1 .endif SUB AL,'0' ; Convert from ASCII SHL AH,4 ; Make room for the new hex digit OR AH,AL ; and add it to the current value .endfor ; Continue with the next character SHL RDX,8 ; Make room for a new byte in the MAC-address MOV DL,AH ; Write there the current byte from the right .until (AL == 0) ; Continue with the next byte till string ends XCHG RAX,RDX ; Return the MAC-address in RAX RET _getmacst endp getmacst endp end