Advertisement
Guest User

Untitled

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