Yuraj Posted August 3, 2009 Share Posted August 3, 2009 Hi, I've written a small com compiler, but It's not very good. It writtes machine code to file, but there's a one problem. You must manualy got adresses of DBs, buffers etc. using some hex editor. It's harder to fix it, that's my opinion. For now not very practical :-( There are few base instructions... Here is the code with simple example: expandcollapse popup; COM compiler test ;Written by Yuraj #include <string.au3> #include <array.au3> $DBs = _DB("What's your name?" & @LF) $DBs &= _DB("Hello, ") $DBs &= _DB(@LF & "Press any key to close ..." & @LF) ; INSTRUCTIONS, 100 + OFFSET $r= _Print(0x14D) & _ ; offset of: "what's your..." _Read(0x128) & _ ; offset of input buffer _Print(0x160) & _ ; offset of: "hello..." _Print(0x128+2) & _ ; offset of input buffer + 2 ;_WriteChar('.') & _ ; write char _Print(0x168) & _ ; offset of "press any key" _ReadChar() & _ ; wait for key press, result in AL _Terminate() & _ ; return _CREATE_BUFFER(0x20,0x00,0x22) & _ ; Max. input string length 32 $DBs ; COMPILE OUTPUT $f = FileOpen("C:\test.com",18) FileWrite($f, $r) FileClose($f) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func DBLen($db) Return (StringLen($db)/2)-2 EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; FUNCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _ClrScr() Return _MOV_AH(0x00) & _INT(0x10) EndFunc Func _Print($adr) $r = _MOV_DX($adr) ; > OFFSET OF STRING TO OUTPUT $r &= _MOV_AH(0x09) ; > FUNCTION: OUTPUT $r &= _INT(0x21) ; > INTERRUPT: IO... Return $r EndFunc Func _Read($adr) $r = _MOV_DX($adr) ; > OFFSET OF BUFFER $r &= _MOV_AH(0x0A) ; > FUNCTION: INPUT $r &= _INT(0x21) ; > INTERRUPT: IO... Return $r EndFunc Func _ReadChar() ; result is stored in AL $r = _MOV_AH(0x01) ; > FUNCTION: INPUT CHAR $r &= _INT(0x21) ; > INTERRUPT: IO... Return $r EndFunc Func _WriteChar($char) ; result is stored in AL $r = _MOV_DL(Asc($char)) ; > OFFSET OF BUFFER $r &= _MOV_AH(0x02) ; > FUNCTION: OUTPUT CHAR $r &= _INT(0x21) ; > INTERRUPT: IO... Return $r EndFunc Func _GetSystemDate() ; return: CX = year (1980-2099). DH = month. DL = day. AL = day of week (00h=Sunday) $r = _MOV_AH(0x2A) ; > FUNCTION: GET DATE $r &= _INT(0x21) ; > INTERRUPT: IO... Return $r EndFunc Func _Terminate() Return _INT(0x20) ; > INTERRUPT: TERMINATE... EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; BASE INSTRUCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _INT($num) Return Binary("0xCD" & Hex($num,2)) EndFunc Func _MOV_AH($num) Return Binary("0xB4" & Hex($num,2)) EndFunc Func _MOV_DL($num) Return Binary("0xB2" & Hex($num,2)) EndFunc Func _MOV_DX($adr) Return Binary("0xBA" & SwapEndian($adr)) EndFunc Func _NOP() Return Binary("0x00") EndFunc Func _DB($str) Return Binary($str & "$") EndFunc ; max,count,BUFFER_LEN (max+2) Func _CREATE_BUFFER($a,$b,$c) Return Binary("0x" & Hex($a,2) & Hex($b,2)) & Binary(_StringRepeat("$",$c)) EndFunc Func SwapEndian($iValue) Return Hex(BinaryMid($iValue, 1, 2)) EndFunc ;==>SwapEndian ShellExecute("http://www.yuraj.ucoz.com")ProcessClose(@AutoItPID) Link to comment Share on other sites More sharing options...
daluu Posted August 3, 2009 Share Posted August 3, 2009 What do you mean a COM compiler? ActiveX/COM object compiler? *.com file compiler? Binary/executable file compiler? Link to comment Share on other sites More sharing options...
Yuraj Posted August 3, 2009 Author Share Posted August 3, 2009 What do you mean a COM compiler? ActiveX/COM object compiler? *.com file compiler? Binary/executable file compiler?I mean executable old dos com file >_< ShellExecute("http://www.yuraj.ucoz.com")ProcessClose(@AutoItPID) 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