This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.
This version is copyright and may only be used for local testing purposes. It may not be distributed.
Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.
Description
Evaluate a string and return its representation in machine code.
Syntax
MachineCodeString = MC_Eval$(StringToEval)
Returns
String.
Parameters
Name |
Type |
Optional |
Meaning |
StringToEval |
String |
No |
String to evaluate into machine code |
Remarks
Rules:
Restrictions
See also
Examples
' Using Machine Code with ThinBasic
'---------------------------------------------------------------------------
'---Reference:
' Intel x86 Architecture Ref Manual Vol 2
'---http://developer.intel.com/design/pentiumii/manuals/243191.htm
'---------------------------------------------------------------------------
' Syntax rules:
' #Variable patches in long address of Variable (4 bytes)
' NLn patches in long decimal value n (4 bytes)
' comments are indicated by a quote mark '
' all other words are read as hexadecimal bytes.
' An error during MC_Eval$ will produce a string containing &hc3 (ret) only.
'----------------------------------------------
' CPUID
' Identifying some key CPU features
' see page 3-111 in the manual above
'----------------------------------------------
Dim sMC As String
sMC = MC_EVAL$ "
b8 01 00 00 00 ' mov eax,1 request feature info in edx
0f a2 ' cpuid
8b c2 ' mov eax,edx
c3 ' ret
"
'----------------------------------------------
' ---Invoke the machine code string
Dim RetVal As Long = MC_Exec(sMC)
Dim s As String="CPU Features:" + $crlf
If Retval And &h0000001 Then s += "FPU " + $crlf ' bit0 FPU
If RetVal And &h0008000 Then s += "CMOV " + $crlf ' bit15 CMOV
If RetVal And &h0010000 Then s += "FGPAT" + $crlf ' bit16 FGPAT
If RetVal And &h0800000 Then s += "MMX " + $crlf ' bit23 MMX
If RetVal And &h1000000 Then s += "FXR " + $crlf ' bit24 FXSAVE / FXRSTOR
If RetVal And &h2000000 Then s += "XMM (streaming simd)" + $crlf ' bit25 XMM streaming SIMD
MSGBOX 0, hex$(RetVal) + $crlf + $crlf + s
'
'----------------------------------------------