diff --git a/PIC_Sim_Hardware/PIC_SIM.exe b/PIC_Sim_Hardware/PIC_SIM.exe new file mode 100644 index 0000000..aff8faf Binary files /dev/null and b/PIC_Sim_Hardware/PIC_SIM.exe differ diff --git a/PIC_Sim_Hardware/PIC_VIEW.pdf b/PIC_Sim_Hardware/PIC_VIEW.pdf new file mode 100644 index 0000000..7e2d75d Binary files /dev/null and b/PIC_Sim_Hardware/PIC_VIEW.pdf differ diff --git a/PIC_Sim_Hardware/PicViewDoc.pdf b/PIC_Sim_Hardware/PicViewDoc.pdf new file mode 100644 index 0000000..fe3b9ad Binary files /dev/null and b/PIC_Sim_Hardware/PicViewDoc.pdf differ diff --git a/PIC_Simulator.sln b/PIC_Simulator.sln new file mode 100644 index 0000000..4e1977c --- /dev/null +++ b/PIC_Simulator.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PIC_Simulator", "PIC_Simulator\PIC_Simulator.csproj", "{61AE0011-89B1-46B3-B2EA-E0949BD27605}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {61AE0011-89B1-46B3-B2EA-E0949BD27605}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61AE0011-89B1-46B3-B2EA-E0949BD27605}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61AE0011-89B1-46B3-B2EA-E0949BD27605}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61AE0011-89B1-46B3-B2EA-E0949BD27605}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/PIC_Simulator/App.config b/PIC_Simulator/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/PIC_Simulator/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/PIC_Simulator/Befehlssatz.cs b/PIC_Simulator/Befehlssatz.cs new file mode 100644 index 0000000..d3b19ba --- /dev/null +++ b/PIC_Simulator/Befehlssatz.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIC_Simulator +{ + class Befehlssatz + { + + } +} diff --git a/PIC_Simulator/Einlesen.cs b/PIC_Simulator/Einlesen.cs new file mode 100644 index 0000000..8ed1d8b --- /dev/null +++ b/PIC_Simulator/Einlesen.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.IO; + +namespace PIC_Simulator +{ + + public class Einlesen + { + //Globale Variablen der Klasse: + public int LengthArray = 0; + public string[] result; + + public int writeToArray(StreamReader sr) + { + + // StreamReader jede Zeile in Listenelement schreiben + var list = new List(); + string line; + while ((line = sr.ReadLine()) != null) + { if (!line.StartsWith(" ") ) + { + list.Add(line); + } + } + + //Schreiben der Listenelemente in String Array + result = list.ToArray(); + LengthArray = result.Length -1; //-1 Wegen Start des Arrays bei Index 0! + // MessageBox.Show("Zeilen des Programms:" + LengthArray ); + + //PCount Variable von Form1 holen und für readExec als Param nutzen + Form1 instForm1 = new Form1(); + readExecCode(instForm1.PCounter); + return LengthArray; + } + + //Ausführbarer Maschinencode aus Zeile des Arrays herausschneiden + public void readExecCode(int index) { + try + { + result[index] = result[index].Substring(5, 4); + // MessageBox.Show(result[index]); + execCode(index); + } + + catch { } + } + + public string execCode(int index) { + // MessageBox.Show("Index der Row welche ausgeführt werden soll" + index); + MessageBox.Show("Code der ausgeführt werden soll" + result[index]); + + Register Ausführen = new Register(); + Ausführen.findOrder(result[index].ToString()); + return result[index]; + + // Hier ist der Start für die Befehlsausführung des PIC bzw. Ãœbergabe an Befehlssatz + // Return übergibt Auszuführenden Code!! + } + + } + } + diff --git a/PIC_Simulator/Form1.Designer.cs b/PIC_Simulator/Form1.Designer.cs new file mode 100644 index 0000000..5a022ef --- /dev/null +++ b/PIC_Simulator/Form1.Designer.cs @@ -0,0 +1,372 @@ +namespace PIC_Simulator +{ + partial class Form1 + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem("INDF"); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.box_CodeView = new System.Windows.Forms.RichTextBox(); + this.lbl_path = new System.Windows.Forms.Label(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.cmd_Start = new System.Windows.Forms.Button(); + this.cmd_next = new System.Windows.Forms.Button(); + this.cmd_reset = new System.Windows.Forms.Button(); + this.label3 = new System.Windows.Forms.Label(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.cmdOpenFile = new System.Windows.Forms.ToolStripMenuItem(); + this.programmÖffnenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.beendenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.hilfeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.cmdOpenDoc = new System.Windows.Forms.ToolStripMenuItem(); + this.label4 = new System.Windows.Forms.Label(); + this.cmdSetClock = new System.Windows.Forms.Button(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.listView1 = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.cmd_Stop = new System.Windows.Forms.Button(); + this.lbl_Timer = new System.Windows.Forms.Label(); + this.insertTime = new System.Windows.Forms.TextBox(); + this.menuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.BackColor = System.Drawing.SystemColors.Control; + this.label1.Location = new System.Drawing.Point(39, 96); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(0, 17); + this.label1.TabIndex = 1; + this.label1.Click += new System.EventHandler(this.label1_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(11, 577); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(105, 17); + this.label2.TabIndex = 2; + this.label2.Text = "Programmpfad:"; + // + // box_CodeView + // + this.box_CodeView.Location = new System.Drawing.Point(11, 95); + this.box_CodeView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.box_CodeView.Name = "box_CodeView"; + this.box_CodeView.Size = new System.Drawing.Size(833, 462); + this.box_CodeView.TabIndex = 3; + this.box_CodeView.Text = ""; + this.box_CodeView.WordWrap = false; + // + // lbl_path + // + this.lbl_path.AutoSize = true; + this.lbl_path.Location = new System.Drawing.Point(116, 577); + this.lbl_path.Name = "lbl_path"; + this.lbl_path.Size = new System.Drawing.Size(0, 17); + this.lbl_path.TabIndex = 4; + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // cmd_Start + // + this.cmd_Start.Location = new System.Drawing.Point(15, 36); + this.cmd_Start.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.cmd_Start.Name = "cmd_Start"; + this.cmd_Start.Size = new System.Drawing.Size(67, 28); + this.cmd_Start.TabIndex = 5; + this.cmd_Start.Text = "Start"; + this.cmd_Start.UseVisualStyleBackColor = true; + this.cmd_Start.Click += new System.EventHandler(this.cmd_Start_Click); + // + // cmd_next + // + this.cmd_next.Location = new System.Drawing.Point(168, 38); + this.cmd_next.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.cmd_next.Name = "cmd_next"; + this.cmd_next.Size = new System.Drawing.Size(67, 26); + this.cmd_next.TabIndex = 6; + this.cmd_next.Text = "Schritt"; + this.cmd_next.UseVisualStyleBackColor = true; + this.cmd_next.Click += new System.EventHandler(this.cmd_next_Click); + // + // cmd_reset + // + this.cmd_reset.Location = new System.Drawing.Point(253, 38); + this.cmd_reset.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.cmd_reset.Name = "cmd_reset"; + this.cmd_reset.Size = new System.Drawing.Size(67, 26); + this.cmd_reset.TabIndex = 7; + this.cmd_reset.Text = "Reset"; + this.cmd_reset.UseVisualStyleBackColor = true; + this.cmd_reset.Click += new System.EventHandler(this.cmd_reset_Click); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(331, 42); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(112, 17); + this.label3.TabIndex = 8; + this.label3.Text = "Programmzähler"; + // + // menuStrip1 + // + this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.cmdOpenFile, + this.hilfeToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2); + this.menuStrip1.Size = new System.Drawing.Size(1397, 28); + this.menuStrip1.TabIndex = 9; + this.menuStrip1.Text = "menuStrip1"; + // + // cmdOpenFile + // + this.cmdOpenFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.programmÖffnenToolStripMenuItem, + this.beendenToolStripMenuItem}); + this.cmdOpenFile.Name = "cmdOpenFile"; + this.cmdOpenFile.Size = new System.Drawing.Size(57, 24); + this.cmdOpenFile.Text = "Datei"; + // + // programmÖffnenToolStripMenuItem + // + this.programmÖffnenToolStripMenuItem.Name = "programmÖffnenToolStripMenuItem"; + this.programmÖffnenToolStripMenuItem.Size = new System.Drawing.Size(201, 26); + this.programmÖffnenToolStripMenuItem.Text = "Programm öffnen"; + this.programmÖffnenToolStripMenuItem.Click += new System.EventHandler(this.programmÖffnenToolStripMenuItem_Click); + // + // beendenToolStripMenuItem + // + this.beendenToolStripMenuItem.Name = "beendenToolStripMenuItem"; + this.beendenToolStripMenuItem.Size = new System.Drawing.Size(201, 26); + this.beendenToolStripMenuItem.Text = "Beenden"; + this.beendenToolStripMenuItem.Click += new System.EventHandler(this.beendenToolStripMenuItem_Click); + // + // hilfeToolStripMenuItem + // + this.hilfeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.cmdOpenDoc}); + this.hilfeToolStripMenuItem.Name = "hilfeToolStripMenuItem"; + this.hilfeToolStripMenuItem.Size = new System.Drawing.Size(53, 24); + this.hilfeToolStripMenuItem.Text = "Hilfe"; + // + // cmdOpenDoc + // + this.cmdOpenDoc.Name = "cmdOpenDoc"; + this.cmdOpenDoc.Size = new System.Drawing.Size(234, 26); + this.cmdOpenDoc.Text = "Dokumentation öffnen"; + this.cmdOpenDoc.Click += new System.EventHandler(this.cmdOpenDoc_Click); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(1038, 36); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(129, 17); + this.label4.TabIndex = 10; + this.label4.Text = "Quarzfrequenz in s"; + // + // cmdSetClock + // + this.cmdSetClock.Location = new System.Drawing.Point(1273, 34); + this.cmdSetClock.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.cmdSetClock.Name = "cmdSetClock"; + this.cmdSetClock.Size = new System.Drawing.Size(67, 24); + this.cmdSetClock.TabIndex = 11; + this.cmdSetClock.Text = "setzen"; + this.cmdSetClock.UseVisualStyleBackColor = true; + this.cmdSetClock.Click += new System.EventHandler(this.cmdSetClock_Click); + // + // timer1 + // + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // listView1 + // + this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2, + this.columnHeader3, + this.columnHeader4, + this.columnHeader5, + this.columnHeader6, + this.columnHeader7, + this.columnHeader8}); + this.listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[] { + listViewItem2}); + this.listView1.Location = new System.Drawing.Point(906, 95); + this.listView1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.listView1.Name = "listView1"; + this.listView1.Size = new System.Drawing.Size(434, 350); + this.listView1.TabIndex = 14; + this.listView1.UseCompatibleStateImageBehavior = false; + this.listView1.View = System.Windows.Forms.View.Details; + // + // columnHeader1 + // + this.columnHeader1.Text = "0"; + // + // columnHeader2 + // + this.columnHeader2.Text = "1"; + // + // columnHeader3 + // + this.columnHeader3.Text = "2"; + // + // columnHeader4 + // + this.columnHeader4.Text = "3"; + // + // columnHeader5 + // + this.columnHeader5.Text = "4"; + // + // columnHeader6 + // + this.columnHeader6.Text = "5"; + this.columnHeader6.Width = 62; + // + // columnHeader7 + // + this.columnHeader7.Text = "6"; + // + // columnHeader8 + // + this.columnHeader8.Text = "7"; + // + // cmd_Stop + // + this.cmd_Stop.Location = new System.Drawing.Point(85, 37); + this.cmd_Stop.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.cmd_Stop.Name = "cmd_Stop"; + this.cmd_Stop.Size = new System.Drawing.Size(67, 27); + this.cmd_Stop.TabIndex = 15; + this.cmd_Stop.Text = "Stop"; + this.cmd_Stop.UseVisualStyleBackColor = true; + this.cmd_Stop.Click += new System.EventHandler(this.cmd_Stop_Click); + // + // lbl_Timer + // + this.lbl_Timer.AutoSize = true; + this.lbl_Timer.Location = new System.Drawing.Point(940, 34); + this.lbl_Timer.Name = "lbl_Timer"; + this.lbl_Timer.Size = new System.Drawing.Size(44, 17); + this.lbl_Timer.TabIndex = 16; + this.lbl_Timer.Text = "Timer"; + // + // insertTime + // + this.insertTime.Location = new System.Drawing.Point(1192, 38); + this.insertTime.Name = "insertTime"; + this.insertTime.Size = new System.Drawing.Size(61, 22); + this.insertTime.TabIndex = 17; + this.insertTime.Text = "100"; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1397, 600); + this.Controls.Add(this.insertTime); + this.Controls.Add(this.lbl_Timer); + this.Controls.Add(this.cmd_Stop); + this.Controls.Add(this.listView1); + this.Controls.Add(this.cmdSetClock); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.cmd_reset); + this.Controls.Add(this.cmd_next); + this.Controls.Add(this.cmd_Start); + this.Controls.Add(this.lbl_path); + this.Controls.Add(this.box_CodeView); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.menuStrip1); + this.MainMenuStrip = this.menuStrip1; + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "Form1"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "PIC Simulator"; + this.Load += new System.EventHandler(this.Form1_Load); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.RichTextBox box_CodeView; + private System.Windows.Forms.Label lbl_path; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Button cmd_Start; + private System.Windows.Forms.Button cmd_next; + private System.Windows.Forms.Button cmd_reset; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem cmdOpenFile; + private System.Windows.Forms.ToolStripMenuItem programmÖffnenToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem hilfeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem cmdOpenDoc; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Button cmdSetClock; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.ListView listView1; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.ColumnHeader columnHeader3; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ColumnHeader columnHeader6; + private System.Windows.Forms.ColumnHeader columnHeader7; + private System.Windows.Forms.ColumnHeader columnHeader8; + private System.Windows.Forms.ToolStripMenuItem beendenToolStripMenuItem; + private System.Windows.Forms.Button cmd_Stop; + private System.Windows.Forms.Label lbl_Timer; + private System.Windows.Forms.TextBox insertTime; + } +} + diff --git a/PIC_Simulator/Form1.cs b/PIC_Simulator/Form1.cs new file mode 100644 index 0000000..1c8f18d --- /dev/null +++ b/PIC_Simulator/Form1.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.IO; +using PIC_Simulator; + + + +namespace PIC_Simulator +{ + public partial class Form1 : Form + { + + public Form1() + { + InitializeComponent(); + + } + // Globale Variablen + public int ArrayLaenge =0; + public int PCounter = -1; + public int time; + public int timeIntervall; + Einlesen instEinlesen = new Einlesen(); + + + private void label1_Click(object sender, EventArgs e) + { + + } + + private void Form1_Load(object sender, EventArgs e) + { + box_CodeView.Font = new Font("Consolas", 8); + timeIntervall = 1000; + } + + private void cmd_Start_Click(object sender, EventArgs e) + { + timer1.Interval = timeIntervall; // 1 Sekunde + timer1.Enabled = true; + } + + private void cmd_next_Click(object sender, EventArgs e) + + { + // MessageBox.Show("Array laenge übergeben:" + ArrayLaenge); + if (PCounter == ArrayLaenge) { MessageBox.Show("Programm ist komplett durchlaufen!"); } + else { + PCounter = PCounter + 1; + try + { + //Zeilenmarkierung aufheben + highLightALine(box_CodeView, PCounter - 1, Color.White); + } + catch { } + //Counter im Label inkrementieren + int shownCounter = PCounter; + shownCounter++; + label3.Text = shownCounter.ToString(); + } + //Aktuelle Zeile markieren + highLightALine(box_CodeView, PCounter, Color.Green); + + instEinlesen.readExecCode(PCounter); + } + + private int getPCounter() { + return PCounter; + } + + private void programmÖffnenToolStripMenuItem_Click(object sender, EventArgs e) + { + // Datei über openFileDialog1 Auswählen und in Anzeige öffnen + FileStream fs; + StreamReader sr; + string zeile; + + if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + sr = new + StreamReader(openFileDialog1.FileName); + DialogResult = MessageBox.Show(sr.ReadToEnd(), "Programm Vorschau", MessageBoxButtons.OKCancel); + sr.Close(); + // Abfrage von Ergebnis des Dialogs, wenn ja Datei laden + if (DialogResult == DialogResult.OK) + { + fs = new FileStream(openFileDialog1.FileName, FileMode.Open); + sr = new StreamReader(fs); + + while (sr.Peek() != -1) + { + zeile = sr.ReadLine(); + box_CodeView.Text += zeile + "\n"; + } + sr.Close(); + lbl_path.Text = openFileDialog1.FileName; + + // StreamReader jede Zeile in Listenelement schreiben über Funktionsaufruf in der Klasse Einlesen + + ArrayLaenge = instEinlesen.writeToArray(sr = new StreamReader(openFileDialog1.FileName)); + } + + } + } + + private void cmdOpenDoc_Click(object sender, EventArgs e) + { + string path = Application.StartupPath; + MessageBox.Show( path); + System.Diagnostics.Process.Start(@"C:\Users\nicol\Desktop\Projekte\PIC_Simulator\Projektinformationen\DataSheet.pdf"); + } + + //Funktion um Zeile aktuell ausgeführte Zeile zu markieren + void highLightALine(RichTextBox rtb, int line, Color hiLight) + { + int i1 = rtb.GetFirstCharIndexFromLine(line); + int i2 = rtb.GetFirstCharIndexFromLine(line + 1); + if (i2 < 0) i2 = rtb.Text.Length; + + rtb.SelectionStart = i1; + rtb.SelectionLength = i2 - i1; + rtb.SelectionBackColor = hiLight; + } + + private void cmdSetClock_Click(object sender, EventArgs e) + { + timeIntervall = Convert.ToInt32(insertTime.Text); + + } + + private void cmd_reset_Click(object sender, EventArgs e) + { //######################### Muss ergänzt und getestet werden !!! + // Hier müssen alle Werte wieder auf den Standard gesetzt werden! + highLightALine(box_CodeView, PCounter, Color.White); + PCounter = -1; + label3.Text = PCounter.ToString(); + //######################### Muss ergänzt und getestet werden !!! + } + + + private void buildtbl_Register() { + + } + + private void beendenToolStripMenuItem_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void timer1_Tick(object sender, EventArgs e) + { + Einlesen QuarzExec = new Einlesen(); + + PCounter = PCounter + 1; + label3.Text = PCounter.ToString(); + } + + private void cmd_Stop_Click(object sender, EventArgs e) + { + timer1.Enabled = false; + } + + + } + } + diff --git a/PIC_Simulator/Form1.resx b/PIC_Simulator/Form1.resx new file mode 100644 index 0000000..d6a0d29 --- /dev/null +++ b/PIC_Simulator/Form1.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + 17, 17 + + + 211, 17 + + + 367, 17 + + \ No newline at end of file diff --git a/PIC_Simulator/PIC_Simulator.csproj b/PIC_Simulator/PIC_Simulator.csproj new file mode 100644 index 0000000..612a3d5 --- /dev/null +++ b/PIC_Simulator/PIC_Simulator.csproj @@ -0,0 +1,85 @@ + + + + + Debug + AnyCPU + {61AE0011-89B1-46B3-B2EA-E0949BD27605} + WinExe + PIC_Simulator + PIC_Simulator + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/PIC_Simulator/Program.cs b/PIC_Simulator/Program.cs new file mode 100644 index 0000000..4f687b6 --- /dev/null +++ b/PIC_Simulator/Program.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.IO; + +namespace PIC_Simulator +{ + static class Program + { + /// + /// Der Haupteinstiegspunkt für die Anwendung. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + + + } + } + + +} diff --git a/PIC_Simulator/Properties/AssemblyInfo.cs b/PIC_Simulator/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..33239d2 --- /dev/null +++ b/PIC_Simulator/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die einer Assembly zugeordnet sind. +[assembly: AssemblyTitle("PIC_Simulator")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PIC_Simulator")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly +// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("61ae0011-89b1-46b3-b2ea-e0949bd27605")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PIC_Simulator/Properties/Resources.Designer.cs b/PIC_Simulator/Properties/Resources.Designer.cs new file mode 100644 index 0000000..e776130 --- /dev/null +++ b/PIC_Simulator/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion: 4.0.30319.42000 +// +// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn +// der Code neu generiert wird. +// +//------------------------------------------------------------------------------ + +namespace PIC_Simulator.Properties +{ + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse + // über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PIC_Simulator.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Ãœberschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/PIC_Simulator/Properties/Resources.resx b/PIC_Simulator/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/PIC_Simulator/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PIC_Simulator/Properties/Settings.Designer.cs b/PIC_Simulator/Properties/Settings.Designer.cs new file mode 100644 index 0000000..0b4f93c --- /dev/null +++ b/PIC_Simulator/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace PIC_Simulator.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/PIC_Simulator/Properties/Settings.settings b/PIC_Simulator/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/PIC_Simulator/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/PIC_Simulator/Register.cs b/PIC_Simulator/Register.cs new file mode 100644 index 0000000..bcbf3ce --- /dev/null +++ b/PIC_Simulator/Register.cs @@ -0,0 +1,357 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; +using System.Windows.Forms; + +namespace PIC_Simulator +{ + class Register + { + // Speicherarray anlegen: + List arrMemList = new List(); + + // BANK 0 definieren + byte BANK0_INDF = 0x0; //0000 0000 + byte BANK0_TMR0 = 0x0; //0000 0000 + byte BANK0_PCL = 0x0; //0000 0000 + byte BANK0_STATUS = 0x18; //0001 1000 + byte BANK0_FSR = 0x0; //0000 0000 + byte BANK0_PORTA = 0x0; //0000 0000 + byte BANK0_PORTB = 0x0; //0000 0000 + byte BANK0_EEDATA = 0x0; //0000 0000 + byte BANK0_EEADR = 0x0; //0000 0000 + + + // BANK 1 definieren + byte BANK1_INDF = 0x0; //0000 0000 + byte BANK1_OPTION_REG = 0xFF; //1111 1111 + byte BANK1_PCL = 0x0; //0000 0000 + byte BANK1_STATUS = 0x18; //0001 1000 + byte BANK1_FSR = 0x0; //0000 0000 + byte BANK1_TRISA = 0x1F; //0001 1111 + byte BANK1_TRISB = 0xFF; //1111 1111 + byte BANK1_EECON1 = 0x0; //0000 0000 + byte BANK1_EECON2 = 0x0; //0000 0000 + + // Gemeinsam genutzte Register + byte BANK_PCLATH = 0x0; //0000 0000 + byte BANK_INTCON = 0x0; //0000 0000 + + + //############## PIC COMMANDS BINARY ############################# + // --- Bit-Oriented File Register Operations --- + public string BCF = "0100"; // 4 Stellen zum Vergleichen + public string BSF = "0101"; + public string BTFSC = "0110"; + public string BTFSS = "0111"; + + //--- Byte-Oriented File Register Operations --- + public string ADDWF = "000111"; //6 Stellen zum Vergleichen + public string ANDWF = "000101"; //6 + public string COMF = "001001"; //6 + public string DECF = "000011"; //6 + public string DECFSZ = "001011"; //6 + public string INCF = "001010"; //6 + public string INCFSZ = "001111"; //6 + public string IORWF = "000100"; //6 + public string MOVF = "001000"; //6 + public string RLF = "001101"; //6 + public string RRF = "001100"; //6 + public string SUBWF = "000010"; //6 + public string SWAPF = "001110"; //6 + public string XORWF = "000110"; //6 + + public string CLRF = "0000011"; //7 Stellen zum Vergleichen + public string CLRW = "0000010"; //7 + public string MOVWF = "0000001"; //7 + + public string NOP1 = "00000000000000"; //14 Stellen zum Vergleichen + public string NOP2 = "00000000100000"; //14 + public string NOP3 = "00000001000000"; //14 + public string NOP4 = "00000001100000"; //14 + + // --- Literal and Control Operations --- + public string CALL = "100"; //3 Stellen zum Vergleichen + public string GOTO = "101"; //3 + + public string MOVLW = "1100"; //4 Stellen zum Vergleichen + public string RETLW = "1101"; //4 + + public string SUBLW = "11110"; //5 Stellen zum Vergleichen + public string ADDLW = "11111"; //5 + + public string ANDLW = "111001"; //6 Stellen zum Vergleichen + public string IORLW = "111000"; //6 + public string XORLW = "111010"; //6 + + public string CLRWDT = "00000001100100"; //14 + public string RETFIE = "00000000001001"; //14 + public string RETURN = "00000000001000"; //14 + public string SLEEP = "00000001100011"; //14 + //############## PIC COMMANDS BINARY ############################# + + + + + // Findet den auszuführenden Befehl + public void findOrder(string Order) + + { + string OrderBinary; + string Reduced; + // Hex to Int Umrechnung Funktionsaufruf + OrderBinary = hex2binary(Order); + + + // 14 Zeichen + + Reduced = OrderBinary; + if (Reduced.Equals(NOP1)) + { + MessageBox.Show("Erfolgreich NOP1" + Reduced); + } + else if (Reduced.Equals(NOP2)) + { + MessageBox.Show("Erfolgreich NOP2" + Reduced); + } + else if (Reduced.Equals(NOP3)) + { + MessageBox.Show("Erfolgreich NOP3" + Reduced); + } + else if (Reduced.Equals(NOP4)) + { + MessageBox.Show("Erfolgreich NOP4" + Reduced); + } + else if (Reduced.Equals(CLRWDT)) + { + MessageBox.Show("Erfolgreich CLRWDT" + Reduced); + } + else if (Reduced.Equals(RETFIE)) + { + MessageBox.Show("Erfolgreich RETFIE" + Reduced); + } + else if (Reduced.Equals(RETURN)) + { + MessageBox.Show("Erfolgreich RETURN" + Reduced); + } + else if (Reduced.Equals(SLEEP)) + { + MessageBox.Show("Erfolgreich SLEEP" + Reduced); + } + + else + { // Reduzieren und Vergleich mit 7 Zeichen + Reduced = OrderBinary.Substring(0, 7); + } + + //7 Zeichen + if (Reduced.Equals(CLRF)) + { + MessageBox.Show("Erfolgreich CLRF" + Reduced); + } + else if (Reduced.Equals(CLRW)) + { + MessageBox.Show("Erfolgreich CLRW" + Reduced); + } + else if (Reduced.Equals(MOVWF)) + { + MessageBox.Show("Erfolgreich MOVWF" + Reduced); + } + + else { + // Reduzieren und Vergleich mit 6 Zeichen + Reduced = OrderBinary.Substring(0, 6); + } + + // 6 Zeichen + + if (Reduced.Equals(ANDWF)) + { + MessageBox.Show("Erfolgreich ANDWF " + Reduced); + } + else if (Reduced.Equals(COMF)) + { + MessageBox.Show("Erfolgreich COMF " + Reduced); + } + else if (Reduced.Equals(DECF)) + { + MessageBox.Show("Erfolgreich DECF " + Reduced); + } + else if (Reduced.Equals(DECFSZ)) + { + MessageBox.Show("Erfolgreich DECFSZ " + Reduced); + } + else if (Reduced.Equals(INCF)) + { + MessageBox.Show("Erfolgreich INCF " + Reduced); + } + else if (Reduced.Equals(INCFSZ)) + { + MessageBox.Show("Erfolgreich INCFSZ " + Reduced); + } + else if (Reduced.Equals(IORWF)) + { + MessageBox.Show("Erfolgreich IORWF " + Reduced); + } + else if (Reduced.Equals(MOVF)) + { + MessageBox.Show("Erfolgreich MOVF " + Reduced); + } + else if (Reduced.Equals(RLF)) + { + MessageBox.Show("Erfolgreich RLF " + Reduced); + } + else if (Reduced.Equals(RRF)) + { + MessageBox.Show("Erfolgreich RRF " + Reduced); + } + else if (Reduced.Equals(SUBWF)) + { + MessageBox.Show("Erfolgreich SUBWF " + Reduced); + } + else if (Reduced.Equals(SWAPF)) + { + MessageBox.Show("Erfolgreich SWAPF " + Reduced); + } + else if (Reduced.Equals(XORWF)) + { + MessageBox.Show("Erfolgreich XORWF " + Reduced); + } + else if (Reduced.Equals(ANDLW)) + { + MessageBox.Show("Erfolgreich ANDLW " + Reduced); + } + else if (Reduced.Equals(IORLW)) + { + MessageBox.Show("Erfolgreich IORLW " + Reduced); + } + else if (Reduced.Equals(XORLW)) + { + MessageBox.Show("Erfolgreich XORLW " + Reduced); + } + else + { // Reduzieren und Vergleich mit 5 Zeichen + Reduced = OrderBinary.Substring(0, 5); + } + + // 5 Zeichen + + if (Reduced.Equals(SUBLW)) + { + MessageBox.Show("Erfolgreich SUBLW " + Reduced); + } + else if (Reduced.Equals(ADDLW)) + { + MessageBox.Show("Erfolgreich ADDLW " + Reduced); + } + + else + { // Reduzieren und Vergleich mit 4 Zeichen + Reduced = OrderBinary.Substring(0, 4); + } + + + + //4 Zeichen + + if (Reduced.Equals(BCF)) + { + MessageBox.Show("Erfolgreich BCF " + Reduced); + } + else if (Reduced.Equals(BSF)) + { + MessageBox.Show("Erfolgreich BSF " + Reduced); + } + else if (Reduced.Equals(BTFSC)) + { + MessageBox.Show("Erfolgreich DBTFSC " + Reduced); + } + else if (Reduced.Equals(BTFSS)) + { + MessageBox.Show("Erfolgreich BTFSS " + Reduced); + } + else if (Reduced.Equals(MOVLW)) + { + MessageBox.Show("Erfolgreich MOVLW " + Reduced); + } + else if (Reduced.Equals(RETLW)) + { + MessageBox.Show("Erfolgreich RETLW " + Reduced); + } + + else + {// Reduzieren und Vergleich mit 3 Zeichen + Reduced = OrderBinary.Substring(0, 3); + } + + + if (Reduced.Equals(CALL)) + { + MessageBox.Show("Erfolgreich CALL " + Reduced); + } + else if (Reduced.Equals(GOTO)) + { + MessageBox.Show("Erfolgreich GOTO " + Reduced); + } + + else { } + + + + } + + + + private string hex2binary(string hexvalue) + { + string binaryval = ""; + binaryval = Convert.ToString(Convert.ToInt32(hexvalue, 16), 2).PadLeft(14,'0'); + return binaryval; + } + + + private void fillpicmemory() + { + int[] line1 = new int[8]; + int[] line2 = new int[8]; + int[] line3 = new int[8]; + int[] line4 = new int[8]; + int[] line5 = new int[8]; + int[] line6 = new int[8]; + int[] line7 = new int[8]; + int[] line8 = new int[8]; + int[] line9 = new int[8]; + int[] line10 = new int[8]; + int[] line11 = new int[8]; + int[] line12 = new int[8]; + int[] line13 = new int[8]; + int[] line14 = new int[8]; + int[] line15 = new int[8]; + int[] line16 = new int[8]; + int[] line17 = new int[8]; + int[] line18 = new int[8]; + int[] line19 = new int[8]; + int[] line20 = new int[8]; + int[] line21 = new int[8]; + int[] line22 = new int[8]; + int[] line23 = new int[8]; + int[] line24 = new int[8]; + int[] line25 = new int[8]; + int[] line26 = new int[8]; + int[] line27 = new int[8]; + int[] line28 = new int[8]; + int[] line29 = new int[8]; + int[] line30 = new int[8]; + int[] line31 = new int[8]; + } + + + + + + } +} diff --git a/Projektinformationen/Auswertungstabelle_Simulator_2016.pdf b/Projektinformationen/Auswertungstabelle_Simulator_2016.pdf new file mode 100644 index 0000000..820c6db Binary files /dev/null and b/Projektinformationen/Auswertungstabelle_Simulator_2016.pdf differ diff --git a/Projektinformationen/DataSheet.pdf b/Projektinformationen/DataSheet.pdf new file mode 100644 index 0000000..301adeb Binary files /dev/null and b/Projektinformationen/DataSheet.pdf differ diff --git a/Projektinformationen/Datenblatt.pdf b/Projektinformationen/Datenblatt.pdf new file mode 100644 index 0000000..301adeb Binary files /dev/null and b/Projektinformationen/Datenblatt.pdf differ diff --git a/Projektinformationen/Lastenheft.docx b/Projektinformationen/Lastenheft.docx new file mode 100644 index 0000000..41db899 Binary files /dev/null and b/Projektinformationen/Lastenheft.docx differ diff --git a/Projektinformationen/Neues Textdokument.txt b/Projektinformationen/Neues Textdokument.txt new file mode 100644 index 0000000..e69de29 diff --git a/Projektinformationen/PIC Commands.txt b/Projektinformationen/PIC Commands.txt new file mode 100644 index 0000000..7ecec8f --- /dev/null +++ b/Projektinformationen/PIC Commands.txt @@ -0,0 +1,43 @@ +--- Byte-Oriented File Register Operations --- +ADDWF | 6 | 00 0111 dfff ffff +ANDWF | 6 | 00 0101 dfff ffff +CLRF | 7 | 00 0001 1fff ffff +CLRW | 7 | 00 0001 0xxx xxxx +COMF | 6 | 00 1001 dfff ffff +DECF | 6 | 00 0011 dfff ffff +DECFSZ | 6 | 00 1011 dfff ffff +INCF | 6 | 00 1010 dfff ffff +INCFSZ | 6 | 00 1111 dfff ffff +IORWF | 6 | 00 0100 dfff ffff +MOVF | 6 | 00 1000 dfff ffff +MOVWF | 7 | 00 0000 1fff ffff +NOP1 | 14 | 00 0000 0000 0000 +NOP2 | 14 | 00 0000 0010 0000 +NOP3 | 14 | 00 0000 0100 0000 +NOP4 | 14 | 00 0000 0110 0000 +RLF | 6 | 00 1101 dfff ffff +RRF | 6 | 00 1100 dfff ffff +SUBWF | 6 | 00 0010 dfff ffff +SWAPF | 6 | 00 1110 dfff ffff +XORWF | 6 | 00 0110 dfff ffff + +--- Bit-Oriented File Register Operations --- +BCF | 4 | 01 00bb bfff ffff +BSF | 4 | 01 01bb bfff ffff +BTFSC | 4 | 01 10bb bfff ffff +BTFSS | 4 | 01 11bb bfff ffff + +--- Literal and Control Operations --- +ADDLW | 5 | 11 111x kkkk kkkk +ANDLW | 6 | 11 1001 kkkk kkkk +CALL | 3 | 10 0kkk kkkk kkkk +CLRWDT | 14 | 00 0000 0110 0100 +GOTO | 3 | 10 1kkk kkkk kkkk +IORLW | 6 | 11 1000 kkkk kkkk +MOVLW | 4 | 11 00xx kkkk kkkk +RETFIE | 14 | 00 0000 0000 1001 +RETLW | 4 | 11 01xx kkkk kkkk +RETURN | 14 | 00 0000 0000 1000 +SLEEP | 14 | 00 0000 0110 0011 +SUBLW | 5 | 11 110x kkkk kkkk +XORLW | 6 | 11 1010 kkkk kkkk \ No newline at end of file diff --git a/Projektinformationen/Projekt_Simulator.pdf b/Projektinformationen/Projekt_Simulator.pdf new file mode 100644 index 0000000..1a99e9f Binary files /dev/null and b/Projektinformationen/Projekt_Simulator.pdf differ diff --git a/TPicSim Testprogramme/TPicSim1.LST b/TPicSim Testprogramme/TPicSim1.LST new file mode 100644 index 0000000..34e211d --- /dev/null +++ b/TPicSim Testprogramme/TPicSim1.LST @@ -0,0 +1,35 @@ + 00001 ;TPicSim1 + 00002 ;Programm zum Test des 16F84-Simulators. + 00003 ;Es werden alle Literal-Befehle geprüft + 00004 ;(c) St. Lehmann + 00005 ;Ersterstellung: 23.03.2016 + 00006 ; + 00007 list c=132 ;Zeilenlänge im LST auf 132 Zeichen setzen + 00008 + 00009 ;Definition einiger Symbole + 00010 ;zuerst Hardware-Register + 00011 status equ 03h + 00012 ra equ 05h + 00013 rb equ 06h + 00014 + 00015 ;für den Benutzer frei verwendbare Register + 00016 count equ 0ch + 00017 + 00018 ;Definition des Prozessors + 00019 device 16F84 + 00020 + 00021 ;Festlegen des Codebeginns + 00022 org 0 + 00023 start +0000 3011 00024 movlw 11h ;in W steht nun 11h, Statusreg. unverändert +0001 3930 00025 andlw 30h ;W = 10h, C=x, DC=x, Z=0 +0002 380D 00026 iorlw 0Dh ;W = 1Dh, C=x, DC=x, Z=0 +0003 3C3D 00027 sublw 3Dh ;W = 20h, C=1, DC=1, Z=0 +0004 3A20 00028 xorlw 20h ;W = 00h, C=1, DC=1, Z=1 +0005 3E25 00029 addlw 25h ;W = 25h, C=0, DC=0, Z=0 + 00030 + 00031 + 00032 ende +0006 2806 00033 goto ende ;Endlosschleife, verhindert Nirwana + 00034 + 00035 diff --git a/TPicSim Testprogramme/TPicSim1.src b/TPicSim Testprogramme/TPicSim1.src new file mode 100644 index 0000000..e105a0c --- /dev/null +++ b/TPicSim Testprogramme/TPicSim1.src @@ -0,0 +1,33 @@ +;TPicSim1 +;Programm zum Test des 16F84-Simulators. +;Es werden alle Literal-Befehle gepr?ft +;(c) St. Lehmann +;Ersterstellung: 23.03.2016 +; + +;Definition einiger Symbole +;zuerst Hardware-Register +status equ 03h +ra equ 05h +rb equ 06h + +;f?r den Benutzer frei verwendbare Register +count equ 0ch + +;Definition des Prozessors + device 16F84 + +;Festlegen des Codebeginns + org 0 +start + movlw 11h ;in W steht nun 11h, Statusreg. unver?ndert + andlw 30h ;W = 10h, C=x, DC=x, Z=0 + iorlw 0Dh ;W = 1Dh, C=x, DC=x, Z=0 + sublw 3Dh ;W = 20h, C=1, DC=1, Z=0 + xorlw 20h ;W = 00h, C=1, DC=1, Z=1 + addlw 25h ;W = 25h, C=0, DC=0, Z=0 + + +ende + goto ende ;Endlosschleife, verhindert Nirwana + diff --git a/TPicSim Testprogramme/TPicSim10.LST b/TPicSim Testprogramme/TPicSim10.LST new file mode 100644 index 0000000..e278d44 --- /dev/null +++ b/TPicSim Testprogramme/TPicSim10.LST @@ -0,0 +1,314 @@ + 00001 ;TPicSim10 + 00002 ;Programm zum Test des 16F84-Simulators. + 00003 ;Es wird die richtige Funktionsweise von PCL und PCLATH am Beispiel + 00004 ;eines Tabellenzugriffs getestet + 00005 ;(c) St. Lehmann + 00006 ;19.04.2014 + 00007 + 00008 list c=132 ;Zeilenlänge im LST auf 132 Zeichen setzen + 00009 + 00010 ;Definition einiger Symbole + 00011 indirect equ 0 + 00012 pcl equ 02h + 00013 status equ 03h + 00014 fsr equ 04h + 00015 ra equ 05h + 00016 rb equ 06h + 00017 pclath equ 0ah + 00018 intcon equ 0bh + 00019 + 00020 ;Definition des Prozessors + 00021 device 16F84 + 00022 ;Festlegen des Codebeginns + 00023 org 0 + 00024 start +0000 3000 00025 movlw 0 ;Index für Tabellenzugriff in 0FH +0001 008F 00026 movwf 0fh +0002 3005 00027 movlw 5 ;insgesamt 5 Tabellenzugriffe +0003 008E 00028 movwf 0eh +0004 3010 00029 movlw 10h ;Ergebnis wird ab 10H abgespeichert +0005 0084 00030 movwf fsr + 00031 loop +0006 3001 00032 movlw 1 ;PCLATH setzen, damit auf den Bereich 256-511 zugegriffen werden kann +0007 008A 00033 movwf pclath +0008 080F 00034 movf 0fh,w +0009 2109 00035 call tabelle +000A 0080 00036 movwf indirect +000B 0A84 00037 incf fsr +000C 0A8F 00038 incf 0fh +000D 0B8E 00039 decfsz 0eh +000E 2806 00040 goto loop +000F 018A 00041 clrf pclath +0010 080F 00042 movf 0fh,w +0011 2109 00043 call tabelle ;Fehler, der ADDWF PCL kommt nicht in die Tabelle. Grund: in W steht 5 + 00044 ;im PC 109 bzw. nach dem Fetch 10A. Zu diesem Wert wird 5 addiert und + 00045 ;die oberen Bits auf 0 gesetzt (PCLATH=0). Damit steht im PC der Wert + 00046 ;0Fh. Dorthin springt der PIC durch den ADDWF-Befehl. Hier verweilt + 00047 ;das Programm während der Stack immer weiter wächst. + 00048 + 00049 + 00050 ende +0012 2812 00051 goto ende ;Endlosschleife, verhindert Nirwana + 00052 +0013 0000 00053 nop +0014 0000 00054 nop +0015 0000 00055 nop +0016 0000 00056 nop +0017 0000 00057 nop +0018 0000 00058 nop +0019 0000 00059 nop +001A 0000 00060 nop +001B 0000 00061 nop +001C 0000 00062 nop +001D 0000 00063 nop +001E 0000 00064 nop +001F 0000 00065 nop +0020 0000 00066 nop +0021 0000 00067 nop +0022 0000 00068 nop +0023 0000 00069 nop +0024 0000 00070 nop +0025 0000 00071 nop +0026 0000 00072 nop +0027 0000 00073 nop +0028 0000 00074 nop +0029 0000 00075 nop +002A 0000 00076 nop +002B 0000 00077 nop +002C 0000 00078 nop +002D 0000 00079 nop +002E 0000 00080 nop +002F 0000 00081 nop +0030 0000 00082 nop +0031 0000 00083 nop +0032 0000 00084 nop +0033 0000 00085 nop +0034 0000 00086 nop +0035 0000 00087 nop +0036 0000 00088 nop +0037 0000 00089 nop +0038 0000 00090 nop +0039 0000 00091 nop +003A 0000 00092 nop +003B 0000 00093 nop +003C 0000 00094 nop +003D 0000 00095 nop +003E 0000 00096 nop +003F 0000 00097 nop +0040 0000 00098 nop +0041 0000 00099 nop +0042 0000 00100 nop +0043 0000 00101 nop +0044 0000 00102 nop +0045 0000 00103 nop +0046 0000 00104 nop +0047 0000 00105 nop +0048 0000 00106 nop +0049 0000 00107 nop +004A 0000 00108 nop +004B 0000 00109 nop +004C 0000 00110 nop +004D 0000 00111 nop +004E 0000 00112 nop +004F 0000 00113 nop +0050 0000 00114 nop +0051 0000 00115 nop +0052 0000 00116 nop +0053 0000 00117 nop +0054 0000 00118 nop +0055 0000 00119 nop +0056 0000 00120 nop +0057 0000 00121 nop +0058 0000 00122 nop +0059 0000 00123 nop +005A 0000 00124 nop +005B 0000 00125 nop +005C 0000 00126 nop +005D 0000 00127 nop +005E 0000 00128 nop +005F 0000 00129 nop +0060 0000 00130 nop +0061 0000 00131 nop +0062 0000 00132 nop +0063 0000 00133 nop +0064 0000 00134 nop +0065 0000 00135 nop +0066 0000 00136 nop +0067 0000 00137 nop +0068 0000 00138 nop +0069 0000 00139 nop +006A 0000 00140 nop +006B 0000 00141 nop +006C 0000 00142 nop +006D 0000 00143 nop +006E 0000 00144 nop +006F 0000 00145 nop +0070 0000 00146 nop +0071 0000 00147 nop +0072 0000 00148 nop +0073 0000 00149 nop +0074 0000 00150 nop +0075 0000 00151 nop +0076 0000 00152 nop +0077 0000 00153 nop +0078 0000 00154 nop +0079 0000 00155 nop +007A 0000 00156 nop +007B 0000 00157 nop +007C 0000 00158 nop +007D 0000 00159 nop +007E 0000 00160 nop +007F 0000 00161 nop +0080 0000 00162 nop +0081 0000 00163 nop +0082 0000 00164 nop +0083 0000 00165 nop +0084 0000 00166 nop +0085 0000 00167 nop +0086 0000 00168 nop +0087 0000 00169 nop +0088 0000 00170 nop +0089 0000 00171 nop +008A 0000 00172 nop +008B 0000 00173 nop +008C 0000 00174 nop +008D 0000 00175 nop +008E 0000 00176 nop +008F 0000 00177 nop +0090 0000 00178 nop +0091 0000 00179 nop +0092 0000 00180 nop +0093 0000 00181 nop +0094 0000 00182 nop +0095 0000 00183 nop +0096 0000 00184 nop +0097 0000 00185 nop +0098 0000 00186 nop +0099 0000 00187 nop +009A 0000 00188 nop +009B 0000 00189 nop +009C 0000 00190 nop +009D 0000 00191 nop +009E 0000 00192 nop +009F 0000 00193 nop +00A0 0000 00194 nop +00A1 0000 00195 nop +00A2 0000 00196 nop +00A3 0000 00197 nop +00A4 0000 00198 nop +00A5 0000 00199 nop +00A6 0000 00200 nop +00A7 0000 00201 nop +00A8 0000 00202 nop +00A9 0000 00203 nop +00AA 0000 00204 nop +00AB 0000 00205 nop +00AC 0000 00206 nop +00AD 0000 00207 nop +00AE 0000 00208 nop +00AF 0000 00209 nop +00B0 0000 00210 nop +00B1 0000 00211 nop +00B2 0000 00212 nop +00B3 0000 00213 nop +00B4 0000 00214 nop +00B5 0000 00215 nop +00B6 0000 00216 nop +00B7 0000 00217 nop +00B8 0000 00218 nop +00B9 0000 00219 nop +00BA 0000 00220 nop +00BB 0000 00221 nop +00BC 0000 00222 nop +00BD 0000 00223 nop +00BE 0000 00224 nop +00BF 0000 00225 nop +00C0 0000 00226 nop +00C1 0000 00227 nop +00C2 0000 00228 nop +00C3 0000 00229 nop +00C4 0000 00230 nop +00C5 0000 00231 nop +00C6 0000 00232 nop +00C7 0000 00233 nop +00C8 0000 00234 nop +00C9 0000 00235 nop +00CA 0000 00236 nop +00CB 0000 00237 nop +00CC 0000 00238 nop +00CD 0000 00239 nop +00CE 0000 00240 nop +00CF 0000 00241 nop +00D0 0000 00242 nop +00D1 0000 00243 nop +00D2 0000 00244 nop +00D3 0000 00245 nop +00D4 0000 00246 nop +00D5 0000 00247 nop +00D6 0000 00248 nop +00D7 0000 00249 nop +00D8 0000 00250 nop +00D9 0000 00251 nop +00DA 0000 00252 nop +00DB 0000 00253 nop +00DC 0000 00254 nop +00DD 0000 00255 nop +00DE 0000 00256 nop +00DF 0000 00257 nop +00E0 0000 00258 nop +00E1 0000 00259 nop +00E2 0000 00260 nop +00E3 0000 00261 nop +00E4 0000 00262 nop +00E5 0000 00263 nop +00E6 0000 00264 nop +00E7 0000 00265 nop +00E8 0000 00266 nop +00E9 0000 00267 nop +00EA 0000 00268 nop +00EB 0000 00269 nop +00EC 0000 00270 nop +00ED 0000 00271 nop +00EE 0000 00272 nop +00EF 0000 00273 nop +00F0 0000 00274 nop +00F1 0000 00275 nop +00F2 0000 00276 nop +00F3 0000 00277 nop +00F4 0000 00278 nop +00F5 0000 00279 nop +00F6 0000 00280 nop +00F7 0000 00281 nop +00F8 0000 00282 nop +00F9 0000 00283 nop +00FA 0000 00284 nop +00FB 0000 00285 nop +00FC 0000 00286 nop +00FD 0000 00287 nop +00FE 0000 00288 nop +00FF 0000 00289 nop +0100 0000 00290 nop +0101 0000 00291 nop +0102 0000 00292 nop +0103 0000 00293 nop +0104 0000 00294 nop +0105 0000 00295 nop +0106 0000 00296 nop +0107 0000 00297 nop +0108 0000 00298 nop + 00299 Tabelle +0109 0782 00300 addwf pcl +010A 3460 00301 retlw 60h +010B 3461 00302 retlw 61h +010C 3462 00303 retlw 62h +010D 3463 00304 retlw 63h +010E 3464 00305 retlw 64h +010F 3465 00306 retlw 65h +0110 3466 00307 retlw 66h +0111 3467 00308 retlw 67h +0112 3468 00309 retlw 68h +0113 3469 00310 retlw 69h +0114 346A 00311 retlw 6Ah + 00312 + 00313 + 00314 diff --git a/TPicSim Testprogramme/TPicSim10.src b/TPicSim Testprogramme/TPicSim10.src new file mode 100644 index 0000000..4bc8de3 --- /dev/null +++ b/TPicSim Testprogramme/TPicSim10.src @@ -0,0 +1,312 @@ +;TPicSim10 +;Programm zum Test des 16F84-Simulators. +;Es wird die richtige Funktionsweise von PCL und PCLATH am Beispiel +;eines Tabellenzugriffs getestet +;(c) St. Lehmann +;19.04.2014 + + +;Definition einiger Symbole +indirect equ 0 +pcl equ 02h +status equ 03h +fsr equ 04h +ra equ 05h +rb equ 06h +pclath equ 0ah +intcon equ 0bh + +;Definition des Prozessors + device 16F84 +;Festlegen des Codebeginns + org 0 +start + movlw 0 ;Index f?r Tabellenzugriff in 0FH + movwf 0fh + movlw 5 ;insgesamt 5 Tabellenzugriffe + movwf 0eh + movlw 10h ;Ergebnis wird ab 10H abgespeichert + movwf fsr +loop + movlw 1 ;PCLATH setzen, damit auf den Bereich 256-511 zugegriffen werden kann + movwf pclath + movf 0fh,w + call tabelle + movwf indirect + incf fsr + incf 0fh + decfsz 0eh + goto loop + clrf pclath + movf 0fh,w + call tabelle ;Fehler, der ADDWF PCL kommt nicht in die Tabelle. Grund: in W steht 5 +;im PC 109 bzw. nach dem Fetch 10A. Zu diesem Wert wird 5 addiert und +;die oberen Bits auf 0 gesetzt (PCLATH=0). Damit steht im PC der Wert +;0Fh. Dorthin springt der PIC durch den ADDWF-Befehl. Hier verweilt +;das Programm w?hrend der Stack immer weiter w?chst. + + +ende + goto ende ;Endlosschleife, verhindert Nirwana + + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop +Tabelle + addwf pcl + retlw 60h + retlw 61h + retlw 62h + retlw 63h + retlw 64h + retlw 65h + retlw 66h + retlw 67h + retlw 68h + retlw 69h + retlw 6Ah + + diff --git a/TPicSim Testprogramme/TPicSim11.LST b/TPicSim Testprogramme/TPicSim11.LST new file mode 100644 index 0000000..05adccc --- /dev/null +++ b/TPicSim Testprogramme/TPicSim11.LST @@ -0,0 +1,50 @@ + 00001 ;TPicSim11 + 00002 ;Programm zum Test des 16F84-Simulators. + 00003 ;Es wird der Watchdog mit und ohne Vorteiler geprüft + 00004 ;(c) St. Lehmann + 00005 ;19.04.2014 + 00006 + 00007 list c=132 ;Zeilenlänge im LST auf 132 Zeichen setzen + 00008 + 00009 ;Definition einiger Symbole + 00010 indirect equ 0 + 00011 status equ 03h + 00012 fsr equ 04h + 00013 ra equ 05h + 00014 rb equ 06h + 00015 count equ 0ch + 00016 + 00017 ;Definition des Prozessors + 00018 device 16F84 + 00019 ;Festlegen des Codebeginns + 00020 org 0 + 00021 start + 00022 ;zuerst wird der VT dem Timer zugewiesen. Damit bekommt der Watchdog + 00023 ;die kleinste Zeit (ca. 18 ms) zugewiesen +0000 3000 00024 movlw 00000000B ;Option-Register entsp. initialisieren +0001 1683 00025 bsf status,5 ;Bank umschalten +0002 0081 00026 movwf 1 ;Option-Register +0003 1283 00027 bcf status,5 +0004 01A0 00028 clrf 20h +0005 01A1 00029 clrf 21h +0006 01A2 00030 clrf 22h +0007 01A3 00031 clrf 23h + 00032 loop1 +0008 0FA0 00033 incfsz 20h +0009 2808 00034 goto loop1 ;kein Überlauf +000A 0FA1 00035 incfsz 21h ;nächste Stelle +000B 2808 00036 goto loop1 ;kein Überlauf +000C 0FA2 00037 incfsz 22h ;ja +000D 2808 00038 goto loop1 +000E 0FA3 00039 incfsz 23h +000F 2808 00040 goto loop1 + 00041 + 00042 ;****************************************************************** + 00043 ;in 20h steht ca. 5fH + 00044 ;in 21H ca. 17H + 00045 ;Zählerstand 16-Bit ca. 175FH = 5983d + 00046 + 00047 ende +0010 2810 00048 goto ende ;Endlosschleife, verhindert Nirwana + 00049 + 00050 diff --git a/TPicSim Testprogramme/TPicSim11.src b/TPicSim Testprogramme/TPicSim11.src new file mode 100644 index 0000000..a87e937 --- /dev/null +++ b/TPicSim Testprogramme/TPicSim11.src @@ -0,0 +1,48 @@ +;TPicSim11 +;Programm zum Test des 16F84-Simulators. +;Es wird der Watchdog mit und ohne Vorteiler gepr?ft +;(c) St. Lehmann +;19.04.2014 + + +;Definition einiger Symbole +indirect equ 0 +status equ 03h +fsr equ 04h +ra equ 05h +rb equ 06h +count equ 0ch + +;Definition des Prozessors + device 16F84 +;Festlegen des Codebeginns + org 0 +start +;zuerst wird der VT dem Timer zugewiesen. Damit bekommt der Watchdog +;die kleinste Zeit (ca. 18 ms) zugewiesen + movlw 00000000B ;Option-Register entsp. initialisieren + bsf status,5 ;Bank umschalten + movwf 1 ;Option-Register + bcf status,5 + clrf 20h + clrf 21h + clrf 22h + clrf 23h +loop1 + incfsz 20h + goto loop1 ;kein ?berlauf + incfsz 21h ;n?chste Stelle + goto loop1 ;kein ?berlauf + incfsz 22h ;ja + goto loop1 + incfsz 23h + goto loop1 + +;****************************************************************** +;in 20h steht ca. 5fH +;in 21H ca. 17H +;Z?hlerstand 16-Bit ca. 175FH = 5983d + +ende + goto ende ;Endlosschleife, verhindert Nirwana + diff --git a/TPicSim Testprogramme/TPicSim12.LST b/TPicSim Testprogramme/TPicSim12.LST new file mode 100644 index 0000000..b9b64c5 --- /dev/null +++ b/TPicSim Testprogramme/TPicSim12.LST @@ -0,0 +1,78 @@ + 00001 ;TPicSim12 + 00002 ;Programm zum Test des 16F84-Simulators. + 00003 ;Funktion: Beschreiben und Lesen des EEPROMs + 00004 ;(c) St. Lehmann Ersterstellung: 11.05.2011 + 00005 ;Definition einiger Symbole + 00006 + 00007 list c=132 ;Zeilenlänge im LST auf 132 Zeichen setzen + 00008 + 00009 indirect equ 0 + 00010 status equ 03h + 00011 fsr equ 04h + 00012 ra equ 05h + 00013 rb equ 06h + 00014 count equ 0ch + 00015 eedata equ 08h + 00016 eeaddr equ 09h + 00017 eecon1 equ 08h ;auf Bank 1 + 00018 eecon2 equ 09h ;auf Bank 1 + 00019 + 00020 ;Definition des Prozessors + 00021 device 16F84 + 00022 + 00023 ;Festlegen des Codebeginns + 00024 org 0 + 00025 start +0000 3000 00026 movlw 0 ;der EEPROM-Speicher von 0 bis 3FH (63) gefüllt +0001 008C 00027 movwf count + 00028 schreiben +0002 080C 00029 movf count,w +0003 0089 00030 movwf eeaddr ;diese Adresse soll beschrieben werden +0004 3AFF 00031 xorlw 255 ;Adresse invertieren +0005 0088 00032 movwf eedata ;dieser Wert an obige Adresse schreiben + 00033 +0006 1683 00034 bsf status,5 ;auf Bank 1 +0007 1208 00035 bcf eecon1,4 ;EEIF zurücksetzen, wird überwacht +0008 1508 00036 bsf eecon1,2 ;WREN-Bit setzen, sonst kein schreiben möglich +0009 1488 00037 bsf eecon1,1 ;WR-Bit setzen + 00038 +000A 3055 00039 movlw 55h ;State-Machine anwerfen +000B 0089 00040 movwf eecon2 +000C 30AA 00041 movlw 0AAh +000D 0089 00042 movwf eecon2 ;Schreibvorgang beginnt jetzt + 00043 + 00044 warte +000E 1E08 00045 btfss eecon1,4 ;warte bis EEIF auf 1 ist +000F 280E 00046 goto warte + 00047 +0010 1108 00048 bcf eecon1,2 ;WREN auf 0 + 00049 +0011 1283 00050 bcf status,5 ;zurück auf Bank 0 + 00051 +0012 0A8C 00052 incf count +0013 080C 00053 movf count,w ;ist der Wert 40H erreicht +0014 3C40 00054 sublw 40h +0015 1D03 00055 btfss status,2 ;wenn 0, dann fertig +0016 2802 00056 goto schreiben + 00057 + 00058 +0017 018C 00059 clrf count ;jetzt gesamten Speicher lesen + 00060 lesen: +0018 080C 00061 movf count,w +0019 0089 00062 movwf eeaddr + 00063 +001A 1683 00064 bsf status,5 ;auf Bank 1 +001B 1408 00065 bsf eecon1,0 ;RD-Bit auf 1, wird vom PIC wieder auf 0 gesetzt +001C 1283 00066 bcf status,5 ;zurück auf Bank 0 + 00067 +001D 0808 00068 movf eedata,w ;Wert ins W-Register + 00069 +001E 0A8C 00070 incf count +001F 080C 00071 movf count,w ;ist der Wert 40H erreicht +0020 3C40 00072 sublw 40h +0021 1D03 00073 btfss status,2 ;wenn 0, dann fertig +0022 2818 00074 goto lesen + 00075 + 00076 ende +0023 2823 00077 goto ende + 00078 diff --git a/TPicSim Testprogramme/TPicSim12.src b/TPicSim Testprogramme/TPicSim12.src new file mode 100644 index 0000000..14194a8 --- /dev/null +++ b/TPicSim Testprogramme/TPicSim12.src @@ -0,0 +1,76 @@ +;TPicSim12 +;Programm zum Test des 16F84-Simulators. +;Funktion: Beschreiben und Lesen des EEPROMs +;(c) St. Lehmann Ersterstellung: 11.05.2011 +;Definition einiger Symbole + + +indirect equ 0 +status equ 03h +fsr equ 04h +ra equ 05h +rb equ 06h +count equ 0ch +eedata equ 08h +eeaddr equ 09h +eecon1 equ 08h ;auf Bank 1 +eecon2 equ 09h ;auf Bank 1 + +;Definition des Prozessors + device 16F84 + +;Festlegen des Codebeginns + org 0 +start + movlw 0 ;der EEPROM-Speicher von 0 bis 3FH (63) gef?llt + movwf count +schreiben + movf count,w + movwf eeaddr ;diese Adresse soll beschrieben werden + xorlw 255 ;Adresse invertieren + movwf eedata ;dieser Wert an obige Adresse schreiben + + bsf status,5 ;auf Bank 1 + bcf eecon1,4 ;EEIF zur?cksetzen, wird ?berwacht + bsf eecon1,2 ;WREN-Bit setzen, sonst kein schreiben m?glich + bsf eecon1,1 ;WR-Bit setzen + + movlw 55h ;State-Machine anwerfen + movwf eecon2 + movlw 0AAh + movwf eecon2 ;Schreibvorgang beginnt jetzt + +warte + btfss eecon1,4 ;warte bis EEIF auf 1 ist + goto warte + + bcf eecon1,2 ;WREN auf 0 + + bcf status,5 ;zur?ck auf Bank 0 + + incf count + movf count,w ;ist der Wert 40H erreicht + sublw 40h + btfss status,2 ;wenn 0, dann fertig + goto schreiben + + + clrf count ;jetzt gesamten Speicher lesen +lesen: + movf count,w + movwf eeaddr + + bsf status,5 ;auf Bank 1 + bsf eecon1,0 ;RD-Bit auf 1, wird vom PIC wieder auf 0 gesetzt + bcf status,5 ;zur?ck auf Bank 0 + + movf eedata,w ;Wert ins W-Register + + incf count + movf count,w ;ist der Wert 40H erreicht + sublw 40h + btfss status,2 ;wenn 0, dann fertig + goto lesen + +ende + goto ende diff --git a/TPicSim Testprogramme/TPicSim13.LST b/TPicSim Testprogramme/TPicSim13.LST new file mode 100644 index 0000000..7928284 --- /dev/null +++ b/TPicSim Testprogramme/TPicSim13.LST @@ -0,0 +1,78 @@ + 00001 ;TPicSim12 + 00002 ;Programm zum Test des 16F84-Simulators. + 00003 ;Funktion: Beschreiben und Lesen des EEPROMs + 00004 ;(c) St. Lehmann Ersterstellung: 11.05.2011 + 00005 ;Definition einiger Symbole + 00006 + 00007 list c=132 ;Zeilenlänge im LST auf 132 Zeichen setzen + 00008 + 00009 indirect equ 0 + 00010 status equ 03h + 00011 fsr equ 04h + 00012 ra equ 05h + 00013 rb equ 06h + 00014 count equ 0ch + 00015 eedata equ 08h + 00016 eeaddr equ 09h + 00017 eecon1 equ 08h ;auf Bank 1 + 00018 eecon2 equ 09h ;auf Bank 1 + 00019 + 00020 ;Definition des Prozessors + 00021 device 16F84 + 00022 + 00023 ;Festlegen des Codebeginns + 00024 org 0 + 00025 start +0000 0020 00026 movlw 0 ;der EEPROM-Speicher von 0 bis 3FH (63) gefüllt +0001 0060 00027 movwf count + 00028 schreiben +0002 0040 00029 movf count,w +0003 0000 00030 movwf eeaddr ;diese Adresse soll beschrieben werden +0004 3AFF 00031 xorlw 255 ;Adresse invertieren +0005 0088 00032 movwf eedata ;dieser Wert an obige Adresse schreiben + 00033 +0006 1683 00034 bsf status,5 ;auf Bank 1 +0007 1208 00035 bcf eecon1,4 ;EEIF zurücksetzen, wird überwacht +0008 1508 00036 bsf eecon1,2 ;WREN-Bit setzen, sonst kein schreiben möglich +0009 1488 00037 bsf eecon1,1 ;WR-Bit setzen + 00038 +000A 3055 00039 movlw 55h ;State-Machine anwerfen +000B 0089 00040 movwf eecon2 +000C 30AA 00041 movlw 0AAh +000D 0089 00042 movwf eecon2 ;Schreibvorgang beginnt jetzt + 00043 + 00044 warte +000E 1E08 00045 btfss eecon1,4 ;warte bis EEIF auf 1 ist +000F 280E 00046 goto warte + 00047 +0010 1108 00048 bcf eecon1,2 ;WREN auf 0 + 00049 +0011 1283 00050 bcf status,5 ;zurück auf Bank 0 + 00051 +0012 0A8C 00052 incf count +0013 080C 00053 movf count,w ;ist der Wert 40H erreicht +0014 3C40 00054 sublw 40h +0015 1D03 00055 btfss status,2 ;wenn 0, dann fertig +0016 2802 00056 goto schreiben + 00057 + 00058 +0017 018C 00059 clrf count ;jetzt gesamten Speicher lesen + 00060 lesen: +0018 080C 00061 movf count,w +0019 0089 00062 movwf eeaddr + 00063 +001A 1683 00064 bsf status,5 ;auf Bank 1 +001B 1408 00065 bsf eecon1,0 ;RD-Bit auf 1, wird vom PIC wieder auf 0 gesetzt +001C 1283 00066 bcf status,5 ;zurück auf Bank 0 + 00067 +001D 0808 00068 movf eedata,w ;Wert ins W-Register + 00069 +001E 0A8C 00070 incf count +001F 080C 00071 movf count,w ;ist der Wert 40H erreicht +0020 3C40 00072 sublw 40h +0021 1D03 00073 btfss status,2 ;wenn 0, dann fertig +0022 2818 00074 goto lesen + 00075 + 00076 ende +0023 2823 00077 goto ende + 00078 diff --git a/TPicSim Testprogramme/TPicSim2.LST b/TPicSim Testprogramme/TPicSim2.LST new file mode 100644 index 0000000..7507b31 --- /dev/null +++ b/TPicSim Testprogramme/TPicSim2.LST @@ -0,0 +1,41 @@ + 00001 ;TPicSim2 + 00002 ;Programm zum Test des 16F84-Simulators. + 00003 ;Es werden CALL, GOTO, RETLW, RETURN geprüft (kein RETFIE) + 00004 ;(c) St. Lehmann + 00005 ;Ersterstellung: 23.03.2016 + 00006 ; + 00007 list c=132 ;Zeilenlänge im LST auf 132 Zeichen setzen + 00008 + 00009 ;Definition einiger Symbole + 00010 ;zuerst Hardware-Register + 00011 status equ 03h + 00012 ra equ 05h + 00013 rb equ 06h + 00014 + 00015 ;für den Benutzer frei verwendbare Register + 00016 count equ 0ch + 00017 + 00018 ;Definition des Prozessors + 00019 device 16F84 + 00020 + 00021 ;Festlegen des Codebeginns + 00022 org 0 + 00023 loop +0000 3011 00024 movlw 11h ;in W steht nun 11h, Statusreg. unverändert +0001 2006 00025 call up1 ;beim Call wird Rücksprungadresse auf Stack gelegt +0002 0000 00026 nop ;W = 36h, C=0, DC=0, Z=0 +0003 2008 00027 call up2 ;in W steht der Rückgabewert +0004 0000 00028 nop ;W = 77h, DC=0, C=0, Z=0; +0005 2800 00029 goto loop + 00030 + 00031 ;UP1 zählt zu W den Wert 25h hinzu und kehrt mit RETURN zurück +0006 3E25 00032 up1 addlw 25h ;W = 36h, DC=0, C=0, Z=0 +0007 0008 00033 return + 00034 + 00035 ;UP2 kehrt mit der Konstanten 77h zurück +0008 3477 00036 up2 retlw 77h + 00037 + 00038 ende +0009 2809 00039 goto ende ;Endlosschleife, verhindert Nirwana + 00040 + 00041 diff --git a/TPicSim Testprogramme/TPicSim3.LST b/TPicSim Testprogramme/TPicSim3.LST new file mode 100644 index 0000000..68565da --- /dev/null +++ b/TPicSim Testprogramme/TPicSim3.LST @@ -0,0 +1,64 @@ + 00001 ;TPicSim3 + 00002 ;Programm zum Test des 16F84-Simulators. + 00003 ;Es werden die Byte-orientieren File-Register Befehle geprüft + 00004 ;aber kein DECFSZ, INCFSZ, RLF, RRF + 00005 ;(c) St. Lehmann + 00006 ;Ersterstellung: 23.03.2016 + 00007 + 00008 ;Hinweis: + 00009 ;Bei diesen Befehlen entscheidet das d-Bit (Destination), ob das Ergebnis + 00010 ;dieser Operation ins W- oder File-Register geschrieben wird. Wird im + 00011 ;Assemblercode der Befehl mit ",W" geschrieben, bedeutet dies, dass das + 00012 ;d-Bit 0 ist und das Ergebnis ins W-Register kommt. Fehlt ",W" ist das + 00013 ;d-Bit 1 und das Ergebnis wird ins Fileregister geschrieben. + 00014 ; + 00015 ;Alle Befehle die eine Fileregister-Adresse haben, können auch "indirekt" + 00016 ;adressieren. Dies ist im Testfile TPicSim6.LST beschrieben. + 00017 ; + 00018 list c=132 ;Zeilenlänge im LST auf 132 Zeichen setzen + 00019 + 00020 ;Definition einiger Symbole + 00021 ;zuerst Hardware-Register + 00022 status equ 03h + 00023 ra equ 05h + 00024 rb equ 06h + 00025 + 00026 ;für den Benutzer frei verwendbare Register + 00027 wert1 equ 0ch ;Variable Nr.1 + 00028 wert2 equ 0dh ;Variable Nr.2 + 00029 ergeb equ 0eh ;Variable Nr.3 + 00030 + 00031 ;Definition des Prozessors + 00032 device 16F84 + 00033 + 00034 ;Festlegen des Codebeginns + 00035 org 0 + 00036 loop +0000 3011 00037 movlw 11h ;in W steht nun 11h, DC=?, C=?, Z=? +0001 008C 00038 movwf wert1 ;diesen Wert abspeichern, DC=?, C=?, Z=? +0002 3014 00039 movlw 14h ;W = 14h, DC=?, C=?, Z=? +0003 070C 00040 addwf wert1,w ;W = 25h, DC=0, C=0, Z=0 +0004 078C 00041 addwf wert1 ;W = 25h, wert1 = 36h, DC=0, C=0, Z=0 +0005 050C 00042 andwf wert1,w ;W = 24h, wert1 = 36h, DC=0, C=0, Z=0 +0006 008D 00043 movwf wert2 ;W=24h, wert1=36, wert2=24h +0007 018C 00044 clrf wert1 ;W=24h, wert1=0, wert2=24h, DC=0, C=0, Z=1 +0008 090D 00045 comf wert2,w ;W=DBh, wert1=0, wert2=24h, DC=0, C=0, Z=0 +0009 030C 00046 decf wert1,w ;W=FFh, wert1=0, wert2=24h, DC=0, C=0, Z=0 +000A 0A8D 00047 incf wert2 ;W=FFh, wert1=0, wert2=25h, DC=0, C=0, Z=0 +000B 088C 00048 movf wert1 ;W=FFh, wert1=0, wert2=25h, DC=0, C=0, Z=1 +000C 048C 00049 iorwf wert1 ;W=FFh, wert1=FFh, wert2=25h, DC=0, C=0, Z=0 +000D 020D 00050 subwf wert2,w ;W=26h, wert1=FFh, wert2=25h, DC=0, C=0, Z=0 +000E 0E8D 00051 swapf wert2 ;W=26h, wert1=FFh, wert2=52h, DC=0, C=0, Z=0 +000F 068C 00052 xorwf wert1 ;W=26h, wert1=D9h, wert2=52h, DC=0, C=0, Z=0 +0010 0100 00053 clrw ;W=00h, wert1=D9h, wert2=52h, DC=0, C=0, Z=1 + 00054 +0011 020C 00055 subwf wert1,w ;W=D9h, wert1=D9h, wert2=52h, DC=1, C=1, Z=0 +0012 020D 00056 subwf wert2,w ;W=79h, wert1=D9h, wert2=52h, DC=0, C=0, Z=0 +0013 028D 00057 subwf wert2 ;W=79h, wert1=D9h, wert2=D9h, DC=0, C=0, Z=0 +0014 028D 00058 subwf wert2 ;W=79h, wert1=D9h, wert2=60h, DC=1, C=1, Z=0 + 00059 + 00060 + 00061 ende +0015 2815 00062 goto ende ;Endlosschleife, verhindert Nirwana + 00063 + 00064 diff --git a/TPicSim Testprogramme/TPicSim4.LST b/TPicSim Testprogramme/TPicSim4.LST new file mode 100644 index 0000000..093da51 --- /dev/null +++ b/TPicSim Testprogramme/TPicSim4.LST @@ -0,0 +1,80 @@ + 00001 ;TPicSim4 + 00002 ;Programm zum Test des 16F84-Simulators. + 00003 ;Es werden die Befehle DECFSZ, INCFSZ, RLF, RRF geprüft + 00004 ;(c) St. Lehmann + 00005 ;Ersterstellung: 23.03.2016 + 00006 ; + 00007 list c=132 ;Zeilenlänge im LST auf 132 Zeichen setzen + 00008 + 00009 ;Definition einiger Symbole + 00010 ;zuerst Hardware-Register + 00011 status equ 03h + 00012 ra equ 05h + 00013 rb equ 06h + 00014 + 00015 ;für den Benutzer frei verwendbare Register + 00016 wert1 equ 0ch ;Variable Nr.1 + 00017 wert2 equ 0dh ;Variable Nr.2 + 00018 ergeb equ 0eh ;Variable Nr.3 + 00019 + 00020 ;Definition des Prozessors + 00021 device 16F84 + 00022 + 00023 ;Festlegen des Codebeginns + 00024 org 0 + 00025 loop +0000 3011 00026 movlw 11h ;in W steht nun 11h, DC=?, C=?, Z=? +0001 008C 00027 movwf wert1 ;diesen Wert abspeichern, DC=?, C=?, Z=? +0002 3E11 00028 addlw 11h ;löscht u.a. das Carry-Flag, DC=0, C=0, Z=0 +0003 0D8C 00029 rlf wert1 ;W=22h, wert1=22h, wert2=?? , DC=0, C=0, Z=0 +0004 0D8C 00030 rlf wert1 ;W=22h, wert1=44h, wert2=?? , DC=0, C=0, Z=0 +0005 0D8C 00031 rlf wert1 ;W=22h, wert1=88h, wert2=?? , DC=0, C=0, Z=0 +0006 0D0C 00032 rlf wert1,w ;W=10h, wert1=88h, wert2=?? , DC=0, C=1, Z=0 +0007 0D8C 00033 rlf wert1 ;W=10h, wert1=11h, wert2=?? , DC=0, C=1, Z=0 +0008 0D0C 00034 rlf wert1,w ;W=23h, wert1=11h, wert2=?? , DC=0, C=0, Z=0 +0009 0C8C 00035 rrf wert1 ;W=23h, wert1=08h, wert2=?? , DC=0, C=0, Z=0 +000A 008D 00036 movwf wert2 ;W=23h, wert1=08h, wert2=23h, DC=0, C=0, Z=0 +000B 0C8D 00037 rrf wert2 ;W=23h, wert1=08h, wert2=91h, DC=0, C=1, Z=0 +000C 0C0D 00038 rrf wert2,w ;W=C8h, wert1=08h, wert2=91h, DC=0, C=1, Z=0 + 00039 +000D 3009 00040 movlw 9 ;W=09h, wert1=08h, wert2=10h, DC=0, C=1, Z=0 +000E 008C 00041 movwf wert1 ;W=09h, wert1=09h, wert2=10h, DC=0, C=1, Z=0 +000F 0100 00042 clrw ;W=00h, wert1=09h, wert2=10h, DC=0, C=1, Z=1 + 00043 loop1 +0010 3E01 00044 addlw 1 ;W=01h, DC=0, C=0, Z=0 + 00045 ;W=02h, DC=0, C=0, Z=0 + 00046 ;W=03h, DC=0, C=0, Z=0 + 00047 ;W=04h, DC=0, C=0, Z=0 + 00048 ;W=05h, DC=0, C=0, Z=0 + 00049 ;W=06h, DC=0, C=0, Z=0 + 00050 ;W=07h, DC=0, C=0, Z=0 + 00051 ;W=08h, DC=0, C=0, Z=0 + 00052 ;W=09h, DC=0, C=0, Z=0 +0011 078D 00053 addwf wert2 ;wert2=92h, DC=0, C=0, Z=0 + 00054 ;wert2=94h, DC=0, C=0, Z=0 + 00055 ;wert2=97h, DC=0, C=0, Z=0 + 00056 ;wert2=9Bh, DC=0, C=0, Z=0 + 00057 ;wert2=A0h, DC=0, C=1, Z=0 + 00058 ;wert2=A6h, DC=0, C=0, Z=0 + 00059 ;wert2=ADh, DC=0, C=0, Z=0 + 00060 ;wert2=B5h, DC=0, C=1, Z=0 + 00061 ;wert2=BEh, DC=0, C=0, Z=0 +0012 0B8C 00062 decfsz wert1 ;wert1=08h, wert1=07h, ... DC,C und Z bleiben unverändert +0013 2810 00063 goto loop1 + 00064 +0014 30F0 00065 movlw 0f0h ;Wert wird bis 00h (über FFh) hochgezählt +0015 008C 00066 movwf wert1 +0016 018D 00067 clrf wert2 +0017 0100 00068 clrw + 00069 loop2 +0018 070C 00070 addwf wert1,w ;W=F0h, DC=0, C=0, Z=0 + 00071 + 00072 +0019 0A8D 00073 incf wert2 ;wert2=F1h, DC= +001A 0F8C 00074 incfsz wert1 +001B 2818 00075 goto loop2 + 00076 + 00077 ende +001C 281C 00078 goto ende ;Endlosschleife, verhindert Nirwana + 00079 + 00080 diff --git a/TPicSim Testprogramme/TPicSim5.LST b/TPicSim Testprogramme/TPicSim5.LST new file mode 100644 index 0000000..917cb14 --- /dev/null +++ b/TPicSim Testprogramme/TPicSim5.LST @@ -0,0 +1,50 @@ + 00001 ;TPicSim5 + 00002 ;Programm zum Test des 16F84-Simulators. + 00003 ;Es werden die Befehle BCF, BSF, BTFSC und BTFSS geprüft + 00004 ;(c) St. Lehmann + 00005 ;Ersterstellung: 23.03.2016 + 00006 ; + 00007 list c=132 ;Zeilenlänge im LST auf 132 Zeichen setzen + 00008 + 00009 ;Definition einiger Symbole + 00010 ;zuerst Hardware-Register + 00011 status equ 03h + 00012 ra equ 05h + 00013 rb equ 06h + 00014 + 00015 ;für den Benutzer frei verwendbare Register + 00016 wert1 equ 0ch ;Variable Nr.1 + 00017 wert2 equ 0dh ;Variable Nr.2 + 00018 ergeb equ 0eh ;Variable Nr.3 + 00019 + 00020 ;Definition des Prozessors + 00021 device 16F84 + 00022 + 00023 ;Festlegen des Codebeginns + 00024 org 0 + 00025 loop +0000 3011 00026 movlw 11h ;in W steht nun 11h, DC=?, C=?, Z=? +0001 008C 00027 movwf wert1 ;diesen Wert abspeichern, DC=?, C=?, Z=? +0002 018D 00028 clrf wert2 ;W=11h, wert1=11h, wert2=00h, DC=?, C=?, Z=1 +0003 178C 00029 bsf wert1,7 ;W=11h, wert1=91h, wert2=00h, DC=?, C=?, Z=1 +0004 158C 00030 bsf wert1,3 ;W=11h, wert1=99h, wert2=00h, DC=?, C=?, Z=1 +0005 120C 00031 bcf wert1,4 ;W=11h, wert1=89h, wert2=00h, DC=?, C=?, Z=1 +0006 100C 00032 bcf wert1,0 ;W=11h, wert1=88h, wert2=00h, DC=?, C=?, Z=1 + 00033 +0007 180C 00034 btfsc wert1,0 +0008 0A8D 00035 incf wert2 +0009 0A8D 00036 incf wert2 +000A 198C 00037 btfsc wert1,3 +000B 0A8D 00038 incf wert2 +000C 0A8D 00039 incf wert2 +000D 1D0C 00040 btfss wert1,2 +000E 0A8D 00041 incf wert2 +000F 0A8D 00042 incf wert2 +0010 1F8C 00043 btfss wert1,7 +0011 0A8D 00044 incf wert2 +0012 038D 00045 decf wert2 ;in wert2 muss 04h stehen + 00046 + 00047 ende +0013 2813 00048 goto ende ;Endlosschleife, verhindert Nirwana + 00049 + 00050 diff --git a/TPicSim Testprogramme/TPicSim6.LST b/TPicSim Testprogramme/TPicSim6.LST new file mode 100644 index 0000000..81c68c1 --- /dev/null +++ b/TPicSim Testprogramme/TPicSim6.LST @@ -0,0 +1,95 @@ + 00001 ;TPicSim6 + 00002 ;Programm zum Test des 16F84-Simulators. + 00003 ;Es werden die Byte-orientieren File-Register-Befehle im + 00004 ;Zusammenhang mit der indirekten Adressierung geprüft + 00005 ; + 00006 ;(c) St. Lehmann + 00007 ;Ersterstellung: 23.03.2016 + 00008 + 00009 ;Hinweis: + 00010 ;Bei der indirekten Adressierung werden die Register "IND" oder auch als + 00011 ;"indirect addr" bezeichnet und das Register FSR (File Select Register) + 00012 ;benutzt. Dabei beinhaltet das FSR-Register die Zieladresse in die etwas + 00013 ;geschrieben oder von der etwas gelesen werden soll. Der eigentliche + 00014 ;Zugriff erfolgt über das Ansprechen der Registeradresse 0 (IND). Der PIC + 00015 ;ersetzt in dem Falle die Adresse 0 durch die Adresse im FSR-Register. + 00016 ;Da die Adresse im FSR-Register 8-Bit umfasst, die Adresse bei der direkten + 00017 ;Adressierung jedoch nur 7 Bit, kann man durch die indirekte Adressierung + 00018 ;auch auf Bank 1 zugreifen ohne das RP0-Bit zu setzen. + 00019 ; + 00020 ;Bei diesen Befehlen entscheidet das d-Bit (Destination), ob das Ergebnis + 00021 ;dieser Operation ins W- oder File-Register geschrieben wird. Wird im + 00022 ;Assemblercode der Befehl mit ",W" geschrieben, bedeutet dies, dass das + 00023 ;d-Bit 0 ist und das Ergebnis ins W-Register kommt. Fehlt ",W" ist das + 00024 ;d-Bit 1 und das Ergebnis wird ins Fileregister geschrieben. + 00025 ; + 00026 list c=132 ;Zeilenlänge im LST auf 132 Zeichen setzen + 00027 + 00028 ;Definition einiger Symbole + 00029 ;zuerst Hardware-Register + 00030 indirect equ 00h + 00031 status equ 03h + 00032 fsr equ 04h + 00033 ra equ 05h + 00034 rb equ 06h + 00035 + 00036 ;für den Benutzer frei verwendbare Register + 00037 wert1 equ 0ch ;Variable Nr.1 + 00038 wert2 equ 0dh ;Variable Nr.2 + 00039 ergeb equ 0eh ;Variable Nr.3 + 00040 + 00041 ;Definition des Prozessors + 00042 device 16F84 + 00043 + 00044 ;Festlegen des Codebeginns + 00045 org 0 + 00046 loop +0000 3020 00047 movlw 20h ;in W steht nun 20h, DC=?, C=?, Z=? +0001 008C 00048 movwf wert1 ;diesen Wert abspeichern, DC=?, C=?, Z=? +0002 3010 00049 movlw 10h ;W = 10h, DC=?, C=?, Z=? +0003 0084 00050 movwf fsr ;W=10h, FSR=10h, wert1=20h, wert2=?? , DC=?, C=?, Z=? +0004 008D 00051 movwf wert2 ;W=10h, FSR=10h, wert1=20h, wert2=10h, DC=?, C=?, Z=? +0005 080C 00052 movf wert1,w ;W=20h + 00053 ;der Speicherbereich von 10h bis 1Fh wird mit Zahlen 20h, 21h, etc. gefüllt + 00054 loop1 +0006 0080 00055 movwf indirect ;W=20h, FSR=10h, F10=20h +0007 3E01 00056 addlw 1 ;W=20h, 21h, 22h, etc +0008 0A84 00057 incf fsr ;FSR=11h, 12h, etc +0009 0B8D 00058 decfsz wert2 +000A 2806 00059 goto loop1 + 00060 +000B 301F 00061 movlw 1fh ;FSR-Zeiger wieder auf Anfang stellen +000C 0084 00062 movwf fsr +000D 30F0 00063 movlw 0f0h +000E 008D 00064 movwf wert2 +000F 0100 00065 clrw + 00066 loop2 +0010 0700 00067 addwf indirect,w +0011 0384 00068 decf fsr +0012 0F8D 00069 incfsz wert2 +0013 2810 00070 goto loop2 + 00071 ;im W-Register muss 78h stehen +0014 008D 00072 movwf wert2 +0015 0A84 00073 incf fsr +0016 0C80 00074 rrf indirect ;F10=10h +0017 0A80 00075 incf indirect ;F10=11h +0018 0C80 00076 rrf indirect ;F10=08h, C=1 +0019 1780 00077 bsf indirect,7 ;F10=88h +001A 1003 00078 bcf status,0 ;C=0 +001B 0D80 00079 rlf indirect ;F10=10h, C=1 +001C 0A84 00080 incf fsr ;fsr=11h +001D 0D80 00081 rlf indirect ;F11=43h, C=0 +001E 0E80 00082 swapf indirect ;F11=34h +001F 0680 00083 xorwf indirect ;F11=4Ch +0020 1A80 00084 btfsc indirect,5 +0021 2800 00085 goto loop +0022 1D00 00086 btfss indirect,2 +0023 2800 00087 goto loop +0024 1980 00088 btfsc indirect,3 +0025 2827 00089 goto ende +0026 2800 00090 goto loop + 00091 + 00092 ende +0027 2827 00093 goto ende ;Endlosschleife, verhindert Nirwana + 00094 + 00095 diff --git a/TPicSim Testprogramme/TPicSim7.LST b/TPicSim Testprogramme/TPicSim7.LST new file mode 100644 index 0000000..20c47c9 --- /dev/null +++ b/TPicSim Testprogramme/TPicSim7.LST @@ -0,0 +1,83 @@ + 00001 ;TPicSim7 + 00002 ;Programm zum Test des 16F84-Simulators. + 00003 ;Es wird der Timer0 mit und ohne Vorteiler geprüft + 00004 ;(c) St. Lehmann Ersterstellung: 23.01.2003 + 00005 ;19.04.2014 überarbeitet + 00006 + 00007 list c=132 ;Zeilenlänge im LST auf 132 Zeichen setzen + 00008 + 00009 ;Definition einiger Symbole + 00010 indirect equ 0 + 00011 status equ 03h + 00012 fsr equ 04h + 00013 ra equ 05h + 00014 rb equ 06h + 00015 count equ 0ch + 00016 + 00017 ;Definition des Prozessors + 00018 device 16F84 + 00019 ;Festlegen des Codebeginns + 00020 org 0 + 00021 start + 00022 ;zuerst Timer0 intern durch den Befehlstakt erhöhen VT = 1:4 + 00023 ;somit wird nach jedem 4. Befehlstakt (Achtung GOTO etc) TMR0 erhöht +0000 3001 00024 movlw 00000001B ;Option-Register entsp. initialisieren +0001 1683 00025 bsf status,5 ;Bank umschalten +0002 0081 00026 movwf 1 ;Option-Register +0003 1283 00027 bcf status,5 +0004 3001 00028 movlw 1 ;Timer 1 auf 1 +0005 0081 00029 movwf 1 +0006 0190 00030 clrf 10h ;zähler + 00031 loop1 +0007 0000 00032 nop +0008 0000 00033 nop +0009 0000 00034 nop +000A 0A90 00035 incf 10h +000B 0801 00036 movf 1,w ;lese Timerwert aus +000C 1D03 00037 btfss status,2 ;wenn Timer = 0, dann fertig +000D 2807 00038 goto loop1 + 00039 ;num muss 80H in 10h stehen + 00040 + 00041 ;nun mit einem VT = 1:16 + 00042 ;somit wird nach jedem 16. Befehlstakt (Achtung GOTO etc) TMR0 erhöht +000E 3003 00043 movlw 00000011B ;Option-Register entsp. initialisieren +000F 1683 00044 bsf status,5 ;Bank umschalten +0010 0081 00045 movwf 1 ;Option-Register +0011 1283 00046 bcf status,5 +0012 3001 00047 movlw 1 ;Timer 1 auf 1 +0013 0081 00048 movwf 1 +0014 0190 00049 clrf 10h ;zähler + 00050 loop2 +0015 0A90 00051 incf 10h +0016 0801 00052 movf 1,w ;lese Timerwert aus +0017 1D03 00053 btfss status,2 ;wenn Timer = 0, dann fertig +0018 2815 00054 goto loop2 + 00055 ;num muss 31H in 10h stehen + 00056 ;***************************************************************** + 00057 ;jetzt wird der Timer0 durch den externen Takt an RA4 hochgezählt. + 00058 ;zuerst ohne VT, damit zählt jede fallende Flanke an RA +0019 3038 00059 movlw 00111000B ;Option-Register initialisieren +001A 1683 00060 bsf status,5 +001B 0081 00061 movwf 1 ;Wert ins Option-Register +001C 1283 00062 bcf status,5 +001D 0181 00063 clrf 1 ;Timer löschen + 00064 loop3 +001E 1E01 00065 btfss 1,4 ;bis im Timer0 der Wert 16 erreicht wird +001F 281E 00066 goto loop3 + 00067 + 00068 ;jetzt auch mit VT 1:4, damit zählt jede 4. fallende Flanke an RA +0020 3031 00069 movlw 00110001B ;Option-Register initialisieren +0021 1683 00070 bsf status,5 +0022 0081 00071 movwf 1 ;Wert ins Option-Register +0023 1283 00072 bcf status,5 +0024 0181 00073 clrf 1 ;Timer löschen + 00074 loop4 +0025 1D81 00075 btfss 1,3 ;bis im Timer0 der Wert 8 erreicht wird +0026 2825 00076 goto loop4 + 00077 + 00078 ;****************************************************************** + 00079 + 00080 ende +0027 2827 00081 goto ende ;Endlosschleife, verhindert Nirwana + 00082 + 00083 diff --git a/TPicSim Testprogramme/TPicSim8.LST b/TPicSim Testprogramme/TPicSim8.LST new file mode 100644 index 0000000..1d95d8c --- /dev/null +++ b/TPicSim Testprogramme/TPicSim8.LST @@ -0,0 +1,116 @@ + 00001 ;TPicSim8 + 00002 ;Programm zum Test des 16F84-Simulators. + 00003 ;Es werden die Interrupts für TMR0, RB0 (INT) und RB4-7 geprüft + 00004 ;(c) St. Lehmann + 00005 ;19.04.2014 + 00006 + 00007 list c=132 ;Zeilenlänge im LST auf 132 Zeichen setzen + 00008 + 00009 ;Definition einiger Symbole + 00010 indirect equ 0 + 00011 status equ 03h + 00012 fsr equ 04h + 00013 ra equ 05h + 00014 rb equ 06h + 00015 intcon equ 0bh + 00016 + 00017 ;Definition des Prozessors + 00018 device 16F84 + 00019 ;Festlegen des Codebeginns + 00020 org 0 + 00021 start +0000 281C 00022 goto main +0001 0000 00023 nop +0002 0000 00024 nop +0003 0000 00025 nop + 00026 + 00027 ;Interrupt-Service-Routine muss an Adresse 4 stehen, deshalb die 3 NOPs + 00028 ISR +0004 1D0B 00029 btfss intcon,2 ;war es ein Timer-Interrupt? +0005 280B 00030 goto isr1 ;nein +0006 3054 00031 movlw 54h ;ja, 54h = T in 20h schreiben +0007 00A0 00032 movwf 20h +0008 128B 00033 bcf intcon,5 ;Timer-Interrupt sperren +0009 110B 00034 bcf intcon,2 ;Interrupt-Flag zurücksetzen +000A 281B 00035 goto isrend + 00036 ISR1 +000B 1C8B 00037 btfss intcon,1 ;war es ein RB0-Interrupt? +000C 2812 00038 goto isr2 ;nein +000D 3049 00039 movlw 'I' ;schreibe ein I an 21h +000E 00A1 00040 movwf 21h +000F 120B 00041 bcf intcon,4 ;RB0-Interrupt sperren +0010 108B 00042 bcf intcon,1 ;RB0-Interrupt-Flag löschen +0011 281B 00043 goto isrend + 00044 ISR2 +0012 1C0B 00045 btfss intcon,0 ;war es ein RB4-7 Interrupt? +0013 2819 00046 goto isr3 ;dürfte nie passieren +0014 3052 00047 movlw 'R' ;schreibe ein R nach 22h +0015 00A2 00048 movwf 22h +0016 118B 00049 bcf intcon,3 ;keine RB4-7 Interrupts erlauben +0017 100B 00050 bcf intcon,0 ;auch das Flag löschen +0018 281B 00051 goto isrend + 00052 ISR3 +0019 3046 00053 movlw 'F' ;Fehlermeldung +001A 00A3 00054 movwf 23h + 00055 + 00056 isrend +001B 0009 00057 retfie ;Ende der Inetrrupt-Service-Routine + 00058 + 00059 + 00060 main: + 00061 ;Der TMR0 wird vom Befehlstakt incrementiert. beim Überlauf wird ein Interrupt ausgelöst +001C 3001 00062 movlw 00000001B ;Option-Register entsp. initialisieren +001D 1683 00063 bsf status,5 ;Bank umschalten +001E 0081 00064 movwf 1 ;Option-Register +001F 1283 00065 bcf status,5 +0020 3020 00066 movlw 20h ;nur Timer-Interrupt erlauben +0021 008B 00067 movwf intcon +0022 178B 00068 bsf intcon,7 ;Globale Freigabe, ab jetzt kann ein Interrupt durchkommen + 00069 loop1 +0023 1A8B 00070 btfsc intcon,5 ;fertig, wenn ISR dieses Bit zurücksetzt +0024 2823 00071 goto loop1 ;bis Timer überläuft + 00072 + 00073 ;zuerst die wirksame Flanke für RB0 festlegen (hier die fallende Flanke) +0025 300F 00074 movlw 00001111b +0026 1683 00075 bsf status,5 +0027 0081 00076 movwf 1 +0028 1283 00077 bcf status,5 + 00078 ;nun den RB0-Interrupt freigeben, Rest sperren +0029 3010 00079 movlw 10h +002A 008B 00080 movwf intcon +002B 178B 00081 bsf intcon,7 + 00082 loop2 +002C 1A0B 00083 btfsc intcon,4 +002D 282C 00084 goto loop2 + 00085 + 00086 ;Beim RB4-7 Interrupts wird ein Flankenwechsel nur an den Pins die als Eingang arbeiten erkannt +002E 3008 00087 movlw 08h ;RB4-7 Interrupt freigeben +002F 008B 00088 movwf intcon +0030 178B 00089 bsf intcon,7 ;GIE + 00090 loop3 +0031 198B 00091 btfsc intcon,3 ;wird in ISR zurückgesetzt +0032 2831 00092 goto loop3 + 00093 + 00094 ;das gleiche nochmals, nur sind RB4-6 Ausgänge und werden deshalb ignoriert +0033 308F 00095 movlw 10001111B +0034 1683 00096 bsf status,5 +0035 0086 00097 movwf 6 ;TRIS RB +0036 1283 00098 bcf status,5 +0037 3008 00099 movlw 08h ;RB4-7 Interrupt freigeben +0038 008B 00100 movwf intcon ;aber nur RB7 ist aktiv +0039 178B 00101 bsf intcon,7 ;GIE + 00102 loop4 +003A 198B 00103 btfsc intcon,3 ;wird in ISR zurückgesetzt +003B 283A 00104 goto loop4 + 00105 + 00106 + 00107 ;****************************************************************** + 00108 ;wenn alles richtig, dann + 00109 ;in 20h steht 54H + 00110 ;in 21H ein 49H + 00111 ;in 22H ein 53H + 00112 + 00113 ende +003C 283C 00114 goto ende ;Endlosschleife, verhindert Nirwana + 00115 + 00116 diff --git a/TPicSim Testprogramme/TPicSim9.LST b/TPicSim Testprogramme/TPicSim9.LST new file mode 100644 index 0000000..421973a --- /dev/null +++ b/TPicSim Testprogramme/TPicSim9.LST @@ -0,0 +1,40 @@ + 00001 ;TPicSim9 + 00002 ;Programm zum Test des 16F84-Simulators. + 00003 ;Funktion: SLEEP-Befehl + 00004 ;(c) St. Lehmann Ersterstellung: 31.03.2016 + 00005 ;Definition einiger Symbole + 00006 + 00007 list c=132 ;Zeilenlänge im LST auf 132 Zeichen setzen + 00008 + 00009 status equ 03h + 00010 rb equ 06h + 00011 var equ 0ch + 00012 liste1 equ 10h + 00013 liste2 equ 11h + 00014 liste3 equ 12h + 00015 liste4 equ 13h + 00016 + 00017 ;Definition des Prozessors + 00018 device 16F84 + 00019 + 00020 ;Festlegen des Codebeginns + 00021 org 0 + 00022 ;wenn mit eingeschaltetem Watchdog-Timer der SLEEP-Befehl aktiviert wird, + 00023 ;dann wird das Programm nach ca. 2,3ms weiter laufen. + 00024 + 00025 ;wenn der Watchdog-Timer ausgeschaltet ist, beendet ein RESET den SLEEP-Modus + 00026 + 00027 ;Auch ein Interrupt an RB0 oder RB4 bis RB7 beendet den SLEEP-Modus + 00028 start +0000 018C 00029 clrf var ; +0001 0E03 00030 swapf status,w +0002 0090 00031 movwf liste1 ;T0=1 , PD=1 +0003 0063 00032 sleep ;warte bis Watchdogtimer anspricht +0004 0E03 00033 swapf status,w +0005 0091 00034 movwf liste2 ;T0=1 , PD=0 bei Watchdog-Timeout + 00035 ;T0=0 , PD=0 bei RESET oder Interrupt + 00036 + 00037 + 00038 ende +0006 2806 00039 goto ende + 00040 diff --git a/TPicSim Testprogramme/Uebersicht.txt b/TPicSim Testprogramme/Uebersicht.txt new file mode 100644 index 0000000..47e86e4 --- /dev/null +++ b/TPicSim Testprogramme/Uebersicht.txt @@ -0,0 +1,46 @@ +Für die Test, ob ihr Simulator richtig funktioniert, gibt es +dieverse Testprogramme. Sie sind bewusst kurz gehalten, damit +der Überblick nicht verloren geht. + + +Die Testprogramme für den PIC-Simulator haben folgende Aufgaben: + +TPicSim1 +Es werden die Literal-Befehle getestet + +TPicSim2 +Test von CALL, GOTO, RETLW und RETURN (RETFIE in TPicSim8) + +TPicSim3 +Prüfen der Byte-orientierten Befehle, ohne die aus TPicSim4 + +TPicSim4 +DECFSZ, INCFSZ, RLF und RRF werden hier gesondert getestet + +TPicSim5 +Hier werden die Bit-orientierten Befehle geprüft. + +TPicSim6 +Die indirekte Adressierung ist wichtig und kommt sehr oft vor. + +TPicSim7 +Der Timer0 wird mit und ohne Vorteiler geprüft. + +TPicSim8 +Es gibt neben dem RB0, RB4-RB7 und dem Timer-Interrupt auch den +EEPROM-Interrupt, der aber nicht geprüft wird. + +TPicSim9 +Der SLEEP-Befehl verlangt etwas mehr Überlegung bei den Tests. +(Siehe auch TPicSim11) + +TPicSim10 +Das PCL- und das PCLATH-Register sind etwas Besonderes beim PIC +und benötigt mehr Detailkenntisse als die übrigen Befehle + +TPicSim11 +Diese Funktion ist grundlegend für das TPicSim9-Testprogramm. + +TPicSim12 +Lesen und Beschreiben des internen Daten-EEPROMs. +