-
-
Notifications
You must be signed in to change notification settings - Fork 1
Writing your First Program
A lot of this is outdated. Documentation is slowly moving over to sap1emu.net/Docs/Docs
This guide will detail how to write a program in SAP1Emu Assembly. It will not cover all of the possible instructions or macros, so please refer to the following pages for more information:
Choice of text editor really not important. As long as the editor can save the file with a .s extension, it will work. Visual Studio Code, Notepad++, and Sublime are all great, free options for Windows, MacOSX, and Linux.
If these are not available, the default text editors in your OS will do (Notepad on Windows, TextEdit on Mac, nano/vim/emac for Linux). Do not use Microsoft Word or Pages as they add extra formatting that will cause errors.
For this example, we will be using Notepad on Windows.
Open your text editor and copy-paste the following into it:
LDA 0xE
ADD 0xF
SUB 0xD
OUT 0x0
HLT 0x0
...
0xD 0x0
0x0 0xB
0xF 0x1
This program written out in pseudocode would look like this:
x=11
x = x + 241
x = x - 208
Print("Output =" + x)
Exit()
The output would be the following:
Output = 44
Save the program as myFirstProgram.s
Note: If you are using Notepad, make sure to click "File" > "Save As", then on the "Save as Type" combo-box, select "All Files (*)"
See the Emulator page to learn how to run your program.
© Bob Baker 2020