¦b³oÓµ{¦¡¸Ì¡A§Ú±N·|»¡©ú¦p¦ó¦b²Õ¦X»y¨¥¤¤¦p¦ó³B²zÁä½L¿é¤J¡AµM«á³B²z¦¨¬°¤Q¤»¶i¦ìªº¼Æ¦r¡A¦s©ó¼È¦s¾¹¤¤¡C
³oÓµ{¦¡¦W¥s HEX2DEC2.COM¡A¬°¦ó¦³¨âÓ2©O¡H¡y2¡z^¤åŪµ©M¡yto¡z¦Pµ¡A¬G HEX2DEC ªº·N«ä´N¬O¡yHEX TO DEC¡z¡AHEX¡BDEC ¤À§Oªí¥Ü¤Q¤»¶i¦ì©M¤Q¶i¦ì¡Q²Ä¤GÓ¡y2¡zªí¥Ü¦³§O©ó¤W¤@³¹ªºµ{¦¡ HEX2DEC.COM¡C
INT 16h ªºªA°Èµ{¦¡¤£¹³ INT 21h ³o»ò¦h¡A¥u¦³¤TÓ¡G
³o¼Ë°µªº¦n³B¬O¡A¦³¨Ç¦r¥i¥H¥Î¨âºØ¤è¦¡«ö¥X¨Ó¡A¨Ò¦pªü©Ô§B¼Æ¦rªº¡y1¡z§A¥i¥H¨Ï Num Lock ¿O«G°_¦A«öÁä½L¥kÃ䪺Áä¡A³oÓÁäÁÙ¥Nªí End¡A©ÎªÌª½±µ«öÁä½L¥ª¤W¤èªºÁä¡A³oÓÁä¤]¥i¥H«ö¥X¡y!¡z¡A¦ý¬O³o¨âÓÁ䪺±½´y½X¤£¦P¡Aµ{¦¡´N¥i¥H½T¹êª¾¹D¨Ï¥ÎªÌ¨ì©³«ö¥X¨º¤@ÓÁä¡CÁöµM±½´y½X¤£¦P¡A¦ý¬O©Ò«ö¥X¨Óªü©Ô§B¼Æ¦r¡y1¡zªº ASCII ½X«o¬O¤@¼Ëªº¡C
°õ¦æ INT 16H/AH=0 ³oÓ BIOS ¤¤Â_ªA°Èµ{¦¡«á¡A·|°±¤U¨Óµ¥¨Ï¥ÎªÌ«ö¤U¤@ÓÁä¡A·í¨Ï¥ÎªÌ«ö¤U¤@ÓÁä«á¡AAH ·|³Q¦s¤J³oÓÁ䪺±½´y½X¡AAL ·|¦s¤J³Q«ö¤UÁ䪺 ASCII ½X¡C
¨ú±o¨Ï¥ÎªÌ«ö¤Uªº¼Æ¦r¤§«á¡AÁÙ±o¸g¹L³B²z¤~¯à¦¨¬°¿é¤Jªº¤Q¤»¶i¦ì¼Æ¡CÁÙ°O±o¦pªG¦³¤@Ó¤Q¤»¶i¦ì¼Æ 021Bh¡A¨ä¼ÆÈ´N¬O 2x162+1x16+11 §a¡H(¦pªG¤£°O±o½Ð°Ñ¦Ò¼Æ¦r¨t²Îªºµù¤@¡C)§Ú̪º³B²z¤èªkÃþ¦ü¤W±¡A¨C·í¿é¤J¤@¦ì¼Æ¦r®É¡Aì¥ýªº¼Æȼ¥H 16 ´NÅܦ¨¤Q¤»¶i¦ì¤F¡C¦³Ãö¤Q¤»¶i¦ìÂà´«¦¨¤Q¶i¦ì«e´X³¹¤w»¡©ú¡A´N¤£ÂØz¤F¡C
;*************************************** code segment assume cs:code,ds:code org 100h ;--------------------------------------- start: jmp short begin hex_n dw ? begin: sub bx,bx ;08 ¨ÏBX¬°¹s¡A¥HÀx¦s¿é¤Jªº¤Q¤»¶i¦ì¼Æ next: mov ah,0 int 16h ;10 ©I¥sBIOSÁä½LªA°Èµ{¦¡ cmp al,'=' ;11 Y¿é¤Jµ¥¸¹ªí¥Ün¶}©lÂà´«¤F je ok1 mov dl,al ;13 ±N¿é¤JªºASCII½X¦s¤JDL¥H§Q¦L¦b¿Ã¹õ¤W cmp al,'0' ;14 Àˬd¿é¤JªºASCII½X¬O§_¬°ªü©Ô§B¼Æ¦r jb next cmp al,'9' ja alpha ;15 Y§_¡A«hÀˬd¬O§_¬°A¨ìFªº^¤å¦r sub al,'0' ;18 ´î¥h30h¡A¥H±o¨ì¤Q¤»¶i¦ì¼Æ jmp short ok0 alpha: and al,0dfh ;20 mov dl,al sub al,37h ;22 Àˬd¬O§_¬°A¨ìFªº^¤å¦r cmp al,0ah jb next cmp al,0fh ja next ;26 ok0: push ax ;28 call ok ;29 ¦b¿Ã¹õ¤W¦L¥X¿é¤Jªº¦r pop ax mov cl,4 ;31 ±NBX¼¥H16d shl bx,cl cbw add bx,ax ;34 ¨ÏBX¥[¤W¿é¤Jªº16¶i¦ì¼Æ mov dh,bh ;35 Àˬd¬O§_¶W¹LBX®e¶q and dh,0f0h jnz ok1 ;37 ¶W¹L¤F jmp next ;38 ¨S¶W¹L ok1: mov dl,'h' call ok mov dl,'=' call ok mov hex_n,bx mov cx,10000;46¶}©lÂà´«¦¨¤Q¶i¦ì¼Æ mov ax,hex_n sub dx,dx div cx xchg ax,dx ;50 AX=°Ó¡A¬G»PDX¥æ´« mov bx,ax ;51 ¦L¥Xªü©Ô§B¼Æ®É·|¨ÏDX¼ÆȧïÅÜ¡A¬G¾l¼Æ«O¦s©óBX call print ;52 ¦L¥X¤Q¶i¦ìªº¸U¦ì¼Æ mov ax,bx sub dx,dx mov cx,1000 div cx xchg ax,dx mov bx,ax call print ;60 ¦L¥X¤d¦ì¼Æ mov ax,bx sub dx,dx mov cx,100 div cx xchg ax,dx mov bx,ax call print ;68 ¦L¥X¦Ê¦ì¼Æ mov ax,bx sub dx,dx mov cx,10 div cx xchg ax,dx mov bx,ax call print ;76 ¦L¥X¤Q¦ì¼Æ mov dx,bx call print ;79 ¦L¥XÓ¦ì¼Æ mov dl,'d' call ok mov ax,4c00h int 21h ;--------------------------------------- ;print °Æµ{¦¡ ;¿é¤J¡GDL-¥Ñ 0 ¨ì F ªº¤Q¤»¶i¦ì¼Æ ;¿é¥X¡G¦b¿Ã¹õ¤W¦L¥X DL ¤ºªº ASCII ½X print proc near add dl,30h ;90 ¥[¤W 30H cmp dl,'9' ;91 ¤ñ¸û¬Ý¬Ý¬O§_¶W¹L 39H jbe ok ;92 ¨S¶W¹Lª½±µ¦L¥X add dl,7 ;93 Y¶W¹L¦A¥[¤W 7 ok: mov ah,2 ;94 int 21h ;95 ¦L¥X ret print endp ;--------------------------------------- code ends ;*************************************** end start
H:\HomePage\SOURCE>hex2dec2 [Enter]
ABCDh=43981d
H:\HomePage\SOURCE>
·í§A¦b DOS ¤¤°õ¦æ³oÓµ{¦¡( DOS n°õ¦æµ{¦¡®É¨Ã¤£¹³ Windows 9x ¤@¼Ë¥Î·Æ¹««ö¨â¤U¡A¦Ó¬On¿é¤Jµ{¦¡ªºÀɦW)¡A·|°±¤U¨Óµ¥§A¿é¤J¡Aµ{¦¡·|¦Û°ÊÀˬd§A¿é¤Jªº¬O¤£¬O¦b 0 ¨ì 9 ©Î¬O A ¨ì F ¤§¶¡¡AY¤£¬O«h¨S¦³¤ÏÀ³¡C³oÓµ{¦¡³Ì¤j¥u¯àÂà´« 0FFFFh¡A©Ò¥H¦pªG§A¿é¤J¶W¹L¡A¤]·|¦Û°ÊºI¥h¡A¦pªG§A·QÂà´«¤p©ó 1000h ªº¼Æ¡A¥i¥H¦b¿é¤J¤T¦ì¤§«á«ö¡y=¡zÁä¡C
¦b¿é¤J¤Q¤»¶i¦ìªº¹Lµ{¡A¤p¤ì°¸¥Î BX ¼È®É¦s©ñ¤Q¤»¶i¦ì¼Æ¡A¦]¦¹²Ä¤K¦æ¥ý±N BX ²M°£Åܬ°¹s¡C²Ä¤E¡B¤Q¦æ¬Oµ¥¨Ï¥ÎªÌ¿é¤J¤@Ó¦rªº BIOS ¤¤Â_ªA°Èµ{¦¡¡C
²Ä 11 ¦æ¨ì²Ä 19 ¦æ¬OÀˬd¬O§_¿é¤J¡y=¡z©Îªü©Ô§B¼Æ¦r 0 ¨ì 9 ©Î^¤å¦r A ¨ì F¡AY¤£¬O¤W±´XÓ¦r´N¦^¨ì BIOS ¤¤Â_Ä~Äòµ¥¨Ï¥ÎªÌ¿é¤J¡AY¬Oªº¸ÜÁÙn¦L¥X¿é¤J¤°»ò¦r¨Ã§@³B²z¡C
³B²z®É±o¤À¤T³¡¥÷¨Ó§@¡C²Ä¤@¡A¦pªG¬O¡y=¡zªº¸Ü´Nª½±µ¸õ¨ì ok1: ¼Ð°O³B¡Aok1: ¼Ð°O¬O³B²z¤w¸g§¹¦¨¿é¤J«áªºµ{¦¡¡C²Ä¤G¡A¦pªG¬Oªü©Ô§B¼Æ¦rªº¸Ü¡A´Nn±N BX ªº¼ÆÈ¥ý¼¥H 16¡A¦A¥[¤Wè¿é¤Jªºªü©Ô§B¼Æ¦r(³o¸Ì¦³¤@Ó 80X86 ·s«ü¥O CBW¡A½Ð¬Ý©³¤U»¡©ú)¡Aª`·N¡Iªü©Ô§B¼Æ¦rÁÙ±o¥ý±q ASCII ½XÅܦ¨¼ÆÈ¡C²Ä¤T¡A¦pªG¬O^¤å¦rªº¸Ü¡An¥ýÂà´«¦¨¤j¼g¡A±µ¤U¨Óªº³B²z¹Lµ{©Mªü©Ô§B¼Æ¦r¤@¼Ë¡C
^¤å¦r¥À¡yA¡zªº ASCII ½X¬O 41h¡A¤G¶i¦ì¬° 0100 0001B¡Q¦Ó¡ya¡zªº ASCII ½X¬O 61h¡A¤G¶i¦ì¬° 0110 0001B¡A¨âªÌªº®t§O¥u¦b²Ä¤Ó¦ì¤¸¡A¤j¼gªÌ¬° 0¡A¤p¼gªÌ¬° 1¡C¬G±N¼È¦s¾¹ªº¼ÆÈ©M 1101 1111B(=0dfh) §@ AND ¹Bºâ´N¯à±j¢Åܦ¨¤j¼g^¤å¦r¥À¡C
ok1: ¼Ð°O³B(²Ä 40 ¦æ)¨ì²Ä 43 ¦æ¬O¦L¥X¡yh=¡z³o¨âÓ¦r¡C²Ä 44 ¦æ¥H«á´N¬O¦L¥X hex_n Åܼƪº¤Q¶i¦ì¼ÆȤF¡C
CBW ¨Ì·Ó¥H¤Uªº¨âÂI³W«h¡G
²Ä¤@¡B¦pªG AL ªº³Ì°ª¦ì¤¸¬O 0 ªº¸Ü(§Y AL ¤p©ó 80h¡A©Î¬O²Ä¥|³¹µù¤@ªº¥¿¼Æ)¡A°õ¦æ¦¹«ü¥O¤§«á AH ·|Åܬ°¹s¡AAL ¤§È¤£ÅÜ¡C
²Ä¤G¡B¦pªG AL ªº³Ì°ª¦ì¤¸¬O 1 ªº¸Ü(t¼Æ)¡A°õ¦æ¦¹«ü¥O¤§«á AH ·|Åܬ° 0ffh¡AAL ¤§È¤£ÅÜ¡C
PUSH ¼È¦s¾¹
PUSH ÅܼÆ
¦]¬°¨C¦¸¶i¤J°ïÅ|ªº¼Æ³£¬O¤@Ó¦r²Õ¡A¦]¦¹³oÓ¡A±À¤J°ïÅ|«á¼È¦s¾¹©MÅܼƪº¼ÆȨ䣷|§ïÅÜ¡C
POP ªº¥\¥Î©M PUSH ¬Û¤Ï¡A¥¦¬O¥Ñ°ïÅ|¨ú¥X¼Æ¨Ã¦s¤J«á±ªº¼È¦s¾¹©ÎÅܼơA¦P®É¨Ï SP ¼È¦s¾¹ªº¼ÆȼW¥[ 2¡C¥¦©M PUSH ¤@¼Ë¡A¼È¦s¾¹©MÅܼƪºªø«×³£¥²¶·¬O¤Q¤»¦ì¤¸¡C¨ä»yªk¦p¤U¡G
POP ¼È¦s¾¹
POP ÅܼÆ
¦b¨Ï¥Î PUSH ©M POP ®Énª`·Nnª`·N¡A³Ì¦n¯à¦¨¹ï¨Ï¥Î¡A¦]¬°¦pªG¦bµ²§ôµ{¦¡©Î°Æµ{¦¡®É¡A³£¥²¶·¨ì°ïÅ|¤¤¨ú¥Xnªð¦^ªº¦ì§}¡A¦pªG°ïÅ|¤ºªº¸ê®Æ¦³¿ù¡A´N·|³y¦¨·í¾÷¡C
²Ä 28¡B30 ¦æªº³o¤@¹ï PUSH ©M POP ªº¥Dn¥Øªº¬O«O¦s AX ¤ºªº¼ÆÈ¡A¦]¬° ok: ¼Ð°Oªºµ{¦¡·|¯}Ãa AX ªº¤º®e¡C¦bµ{¦¡¤¤±`±`¥Î³oºØ¤è¦¡¨Ó«O¦s¼ÆÈ¡C
³oÓ«ü¥Oªº»yªk©M SHR ¬Û¦P¡A§@¥Î¤]´X¥G¬Û¦P¡A¤£¦Pªº¬O SHL ¬O¨Ï¸ò¦b«á±ªº¼È¦s¾¹©ÎÅܼƤº®e¦V¥ª²¾¡ASHR ¬O¦V¥k²¾¡C
SHL °£¤F¨Ï¼È¦s¾¹¤ºªº¤G¶i¦ì¼Æ¦V¥ª²¾¼ÆӦ줸¥~¡AÁÙ¦³¼ªkªº¥\¯à¡C¥¦¥i¥H¥ß§Yºâ¥X¤Gªº¾¤èªº¼ªk¡C¨Ò¦p·í»Ýn±N AX ¤ºªº¼Æȼ¥H 2 ®É¥i¥H¥Î
shl ax,1
n¨Ï AX ¤ºªº¼Æȼ¥H 4 ®É¥i¥H¥Î
shl ax,2
n¨Ï AX ¤ºªº¼Æȼ¥H 8 ®É¥i¥H¥Î
shl ax,3
³oºØ±¡§Î¨ä¹ê©M§Ṳ́Q¶i¦ì¬Û¦ü¡A¨Ò¦p·í 25 ¦V¥ª²¾¤@¦ì¡A´NÅܦ¨ 250¡C®t§O¥u¦b¤@Ó¬O¤G¶i¦ì¡A¤@Ó¬O¤Q¶i¦ì¡Cµ{¦¡²Ä 31¡N32 ¦æªºì²z´N¦b³oùØ¡C·íµM SHR ¤]¦³°£¥H 2 ªº¾¤èªº¥\¥Î¡C
©Î³\±z·|°Ý¡A80X86 ¤£¬O¤]¦³ MUL »P DIV «ü¥O¶Ü¡H¬°¦ó¤£¥Î³o¨âÓ«ü¥O©O¡Hì¦]¬O³o¨âÓ«ü¥O©Òªá®É¶¡¤Óªø¤F¡A©Ò¥H¦pªG¼°£¤Gªº¾¤è¼Æ¥Î SHL ©Î SHR ¸û¬°¨³³t¡C( DIV «ü¥O´¿¦b²Ä¤»³¹»P²Ä¤C³¹¤¶²Ð¡A¦Ü©ó¼ªk«ü¥O½Ð¬Ý¥»³¹µù¤G¡C )
¦ì¤¸ | ³]¬°¤@®É¤§·N¸q |
0 | «ö¤U¥kÃ䪺 Shift Áä |
1 | «ö¤U¥ªÃ䪺 Shift Áä |
2 | «ö¤U Ctrl Áä |
3 | «ö¤U Alt Áä |
4 | ¦b Scroll Lock ª¬ºA |
5 | ¦b Num Lock ª¬ºA(¼Æ¦r) |
6 | ¦b Caps Lock ª¬ºA(¤j¼g) |
7 | ¦b´¡¤Jª¬ºA |
80x86 ®a±Úªº¼ªk«ü¥O¦³¨âºØ¡AMUL »P IMUL¡A«eªÌ¬O¥Î¨ÓpºâµL¸¹¼Æ¡A«áªÌ«h¬O¥Î¨Ópºâ¦³¸¹¼Æªº¡C¦¹³B¶È¤¶²Ð MUL¡A¦Ü©ó IMUL ¥Îªk½Ð°Ñ¾\²Ä 35 ³¹¡CMUL ªº»yªk¦p¤U¡G
MUL ¼È¦s¾¹©ÎÅܼÆ
80x86 ªº MUL «ü¥O¥i¥H¥Î¨Ópºâ 8¡B16¡B32 ¦ì¤¸ªº¼ªk¡A©Ò±oªº¼¿n¤j¤pÀ³¬° 16¡B32¡B64 ¦ì¤¸¡A¤À§O¦s©ó AX¡BDX:AX¡BEDX:EAX ¼È¦s¾¹¤¤¡C·í«ü¥O MUL ©Ò±µ¹Bºâ¤¸¡A¼È¦s¾¹©ÎÅܼơA¤j¤p¬°¤K¦ì¤¸®É¡A´Nªí¥Ü¦¹¹Bºâ¬O AL ¼¥H¦¹¤K¦ì¤¸ªº¼È¦s¾¹©ÎÅܼơA¦Ó©Ò±o¤§¼¿n¦s©ó AX ¼È¦s¾¹ùØ¡Aì¥ý AH ¤§È·|®ø¥¢¡F·í MUL ©Ò±µªº¹Bºâ¤¸¬O 16 ¦ì¤¸®É¡A´Nªí¥Ü¬O AX ¼¥H¦¹ 16 ¦ì¤¸ªº¹Bºâ¤¸¡A¦Ó©Ò±o¤§¼¿n¦s©ó DX:AX ¼È¦s¾¹ùØ¡Aì¥ý DX ¤§È·|®ø¥¢¡F·í MUL ©Ò±µªº¹Bºâ¤¸¬O 32 ¦ì¤¸®É¡A´Nªí¥Ü¬O EAX ¼¥H¦¹ 32 ¦ì¤¸ªº¹Bºâ¤¸¡A¦Ó©Ò±o¤§¼¿n¦s©ó EDX:EAX ¼È¦s¾¹ùØ¡Aì¥ý EDX ¤§È·|®ø¥¢¡C¾ã²z¦p¤Uªí¡G
¼ªk¤è¦¡ | ³Q¼¼Æ | ¼¼Æ | ¼¿n | ½d¨Ò | |
¹Bºâ«e | ¹Bºâ«á | ||||
8 ¦ì¤¸ | AL | 8 ¦ì¤¸¼È¦s¾¹ ©ÎÅÜ¼Æ | AX | AX=0105 BX=0106 MUL BL | AX=001E BX=0106 |
16 ¦ì¤¸ | AX | 16 ¦ì¤¸¼È¦s¾¹ ©ÎÅÜ¼Æ | DX:AX | AX=0200¡ADX=FFFF BX=0106 MUL BX | DX=0002¡AAX=0C00 BX=0106 |
32 ¦ì¤¸ ¥u¯à¥Î©ó 386µ¥¯Å¥H¤W | EAX | 32 ¦ì¤¸¼È¦s¾¹ ©ÎÅÜ¼Æ | EDX:EAX | EAX=80000001 EDX=88887777 EBX=00000002 MUL EBX |
EDX=00000001 EAX=00000002 EBX=00000002 |
¨Ò¦p¡A¦pªGnpºâ 9 ¼¥H 8¡A¥i¥H¥Î©³¤Uªº¤è¦¡¡G
mov al,9 mov bl,8 mul bl
³o¬O¦]¬° 9¡B8 ³£¤£¶W¹L 255 ( ÁÙ°O±o§a¡H¤K¦ì¤¸ªº¼È¦s¾¹©Î°O¾ÐÅé¼e«×¥i¥Hªí¥Ü 0 ¨ì 255 ½d³òªº¥¿¼Æ )¡A¦]¦¹³Q¼¼Æ¡B¼¼Æ³£¦s©ó¤K¦ì¤¸ªº¼È¦s¾¹ùØ¡A¦ý¬O¨Ì¾Ú 80x86 MUL »yªk¡A³Q¼¼Æ¥u¯à¥Î AL¡A©Ò¥H²Ä¤@¦æ¬°¡ymov al,9¡z¡A¦Ü©ó¼¼Æ¡A8¡A¥i©ñ©ó¥ô¦ó¤@Ó¤K¦ì¤¸ªº¼È¦s¾¹¡A¦p AH¡BBL¡BBH¡K¡K³£¥i¥H¡A¤]¥i¥H©ñ¦b¥H DB ©Ò©w¸qªº¤K¦ì¤¸°O¾ÐÅéÅܼÆùØ¡A³Ì«á¦A¥H«ü¥O¡ymul bl¡zpºâ¡A©Ò±o¼¿n·|¦b AX ¼È¦s¾¹ùØ¡C
MUL «ü¥O¤@¯ë¥Î¦b¹ïµL¸¹¼Æªºpºâ¡AµL¸¹¼Æ©Ò«üªº´N¬O¥¿¼Æ¡A¦pªGnpºâ¦³¸¹¼Æ¡A½Ð°Ñ¦Ò²Ä 35 ³¹¡C