Biatu Posted May 7, 2015 Share Posted May 7, 2015 Hello, I was wondering if anyone would be able to help me convert this to machine code?Plz and Thk u... Basically, The function parses a string which I manually encoded.If the byte is not 0x01, it passes that byte to the resulting string.If the byte is 0x01, then the previous byte is used in reference to the next byte(not 0x01) to generate a number of bytes in order to reproduce the data.For example:$sStr=@TAB&@TAB&"0123456789abcdefghijklmnopqrstuvwxyz" ;0909 ;30 01 09 ;61 01 1A ;Resulting in: ;0x090930010961011A I'm trying to port this code:$a="0x090A20015E" Local $c,$d,$b For $e=1 To 5 $f=Int(BinaryMid($a,$e,1)) If $f=1 Then $b=1 ContinueLoop ElseIf $b=1 Then $g=Int(BinaryMid($a,$e,1)) $g=$c+$g For $h=$c To $g $d&=Hex($h,2) Next $b=0 Else $d&=Hex($f,2) EndIf $c=Int(BinaryMid($a,$e,1)) Next What is what? What is what. Link to comment Share on other sites More sharing options...
jchd Posted May 7, 2015 Share Posted May 7, 2015 There are problems with your example.First: the byte count: either the cleartext isTABTAB012345678abcdefghijklmnopqrstuvwxyzorTABTAB0123456789abcdefghijklmnopqrstuvwxyz{If 30 01 09 means 0123456789 (total 10 digits)then 61 01 1A means abcdefghijklmnopqrstuvwxyz{ (total 27 characters)Also the AutoIt code doesn't work with your first example (some variables are not reset correctly).In any case, the code you want boils down to: $a = "090A20015E" $z = '090930010961011A' ConsoleWrite(Execute('"' & StringRegExpReplace($a, '(?|(..)01(..)|(..)())', '" & _StrInc(0x$1, 0x00$2) & "') & '"') & @LF) ConsoleWrite(Execute('"' & StringRegExpReplace($z, '(?|(..)01(..)|(..)())', '" & _StrInc(0x$1, 0x00$2) & "') & '"') & @LF) Func _StrInc($c, $n) If $n = 0 Then Return Chr($c) Local $s For $i = 0 To $n ; or is it $n - 1? You decide! $s &= Chr($c + $i) Next Return $s EndFuncUnless your processing very large strings with this toy, you don't need machine code. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Biatu Posted May 7, 2015 Author Share Posted May 7, 2015 (edited) Thanks for your reply.The reasoning for having a machine code version of that function is for research and minimizing code size.In the end, the script should have 3 binary strings. 1 being 0x090A20015E, another being an index using the same or similar format, and the 3rd being a machine code interpreter, ability to compact or expand large strings might be necessary. The original string is 96 characters long.The string is then sorted by byte order.The binary is then reduced from 96 Bytes to only 5.Lastly an index is formed to reproduce the original string.Upon executing the func, a static variable containing the 5Byte string+Index data will be expanded back into the originating format.The format im using will have multiple methods of both compacting and expanding these binary strings. Not just adding 0x01, but thats for later. Edited May 7, 2015 by Biatu What is what? What is what. Link to comment Share on other sites More sharing options...
Biatu Posted June 18, 2015 Author Share Posted June 18, 2015 Bump? What is what? What is what. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now