This page is a step by step guide on how to develop a JBit program on your desktop. I assume you are working on Windows XP, but the techniques presented here should be easy to adapt to other platforms.

Environment Setup

Download the following (required):

and the following (recommended):

I don't provide direct links and I encourage you to download the lastest stable version of each package.

Install Java, if necessary.

Create a new folder; in this example I assume you have created a folder named jbit in the folder Home of the disk D (i.e. D:\Home\jbit).

Copy the following files to the new folder:

FileSource PackageLocation in Package

That is it.

This environment has been chosen because there are fewer things that can go wrong with it; not knowing who is going to read this page, I reckon this is the best approach. In the long term, I would not recommend to keep this environment, though. Once you get the idea, I encourage you to learn more about these tools to be able to setup a better one yourself.

Command Prompt

Creating JB files requires the use of the Command Prompt. The Command Prompt is less difficult that a lot of people think; you just need to be careful and pay attention to the details (even single characters are important!).

Press Win+R, type cmd and click on OK. A window should appear containing something like this:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Emanuele>

This window is used by typing commands. Each command is confirmed by pressing Enter. You can recall and edit commands typed earlier using the cursor keys.

On this page, what the computer types is shown using normal characters, while what you type is shown using bold characters.

Go to the new folder (the first command can be omitted if you are already on the right disk):

C:\Documents and Settings\Emanuele>d:

D:\>cd \home\jbit


Generate a JB File

Edit the assembly source:

D:\Home\jbit>notepad hello.s


Confirm the creation of the new file and copy the following program:

.include "jbit.inc"

START = CONVIDEO + 10*1 + 2


	ldx	#0
next:	lda	msg,x
	beq	getkey
	sta	START,x
	jmp	next
getkey: sta	FRMDRAW
	beq	getkey


msg:	.byte	"Hello!", 0

Save. You don't need to close Notepad.

Generate the JB file:

D:\Home\jbit>cl65 -t none -C jbit.cfg -o hello.jb header.s hello.s


If everything is OK, cl65 does its job without complaining.

Test the JB File

Before packaging the JB file into a MIDlet and installing it on your phone, you might want to test it on your PC.

Edit JBit2.jad:

D:\Home\jbit>notepad JBit2.jad


Add the property JBit-AutoRun:

JBit-AutoRun: hello.jb

Don't bother changing the other properties.

Save and close.

Now you can invoke MicroEmulator:

D:\Home\jbit>microemulator.jar -appclasspath JBit2.jar;. --propertiesjad JBit2.jad JBit


On Linux you should replace ; with :.

As usual you, can do step by step execution (not really needed here) by pressing a soft-key (e.g. F1) and selecting the option Debug.

To change the program, repeat the edit/generate/test cycle, using the cursor keys to avoid retyping the same commands again and again.

JB File Format (for use with other Assemblers)

A JB file is a header of 12 bytes followed by the code pages and by the data pages; the pages are 0-filled. The waste of space is not really a problem because jar files can compress sequences of 0s very well. The pages are loaded starting from the address 768 ($300).

In the example above (1 code page and 1 data page), the file is 12 + 256*2 = 524 bytes long.

This is the header for the example above:

4A 42 69 74 00 0C 01 00 01 01 00 00

First there is the JB signature (4 bytes, "JBit" in ASCII), then the length of the header as a 16 bit word in network byte order (2 bytes, $000C = 12), then the major (1) and the minor (0) version used to identify the file format, then the number of code (1) and data (1) pages. The last two bytes are reserved for future use and should be 0.