In this example we will write the standard C example "hello world" in Basic18. The following assumptions will be made
Step 1, Creating a source file
Open Basic18 and save the following program to a file named tutorial1.bas:
Include <libs/hardware.bas>
Sub main() ' program execution begins with main
Dim s(15) As String ' define a string
' Initialize the USART
TXSTA = 0x24 ' setup internal PIC registers
RCSTA = 0x90
SPBRG = 0xC
Call puts("Hello World") ' send the message to the USART
End Sub
Step 2, Create and Setup a new Project
Select "New Project" from the menu, or click "New Project" on the toolbar to bring up the following project properties window with a new project.

We need to add the source file we created above "tutorial1.bas" to the project. To do this click the "Add File" button and select the file.
The other default settings will work for this project so click "OK" to exit the project properties.
Step 3, Save the Project
We now need to save the project by clicking on "Save Project" from the tool bar or selecting it from the "Project" menu. Save it with a name of "tutorial1.prj".
Step 4, Build the Project
Click the "Build Project"
icon
on the toolbar to compile the basic program into PIC18 assembly code, if all
goes well the Compiler Output window will show the following.

Step 5, Setup MPLab
Create a new project in MPLab naming it "Tutorial1", placing it in the same directory as the basic files in the above steps.
Make sure the "Microchip MPASM Toolsuite" is selected from the "Project/Select Language Toolsuite" menu.
Make sure the PIC18F452 is the selected device, and the configuration bits are setup properly.
Add the file "tutorial1.asm" to the project
Save the project.
Build the project.
The hex file "tutorial1.hex" is ready to be programmed into a chip.