Ch 29 ¿é¥X¤J°ð (2) 8253/8254

³o¤@³¹ùØ¡A¤p¤ì°¸±N¤¶²Ð PC ùØ­±ªº­p®É´¹¤ù¡A8253/8254 ´¹¤ù¡CµM«á¥H 8253/8254 ´¹¤ù±À°Ê³â¥z¨Ï³â¥zµo¥XÁn­µ¡C³o­Ó³â¥z¬OÁôÂæb¥D¾÷ùتº¡A¤£¬O¥D¾÷¥~­±±µ¦b­µ®Ä¥d«á­±ªº³â¥z¡C¦­´Áªº¹q¸£¨S¦³«Ü±jªºÁn­µ¥\¯à¡A¶È¶È¾a¥D¾÷ªOùتº³â¥zµo¥X¡y¹Í¡zªº¤@Án¡A¨Ò¦p·í¹q¸£±Ò°Ê®É¡A¦pªG¨S¦³°ÝÃD¡A¥¦·|µo¥X¤@µuÁn¡y¹Í¡z¡A©ÎªÌ·í±z¤@¤U¤l¿é¤J¤Ó¦h«öÁä¡A¹q¸£¨Ó¤£¤Î³B²z¡A¤]´NÁä½L½w½Ä°Ï¶ñ¤J¤Ó¦h¸ê®Æ¨Ó¤£¤Î³B²z®É¡A¹q¸£³â¥z¤]·|µo¥X¡y¹Í¡zªº¤@Án³qª¾±z¡C³o¤@³¹©Ò«üªº¥u¬OÅý³o­Ó³â¥zµo¥X³oºØ³æ½ÕªºÁn­µ¡A¤£¬O±z·Qªº¹³¬y¦æºq¦±ªº¨ººØÁn­µ¡C

¥»³¹¥½¤F¡A¦A¥H 8253/8254 ´¹¤ù¬°°ò¦¡A³]­p¤@­Óºë±K­p®É¾¹µ{¦¡¡A¦¹­p®É¾¹¥i¥H©µ¿ð¤@¬q®É¶¡¡Aºë±K«×¹F¤@·L¬í¡A§Q¥Î¦¹¯S©Ê¡A¤p¤ì°¸¦A¼¶¼g¤@­Ó¥i¥H¼u«µ¤@­º¦±¤lªºµ{¦¡¡C


8253/8254 ­p®É¾¹

8253/8254 µ²ºc

IBM ¦b±À¥X PC/XT ®É¡AùØ­±­t³d­p®Éªº¬O 8253 ´¹¤ù¡A¨ì¤F IBM ±À¥X AT ¯Å¹q¸£®É§ï¥Î 8254 ´¹¤ù¡A¤£¹L³o¨â­Ó´¹¤ù´X¥G§¹¥þ¬Û®e¡A®t§O¦³¤G¡G8254 ¦³Åª¦^¼Ò¦¡¡A8253 «hµL¦¹¼Ò¦¡¡F¥t¥~ 8253 ¥i±µ¨üªº³Ì¤j®É¯ß¬° 2.6MHz¡A¦Ó 8254 ¬° 10MHz¡A¤£¹L¦b PC ¤W¡A¥¦­Ì³£¬O±µ¦¬¥D¾÷ªO¤Wªº¤@­Ó¥Û­^¾_Àú¾¹©Ò²£¥Íªº®É¯ß¡A¦¹¾_Àú¾¹¨C¬í¾_Àú 1193180 ¦¸¡A©Ò¥H¹ïµ{¦¡³]­p®v¨Ó»¡´X¥G¬O¬Û¦Pªº¡C¦¹¥~¥¦­Ìªº­p®É¤è¦¡¥i¥HÂǥѵ{¦¡ªº³W¹º¦Ó§ïÅÜ¡A©Ò¥H¤]ºÙ¬°¥iµ{¦¡­p®É´¹¤ù ( programmable interval timer )¡A¤]¥iÁY¼g¬° PIT¡C

8253/8254 ¤º³¡¥Ñ¤T­Ó­p®É³q¹D ( ©ÎªÌ»¡ 8253/8254 ¤º³¡¦³¤T­Ó­p®É¾¹ ) ¤Î¤@­Ó¼Ò¦¡±±¨î¼È¦s¾¹ ( mode control register ) ²Õ¦¨¡C³o¤T­Ó­p®É¾¹½s¸¹¬O 0¡B1¡B2¡A¤À§O¹ïÀ³ I/O °ð 40H¡B41H¡B42H¡C³o¤T­Ó­p®É¾¹¡A¨C¤@­Ó­p®É¾¹³£¦³¤»ºØ­p®É¼Ò¦¡¡A¥i¥HÂǥѧïÅÜ 8253/8254 ¼Ò¦¡±±¨î¼È¦s¾¹­«·s³W¹º­p®É¼Ò¦¡ ( ¦ý³Ì¦n¤£­n³o¼Ë°µ¡A¦]¬°¨t²Î¤¤©Ò¦³ªº­p®É¤u§@³£¥Ñ 8253/8254 ­t³d¡A¤@¥¹§ïÅÜ­p®É¼Ò¦¡«Ü®e©ö·í¾÷ )¡C¼Ò¦¡±±¨î¼È¦s¾¹¦b I/O °ð½s¸¹ 43H¡A¨äªø«×¶È¤@­Ó¦ì¤¸²Õ¡A¤]´N¬O¤K­Ó¦ì¤¸ªø¡A³o¤K­Ó¦ì¤¸©Ò¥Nªí·N¸q¦p¤Uªí¡G

¦ì¤¸ ¦ì¤¸­È ·N¡@¡@¸q
7¡B6 00 ¿ï¾Ü­p®É³q¹D 0
01 ¿ï¾Ü­p®É³q¹D 1
10 ¿ï¾Ü­p®É³q¹D 2
11 «ü©wŪ¦^©R¥O ( ¶È 8254 ¥i¥Î )
5¡B4 00 «O¯d¦í¥Ø«e¼Æ­È
01 ¶ÈŪ¼g¸û°ªªº¦ì¤¸²Õ
10 ¶ÈŪ¼g¸û§Cªº¦ì¤¸²Õ
11 ¥ýŪ¼g¸û§Cªº¦ì¤¸²Õ¡A¦AŪ¼g¸û°ªªº¦ì¤¸²Õ
1¡B2¡B3 000 ­p®É¼Ò¦¡ 0
001 ­p®É¼Ò¦¡ 1
010 ­p®É¼Ò¦¡ 2
011 ­p®É¼Ò¦¡ 3
100 ­p®É¼Ò¦¡ 4
101 ­p®É¼Ò¦¡ 5
0 0 ¨Ï¥Î¤G¶i¦ì®æ¦¡ªº¼Æ­È
1 ¨Ï¥Î BCD ®æ¦¡ªº¼Æ­È

8253/8254 ¤ºªº³o¤T­Ó­p®É¾¹¡A¨C¤@­Ó­p®É¾¹¤W¥Ñ¤T³¡¥÷²Õ¦¨¡G

  1. ¨â­Ó 16 ¦ì¤¸ªº¼È¦s¾¹¡G­p¼Æ¼È¦s¾¹ ( counter register ) ©M­¬¼È¦s¾¹ ( latch register )¡C
  2. ¨â­Ó¿é¤J«H¸¹¸Ë¸m¡G±±¨î¹h ( gate ) ©M®É§Ç¯ß½Ä ( clock )¡C
  3. ¤@­Ó¿é¥X«H¸¹¡G¿é¥XºÝ ( out )¡C

¨C·í­p®É¾¹­«·s³Q³W¹º«á¡A¥Ñ I/O °ð¼g¤Jªº¼Æ­È·|³Q«O¯d¦b­¬¼È¦s¾¹ùØ¡AµM«á½Æ»s¤@¥÷¨ì­p¼Æ¼È¦s¾¹¤¤¡A­p¼Æ¼È¦s¾¹¨Ì®É§Ç¯ß½Ä°T¸¹¶}©l»¼´î­Ë¼Æ¨ì¹s®É¡A«K·|¦³¤@¤èªi¸g¹L±±¨î¹h¡A°²¦p±±¨î¹h¶}±Ò¡A¦¹¤èªi°T¸¹«K·|³q¹L¿é¥XºÝ¦Ó¨ì¹F©PÃä¸Ë¸m¡A©PÃä¸Ë¸m«K¦¬¨ì¤@­Ó°T¸¹¡A°²¦p±±¨î¹hÃö³¬¡A«h¿é¥XºÝ«KµL§@¥Î¡A©PÃä¸Ë¸m«K¦¬¤£¨ì°T¸¹¡C

¥H­p®É¾¹¹s¨Ó»¡¡A¥¦³Q PC ¥Î¨Ó§@¬°¨t²Î®É¯ß¡A¥¦ªº­¬¼È¦s¾¹¤@¶}¾÷®É¶ñ¤J 0¡AµM«á§â³o­Ó 0 ½Æ»s¨ì­p¼Æ¼È¦s¾¹¤¤¡A­p¼Æ¼È¦s¾¹ªº 0 ¶}©l»¼´îÅܦ¨ 0FFFFH¡B0FFFEH¡K¡K¤@ª½¨ì¦A«×Åܬ°¹s®É¡A«Kµo¥X¤@­Ó°T¸¹¡A¦¹°T¸¹¥ý«á³q¹L±±¨î¹h»P¿é¥XºÝ¨ì¹F 8259 ´¹¤ù¡A8259 ²£¥Í¤@­Ó INT 8 ¤¤Â_¡C¦]¬° 8253/8254 ±µ¦¬¨C¬í 1193180 ¦¸ªº¾_Àú¡A¦Ó¥Ñ 0 ´î¨ì 0 ¦@­p¼Æ 65536 ¦¸¤~²£¥Í¤@­Ó¤èªi¡A©Ò¥H¨C¬í 8253/8254 ²£¥Í 18.2 ¦¸ªº²Ä¤K¸¹¤¤Â_¡C

1193180¡Ò65536¡×18.2

±`±`¦³³\¦h°ª¤â´N¬O§Q¥Î¦¹¤@¤è¦¡Àˬd INT 8¡A¨Ó¹F¦¨±`¾nªº¥Øªº¡A¦]¬°µwÅé¨C¬í·|²£¥Í 18.2 ¦¸¤¤Â_¤K¡C¥u­nª¾¹D¤¤Â_¤Kªº°_ÂI¡A±`¾nµ{¦¡«Ü®e©ö´N¯à´x´¤±±¨îÅv¡C¦Ü©ó­p®É¾¹¤@»P­p®É¾¹¤G¬O¤À§O¥Î¨Ó©w®É§ó·s DRAM °O¾ÐÅ餺ªº¸ê®Æ»P±À°Ê³â¥z¡C¥Ñ¤W­±»¡©ú¥i¥Hª¾¹D¡A³o¤T­Ó­p®É¾¹³£¤w¦³¤F©T©wªº¥Î³~¡A¦Ó¥B­p®É¾¹¹s»P­p®É¾¹¤@³£©M¨t²Îªº­p®É¦³Ãö¡A¨ä±±¨î¹h¤£¯à¸gµ{¦¡Ãö³¬¡A¦Ó¥B­¬¼È¦s¾¹¤ºªº­p¼Æ­È¦pªG¥ô·N¿y§ïªº¸Ü¡A«Ü®e©ö·í¾÷¡A©Ò¥H¥u³Ñ¤U­p®É¾¹¤G¥i¨Ñµ{¦¡³]­p®v¨Ï¥Î¤£­P¦³·í¾÷ªº¦MÀI¡A·íµM¸gÅçÂ×´Iªºµ{¦¡³]­p®v¤£¦b¦¹­­¡C©³¤Uªºªí¬O¦C¥X¦U­p®É¾¹¤º©wªº¥Î³~¤Î³]©w­È¡G

¦WºÙI/O °ð ¤º©w­p
®É¼Ò¦¡
¥Î¡@¡@³~
­p®É¾¹ 0 40H 3 ¨t²Î­p®É
­p®É¾¹ 1 41H 2 DRAM ¨ê·s
­p®É¾¹ 2 42H ¡@ PC ³â¥z
¼Ò¦¡±±¨î¼È¦s¾¹ 43H ¡@ ³]©w­p®É¾¹¤§­p®É¼Ò¦¡¤Î¿é¤J®æ¦¡

8253/8254 ªº­p®É¾¹¤G

­p®É¾¹ 2 »P¹q¸£ÂǥѰð 42H ·¾³q¡A¦Ó­p®É¾¹ 2 ¤S»P PC ³â¥z¬Û³s¡A¦]¦¹§^¤H§ïÅÜ°ð 42H ¤§­p¼Æ­È¡A«K¥i¥H§ïÅܳâ¥zªºÀW²v¡C·íµM­n¨Ï³â¥zµo¥XÁn­µÁÙ±o¥´¶}­p®É¾¹ 2 ªº±±¨î¹h¡A¦¹±±¨î¹h¦b°ð 61H ªº¦ì¤¸ 0¡C­p®É¾¹ 2 »P³â¥zªº³s±µ¥Ü·N¹Ï¦p¤U¡G

8253¡BI/O°ð61H»P³â¥z
±q¹Ï¤¤¬Ý¨Ó¡A¨C·í­p®É¾¹ 2 ¿é¥X¤@¦¸¾_Àú¡A¤]ÂǥѰð 61H ªº²Ä¤@¦ì¤¸¶Çµ¹³â¥z¡C¦Ó°ð 61H ªº²Ä¹s¤Î²Ä¤@¦ì¤¸¦A©M¤@­Ó¡y¥B¹h¡z( AND ¹h ) ¬Û³s¡A©Ò¥H¹ê»Ú¼¶¼gµ{¦¡®É¡A¥²¶·§â°ð 61H ªº²Ä¹s¤Î²Ä¤@¦ì¤¸§¡³]¦¨¤@¡C

¦Ü©ó­p¼Æ­ÈÀ³¸Ó¶ñ¤J¤°»ò¼Æ­È©O¡Hµª®×ÅãµM¤£¬OÁn­µªºÀW²v¡C¦]¬°Án­µÀW²v¶V¤j¡A¨C¬í®¶°Ê¶V¦h¦¸¡A­p¼Æ¼È¦s¾¹À³¸Ó­n«Ü§ÖªºÅܬ°¹s¡A©Ò¥H­p¼Æ¼È¦s¾¹©Ò¶ñ¤Jªº¼Æ­È­n¤p¤~¦æ¡A¤]´N¬O»¡§Ú­Ì©Ò¶ñ¤Jªº¼Æ­È¬O¬Y¼Æ°£¥HÀW²v¡C¬Y¼Æ¤S¬O¦h¤Ö©O¡H¥H C ¤j½Õªº Do ¬°¨Ò¡A¨äÀW²v¬O 262Hz¡A¤]´N¬O»¡¨C¬í­n®¶°Ê 262 ¦¸¡A­p¼Æ¼È¦s¾¹¨C¤@¬í­nÂk¹s 262 ¦¸¡A¦Ó 8253/8254 ¨C¬í±µ¦¬¨ì¥Û­^¾_Àú¾¹ 1193180 ¦¸ªº®¶°Ê¡A©Ò¥H­p®É¾¹À³¶ñ¤J 4554¡G

1193180¡Ò262¡×4554

¦Ó Re ÀW²v¬° 294Hz¡A©Ò¥H­p¼Æ¼È¦s¾¹À³¶ñ¤J 4058¡G

1193180¡Ò294¡×4058

¨ä¾l¨Ì¦¹Ãþ±À¡C´«¥y¸Ü»¡¡A­p¼Æ¼È¦s¾¹¤ºªº¼Æ­ÈÀ³¬° 1193180 °£¥HÀW²v¥H«áªº°Ó¼Æ¡C

PIANO.ASM ­ì©lµ{¦¡

©³¤U¬O PIANO.ASM ªº­ì©lµ{¦¡¡A§â¥¦²ÕĶ¡B³sµ²¦n¨ÃÂà´«¦¨ PIANO.COM ¡A§Y¥i¦b DOS ©Î Win 9x DOS ¼Ò¦¡¤U°õ¦æ¡C

;§âÁä½L¼ÒÀÀ¦¨¿ûµ^ªºµ{¦¡¡G
;1¡GDo¡@2¡GRe¡@3¡GMi¡@4¡GFa¡@5¡GSol¡@6¡GLa¡@7¡GSi¡@8¡GDo

;***************************************
code    segment
        assume  cs:code,ds:code
        org     100h
;---------------------------------------
start:  jmp     short begin
message db      'PAINO v 1.0',0dh,0ah
        db      '¥HÁä½L¼ÒÀÀ¿ûµ^ªºµ{¦¡',0dh,0ah,0dh,0ah
        db      'Áä½L 1¡B2¡K¡K8 ªí¥Ü Do¡BRe¡K¡KDo¡C',0dh,0ah
        db      '«ö Esc Áä°h¥Xµ{¦¡¡C$'
freq    dw      262,294,330,347,392,440,494,524 ;14 ÀW²v
begin:  mov     ah,9
        mov     dx,offset message
        int     21h

gt_key: mov     ah,7
        int     21h     ;20 Ū¨ú«öÁä
        cmp     al,1bh
        je      exit    ;22 ­Y¬° Esc Áä¡A«h°h¥Xµ{¦¡
        sub     al,'1'
        cbw
        mov     bx,ax
        shl     bx,1
        mov     ax,34dch
        mov     cx,freq[bx]     ;28 ¨ú±o«öÁä©Ò¥NªíªºÀW²v
        mov     dx,12h          ;29 DX:AX=1234DCH=1193180D
        div     cx
        mov     bx,ax           ;31 BX=(1193180/ÀW²v)¤§°Ó¼Æ

        mov     al,10110110b    ;33 ·Ç³Æ§â BX ¼g¤J°ð 42H ·í§@­p¼Æ¼È¦s¾¹
        out     43h,al
        mov     ax,bx
        out     42h,al          ;36 ¥ý¶Ç¥X BX ¤§§C¦ì¤¸²Õ
        mov     al,ah
        out     42h,al          ;38 ¦A¶Ç¥X BX ¤§°ª¦ì¤¸²Õ
        in      al,61h
        or      al,00000011b
        out     61h,al          ;41 ¥´¶}³â¥zµo¥XÁn­µ

        mov     cx,0ffffh       ;43
delay:  mov     dx,400h
dec_dx: dec     dx
        jnz     dec_dx
        loop    delay           ;47 ¨ÏÁn­µ©µÄò¤@¬q®É¶¡

        in      al,61h
        and     al,11111100b    ;50 ¾B±¼¦ì¤¸ 0 ¤Î¦ì¤¸ 1
        out     61h,al          ;51 Ãö±¼³â¥z
        jmp     gt_key

exit:   int     20h
;---------------------------------------
code    ends
;***************************************
        end     start

®e¤p¤ì°¸µy°µ¸Ñ»¡¡Cµ{¦¡²Ä 33¡B34 ¦æ¡A§â 10110110B ¶ñ¤J°ð 43H¡C¬°¦ó¶ñ¤J 10110110B ³o­Ó¼Æ©O¡H½Ð°Ñ¦Ò«eªí¥iª¾¡A¦]¬°¿ï¾Ü­p®É¾¹ 2¡A©Ò¥H²Ä 6¡B7 ¦ì¤¸¬O 10¡F­n¥ýŪ¼g¸û§Cªº¦ì¤¸²Õ¦AŪ¼g¸û°ªªº¦ì¤¸²Õ¡A©Ò¥H²Ä 4¡B5 ¦ì¤¸¬° 11¡F¥H­p®É¼Ò¦¡ 3 ­p®É¡A©Ò¥H²Ä 1¡B2¡B3 ¦ì¤¸¬° 011¡F¿é¤J¼Æ­È¥H¤G¶i¦ì®æ¦¡ ( §Y¤Q¤»¶i¦ì ) ªí¥Ü¡A©Ò¥H²Ä 0 ¦ì¤¸¬° 0¡C

¦¹µ{¦¡¬°¼ÒÀÀ¿ûµ^Áä½Lµo¥XÁn­µ¡A©Ò¥H·í¨Ï¥ÎªÌ¨C«ö¤U¤@Áä¡A´N¨Ï³â¥zµo¥X¸ÓÁä©Ò¹ïÀ³ÀW²vªºÁn­µ¡A¨Ã¨ÏÁn­µ«ùÄò¤@¬q®É¶¡¦Ó«á°±¤îµo­µ¡C­n¨Ï³â¥zµLÁn¡A¥u­n¨Ï°ð 61H ªº²Ä 0 ©Î²Ä 1 ¦ì¤¸¥ô¦ó¤@­Ó¬°¹s§Y¥i¡A¦ý¤S¨Ï¨ä¥L¦ì¤¸¤£§ó°Ê¡A©Ò¥H¦b 50 ¦æ¨Ï¥Î AND «ü¥O­¢¨Ï¦ì¤¸ 0 ¤Î¦ì¤¸ 1 Åܬ°¹s¡C

µ{¦¡²Ä 43 ¦æ¨ì²Ä 47 ¦æ¬O¥Î¨Ó©µ¿ð³â¥zµo¥XÁn­µªº¡C³o¬O¦]¬°²{¦b¹q¸£°õ¦æ³t«×«Ü§Ö¡A°²¦p¨S¦³³o¬q©µ¿ð®É¶¡µ{¦¡¡A¤@Àþ¶¡´N·|°õ¦æ¨ì²Ä 49 ¦æ¨ÏÁn­µ¤Óµu¡Aµu¨ì±zÅ¥¤£¨£¡A©Ò¥H­n¤@¬q©µ¿ð®É¶¡¨Ï³â¥zµo¥XªºÁn­µ°÷ªø¡C¦Ü©ó­n©µ¿ð¦h¤Ö¡A¥²¶·µø¹q¸£³t«×½Õ¾ã¡A³t«×¶V§Öªº¹q¸£¥²¶·¨Ï DX §ó¤j¤~¦æ¡C¤p¤ì°¸ªº¹q¸£¬O AMD K6-2-500¡A¤]´N¬O 500MHz µ¥¯Åªº¡A°²¦p±zªº¹q¸£¬O 2GHz ¯Åªº¡ADX À³·í­n§ó¤j¡C

©³¤U¤p¤ì°¸¤¶²Ð¦p¦ó¹ê§@¤@­Ó­p®É¾¹¡A³o­Ó­p®É¾¹¤]¥i¥H¥Î¦b­×§ï PIANO µ{¦¡¡A¤£¥²¦A¥Î¹Á¸Õ¿ù»~ªº¤èªk©µ¿ð®É¶¡¡C


ºë±K­p®É¾¹

­ì²z

8253 ´¹¤ùÁö¯à±À°Ê³â¥z¡A¦ý³o¥u¬O¥¦ªþÄݪº¥\¯à¡A¥¦¥D­nªº¥\¯à¨ä¹ê¬O­p®É¡C³oùةҿתº­p®É¬O«ü¨â¨Æ¥óµo¥Í¬Û¶Z¦h¤Ö®É¶¡¡AºÙ¬°®É¶¡¶¡¹j¡C¦³Ãö­p®É¾¹ªº¤èªk¡A¤@¯ë¬O§Q¥Î AH=2CH/INT 21H ©Î CMOS ´¹¤ù¤À§OŪ¨ú¨â¨Æ¥óµo¥Íªº®É¶¡¡AµM«á­pºâ®É¶¡®t´N¯à¨D¥X®É¶¡¶¡¹j¡A³o¼Ëªº­p®É¤èªkºë±K«×¶È¯à¨ì¹F¦Ê¤À¤§¤@¬í¡C¦¹³B¤p¤ì°¸¥HŪ¨ú 8253 ¤º§tªº­p¼Æ¼È¦s¾¹¨Ó­p®É¡A³o¼Ëªº­p®É¤èªkºë±K«×¥i±µªñ·L¬í ( ¤@·L¬íµ¥©ó 10¡Ð6 ¬í )¡C¤£¹L¦bºC³tªº¹q¸£¡A¦p 8088¡B80286¡A°õ¦æ¤@¹D«ü¥Oªº®É¶¡¤ñ¤@·L¬íµy¤p¡A©Ò¥H¹ê»Ú¤W¦³¤@¨Ç­­¨îµLªk¯u¥¿¹F¨ì¦p¦¹ºë±K«×¡A¦ýÁÙ¬O¤ñ AH=2CH/INT 21H ©ÎŪ¨ú CMOS ¨t²Î®É¶¡¨Ó±oºë±K¡C

§Q¥Î 8253 ­p®Éªº­ì²z¨ä¹ê«Ü²³æ¡C«e­±´£¨ì¡A8253/8254 ­p®É¾¹¹s¨C¬íµo¥X 18.2 ¦¸ªº INT 8H ¤¤Â_¡A¦¹¤¤Â_¦¸¼Æ·|³Q BIOS °O¿ý¦b°O¾ÐÅé¦ì§} 0000:046C ³B¡A¥HÂù¦r²Õªºªø«×ªí¥Ü¡C¹q¸£¤@¶}¾÷«á¡ABIOS «K¶}©l¨Ï¸ÓÂù¦r²Õ¥Ñ¹s³vº¥¼W¥[¡A¦¹«á¥H¨C¬í¼W¥[ 18.2¡A´«¥y¸Ü»¡¡A¨C 0.055 ¬í¡A0000:046C ³BªºÂù¦r²Õ·|¼W¥[¤@¡G

1¡Ò18.2¡×0.055

©Ò¥H¦pªGŪ¨ú¨â¦¸¦ì©ó°O¾ÐÅé 0000:046C Âù¦r²Õ¡A¨Ã¨D¥X¨âªÌ¤§®t­È¡A¦A°£¥H 18.2 ´N¬O¨â¦¸Åª¨úªº®É¶¡¶¡¹j¡A¨ä³æ¦ì¬°¡y¬í¡z¡C¤£¹L³o¼Ëªº­p®Éºë±K«×¶È¶È 0.055 ¬í¡C

¦pªG­n¦A¼W¥[ºë±K«×¡AÁÙ¥i¥H¦AŪ¨ú 8253/8254 ­p®É¾¹¹sùØ­±ªº­p¼Æ¼È¦s¾¹¼Æ­È¡C¸Ó¼Æ­È¦b 0.055 ¬í¤º¡A·|¥Ñ 0FFFFH ³v¦¸»¼´î¦Ü 0¡A©Ò¥Hºë±K«×¬° 8.4¡Ñ10¡Ð7 ¬í¡A¤j¬ù¤@·L¬í¡G

0FFFFH¡×65536
0.055¡Ò65536¡×8.4¡Ñ10¡Ð7

»¡¤F³o»ò¦h¡A¾ã²z¤@¤U¡C§Ú­Ìªº­p®É¾¹¬O¤T­Ó¦r²Õ²Õ¦¨ªº¡A«e¨â­Ó¦r²Õ¬OŪ¨ú 0000:046C ªºÂù¦r²Õ¡A¦¹Âù¦r²Õ¬O¥H 0.055 ¬í¬°³æ¦ì¡F«á¤@­Ó¦r²Õ¬OŪ¨ú­p®É¾¹ 0 ¤ºªº­p¼Æ­È¡A¦¹­p¼Æ­È¬°¤@¦r²Õªø«×¡A¥H 8.4¡Ñ10¡Ð7 ¬í¬°³æ¦ì¡C

·í¬Y¨Æ¥óµo¥Í®É¡A¦]¬°­p¼Æ¼È¦s¾¹¤ºªº­p¼Æ­È»¼´î¦Ü¹s®É¡A0000:046C ¤§¤¤Â_¦¸¼Æ¤~¼W¤@¡A©Ò¥H§Ú­ÌÀ³¥ýŪ¨ú­p¼Æ¼È¦s¾¹¤ºªº­p¼Æ­È¡A¦AŪ¨ú 0000:046C ¤ºªº¤¤Â_¦¸¼Æ¡A³o¼Ë¤~§ó±µªñ¨Æ¥óµo¥Íªº®É¶¡¡C¦ý¬O·í§Ú­ÌŪ¨ú­p¼Æ¼È¦s¾¹«á¡A¨ä­p¼Æ¾¹¤ºªº¼Æ­È¤´¤£Â_¦a­Ë¼Æ¡A¦³¥i¯à¦bŪ¨ú­p¼Æ¼È¦s¾¹¤§«á¡A¦ý¬O©|¥¼Åª¨ú 0000:046C ªº³o¬q®É¶¡¤º¡A­p¼Æ¼È¦s¾¹´N¤wÂk¹s¡A³o¼ËŪ¨úªº¤¤Â_¦¸¼Æ¨ä¹ê¬O»Ý­n´î¤Ö¤@ªº¡C³o­Ó°ÝÃD·|µo¥Í¦b­p¼Æ¼È¦s¾¹¤ºªº¼Æ­È¤w¸g«Ü±µªñ¹s®É¡A¬°ÁקK³o­Ó°ÝÃDµo¥Í¡A¤p¤ì°¸ªº°µªk¬O¥ý¸T¤î¤¤Â_µo¥Í¡A«ÝŪ¨ú 0000:046C ¤§¤¤Â_¦¸¼Æ«á¦A¨Ï¤¤Â_¯àµo¥Í¡C

PLAY.ASM »Pºq¦±ÀÉ

©³¤U¤p¤ì°¸§Q¥Î¤W­z­ì²z¼¶¼g¤@µ{¦¡¡APLAY.ASM¡A¦¹µ{¦¡¥i¥H§Q¥Î PC ³â¥z¼u«µ¤@­º¦±¤l¡C©Ò¼u«µªº¦±¤l¥H¯Â¤å¦rÀɧΦ¡´y­z¡A¤p¤ì°¸ºÙ¤§¬°ºq¦±ÀÉ¡A¨ä®æ¦¡²Ä¤@¦æ¬°ºq¦±¦WºÙ¡A²Ä¤G¦æ¥H«á¨C 6 ­Ó¦ì¤¸²Õªí¥Ü¤­½uÃФ¤ªº¤@­Ó­µ²Å¡A«e¨â­Ó¦ì¤¸²Õªí¥Ü­µ°ª¡A³o¨â­Ó¦ì¤¸²Õªº²Ä¤@­Ó¦ì¤¸²Õªí°ª­µ©Î§C­µ¡A°ª­µ¥Î¡y+¡zªí¥Ü¡A§C­µ¥H¡y-¡zªí¥Ü¡A¡y0¡zªí¥Ü¥¿±`¡A²Ä¤G­Ó¦ì¤¸²Õªí¥Ü­µ¶¥¡AC ªí¥Ü Do¡BD ªí¥Ü Re¡BE ªí¥Ü Mi¡BF ªí¥Ü Fa¡K¡K¡BB ªí¥Ü Si¡A¦pªG¬O 0 ªí¥Ü¥ð¤î²Å¡C

¤§«á©Ò±µªº¤@­Ó¦ì¤¸²Õ¬O¤À¹j²Å¸¹¡A¥i¥Î¡y,¡z©ÎªÅ¥Õªí¥Ü¡A¨ä¹ê¦b PLAY.ASM ùبèS¦³Àˬd¤@©w­n¥Î¡y,¡z©ÎªÅ¥Õ¡C±µ¤U¨Óªº¨â­Ó¦ì¤¸²Õªí¥Ü¦¹­µ²Åªº©ç¤l¡A01 ªí¥Ü¤Q¤»¤À­µ²Å ( ¥|¤À¤§¤@©ç )¡B02 ªí¥Ü¤K¤À­µ²Å ( ¥b©ç )¡B04 ªí¥Ü¥|¤À­µ²Å ( ¤@©ç )¡B06 ªí¥ÜªþÂI¥|¤À­µ²Å ( ¤@©ç¥b )¡B08 ªí¥Ü¤G¤À­µ²Å ( ¨â©ç )¡B16 ªí¥Ü¥þ­µ²Å ( ¥|©ç )¡C©ç¤l§¹«á¡A±µ¤U¨Óªº¤@­Ó¦ì¤¸²Õ¬O¤À¹j²Å¸¹¡A¡y,¡z¡C¨Ò¦p©³¤U¬O¤@­º¦Ñºq¡A¡y¯¬§A©¯ºÖ¡z¡Aªººq¦±ÀÉ¡AÀɦW¬O bless_you_happy.txt¡A±z¥i¥Î¤å®Ñ³nÅé½s¿è¡G

¯¬§A©¯ºÖ
0G,06,0A,01,0G,01,0E,04,0G,04
0C,04,0D,02,0C,01,0D,01,0E,08
0G,06,0A,02,+C,04,0A,02,0E,02
0G,16
0C,06,0C,02,0D,02,0C,01,0D,01,0E,02,0G,02
0G,02,0A,02,+C,02,+D,02,0A,01,0G,01,0E,04
00,02,0G,02,0G,02,0E,03,0D,02,0E,02,0E,02,0D,02
0C,16
0A,06,0G,01,0A,01,+C,04,0A,02,+C,02
+C,02,+D,02,+C,02,+C,02,+E,08
00,02,+D,02,+C,02,0A,02,0G,02,+C,02,0A,01,0G,01,0E,02
0G,16
0C,06,0C,02,0D,02,0C,01,0D,01,0E,02,0G,02
0G,02,0G,02,0E,02,0G,02,0A,02,0A,01,0G,01,0A,04
00,02,0G,02,0G,02,+E,02,+D,02,+C,02,0G,02,+D,02
+C,16

°õ¦æ®É¡A¦b DOS ¼Ò¦¡¤U¿é¤J

D:\HomePage\SOURCEG>play bless_~1.txt [Enter]
ºt«µ¡y¯¬§A©¯ºÖ¡z  ¡÷µ{¦¡¦^À³ºq¦±¦W

´N¥i¥H¬Ý¨£¿Ã¹õ¤WÅã¥Üºq¦W¡A¨Ãµo¥XÁn­µ¡C¦b³o­Óµ{¦¡ùØ¡A±z¤]¥i¥H¨Ï¥ÎªøÀɦW¡A¦Û±q Win 95 ¤W¥«¥H¨Ó¡AÀɦW´N¤£¦b¨ü­­©ó 8.3 ®æ¦¡¡A©Ò¥Hµ{¦¡¤]¤£À³¸Ó­­¨î¥u¯à¨Ï¥Î 8.3 ®æ¦¡ªºÀɦW¡A¨Æ¹ê¤W¦b Win 9X DOS ¼Ò¦¡ùتº AH=71H/INT 21H ¦³¤@¨t¦C¦³Ãö³B²zªøÀɦWªºªA°È¤¤Â_¡A½Ð°Ñ¦Ò²Ä 15 ³¹©Î Ralf Brown's Home Page ªº»¡©ú¡C©Ò¥H°õ¦æ PLAY.COM ®É¡A±z¤]¥i¥H¿é¤J

D:\HomePage\SOURCEG>play bless_you_happy.txt [Enter]  ¡÷¨Ï¥ÎªøÀɦW
ºt«µ¡y¯¬§A©¯ºÖ¡z

PLAY.ASM ­ì©lµ{¦¡

©³¤U¬Ý¬Ý PLAY.ASM¡C§â PLAY.ASM ²ÕĶ¡B³sµ²¦n¡A¥i±o PLAY.EXE¡A¦A¥Î EXE2BIN.EXE Âà´«¦¨ PLAY.COM ¥i°õ¦æÀÉ¡C

file_info       struc       ;01 ©w¸q file_info µ²ºcÅé
attributes                  dd   ?	
creation_time               dq   ?	
last_access_time            dq   ?	
last_write_time             dq   ?	
volume_serial_number        dd   ?	
file_size_high              dd   ?	
file_size_low               dd   ?	
number_of_links_to_file     dd   ?
unique_file_identifier_high dd   ?	
unique_file_identifier_low  dd   ?	
file_info       ends        ;12 µ²ºcÅéµ²§ô

;***************************************
play    segment
        assume  cs:play,ds:play
        org     100h
;---------------------------------------
start:  jmp     begin
song_info       file_info       <?>
handle  dw      ?
msg1    db      'Àɮ׶}±Ò©ÎŪ¨ú¿ù»~¡C$'
msg2    db      'ºt«µ¡y$'
msg3    db      '¡z',0dh,0ah,'$'
msg4    db      'ÀɮפӤj¡C$'
freq1   dw      131,147,165,174,196,220,247         ;26 §C­µÀW²v
freq2   dw      262,294,330,347,392,440,494
freq3   dw      524,588,660,694,784,880,988         ;28 °ª­µÀW²v
lst_buf dw      ?
time1   dw      ?,?,?,0
time2   dw      ?,?,?,0

begin:  mov     si,81h          ;33 «ü¦V PLAY.COM °Ñ¼Æ¦ì§}
        cld
nxt0:   lodsb
        cmp     al,' '
        je      nxt0
        mov     dx,si
        dec     dx              ;39 ºq¦±ÀɦW°_©l¦ì§}
nxt1:   lodsb
        cmp     al,0dh
        jne     nxt1
        dec     si
        mov     byte ptr [si],0 ;44 ºq¦±ÀɦWµ²§ô¦ì§}

        mov     si,dx
        sub     bx,bx
        mov     dx,1
        mov     cx,dx
        mov     ax,716ch
        int     21h             ;50 ¶}±ÒÀÉ®×
        jc      exit0
        mov     handle,ax

        mov     bx,ax
        mov     dx,offset song_info
        mov     ax,71a6h
        int     21h             ;57 ¨ú±oÀɮ׸ê°T

        mov     bx,handle
        mov     cx,word ptr song_info.file_size_low
        cmp     cx,0f000h
        ja      exit2
        mov     dx,offset buffer
        mov     ah,3fh
        int     21h             ;63 Ū¨úÀÉ®×
        jnc     ok0

exit0:  mov     dx,offset msg1  ;59 ¶}±ÒÀɮשÎŪ¨ú¿ù»~
exit3:  mov     ah,9
        int     21h
exit1:  mov     ax,4c00h
        int     21h
        
exit2:  mov     dx,offset msg4  ;75 ÀɮפӤj
        jmp     exit3

ok0:    add     dx,word ptr song_info.file_size_low
        mov     lst_buf,dx      ;79 ­pºâºq¦±Àɳ̫á¦ì§}

        call    print_song_name ;81 Åã¥Üºq¦±¦W
        mov     si,di
nxt2:   inc     si              ;83 «ü¦V­µ°ª
nxt3:   lodsw
        cmp     al,0ah          ;85 Àˬd¬O§_´«¦æ
        jne     nt_lf           ;86 ­Y¤£¬O´«¦æ¡A¨ì nt_lf
        dec     si              ;87 ­Y´«¦æ¡A±N SI ´î¤@
        cmp     si,lst_buf      ;88 ¡A¦A¬d¬O§_¤w¨ìÀɮקÀµ²§ô
        je      t_off           ;89 ­Y¤w¨ìÀɮקÀ¡A¨ì t_off ³B
        jmp     nxt3
nt_lf:  cmp     ax,3030h        ;91 Àˬd¬O§_¬°¥ð¤î²Å
        jne     nt_rst          ;92 ­Y¤£¬O¥ð¤î²Å¡A¸õ¨ì nt_rst ³B
        call    turn_off_speaker;93 ­Y¬O¥ð¤î²Å¡A«hÃö³¬³â¥z
        jmp     short last_t

nt_rst: call    get_freq_addr   ;96 ¨ú±oÀ³¼u«µÀW²v¦ì§}
        call    sound

last_t: mov     di,offset time2 ;99 ¨ú±o INT 8 ¤¤Â_¦¸¼Æ¡A¨Ã¦s
        call    get_time        ;100 ©ó time2 Âù¦r²ÕÅܼÆùØ

        inc     si
        lodsw                   ;103 ¨ú±o©ç¤lªø«×
        sub     ax,3030h        ;104 ©ç¤lªø«×ªº¤Q¦ì¼Æ¦b AL¡A­Ó¦ì¼Æ¦b AH
        mov     bl,ah
        cbw
        mov     bh,10
        mul     bh
        add     al,bl           ;109 AX= ©ç¤lªø«×ªº¤Q¤»¶i¦ì¼Æ
        shl     ax,1            ;110 °²³]¤@©çªº®É¶¡¬° 16/18.2 ¬í
        shl     ax,1            ;111 AX= ¦b©ç¤l®É¶¡¤ºªº¤¤Â_¦¸¼Æ
        mov     di,offset time2+2
        add     [di],ax         ;113 timer2= ©ç¤lµ²§ô®Éªº¤¤Â_¦¸¼Æ
        adc     word ptr [di+2],0

gt_tm:  mov     di,offset time1 ;116 ¨ú±o INT 8H ¤Î­p¼Æ¾¹¼Æ­È©ó time1
        call    get_time

        mov     bx,offset time1+2
        mov     di,offset time2+2
        mov     ax,[bx+2]
        cmp     ax,[di+2]       ;122 ¤ñ¸û time1 ¬O§_¤j©ó©Îµ¥©ó time2
        jb      gt_tm           ;123 ­Y§_¡A«h¦AŪ¨ú INT 8H ¤¤Â_¦¸¼Æ¤Î­p¼Æ­È
        mov     ax,[bx]
        cmp     ax,[di]
        jb      gt_tm

        cmp     si,lst_buf      ;128 ­Y¬O¡Aªí¥Ü©ç¤l¤wµ²§ô¡AÀˬd¬O§_¨ìÀɮקÀ
        jne     nxt2
t_off:  call    turn_off_speaker
        mov     bx,handle
        mov     ah,3eh
        int     21h                 ;133 Ãö³¬ÀÉ®×
        jmp     exit1
;---------------------------------------
;¦L¥Xºq¦±¦W
;¿é¤J¡Ðbuffer ¤§¸ê®Æ
print_song_name proc    near
        mov     di,offset buffer
        mov     al,0dh              ;140 ´M§ä²Ä¤@¦æµ²§ô¦ì§}
        repne   scasb
        mov     byte ptr [di-1],'$' ;142 ¥[¤W¡y$¡z·í§@ AH=9/INT 21H
        mov     ah,9                ;143 ©Ò¦L¥X¦r¦êµ²§ô°O¸¹
        mov     dx,offset msg2
        int     21h
        mov     dx,offset buffer
        mov     ah,9
        int     21h
        mov     dx,offset msg3
        mov     ah,9
        int     21h
        ret
print_song_name endp
;---------------------------------------
;¨ú±oÀW²v¦ì§}
;¿é¤J¡ÐAL¡G0¡B¡Ï¡B¡Ðµ¥°ª§C­µ
;      AH¡GCDEFGAB µ¥­µ¶¥
;¿é¥X¡ÐBX¡G«ü¦V freq1¡Bfreq2¡Bfreq3 ¨ä¤¤¤@­ÓÀW²v¦ì§}
get_freq_addr   proc    near
        mov     dx,offset freq2 ;160 °²³]¤¤­µ
        cmp     al,'+'          ;161 Àˬd¬O§_°ª­µ
        jne     if_low          ;162 ­Y§_¡A¸õ¨ì if_low Àˬd¬O§_§C­µ
        mov     dx,offset freq3 ;163 ­Y¬°°ª­µ¡A¨Ï DX «ü¦V freq3
        jmp     short ok1
if_low: cmp     al,'-'          ;165 Àˬd¬O§_§C­µ
        jne     ok1             ;166 ­Y§_¡A¸õ¨ì ok1
        mov     dx,offset freq1 ;167 ­Y¨Ï§C­µ¡A¨Ï DX «ü¦V freq1

ok1:    and     ah,0dfh ;169 ¨Ï¤p¼gÅܤj¼g
        cmp     ah,'A'  ;170 Àˬd¬O§_¬° La ©Î Si
        je      ra_ton
        cmp     ah,'B'
        je      si_ton
        sub     ah,'C'
ton:    mov     bl,ah   ;175 ¥H freq? ªº¦ì§}¬°°ò·Ç­pºâ­µ°ªÀW
        sub     bh,bh   ;176 ²v¬Û¹ï©ófreq? ¤§¦ì§}¡A
        shl     bx,1    ;177 ¨Ã¦s©ó BX
        add     bx,dx   ;178 ¦A¥[¤W DX¡A«h BX ¬°±N¼u«µ­µ²Å¤§ÀW²v¦ì§}
        ret

ra_ton: mov     ah,5
        jmp     ton
si_ton: mov     ah,6
        jmp     ton
get_freq_addr   endp
;---------------------------------------
;µo¥XÁn­µ
;¿é¤J¡ÐBX¡G«ü¦VÁn­µÀW²v¦ì§}
;¿é¥X¡Ðµo¥XÁn­µ
sound   proc    near
        mov     ax,34dch
        mov     cx,[bx]
        mov     dx,12h
        div     cx
        mov     bx,ax

        mov     al,10110110b
        out     43h,al
        mov     ax,bx
        out     42h,al          ;200 ¥ý¶Ç¥X§C¦ì¤¸
        mov     al,ah
        out     42h,al          ;202 ¦A¶Ç¥X°ª¦ì¤¸
        in      al,61h
        or      al,00000011b
        out     61h,al          ;205 ¥´¶}³â¥zµo¥XÁn­µ
        ret
sound   endp
;---------------------------------------
;¨ú±oºwµª¦¸¼Æ¡A¦s©ó DI ©Ò«üªº¤T­Ó¦r²Õ¤º
;¿é¤J¡ÐDS:DI «ü¦V¤T¦r²Õ¦ì§}
;¿é¥X¡ÐES:DI ©Ò«ü¦ì§}±N¦s¤J TIMER0 ­p¼Æ­È¤Î INT 8H ¤¤Â_¦¸¼Æ
;      AX¡BBX ¤§­È·|³Q¯}Ãa
get_time        proc    near
        push    ds      ;214 «O¦s DS¡BSI
        push    si      
        sub     ax,ax   ;216 ¨Ï DS:SI «ü¦V 0000:046C
        mov     si,46ch
        mov     ds,ax

        cli             ;220 ¸T¤îµwÅ餤Â_

        mov     al,0    ;222 ­n¨D«O¯d­p®É¾¹¹sªº­p¼Æ­È
        out     43h,al

        in      al,40h  ;225 Ū¨ú­p¼Æ¾¹¤§­È¡A¨Ã¦s©ó BX
        mov     bl,al
        in      al,40h
        mov     bh,al
        not     bx      ;229 ¨Ï BX §ï¬°»¼¼W

        mov     ax,bx
ok:     stosw           ;232 ¦s¤J­p¼Æ­p¼Æ­È
        movsw           ;233 ¦s¤J INT 8H ¤¤Â_¦¸¼Æ
        movsw

        sti             ;236 «ì´_¸T¤îªºµwÅ餤Â_ 
        pop     si
        pop     ds
        ret
get_time        endp
;---------------------------------------
turn_off_speaker        proc    near
        in      al,61h
        and     al,0fch
        out     61h,al  ;245 Ãö³¬³â¥z
        ret
turn_off_speaker        endp
;---------------------------------------
buffer:                 ;249 ºq¦±Àɸê®Æ¦s©ñ³B
;---------------------------------------
play    ends
;***************************************
        end     start

¨ÌºD¨Ò¡A¤p¤ì°¸µy§@¸ÑÄÀ¡C1¡ã12 ¦æ¬O©w¸q¤@­Óµ²ºcÅé¡A¦¹µ²ºcÅéªí¥ÜÀɮ׸ê°T¡A¦b 57 ¦æ¨ú±oÀɮ׸ê°T®É¡A¨t²Î·|§â bless_yuo_happy.txt ªº¸ê°T¶ñ¤J¦¹µ²ºcÅé¡C

AX=71A6H/INT 21H

³o­Ó¤¤Â_ªA°Èµ{¦¡¬O¥Î¨ÓÀò±o¬Y­ÓÀɮתº¸ê°T¡A¨ä¥Îªk¬O¨Ï AX ¶ñ¤J 71A6H¡ABX ¶ñ¤JÀÉ®×¥N½X¡ADS:DX «ü¦V¤@­Óµ²ºcÅé¡C·í¦¨¥\¦a¨ú±o¸ÓÀɸê°T®É¡A¶i¦ìºX¼Ð·|³Q²M°£¡A¨Ã¦b DS:DX ©Ò«ü©wªºµ²ºcÅé¶ñ¤J¸ÓÀɪºÀɮ׸ê°T¡AÀɮ׸ê°Tªºµ²ºc¦p¤U¡G

°¾²¾¦ì§}¤j¤p ·N¡@¡@¸q
0 Âù¦r²Õ ÀÉ®×ÄÝ©Ê
04 ¥|¦r²Õ «Ø¥ß®É¶¡
0C ¥|¦r²Õ ³Ì«áŪ¨ú®É¶¡
14 ¥|¦r²Õ ³Ì«á§ó°Ê®É¶¡
1C Âù¦r²Õ ¨÷§Ç¸¹
20 Âù¦r²Õ Àɮפj¤p ( ¸û°ªªº 32 ¦ì¤¸ )
24 Âù¦r²Õ Àɮפj¤p ( ¸û§Cªº 32 ¦ì¤¸ )
28 Âù¦r²Õ
2C Âù¦r²Õ
30 Âù¦r²Õ
¦b³o­Óµ{¦¡ùØ¡A³Ì­«­nªº¬OÀɮפj¤p¡A±o¨ìÀɮפj¤p¤§«á¡Aµ{¦¡¤~ª¾¹D­nºt«µ¨ì¨º¨à¤~µ²§ô¡C

µ{¦¡²Ä 33¡ã44 ¦æ¬O¨ú±o¨Ï¥ÎªÌ¦b©R¥O´£¥Ü¤U¿é¤J PLAY ¤§«áªº°Ñ¼Æ¡A¤]´N¬Oºq¦±ÀɦW¡C°Ñ¼Æ¦ì§}·|©ñ¦b PSP ªº 80H ³B¡A¦ý 80H ¬O¿é¤J°Ñ¼Æªºªø«×¡A©Ò¥H¦¹µ{¦¡¥Ñ 81H ¶}©l¡C¨Ò¦p±z¦b DOS ¼Ò¦¡¤U¿é¤J

D:\HomePage\SOURCEG>play bless_you_happy.txt [Enter]

¨º»ò¦b 80H ³B¡A·|¦³±z¿é¤Jªº°Ñ¼Æ¡A¦p¤U¡J

1825:0080  14 20 62 6C 65 73 73 5F-79 6F 75 5F 68 61 70 70  . bless_you_happ
1825:0090  79 2E 74 78 74 0D 00 00-00 00 00 00 00 00 00 00  y.txt...........
1825:00A0  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................

¬°¤F¥Î AX=716C/INT 21H ¶}±ÒÀɮסA¥²¶·§ä¨ìºq¦±Àɪº°_©l¦ì§}¡A¨Ã¦bÀɮקÀ¥[¤W¡y0¡zªí¥Üµ²§ô¡A³o´X¦æ´N¬O°µ³o¼Ëªº¨Æ¡C

¶}±Ò³o­Óºq¦±Àɤ§«á¡A¥ý±o¨ì¦¹ÀɪºÀɮ׸ê°T¡A¥ÑÀɮ׸ê°TùبD¥XÀɮפj¤p¡C¦¹µ{¦¡³Ì«á·|Ū¨ú¾ã­ÓÀɮפº®e¡A¨Ã¦s©ñ¦bµ{¦¡§ÀºÝªº buffer: ¼Ð¸¹³B¡A©Ò¥H buffer: ¼Ð¸¹¦ì§}¥[¤WÀɮפj¤p´N¬O­µ¼ÖÀɤº®eªº³Ì«á¦ì§}¡C¤]´N¬O»¡·í¦¨¬Oºt«µ¨ì³o­Ó¦ì§}§¹²¦¡A¾ã­ººq¦±´Nµ²§ô¤F¡A³o­Ó¦ì§}³Q¦s¦b lst_buf ÅܼÆùØ ( ¦bµ{¦¡²Ä 29 ¦æ©w¸q)¡C½Ð¬Ý¬Ýµ{¦¡²Ä 52¡ã79 ¦æ´N¬O°µ³o¨Ç¨Æ±¡¡C

µ¥³o¨Ç¨Æ±¡°µ§¹¡Aµ{¦¡´N¶}©l¼u«µ¼Ö¦±¤F¡C¤@¯ë¦Ó¨¥¡A¤@­Ó­µ¥]§t­µ½Õ¤Î©ç¤l¡A­µ½Õ«üªº´N¬OÀW²v¡A©ç¤l¬O«ü³â¥zµo¥XªºÁn­µÀ³«ùÄò¦h¤[¡C¦Ó©³¤Uªºµ{¦¡´N¬O³B²z³o¨â­Ó°ÝÃD¡C

²Ä 83¡ã97 ¦æ¬OŪ¨ú buffer: ³Bªº­µ¼ÖÀɸê®Æ¡A¦¹®É SI «ü¦V­µ¼ÖÀɺq¦±¦W¤§«áªº¦ì§}¡A¥Î LODSW ¸ü¤J¦Ü AX «áÀˬd¬O§_´«¦æ¡A¬O§_¨ìÀɮקÀ¡A¬O§_¬°¥ð¤î²Å¡A¦pªG³£¤£¬Oªº¸Ü¡Aªí¥Ü©ÒŪ¨ìªº¬O­µ°ª¡AµM«á¨ì 96 ¦æ¨ú±o¸Ó­µªºÀW²v¡AµM«á¨ì 97 ¦æµo¥XÁn­µ¡C

µo¥XÁn­µ§¹«á«K¬O¨M©w³o­ÓÁn­µ«ùÄò¦h¤[¡A¤p¤ì°¸ªº°µªk¦bµo¥XÁn­µ«á¥ß§YŪ¨ú®É¶¡¡A¦¹®É¶¡´N¬Oµo¥XÁn­µªº®É¶¡¡AµM«áŪ¨úºq¦±Àɪº©ç¤lªø«×¡A©ç¤lªø«×´N¬OÁn­µ«ùÄòªº®É¶¡¡AÁn­µ«ùÄòªº®É¶¡¦A¥[¤Wµo¥XÁn­µªº®É¶¡´N¬O°±¤îÁn­µªº®É¶¡¡AµM«á¶i¤J¤@­Ó°j°é¡A¦¹°j°éªº²Ä¤@¨B¬OŪ¨ú®É¶¡¡A¦A¤ñ¸û¦¹®É¶¡¬O§_µ¥©ó°±¤îµo¥XÁn­µªº®É¶¡¡A¦pªG¤£¬Ûµ¥¡A·|¦^¨ì°j°éªº²Ä¤@¨B¡A­«½Æ³o¨Ç°Ê§@¡A¤@ª½¨ìŪ¨úªº®É¶¡µ¥©óÁn­µ°±¤îªº®É¶¡¡AµM«á¶i¦æ¤U¤@­Ó­µ²Å¡C

¤p¤ì°¸§Q¥Î¤@­Ó°Æµ{¦¡¡Aget_time¡AŪ¨ú®É¶¡¡Cget_time ¦bµ{¦¡²Ä 214¡ã239 ¦æ¡A¥¦·|§â®É¶¡°O¿ý¦b ES:DI ©Ò«üªº¤T­Ó¦r²Õªø«×ªº¦a¤è¡C°Æµ{¦¡¤@¶}©l¬O«O¦s SI ¨Ã¨Ï DS:SI «ü¦V 0000:046C¡A¦]¬° SI ¦b¥Dµ{¦¡¤¤ªí¥Üºq¦±Àɪº«ü¼Ð¡A¥²¶·«O¦s¡A§_«h´NµLªk±oª¾¤U¤@­Ó­µ¦b¨º¨à¤F¡C±µ¤U¨Ó¸T¤îµwÅ餤Â_¡A¥Î CLI «ü¥O¡C

CLI «ü¥O

µM«áŪ¨ú­p®É¾¹ 0 ªº­p¼Æ¼È¦s¾¹¤ºªº¼Æ­È¡AŪ¨úªº¤èªk¬O¥ý

²Ä 26¡ã28 ¦æ¬O©w¸q­µ²ÅÀW²v¡A¤@­ººqùسq±`·|¦³¤Ö³¡¥÷§C­µ»P°ª­µ¡CPLAY.COM ¨ú±o¬Y­Ó­µ²ÅÀW²vªº¹Lµ{¦b²Ä 160¡ã184 ¦æªº get_freq_addr °Æµ{¦¡¡A


µù¤@¡G¥»³¹ªº²Ä¤G³¡¥÷¥]§t¤@­Ó©µ¿ð®É¶¡ªºµ{¦¡¡A¦¹³B¤p¤ì°¸¥Î 8253 ­p®É¾¹¨Ó¹F¨ì©µ¿ðªº¥Øªº¡AÅý³â¥z¯à«ùÄòµo¥X¤@¬qÁn­µ¡C¨Æ¹ê¤W AT ¯Å¥H¤Wªº¹q¸£¤¤¡ABIOS ¤w¸g´£¨Ñ¤F³o­ÓªA°Èµ{¦¡¡C¾¨ºÞ BIOS ¤w¸g´£¨Ñ³o­ÓªA°Èµ{¦¡¡A¤£¹L¦Û¤v DIY ¤@µf¡A¤]¬O«Ü¦³½ìªº¡A¤£¬O¶Ü¡H

AH=86H/INT 15H ©µ¿ð®É¶¡

¦¹ BIOS ¤¤Â_ªA°Èµ{¦¡¥i¥H¨Ï¹q¸£©µ¿ð¤@·L¬í¦Ü¤@¤p®Éªº®É¶¡¡A¨Ï¥Î®É AH ¥²µ¥©ó 86H¡ACX:DX ¦s©ñ­n©µ¿ðªº®É¶¡¡A¦¹®É¶¡¥H 0.977 ·L¬í¬°³æ¦ì¡C( ¤@·L¬í = 10¡Ð6¬í )


¦^¨ì­º­¶¡A ¨ì²Ä¤G¤Q¤K³¹¡A ¨ì²Ä¤T¤Q³¹