; Write at an address passed in register RSI an ASCIIZ string in hexadecimal ; format with a hyphen as a byte delimiter, obtained from a 48-bit MAC-address, ; passed in register RDI. option prologue:none, epilogue:none .code putmacst proc _putmacst proc SHRD RAX,RDI,48 ; Put MAC-address in the highest 6 bytes of RAX MOV RDI,RSI ; Starting buffer address MOV ECX,0AAAH ; Initialise the nibble counter .repeat ROL RAX,4 ; Shift the MAC-address left by 1 nibble AND AL,0FH ; Isolate its highest nibble in AL ADD AL,'0' ; Convert it to ASCII, assuming it's a digit .if (AL > '9') ; But if it's a letter, increase its ASCII-code ADD AL,'A'-'9'-1 .endif STOSB ; Write it into the string updating the address SHR ECX,1 ; An even nibble? .continue .if (!carry?); No, there is one more MOV AL,'-' ; Yes, prepare the delimiter as the next char STOSB ; and write it into the string .until (zero?) ; Not the last nibble? Go to the next one MOV BYTE PTR [RDI-1],CL; Replace the 6th excessive hyphen with a 0 RET _putmacst endp putmacst endp end