; Return in the EAX register the IP-address (IPv4), obtained from the ASCIIZ ; string starting at an address passed in the RDI register. The string is in ; decimal format with a dot as a delimiter between bytes (e.g.: 192.92.129.2). option prologue:none, epilogue:none .code getipstr proc _getipstr proc MOV RSI,RDI ; Place the starting address in RSI because of LODSB .repeat XOR EAX,EAX ; New current byte - start accumulating from 0 CDQ .repeat IMUL EDX,EDX,10; Shift current byte 1 decimal place ADD DL,AL; Add the new digit to it LODSB ; Load the next character assuming it's a digit SUB AL,'0'; Convert from ASCII to BCD .until (below?) ; A digit? Continue with the next character SHL ECX,8 ; Make room for the current byte MOV CL,DL ; and write it from the right in the IP-address .until (AL == -'0') ; If this byte was a null terminator, XCHG EAX,ECX ; return the IP-address in EAX RET _getipstr endp getipstr endp end