You are on page 1of 2

;*****************************************************************

;* This stationery serves as the framework for a


*
;* user application (single file, absolute assembly application) *
;* For a more comprehensive program that
*
;* demonstrates the more advanced functionality of this
*
;* processor, please see the demonstration applications
*
;* located in the examples subdirectory of the
*
;* Freescale CodeWarrior for the HC12 Program directory
*
;*****************************************************************
; export symbols
XDEF Entry, _Startup
; export 'Entry' symbol
ABSENTRY Entry
; for absolute assembly: mark this as applicat
ion entry point

; Include derivative-specific definitions


INCLUDE 'derivative.inc'
ROMStart

EQU $4000 ; absolute address to place my code/constant data

; variable/data section
ORG RAMStart
; Insert here your data definition.
opcion DS.b 1
dato1 DS.b 1
dato2 DS.b 1
resultado DS.b 2
; code section
ORG ROMStart
Entry:
_Startup:
LDS

#RAMEnd+1

CLI
LDAA #$00
STAA DDRA
Inicio:

CLC
CLR resultado
LDAA PORTA
ANDA #$0F
CMPA #$01
LBEQ Suma
CMPA #$02
LBEQ Resta
CMPA #$04
LBEQ Mult
CMPA #$08
LBEQ Division

; initialize the stack pointer


; enable interrupts

Suma:

LDX #$01
LDAB dato1
ADCB dato2
STAB resultado,X
BCS acarreo
LBRA Inicio

Resta:

LDX #$01
LDAB dato1
SBCB dato2
STAB resultado,X
LBRA Inicio

Mult:

LDAB dato1
LDAA dato2
MUL
STD resultado
LBRA Inicio

Division:

LDD dato1
LDX dato2
IDIV
STX resultado
LBRA Inicio

acarreo:

LDAA #$01
LDX #$00
STAA resultado,X
LBRA Inicio

;**************************************************************
;*
Interrupt Vectors
*
;**************************************************************
ORG $FFFE
DC.W Entry
; Reset Vector

You might also like