Guest User

Untitled

a guest
Oct 7th, 2012
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. main:
  2. ;------------------------------------------------------------------------------
  3. ; Source code template for A251/A51 assembler modules.
  4. ; Copyright (c) 1995-2000 KEIL Software, Inc.
  5. ;------------------------------------------------------------------------------
  6. #include <REG8252.H>     ; include CPU definition file (for example, 8052)
  7. #include "notedefines.h"
  8.  
  9. ;auf Port 1 pin 7 kommt der Ton raus
  10. #define TONEOUT P1_7
  11.  
  12.  
  13. ;------------------------------------------------------------------------------
  14. ; Change names in lowercase to suit your needs.
  15. ;
  16. ; This assembly template gives you an idea of how to use the A251/A51
  17. ; Assembler.  You are not required to build each module this way-this is only
  18. ; an example.
  19. ;
  20. ; All entries except the END statement at the End Of File are optional.
  21. ;
  22. ; If you use this template, make sure you remove any unused segment declarations,
  23. ; as well as unused variable space and assembly instructions.
  24. ;
  25. ; This file cannot provide for every possible use of the A251/A51 Assembler.
  26. ; Refer to the A51/A251 User's Guide for more information.
  27. ;------------------------------------------------------------------------------
  28.  
  29. ;------------------------------------------------------------------------------
  30. ; Module name (optional)
  31. ;------------------------------------------------------------------------------
  32. NAME            MAIN_Module
  33.  
  34. ;------------------------------------------------------------------------------
  35. ; Here, you may import symbols from other modules.
  36. ;------------------------------------------------------------------------------
  37. EXTRN   CODE    (T0_INIT, PlayTone, T1_INIT, PlayNote)
  38. ;------------------------------------------------------------------------------
  39. ; Here, you may export symbols to other modules.
  40. ;------------------------------------------------------------------------------
  41. PUBLIC  start
  42.  
  43. ;------------------------------------------------------------------------------
  44. ; Put the STACK segment in the main module.
  45. ;------------------------------------------------------------------------------
  46. ?STACK          SEGMENT IDATA           ; ?STACK goes into IDATA RAM.
  47.                 RSEG    ?STACK          ; switch to ?STACK segment.
  48.                 DS      5               ; reserve your stack space
  49.                                         ; 5 bytes in this example.
  50. ;------------------------------------------------------------------------------
  51. ; Put segment and variable declarations here.
  52. ;------------------------------------------------------------------------------
  53.  
  54. ;------------------------------------------------------------------------------
  55. ; DATA SEGMENT--Reserves space in DATA RAM--Delete this segment if not used.
  56. ;------------------------------------------------------------------------------
  57.  
  58. ;------------------------------------------------------------------------------
  59. ; XDATA SEGMENT--Reserves space in XDATA RAM--Delete this segment if not used.
  60. ;------------------------------------------------------------------------------
  61.  
  62. ;------------------------------------------------------------------------------
  63. ; INPAGE XDATA SEGMENT--Reserves space in XDATA RAM page (page size: 256 Bytes)
  64. ; INPAGE segments are useful for @R0 addressing methodes.
  65. ; Delete this segment if not used.
  66. ;------------------------------------------------------------------------------
  67.  
  68. ;------------------------------------------------------------------------------
  69. ; ABSOLUTE XDATA SEGMENT--Reserves space in XDATA RAM at absolute addresses.
  70. ; ABSOLUTE segments are useful for memory mapped I/O.
  71. ; Delete this segment if not used.
  72. ;------------------------------------------------------------------------------
  73.  
  74. ;------------------------------------------------------------------------------
  75. ; BIT SEGMENT--Reserves space in BIT RAM--Delete segment if not used.
  76. ;------------------------------------------------------------------------------
  77.  
  78. ;------------------------------------------------------------------------------
  79. ; Add constant (typeless) numbers here.
  80. ;------------------------------------------------------------------------------
  81.  
  82. ;------------------------------------------------------------------------------
  83. ; CODE SEGMENT--Reserves space in CODE ROM for assembler instructions.
  84. ;------------------------------------------------------------------------------
  85. main_code_seg   SEGMENT CODE
  86.        
  87.                 RSEG    main_code_seg   ; switch to this code segment
  88.  
  89.                 USING   0               ; state register_bank used
  90.                                         ; for the following program code.  
  91.            
  92. start:          MOV     SP,#?STACK-1    ; assign stack at beginning
  93.                 SETB EA  ;enable all interrupts
  94.                 SETB ET0 ;enable 1 interrupt namens ET0  
  95.                 MOV     R0,#A4    
  96.         MOV     R1,#VIERTEL    
  97. ;------------------------------------------------------------------------------
  98. ; Insert your assembly program here.  Note, the code below is non-functional.
  99. ;------------------------------------------------------------------------------
  100.         CALL    T0_INIT
  101.         CALL    T1_INIT
  102.         CALL    PlayTone
  103.         CALL    PlayNote
  104.        
  105.    
  106.      
  107.        
  108.         JMP $
  109.                
  110. ;------------------------------------------------------------------------------
  111. ; The END directive is ALWAYS required.
  112. ;------------------------------------------------------------------------------
  113.                 END             ; End Of File
  114.  
  115.  
  116.  
  117.  
  118. basemonitor:
  119. ;------------------------------------------------------------------------------
  120. ; set Reset and other Vectors to Monitor needs
  121. ;------------------------------------------------------------------------------
  122.  
  123. ;------------------------------------------------------------------------------
  124. ; Module name (optional)
  125. ;------------------------------------------------------------------------------
  126. NAME            BASE_Module
  127.  
  128. ;------------------------------------------------------------------------------
  129. ; Here, you may import symbols from other modules.
  130. ;------------------------------------------------------------------------------
  131. EXTRN   CODE   (start)      ; May be a subroutine entry declared in
  132.                                 ; CODE segments or with CODE directive.
  133. EXTRN   CODE   (T0_ISR, T1_ISR)
  134.  
  135. ;------------------------------------------------------------------------------
  136. ; Provide an LJMP to start at the reset address (address 0) in the main module.
  137. ; You may use this style for interrupt service routines.
  138. ;------------------------------------------------------------------------------
  139.                 CSEG    AT      0x8000  ; absolute Segment at Address 0x8000
  140.                 JMP     start           ; reset location (jump to start)
  141.  
  142. ;------------------------------------------------------------------------------
  143. ; Provide an LJMP to T0 Interrupt Service Routine
  144. ;------------------------------------------------------------------------------
  145.                 CSEG    AT      0x800B  ; absolute Segment at Address 0x800B
  146.                 JMP     T0_ISR          ; T0 Interrupt Service Routine
  147.  
  148.         CSEG    AT  0x801B
  149.         JMP T1_ISR
  150.  
  151. ;------------------------------------------------------------------------------
  152. ; The END directive is ALWAYS required.
  153. ;------------------------------------------------------------------------------
  154.                 END             ; End Of File
  155.  
  156.  
  157.  
  158. timer0:
  159. ;------------------------------------------------------------------------------
  160. ; Source code template for A251/A51 assembler modules.
  161. ; Copyright (c) 1995-2000 KEIL Software, Inc.
  162. ;------------------------------------------------------------------------------
  163. #include <REG8252.H>     ; include CPU definition file (for example, 8052)
  164. #define TONEOUT P1_7
  165. ;------------------------------------------------------------------------------
  166. ; Change names in lowercase to suit your needs.
  167. ;
  168. ; This assembly template gives you an idea of how to use the A251/A51
  169. ; Assembler.  You are not required to build each module this way-this is only
  170. ; an example.
  171. ;
  172. ; All entries except the END statement at the End Of File are optional.
  173. ;
  174. ; This file cannot provide for every possible use of the A251/A51 Assembler.
  175. ; Refer to the A51/A251 User's Guide for more information.
  176. ;------------------------------------------------------------------------------
  177.  
  178. ;------------------------------------------------------------------------------
  179. ; Module name (optional)
  180. ;------------------------------------------------------------------------------
  181. NAME            Timer0_Module
  182.  
  183. ;------------------------------------------------------------------------------
  184. ; Here, you may import symbols from other modules.
  185. ;------------------------------------------------------------------------------
  186.  
  187. T0_data_seg   SEGMENT DATA
  188.        
  189.                 RSEG    T0_data_seg     ; switch to this code segment
  190.     t0count:    DS 1
  191.  
  192. ;------------------------------------------------------------------------------
  193. ; Here, you may export symbols to other modules.
  194. ;------------------------------------------------------------------------------
  195. PUBLIC  T0_ISR, T0_INIT, PlayTone
  196.  
  197. ;------------------------------------------------------------------------------
  198. ; CODE SEGMENT--Reserves space in CODE ROM for assembler instructions.
  199. ;------------------------------------------------------------------------------
  200. T0_code_seg   SEGMENT CODE
  201.        
  202.                 RSEG    T0_code_seg     ; switch to this code segment
  203. ;------------------------------------------------------------------------------
  204. ; init T0 to ....
  205. ;------------------------------------------------------------------------------
  206.                 USING   0               ; state register_bank used
  207.                                         ; for the following program code.  
  208. T0_INIT:
  209. ANL     TMOD, #~(T0_MASK_)
  210. ORL     TMOD, #(T0_M1_)
  211.  
  212. MOV t0count,#0
  213.  
  214.  
  215. RET
  216.  
  217. PlayTone:
  218. MOV TH0,R0
  219. MOV TL0,R0
  220. SETB TR0
  221. RET
  222.  
  223. ;------------------------------------------------------------------------------
  224. ; T0 Interrupt Sevice Routine
  225. ;------------------------------------------------------------------------------
  226.                 USING   0               ; state register_bank used
  227.                                         ; for the following program code.  
  228.  
  229. T0_ISR:
  230.         PUSH PSW
  231.         MOV  a,#16 
  232.         INC t0count
  233.         CJNE a,t0count,loop
  234.         CPL TONEOUT
  235.         MOV t0count,#0
  236. loop:   POP PSW
  237.         RETI
  238. ;------------------------------------------------------------------------------
  239. ; The END directive is ALWAYS required.
  240. ;------------------------------------------------------------------------------
  241.                 END             ; End Of File
  242.  
  243.  
  244. timer1:
  245.                          ;------------------------------------------------------------------------------
  246. ; Source code template for A251/A51 assembler modules.
  247. ; Copyright (c) 1995-2000 KEIL Software, Inc.
  248. ;------------------------------------------------------------------------------
  249. #include <REG8252.H>     ; include CPU definition file (for example, 8052)
  250. #define TONEOUT P1_7
  251. ;------------------------------------------------------------------------------
  252. ; Change names in lowercase to suit your needs.
  253. ;
  254. ; This assembly template gives you an idea of how to use the A251/A51
  255. ; Assembler.  You are not required to build each module this way-this is only
  256. ; an example.
  257. ;
  258. ; All entries except the END statement at the End Of File are optional.
  259. ;
  260. ; This file cannot provide for every possible use of the A251/A51 Assembler.
  261. ; Refer to the A51/A251 User's Guide for more information.
  262. ;------------------------------------------------------------------------------
  263.  
  264. ;------------------------------------------------------------------------------
  265. ; Module name (optional)
  266. ;------------------------------------------------------------------------------
  267. NAME            Timer1_Module
  268.  
  269. ;------------------------------------------------------------------------------
  270. ; Here, you may import symbols from other modules.
  271. ;------------------------------------------------------------------------------
  272.  
  273. T1_data_seg   SEGMENT DATA
  274.        
  275.                 RSEG    T1_data_seg     ; switch to this code segment
  276.     t0count:    DS 1
  277.  
  278. ;------------------------------------------------------------------------------
  279. ; Here, you may export symbols to other modules.
  280. ;------------------------------------------------------------------------------
  281. PUBLIC  T1_ISR, T1_INIT, PlayNote
  282.  
  283. ;------------------------------------------------------------------------------
  284. ; CODE SEGMENT--Reserves space in CODE ROM for assembler instructions.
  285. ;------------------------------------------------------------------------------
  286. T1_code_seg   SEGMENT CODE
  287.        
  288.                 RSEG    T1_code_seg     ; switch to this code segment
  289. ;------------------------------------------------------------------------------
  290. ; init T0 to ....
  291. ;------------------------------------------------------------------------------
  292.                 USING   0               ; state register_bank used
  293.                                         ; for the following program code.  
  294. T1_INIT:
  295. ANL     TMOD, #~(T1_MASK_) // Was ist den die Maske für Mod1 laden?
  296. ORL     TMOD, #(T1_M1_)  //
  297.  
  298.  
  299. RET
  300.  
  301. PlayNote:
  302.  
  303.  
  304. ;------------------------------------------------------------------------------
  305. ; T0 Interrupt Sevice Routine
  306. ;------------------------------------------------------------------------------
  307.                 USING   0               ; state register_bank used
  308.                                         ; for the following program code.  
  309.  
  310. T1_ISR:
  311.         PUSH PSW
  312.        
  313.         CLR TR0 // Timer0 stoppen  
  314.  
  315.         POP PSW    
  316.         RETI
  317. ;------------------------------------------------------------------------------
  318. ; The END directive is ALWAYS required.
  319. ;------------------------------------------------------------------------------
  320.                 END             ; End Of File
  321.  
  322.  
  323.  
  324.  
  325. notesdefine.h:
  326. // Definition der Zähler für die Töne und die Tonlängen
  327.  
  328. #define B3 //233,03 Hz
  329. #define H3 //246,96 Hz
  330.  
  331. #define C4 //261,63 Hz
  332. #define D4 //293,66 Hz
  333. #define Es4 //311,13 Hz
  334. #define E4 //329,63 Hz
  335. #define F4 //349,23 Hz
  336. #define G4 //392,00 Hz
  337. #define A4 114 //440 Hz
  338. #define H4 //493,88 Hz
  339.  
  340. #define C5 //523,25 Hz
  341. #define D5 //587,33 Hz
  342. #define E5 //659,26 Hz
  343.  
  344.  
  345. //100mps
  346.  
  347.  
  348. #define VIERTEL 4 //4*150 = 600ms(da man ja 600dez nicht laden kann)
  349. #define VIERTEL_PUNKT
  350. #define ACHTEL 2 // 2*150 = 300ms
  351. #define SECHZENTEL 1  // 1*150 = 150ms
  352. #define GANZE 16 // 16*150 = 2400ms
  353. #define HALBE 8 // 8*150 = 1200ms
Advertisement
Add Comment
Please, Sign In to add comment