Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;******************************************************************************
- ;*
- ;* CSE3215 Relocatable Assembly Source Code Template for the MC9S12DP256B
- ;* microcontroller.
- ;*
- ;* main.asm
- ;*
- ;* Jan 09, 2006
- ;*
- ;******************************************************************************
- NOLIST
- include "mc9s12dp256.inc" ; Register definitions.
- LIST
- ; export symbols
- XDEF Entry ; export 'Entry' symbol
- ABSENTRY Entry ; for absolute assembly: mark this as application entry point
- MyRAMStart EQU $1000 ; absolute address to place my variablesMy
- MyROMStart EQU $2000 ; absolute address to place my code/constant data
- ; variable/data section
- ORG MyRAMStart
- ; Insert here your data definition. For demonstration, temp_byte is used.
- temp_byte ds.b 1
- ; code section
- ORG MyROMStart
- Entry:
- CLI ; enable interrupts
- MOVB #1,temp_byte ; just some demonstration code
- NOP ; Insert here you own code
- MOVB #FF,DDRB ; Set LED PORTB to be output
- CLC PTB ; Clear contents of LED PORTB
- MOVB #00,DDRH ; Set DDRH0-3 to be input
- LDAA #3E ; Load 62 into accumulator A
- LDAB #C0 ; Load 192 into accumulator B
- BRA Entry ; endless loop
- Compare:
- CMPA PTH ; Compare switch input register PORTH with the accumulator A(62)
- BHI Greater ; Branch if A(62)>PTH
- CMPB PTH ; Compare switch input register PORTH with accumulator B(192)
- BLO Less ; Branch if PTH>192(B)
- MOVB #00,PORTB ; Turn of both LEDs
- BRA Compare ; Else repeat compare
- Less:
- MOVB #01,PORTB ; Turn on LED0(B0)
- BRA Compare
- Greater:
- MOVB #80,PORTB ; Turn on LED7(B7)
- BRA Compare ; Branch back to beginning of compare
Advertisement
Add Comment
Please, Sign In to add comment