These examples have been written to run on the demo board described in PE.
They can also be run within an 8051 simulator 
e.g. JSIM (FREE) 
-This has an excellent interface
http://home.t-online.de/home/Jens.Altmann 

Shareware simulators:
Windows:
SIM8052D From http://www.vaultbbs.com/sim8052/ or www.8052.com
DOS:
SIM51 From
ftp://ftp.philipsmcu.com/ - /pub
http://www.philipsmcu.com/assemblers.html
(Note: This is in German but it is a good simulator (fast) I have a list of
Instructions in English email me if you want a copy)


If you are new to 8051 programming spend time running your programs within a simulator
to understand how the processor works. Some times you are better with more than one 
simulator, as it is useful to verify your results on two different simulators if don't
believe what it telling you! 


Here is how to run the serial example in JSIM. The other simulators are similar.


Run JSIM.
File open (Select File Type hex) 
Select file e.g. serial.hex
Select windows to view e.g. view>terminal 
(The terminal window can be used for viewing/entering info. 
I.e. sending data across serial port) 
Debug>Run (or use button).
The program should functions as described below. 
(Note: You can type data into the terminal window)




Example Code:
All these examples can be complied using the METALINK assembler.
It is available from many sites. e.g. http://www.philipsmcu.com/assemblers.html
or from the ATMEL CD. To locate errors in your code view the listing (.LST) file
produced by the Assembler.

 
Flash.asm source code for a simple led flash  program. This program turns each LED on in turn,
 then turns them all off. The LEDs are connected to P1 bits 4 to 7, i.e. the same as the PE demo
board. Note: a low turns the leds on and a high off. The program uses a software loop for the
delay, a better way would be to use the built in timer, refer to the data book for details, it is
not difficult. 


serial.asm code for a simple serial comms. This program will display a 
           message, wait for you to type some info (upto 32 chars), then
           echo it back to you. It will then go into echo mode echoing back your keypresses
           Use with a terminal emulation program 
           e.g. HyperTerminal  in WIN95 (in accessories)
           *select hyperterminal 
           *select direct to com1 (in the connect using box)
           * set-up for 4800 baud, 8 data bit 1 stop bit, parity none flow cont none
           
           This program shows how to define storage & relocate the stack. It shows 
           safe locations for code and data.     
      

lcd.asm    Example code showing how to initialise and write data to the lcd via a 4-bit interface.
           Note the bottom 4 bits of port 1 can only be used as inputs.
           The example prints "Hello world! I work" on the LCD (assumes a 20 char display)


If you want to try programming in 'C' try the SDC compiler SDC 
by Sandeep Dutta http://www2.netcom.com/~sandeepd. 
There is even a mailing list for discussing problems with it.


You can contact me Colin Meikle at colin.meikle@virgin.net. All feedback welcome!


