# Machine Code Help?

## Recommended Posts

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.

##### Share on other sites

There are problems with your example.

First: the byte count: either the cleartext is
TABTAB012345678abcdefghijklmnopqrstuvwxyz
or
TABTAB0123456789abcdefghijklmnopqrstuvwxyz{

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
EndFunc```

Unless 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.
RegExp tutorial: enough to get started
PCRE 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)

##### Share on other sites

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 by Biatu

What is what? What is what.

##### Share on other sites

Bump?

What is what? What is what.

## Create an account

Register a new account

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...