;unsigned getVLQ(unsigned char **src) ;{ // read a variable length quantity ; unsigned char c, *p = *src;// (see Standard MIDI-File Format Spec. 1.1) ; unsigned value = *p++; ; if (value & 0x80) { ; value &= 0x7f; ; do ; value = (value << 7) + ((c = *p++) & 0x7f); ; while (c & 0x80); ; } ; *src = p; ; return value; ;} option prologue:none, epilogue:none .code getvlq proc _getvlq proc ; src = RDI, p = RSI XOR EAX,EAX ; value = EAX c = AL MOV RSI,[RDI] ; get the address .repeat LODSB ; read the next byte and update the address ROR EAX,8 ; put the byte as the highest one; other bytes? .until (!carry?) ; yes, continue BSWAP EAX ; no, put the bytes on their real places MOV EDX,7F7F7F7FH ; prepare a mask to compact the bytes PEXT EAX,EAX,EDX ; leave only the significant bits MOV [RDI],RSI ; save the new address RET _getvlq endp getvlq endp end