; Freeware, Program: hello51.asm
;
;Micorsoft users: The best way to run j51 simulator is via the command line mode:
;
;(1) First open a dos command-line window:
;
;    Start --> All programs --> accessories  --> command prompt
;
;    (i.e. open a dos window, msdos window, or command prompt, 
;    depends on which version of windows).
;
;(2) dos window: Change to the root directory like this: cd c:\
;
;(3) dos window: now make a new directory like this: mkdir c:\eecs_281
;
;(4) dos window: Change directory to c:\eecs_314 like this: cd c:\eecs_281
;
;(5) Browser: First download the j51.jar, j51.conf, hello51.hex from
;    http://bear.ces.cwru.edu/eecs_281 into a directory called c:\eecs_281
;    via web browser by clicking right mouse button over the link and
;    select save link as ... into "c:\eecs_281"
;    
;(6) dos window: list the directory by typing: dir
;    The j51.jar, j51.conf, hello51.hex files should appear
;    in that directory.
;    
;(7) dos window: test if java is installed properly in your system
;    by typing: java -version
;    and the output should say:
;
;    java version "1.5.0_01"
;    Java(TM) Runtime Environment ....
;
;    (a) if command not found or missing you need to install java at
;    http://www.java.com
;
;    (b) if your version is not 1.5 or greater then you need to upgrade
;    java using http://www.java,com
;
;(8) dos window: to execute the j51 now type: java -jar j51.jar
;
;(9) Now File --> load  --> hello51.hex
;    (note: 8051 files can only be read via the j51 program.) 
;
;(10) "On J51 simulator set "CPU" to j51.intel.P8051"
;
;(11) "Go" and Peripheral output should say: Hello, World and Goodbye
;
;(12) "Stop"
;
;(13) File --> Exit
;
;(14) Download assembler: use browser at http://bear.ces.cwru.edu/eecs_281
;     and save link as "c:\eecs_281\as31.exe" for windows PC.
;
;(15) In order to assemble this you need another program called as31 and
; execute it also in the dos command line: 
;
;      as31 -l hello51.asm
;
; will output a listing file and a intel hex file: hello51.lst and hello51.hex
; After assembly, now you can proceed to step (1) to simulate your program.
;

	.org  0h 
start:
	mov   TMOD, #20h ; set timer 1 for auto reload 
	mov   TCON, #41h ; run counter 1 edge trig
	mov   TH1,  #0FDh ; 9600 baud
	mov   SCON,#50h ; 8-bit data mode 1 

	mov   dptr,#msg1
	lcall puts
	mov   dptr,#msg2
	lcall puts
idle:	sjmp  idle

puts:
        clr   a
	movc  a,@a+dptr
	jz    putret
	clr   TI
	mov   SBUF, A
puts1:	jnb   TI,puts1
	inc   dptr
	sjmp  puts

putchar:
	clr   TI
	mov   SBUF, A
putchar1:
	jnb   TI, putchar1
putret:ret


msg1:	.byte	'H','e','l','l','o',',',' '
	.byte	'W','o','r','l','d',0x0a, 0

msg2:   .byte   'G','o','o','d','b','y','e',0x0a,0

	.end

