Ch 09 Åã¥Ü°O¾ÐÅ骺¤º®e

¯u¹ê¼Ò¦¡ªº°O¾ÐÅé

IBM PC/XT/AT ¤Î¨ä¬Û®e¹q¸£ªº¾ú¥v²­z

Intel ¤½¥q¥X«~ªº 80386 µ¥¯Å¥H¤Wªº CPU ¥i¦b¯u¹ê¼Ò¦¡(real mode)¡B«OÅ@¼Ò¦¡(protect mode)¤ÎµêÀÀ 86 ¤TºØ¼Ò¦¡¤U¾Þ§@¡A¦ý¬O¦b³o¸Ì¥u±´°Q¯u¹ê¼Ò¦¡¡C¦b¯u¹ê¼Ò¦¡¤U CPU ³Ì¦h¥u¯à¨Ï¥Î 1MB(1048576 ­Ó¦ì¤¸²Õ) ªº°O¾ÐÅé¡C°²¦p§Aªº¹q¸£°t¦³¶W¹L 1MB ªº°O¾ÐÅé¡A¦b DOS ¯u¹ê¼Ò¦¡¤U¡A¤]¥u¯à¨Ï¥Î 1MB ªº°O¾ÐÅé¡A¦h¾lªº°O¾ÐÅé¤]¤£¯à¨Ï¥Î¡C

¬°¤°»ò·|¦³³o¼Ëªº­­¨î©O¡H³o­n±q¦è¤¸ 1980 ¦~ 4 ¤ë»¡°_¡C¦b¨º¦~¤§«e¡A³Ì¬y¦æ­Ó¤H¹q¸£¾÷ºØ¬OÄ«ªG¤½¥q¥X«~ªº Apple ][ ¹q¸£¡A¥¦°t¦³ 8 ¦ì¤¸ªº 6502 CPU¡A³Ì¦h¥i¥H¨Ï¥Î 64KB(65536 ­Ó¦ì¤¸²Õ) ªº°O¾ÐÅé¡C¨º¤@¦~ IBM ¥´ºâ±À¥X·s¤@¥Nªº 16 ¦ì¤¸­Ó¤H¹q¸£¡AºÙ¬°IBM PC¡A´N¬O personal computer ¤§·N¡A¤§«á¤@¨â¦~¤§¤º IBM PC ¤j½æ¡A´X¥G¦û¤F Apple ][ ªº¥«³õ¡CIBM ©Ò¥Îªºµ¦²¤¬O¤½¶} PC ªº¤º³¡¬[ºc¡A©Ò¥H³\¦h¬Û®e¼t°Ó¥u­n¦³·NÄ@³£¥i¥H³c½æ»s³y PC ªº¬Û®e¾÷ºØ¡C

«á¨Ó¡AIBM ¥t¥~¤S±À¥X¤F«¬¸¹ XT ªº¹q¸£¡A¥¦»P PC ³Ì¤jªº®t§O¦b XT °t³Æ¤F 10MB ªºµwºÐ¾÷¡A«á¨Ó¦A±À¥X¥H 80286 CPU ¬°°ò¦ªº AT (advance technique) ­Ó¤H¹q¸£¡C¤§«á¦U®a¬Û®e¼t°Ó±À¥Xªº¬Û®e¹q¸£¾P°â¤ñ IBM ÁÙ¦n¡A¥H­PºtÅܨì IBM µLªk¦A¤]´x´¤ PC ªº³W®æ¡A©Ò¥HÅܦ¨²{¦bªº PC ¬O¦Ê®aª§»ï¡A½´«kµo®i¡C·íµM²{¦bªº PC ¤º³¡¬[ºc©M·íªì IBM ¥Í²£ªº PC ¬[ºc´X¥G¥þ¤£¦P¤F¡A¦ý¬O PC ³o­Ó¦Wµü¤w¸gÅܦ¨«ü±M¬°¤@­Ó¤H©Ò¨Ï¥Îªº¹q¸£¡A¦Ó¤£¬O¥H«e IBM ±À¥Xªº PC¡C

·íªì IBM PC ¥i¥H¨Ï¥Î 1MB ªº°O¾ÐÅé¡A¦b·í®É¥i¥H»¡¬O¬Û·íªº¤j¡A¤ñ·í®Éªº Apple ][ ¤j¤F 16 ­¿¡A¦b·í®É¨S¦³¤H»¡¤£°÷¡A´N¹³²{¦b¤@¯ë¹q¸£¬ù 128MB ¨ì 256MB ªº°O¾ÐÅé¡A°²¦p¦³¤@¥x¹q¸£¨Ï¥Î 2048MB ªº°O¾ÐÅé¡A¤@©w¨S¤H·|»¡¤Ó¤pªº¡C©Ò¥H³o 1MB ªº­­¨î¤]¬O¾ú¥vºt¶iªºµ²ªG¡A«D¬O³]­pªÌªº¿ù»~¡C

8088 ªº¦ì§}ªí¥Üªk

·íªì IBM ±Ä¥Î Intel(­^¯Sº¸) ¥Í²£ªº 8088 ¬° CPU¡C8088 ¦³ 20 ±ø¦ì§}½u¡A¥i¥H©w§}¨ì 1MB(220=1048576)¡A1MB ªº¤j¤p¬O 1048576 ­Ó¦ì¤¸²Õ¡A´«ºâ¦¨¤Q¤»¶i¦ì¬O 100000H¡A³o 100000H ­Ó¦ì¤¸²Õªº°O¾ÐÅé±q 00000 ¨ì FFFFFH¡A©Ò¥H¦pªG­n¦s¨ú¬Y¤@­Ó°O¾ÐÅ骺¤º®e¥²¶·­n¦³¼È¦s¾¹¥i¥H®e¯Ç¤­­Ó¤Q¤»¶i¦ìªº¦ì¼Æ(´N¬O­n¦³ 20 ¦ì¤¸ªº¼È¦s¾¹)¡AµM«á¤~¯à¦s¨ú¡C

¦ý¬O³o¼Ë·|²£¥Í³\¦h§ó¤jªº§xÂZ¡A¨Ò¦p·í 20 ¦ì¤¸ªº¼È¦s¾¹©M 16 ¦ì¤¸ªº¼È¦s¾¹­n¥æ´«¸ê®Æ®É¸Ó¦p¦ó³B²z¡H¦Ó¥B¹q¸£¤u·~³£¬O¥H¦ì¤¸²Õ(´N¬O 8 ­Ó¦ì¤¸)ªº¾ã¼Æ­¿¨Ó§@¬°­p¼Æ³æ¦ì¡A¦p 16¡B32¡B64 µ¥¨Ó§@¬°³æ¦ì¡A©Ò¥H 8088 ªº¼È¦s¾¹³£¬O 16 ¦ì¤¸¡A¦ý¬O³o¼Ë³Ì¦h¥u¯à¦s¨ú 64KB °O¾ÐÅé¡A¨Ã¤£¯à¦s¨ú 1MB ªº°O¾ÐÅé¡C

·íªì³]­p 8088 ªº¤uµ{®v«K·Q¨ì¤@­Ó«Ü¦nªº¤èªk¡C´N¬O±Ä¥Î¤À¬q³B²z¡A±N 64KB ©w¸q¬°¤@­Ó°Ï¬q(segment)¡A64KB ªº¤j¤p­è¦n¬O±q 0000H ¨ì FFFFH¡A¥i¥H¥Î 16 ¦ì¤¸ªí¥Ü¡QµM«á 1MB ªº°O¾ÐÅé¥i¥H¤À¦¨¤Q¤»­Ó°Ï¬q¡A³o¨Ç°Ï¬q¥i¥H¥Î 16 ¦ì¤¸ªº¼È¦s¾¹ªí¥Ü¡C§Ú­Ì¹ê»Ú¤W¦bµ{¦¡¤¤¨Ï¥Î®É¡A´N¥Î Segment:Offset ¨Ó©w¥X³o 1MB °O¾ÐÅ餤ªº¥ô¦ó¤@­Ó¦ì¤¸²Õ¡ASegment ©Ò¥Nªíªº´N¬O°Ï¬q¦ì§}¡AOffset ©Ò¥Nªíªº´N¬O°¾²¾¦ì§}¡C

Segment ©M Offset ³£¬O¥Î 16 ¦ì¤¸¨Óªí¥Ü¡ASegment:Offset ©Òªí¥Üªº¹ê»Ú¦ì§}¬O 16D*Segment+Offset¡A¨Ò¦p°O¾ÐÅé 01AD:0021 ¨ä¹ê¬Oªí¥Ü 01ADH ­¼¥H 10H ¦A¥[¤W 0021H ªº°O¾ÐÅé¡Aµ¥©ó 1AF1H ªº¦ì§}¡C¥Î Segment:Offset ³oºØªí¥Ü¦ì§}ªº¤èªk´N¥s¡y¤À¬q¦ì§}¡z¡A­Y¬Oª½±µ¥Î 20 ¦ì¤¸ªº¤Q¤»¶i¦ì¼Æ¨Óªí¥Ü¦ì§}ªº¤èªk´N¥s¡yµ´¹ï¦ì§}¡z©Î¡y½u©Ê¦ì§}¡z¡C½Ð¬Ý¤U¹Ï¡G

¥ô¦ó¤@­Ó¦ì§}¥Îµ´¹ï¦ì§}¨Óªí¥Ü¡A¥u¦³¤@ºØªí¥Üªk¡F¦ý¬O¥Î¤À¬q¦ì§}¡A·|¦³³\¦hºØªí¥Üªk¡C¨Ò¦p¤W­z 01AD:0021 ©M 01AE:0011¡B01AF:0001 ³£¬O¦P¤@µ´¹ï¦ì§} 1AF1H¡C¦P®É±z¥i¥Hµo²{¡A°Ï¬q¦ì§}¨C´î¤@¡A°¾²¾¦ì§}±o¥[ 10H¡C

ÁöµM¥H²{¦b²´¥ú¨Ó¬Ý¡A²{¦b¹q¸£¦Ü¤Ö¤]¦³ 64MB ªº°O¾ÐÅé¡A128MB ªº¤]¤£¦b¤Ö¼Æ¡A1MB ªº°O¾ÐÅé«D±`¤p¡C¦ý¬O¦b¨º­Ó¦~¥N¡A1MB ªº°O¾ÐÅé¤w¸g«Ü¤j¤F¡A¤j¦h¼Æªº¹q¸£¥u¸Ë 640KB¡ALotus 1-2-3 ¥u­n 256KB ´N¯à¶]±o«Ü¶¶¡C


Åã¥Ü 1MB ¤ºªº°O¾ÐÅ餺®e­ì©lµ{¦¡

©³¤U¤p¤ì°¸¼¶¼g¤@­Óµ{¦¡ MEMDUMP.ASM¡A¥i¥HÅã¥Ü¥ô¦ó¦b 1MB ¥H¤º°O¾ÐÅ餺ªº¤º®e¡C³o­Óµ{¦¡·|Åã¥Ü¬Y¤@°Ï¬qªº°O¾ÐÅ餺®e¡A¥i¥H«öÁä½L¤Wªº S Áä§ïÅܰϬq¡A«ö O Áä§ïÅÜ°¾²¾¦ì§}¡A«ö Esc Áä¸õ¥Xµ{¦¡¡Q¥Î PageUp Áä©Î PageDown Áä¨ÓÅã¥Ü¤W¤@­¶©Î¤U¤@­¶ªº 140H ­Ó¦ì¤¸²Õ¡C³o­Óµ{¦¡µLªk¦b Windows XP/2K/Vista/7 ùØ°õ¦æ¡A¥u¯à¦b DOS ©Î Windows 9x/Me ¤¤ªº DOS ¼Ò¦¡°õ¦æ¡A³Ì¦n¬O±N¤u¨ã¦CªºÃö³¬¡A¤~¤£·|¦³¶Ã½X¡Q¦b MS DOS ¤Uªº­Ê¤Ñ¤¤¤å¸Ì¡A½Ð«ö¦í Ctrl¡BAlt ¨â­ÓÁ䤣©ñ¡A¦A«ö¤U­^¤å¦r¥À A Áä¡A¦b¤¤¡B­^¤å¶¡¤Á´«ÁקK¶Ã½X¡C( ¦pªG±z·Q¸Õ¸Õ¬Ý³o­Óµ{¦¡ªº¸Ü¡A±o¦b Windows XP/2K/Vista/7 ùئw¸ËÃþ¦ü Virtual PC ¤§Ãþªº DOS ¼ÒÀÀ¾¹¡A½Ð°Ñ¾\ªþ¿ý 11¡C)
;***************************************
memdump segment
        assume  cs:memdump,ds:memdump
        org     100h
;---------------------------------------
start:  jmp     begin
seg_adr dw      0           ;007
off_adr dw      0           ;008
row     db      ?           ;009
msg     db      ' Seg:Off  00 01 02 03 04 05 06 07-08 09 0A '
        db      '0B 0C 0D 0E 0F  01234567-89ABCDEF',0dh,0ah,'$'
ipt_of  db      ' Input offset address : $'
ipt_sg  db      'Input segment address : $'
begin:  call    print_msg   ;014

        mov     row,3       ;016 ¥Ñ²Ä¥|¦C¶}©l
nxt_rw: mov     ah,2        ;017 ³]©wAH¬°´å¼Ð©w¦ì
        mov     dl,0
        mov     dh,row
        mov     bh,0
        int     10h         ;021 ©I¥sINT 10H¤¤Â_
        mov     bx,seg_adr  ;022 ±N­n¦Lªº°Ï¬q©ñ¤JBX
        mov     es,bx       ;023 ³]©w°Ï¬q¡A¥H§Q©¹«á±N°O¾ÐÅ餺®e¨ú¥X
        call    print_bx_hex;024 ¦L¥X
        mov     dl,':'
        call    print
        mov     bx,off_adr
        call    print_bx_hex
        mov     dl,' '
        call    print       ;030 ¦L¥XªÅ®æ

        mov     si,off_adr
        mov     ch,10h      ;033 ¨C¦C¦L¥X16­Ó¦ì¤¸²Õ
nxt_col_0:
        mov     bl,es:[si]  ;035 ¨ú¥X°O¾ÐÅ餺®e¦s©ó BL
        call    print_bl_hex    ;036 ¦L¥X°O¾ÐÅ餺®e
        mov     dl,' '      ;037 ¦L¥XªÅ¥Õ
        mov     ax,si
        and     al,0fh      ;038 Àˬd¬O­n¦LªÅ¥Õ©Î¡y-¡z
        cmp     al,7
        jne     pnt_sp      ;041 ­Y¬OAL=7­n¦L¥X¡y-¡z
        mov     dl,'-'      ;042 ¦L¥X¡y-¡z
pnt_sp: call    print       ;043 ¦L¥X
        inc     si          ;044 «ü¦V¤U¤@­Ó¦ì§}
        dec     ch          ;045 Àˬd¬O§_¤w¦L§¹16­Ó¦ì¤¸²Õ¤F¡H
        jnz     nxt_col_0

        mov     dl,' '      ;048 °O¾ÐÅ骺¤º®e¤w¦L§¹¡A¦L¥XASCII¦r¤¸
        call    print
        mov     si,off_adr  ;050 ­n¦L¥XASCII¦r¤¸¡A¬G­«·s¨ú¦^°¾²¾¦ì§}
        mov     ch,10h
nxt_col_1:                  ;052 §PÂ_­n¤£­n¦L¡y-¡z
        mov     ax,si
        and     al,0fh
        cmp     al,8
        jne     nt_pnt
        mov     dl,'-'
        call    print
nt_pnt: mov     dl,es:[si]  ;059 ¨ú¥X°O¾ÐÅé
        cmp     dl,' '      ;060 ­YASCII½X¤p©ó1Fh¡A«h¦L¥XªÅ¥Õ
        jae     ok_pnt
        mov     dl,' '
ok_pnt: call    print
        inc     si
        dec     ch          ;065 Àˬd¬O§_¤w¦L§¹16­ÓASCII¦r¤¸¤F¡H
        jnz     nxt_col_1

        inc     row
        mov     off_adr,si  ;069 «ü¦V¤U¤@­Ó16¦ì¤¸²Õ°O¾ÐÅ骺«eºÝ
        cmp     row,23      ;070 ¬O§_¤w¦L§¹¤@­¶¡H
        jnz     nxt_rw
press_key:                  ;072 ¤w¦L§¹¤@­¶¡Aµ¥¨Ï¥ÎªÌ«öÁä
        mov     ah,0
        int     16h
        cmp     ah,01h
        je      esc_key     ;076 «ö¤UEscÁä
        cmp     ah,1fh
        je      s_key       ;078 «ö¤USÁä
        cmp     ah,18h
        je      o_key       ;080 «ö¤UOÁä
        cmp     ah,49h
        je      pgup        ;082 «ö¤UPgUpÁä
        cmp     ah,51h
        jne     press_key

pgdn:   jmp     begin       ;086 «ö¤UPgDnÁä

pgup:   sub     off_adr,140h*2
        jmp     begin

s_key:  mov     cx,offset ipt_sg
        call    input
        mov     seg_adr,bx
        sub     off_adr,140h
        jmp     begin

o_key:  mov     cx,offset ipt_of
        call    input
        and     bx,0fff0h
        mov     off_adr,bx
        jmp     begin

esc_key:
        mov     ax,4c00h
        int     21h         ;105 µ²§ôµ{¦¡ªð¦^DOS
;---------------------------------------
print_msg       proc    near
        mov     ah,2
        mov     dx,100h
        mov     bh,0
        int     10h
        mov     dx,offset msg
        mov     ah,9
        int     21h
        mov     cx,76       ;115 115¨ì116ªº¥Øªº¬O
next_c: mov     dl,0cdh     ;116 ¦L¥X²Ä2¦CªºÂù¾î½u
        mov     ah,2
        int     21h
        loop    next_c      ;119
        ret
print_msg       endp
;---------------------------------------
;¦b»È¹õ¤W¦L¥X BL ªº¤Q¤»¶i¦ì¼Æ
;¿é¤J¡GBL
print_bl_hex    proc    near
        mov     cl,4
        rol     bl,cl
        call    print_4_bits
        rol     bl,cl
        call    print_4_bits
        ret
print_bl_hex    endp
;---------------------------------------
;¥Øªº¡G¦b»È¹õ¤W¦L¥X BX ¤§¤Q¤»¶i¦ì­È
;¿é¤J¡GBX
print_bx_hex    proc    near  ;136
        mov     cl,4
        rol     bx,cl
        call    print_4_bits
        rol     bx,cl
        call    print_4_bits
        rol     bx,cl
        call    print_4_bits
        rol     bx,cl
print_4_bits:
        mov     dx,bx
        and     dl,0fh
        add     dl,30h
        cmp     dl,3ah
        jb      print
        add     dl,7
print:  mov     ah,2
        int     21h
        ret
print_bx_hex    endp
;---------------------------------------
;¥Øªº¡G¿é¤J¤@­Ó¤Q¤»¶i¦ì¼Æ
;¿é¤J¡GDX-´£¥Ü¦r¦ê
;¿é¥X¡GBX-¿é¤Jªº¤Q¤»¶i¦ì¼Æ
input   proc    near
        mov     ah,2
        mov     dx,1700h
        mov     bh,0
        int     10h
        mov     ah,9
        mov     dx,cx
        int     21h

        mov     cx,404h ;169 CH¡×4¦ì16¶i¦ì¼Æ
        sub     bx,bx
next:   mov     ah,0
        int     16h     ;172 ©I¥sBIOSÁä½LªA°Èµ{¦¡
        cmp     al,0dh  ;173 ­Y¿é¤JEnterÁäªí¥Ü­n¿é¤J§¹¦¨
        je      ok1
        mov     dl,al   ;175 ±N¿é¤JªºASCII½X¦s¤JDL¥H§Q¦L¦b¿Ã¹õ¤W
        cmp     al,'0'  ;176 Àˬd¿é¤JªºASCII½X¬O§_¬°ªü©Ô§B¼Æ¦r
        jb      next
        cmp     al,'9'
        ja      alpha   ;179 ­Y§_¡A«hÀˬd¬O§_¬°A¨ìFªº­^¤å¦r
        sub     al,'0'  ;180 ´î¥h30h¡A¥H±o¨ì¤Q¤»¶i¦ì¼Æ
        jmp     short ok0
alpha:  and     al,0dfh ;182
        mov     dl,al
        sub     al,37h  ;184 Àˬd¬O§_¬°A¨ìFªº­^¤å¦r
        cmp     al,0ah
        jb      next
        cmp     al,0fh
        ja      next    ;188

ok0:    push    ax      ;190
        call    print   ;191 ¦b¿Ã¹õ¤W¦L¥X¿é¤Jªº¦r
        pop     ax
        shl     bx,cl   ;193 ±NBX­¼¥H16d
        cbw
        add     bx,ax   ;196 ¨ÏBX¥[¤W¿é¤Jªº16¶i¦ì¼Æ
        dec     ch      ;197 Àˬd¬O§_¶W¹L4¦ì¤Q¤»¶i¦ì¼Æ
        jz      ok1
        mov     dh,bh   ;199 Àˬd¬O§_¶W¹LBX®e¶q
        and     dh,0f0h
        jz      next    ;201 ¨S¶W¹L

ok1:    push    bx      ;203
        mov     ah,2
        mov     dx,1700h
        mov     bh,0
        int     10h
        pop     bx
        mov     cx,57   ;209 209¨ì213ªº¥Øªº¬O·í¿é¤J§¹
ok2:    mov     ah,2    ;210 ¦¨«á¡A²M°£¿Ã¹õ¤W²Ä23¦æªº¦r
        mov     dl,' '
        int     21h
        loop    ok2     ;213
        ret
input   endp
;---------------------------------------
memdump ends
;***************************************
        end     start

µ{¦¡³W¹º

³o­Óµ{¦¡ºâ¬O¤ñ¸û¤jªºµ{¦¡¤F¡A¦b¼g¤ñ¸û¤jªºµ{¦¡¤§«e¡AÀ³¥ý³W¹º¦n¡A¤~¤£·|µ¹¤H­â¶Ãªº·Pı¡A¥H­PÅý¤é«áºûÅ@µ{¦¡®Éªá¶O³\¦h®É¶¡¡C

¦p¦ó³W¹º

­n³W¹ºµ{¦¡·íµM­n¥ýª¾¹Dµ{¦¡¦³¤°»ò¥\¯à¡A°õ¦æ®É¦³¤°»òµe­±¡H©Ò¥H§Ú­Ì¥ý¬Ý¬Ý°õ¦æªº±¡§Î¡G

¦b¤W¹Ï¤¤¡A©M DEBUG ¤¤ D «ü¥Oªºµe­±¤@¼Ë¡A¤j­P¥i¤À¬°¤T³¡¥÷¡A³Ì¥ªÃä¬O¦ì§}¦ì§}¬O¥H¤À¬q©w§}¤è¦¡ªí¥Ü¡A°Ï¬q¦ì§}»P°¾²¾¦ì§}³£¬O¤Q¤»¦ì¤¸¡C¤¤¶¡¬O°O¾ÐÅ餺®e¡A¥H¨C¦C¤Q¤»­Ó¦ì¤¸²Õ¦C¥X¡A¨C­Ó¦ì¤¸²Õ³£¬O 8 ¦ì¤¸¡C³Ì¥kÃä¬O¨C­Ó¦ì¤¸²Õ¹ïÀ³ªº ASCII ¦r¤¸¡C

«Ü©úÅã¨C¤@¦C³£¬O¦C¥X 16 ­Ó¦ì¤¸²Õªº¸ê®Æ¡A¦Ó¨C¦Cªº¤U­±¤@¦C³£¤ñ¤W­±¤@¦Cªº°O¾ÐÅé¦ì§}¦h 16¡A¦Ó¥BÅã¥Ü¤è¦¡¤£ºÞ¬O¦ì§}¡B°O¾ÐÅ餺®e©Î ASCII ¦r¤¸¨C¤@¦C³£¬Û¦P¡C©Ò¥H¦pªG¯à¼g¥XÅã¥Ü¤@¦Cªºµ{¦¡¡A¦Ó¨ä¥L¦C´N¨Ì¼Ëµe¸¬Äª¡A«Ü§Ö´N¥i¥H§¹¦¨¦¹µ{¦¡¤F¡C¦Ó¨C¤@¦Cªº®t§O¥u¬O¤U­±¤@¦Cªº¦ì§}¤ñ¤W­±¤@¦Cªº¦ì§}¦h 16D¡C©Ò¥H¤p¤ì°¸³]¤@­ÓÅÜ¼Æ off_adr(offset address ¤§·N)¡A¥Nªí¨C¦C³Ì§Cªº°¾²¾¦ì§}¡C

¨C¤@¦C³Ì¥ªÃ䥲¶·­n¦L¥X¨â­Ó 16 ¦ì¤¸ªº¤º®e¡A¤p¤ì°¸´N±N­n¦L¥Xªº¤º®e¦s©ñ¦b BX¡AµM«á©I¥s print_bx_hex °Æµ{¦¡§Y¥i¡C¤¤¶¡¥²¶·¦L¥X 16 ­Ó 8 ¦ì¤¸ªº¤º®e¡A¤p¤ì°¸±N¥¦¦s©ñ¦b BL ¤¤©I¥s print_bl_hex °Æµ{¦¡¦L¥X¡A¦Ó¥B­n­«½Æ 16 ¦¸¡A¨C¦¸°¾²¾¦ì§}³£¼W¥[¤@¡A¬°¨¾¤î§ïÅÜ off_adr ¤§­È¡A©Ò¥H¥Î SI §@¬°«ü¼Ð¥N´À off_adr¡C

¨ä¥L²Ó¸`

¦pªG¨Ï¥ÎªÌ«ö¤U PgDn Á䪺¸Ü¡Aµ{¦¡´N±oÅã¥Ü¤U¤@­¶ 140h ­Ó¦ì¤¸²Õ¡A³o 140h ­Ó¦ì¤¸²Õªº²Ä¤@¦C¤ñ«e¤@­¶ªº³Ì«á¤@­¶¦h 10h¡A¦]¦¹¥u»Ý±N off_adr ¦A¼W¥[ 10h ¡A¦ý¬O¦b³B²z§¹¤F«e¤@­¶®É´N¤w¸g¥[ 10h ¤F¡A©Ò¥H¤£¥Î¦A¥[ 10h¡C

¦ý¬O¦pªG¨Ï¥ÎªÌ«ö¤U PgUp Áä®É¡A´N±oÅã¥Ü¤W¤@­¶¡A¦Ó¦¹®É off_adr «o«ü¦V¤U¤@­¶ªº²Ä¤@­Ó¦ì¤¸²Õ¡A©Ò¥H off_adr ­n´î¥h 140h ªº¨â­¿¡C

¦pªG¨Ï¥ÎªÌ«ö¤U S Áä©Î O Áä¡Aµ{¦¡±oÅý¨Ï¥ÎªÌ¿é¤J¤@­Ó¤Q¤»¦ì¤¸ªº¼Æ¦r¡A¤À§O§ïÅܰϬq¦ì§}©M°¾²¾¦ì§}¡A¦Ó°Ï¬q¦ì§}©M°¾²¾¦ì§}¤À§O¦s¤J seg_adr ©M off_adr¡C¦Ü©ó¦p¦ó¿é¤J¤Q¤»¦ì¤¸ªº¼Æ¦r¡A½Ð°Ñ¦Ò¤W¤@³¹¡C


·sªº«ü¥O»PªA°È¤¤Â_

INT 10H/AH=2 ¤¤Â_

INT 10H ³o­Ó¤¤Â_ªA°Èµ{¦¡¬O¥D¾÷ªO¤Wªº BIOS ´£¨Ñªº¡A¥D­n¥Î³~¬O´£¨Ñ¿Ã¹õªºªA°Èµ{¦¡¡A©Ò­nªºªA°È©ñ¦b AH ¼È¦s¾¹¤¤¡C³o¨ÇªA°È¥]§t³]©wÅã¥Ü¼Ò¦¡¡B³]©w´å¼Ð¤j¤p¡B³]©w´å¼Ð¦ì¸mµ¥µ¥¡C

¦b³o­Óµ{¦¡¸Ì¡A¤p¤ì°¸¨Ï¥Îªº¬O±N´å¼Ð©T©w¦b¦b¿Ã¹õªº¬Y­Ó¦ì¸m¡A³o®É AH ¥²¶·³]¬° 2¡Aªí¥Ü§Ú­n BIOS ªA°Èµ{¦¡À°§Ú³]©w´å¼Ð¦ì¸m¡A¦Ó BH ¼È¦s¾¹¥²¶·©ñ¿Ã¹õ­¶¡A¤@¯ë³£³]¬°¹s¡ADL¡BDH ¤À§O¦s©ñ¿Ã¹õªº¦æ»P¦C¡C

¦b DOS ¼Ò¦¡¤U¡A¥Ñ¥ª¦Ó¥kºÙ¬°¦C¡A¨C¤@¦C¥Ñ³Ì¥ªÃä¶}©l½s¸¹¬°¹s¡A¤@ª½¨ì³Ì¥kÃä½s¸¹ 79¡A¨C¤@¦C³Ì¦hÁ`¦@¥i¥HÅã¥Ü 80 ­Ó­^¤å¦r¡C¥Ñ¤W¦Ó¤UºÙ¬°¦æ¡A¨C¤@¦æ¤]¬O±q½s¸¹¹s¶}©l¡A¤@ª½¨ì 24¡A³Ì¦h¥i¥HÅã¥Ü 25 ­Ó¦r¡C³o­Óµ{¦¡ªº

        mov     row,3       ;016 ¥Ñ²Ä¥|¦C¶}©l
nxt_rw: mov     ah,2        ;017 ³]©wAH¬°´å¼Ð©w¦ì
        mov     dl,0
        mov     dh,row
        mov     bh,0
        int     10h         ;021 ©I¥sINT 10H¤¤Â_
¤ù¬q´N¬O³]©w´å¼Ð¦b¿Ã¹õªº²Ä¹s¦æ²Ä¤T¦C¡C½Ð°Ñ¦Ò¤U¹Ï»¡©ú¡G
»¡©ú¿Ã¹õ¦æ¦CÃö«Y

ª½±µ©w§}»P¼È¦s¾¹¶¡±µ©w§}

±µ¤U¨ÓÁÙ¦³¤@­Ó¤j°ÝÃD­n¸Ñ¨M¡A´N¬O¦p¦ó¨ú±o°O¾ÐÅ骺¤º®e¡C§A¥i¥H·Q¹³¡G¦pªG§A­n¨ì¤@­Ó§A¤£¼ô±xªº¦a¤è§ä§AªB¤Í¡A¦Ó§A±oª¾¹D§AªB¤Í¦í¦b¨º¸Ì¡A©Î¬O»¡§A±oª¾¹D§AªB¤Íªº¦a§}¡A§A¤~¯à§ä¨ì¡C

¦b¹q¸£¤¤¤]¬O¤@¼Ë¡A¦pªG­n¥Ñ°O¾ÐÅé¨ú±o¨ä¤º®e¡A¥²¶·­n§i¶D¹q¸£­n¨ú±o¨º¤@­Ó°O¾ÐÅ骺¤º®e¤~¦æ¡A³o¡y¨º¤@­Ó°O¾ÐÅé¡z¥Î³N»y¨Ó»¡´N¬O°O¾ÐÅ骺¡y¦ì§}¡z¡C

¨Æ¹ê¤W¡A§Ú­Ì¦b«e­±´X³¹¤w¸g¥Î¹L³o­ÓÆ[©À¤F¡A·í§Ú­Ì©w¸q¤@­ÓÅܼƮɡA´N¬O§i¶D²ÕĶ¾¹­n«O¯d¤@­Ó¦ì§}µ¹³o­ÓÅܼơAµM«á²ÕĶ¾¹·|¥Î³o­Ó¦ì§}¥N´À­ì©lÀɤ¤ªºÅܼƦWºÙ¡C©Ò¥H·íµ{¦¡¤¤­n¦s¨ú³o­ÓÅܼƮɡA¨Æ¹ê¤W¬O¨ì¸Ó¦ì§}¥h¦s¨ú¡C³oºØ¤èªkºÙ¬°¡yª½±µ©w§}¡z¡C

¦ý¬O¦b³o­Óµ{¦¡¸Ì¡A¦]¬°§Ú­Ì­nÅã¥Ü¥ô¦ó¤@­Ó°O¾ÐÅ骺¤º®e¡A©Ò¥H¦s¨úªº¦ì§}·|¤@ª½§ïÅÜ¡A§Ú­Ì´NµLªk¥Î¤W­±ªº¤èªk¡A©¯¦n²Õ¦X»y¨¥´£¨Ñ¤F¥t¤@ºØ¦s¨ú°O¾ÐÅ骺¤èªk¡AºÙ¬°¡y¼È¦s¾¹¶¡±µ©w§}¡z¡A¨Ò¦pµ{¦¡¤¤ªº

        mov     bl,es:[si]  ;035 ¨ú¥X°O¾ÐÅ餺®e¦s©ó BL
		................................
nt_pnt: mov     dl,es:[si]  ;059 ¨ú¥X°O¾ÐÅé
´N¬OÄÝ©ó³oÃþ©w§}¤è¦¡¡C

¥H²Ä¤T¤Q¤­¦æ¬°¨Ò¡A³o¤@¦æ¬O§â ES:SI ©Ò«ü¦ì§}ªº¤º®e¨ú¥X¡A¦s©ñ©ó BL¡A¦³ÂI½ÆÂø¬O§a¡H¨SÃö«Y¡A¨C­Ó¾Ç²ß²Õ¦X»y¨¥ªº¤H³£­nªá¤@¨Ç®É¶¡¨Ó¼ô±x¥¦¡C¥ý°²³]¡A¦pªG¦b DEBUG ¸Ì¿é¤J¤U­±¶À¦âªº«ü¥O¡G

-d 0:0 [Enter]
0000:0000  9E 01 00 00 00 04 70 00-16 00 FC 07 65 04 70 00  ......p...|.e.p.
­Y¦¹®É ES ¬°¹s¡A¦Ó SI ¬° 0¡A«h°õ¦æ²Ä 35 ¦æ«ü¥O®É¡ACPU ·|¨ì 0000:0000(´N¬O ES:SI ©Ò«üªº¦ì§}) ¥h§ä¡Aµ²ªG¸Ó¦ì§}ªº¤º®e¬O 9EH¡A©Ò¥H´N·|§â 9EH ¦s¤J BL ¤¤¡C

¦pªG²{¦b SI Åܦ¨ 1 ®É¡ABL ´N·|Åܦ¨ 01H¡C­Y SI ¬° 2 ®É¡ABL ´N·|Åܦ¨ 00H¡C¥i¥H¥Î¤U¹Ï»¡©ú¡G

©Ò¥H¥u­n¨Ï SI ¥Ñ 0000 »¼¼W¨ì 0FFFFH¡A´N¥i¥H¦s¨ú¾ã­Ó°Ï¬qªº¤º®e¡C¦pªG­n¦s¨ú¨ä¥L°Ï¬q¡A¥u»Ý§ïÅÜ ES ­È§Y¥i¡C

Á`¨¥¦Ó¤§¡A¼È¦s¾¹¶¡±µ©w§}¬O§â°O¾ÐÅé¦ì§}©ñ¤J¬Y­Ó¼È¦s¾¹¸Ì¡A¨Ã¥Î¤¤¬A©·±N¼È¦s¾¹¬A©·°_¨Ó¡A´N¯à¨ú±o¼È¦s¾¹¤º®e©Ò«üªº°O¾ÐÅé¼Æ­È¡A¦Ó«D¼È¦s¾¹ªº¤º®e¡C¥i¥H¥Î¨Ó§@¬°¼È¦s¾¹¶¡±µ©w§}ªº¼È¦s¾¹¦³ BX¡BSI¡BDI¡BSP ¥|­Ó¡A¤@¯ë¦Ó¨¥¦pªG¼g¦¨¹³¤U­±ªºµ{¦¡¤ù¬q¡G

        mov     dh,[bx]
        mov     dl,[si]
CPU ·|¨ì DS ©Ò«üªº°Ï¬q§ä BX¡BSI ¤ºªº°O¾ÐÅé¦ì§}©Ò§tªº¤º®e¡F¦pªG¥Î DI §@¬°¼È¦s¾¹¶¡±µ©w§}ªº¼È¦s¾¹¡A«h CPU ·|¨ì ES ©Ò«üªº°Ï¬q¥h§ä¡F­Y¬O¥Î SP ªº¸Ü¡ACPU ·|¨ì SS ¥h§ä¡A³o¨Ç¬O¤º©wªº(©Î¬OºÙÁô§tªº)¡C·íµM¤]¥i¥H§ïÅÜ¡A´N¬O¦b¤¤¬A©·«e­±¥[¤W­n´M§äªº°Ï¬q¡C©ó¬O´NÅܦ¨µ{¦¡¤¤ªº²Ä 35¡B59 ¦æ¤F¡C

·sªº«ü¥O DEC

²Ä45¦æ«ü¥O DEC ¬O¨Ï«á­±ªºÅܼƩμȦs¾¹¤§­È´î¤@¡AÅܼƩμȦs¾¹¥i¥H¬O8¦ì¤¸©Î16¦ì¤¸¡C¦pªG¸g¹L´î¤@«á¡A¼È¦s¾¹©ÎÅܼƤ§­ÈÅܬ°¹s®É¡A¹s¨ä¼Ð·|³Q³]¬°1¡A©Ò¥H¤U¤@¦æ¥i¥Hª½±µÀˬd¹Bºâµ²ªG¬O§_¬°¹s¡A¨Ó¨M©w­n¤£­n¸õÅD¡C¥Îªk¦p¤U¡G
dec     ¼È¦s¾¹
dec     ÅܼÆ

·sªº«ü¥O ROL/ROR

²Ä127¦æ«ü¥O ROL ¬O±ÛÂà«ü¥O¡A¥¦©M SHL «ü¥O«Ü¬Û¹³¡A®t§O¬O¦b SHL ¬O¦V¥ª²¾¦ì«ü¥O¡A­ì¨Ó³Ì¥ªÃ䪺¦ì¤¸·|³Q²¾¥X¼È¦s¾¹¦Ó®ø¥¢¤£¨£¡A³Ì¥kÃä·|¶ñ¶i0¡Q¦Ó ROL ³Ì¥ªÃ䪺¦ì¤¸·|³Q²¾¨ì³Ì¥kÃä¡A­«·s¶ñ¶i¼È¦s¾¹¤º¡C¦p¤U¹Ï¡G

ROR ¬O¦V¥k±ÛÂà¡CROL¡BROR ¥Îªk¦p¤U¡G

ROL     ¼È¦s¾¹
ROL     ÅܼÆ
ROR     ¼È¦s¾¹
ROR     ÅܼÆ


µù¤@¡G¤@¯ë¬ì¾Ç¤W¡A¤d¡B¦Ê¸Uªº¼Æ¶q¤À§O¬O 103¡B106 ªº·N«ä¡A±`±`¥Î K¡BM ¤À§Oªí¥Ü¤d¡B¦Ê¸U¡C¦ý¬O¦b¹q¸£¤W K¡BM ±`±`¬O¥Nªí 210¡B220 ªº·N«ä¡A210=1024 ¦Ó 220=1048576 ³£«Ü±µªñ¤@¤d¡B¤@¦Ê¸U¡C


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