Advertisement
abdullahkahraman

Microchip Forums: RTOS implementation - Dissambly Listing 3

Jun 13th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Disassembly Listing for messingWithRTOS
  2. Generated From:
  3.  
  4. ---  D:/Documents/MPLABXProjects/messingWithRTOS.X/dist/default/production/messingWithRTOS.X.production.as
  5. 1:             opt subtitle "HI-TECH Software Omniscient Code Generator (Lite mode) build 12136"
  6. 2:            
  7. 3:             opt pagewidth 120
  8. 4:            
  9. 5:              opt lm
  10. 6:            
  11. 7:              processor   16F616
  12. 8:             clrc macro
  13. 9:              bcf 3,0
  14. 10:             endm
  15. 11:            clrz macro
  16. 12:             bcf 3,2
  17. 13:             endm
  18. 14:            setc macro
  19. 15:             bsf 3,0
  20. 16:             endm
  21. 17:            setz macro
  22. 18:             bsf 3,2
  23. 19:             endm
  24. 20:            skipc    macro
  25. 21:             btfss   3,0
  26. 22:             endm
  27. 23:            skipz    macro
  28. 24:             btfss   3,2
  29. 25:             endm
  30. 26:            skipnc   macro
  31. 27:             btfsc   3,0
  32. 28:             endm
  33. 29:            skipnz   macro
  34. 30:             btfsc   3,2
  35. 31:             endm
  36. 32:            indf equ 0
  37. 33:            indf0    equ 0
  38. 34:            pc   equ 2
  39. 35:            pcl  equ 2
  40. 36:            status   equ 3
  41. 37:            fsr  equ 4
  42. 38:            fsr0 equ 4
  43. 39:            c    equ 1
  44. 40:            z    equ 0
  45. 41:            pclath   equ 10
  46. 42:            # 8 "arrray_asm.c"
  47. 43:            psect config,class=CONFIG,delta=2 ;#
  48. 44:            # 8 "arrray_asm.c"
  49. 45:            dw 0xFFFC & 0xFFF7 & 0xFFEF & 0xFFDF & 0xFFFF & 0xFF7F & 0xFFFF ;#
  50. 46:             FNCALL  _main,_fTask1
  51. 47:             FNCALL  _main,_fTask2
  52. 48:             FNROOT  _main
  53. 49:             global  _tasks
  54. 50:             global  _currentTask
  55. 51:             global  _PORTA
  56. 52:            _PORTA   set 0x5
  57. 53:             global  _PORTC
  58. 54:            _PORTC   set 0x7
  59. 55:             global  _ANSEL
  60. 56:            _ANSEL   set 0x91
  61. 57:             global  _TRISA
  62. 58:            _TRISA   set 0x85
  63. 59:             global  _TRISC
  64. 60:            _TRISC   set 0x87
  65. 61:            psect    text36,local,class=CODE,delta=2,merge=1
  66. 62:            global __ptext36
  67. 63:            __ptext36:
  68. 64:             file    "dist/default/production\messingWithRTOS.X.production.as"
  69. 65:             line    #
  70. 66:            psect cinit,class=CODE,delta=2
  71. 67:            global start_initialization
  72. 68:            start_initialization:
  73. 69:            
  74. 70:            psect    bssCOMMON,class=COMMON,space=1
  75. 71:            global __pbssCOMMON
  76. 72:            __pbssCOMMON:
  77. 73:            _tasks:
  78. 74:                   ds      4
  79. 75:            
  80. 76:            _currentTask:
  81. 77:                   ds      1
  82. 78:            
  83. 79:            ; Clear objects allocated to COMMON
  84. 80:            psect cinit,class=CODE,delta=2,merge=1
  85. 81:             clrf    ((__pbssCOMMON)+0)&07Fh
  86. 07A4  01F0     CLRF tasks
  87. 82:             clrf    ((__pbssCOMMON)+1)&07Fh
  88. 07A5  01F1     CLRF 0x71
  89. 83:             clrf    ((__pbssCOMMON)+2)&07Fh
  90. 07A6  01F2     CLRF 0x72
  91. 84:             clrf    ((__pbssCOMMON)+3)&07Fh
  92. 07A7  01F3     CLRF 0x73
  93. 85:             clrf    ((__pbssCOMMON)+4)&07Fh
  94. 07A8  01F4     CLRF currentTask
  95. 86:            psect cinit,class=CODE,delta=2,merge=1
  96. 87:            global end_of_initialization
  97. 88:            
  98. 89:            ;End of C runtime variable initialization code
  99. 90:            
  100. 91:            end_of_initialization:
  101. 92:            clrf status
  102. 07A9  0183     CLRF STATUS
  103. 93:            ljmp _main   ;jump to C main() function
  104. 07AA  2FE3     GOTO 0x7E3
  105. 94:            psect    cstackCOMMON,class=COMMON,space=1
  106. 95:            global __pcstackCOMMON
  107. 96:            __pcstackCOMMON:
  108. 97:             global  ?_fTask1
  109. 98:            ?_fTask1:    ; 0 bytes @ 0x0
  110. 99:             global  ??_fTask1
  111. 100:           ??_fTask1:   ; 0 bytes @ 0x0
  112. 101:            global  ?_fTask2
  113. 102:           ?_fTask2:    ; 0 bytes @ 0x0
  114. 103:            global  ??_fTask2
  115. 104:           ??_fTask2:   ; 0 bytes @ 0x0
  116. 105:            global  ?_main
  117. 106:           ?_main:  ; 0 bytes @ 0x0
  118. 107:            global  ??_main
  119. 108:           ??_main: ; 0 bytes @ 0x0
  120. 109:            ds  1
  121. 110:           ;!
  122. 111:           ;!Data Sizes:
  123. 112:           ;!    Strings     0
  124. 113:           ;!    Constant    0
  125. 114:           ;!    Data        0
  126. 115:           ;!    BSS         5
  127. 116:           ;!    Persistent  0
  128. 117:           ;!    Stack       0
  129. 118:           ;!
  130. 119:           ;!Auto Spaces:
  131. 120:           ;!    Space          Size  Autos    Used
  132. 121:           ;!    COMMON           14      1       6
  133. 122:           ;!    BANK0            80      0       0
  134. 123:           ;!    BANK1            32      0       0
  135. 124:          
  136. 125:           ;!
  137. 126:           ;!Pointer List with Targets:
  138. 127:           ;!
  139. 128:           ;!    None.
  140. 129:          
  141. 130:          
  142. 131:           ;!
  143. 132:           ;!Critical Paths under _main in COMMON
  144. 133:           ;!
  145. 134:           ;!    None.
  146. 135:           ;!
  147. 136:           ;!Critical Paths under _main in BANK0
  148. 137:           ;!
  149. 138:           ;!    None.
  150. 139:           ;!
  151. 140:           ;!Critical Paths under _main in BANK1
  152. 141:           ;!
  153. 142:           ;!    None.
  154. 143:          
  155. 144:           ;;
  156. 145:           ;;Main: autosize = 0, tempsize = 1, incstack = 0, save=0
  157. 146:           ;;
  158. 147:          
  159. 148:           ;!
  160. 149:           ;!Call Graph Tables:
  161. 150:           ;!
  162. 151:           ;! ---------------------------------------------------------------------------------
  163. 152:           ;! (Depth) Function              Calls       Base Space   Used Autos Params    Refs
  164. 153:           ;! ---------------------------------------------------------------------------------
  165. 154:           ;! (0) _main                                                 1     1      0       0
  166. 155:           ;!                                              0 COMMON     1     1      0
  167. 156:           ;!                             _fTask1
  168. 157:           ;!                             _fTask2
  169. 158:           ;! ---------------------------------------------------------------------------------
  170. 159:           ;! (1) _fTask1                                               0     0      0       0
  171. 160:           ;! ---------------------------------------------------------------------------------
  172. 161:           ;! (1) _fTask2                                               0     0      0       0
  173. 162:           ;! ---------------------------------------------------------------------------------
  174. 163:           ;! Estimated maximum stack depth 1
  175. 164:           ;! ---------------------------------------------------------------------------------
  176. 165:           ;!
  177. 166:           ;! Call Graph Graphs:
  178. 167:           ;!
  179. 168:           ;! _main (ROOT)
  180. 169:           ;!   _fTask1
  181. 170:           ;!   _fTask2
  182. 171:           ;!
  183. 172:          
  184. 173:           ;! Address spaces:
  185. 174:          
  186. 175:           ;!Name               Size   Autos  Total    Cost      Usage
  187. 176:           ;!BITCOMMON            E      0       0       0        0.0%
  188. 177:           ;!NULL                 0      0       0       0        0.0%
  189. 178:           ;!CODE                 0      0       0       0        0.0%
  190. 179:           ;!COMMON               E      1       6       1       42.9%
  191. 180:           ;!BITSFR0              0      0       0       1        0.0%
  192. 181:           ;!SFR0                 0      0       0       1        0.0%
  193. 182:           ;!BITSFR1              0      0       0       2        0.0%
  194. 183:           ;!SFR1                 0      0       0       2        0.0%
  195. 184:           ;!STACK                0      0       1       2        0.0%
  196. 185:           ;!BITBANK0            50      0       0       3        0.0%
  197. 186:           ;!BANK0               50      0       0       4        0.0%
  198. 187:           ;!BANK1               20      0       0       5        0.0%
  199. 188:           ;!ABS                  0      0       6       6        0.0%
  200. 189:           ;!BITBANK1            20      0       0       7        0.0%
  201. 190:           ;!DATA                 0      0       7       8        0.0%
  202. 191:          
  203. 192:            global  _main
  204. 193:          
  205. 194:           ;; *************** function _main *****************
  206. 195:           ;; Defined at:
  207. 196:           ;;       line 18 in file "arrray_asm.c"
  208. 197:           ;; Parameters:    Size  Location     Type
  209. 198:           ;;       None
  210. 199:           ;; Auto vars:     Size  Location     Type
  211. 200:           ;;       None
  212. 201:           ;; Return value:  Size  Location     Type
  213. 202:           ;;       None               void
  214. 203:           ;; Registers used:
  215. 204:           ;;       wreg, status,2, status,0, pclath, cstack
  216. 205:           ;; Tracked objects:
  217. 206:           ;;       On entry : 17F/0
  218. 207:           ;;       On exit  : 0/0
  219. 208:           ;;       Unchanged: 0/0
  220. 209:           ;; Data sizes:     COMMON   BANK0   BANK1
  221. 210:           ;;      Params:         0       0       0
  222. 211:           ;;      Locals:         0       0       0
  223. 212:           ;;      Temps:          1       0       0
  224. 213:           ;;      Totals:         1       0       0
  225. 214:           ;;Total ram usage:        1 bytes
  226. 215:           ;; Hardware stack levels required when called:    1
  227. 216:           ;; This function calls:
  228. 217:           ;;       _fTask1
  229. 218:           ;;       _fTask2
  230. 219:           ;; This function is called by:
  231. 220:           ;;       Startup code after reset
  232. 221:           ;; This function uses a non-reentrant model
  233. 222:           ;;
  234. 223:           psect    maintext,global,class=CODE,delta=2,split=1
  235. 224:           global __pmaintext
  236. 225:           __pmaintext:
  237. 226:           psect    maintext
  238. 227:            file    "arrray_asm.c"
  239. 228:            line    18
  240. 229:            global  __size_of_main
  241. 230:            __size_of_main  equ __end_of_main-_main
  242. 231:            
  243. 232:           _main:  
  244. 233:            opt stack 7
  245. 234:           ; Regs used in _main: [wreg+status,2+status,0+pclath+cstack]
  246. 235:            line    19
  247. 236:            
  248. 237:           l414:   
  249. 238:           ;arrray_asm.c: 19: TRISA = 0;
  250. 239:            bsf status, 5   ;RP0=1, select bank1
  251. 240:            clrf    (133)^080h  ;volatile
  252. 241:            line    20
  253. 242:           ;arrray_asm.c: 20: TRISC = 0;
  254. 243:            clrf    (135)^080h  ;volatile
  255. 244:            line    21
  256. 245:           ;arrray_asm.c: 21: ANSEL = 0;
  257. 246:            clrf    (145)^080h  ;volatile
  258. 247:            line    22
  259. 248:           ;arrray_asm.c: 22: PORTA = 0;
  260. 249:            bcf status, 5   ;RP0=0, select bank0
  261. 250:            clrf    (5) ;volatile
  262. 251:            line    23
  263. 252:           ;arrray_asm.c: 23: PORTC = 0;
  264. 253:            clrf    (7) ;volatile
  265. 254:            line    25
  266. 255:            
  267. 256:           l416:   
  268. 257:           ;arrray_asm.c: 25: currentTask = 0;
  269. 258:            clrf    (_currentTask)
  270. 259:            line    26
  271. 260:            
  272. 261:           l418:   
  273. 262:           ;arrray_asm.c: 26: fTask1();
  274. 263:            fcall   _fTask1
  275. 264:            line    27
  276. 265:            
  277. 266:           l420:   
  278. 267:           ;arrray_asm.c: 27: currentTask++;
  279. 268:            movlw   (01h)
  280. 269:            movwf   (??_main+0)+0
  281. 270:            movf    (??_main+0)+0,w
  282. 271:            addwf   (_currentTask),f
  283. 272:            line    28
  284. 273:            
  285. 274:           l422:   
  286. 275:           ;arrray_asm.c: 28: fTask2();
  287. 276:            fcall   _fTask2
  288. 277:            line    31
  289. 278:           # 31 "arrray_asm.c"
  290. 279:           _taskswitcher ;#
  291. 280:            line    32
  292. 281:           # 32 "arrray_asm.c"
  293. 282:           movlw 0x02 ; W = 2 ;#
  294. 283:            line    33
  295. 284:           # 33 "arrray_asm.c"
  296. 285:           addwf _currentTask, f ; Add 2 to currentTask, store it in currentTask. ;#
  297. 286:            line    34
  298. 287:           # 34 "arrray_asm.c"
  299. 288:           movlw 4 ; W = 4 ;#
  300. 289:            line    35
  301. 290:           # 35 "arrray_asm.c"
  302. 291:           subwf _currentTask, w ; w= f - w ;#
  303. 292:            line    36
  304. 293:           # 36 "arrray_asm.c"
  305. 294:           btfsc status, 0 ; If currentTask >= 4 ;#
  306. 295:            line    37
  307. 296:           # 37 "arrray_asm.c"
  308. 297:           clrf _currentTask ; Clear currentTask ;#
  309. 298:            line    39
  310. 299:           # 39 "arrray_asm.c"
  311. 300:           movlw _tasks ; Store the address of tasks, which is the start address of our task "array". ;#
  312. 301:            line    40
  313. 302:           # 40 "arrray_asm.c"
  314. 303:           addwf _currentTask, w ; Add current task's index to the start address. ;#
  315. 304:            line    41
  316. 305:           ; For example; task1's index is 2: [task0_1][task0_2][task1_1][task1_2].... ;#
  317. 306:            line    42
  318. 307:           ; 0 1 2 3 ;#
  319. 308:            line    43
  320. 309:           # 43 "arrray_asm.c"
  321. 310:           movwf fsr ; We have the index of current task in W. Copy it to FSR ;#
  322. 311:            line    44
  323. 312:           # 44 "arrray_asm.c"
  324. 313:           movf indf, w ; Copy the contents of current task's first item to W ;#
  325. 314:            line    45
  326. 315:           # 45 "arrray_asm.c"
  327. 316:           movwf pclath ; Copy W to PCLATH. As a result, current task's PCLATH will be in PCLATH register. ;#
  328. 317:            line    47
  329. 318:           # 47 "arrray_asm.c"
  330. 319:           incf fsr, f ; Increment index, so that we will point to the next item of current task. ;#
  331. 320:            line    48
  332. 321:           # 48 "arrray_asm.c"
  333. 322:           movf indf, w ; Copy the contents of current task's second item to W. ;#
  334. 323:            line    49
  335. 324:           # 49 "arrray_asm.c"
  336. 325:           movwf pcl ; Copy W to PCL. Finally, current task's PCL will be in PCL register. ;#
  337. 326:           psect    maintext
  338. 327:            line    51
  339. 328:            
  340. 329:           l21:
  341. 330:            global  start
  342. 331:            ljmp    start
  343. 332:            opt stack 0
  344. 333:           GLOBAL   __end_of_main
  345. 334:            __end_of_main:
  346. 335:            signat  _main,88
  347. 336:            global  _fTask1
  348. 337:          
  349. 338:           ;; *************** function _fTask1 *****************
  350. 339:           ;; Defined at:
  351. 340:           ;;       line 54 in file "arrray_asm.c"
  352. 341:           ;; Parameters:    Size  Location     Type
  353. 342:           ;;       None
  354. 343:           ;; Auto vars:     Size  Location     Type
  355. 344:           ;;       None
  356. 345:           ;; Return value:  Size  Location     Type
  357. 346:           ;;       None               void
  358. 347:           ;; Registers used:
  359. 348:           ;;       wreg
  360. 349:           ;; Tracked objects:
  361. 350:           ;;       On entry : 0/0
  362. 351:           ;;       On exit  : 0/0
  363. 352:           ;;       Unchanged: 0/0
  364. 353:           ;; Data sizes:     COMMON   BANK0   BANK1
  365. 354:           ;;      Params:         0       0       0
  366. 355:           ;;      Locals:         0       0       0
  367. 356:           ;;      Temps:          0       0       0
  368. 357:           ;;      Totals:         0       0       0
  369. 358:           ;;Total ram usage:        0 bytes
  370. 359:           ;; Hardware stack levels used:    1
  371. 360:           ;; This function calls:
  372. 361:           ;;       Nothing
  373. 362:           ;; This function is called by:
  374. 363:           ;;       _main
  375. 364:           ;; This function uses a non-reentrant model
  376. 365:           ;;
  377. 366:           psect    text37,local,class=CODE,delta=2,merge=1
  378. 367:           global __ptext37
  379. 368:           __ptext37:
  380. 369:           psect    text37
  381. 370:            file    "arrray_asm.c"
  382. 371:            line    54
  383. 372:            global  __size_of_fTask1
  384. 373:            __size_of_fTask1    equ __end_of_fTask1-_fTask1
  385. 374:            
  386. 375:           _fTask1:
  387. 376:            opt stack 7
  388. 377:           ; Regs used in _fTask1: [wreg]
  389. 378:            line    56
  390. 379:            
  391. 380:           l406:   
  392. 381:           # 56 "arrray_asm.c"
  393. 382:           movlw _tasks ; Store the address of tasks, which is the start address of our task "array". ;#
  394. 383:            line    57
  395. 384:           # 57 "arrray_asm.c"
  396. 385:           addwf _currentTask, w ; Add current task's index to the start address. ;#
  397. 386:            line    59
  398. 387:           # 59 "arrray_asm.c"
  399. 388:           movwf fsr ; We have the index of current task in W. Copy it to FSR ;#
  400. 389:            line    60
  401. 390:           # 60 "arrray_asm.c"
  402. 391:           movf pclath, w ; Copy PCLATH register's contents to W register. ;#
  403. 392:            line    61
  404. 393:           # 61 "arrray_asm.c"
  405. 394:           movwf indf ; Copy W to current task's first item. We now store PCLATH. ;#
  406. 395:            line    63
  407. 396:           # 63 "arrray_asm.c"
  408. 397:           incf fsr,f ; Increment index, so that we will point to the next item of current task. ;#
  409. 398:            line    64
  410. 399:           # 64 "arrray_asm.c"
  411. 400:           movlw low($+3) ; Copy PCL+3 to W register. This will let us save the PCL of the start of the task. ;#
  412. 401:            line    65
  413. 402:           # 65 "arrray_asm.c"
  414. 403:           movwf indf ; Copy W to task's next item. With that, we will initialize the current task. ;#
  415. 404:            line    66
  416. 405:           # 66 "arrray_asm.c"
  417. 406:           return ; We have gathered our initialazation information. Return back to main. ;#
  418. 407:           psect    text37
  419. 408:            goto    l408
  420. 409:            line    69
  421. 410:           ;arrray_asm.c: 69: while (1)
  422. 411:            
  423. 412:           l24:
  424. 413:            line    71
  425. 414:            
  426. 415:           l408:   
  427. 416:           ;arrray_asm.c: 70: {
  428. 417:           ;arrray_asm.c: 71: PORTA = 0xAA;
  429. 418:            movlw   (0AAh)
  430. 419:            bcf status, 5   ;RP0=0, select bank0
  431. 420:            movwf   (5) ;volatile
  432. 421:            line    74
  433. 422:           # 74 "arrray_asm.c"
  434. 423:           movlw _tasks ; Store the address of tasks, which is the start address of our task "array". ;#
  435. 424:            line    75
  436. 425:           # 75 "arrray_asm.c"
  437. 426:           addwf _currentTask, w ; Add current task's index to the start address. ;#
  438. 427:            line    77
  439. 428:           # 77 "arrray_asm.c"
  440. 429:           movwf fsr ; We have the index of current task in W. Copy it to FSR ;#
  441. 430:            line    78
  442. 431:           # 78 "arrray_asm.c"
  443. 432:           movf pclath, w ; Copy PCLATH register's contents to W register. ;#
  444. 433:            line    79
  445. 434:           # 79 "arrray_asm.c"
  446. 435:           movwf indf ; Copy W to current task's first item. We now store PCLATH of the current state of the task. ;#
  447. 436:            line    81
  448. 437:           # 81 "arrray_asm.c"
  449. 438:           incf fsr, f ; Increment index, so that we will point to the next item of current task. ;#
  450. 439:            line    82
  451. 440:           # 82 "arrray_asm.c"
  452. 441:           movlw low($+3) ; Copy PCL+3 to W register. This will let us save the PCL of the current state of the task. ;#
  453. 442:            line    83
  454. 443:           # 83 "arrray_asm.c"
  455. 444:           movwf indf ; Copy W to task's next item. With that, we will initialize the current task. ;#
  456. 445:            line    85
  457. 446:           # 85 "arrray_asm.c"
  458. 447:           goto _taskswitcher ; Yield the CPU to the awaiting task by going to task switcher. ;#
  459. 448:           psect    text37
  460. 449:            line    88
  461. 450:           ;arrray_asm.c: 88: PORTA = 0x55;
  462. 451:            movlw   (055h)
  463. 452:            bcf status, 5   ;RP0=0, select bank0
  464. 453:            movwf   (5) ;volatile
  465. 454:            goto    l408
  466. 455:            line    89
  467. 456:            
  468. 457:           l25:
  469. 458:            line    69
  470. 459:            goto    l408
  471. 460:            
  472. 461:           l26:
  473. 462:            line    90
  474. 463:            
  475. 464:           l27:
  476. 465:            return
  477. 466:            opt stack 0
  478. 467:           GLOBAL   __end_of_fTask1
  479. 468:            __end_of_fTask1:
  480. 469:            signat  _fTask1,88
  481. 470:            global  _fTask2
  482. 471:          
  483. 472:           ;; *************** function _fTask2 *****************
  484. 473:           ;; Defined at:
  485. 474:           ;;       line 93 in file "arrray_asm.c"
  486. 475:           ;; Parameters:    Size  Location     Type
  487. 476:           ;;       None
  488. 477:           ;; Auto vars:     Size  Location     Type
  489. 478:           ;;       None
  490. 479:           ;; Return value:  Size  Location     Type
  491. 480:           ;;       None               void
  492. 481:           ;; Registers used:
  493. 482:           ;;       wreg
  494. 483:           ;; Tracked objects:
  495. 484:           ;;       On entry : 0/0
  496. 485:           ;;       On exit  : 0/0
  497. 486:           ;;       Unchanged: 0/0
  498. 487:           ;; Data sizes:     COMMON   BANK0   BANK1
  499. 488:           ;;      Params:         0       0       0
  500. 489:           ;;      Locals:         0       0       0
  501. 490:           ;;      Temps:          0       0       0
  502. 491:           ;;      Totals:         0       0       0
  503. 492:           ;;Total ram usage:        0 bytes
  504. 493:           ;; Hardware stack levels used:    1
  505. 494:           ;; This function calls:
  506. 495:           ;;       Nothing
  507. 496:           ;; This function is called by:
  508. 497:           ;;       _main
  509. 498:           ;; This function uses a non-reentrant model
  510. 499:           ;;
  511. 500:           psect    text38,local,class=CODE,delta=2,merge=1
  512. 501:           global __ptext38
  513. 502:           __ptext38:
  514. 503:           psect    text38
  515. 504:            file    "arrray_asm.c"
  516. 505:            line    93
  517. 506:            global  __size_of_fTask2
  518. 507:            __size_of_fTask2    equ __end_of_fTask2-_fTask2
  519. 508:            
  520. 509:           _fTask2:
  521. 510:            opt stack 7
  522. 511:           ; Regs used in _fTask2: [wreg]
  523. 512:            line    95
  524. 513:            
  525. 514:           l410:   
  526. 515:           # 95 "arrray_asm.c"
  527. 516:           movlw _tasks ; Store the address of tasks, which is the start address of our task "array". ;#
  528. 517:            line    96
  529. 518:           # 96 "arrray_asm.c"
  530. 519:           addwf _currentTask, w ; Add current task's index to the start address. ;#
  531. 520:            line    98
  532. 521:           # 98 "arrray_asm.c"
  533. 522:           movwf fsr ; We have the index of current task in W. Copy it to FSR ;#
  534. 523:            line    99
  535. 524:           # 99 "arrray_asm.c"
  536. 525:           movf pclath, w ; Copy PCLATH register's contents to W register. ;#
  537. 526:            line    100
  538. 527:           # 100 "arrray_asm.c"
  539. 528:           movwf indf ; Copy W to current task's first item. We now store PCLATH. ;#
  540. 529:            line    102
  541. 530:           # 102 "arrray_asm.c"
  542. 531:           incf fsr,f ; Increment index, so that we will point to the next item of current task. ;#
  543. 532:            line    103
  544. 533:           # 103 "arrray_asm.c"
  545. 534:           movlw low($+3) ; Copy PCL+3 to W register. This will let us save the PCL of the start of the task. ;#
  546. 535:            line    104
  547. 536:           # 104 "arrray_asm.c"
  548. 537:           movwf indf ; Copy W to task's next item. With that, we will initialize the current task. ;#
  549. 538:            line    105
  550. 539:           # 105 "arrray_asm.c"
  551. 540:           return ; We have gathered our initialazation information. Return back to main. ;#
  552. 541:           psect    text38
  553. 542:            goto    l412
  554. 543:            line    108
  555. 544:           ;arrray_asm.c: 108: while (1)
  556. 545:            
  557. 546:           l30:
  558. 547:            line    110
  559. 548:            
  560. 549:           l412:   
  561. 550:           ;arrray_asm.c: 109: {
  562. 551:           ;arrray_asm.c: 110: PORTA = 0xAA;
  563. 552:            movlw   (0AAh)
  564. 553:            bcf status, 5   ;RP0=0, select bank0
  565. 554:            movwf   (5) ;volatile
  566. 555:            line    113
  567. 556:           # 113 "arrray_asm.c"
  568. 557:           movlw _tasks ; Store the address of tasks, which is the start address of our task "array". ;#
  569. 558:            line    114
  570. 559:           # 114 "arrray_asm.c"
  571. 560:           addwf _currentTask, w ; Add current task's index to the start address. ;#
  572. 561:            line    116
  573. 562:           # 116 "arrray_asm.c"
  574. 563:           movwf fsr ; We have the index of current task in W. Copy it to FSR ;#
  575. 564:            line    117
  576. 565:           # 117 "arrray_asm.c"
  577. 566:           movf pclath, w ; Copy PCLATH register's contents to W register. ;#
  578. 567:            line    118
  579. 568:           # 118 "arrray_asm.c"
  580. 569:           movwf indf ; Copy W to current task's first item. We now store PCLATH of the current state of the task. ;#
  581. 570:            line    120
  582. 571:           # 120 "arrray_asm.c"
  583. 572:           incf fsr, f ; Increment index, so that we will point to the next item of current task. ;#
  584. 573:            line    121
  585. 574:           # 121 "arrray_asm.c"
  586. 575:           movlw low($+3) ; Copy PCL+3 to W register. This will let us save the PCL of the current state of the task. ;#
  587. 576:            line    122
  588. 577:           # 122 "arrray_asm.c"
  589. 578:           movwf indf ; Copy W to task's next item. With that, we will initialize the current task. ;#
  590. 579:            line    124
  591. 580:           # 124 "arrray_asm.c"
  592. 581:           goto _taskswitcher ; Yield the CPU to the awaiting task by going to task switcher. ;#
  593. 582:           psect    text38
  594. 583:            line    127
  595. 584:           ;arrray_asm.c: 127: PORTA = 0x55;
  596. 585:            movlw   (055h)
  597. 586:            bcf status, 5   ;RP0=0, select bank0
  598. 587:            movwf   (5) ;volatile
  599. 588:            goto    l412
  600. 589:            line    128
  601. 590:            
  602. 591:           l31:
  603. 592:            line    108
  604. 593:            goto    l412
  605. 594:            
  606. 595:           l32:
  607. 596:            line    129
  608. 597:            
  609. 598:           l33:
  610. 599:            return
  611. 600:            opt stack 0
  612. 601:           GLOBAL   __end_of_fTask2
  613. 602:            __end_of_fTask2:
  614. 603:            signat  _fTask2,88
  615. 604:           psect    text39,local,class=CODE,delta=2,merge=1
  616. 605:           global __ptext39
  617. 606:           __ptext39:
  618. 607:            global  btemp
  619. 608:            btemp set 07Eh
  620. 609:          
  621. 610:            DABS    1,126,2 ;btemp
  622. 611:            global  wtemp0
  623. 612:            wtemp0 set btemp
  624. 613:            end
  625. ---  D:/Documents/MPLABXProjects/messingWithRTOS.X/arrray_asm.c  ----------------------------------------
  626. 1:             /*
  627. 2:              * File:   main.c
  628. 3:              * Author: abdullah
  629. 4:              *
  630. 5:              * Created on 10 Haziran 2012 Pazar, 14:43
  631. 6:              */
  632. 7:             #include <xc.h> // Include the header file needed by the compiler
  633. 8:             __CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_ON & MCLRE_OFF & CP_OFF & IOSCFS_4MHZ & BOREN_ON);
  634. 9:            
  635. 10:            #define numOfTasks 4
  636. 11:            unsigned char currentTask; // This TCB pointer will point to the current task's TCB.
  637. 12:            unsigned char tasks[4];
  638. 13:            
  639. 14:            void fTask1(void); // Prototype the function for task1.
  640. 15:            void fTask2(void); // Prototype the function for task2.
  641. 16:            
  642. 17:            void main(void)
  643. 18:            {
  644. 19:                TRISA = 0; // Set all of the PORTA pins as outputs.
  645. 07E3  1683     BSF STATUS, 0x5
  646. 07E4  0185     CLRF PORTA
  647. 20:                TRISC = 0; // Set all of the PORTC pins as outputs.
  648. 07E5  0187     CLRF PORTC
  649. 21:                ANSEL = 0; // Set all of the analog input pins as digital i/o.
  650. 07E6  0191     CLRF TMR2
  651. 22:                PORTA = 0; // Clear PORTA bits.
  652. 07E7  1283     BCF STATUS, 0x5
  653. 07E8  0185     CLRF PORTA
  654. 23:                PORTC = 0; // Clear PORTC bits.
  655. 07E9  0187     CLRF PORTC
  656. 24:            
  657. 25:                currentTask = 0;
  658. 07EA  01F4     CLRF currentTask
  659. 26:                fTask1();
  660. 07EB  27C7     CALL 0x7C7
  661. 27:                currentTask++;
  662. 07EC  3001     MOVLW 0x1
  663. 07ED  00F5     MOVWF 0x75
  664. 07EE  0875     MOVF 0x75, W
  665. 07EF  07F4     ADDWF currentTask, F
  666. 28:                fTask2();
  667. 07F0  27AB     CALL 0x7AB
  668. 29:            
  669. 30:            #asm
  670. 31:                _taskswitcher
  671. 32:                    movlw   0x02                ; W = 2
  672. 07F1  3002     MOVLW 0x2
  673. 33:                    addwf   _currentTask, f     ; Add 2 to currentTask, store it in currentTask.
  674. 07F2  07F4     ADDWF currentTask, F
  675. 34:                    movlw   numOfTasks          ; W = numOfTasks
  676. 07F3  3004     MOVLW 0x4
  677. 35:                    subwf   _currentTask, w     ; w= f - w
  678. 07F4  0274     SUBWF currentTask, W
  679. 36:                    btfsc   status, 0           ; If currentTask >= numOfTasks
  680. 07F5  1803     BTFSC STATUS, 0x0
  681. 37:                    clrf    _currentTask        ; Clear currentTask
  682. 07F6  01F4     CLRF currentTask
  683. 38:            
  684. 39:                    movlw   _tasks              ; Store the address of tasks, which is the start address of our task "array".
  685. 07F7  3070     MOVLW 0x70
  686. 40:                    addwf   _currentTask, w     ; Add current task's index to the start address.
  687. 07F8  0774     ADDWF currentTask, W
  688. 41:                                                ; For example; task1's index is 2:  [task0_1][task0_2][task1_1][task1_2]....
  689. 42:                                                ;                                       0        1        2        3
  690. 43:                    movwf   fsr                 ; We have the index of current task in W. Copy it to FSR
  691. 07F9  0084     MOVWF FSR
  692. 44:                    movf    indf, w             ; Copy the contents of current task's first item to W
  693. 07FA  0800     MOVF INDF, W
  694. 45:                    movwf   pclath              ; Copy W to PCLATH. As a result, current task's PCLATH will be in PCLATH register.
  695. 07FB  008A     MOVWF PCLATH
  696. 46:            
  697. 47:                    incf    fsr, f              ; Increment index, so that we will point to the next item of current task.
  698. 07FC  0A84     INCF FSR, F
  699. 48:                    movf    indf, w             ; Copy the contents of current task's second item to W.
  700. 07FD  0800     MOVF INDF, W
  701. 49:                    movwf   pcl                 ; Copy W to PCL. Finally, current task's PCL will be in PCL register.
  702. 07FE  0082     MOVWF PCL
  703. 50:            #endasm
  704. 51:            }
  705. 52:            
  706. 53:            void fTask1(void)
  707. 54:            {
  708. 55:            #asm
  709. 56:                    movlw   _tasks               ; Store the address of tasks, which is the start address of our task "array".
  710. 07C7  3070     MOVLW 0x70
  711. 57:                    addwf   _currentTask, w      ; Add current task's index to the start address.
  712. 07C8  0774     ADDWF currentTask, W
  713. 58:            
  714. 59:                    movwf   fsr                 ; We have the index of current task in W. Copy it to FSR
  715. 07C9  0084     MOVWF FSR
  716. 60:                    movf    pclath, w           ; Copy PCLATH register's contents to W register.
  717. 07CA  080A     MOVF PCLATH, W
  718. 61:                    movwf   indf                ; Copy W to current task's first item. We now store PCLATH.
  719. 07CB  0080     MOVWF INDF
  720. 62:            
  721. 63:                    incf    fsr,f               ; Increment index, so that we will point to the next item of current task.
  722. 07CC  0A84     INCF FSR, F
  723. 64:                    movlw   low($+3)            ; Copy PCL+3 to W register. This will let us save the PCL of the start of the task.
  724. 07CD  30D0     MOVLW 0xD0
  725. 65:                    movwf   indf                ; Copy W to task's next item. With that, we will initialize the current task.
  726. 07CE  0080     MOVWF INDF
  727. 66:                    return                      ; We have gathered our initialazation information. Return back to main.
  728. 07CF  0008     RETURN
  729. 07D0  2FD1     GOTO 0x7D1
  730. 67:            #endasm
  731. 68:            
  732. 69:                while (1)
  733. 07E1  2FD1     GOTO 0x7D1
  734. 70:                {
  735. 71:                    PORTA = 0xAA; // Toggle PORTA.0
  736. 07D1  30AA     MOVLW 0xAA
  737. 07D2  1283     BCF STATUS, 0x5
  738. 07D3  0085     MOVWF PORTA
  739. 72:            
  740. 73:            #asm
  741. 74:                    movlw   _tasks               ; Store the address of tasks, which is the start address of our task "array".
  742. 07D4  3070     MOVLW 0x70
  743. 75:                    addwf   _currentTask, w      ; Add current task's index to the start address.
  744. 07D5  0774     ADDWF currentTask, W
  745. 76:            
  746. 77:                    movwf   fsr                 ; We have the index of current task in W. Copy it to FSR
  747. 07D6  0084     MOVWF FSR
  748. 78:                    movf    pclath, w           ; Copy PCLATH register's contents to W register.
  749. 07D7  080A     MOVF PCLATH, W
  750. 79:                    movwf   indf                ; Copy W to current task's first item. We now store PCLATH of the current state of the task.
  751. 07D8  0080     MOVWF INDF
  752. 80:            
  753. 81:                    incf    fsr, f               ; Increment index, so that we will point to the next item of current task.
  754. 07D9  0A84     INCF FSR, F
  755. 82:                    movlw   low($+3)            ; Copy PCL+3 to W register. This will let us save the PCL of the current state of the task.
  756. 07DA  30DD     MOVLW 0xDD
  757. 83:                    movwf   indf                ; Copy W to task's next item. With that, we will initialize the current task.
  758. 07DB  0080     MOVWF INDF
  759. 84:            
  760. 85:                    goto    _taskswitcher        ; Yield the CPU to the awaiting task by going to task switcher.
  761. 07DC  2FF1     GOTO 0x7F1
  762. 86:            #endasm
  763. 87:            
  764. 88:                    PORTA = 0x55; // Toggle PORTA.0
  765. 07DD  3055     MOVLW 0x55
  766. 07DE  1283     BCF STATUS, 0x5
  767. 07DF  0085     MOVWF PORTA
  768. 07E0  2FD1     GOTO 0x7D1
  769. 89:                }
  770. 90:            }
  771. 07E2  0008     RETURN
  772. 91:            
  773. 92:            void fTask2(void)
  774. 93:            {
  775. 94:            #asm
  776. 95:                    movlw   _tasks               ; Store the address of tasks, which is the start address of our task "array".
  777. 07AB  3070     MOVLW 0x70
  778. 96:                    addwf   _currentTask, w      ; Add current task's index to the start address.
  779. 07AC  0774     ADDWF currentTask, W
  780. 97:            
  781. 98:                    movwf   fsr                 ; We have the index of current task in W. Copy it to FSR
  782. 07AD  0084     MOVWF FSR
  783. 99:                    movf    pclath, w           ; Copy PCLATH register's contents to W register.
  784. 07AE  080A     MOVF PCLATH, W
  785. 100:                   movwf   indf                ; Copy W to current task's first item. We now store PCLATH.
  786. 07AF  0080     MOVWF INDF
  787. 101:          
  788. 102:                   incf    fsr,f               ; Increment index, so that we will point to the next item of current task.
  789. 07B0  0A84     INCF FSR, F
  790. 103:                   movlw   low($+3)            ; Copy PCL+3 to W register. This will let us save the PCL of the start of the task.
  791. 07B1  30B4     MOVLW 0xB4
  792. 104:                   movwf   indf                ; Copy W to task's next item. With that, we will initialize the current task.
  793. 07B2  0080     MOVWF INDF
  794. 105:                   return                      ; We have gathered our initialazation information. Return back to main.
  795. 07B3  0008     RETURN
  796. 07B4  2FB5     GOTO 0x7B5
  797. 106:           #endasm
  798. 107:          
  799. 108:               while (1)
  800. 07C5  2FB5     GOTO 0x7B5
  801. 109:               {
  802. 110:                   PORTA = 0xAA; // Toggle PORTA.0
  803. 07B5  30AA     MOVLW 0xAA
  804. 07B6  1283     BCF STATUS, 0x5
  805. 07B7  0085     MOVWF PORTA
  806. 111:          
  807. 112:           #asm
  808. 113:                   movlw   _tasks               ; Store the address of tasks, which is the start address of our task "array".
  809. 07B8  3070     MOVLW 0x70
  810. 114:                   addwf   _currentTask, w      ; Add current task's index to the start address.
  811. 07B9  0774     ADDWF currentTask, W
  812. 115:          
  813. 116:                   movwf   fsr                 ; We have the index of current task in W. Copy it to FSR
  814. 07BA  0084     MOVWF FSR
  815. 117:                   movf    pclath, w           ; Copy PCLATH register's contents to W register.
  816. 07BB  080A     MOVF PCLATH, W
  817. 118:                   movwf   indf                ; Copy W to current task's first item. We now store PCLATH of the current state of the task.
  818. 07BC  0080     MOVWF INDF
  819. 119:          
  820. 120:                   incf    fsr, f               ; Increment index, so that we will point to the next item of current task.
  821. 07BD  0A84     INCF FSR, F
  822. 121:                   movlw   low($+3)            ; Copy PCL+3 to W register. This will let us save the PCL of the current state of the task.
  823. 07BE  30C1     MOVLW 0xC1
  824. 122:                   movwf   indf                ; Copy W to task's next item. With that, we will initialize the current task.
  825. 07BF  0080     MOVWF INDF
  826. 123:          
  827. 124:                   goto    _taskswitcher        ; Yield the CPU to the awaiting task by going to task switcher.
  828. 07C0  2FF1     GOTO 0x7F1
  829. 125:           #endasm
  830. 126:          
  831. 127:                   PORTA = 0x55; // Toggle PORTA.0
  832. 07C1  3055     MOVLW 0x55
  833. 07C2  1283     BCF STATUS, 0x5
  834. 07C3  0085     MOVWF PORTA
  835. 07C4  2FB5     GOTO 0x7B5
  836. 128:               }
  837. 129:           }
  838. 07C6  0008     RETURN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement