TheLegace

Lab1P1

Jan 20th, 2012
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;******************************************************************************
  2. ;*
  3. ;* CSE3215 Relocatable Assembly Source Code Template for the MC9S12DP256B
  4. ;* microcontroller.
  5. ;*
  6. ;* main.asm
  7. ;*
  8. ;* Jan 09, 2006
  9. ;*
  10. ;******************************************************************************
  11.  
  12.  NOLIST
  13.  include    "mc9s12dp256.inc"   ; Register definitions.
  14.  LIST
  15.  
  16. ; export symbols
  17.             XDEF Entry        ; export 'Entry' symbol
  18.             ABSENTRY Entry    ; for absolute assembly: mark this as application entry point
  19.  
  20.  
  21. MyRAMStart    EQU  $1000  ; absolute address to place my variablesMy
  22. MyROMStart    EQU  $2000  ; absolute address to place my code/constant data
  23.  
  24. ; variable/data section
  25.             ORG MyRAMStart
  26. ; Insert here your data definition. For demonstration, temp_byte is used.
  27. temp_byte   ds.b 1
  28.  
  29.  
  30. ; code section
  31.             ORG MyROMStart
  32. Entry:
  33.             CLI                ; enable interrupts
  34.  
  35.             MOVB #1,temp_byte  ; just some demonstration code
  36.             NOP                ; Insert here you own code
  37.            
  38.             MOVB #FF,DDRB      ; Set LED PORTB to be output
  39.             CLC PTB            ; Clear contents of LED PORTB
  40.             MOVB #00,DDRH      ; Set DDRH0-3 to be input
  41.             LDAA #3E           ; Load 62 into accumulator A
  42.             LDAB #C0           ; Load 192 into accumulator B
  43.            
  44.             BRA Entry  ; endless loop
  45. Compare:
  46.             CMPA PTH           ; Compare switch input register PORTH with the accumulator A(62)
  47.             BHI Greater        ; Branch if A(62)>PTH
  48.             CMPB PTH           ; Compare switch input register PORTH with accumulator B(192)
  49.             BLO Less           ; Branch if PTH>192(B)
  50.             MOVB #00,PORTB     ; Turn of both LEDs
  51.             BRA Compare        ; Else repeat compare
  52. Less:
  53.             MOVB #01,PORTB     ; Turn on LED0(B0)
  54.             BRA Compare
  55. Greater:   
  56.             MOVB #80,PORTB     ; Turn on LED7(B7)
  57.             BRA Compare        ; Branch back to beginning of compare
Advertisement
Add Comment
Please, Sign In to add comment