<< Click to Display Table of Contents >> Navigation: ThinBASIC Core Language > Machine Code > MC_Eval$ |
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
'
'----------------------------------------------