; Write at an address passed in register RSI an ASCIIZ string in decimal format ; without leading zeros and with a dot as a byte delimiter, obtained from an ; IP-address (IPv4), passed in register EDI. option prologue:none, epilogue:none .code putipstr proc _putipstr proc MOV EDX,EDI ; EDX = IP-address MOV RDI,RSI ; RDI = string buffer address MOV ECX,'.' shl 24 or '.' shl 16 or '.' shl 8; 3 delimiters .repeat ROL EDX,8 ; Load next byte (from high to low) XOR EAX,EAX MOV AL,DL ; Byte must be in AX because of DIV instruction .if (AL > 9) ; Not only ones .if (AL > 99) ; Not only tens and ones MOV DL,100 ; Prepare the divisor DIV DL ; AL: hundreds, AH: tens, ones ADD AL,'0' ; Convert the hundreds in ASCII STOSB ; and write it to the string SHR EAX,8 ; AL = tens and ones .endif MOV DL,10 ; Prepare the divisor DIV DL ; AL = tens, AH = ones ADD AL,'0' ; Convert the tens in ASCII STOSB ; and write it to the string MOV AL,AH ; AL = ones .endif ADD AL,'0' ; Convert the ones in ASCII SHR ECX,8 ; Last byte? MOV AH,CL ; (Prepare the delimiter as the next character, STOSW ; write the ones & the delimiter to the string) .until (zero?) ; No - go process the next one RET ; Yes - return to the caller _putipstr endp putipstr endp end