Page 186 - DCAP507_SYSTEM_SOFTWARE
P. 186

System Software




                    Notes
                                      016   inc and jmp          bx     bx,  ;  increment  to  next  shape;  taking
                                      017                        3taskone    modulus by 4; infinite task
                                      018
                                      019

                                      020   ;  second  task  to  be  multitaskedtasktwo:  ; read the next shape; write at top
                                      021   mov  al,  [chars+bx]mov  [es:158],  alinc  bx  right  of  screen;  increment  to  next
                                      022   and bx, 3jmp tasktwo                shape;  taking  modulus  by  4;
                                      023                                       infinite task
                                      024
                                      025
                                      026
                                      027   ;  timer  interrupt  service  routinetimer:
                                      028   push axpush bx
                                      029
                                      030
                                      031   mov mov mul mov      bl,   [cs:current]ax,  ;  read  index  of  current  task;
                                      032                        10bl bx, ax       space  used  by  one  task;
                                      033                                          multiply  to  get  start  of  task;
                                      034                                          load start of task in bx
                                      035
                                      036   popmov      popmov  ax ; read original value of bx[cs:taskstates+bx+2], ax ;
                                      037   popmov      popmov  space  for  current  taskax  ;  read  original  value  of
                                      038   popmov               ax[cs:taskstates+bx+0], ax ; space for current taskax ;
                                      039                        read  original  value  of  ip[cs:taskstates+bx+4],  ax  ;
                                      040                        space  for  current  taskax  ;  read  original  value  of
                                      041                        cs[cs:taskstates+bx+6], ax ; space for current taskax ;
                                      042                        read  original  value  of  flags[cs:taskstates+bx+8],  ax  ;
                                      043                        space for current task
                                      044
                                      045
                                      046

                                      047   inc byte [cs:current] ; update current task indexcmp byte [cs:current], 3 ; is task
                                      048   index out of rangejne skipreset ; no, proceedmov byte [cs:current], 0 ; yes, reset
                                      049   to task 0
                                      050
                                      051

                                      052   skipreset:    mov    bl,   [cs:current]ax,  ;  read  index  of  current  task;
                                      053                 mov    10bl bx, ax       space  used  by  one  task;
                                      054                 mul                      multiply  to  get  start  of  task;
                                      055                 mov                      load start of task in bx
                                      056

                                      057                 mov    al, 0x200x20, al   ; send EOI to PIC
                                      058                 out
                                      059
                                      060   push   word   [cs:taskstates+bx+8]   ;   flags   of   new   taskpush   word
                                      061   [cs:taskstates+bx+6] ; cs of new taskpush word [cs:taskstates+bx+4] ; ip of new
          180                         062   LOVELY PROFESSIONAL UNIVERSITY
                                            taskmov ax, [cs:taskstates+bx+0] ; ax of new task mov bx, [cs:taskstates+bx+2] ;
                                      063   bx of new taskiret ; return to new task
                                      064
                                      065
                                      066

                                      067   start:     mov  mov  word   [taskstates+10+4],   taskone   ;   initialize
                                      068              mov  mov  ip[taskstates+10+6],   cs   ;   initialize   csword
                                      069              mov  mov  [taskstates+10+8],  0×0200  ;  initialize  flagsword
                                      070              mov       [taskstates+20+4],   tasktwo   ;    initialize
                                      071                        ip[taskstates+20+6],   cs   ;   initialize   csword
                                      072                        [taskstates+20+8],  0×0200  ;  initialize  flagsword
                                      073                        [current], 0 ; set current task index
                                      074
                                      075   xor mov cli          ax, ax es, ax         ; point es to IVT base
                                      076
                                      077
                                      078   mov  mov  mov  mov  word           [es:8*4],  ;  hook  timer  interrupt  ;
                                      079   xor sti              timer[es:8*4+2],   csax,  point  es  to  video  base;
   181   182   183   184   185   186   187   188   189   190   191