?? frmoutput.frm
字號:
ForeColor = &H00FF0000&
Height = 315
Left = 7305
TabIndex = 7
Top = 120
Width = 990
End
Begin VB.Label Label1
AutoSize = -1 'True
BackColor = &H00FFFF80&
BeginProperty Font
Name = "隸書"
Size = 18
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000C0&
Height = 360
Left = 2880
TabIndex = 5
Top = 240
Width = 210
End
Begin VB.Label Label4
AutoSize = -1 'True
BackColor = &H00C0C0FF&
Caption = "代 碼 生 成"
BeginProperty Font
Name = "隸書"
Size = 15.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 315
Left = 240
TabIndex = 3
Top = 240
Width = 1935
End
Begin VB.Label Label3
AutoSize = -1 'True
BackColor = &H00C0C0FF&
Caption = "符 號 表"
BeginProperty Font
Name = "隸書"
Size = 15.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 315
Left = 3960
TabIndex = 2
Top = 960
Width = 1770
End
End
Attribute VB_Name = "frmOutput"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Me.Hide
End Sub
Private Sub Form_Load()
With varTable
.Row = 0
.Col = 0
.Text = "序號"
.Col = 1
.Text = "變量名"
.Col = 2
.Text = "類型"
.Col = 3
.Text = "地址"
End With
End Sub
Private Sub HScroll1_Change()
s = HScroll1.Value
End Sub
Private Sub run_Click()
Dim Label(100) As Integer
Dim i As Integer, inText As String
Dim command(1) As String
output.Clear
stack.Clear
For i = 0 To lstCode.ListCount - 1
lstCode.ListIndex = i
If Right$(lstCode.List(i), 1) = ":" Then
Label(Val(Mid$(lstCode.List(i), 6, Len(lstCode.List(i)) - 6))) = i '用label數組記住每個標號的地址
End If
Next i
For i = 0 To lstCode.ListCount - 1
lstCode.ListIndex = i
Sleep
If Check1.Value = 1 Then MsgBox "繼續"
command(0) = Trim$(Left$(lstCode.List(i), 15))
command(1) = Mid$(lstCode.List(i), 16)
Select Case command(0)
Case "LOAD"
data.Row = Val(command(1))
data.Col = 1
stack.AddItem data.Text
stack.ListIndex = stack.ListCount - 1
Case "LOADI" 'LOADI a將常量a壓入操作數棧
stack.AddItem command(1)
stack.ListIndex = stack.ListCount - 1
Case "STO" 'STO D 將操作數棧棧頂單元內容存入D,且棧頂單元內容保持不變。
data.Row = Val(command(1))
data.Col = 1
data.Text = stack.Text
Case "STI" 'STI D 將操作數棧棧頂單元內容存入D,且棧頂單元內容出棧。
data.Row = Val(command(1))
data.Col = 1
data.Text = stack.Text
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "ADD" 'ADD將次棧頂單元與棧頂單元內容出棧并相加,和置于棧頂。
stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) + Val(stack.List(stack.ListCount - 1))
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "SUB" 'SUB 將次棧頂單元減去棧頂單元內容并出棧,差置于棧頂。
stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) - Val(stack.List(stack.ListCount - 1))
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "MULT" 'MULT 將次棧頂單元與棧頂單元內容出棧并相乘,積置于棧頂。
stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) * Val(stack.List(stack.ListCount - 1))
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "DIV" 'DIV 將次棧頂單元與棧頂單元內容出棧并相除,商置于棧頂。
stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) \ Val(stack.List(stack.ListCount - 1))
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "BR" 'BR lab 無條件轉移到lab
i = Label(Val(Mid$(command(1), 6, 10)))
stack.ListIndex = stack.ListCount - 1
Case "BRF" 'BRF lab 檢查棧頂單元邏輯值,若為假(0)則轉移到lab
If stack.Text = "False" Then i = Label(Val(Mid$(command(1), 6, 10)))
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "EQ" 'EQ 將棧頂兩單元做等于比較,并將結果真或假(1或0)置于棧頂
stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) = Val(stack.List(stack.ListCount - 1))
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "NOTEQ" 'NOTEQ 將棧頂兩單元做不等于比較,并將結果真或假(1或0)置于棧頂
stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) <> Val(stack.List(stack.ListCount - 1))
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "GT" 'GT 次棧頂大于棧頂操作數,則棧頂置1,否則置0
stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) > Val(stack.List(stack.ListCount - 1))
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "LES" 'LES 次棧頂小于棧頂操作數,則棧頂置1,否則置0
stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) < Val(stack.List(stack.ListCount - 1))
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "GE" 'GE 次棧頂大于等于棧頂操作數,則棧頂置1,否則置0
stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) >= Val(stack.List(stack.ListCount - 1))
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "LE" 'LE 次棧頂小于等于棧頂操作數,則棧頂置1,否則置0
stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) <= Val(stack.List(stack.ListCount - 1))
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "AND" 'AND 將棧頂兩單元做邏輯與運算,并將結果真或假(1或0)置于棧頂
stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) And Val(stack.List(stack.ListCount - 1))
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "OR" 'OR 將棧頂兩單元做邏輯或運算,并將結果真或假(1或0)置于棧頂
stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) Or Val(stack.List(stack.ListCount - 1))
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "NOT" 'NOT 將棧頂的邏輯值取反
stack.List(stack.ListCount - 1) = Not stack.List(stack.ListCount - 1)
Case "IN" 'IN 從標準輸入設備(鍵盤)讀入一個整型數據,并入棧。
inText = InputBox("請輸入整數數據:")
stack.AddItem inText
stack.ListIndex = stack.ListCount - 1
Case "OUT" 'OUT 將棧頂單元內容出棧,并輸出到標準輸出設備上(顯示器)。
output.AddItem stack.Text
stack.RemoveItem stack.ListCount - 1
stack.ListIndex = stack.ListCount - 1
Case "STOP" 'STOP 停止執行
MsgBox "運行結束"
Exit Sub
End Select
Next i
End Sub
Private Sub Timer1_Timer()
s = Val(HScroll1.Value) * 1000
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -