EE3376 Programs EE3376 Home

"demo2_sim" program

This is the "demo2_sim" program used for the Code Warrior Stationery tutorial. This version runs on the Simulator; simply remove the interrupt vector code if it is to run on the HCS12 with DBug12 running.


;****************************************************************
;*
;* UTEP EE3376 
;* Program "demo2_sim" 
;* Adds two numbers, stores result and displays results on LEDs
;* on port B. Designed for Code Warrior Simulator. Remove
;* interrupt vector line at end for running on the hcs12 with
;* DBug12 running.
;*
;****************************************************************

; export symbols
            XDEF Entry        	; export 'Entry' symbol
            ABSENTRY Entry    	; for absolute assembly: mark this as application entry point


PSEUDO_ROM    	EQU		$1000  	; absolute address to place code/constant data
RAM		    	EQU  		$1100  	; absolute address to place variables

portb_ddr		EQU		$0003	; data direction register (ddr) for portb
portb			EQU		$0001	; memory address of port B
output			EQU		$FF	; set port B ddr to output
	

;-----------------------------------------------------
; variable/data section
            ORG RAM
; Insert your data definitions here. 
num1:	dc.b	$2a		; first number = 42 decimal
num2:	dc.b	$18		; second number = 24 decimal
res1:	ds.b	1		; reserve one byte for result



;------------------------------------------------------
; code section
	ORG	PSEUDO_ROM	;set PC to $1000
	
; Insert your code following the label "Entry"
Entry:

	movb	#output, portb_ddr		; make port B an output
 	ldaa	num1		; the first number
	adda	num2		; add second number to A and store in A
	staa	res1		; store result in memory
	staa	portb		; light LEDs on port B to binary pattern of res1
	
	swi			; end the program


 ;------------------------------------------------------
; Interrupt Vectors - we need this to run on the Simulator correctly
  	ORG $FFFE		  

  	fdb     Entry      ; Reset
 	
  	
;****************************************************************



EE3376 Programs EE3376 Home