Guest User

Untitled

a guest
Dec 9th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. main:
  2.  
  3. ;------------------------------------------------------------------------------
  4. ; Source code template for A251/A51 assembler modules.
  5. ; Copyright (c) 1995-2000 KEIL Software, Inc.
  6. ;------------------------------------------------------------------------------
  7. #include <REG8252.H>     ; include CPU definition file (for example, 8052)
  8. #include "notedefines.h" ; include notedefines (user definition for playing notes)
  9. ;------------------------------------------------------------------------------
  10. ; Change names in lowercase to suit your needs.
  11. ;
  12. ; This assembly template gives you an idea of how to use the A251/A51
  13. ; Assembler.  You are not required to build each module this way-this is only
  14. ; an example.
  15. ;
  16. ; All entries except the END statement at the End Of File are optional.
  17. ;
  18. ; If you use this template, make sure you remove any unused segment declarations,
  19. ; as well as unused variable space and assembly instructions.
  20. ;
  21. ; This file cannot provide for every possible use of the A251/A51 Assembler.
  22. ; Refer to the A51/A251 User's Guide for more information.
  23. ;------------------------------------------------------------------------------
  24.  
  25. ;------------------------------------------------------------------------------
  26. ; Module name (optional)
  27. ;------------------------------------------------------------------------------
  28. NAME            MAIN_Module
  29.  
  30. ;------------------------------------------------------------------------------
  31. ; Here, you may import symbols from other modules.
  32. ;------------------------------------------------------------------------------
  33. EXTRN   CODE    (T0_INIT)
  34. ;------------------------------------------------------------------------------
  35. ; Here, you may export symbols to other modules.
  36. ;------------------------------------------------------------------------------
  37. PUBLIC  start
  38.  
  39. ;------------------------------------------------------------------------------
  40. ; Put the STACK segment in the main module.
  41. ;------------------------------------------------------------------------------
  42. ?STACK          SEGMENT IDATA           ; ?STACK goes into IDATA RAM.
  43.                 RSEG    ?STACK          ; switch to ?STACK segment.
  44.                 DS      5               ; reserve your stack space
  45.                                         ; 5 bytes in this example.
  46. ;------------------------------------------------------------------------------
  47. ; Put segment and variable declarations here.
  48. ;------------------------------------------------------------------------------
  49.  
  50. ;------------------------------------------------------------------------------
  51. ; DATA SEGMENT--Reserves space in DATA RAM--Delete this segment if not used.
  52. ;------------------------------------------------------------------------------
  53.  
  54. ;------------------------------------------------------------------------------
  55. ; XDATA SEGMENT--Reserves space in XDATA RAM--Delete this segment if not used.
  56. ;------------------------------------------------------------------------------
  57.  
  58. ;------------------------------------------------------------------------------
  59. ; INPAGE XDATA SEGMENT--Reserves space in XDATA RAM page (page size: 256 Bytes)
  60. ; INPAGE segments are useful for @R0 addressing methodes.
  61. ; Delete this segment if not used.
  62. ;------------------------------------------------------------------------------
  63.  
  64. ;------------------------------------------------------------------------------
  65. ; ABSOLUTE XDATA SEGMENT--Reserves space in XDATA RAM at absolute addresses.
  66. ; ABSOLUTE segments are useful for memory mapped I/O.
  67. ; Delete this segment if not used.
  68. ;------------------------------------------------------------------------------
  69.  
  70. ;------------------------------------------------------------------------------
  71. ; BIT SEGMENT--Reserves space in BIT RAM--Delete segment if not used.
  72. ;------------------------------------------------------------------------------
  73.  
  74. ;------------------------------------------------------------------------------
  75. ; Add constant (typeless) numbers here.
  76. ;------------------------------------------------------------------------------
  77.  
  78. ;------------------------------------------------------------------------------
  79. ; CODE SEGMENT--Reserves space in CODE ROM for assembler instructions.
  80. ;------------------------------------------------------------------------------
  81. main_code_seg   SEGMENT CODE
  82.        
  83.                 RSEG    main_code_seg   ; switch to this code segment
  84.  
  85.                 USING   0               ; state register_bank used
  86.                                         ; for the following program code.  
  87.  
  88. start:          MOV     SP,#?STACK-1    ; assign stack at beginning
  89.  
  90. ;------------------------------------------------------------------------------
  91. ; Insert your assembly program here.  Note, the code below is non-functional.
  92. ;------------------------------------------------------------------------------
  93.         SETB    ET0;Timer 0 interrupt
  94.         SETB    ET1;Timer 1 interrupt
  95.         SETB    EA;enable all interrupt
  96.        
  97.         MOV R0, #A4     ;Reloadvalue für Kammerton A4 = 440Hz  setzen
  98.         CALL T0_INIT
  99.         ;CALL T1_INIT
  100.        
  101.     ;   CALL PlayNote
  102.        
  103.        
  104.        
  105.        
  106.        
  107.        
  108.         JMP $
  109.                
  110. ;------------------------------------------------------------------------------
  111. ; The END directive is ALWAYS required.
  112. ;------------------------------------------------------------------------------
  113.         END             ; End Of File
  114.  
  115.  
  116. basemon:
  117. ;------------------------------------------------------------------------------
  118. ; set Reset and other Vectors to Monitor needs
  119. ;------------------------------------------------------------------------------
  120.  
  121. ;------------------------------------------------------------------------------
  122. ; Module name (optional)
  123. ;------------------------------------------------------------------------------
  124. NAME            BASE_Module
  125.  
  126. ;------------------------------------------------------------------------------
  127. ; Here, you may import symbols from other modules.
  128. ;------------------------------------------------------------------------------
  129. EXTRN   CODE   (start)      ; May be a subroutine entry declared in
  130.                                 ; CODE segments or with CODE directive.
  131. EXTRN   CODE   (T0_ISR)
  132.  
  133. ;------------------------------------------------------------------------------
  134. ; Provide an LJMP to start at the reset address (address 0) in the main module.
  135. ; You may use this style for interrupt service routines.
  136. ;------------------------------------------------------------------------------
  137.                 CSEG    AT      0x8000  ; absolute Segment at Address 0x8000
  138.                 JMP     start           ; reset location (jump to start)
  139.  
  140. ;------------------------------------------------------------------------------
  141. ; Provide an LJMP to T0 Interrupt Service Routine
  142. ;------------------------------------------------------------------------------
  143.                 CSEG    AT      0x800B  ; absolute Segment at Address 0x800B
  144.                 JMP     T0_ISR          ; T0 Interrupt Service Routine
  145.  
  146. ;------------------------------------------------------------------------------
  147. ; The END directive is ALWAYS required.
  148. ;------------------------------------------------------------------------------
  149.                 END             ; End Of File
  150.  
  151.  
  152.  
  153. timer0:
  154.  
  155. ;------------------------------------------------------------------------------
  156. ; Source code template for A251/A51 assembler modules.
  157. ; Copyright (c) 1995-2000 KEIL Software, Inc.
  158. ;------------------------------------------------------------------------------
  159. #include <REG8252.H>     ; include CPU definition file (for example, 8052)
  160. #define TONEOUT P1_7        //Ausgabepins für den Ton
  161. #define Reloadvalue 5535
  162. ;------------------------------------------------------------------------------
  163. ; Change names in lowercase to suit your needs.
  164. ;
  165. ; This assembly template gives you an idea of how to use the A251/A51
  166. ; Assembler.  You are not required to build each module this way-this is only
  167. ; an example.
  168. ;
  169. ; All entries except the END statement at the End Of File are optional.
  170. ;
  171. ; This file cannot provide for every possible use of the A251/A51 Assembler.
  172. ; Refer to the A51/A251 User's Guide for more information.
  173. ;------------------------------------------------------------------------------
  174.  
  175. ;------------------------------------------------------------------------------
  176. ; Module name (optional)
  177. ;------------------------------------------------------------------------------
  178. NAME            Timer0_Module
  179.  
  180. ;------------------------------------------------------------------------------
  181. ; Here, you may import symbols from other modules.
  182. ;------------------------------------------------------------------------------
  183.  
  184. T0_data_seg   SEGMENT DATA
  185.        
  186. RSEG    T0_data_seg  
  187. t0count: DS 1
  188.  
  189. ;------------------------------------------------------------------------------
  190. ; Here, you may export symbols to other modules.
  191. ;------------------------------------------------------------------------------
  192. PUBLIC  T0_ISR, T0_INIT
  193.  
  194. ;------------------------------------------------------------------------------
  195. ; CODE SEGMENT--Reserves space in CODE ROM for assembler instructions.
  196. ;------------------------------------------------------------------------------
  197. T0_code_seg   SEGMENT CODE
  198.        
  199.                 RSEG    T0_code_seg     ; switch to this code segment
  200.                
  201.                 USING   0               ; state register_bank used
  202.                                         ; for the following program code.
  203. ;------------------------------------------------------------------------------
  204. ; init T0 to 8 Bit autoreload Timer
  205. ;------------------------------------------------------------------------------
  206. T0_INIT:
  207. ANL     TMOD, #1111$0010B
  208. ;ORL    TMOD, #(T0_M1_)
  209. MOV     TH0, R0 ;Reloadvalue setzen
  210. MOV     TL0, R0
  211.  
  212. SETB    TR0 ; Timer 0 starten
  213.  
  214. RET
  215.  
  216. ;------------------------------------------------------------------------------
  217. ; init T1 to 16 Bit Timer
  218. ;------------------------------------------------------------------------------
  219. ;T1_INIT:
  220. ;ANL    TMOD, #~(T1_MASK_)
  221. ;ORL    TMOD, #(T1_M0_)
  222. ;RET
  223.  
  224.  
  225. ;PlayTone:
  226. ;CALL PlayNote
  227. ;Reloadvalue für T1 setzen
  228. ;MOV TH1, #HIGH(Reloadvalue)
  229. ;MOV TL1, #LOW(Reloadvalue)
  230. ;CLR TR0
  231. ;SETB   TR1 ;T1 starten
  232.  
  233. ;RET
  234.  
  235.  
  236. ;PlayNote:
  237. ;MOV A,#2
  238. ;MOV    TH0, R0 ;Reloadvalue setzen
  239. ;SETB   TR0 ; Timer 0 starten
  240.  
  241.  
  242.  
  243.  
  244. ;------------------------------------------------------------------------------
  245. ; T0 Interrupt Sevice Routine
  246. ;------------------------------------------------------------------------------
  247.                 USING   1               ; state register_bank used
  248.                                         ; for the following program code.  
  249.  
  250. T0_ISR:  
  251.         PUSH    PSW
  252.         SETB    RS0     ; select Registerbank 1
  253.         CLR RS1
  254.         MOV A,#16
  255.         CJNE A,t0count,return
  256.         INC t0count
  257.         CPL TONEOUT
  258.         POP PSW
  259. return: RETI
  260. ;-------------------0-----------------------------------------------------------
  261. ; The END directive is ALWAYS required.
  262. ;------------------------------------------------------------------------------
  263.                 END             ; End Of File
Add Comment
Please, Sign In to add comment