Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main:
- ;------------------------------------------------------------------------------
- ; Source code template for A251/A51 assembler modules.
- ; Copyright (c) 1995-2000 KEIL Software, Inc.
- ;------------------------------------------------------------------------------
- #include <REG8252.H> ; include CPU definition file (for example, 8052)
- #include "notedefines.h" ; include notedefines (user definition for playing notes)
- ;------------------------------------------------------------------------------
- ; Change names in lowercase to suit your needs.
- ;
- ; This assembly template gives you an idea of how to use the A251/A51
- ; Assembler. You are not required to build each module this way-this is only
- ; an example.
- ;
- ; All entries except the END statement at the End Of File are optional.
- ;
- ; If you use this template, make sure you remove any unused segment declarations,
- ; as well as unused variable space and assembly instructions.
- ;
- ; This file cannot provide for every possible use of the A251/A51 Assembler.
- ; Refer to the A51/A251 User's Guide for more information.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; Module name (optional)
- ;------------------------------------------------------------------------------
- NAME MAIN_Module
- ;------------------------------------------------------------------------------
- ; Here, you may import symbols from other modules.
- ;------------------------------------------------------------------------------
- EXTRN CODE (T0_INIT)
- ;------------------------------------------------------------------------------
- ; Here, you may export symbols to other modules.
- ;------------------------------------------------------------------------------
- PUBLIC start
- ;------------------------------------------------------------------------------
- ; Put the STACK segment in the main module.
- ;------------------------------------------------------------------------------
- ?STACK SEGMENT IDATA ; ?STACK goes into IDATA RAM.
- RSEG ?STACK ; switch to ?STACK segment.
- DS 5 ; reserve your stack space
- ; 5 bytes in this example.
- ;------------------------------------------------------------------------------
- ; Put segment and variable declarations here.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; DATA SEGMENT--Reserves space in DATA RAM--Delete this segment if not used.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; XDATA SEGMENT--Reserves space in XDATA RAM--Delete this segment if not used.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; INPAGE XDATA SEGMENT--Reserves space in XDATA RAM page (page size: 256 Bytes)
- ; INPAGE segments are useful for @R0 addressing methodes.
- ; Delete this segment if not used.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; ABSOLUTE XDATA SEGMENT--Reserves space in XDATA RAM at absolute addresses.
- ; ABSOLUTE segments are useful for memory mapped I/O.
- ; Delete this segment if not used.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; BIT SEGMENT--Reserves space in BIT RAM--Delete segment if not used.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; Add constant (typeless) numbers here.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; CODE SEGMENT--Reserves space in CODE ROM for assembler instructions.
- ;------------------------------------------------------------------------------
- main_code_seg SEGMENT CODE
- RSEG main_code_seg ; switch to this code segment
- USING 0 ; state register_bank used
- ; for the following program code.
- start: MOV SP,#?STACK-1 ; assign stack at beginning
- ;------------------------------------------------------------------------------
- ; Insert your assembly program here. Note, the code below is non-functional.
- ;------------------------------------------------------------------------------
- SETB ET0;Timer 0 interrupt
- SETB ET1;Timer 1 interrupt
- SETB EA;enable all interrupt
- MOV R0, #A4 ;Reloadvalue für Kammerton A4 = 440Hz setzen
- CALL T0_INIT
- ;CALL T1_INIT
- ; CALL PlayNote
- JMP $
- ;------------------------------------------------------------------------------
- ; The END directive is ALWAYS required.
- ;------------------------------------------------------------------------------
- END ; End Of File
- basemon:
- ;------------------------------------------------------------------------------
- ; set Reset and other Vectors to Monitor needs
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; Module name (optional)
- ;------------------------------------------------------------------------------
- NAME BASE_Module
- ;------------------------------------------------------------------------------
- ; Here, you may import symbols from other modules.
- ;------------------------------------------------------------------------------
- EXTRN CODE (start) ; May be a subroutine entry declared in
- ; CODE segments or with CODE directive.
- EXTRN CODE (T0_ISR)
- ;------------------------------------------------------------------------------
- ; Provide an LJMP to start at the reset address (address 0) in the main module.
- ; You may use this style for interrupt service routines.
- ;------------------------------------------------------------------------------
- CSEG AT 0x8000 ; absolute Segment at Address 0x8000
- JMP start ; reset location (jump to start)
- ;------------------------------------------------------------------------------
- ; Provide an LJMP to T0 Interrupt Service Routine
- ;------------------------------------------------------------------------------
- CSEG AT 0x800B ; absolute Segment at Address 0x800B
- JMP T0_ISR ; T0 Interrupt Service Routine
- ;------------------------------------------------------------------------------
- ; The END directive is ALWAYS required.
- ;------------------------------------------------------------------------------
- END ; End Of File
- timer0:
- ;------------------------------------------------------------------------------
- ; Source code template for A251/A51 assembler modules.
- ; Copyright (c) 1995-2000 KEIL Software, Inc.
- ;------------------------------------------------------------------------------
- #include <REG8252.H> ; include CPU definition file (for example, 8052)
- #define TONEOUT P1_7 //Ausgabepins für den Ton
- #define Reloadvalue 5535
- ;------------------------------------------------------------------------------
- ; Change names in lowercase to suit your needs.
- ;
- ; This assembly template gives you an idea of how to use the A251/A51
- ; Assembler. You are not required to build each module this way-this is only
- ; an example.
- ;
- ; All entries except the END statement at the End Of File are optional.
- ;
- ; This file cannot provide for every possible use of the A251/A51 Assembler.
- ; Refer to the A51/A251 User's Guide for more information.
- ;------------------------------------------------------------------------------
- ;------------------------------------------------------------------------------
- ; Module name (optional)
- ;------------------------------------------------------------------------------
- NAME Timer0_Module
- ;------------------------------------------------------------------------------
- ; Here, you may import symbols from other modules.
- ;------------------------------------------------------------------------------
- T0_data_seg SEGMENT DATA
- RSEG T0_data_seg
- t0count: DS 1
- ;------------------------------------------------------------------------------
- ; Here, you may export symbols to other modules.
- ;------------------------------------------------------------------------------
- PUBLIC T0_ISR, T0_INIT
- ;------------------------------------------------------------------------------
- ; CODE SEGMENT--Reserves space in CODE ROM for assembler instructions.
- ;------------------------------------------------------------------------------
- T0_code_seg SEGMENT CODE
- RSEG T0_code_seg ; switch to this code segment
- USING 0 ; state register_bank used
- ; for the following program code.
- ;------------------------------------------------------------------------------
- ; init T0 to 8 Bit autoreload Timer
- ;------------------------------------------------------------------------------
- T0_INIT:
- ANL TMOD, #1111$0010B
- ;ORL TMOD, #(T0_M1_)
- MOV TH0, R0 ;Reloadvalue setzen
- MOV TL0, R0
- SETB TR0 ; Timer 0 starten
- RET
- ;------------------------------------------------------------------------------
- ; init T1 to 16 Bit Timer
- ;------------------------------------------------------------------------------
- ;T1_INIT:
- ;ANL TMOD, #~(T1_MASK_)
- ;ORL TMOD, #(T1_M0_)
- ;RET
- ;PlayTone:
- ;CALL PlayNote
- ;Reloadvalue für T1 setzen
- ;MOV TH1, #HIGH(Reloadvalue)
- ;MOV TL1, #LOW(Reloadvalue)
- ;CLR TR0
- ;SETB TR1 ;T1 starten
- ;RET
- ;PlayNote:
- ;MOV A,#2
- ;MOV TH0, R0 ;Reloadvalue setzen
- ;SETB TR0 ; Timer 0 starten
- ;------------------------------------------------------------------------------
- ; T0 Interrupt Sevice Routine
- ;------------------------------------------------------------------------------
- USING 1 ; state register_bank used
- ; for the following program code.
- T0_ISR:
- PUSH PSW
- SETB RS0 ; select Registerbank 1
- CLR RS1
- MOV A,#16
- CJNE A,t0count,return
- INC t0count
- CPL TONEOUT
- POP PSW
- return: RETI
- ;-------------------0-----------------------------------------------------------
- ; The END directive is ALWAYS required.
- ;------------------------------------------------------------------------------
- END ; End Of File
Add Comment
Please, Sign In to add comment