The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: ecube on March 25, 2010, 09:08:33 PM

Title: help convert time
Post by: ecube on March 25, 2010, 09:08:33 PM
thanks qword
Title: Re: help convert time
Post by: qWord on March 25, 2010, 09:46:06 PM
seems like an byte swap:
xTime db "0123" ;=> db 30h,31h,32h,33h
the algo does:
30h SHL 24 + 31h SHL 16 + 32h SHL 8 + 33h = 30313233h
stored in mem: db 33h,32h,31h,30h


bswap is your friend:
mov eax,DWORD ptr xTime
bswap eax
;eax = result


Title: Re: help convert time
Post by: qWord on March 25, 2010, 10:21:49 PM
how can an 4 byte numeric string exceed 9999 (or if hex decimal 0xffff) ?

EDIT: didn't see your example  :red - this also works! even with: FF FF FF FF
Title: Re: help convert time
Post by: qWord on March 25, 2010, 10:54:52 PM
bswap is correct for converting an DWORD from Network byte order to Little-Endian.
Did you ever heard of differenc between signed and unsigned int  :U