Ch 13 BCD ¼Æ(1)¡GBCD ²¤¶


BCD ·§©À

«e­±ªº´X³¹ùØ¡A½Í¨ì¤Q¤»¶i¦ì¼Æ¤Î¤G¶i¦ì¼Æ¡A¦b³o¤@³¹ùØ¡A¤p¤ì°¸·Q½Í½Í BCD ¼Æ¡C¦ó¿× BCD ¼Æ©O¡H§Ú­Ì¤w¸gª¾¹D 4 ­Ó¦ì¤¸³Ì¦h¥i¥Hªí¥Ü 16 ­Ó¼Æ¦r¡A­Y¥H¤Q¤»¶i¦ìªí¥Ü¥i¥H¥Ñ 00H ¨ì 0FH¡A¥H¤Q¶i¦ìªí¥Ü¥i¥H¥Ñ 00D ¨ì 15D¡A¦Ó BCD ¼Æ«h¬O¥u¥Î¨ì«e­±ªº 10 ­Ó¼Æ¨Óªí¥Ü¤Q¶i¦ì¡A¤]´N¬O»¡ BCD ¼Æ¤¤¤£¥i¯à¦³ 0A¡B0B¡B0C µ¥­^¤å¦r¥X²{¡C

BCD ¼Æªº­^¤å¬O binary-coded decimal¡A´N¦r­±¤W·N¸q§Y¬°¡y¤G¶i¦ì½s½Xªº¤Q¶i¦ì¼Æ¡z¡A·N«ä´N¬O¥H 4 ­Ó¦ì¤¸ªº¤è¦¡¨Óªí¥Ü¤Q¶i¦ì¡A¦]¦¹¦³³\¦hªÅ¶¡¬O®ö¶O±¼¤F¡A¦ý¬O«o¥i¥H§Q¥Î§Ú­Ì¹ï¤Q¶i¦ìªº¼ô±x¡A«Ü¤è«Kªº½s¼gµ{¦¡¡C¤@¯ë¦Ó¨¥¡ABCD ¼Æ¥i¥H¤À¦¨¨âºØ¡A»E¶°ªº BCD ¼Æ (packed BCD) ©M«D»E¶°ªº BCD ¼Æ (unpacked BCD)¡C

Áö¸g¤W­z»¡©ú BCD ¼Æªº·N¸q¡A¦ý¬Û«HÁÙ¬O¦³³\¦h¤H¤£À´¡AÅý¤p¤ì°¸Á|­Ó¨Ò¤l§a¡C¨Ò¦p§A¦b DEBUG ¤¤¿é¤J AX ¼È¦s¾¹ªº¼Æ­È¬° 0908¡A¥H«D»E¶° BCD ¼Æ¨Ó¬Ýªí¥Ü¬O¤Q¶i¦ìªº 98¡A­Y¬O¥H»E¶° BCD ¼Æ¨Ó¬Ý¬Oªí¥Ü¤Q¶i¦ìªº 908¡Q¦pªG¬O¥H¤Q¤»¶i¦ì¨Ó¬Ý¬Oªí¥Ü¤Q¶i¦ìªº 2312¡C³o¼Ë»¡§A¥i¯à·|³Q·d½k¶î¤F¡A«e­±¤£¬O»¡ AX ¤ºªº¼Æ­È¬°¤Q¤»¶i¦ì¶Ü¡H«ç»ò¤@¤UÅÜ 98 ¡A¤@¤UÅÜ 908¡A¤@¤U¤SÅܦ¨ 2312 ©O¡H¨ä¹ê³o§¹¥þ¬O¬Ýµ{¦¡³]­p®v©Ò¼gªºµ{¦¡¦p¦ó¥h¸ÑÄÀ AX ¤ºªº¼Æ­È¡C

·íµ{¦¡¥HÃþ¦ü²Ä¤C©Î²Ä¤K³¹ªº¤è¦¡±N AX ¼È¦s¾¹ªº¼Æ­È¦L¥X¨Ó®É¡AAX ªº¼Æ­È©úÅã¬O¤Q¤»¶i¦ì¼Æ¦r¡C¦ý¬O¦pªGµ{¦¡¥H¤U­±ªº¤ù¬q¦C¦L¥X¨Ó¡A§A²q²q¬Ý¦b¿Ã¹õ¤W·|Åã¥Ü¤°»ò¼Æ¦r¡H¦b DEBUG ¤º¡A¥H A «ü¥O¿é¤J¤U­±µ{¦¡¤ù¬q¡G(¶À¦â¬O±z­n¿é¤Jªº¦r¡Aºñ¦â¬O BEBUG Åã¥Üªº¦r¡A[Enter]¬Oªí¥Ü«ö¤U Enter Áä)¡C

C:\WINDOWS\COMMAND>debug [Enter]
-a [Enter]
1C6C:0100 mov ax,908 [Enter]
1C6C:0103 mov dl,ah [Enter]
1C6C:0105 add dl,30 [Enter]
1C6C:0107 push ax [Enter]
1C6C:0108 mov ah,2 [Enter]
1C6C:010A int 21 [Enter]
1C6C:010C pop ax [Enter]
1C6C:010D mov dl,al [Enter]
1C6C:010F add dl,30 [Enter]
1C6C:0112 mov ah,2 [Enter]
1C6C:0114 int 21 [Enter]
1C6C:0116 [Enter]
-g 116 [Enter]
98

ÁöµM AX ¤§­È¬° 908¡A¦ý¬O§Ú­Ì¤]¥i¥H§â¥¦¬Ý¦¨¬O 98¡A¦Ó¥BÅã¥Ü¦¨ 98¡A¦¹®É AX ¤§¼Æ­È¬°«D»E¶°ªº BCD ¼Æ¡C·íµM§A¤]¥i¥H§â¥¦Åã¥Ü¦¨ 908¡A¦¹®É AX ¼Æ­È¬°»E¶°ªº BCD ¼Æ¡C©Î¬O¹³²Ä¤C¡N²Ä¤K³¹ªº¤è¦¡Åã¥Ü¦¨ 2312¡A³o®É AX ¤§¼Æ­È¬O¤Q¤»¶i¦ì¼Æ¡C©Ò¥H¤p¤ì°¸»¡¡A¦b¹q¸£¤¤ªº¼Æ­È¬OÀHµ{¦¡¸ÑÄÀ¦Ó¤£¦P¡C

­Y§Ú­Ì¥Î ADD¡NSUB¡NMUL¡NDIV µ¥ 80X86 «ü¥O¶°°µ¹Bºâ¡ACPU ·|¦Û°Êªº§â ©Ò¥Î¨ìªº¹Bºâ¤¸ (¼Æ­È) ·í§@¤Q¤»¶i¦ì¡C¦pªG§Ú­Ì­n§â³o¨Ç¼Æ­È·í§@ BCD ¼Æ¡A¦³¨âºØ¤èªk¥i¥H¹F¦¨¡A¤@ºØ¬O¥t¥~«Ø¥ß·sªº«ü¥O±M§@ BCD ¼Æªº¹Bºâ¡F¥t¥~¤@ºØ¤èªk¬O¥ý§â¥L­Ì·í§@¤Q¤»¶i¦ì¡A¹Bºâ«á¦pªG¶W¹L¤E¡A¦A°µ½Õ¾ã¡C¦Ó 80X86 CPU ¬O±Ä¥Î«áªÌ¡C

80X86 ¦b°µ BCD ¼Æ­È¹Bºâ®É¡A¥²©w¥Î AL §@¬°½Õ¾ãªº¹ï¶H¡A¦]¦¹¥²©w¥Î AL ·í§@¨ä¤¤ªº¤@­Ó¹Bºâ¤¸¡CÁ|¨Ò¨Ó»¡¨Ò¦p·Q§@ 8+7 ªº«D»E¶° BCD ¹Bºâ¡A³Ì«á¦b AL ¼È¦s¾¹À³¸Ó·|±o¨ì 0105 ³o­Ó¼Æ¡A¤p¤ì°¸¥Î DEBUG ¨Ó»¡©ú¡G

C:\WINDOWS\COMMAND>debug [Enter]
-a [Enter]
1C6C:0100 mov al,8 [Enter]
1C6C:0102 add al,7 [Enter]
1C6C:0104 aaa [Enter]
1C6C:0105 [Enter]
-t [Enter]

AX=0008  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=1C6C  ES=1C6C  SS=1C6C  CS=1C6C  IP=0102   NV UP EI PL NZ NA PO NC
1C6C:0102 0407          ADD     AL,07
-t [Enter]

AX=000F  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=1C6C  ES=1C6C  SS=1C6C  CS=1C6C  IP=0104   NV UP EI PL NZ NA PE NC
1C6C:0104 37            AAA
-t [Enter]

AX=0105  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=1C6C  ES=1C6C  SS=1C6C  CS=1C6C  IP=0105   NV UP EI PL NZ AC PO CY
1C6C:0105 0475          ADD     AL,75
-

¦b¦ì§} 1C6C:0100 ±N 8 ¦s¤J AL ¼È¦s¾¹¡A¤U¤@­Ó«ü¥O¬O§â 7 ¥[¨ì AL ¼È¦s¾¹¤º¡A§¹¦¨«á¡A¬Ý¨ì AX ¼È¦s¾¹¬O 000F(¬õ¦â¦r)¡A³o¬O²z©Ò·íµMªº¡A¦]¬° ADD «ü¥O¥»¨Ó´N¬O±N³o¨Ç¼Æ¦r·í§@¤Q¤»¶i¦ì¨Ó¬Ý¡C¦A¤U¤@¦æ¬O AAA «ü¥O¡A³o¤@­Ó«ü¥O´N¬O§â AL ¤ºªº¤Q¤»¶i¦ì¼Æ°µ¾A·íªº½Õ¾ã¡A¨Ï¨äÅܬ°«D»E¶°ªº BCD ¼Æ¡CAAA ³o­Ó«ü¥O·|Àˬd AL ¬O§_¶W¹L 9¡A¦pªG¬Oªº¸Ü´N·|²£¥Í¶i¦ì¡A¨Ï AH ¬°¤@¡A¨Ã¨Ï AL ¼È¦s¾¹´î 0AH¡A©Ò¥H·í AAA «ü¥Oµ²§ô«á¡AAX ¤§¤º®e¨Ã«D 000F ¤Ï¦Ó¬O 0105¡C

AAA ³o­Ó 80X86 ªº«ü¥O¡A´N¬O¦b°µ§¹¥[ªk«á±N AL ¤§¤º®e½Õ¾ã¦¨«D»E¶°ªº BCD ¼Æ¡A¦]¨ä¥[¤W 3030h «Ü§Ö´NÅܦ¨ ASCII ¼Æ¦r´N¥i¦L¦b¿Ã¹õ¤W¡AAAA ³o¤T­Ó¦r¥À¬O ASCII adjust for addition ¤§·N¡C°²¦p­n±N¨ä½Õ¾ã¦¨»E¶°ªº BCD ¼Æ¡A¹Lµ{¬Û¦P¡A¥u¬O±N AAA «ü¥O´«¦¨ DAA «ü¥O¡A¨ä·N¸q¬°decimal adjust for addition¡A½Ð¬Ý¤U­± DEBUG ¤§¨Ò¤l¡C

C:\WINDOWS\COMMAND>debug [Enter]
-a [Enter]
1C6C:0100 mov al,8 [Enter]
1C6C:0102 add al,7 [Enter]
1C6C:0104 daa [Enter]
1C6C:0105 [Enter]
-t [Enter]

AX=0008  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=1C6C  ES=1C6C  SS=1C6C  CS=1C6C  IP=0102   NV UP EI PL NZ NA PO NC
1C6C:0102 0407          ADD     AL,07
-t [Enter]

AX=000F  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=1C6C  ES=1C6C  SS=1C6C  CS=1C6C  IP=0104   NV UP EI PL NZ NA PE NC
1C6C:0104 27            DAA
-t [Enter]

AX=0015  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=1C6C  ES=1C6C  SS=1C6C  CS=1C6C  IP=0105   NV UP EI PL NZ AC PO NC
1C6C:0105 0475          ADD     AL,75

¨ä¥Lªº¥|«h¹Bºâ¡A¤]³£Ãþ¦ü¡A´îªk½Õ¾ã¦¨«D»E¶° BCD ¼Æªº«ü¥O¬° AAS(ASCII adjust for subtraction ) ¡A½Õ¾ã¦¨»E¶° BCD ¼Æªº«ü¥O¬° DAS(decimal adjust for subtraction)¡C­¼°£ªk¥u¦³½Õ¾ã¦¨«D»E¶° BCD ¼Æªº«ü¥O¡A¤À§O¬O AAM ©M AAD (ASCII adjust for multuply ©M ASCII adjust for division )¡C¤p¤ì°¸±N¤§¾ã²z¦¨¤Uªí¡G

¥[ªk´îªk­¼ªk°£ªk
«D»E¶°½Õ¾ãAAAAASAAMAAD
»E¶°½Õ¾ãDAADAS

«D»E¶° BCD ¼Æªº¥[ªk

¤@¯ëªº­pºâ¾÷¥u¯àÅã¥Ü¬ù¤K¦ì¼Æªº¤j¤p(¤@¦ì¼Æ¬O«ü¥u¦³­Ó¦ì¼Æ¡A¤G¦ì¼Æ¬O«ü­Ó¦ì¼Æ©M¤Q¦ì¼Æ¡A¤T¦ì¼Æ¬O«ü­Ó¡B¤Q©M¦Ê¦ì¼Æ¡A¬G¤K¦ì¼Æ¯à­pºâ¦Ü¤d¸U¦ì¼Æ)¡A¦ý²{¦b¤p¤ì°¸­n¼g¤@­Óµ{¦¡¡A¯àÂX¥R¦¨¥i¥H­pºâ«Ü¤j¦ì¼Æªº¥[ªkµ{¦¡¡A¦ý¬O¦¹³B¤p¤ì°¸¥u¼g¤­¦ì¼Æ¬Û¥[ªºµ{¦¡¡C

ÁöµM 80X86 «ü¥O¥u´£¨Ñ AL ¼È¦s¾¹§@¬° BCD ¼Æ¥[ªk¹Bºâ¤§¥Î¡Aªø«×¶È¶È 8 ¦ì¤¸¦Ó¤w¡A¦ý¬O§Ú­Ì¥i¥H¤@¦¸¥u¹Bºâ¤@¦ì´N¯àºâ¥X«Ü¤j¦ì¼Æªº¥[ªk¡A´N¹³¤p¾Ç®É¥N¡A°ê¤p¦Ñ®v±Ð§Ú­Ìªºª½¦¡¥[ªk¹BºâÃþ¦ü¡C

  ³Q¥[¼Æ¡G          9 3 5 0 4
    ¥[¼Æ¡G    +     6 1 6 8 9
  ----------------------------
      ©M¡G                9 3

´N¹³¤W¦¡¤@¼Ë¡A·í§Ú­Ì¹Bºâ®É¡A¥ý¥Ñ­Ó¦ì¼Æ¶}©l¬Û¥[¡A¦pªG¦³¶i¦ì«h¤U¤@¦¸°µ¤Q¶i¦ì¼Æ¬Û¥[®É¡A­n°O±o¥[¤@¡A¥u­n­«½Æ¤W­z¨BÆJ¡A´N¯à±N¹Bºâ«Ü¤j¼Æªº¥[ªk¡C¤p¤ì°¸§â­ì©lµ{¦¡©R¦W¬°¡yBCD_ADD.ASM¡z¡A¨ä¤º®e¦p¤U¡G

digit   equ     5
;***************************************
code    segment                 ;03
        assume  cs:code,ds:code ;04
        org     100h            ;05
;---------------------------------------
main    proc    far             ;07
start:  mov     si,offset v1    ;08
        mov     cx,digit        ;09
        call    ubcd_print      ;10 ¦L¥X³Q¥[¼Æ
        mov     dl,'+'          ;11 ¦L¥X¡y+¡z¦r
        mov     ah,2
        int     21h
        mov     si,offset v2    ;14 ¦L¥X¥[¼Æ
        mov     cx,digit
        call    ubcd_print      ;16
        mov     dl,'='          ;17 ¦L¥X¡y=¡z¦r
        mov     ah,2            ;18
        int     21h             ;19

;¶}©l­pºâ
        mov     ax,offset v1    ;22
        mov     bx,offset v2
        mov     dx,offset sum
        mov     cl,digit
        mov     ch,digit
        call    ubcd_add        ;27

        mov     si,offset sum   ;29 ¦L¥X©M
        mov     cx,digit+1
        call    ubcd_print      ;31

        mov     ax,4c00h        ;33 µ²§ô
        int     21h             ;34
main    endp
;---------------------------------------
;¦b¿Ã¹õ¤W¦L¥X«D»E¶° BCD ¼Æ      ;37
;¿é¤J¡GSI¡G«ü¦V«D»E¶°BCD¼Æ¦r³Ì§C¦ì§}¡A³Ì¤j¦ì¼Æ©ó°ª¦ì§}
;      CX¡G±ý¦L¥X¤§«DBCD¼Æªº¦ì¼Æ¡A­YCX¬°¹s«h¦¹°Æµ{¦¡·|¦Û°Ê´M§ä(­nª`·N¸ê®Æ¥¿½T)
;¿é¥X¡G©Ò¦³¼È¦s¾¹§¡¤£ÅÜ
ubcd_print      proc    near
        push    ax              ;42 «O¦s¼È¦s¾¹¤§­È
        push    cx
        push    dx
        jcxz    u_pt0           ;45 §PÂ_¬O§_»Ý­n¦Û°Ê´M§äBCD³Ì°ª¦ì§}

        push    si              ;47 ¤£¶·¦Û°Ê´M§äBCD³Ì°ª¦ì§}
        add     si,cx           ;48 ¦]¬°¸Ó³Ì°ª¦ì§}§Yµ¥©óSI+CX¡A¨Ã¦s©óSI
        pop     cx
        jmp     short u_pt2     ;50

;¦Û°Ê´M§ä BCD ¤§³Ì°ª¦ì§}(¦V°ª¦ì§}³B§ä¨ì²Ä¤@­Ó¤£¬Oªü©Ô§B¼Æ¦rªº¦ì§})¨Ã¦s©óSI
u_pt0:  mov     cx,si           ;53 ±ý¦L¥X¤§BCD¼Æ¤§¦ì§}¦s©óCX
u_pt1:  cmp     byte ptr [si],0
        jb      u_pt2
        cmp     byte ptr [si],9
        ja      u_pt2
        inc     si
        jmp     u_pt1           ;59

;¶}©l¦L¥X¼Æ¦r¡A¦ý³Ì¤j¦ì¼Æ¬°¹s®É¡A0¤£¦L¥X¡CSI«ü¦V­n¦L¥XªºBCD¼Æªº¬Y¤@¦ì
u_pt2:  dec     cx              ;62 CX¤§­È¬°BCD¼Æªº³Ì§C¦ì§}´î¤@
u_pt3:  dec     si              ;63 ­Y³Ì«e­±¦ì¼Æ¬°¹s«h¤£¦L¥X
        cmp     si,cx           ;64 Àˬd¬O§_¤w¸g¬O¸Ó BCD ¼Æªº³Ì§C¦ì§}¤F
        je      u_pt5           ;65 ­Y¬O¡A«hªí¥Ü¸Ó BCD ¼Æ¬°¹s
        cmp     byte ptr [si],0
        je      u_pt3

u_pt4:  mov     dl,[si]         ;69 ¤w¸g§ä¨ì³Ì¤j¦ì¼Æ¤£¬O¹s¡A¨Ã¶}©l¦L¥X
        add     dl,'0'
        mov     ah,2
        int     21h
        dec     si
        cmp     si,cx
        jne     u_pt4           ;75

        pop     dx              ;77 ±N­ì¼Æ­È¦s¦^¼È¦s¾¹
        pop     cx
        pop     ax
        inc     si
        ret                     ;81 ªð¦^¤÷µ{¦¡

u_pt5:  inc     si              ;83 ·Q­n¦L¥XªºBCD¼Æ¬°¹s
        jmp     u_pt4
ubcd_print      endp            ;85
;---------------------------------------
;­pºâ¨â«D»E¶° BCD ¼Æ¤§¥[ªk
;¿é¤J¡GAX¡G³Q¥[¼Æ¦ì§}
;      BX¡G¥[¼Æ¦ì§}
;      DX¡G©M¦ì§}
;      CH¡G³Q¥[¼Æ¦ì¼Æ
;      CL¡G¥[¼Æ¦ì¼Æ
;¿é¥X¡G©óDI©Ò«üªº¦ì§}¦C¥X©M
;      AX¡NBX¡NCX¡NDX§¡³Q¯}Ãa
ubcd_add        proc    near
        push    si      ;96 «O¦sSI¡NDI
        push    di
        mov     si,ax   ;98 SI=³Q¥[¼Æ³Ì§C¦ì§}
        mov     di,dx   ;99 DI=¥[¼Æ³Ì§C¦ì§}
        cmp     ch,cl   ;100 ¤ñ¸û³Q¥[¼Æ»P¥[¼Æ¨º¤@­Ó¦ì¼Æ¤j
        jae     u_a0
        xchg    ch,cl   ;102 ­Y¥[¼Æ¦ì¼Æ¤j¡A«h¨Ï³Q¥[¼Æ»P¥[¼Æ¥æ´«³Ì§C
        xchg    bx,si   ;103 ¦ì§}(SI»PDI)¡A¦P®É¤]¥æ´«¦ì¼Æ(CH¡NCL)

;¶}©l¬Û¥[®É¡ASI«ü¦V¨â¸û¤j¦ì¼Æªº¦ì§}¡ACH¬°¸û¤j¦ì¼Æ
u_a0:   sub     ch,cl
        sub     ax,ax
        clc

;­pºâ­«Å|³¡¥÷
u_a1:   mov     al,[bx]	;111 ¨ú±o¥[¼Æ¤¤ªº¤@¦ì
        adc     al,[si]	;112 ¥[¤W³Q¥[¼Æ¬Û¹ïÀ³ªº¤@¦ì
        aaa		;113 ¥[ªk½Õ¾ã
        inc     si	
        mov     [di],al	;115 ¦s¤J©M¤º
        inc     bx
        inc     di
        dec     cl
        jnz     u_a1
        jcxz    u_a3	;120 °²¦p³Q¥[¼Æ»P¥[¼Æ¦ì¼Æ¬Ûµ¥®É¡ACX·|µ¥©ó¹s

;­pºâ¥u¦³¸û¤j¦ì¼Æ³¡¥÷
u_a2:   mov     al,[si]	;123
        adc     al,0	;124 ¨ÏAL¥[¤W¹s¡A¦A¥[¤W¶i¦ìºX¼Ð
        aaa
        inc     si
        mov     [di],al
        inc     di
        dec     ch
        jnz     u_a2	;130

;³B²z³Ì¤j¦ì¼Æ¶i¦ì
u_a3:   mov     al,cl	;133 ¨ÏALµ¥©ó¹s
        adc     al,0	;134 ¨ÏAL¥[¤W¹s¡A¦A¥[¤W¶i¦ìºX¼Ð
        mov     [di],al	;135 ¦s¤J©M¤¤

        pop     di
        pop     si
        ret
ubcd_add        endp
;---------------------------------------
v1      db      4,0,5,3,9       ;142 ³Q¥[¼Æ=93504¡A¤Q¶i¦ìªº¤E¸U¤T¤d¤­¦Ê¹s¥|
v2      db      9,8,6,1,6       ;143 ¥[¼Æ=61689
sum     db      digit+1 dup (?) ;144 ©M
;---------------------------------------
code    ends
;***************************************
        end     start

¥ý¬Ý²Ä 142 ¦æ¨ì²Ä 144 ¦æªº¸ê®Æ³¡¥÷¡A³o¤@³¡¥÷¬O¦s©ñ³Q¥[¼Æ(v1) ¤Î¥[¼Æ(v2) ªº BCD ¼Æ¡A¦b³o¸Ì­nª`·N¤@¥ó¨Æ¡A·í§Ú­Ì®Ñ¼g¼Æ¦r®É¡A¥ªÃ䪺¼Æ¦r¬O¸û¤j¦ì¼Æ(¨Ò¦p 93504 ¤¤ 9ªí¥Ü¸U¦ì¼Æ¤ñ¤d¦ì¼Æ¤j)¡C¦ý¬O¦b¹q¸£¤¤ªí¥Ü¼Æ­Èªº¤è¦¡¡A¤@¯ë¬O¤j¦ì¼Æ¦ì©ó°ª¦ì§}¡A¤]´N¬O»¡ 9 ©Ò¦bªº¦ì§}­n¤ñ 3 ªº¦ì§}°ª¤@­Ó¦ì¤¸²Õ¡C°²¦p§A¥Î DEBUG ¨ÓÆ[¹î¡AÀ³¸Ó·|Åܦ¨¹³¤U­±³o¼Ë¡C

H:\HomePage\SOURCE>debug bcd_add.com [Enter]
-r [Enter]
AX=0000  BX=0000  CX=00C0  DX=0000  SP=FFFE  BP=0000  SI=0000  DI=0000
DS=1C8E  ES=1C8E  SS=1C8E  CS=1C8E  IP=0100   NV UP EI PL NZ NA PO NC
1C8E:0100 BEB001        MOV     SI,01B0
-d 1a0 L20 [Enter]
1C8E:01A0  88 05 47 FE CD 75 F3 8A-C1 14 00 88 05 5F 5E C3   ..G..u......._^.
1C8E:01B0  04 00 05 03 09 09 08 06-01 06 00 00 00 00 00 00   ................

¬Ý¨ì¬õ¦âªº³¡¥÷¡A¸U¦ì¼Æ¬O¦b¸û°ª¦ì§}(1C8E:01B4)¡A¬O¦b¥kÃä¡F­Ó¦ì¼Æ¦b§C¦ì§}(1C8E:01B0)¡A¬O¦b¥ªÃä¡A¬Ý°_¨Ó¸ò¤@¯ëªº®Ñ¼g¤è¦¡¤£¦P¡A«Ü¤£²ßºD¡C©Î³\±z¤]¥i¥H¨Ì§Ú­Ì¥­®É®Ñ¼gªº²ßºD¡A±N¤j¦ì¼Æ©ñ¦b¥ªÃä¡A¤]´N¬O§C¦ì§}³B¡A¦b¼¶¼gµ{¦¡®É¡A¬O¨S¤°»ò°ÝÃDªº¡A¦ý¬O¤£ª¾¦³¨S¦³µw©Ê³W©w¤£¯à³o¼Ë¼g¡C

©Î³\±z·|°Ý¡A¤p¤ì°¸«çª¾¹D 1C8E:01B0 ´N¬O³Q¥[¼Æªº¦ì§}©O¡H­ì¨Ó·í DEBUG ¸ü¤Jµ{¦¡®É¡ACX ªº¤j¤p¬O¸ü¤JÀɮפ§ªø«×¡A¦Ó COM ÀɬO±q 0100H ³B¶}©l¡A¬G CX ¥[¤W 100H ´N¬OÀɮ׳̫á¡A¦Ó¤p¤ì°¸©Ò¼gªºµ{¦¡¥[¼Æ»P³Q¥[¼Æ§¡¦bÀɮ׳̫á¡C©Ò¥H¤@¶i¤J DEBUG «á¡A¤p¤ì°¸¥ß§Y¥Î¡yr¡z«ü¥O¬Ý¬Ý CX ¤§¤j¤p¡C(¦ý¬O¦pªG¬O¥Ñ DOS ¸ü¤Jµ{¦¡ªº¸Ü¡A¼È¦s¾¹ªºªì©l­È¬OµL·N¸qªº¡A­n¯S§O¤p¤ß¡A¤p¤ì°¸¦b¼¶¼g¤U¤@³¹ªºµ{¦¡®É¡A¦]²Ê¤ß¦Ó»~»{¥Ñ DOS ¸ü¤J¸ò DEBUG ¤@¼Ë¡Aµ²ªG¦hªá¤F¨â¤Ñªº¤u¤Ò¤~§ä¨ì¿ù»~¡C)

²Ä 144 ¦æ¡A©Mªº¦ì¼Æ¥²¶·¤ñ³Q¥[¼Æ©Î¥[¼Æªº¦ì¼ÆÁÙ­n¦h¤@¡A³o²z¥ÑÀ³¸Ó¨Ã¤£Ãø·Q¹³¡C¦]¬°¨â¼Æ¬Û¥[¡A¦³¥i¯à·|¦³¶i¦ì²£¥Í¡A¦Ò¼{¨â­Ó³Ì¤jªº¤­¦ì¼Æ¡A§Y 99999 ¬Û¥[¡A±o¨ìªº©M¬O¤»¦ì¼Æ¡A©Ò¥H©Mªº¦ì¼Æ¥²¶·¤ñ³Q¥[¼Æ©Î¥[¼Æ¦h¤@¡C

ubcd_print °Æµ{¦¡

±µ¤U¨Ó¡A¨Ó¬Ý¬Ýµ{¦¡²Ä 37 ¨ì²Ä 85 ¦æªº ubcd_print °Æµ{¦¡¡A³o­Ó°Æµ{¦¡¬O§â«D»E¶°ªº BCD ¼Æ¦L¦b¿Ã¹õ¤W¡C

¤£ºÞ¹q¸£¤W¤j¦ì¼Æ©ñ¦b¥ªÃä©Î¥kÃä¡A­n§â BCD ¼Æ¦L¥X¨Ó®É¡A³Ì¤j¦ì¼Æ (¹ï BCD_ADD.COM ¦Ó¨¥¡A³Ì¤j¦ì¼Æ´N¬O¸U¦ì¼Æ) À³³Ì¥ý¦L¥X¨Ó¡A¨Ã¥B¦b³Ì¥ªÃä¡C©Ò¥H³o­Ó°Æµ{¦¡§â¸Ó«O¯dªº¼È¦s¾¹¦s¤J°ïÅ|«á¡A²Ä¤G­n°µªº´N¬O§ä¨ì³Ì¤j¦ì¼Æªº¦ì§}¡Cµ{¦¡²Ä 45 ¦æ¨ì²Ä 59 ¦æ´N¬O´M§ä³Ì¤j¦ì¼Æ¡C

¦pªG CX ¤£µ¥©ó¹s¡Aªí¥Ü°Æµ{¦¡´£¨Ñ¤F­n¦L¥X BCD ¼Æªº¦ì¼Æ¡A¦Ó SI ¤S´£¨Ñ¤F¸Ó¼Æªº³Ì§C¦ì§}¡A¬G¸Ó¼Æªº³Ì¤j¦ì¼Æ¦ì§}¤£Ãø¨D¥X (¨£²Ä 47 ¦æ¨ì²Ä 50 ¦æ)¡C¦pªG CX ¬°¹s¡A´N±o¥Ñ ubcd_print °Æµ{¦¡­t³d¨D¥X¡A­ì²z¦p¤U¡A¦]¬°«D»E¶° BCD ¼Æ¥²¬O¥Ñ 0¡N1¡N2¡N3¡K¡K9 µ¥¤Q­Óªü©Ô§B¼Æ¦r²Õ¦¨¡A©Ò¥H¤p¤ì°¸³]­p¥Ñ SI ¦V°ª¦ì§}³B·j´M¡A¦pªG§ä¨ì²Ä¤@­Ó«Dªü©Ô§B¼Æ¦rªº¦ì¤¸²Õ¡AÅãµM´N¬O¤p¤ì°¸­n§äªº¡C¦ý¬O³oºØ¤èªk¬O¦³¯ÊÂIªº¡A³Ì¦nÁÙ¬O¥Ñ°Æµ{¦¡´£¨Ñ­n¦L¥Xªº¦ì¼Æ¸û¦n¡C

±µ¤U¨Ó´N¬O¥Ñ³Ì¤j¦ì¼Æ¶}©l¡A¤@¦ì¤@¦ì¦a§â«D»E¶° BCD ¼Æ¦L¦b¿Ã¹õ¤W¡C¦pªG³Ì¤j¦ì¼Æ¬°¹s¡A´N¤£»Ý­n¦L¦b¿Ã¹õ¤W¡A²Ä 53 ¦æ¨ì²Ä 59 ¦æ´N¬O´M§ä¤£¬O¹sªº³Ì¤j¦ì¼Æ¡C¶}©l¨Ì¦¸¦L¥X¨Ó¡A­nª`·Nªº¬O¦b¦L¥X¨C¤@¦ì¼Æ®É¥²¶·¥[¤W 30H ¨Ï¤§¦¨¬° ASCII ½X¡C

ubcd_add °Æµ{¦¡

²Ä 87 ¦æ¨ì²Ä 140 ¦æ¬O­Ó°Æµ{¦¡¡A³o­Ó°Æµ{¦¡ªº¥D­n¤u§@´N¬O§â³Q¥[¼Æªº¨C¤@¦ì¼Æ©M¥[¼Æªº¬Û¹ïÀ³¦ì¼Æ¬Û¥[¡A¨Ã¦s©ó DX ¼È¦s¾¹©Ò«ü¦ì§}ªº¬Û¹ïÀ³¦ì¼Æ¡C

¤]´N¬O»¡­º¥ý¨ú±o³Q¥[¼Æªº­Ó¦ì¼Æ¡A¦A¥[¤W¥[¼Æªº­Ó¦ì¼Æ¡A¨Ã±Nµ²ªG¦s©ó©Mªº­Ó¦ì¼Æ¡C¤p¤ì°¸¥Î¤T­Ó¼È¦s¾¹¨Óªí¥Ü³Q¥[¼Æ¡B¥[¼Æ¥H¤Î©Mªº¦ì§}¡A³o¤T­Ó¼È¦s¾¹¤À§O¬O AX¡BBX¡BDX¡A¦]¬°­Ó¦ì¼Æ¦b³Ì§C¦ì§}¡A¬G¤@¶}©l¹Bºâ®É±N³o¤T­Ó¼È¦s¾¹«ü¦V³o¤T­Ó BCD ¼Æªº³Ì§C¦ì§}¡A«Ý­Ó¦ì¼Æ¬Û¥[§¹²¦¡A±N³o¤T­Ó¼È¦s¾¹¤À§O¥[¤@¡A¨ú±o¤Q¦ì¼Æ¦A¬Û¥[¡A­«½Æ¦¹¨BÆJ´N¥i¥H§¹¦¨¤j³¡¤À¤u§@¡C

¬°¤F¦Ò¼{±N¨Ó§@¬°µ{¦¡®wªº¤¸¥ó¤§¤@¡A¬G¤p¤ì°¸±N¥¦¦Ò¼{±o¸û½ÆÂø¨Ç¡C¥[ªk¤£¤@©w¬O¬Û¦P¦ì¼Æ¬Û¥[¡A¤]¥i¯à¬O¤£¦P¦ì¼Æ¬Û¥[¡C·í¤£¦P¦ì¼Æ¬Û¥[®É¡A¤p¤ì°¸¤À¦¨¤T³¡¥÷¡A­«Å|³¡¥÷ (µµ¦â³¡¥÷¡A´N¬O³Q¥[¼Æ»P¥[¼Æ³£¦³ªº³¡¥÷)¡N«D­«Å|³¡¥÷ (¾ï¦â³¡¥÷¡A´N¬O¥u¦³¸û¤j¦ì¼Æ¦³ªº³¡¥÷) ¤Î¶i¦ì³¡¥÷¡C½Ð°Ñ¦Ò¤U­±ªº¥[ªk¡G

  ³Q¥[¼Æ¡G          9 3 5 0 4
    ¥[¼Æ¡G    +           8 9
  ----------------------------
      ©M¡G          9 3 5 9 3

©Ò¥H ubcd_add °Æµ{¦¡¤@¶}©l´N¬O¥ý¨D¥X³Q¥[¼Æ©M¥[¼Æ¨º¤@­Ó¦ì¼Æ¤j¡H¤p¤ì°¸¥ý°²©w³Q¥[¼Æ¦ì¼Æ¤j¡A©Ò¥H¦pªG CH>CL ¨º´Nª½±µ¨ì 106 ¦æ¡A§_«h¥æ´«³Q¥[¼Æ»P¥[¼Æ¤§¦ì¼Æ»P³Ì§C¦ì§} (²Ä 102 ¦æ¡N²Ä 103 ¦æ)¡A¤Ï¥¿¥[ªk¬O¦³¡y¥æ´««ß¡zªº¡C

¦A¨Ó´N¬O­pºâ­«Å|³¡¥÷¤F (²Ä 111 ¦æ¨ì²Ä 120 ¦æ)¡A³o¨à¦³­Ó·s«ü¥O¡GADC¡C

·sªº«ü¥O¡GADC

¦b 80X86 «ü¥O¶°¤¤¦³¤@­Ó¦Ò¼{¶i¦ìªº¥[ªk«ü¥O¡A´N¬O ADC «ü¥O¡C³o­Ó«ü¥Oªº»yªk¦p¤U¡G

ADC     ¥Øªº,¨Ó·½

¨ä¤¤¥Øªº¤Î¨Ó·½¥i¥H¬O¼È¦s¾¹¡N°O¾ÐÅé©Î¬O±`¼Æ¡A¦ý¤£¯à¦P®É¬°°O¾ÐÅé§Y¥i¡A¥B­nª`·N¸ê®Æªø«×­n¬Û¦P¡C

ADD »P ADC ³£¬O¦b°µ¥[ªk¹Bºâ®É¡A¥L­Ì¨â­Ó¤£¦P¤§³B¬O ADD ¥u³æ¯Â±N¨Ó·½¥[¨ì¥Øªº´N¦n¤F¡A¦Ó ADC °£¤F±N¨Ó·½¥[¨ì¥Øªº¤§¥~¡AÁÙ·|¥[¤W¶i¦ìºX¼Ð§@¬°³Ì«áµ²ªG¦s¤J¥Øªº¤¤¡C

³o¨â­Ó«ü¥O°£¤F¬Û¥[¥~ÁÙ·|³]©w¶i¦ìºX¼Ð¡A¦]¬°³o¨â­Ó«ü¥O³£¬O°w¹ï¤Q¤»¶i¦ì³]­pªº¡A©Ò¥H¦pªG¬Û¥[¤§«áªº©M¶W¹L©Îµ¥©ó 100H ©Î 10000H ´N·|µo¥Í¶i¦ì¡C¦Ó AAA ¤]·|³]©w¶i¦ìºX¼Ð¡A¥u¬O AAA «ü¥O¬O°w¹ï¤Q¶i¦ìªº¹Bºâ¡A©Ò¥H¦pªG¶W¹L©Îµ¥©ó 10D¡A´N·|µo¥Í¶i¦ì¡C¤£ºÞ¬O¨º¤@ºØ«ü¥O²£¥Íªº¶i¦ìª¬ºA¡A·í¶i¦ìµo¥Í®É¡A¶i¦ìºX¼Ð³£·|³Q³]©w¦¨¡y¤@¡z¡A¦b DEBUG Åã¥Ü¬° CY¡F¦pªG¨Sµo¥Í¶i¦ì¡A¶i¦ìºX¼Ð´N·|³Q²M°£¬°¡y¹s¡z¡A¦b DEBUG Åã¥Ü¬° NC¡C

¦A¦^¨Ó¬Ý¬Ýµ{¦¡¡C·í­Ó¦ì¼Æ¬Û¥[«á¡A¦pªG¸g½Õ¾ã«á¶W¹L¤Q¡Aªí¥Ü¶i¦ìµo¥Í¡A²Ä 30 ¦æªº AAA «ü¥O·|³]©w¶i¦ìºX¼Ð¬°¤@¡A­Y¨S¶i¦ì«h¶i¦ìºX¼Ð³]¬°¹s¡C¦n¡A§Ú­Ì¥Î DEBUG Æ[¹î¬Ý¬Ý¡C

H:\HomePage\SOURCE>debug bcd_add.com [Enter]
-g 18a [Enter]
93504+61689=
AX=0000  BX=01B5  CX=0005  DX=01BA  SP=FFF8  BP=0000  SI=01B0  DI=01BA
DS=1C8E  ES=1C8E  SS=1C8E  CS=1C8E  IP=018A   NV UP EI PL ZR NA PE NC
1C8E:018A 8A07          MOV     AL,[BX]                            DS:01B5=09
-t [Enter]

AX=0009  BX=01B5  CX=0005  DX=01BA  SP=FFF8  BP=0000  SI=01B0  DI=01BA
DS=1C8E  ES=1C8E  SS=1C8E  CS=1C8E  IP=018C   NV UP EI PL ZR NA PE NC
1C8E:018C 1204          ADC     AL,[SI]                            DS:01B0=04
-t [Enter]

AX=000D  BX=01B5  CX=0005  DX=01BA  SP=FFF8  BP=0000  SI=01B0  DI=01BA
DS=1C8E  ES=1C8E  SS=1C8E  CS=1C8E  IP=018E   NV UP EI PL NZ NA PO NC
1C8E:018E 37            AAA

¦]¬° ADC ¬Û¥[«á¨Ã¨S¦³¶W¹L 10H ¬G¨S¦³¶i¦ì(¨£¬õ¦â¦r)¡C¦AÄ~Äò°lÂÜ¡C

-t [Enter]

AX=0103  BX=01B5  CX=0005  DX=01BA  SP=FFF8  BP=0000  SI=01B0  DI=01BA
DS=1C8E  ES=1C8E  SS=1C8E  CS=1C8E  IP=018F   NV UP EI PL NZ AC PO CY
1C8E:018F 46            INC     SI

¬Ý¨ì¤W­±¶i¦ìºX¼ÐÅܦ¨¡yCY¡z¤F¶Ü¡H³o¬O¦]¬°°µ AAA ½Õ¾ã«á¡Aµo¥Í¤F¶i¦ì¡C©¯¦n 80X86 «ü¥O¤¤ªº MOV¡NDEC¡NLOOP «ü¥O³£¤£·|¼vÅT¶i¦ìºX¼Ð¡A¬G¥i¥H«O¦s³oºØ¶i¦ì©Î¤£¶i¦ìªºª¬ºA¨ì¤U¦¸¥[ªk¡A³o¤]´N¬O§Ú­Ì¥i¥H§Q¥Î³o­Ó©Ê½è¨Ì¦¸°µ­Ó¦ì¼Æ¡B¤Q¦ì¼Æ¡B¦Ê¦ì¼Æ¡K¡K¥[ªkªº²z¥Ñ¡C±µ¤U¨Ó 1C8E:0143 ¦ì§}ªº«ü¥O¬O§â¨C¦¸°µ§¹¥[ªk«áªºµ²ªG¦s¤J sum ÅܼƤ¤¡C

-t [Enter]

AX=0103  BX=01B5  CX=0005  DX=01BA  SP=FFF8  BP=0000  SI=01B1  DI=01BA
DS=1C8E  ES=1C8E  SS=1C8E  CS=1C8E  IP=0190   NV UP EI PL NZ NA PE CY
1C8E:0190 8805          MOV     [DI],AL                            DS:01BA=00
-t [Enter]

AX=0103  BX=01B5  CX=0005  DX=01BA  SP=FFF8  BP=0000  SI=01B1  DI=01BA
DS=1C8E  ES=1C8E  SS=1C8E  CS=1C8E  IP=0192   NV UP EI PL NZ NA PE CY
1C8E:0192 43            INC     BX
-t [Enter]

AX=0103  BX=01B6  CX=0005  DX=01BA  SP=FFF8  BP=0000  SI=01B1  DI=01BA
DS=1C8E  ES=1C8E  SS=1C8E  CS=1C8E  IP=0193   NV UP EI PL NZ NA PO CY
1C8E:0193 47            INC     DI
-t [Enter]

AX=0103  BX=01B6  CX=0005  DX=01BA  SP=FFF8  BP=0000  SI=01B1  DI=01BB
DS=1C8E  ES=1C8E  SS=1C8E  CS=1C8E  IP=0194   NV UP EI PL NZ NA PE CY
1C8E:0194 FEC9          DEC     CL
-t [Enter]

AX=0103  BX=01B6  CX=0004  DX=01BA  SP=FFF8  BP=0000  SI=01B1  DI=01BB
DS=1C8E  ES=1C8E  SS=1C8E  CS=1C8E  IP=0196   NV UP EI PL NZ NA PO CY
1C8E:0196 75F2          JNZ     018A
-t [Enter]

AX=0103  BX=01B6  CX=0004  DX=01BA  SP=FFF8  BP=0000  SI=01B1  DI=01BB
DS=1C8E  ES=1C8E  SS=1C8E  CS=1C8E  IP=018A   NV UP EI PL NZ NA PO CY
1C8E:018A 8A07          MOV     AL,[BX]                            DS:01B6=08
-t [Enter]

AX=0108  BX=01B6  CX=0004  DX=01BA  SP=FFF8  BP=0000  SI=01B1  DI=01BB
DS=1C8E  ES=1C8E  SS=1C8E  CS=1C8E  IP=018C   NV UP EI PL NZ NA PO CY
1C8E:018C 1204          ADC     AL,[SI]                            DS:01B1=00
-t [Enter]

AX=0109  BX=01B6  CX=0004  DX=01BA  SP=FFF8  BP=0000  SI=01B1  DI=01BB
DS=1C8E  ES=1C8E  SS=1C8E  CS=1C8E  IP=018E   NV UP EI PL NZ NA PE NC
1C8E:018E 37            AAA

ª`·N¬Ý¥Õ¦âªº³¡¥÷¡AAL ¬O¤£¬Oµ¥©ó 8 ¥[¹s¦A¥[¤W¶i¦ìºX¼Ð¡H¦Aª`·N¡A¤W­z±q¦ì§} 018a ¨ì 0196 ³o´X¦æªº«ü¥O¦b§@¥Î§¹¤§«á¡A§¡¤£¼vÅT¶i¦ìºX¼Ð¡C

-t

AX=0309  BX=010B  CX=0006  DX=003D  SP=FFFE  BP=0000  SI=0104  DI=0112
DS=1C8E  ES=1C8E  SS=1C8E  CS=1C8E  IP=0143   NV UP EI PL NZ NA PE NC
1C8E:0143 8805          MOV     [DI],AL                            DS:0112=00

³o¦¸½Õ¾ã¤§«á¡A¨S¦³¶i¦ì§a¡H¥H«á³£¬O­«½Æ©Êªº¤u§@¤F¡A´N¤£¦AÂØ­z¡C

±µ¤U¨Ó¬O³B²z«D­«Å|³¡¥÷¡A³o¤@³¡¥÷©M­«Å|³¡¥÷¨ä¹ê´X¥G¤@¼Ë¡A¥u¬O²Ä 124 ¦æ³B¬O¥[¤W¹s¦Ó¤w¡C¤]¤£¦AÂØ­z¡C¦Ó³B²z¶i¦ìªº³o¤@³¡¥÷¡A¤p¤ì°¸¤]¤£¦A­«½Æ¤F¡C

·sªº«ü¥O¡GCLC

³o­Ó«ü¥O«Ü²³æ¡A´N¬O±N¶i¦ìºX¼Ð³]¦¨¹s¡C¥L¨S¦³¹Bºâ¤¸¡C¦b BCD_ADD.ASM µ{¦¡¤¤¡A¥¦ªº¥\¥Î´N¬O¥ý§â¶i¦ìºX¼ÐÂk¹s¡A§K±o©¹«á°µ ADC ¹Bºâ®É²£¥Í¿ù»~¡C


§â ubcd_print¡Nubcd_add ¥[¤Jµ{¦¡®w

¥i¥H¹w¨£¡A¦b³o³¹©Ò¼¶¼gªº¨â­Ó°Æµ{¦¡ ubcd_print ©M ubcd_add ¬O«Ü¦³¥Îªº¡A¥i¬°³\¦hµ{¦¡©Ò©I¥s¡A©Ò¥H¤p¤ì°¸±N³o¨â­Ó°Æµ{¦¡¿W¥ß¥X¨Ó¡A¤À§OºÙ¬° UBCD_PNT.ASM ©M UBCD_ADD.ASM¡C

¥ý±N BCD_ADD.ASM ¤¤ªº²Ä 36 ¦æ¨ì²Ä 84 ¦æ¼Ð¥Ü¨Ã«þ¨©°_¨Ó¡AµM«á¶}±Ò°O¨Æ¥»¡A¶K¤W¡A¨Ã¦bµ{¦¡³Ì«e­±¤Î³Ì«á­±¥[¤W´X¦æ¡A¨Ï¦¨¤U­±ªº¼Ë¤l¡G

code    segment
        assume  cs:code,ds:code
        public  ubcd_print
;---------------------------------------
;¦b¿Ã¹õ¤W¦L¥X«D»E¶° BCD ¼Æ      ;37
¡K¡K¡K¡K¡K¡K
;¤¤¶¡¬Ù²¤
¡K¡K¡K¡K¡K¡K
ubcd_print      endp            ;85
;---------------------------------------
code    ends
;***************************************
        end     ubcd_print

µM«á¦s¦¨ UBCD_PNT.ASM¡A¦P²z¤]¨Ï ubcd_add °Æµ{¦¡Åܦ¨¤@¥i²ÕĶªº UBCD_ADD.ASM¡AµM«á¶}±Ò DOS ¼Ò¦¡¡A°õ¦æ¤U­±¨BÆJ¡A¨Ï³o¨â­Ó°Æµ{¦¡¥[¤J²Ä¤Q³¹©Ò«Ø¥ßªºµ{¦¡®w¡G

H:\HomePage\SOURCE>..\masm50\masm ubcd_pnt; [Enter]   ²ÕĶ UBCD_PNT.ASM
Microsoft (R) Macro Assembler Version 5.00
Copyright (C) Microsoft Corp 1981-1985, 1987.  All rights reserved.


  51452 + 381924 Bytes symbol space free

      0 Warning Errors
      0 Severe  Errors

H:\HomePage\SOURCE>..\masm50\masm ubcd_add; [Enter]   ²ÕĶ UBCD_ADD.ASM
Microsoft (R) Macro Assembler Version 5.00
Copyright (C) Microsoft Corp 1981-1985, 1987.  All rights reserved.


  51490 + 381886 Bytes symbol space free

      0 Warning Errors
      0 Severe  Errors

H:\HomePage\SOURCE>..\masm50\lib [Enter]   ¨ÏUBCD_PNT.ASM ¤ºªº ubcd_print
                                           ¥[¤J MYASMLIB.LIB µ{¦¡®w
Microsoft (R) Library Manager  Version 3.07
Copyright (C) Microsoft Corp 1983-1987.  All rights reserved.

Library name: myasmlib [Enter]
Operations: +ubcd_pnt [Enter]
List file:  [Enter]
Output library: myasmlib [Enter]

H:\HomePage\SOURCE>..\masm50\lib [Enter]   ¨ÏUBCD_ADD.ASM ¤ºªº ubcd_add
                                           ¥[¤J MYASMLIB.LIB µ{¦¡®w
Microsoft (R) Library Manager  Version 3.07
Copyright (C) Microsoft Corp 1983-1987.  All rights reserved.

Library name: myasmlib [Enter]
Operations: +ubcd_add [Enter]
List file: myasmlib.lst [Enter]
Output library: myasmlib [Enter]
H:\HomePage\SOURCE>type myasmlib.lst [Enter]
PRINT_BL..........pnt_bl            PRINT_BX..........pnt_bx
UBCD_ADD..........ubcd_add          UBCD_PRINT........ubcd_pnt


pnt_bl            Offset: 00000010H  Code and data size: 11eH
  PRINT_BL

pnt_bx            Offset: 000000a0H  Code and data size: 128H
  PRINT_BX

ubcd_pnt          Offset: 00000140H  Code and data size: 3bH
  UBCD_PRINT

ubcd_add          Offset: 000001e0H  Code and data size: 39H

³o¼Ë¤p¤ì°¸´N¦³¥|­Ó°Æµ{¦¡¤F¡C


µ²½×

³o¤@³¹ùØ´£¨ì BCD ¼Æªº·§©À¡A¥÷¶qºâ¬O¬Û·í±o¦h¡C¦ý¬O§Ú·Q³Ì­«­n±o¬O±z¬O§_¯à¥Î¦Û¤vªº¸Ü»¡¥X¨Ó¦ó¿× BCD ¼Æ¡A°²¦p±z¯à°÷ªº¸Ü¡A¬Û«H±z¯uªºÀ´¤F¡A°²¦p±z¤£¯àªº¸Ü¡A«Øij±z¥Î DEBUG ¥h°lÂܬݬݡC¦Ü©ó¤W­z¤¶²Ð³\¦h·sªº«ü¥O¨ä¹ê³£¬O¥½¸`¡A¦pªG±z¯uªº¤w¸gª¾¹D BCD ¼Æªº·N¸q¡A³o¨Ç«ü¥O±z¦ÛµM¦ÓµMªº´N¤w¸g¯à°O±o¤F¡A§Y¨Ï¹³¤p¤ì°¸¤@¼Ë°O¤£¤Ó²M·¡¡A¨ì®É¬d¬d®Ñ¡A´X¤ÀÄÁ¤ºÁÙ¬O¯à¼g¥X¨Ó¡C

¦Ü©ó±z»¡¡A¤p¤ì°¸¤£¬O­n¼g¥X«Ü¤j¦ì¼Æªº¥[ªk¶Ü¡H«ç»ò¥u¦³¤­¦ì¼Æ©O¡H¨ä¹ê«Ü²³æ¡A°²¦p±z·Q­pºâ 20 ¦ì¼Æ¡A±z¥u»Ý­n§â BCD_ADD.ASM ²Ä¤@¦æªº digit §ï¦¨ 20¡AµM«á§â v1¡Bv2 §ï¦¨±z­n¬Û¥[ªº¨â¼Æ(­n°O±o¨C¤@­Ó¼Æ³£­n¦³ 20 ¦ì¼Æ)¡A¦A­«·s½sĶ³sµ²§Y¥i¡C

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