Home
Downloads
Licenses Contact

OshonSoft

20th Anniversary

2021 - 20th Anniversary of the
OSHONSOFT PROJECT
OshonSoft © 2001 - 2025

6502 Simulator IDE
Getting Started

This presentation will help you to test the examples included with the software package and in that way get acquainted with the most interesting features of 6502 Simulator IDE.


Example 1: osi_bas_mod.asm
Example 2: ehbasic_mod.asm
Example 3: print_variables.bas
Example 4: c64_rom_play.prg
Example 5: c64_rom_play2.prg


Example 1

This example is the simulation of the Microsoft OSI BASIC prepared by Mr. Grant Searle. Here is the link to Grant's 6502 computer homepage. Assembler source of the OSI BASIC can be downloaded on the page linked above. In the app setup package you will find osi_bas_mod.asm file that is the original assembler source with the applied garbage collection routine patch.


- Start 6502 Simulator IDE.
- Start the Assembler using the Tools menu command, or use Shortcuts Panel Configuration option to organize the shortcuts for your most used commands on the main window.
- Using the Assembler Options menu, turn off the option - Focus With MouseMove (this option is useful when most of the work is focused on the assembler editor).
- Click on File\Open.
- Select osi_bas_mod.asm file and click on Open. The OSI BASIC source will be displayed in the editor.
- Click on Tools\Assemble & Load. After the operation is completed the assembler will generate two main files: osi_bas_mod.lst (assembler listing with assembled opcodes) and osi_bas_mod.obj (binary image of the assembled code that will be automatically loaded into the simulator memory). The output listing file osi_bas_mod.lst will be displayed. (Generate HEX File Also option is on by default, so osi_bas_mod.hex file will be there too.)
- Start Input/Output Terminal interface (main IDE window Tools menu). The default settings for the terminal data addresses and the control bits are suitable for this simulation. Take a look at the relevant information by clicking on the tiny Info label in the lower right corner.
- On the terminal use Change Screen Color Scheme command to select blue background for example.
- Reposition the windows on the screen to get better view. If needed use Always On Top option on the windows. By default the application will remember windows sizes, positions, and 'on top' settings.
- Select the Rate\Extremely Fast simulation rate (main IDE window).
- Close the Assembler window. It's Code Tracking feature that is very useful for the code debugging would slow down the simulation performance.
- Click on Simulation\Start. The simulation will start immediately.
- Soon you will see the message on the terminal: Cold [C] or warm [W] start?
- Respond by clicking C on the terminal keyboard.
- MEMORY SIZE? message is now displayed.
- Use the terminal keyboard to enter 30000 for example and click on the (return) key.
- TERMINAL WIDTH? message is displayed.
- Enter 80 for example and click on the (return) key.
- Soon, the OSI BASIC welcome message will be displayed, and the desired basic program can be entered to the interpreter memory.
- Use the following basic program for example:


10 FOR A=0 TO 6.2 STEP 0.2
20 PRINT TAB(20+SIN(A)*19);"*"
30 NEXT A


- It can be entered using the terminal keyboard, or using the Paste or Send String commands.
- You can try typing the LIST command to see the basic command listing.
- Start the basic program execution by typing the RUN command.
- Change the simulation rate to Ultimate selection. When the program execution ends, change the simulation rate to Fast.
- Open the Assembler window to enjoy the Code Tracking feature.
- Review the Assembler window context menu and explore the useful bookmarks and breakpoints features.
- Click on Tools\Memory Editor to start another useful tool. Click on the Focus SP command. Stop, then run the simulation from the beginning to enjoy the functionality of the Track Read/Write access feature.

(screenshot)


Example 2

This example is the simulation of the Enhanced BASIC (EhBASIC) by Mr. Lee Davison. Here is the link to Enhanced BASIC homepage. Assembler source of the basic interpreter can be downloaded on the page linked above. In the app setup package you will find ehbasic_mod.asm file that is the original basic assembler source with the appended minimal monitor for EhBASIC that is available in the same linked archive.


- Start 6502 Simulator IDE.
- Experience from the Example 1 testing will be presumed here. ;-)
- Click on Options\Change Color Theme. Select City Night for example.
- Start the Assembler using the Tools menu command.
- Click on File\Open.
- Select ehbasic_mod.asm file and click on Open. The Enhanced BASIC source will be displayed in the editor.
- Click on Tools\Assemble & Load. After the operation is completed the assembler will generate the files: ehbasic_mod.lst, ehbasic_mod.hex and ehbasic_mod.obj (binary image of the assembled code that will be automatically loaded into the simulator memory). The output listing file ehbasic_mod.lst will be displayed.
- Start Input/Output Terminal interface (Tools menu). The default settings for the terminal data addresses and the control bits need to be changed for this simulation. Take a look at the relevant information by clicking on the Info label. By clicking on the appropriate labels, you should set the output data register to $F001, and input data register to $F004. Control bits are not important here, and could be set to $F000,1 (output) and $F000,0 (input terminal).
- Select the Rate\Extremely Fast simulation rate.
- Close the Assembler window.
- Click on Simulation\Start. The simulation will start immediately.
- Soon you will see the message on the terminal: 6502 EhBASIC [C]old/[W]arm ?
- Respond by clicking C on the terminal keyboard.
- Memory size ? message is now displayed.
- Use the terminal keyboard to enter 30000 for example and click on the (return) key.
- Soon, the EhBASIC welcome message will be displayed, and the desired basic program can be entered to the interpreter memory.
- Use the following basic program for example:


10 FOR I=1 TO 10
20 PRINT I,SIN(I);" ";COS(I)
30 NEXT I


- It can be entered using the terminal keyboard, or using the Paste or Send String commands.
- You can try typing the LIST command to see the basic command listing.
- Start the basic program execution by typing the RUN command. Watch the simulation running at Extremely Fast simulation rate.
- Click on Tools\Fast Debugger - Breakpoints Manager to start another useful tool.
- Use Change Number Of Lines command and set the 35 value.
- Use Change Color Scheme command and make blue selection for example.
- Enjoy the tool fast performance and experiment with breakpoints feature.

(screenshot)


Example 3

This example is the presentation of the integrated 6502 Basic Compiler. Examine print_variables.bas file from the application folder. This basic program sends formatted output of variable values to the memory mapped output port at address $9001. File print_variables.asm was generated using integrated Basic compiler. Files print_variables.obj and print_variables.hex were generated using integrated assembler.


#define PRINT_SINGLE_DIGITS = 5

Dim x1 As Integer
Dim x2 As UInteger
Dim x3 As Short
Dim x4 As UShort
Dim x5 As Boolean
Dim x6 As Long
Dim x7 As ULong
Dim x8 As Single

'$9001 is the address of the memory mapped output port
x1 = -31456
Print $9001, "Integer = ", x1, CrLf
x2 = 65535
Print $9001, "UInteger = ", x2, CrLf
x3 = -68
Print $9001, "Short = ", x3, CrLf
x4 = 251
Print $9001, "UShort = ", x4, CrLf
x5 = False
Print $9001, "Boolean = ", x5, CrLf

x6 = -1234567890
Print $9001, "Long = ", x6, CrLf
x7 = 4123456789
Print $9001, "ULong = ", x7, CrLf

x8 = -123.456
Print $9001, "Single = ", x8, CrLf


- Start 6502 Simulator IDE.
- Experience from the previous examples testing will be presumed here.
- Click on Options\Change Color Theme. Select Bitter Lemon for example.
- Click on Tools\BASIC Compiler. That will open integrated Basic Compiler editor window.
- Using the Compiler Options menu, turn off the option - Focus With MouseMove (this option is useful when most of the work is focused on the basic program editing).
- Click on File\Open.
- Select print_variables.bas file and click on Open. The basic source program will be displayed in the editor.
- Click on Tools\Compile & Assemble & Load. The compiler will generate print_variables.asm file with assembler source. The integrated assembler will assemble that file and make print_variables.lst and print_variables.obj files. The print_variables.obj file will be loaded into the simulator program memory.
- Click on Tools\Watch Variables to open another very useful simulation interface for basic program debugging. Variables from the loaded basic program will be automatically added to the display.
- Click on Tools\Peripheral Devices. That will open the Peripheral Devices window for the simulation of the memory mapped I/O ports.
- Turn on the Output Terminal by clicking on its OFF button. Enter 9001 for its memory mapped address.
- Reposition the windows on the screen to get better view. If needed use Always On Top option on the windows.
- Select the Rate\Extremely Fast simulation rate.
- Check that Options\Basic Program Tracking option is turned on.
- Click on Options\Infinite Loop Stops Simulation to turn on that option. It will be very useful here.
- Click on Simulation\Start. The simulation will start immediately.
- Enjoy the example code execution. The basic statement currently being simulated will be highlighted (Basic Program Tracking).
- The simulation can be stopped any time by clicking on Simulation\Stop. It will be automatically stopped when the whole basic code has been executed, because the integrated compiler inserts an infinite loop at the end of the code.
- Try to run the simulation in Step By Step mode. Then use Run To Next Basic Statement command.

(screenshot)


Example 4

This example will demonstrate the simulation of the C64 ROM using the 6502 Simulator IDE integrated tools - Commodore 64 Rom I/O Terminal and C64 Video Memory Screen. It will also demonstrate the process of a PRG file compiling using the integrated 6502 Basic Compiler. Examine c64_rom_play.bas file from the application folder. This basic program uses C64 related basic statements to send formatted output of variable values to the C64 screen. File c64_rom_play.prg was generated using the integrated compiler.


'tells the compiler to generate the PRG file
#define C64_TARGET = 1
'tells the compiler to include SYS statement
'so that the PRG file can be started with RUN command
#define C64_PRG_ADDSYS = 1
#define PRINT_SINGLE_DIGITS = 5

Dim x1 As Integer
Dim x2 As UInteger
Dim x3 As Short
Dim x4 As UShort
Dim x5 As Boolean
Dim x6 As Long
Dim x7 As ULong
Dim x8 As Single

C64_Cls

x1 = -31456
C64_CursorSet 1, 3
C64_Print "Integer = ", x1, CrLf
x2 = 65535
C64_CursorSet 3, 4
C64_Print "UInteger = ", x2, CrLf
x3 = -68
C64_CursorSet 5, 5
C64_Print "Short = ", x3, CrLf
x4 = 251
C64_CursorSet 7, 6
C64_Print "UShort = ", x4, CrLf
x5 = False
C64_CursorSet 9, 7
C64_Print "Boolean = ", x5, CrLf

x6 = -1234567890
C64_CursorSet 11, 8
C64_Print "Long = ", x6, CrLf
x7 = 4123456789
C64_CursorSet 13, 9
C64_Print "ULong = ", x7, CrLf

x8 = -123.456
C64_CursorSet 15, 10
C64_Print "Single = ", x8, CrLf


- Start 6502 Simulator IDE.
- Experience from the previous examples testing will be presumed here.
- Start the Assembler using the Tools menu command.
- Click on File\Open.
- Select c64rom.asm file and click on Open. The C64 ROM source will be displayed in the editor.
- Click on Tools\Assemble & Load.
- Be patient to see the process fully completed, because the C64 ROM source is a large file with comments on almost all lines. Then, close the Assembler tool.
- Click on Tools\BASIC Compiler. That will open integrated Basic Compiler editor window.
- Click on File\Open.
- Select c64_rom_play.bas file and click on Open. The basic source program will be displayed in the editor.
- Click on Tools\Compile & Assemble. The compiler will generate the desired c64_rom_play.prg file. Then, close the Compiler tool.
- On the main simulator window, click on Tools\Commodore 64 Rom I/O Terminal to open the tool specifically designed for the C64 ROM simulation. Take a look at the relevant information by clicking on the Info label.
- Click on Cursor checkbox to hide it.
- Click on C64 Video Memory Screen label to open the tool window.
- Select the Rate\Ultimate simulation rate.
- Click on Simulation\Start. The simulation will start immediately. It will take some 600000 simulated instructions to finally see the famous welcome message '**** COMMODORE 64 BASIC V2 ****, 64K RAM SYSTEM, 38911 BASIC BYTES FREE, READY.' on both the I/O Terminal and Video Memory tools.
- This simulation part will be executed relatively fast at Ultimate rate.
- Now switch the simulation to Fast simulation rate.
- On the C64 ROM I/O Terminal click on the Load PRG command label.
- Select the previously compiled c64_rom_play.prg file.
- With this command the simulation will be automatically switched to Step By Step mode.
- Click on Tools\Fast Debugger - Breakpoints Manager to start the tool. Set the number of lines to 20.
- By default it will load the c64rom.lst file previously created by the Assembler. However, that listing does not contain the code from the loaded PRG file.
- Click on the small 'M' command label to disassemble the whole simulator memory buffer, and set the tool to work with that listing.
- Resume the simulation with Extremely Fast simulation rate.
- Use the terminal keyboard to enter the RUN command and click on the (return) key.
- Enjoy the simulation of the PRG file execution.

(screenshot)


Example 5

Examine c64_rom_play2.bas file from the application folder. This basic program is a play with the C64_InputChar and C64_PutChar statements.


#define C64_TARGET = 1
#define C64_PRG_ADDSYS = 1

Dim x1 As Integer

C64_Cls
C64_Print "Press a key to start the play.", Cr
loop1:
        C64_GetChar x1
If x1 = 0 Then Goto loop1
C64_Print "Now, the pressed keys", Cr
C64_Print "will be echoed twice.", Cr

loop2:
        C64_InputChar x1
        If x1 = "@" Then Goto endlab
        C64_PutChar x1, x1
Goto loop2
endlab:


- Start 6502 Simulator IDE.
- Click on File\Load Program.
- Select c64rom.obj file and click on Open. The C64 ROM image will be loaded into the simulator memory.
- Click on Tools\BASIC Compiler. That will open integrated Basic Compiler editor window.
- Click on File\Open.
- Select c64_rom_play2.bas file and click on Open. The basic source program will be displayed in the editor.
- Click on Tools\Compile & Assemble. The compiler will generate the desired c64_rom_play2.prg file.
- On the main simulator window, click on Tools\Commodore 64 Rom I/O Terminal to open the tool.
- Click on C64 Video Memory Screen label to open the tool window.
- Select the Rate\Ultimate simulation rate.
- Click on Simulation\Start. The simulation will start immediately. It will take some 600000 simulated instructions until the C64 system has been initialized.
- Now switch the simulation to Fast simulation rate.
- On the C64 ROM I/O Terminal click on the Load PRG command label.
- Select the previously compiled c64_rom_play2.prg file.
- Resume the simulation with Extremely Fast simulation rate.
- Use the terminal keyboard to enter the RUN command and click on the (return) key.
- Enjoy the simulation of the PRG file execution and play with the code using the terminal keyboard.

(screenshot)