¨Ï¥Î DEBUG ¼¶¼g²Õ¦X»y¨¥µ{¦¡ÁöµM¤è«K¡A¥i¥H¤Î®É§ó¥¿¿ù»~¡C¦ý¬O¹³²Ä¤T³¹ªº PRINTSTR.COM ©Î¬O KEYIN.COM µLªk¨Æ¥ý½T©w¸ê®Æ¦ì§}¡B©Î¬O¹J¨ì©¹«eªº¸õÅD«ü¥Oµ¥±¡§Î¡AµLªk¨Æ¥ý½T©w¦ì§}¡A´NÅã±o³Â·Ð¤F¡C³o¤@³¹¡A¤p¤ì°¸n¤¶²Ð³Ì±`¨£ªº¤è¦¡¨Ó¼¶¼g²Õ¦X»y¨¥¡A¤]¯à§ïµ½³oºØ¯ÊÂI¡A¨Ã¥B¥i¥H¼¶¼g¸û¤j¡B¸û½ÆÂøªºµ{¦¡¡C
»s§@²Õ¦X»y¨¥µ{¦¡ªº²Ä¤@¨B¡A³q±`¬O³W¹ºµ{¦¡»Ýn¦³þ¨Ç¥\¯à¡AµM«á¦A¶}©l¼¶¼gì©lµ{¦¡ ( source file ©Îì©l½X )¡C¼¶¼gì©l½X¡A¥²¶·¨Ï¥Î¤å®Ñ³B²z³nÅé¡A¨Ò¦p UltraEdit32¡A½s¼g¤@¦æ¤@¦æªºì©l½X¡C½s¼g¦n«á¡An¦s¦¨°ÆÀɦW¬°¡uASM¡vªº¯Â¤å¦rÀÉ¡C±µ¤U¨Ó¬O¸g¥Ñ²ÕĶ¾¹²ÕĶ ( ¹ï¨ä¥Lµ{¦¡»y¨¥¦Ó¨¥¡AºÙ¬°½sĶ )¡C
ì©l½X¸g¹L²ÕĶ«á¡A¦pªG»yªk¨S¿ù¡A´N¯à¦¨¥\²£¥Í¥ØªºÀÉ ( °ÆÀɦW¬°¡uOBJ¡v)¡CµM«á¬O¥Î³sµ²¾¹ ( LINK.EXE ) §â»s§@¥X¨Óªº¥ØªºÀÉ»Pµ{¦¡®w³sµ²°_¨Ó¡A¦pªG¯à¦¨¥\²£¥Í¥i°õ¦æÀÉ ( °ÆÀɦW¬O EXE ©Î COM )¡A³Ì«áÁÙn°õ¦æ¬Ý¬Ý¡A¬O§_¹F¨ì·íªì³W¹ºªº¥\¯à¡A¦pªG¯à¦¨¥\°õ¦æ¡A¤~ºâ¤j¥\§i¦¨¡C
°²¦p¦b²ÕĶ¹Lµ{¡A©Î³sµ²¹Lµ{¡A¬Æ¦Ü³Ì«á°õ¦æ®É¡A¦³¥ô¦ó¿ù»~µo¥Í¡A³£n«·sÀ˵øì©l½X¡A¬Ý¬Ý¿ù»~¬°¦ó²£¥Í¡An¦b¤å®Ñ³B²z¾¹¤¤×¥¿¿ù»~¡A³o¤@¨BÆJºÙ¬°¡u°£¿ù¡v¡C§ó¥¿©Ò¦³¿ù»~«á¡A¤Sn¦A¤@¦¸²ÕĶ¡B³sµ²¡B°õ¦æ¡Aª½¨ì¨S¦³¿ù»~µo¥Í¡A¥Bµ{¦¡¹F¨ì¹w´Á®ÄªG¡A¤~ºâ¬O§¹¦¨¡C¾ãÓ¹Lµ{¦p¤U¹Ï¡G
MASM 5.x ¤Î¨ä¥H«eªºª©¥»¡A¥²¶·¥Î²ÕĶ¾¹«á¡A¦A¥H¤H¤u¤è¦¡°õ¦æ³sµ²¾¹¡A´N¦p¦P¤W¹Ï©Òªí¥Üªº¨º¼Ë¡FMASM 5.x ¤Î¨ä¥H«eªºª©¥»¡A²ÕĶ¾¹¦WºÙ¬O MASM.EXE¡A³sµ²¾¹¦WºÙ¬O LINK.EXE¡C¨ì¤F MASM 6.x ª©®É¡A²ÕĶ¾¹¦WºÙ¬° ML.EXE¡A³sµ²¾¹¦WºÙ¤´¬O LINK.EXE¡A¦ý¬O ML.EXE ¦b²ÕĶ¦¨¥\«á¡A·|¦Û°Ê°õ¦æ LINK.EXE¡A¦P®É¤]¯à±N°Ñ¼Æ¶Çµ¹³sµ²¾¹¡A¦]¦¹¨Ï¥Î¸û¬°¤è«K¡C¤]´N¬O»¡¡AMASM 6.x «á¡A²ÕĶ»P³sµ²¤w¸g¥i¤w²¤Æ¦¨¤@Ó¨BÆJ¤F¡C
¦b°£¿ù¹Lµ{¡A¤j³¡¤À»yªk¤Wªº¿ù»~¡A²ÕĶ¾¹©Î³sµ²¾¹·|¦³´£¥Ü¡A¥u»Ýn«ö´£¥Üקï§Y¥i¡C¦ý¬O°õ¦æ¤Wªº¿ù»~¡A¨Ò¦pµLªk¹F¨ì¹w´Á®ÄªG¡A¬Æ¦Ü²£¥Í¿ù»~ªºµ²ªG¡A³o¨ÇÅÞ¿è¤Wªº¿ù»~¡A¤£©öªÈ¥X¨Ó¡C³o®ÉÔ¥²¶·¥Î°£¿ùµ{¦¡¡A¨Ò¦p DEBUG ©Î SYMDEB ¸ü¤Jµ{¦¡¡A¬Æ¦Ün¤@¨B¤@¨B°lÂÜ¡A¤~¯à¬d¥X¨Ó¡C
©³¤U¤p¤ì°¸´N¨Ó¤ñ¸û¡A¨Ï¥Î ML.EXE ²ÕĶì©lµ{¦¡»P¨Ï¥Î DEBUG ²ÕĶ¡An§ïÅܪº¦a¤è¦³þ¨Ç¡C¤p¤ì°¸´N¥Î²Ä¤G³¹§ÚÌ©Ò¼ô±xªº ASCII2.EXE ·í¦¨½d¨Ò»¡©ú¡C
¥Î ML.EXE ²ÕĶ»P DEBUG ²ÕĶ¤£¦P¤§³B¦b©ó¡An¥ý½s¼g¤@ÓºÙ¬°ì©lµ{¦¡ ( source file ©Îì©l½X ) ªº¯Â¤å¦rÀÉ¡A¨ä°ÆÀɦW¬O ASM¡A¦]¦¹¨äÀɦW¥i©R¦W¬° ASCII2.ASM¡C¥i¥H¥Î¥ô¦ó¤@ºØ¤å®Ñ³B²z³n¾¹¡A¨Ò¦p UltraEdit 32 ©Î°O¨Æ¥»¡A½s¼gì©lµ{¦¡¡C©³¤U¬O ASCII2.ASM ªº¤º®e¡G
1 2 3 4
5 6 7 8
9 10 11 12
13 14 |
.MODEL TINY ;¨Ï¥Î TINY °O¾ÐÅé¼Ò¦¡
;***************************************************************************************************
.CODE ;µ{¦¡½X°Ï¬q¶}©l
ORG 100h ;µ{¦¡½X¦b 100h ³B¶}©l
;---------------------------------------------------------------------------------------------------
start: mov cx,100h ;°õ¦æ256¦¸°j°é
mov ah,2 ;¨Ï¥Î AH¡×2/INT 21h DOS ªA°Èµ{¦¡
mov dl,0 ;²Ä¤@Ó¦r¤¸¬O½s¸¹ 0 ªº ASCII ¦r¤¸
next: int 21h ;©I¥s DOS ªA°Èµ{¦¡
inc dl ;¨Ï ASCII ½s¸¹¼W¥[¤@
loop next ;¨Ï CX ´î¤@¡AY¤£¬°¹s¸õ¨ì°j°é¶}©l³BÄ~Äò°õ¦æ
int 20h ;µ{¦¡µ²§ô
;***************************************************************************************************
END start ;ì©lµ{¦¡µ²§ô
|
¥Î¤å®Ñ³B²z³nÅé½s¼g¦n«á¡A¦s¤J¡uE:\HomePage\SOURCE\DOS\ASCII\ASCII2.ASM¡v¡Cnª`·Nªº¬O¡A¤@©wnÀx¦s¦b¡uE:\HomePage\SOURCE\¡v¤l¥Ø¿ý¤º©Î¬O³oÓ¤l¥Ø¿ý¤ºªº¡u®]¡v¥Ø¿ý¡A³o¬O¦]¬°n°t¦X¡uVirtual PC¡v¤ºªº¡uMS-DOS 6.20¡vµêÀÀ¾÷¾¹¡A³o¥xµêÀÀ¾÷¾¹»P¹êÅé¹q¸£¤WªºµwºÐ¦@¦P¤À¨É¡uE:\HomePage\SOURCE\¡v¤l¥Ø¿ý¡C( ¨£ªþ¿ý¤@¤À¨ÉÀÉ®× )
¦Ü©ó¤p¤ì°¸§âÀÉ®×Àx¦s¦b¡u®]¡v¥Ø¿ý¡uDOS\ASCII\¡vùØ¡A¬O¦]¬°¤p¤ì°¸¦b»s§@³oÓºô¶ÁÙ·|²o¯A¨ì Win32 ¤Î Win64 ²Õ¦X»y¨¥¡A©Ò¥H¤À¦¨³o¨Ç¥Ø¿ý¡A¤è«K¾ã²z¡C¦Ó DOS ¤l¥Ø¿ý¤]·|¤À¦¨³\¦h³¹¸`¡A¦]¦¹¤~·|³o¼Ë³]©w¡C
±µ¤U¨Ó¶}±Ò¡uMicrosoft Virtual PC¡v¡A¿ï¾Ü¡uMS-DOS 6.20¡vµêÀÀ¾÷¾¹°õ¦æ¡A¶i¤J DOS «á¡A¿é¤J¤U¦C«ü¥O¡A¥H«K²ÕĶ¡B³sµ²¤Î°õ¦æ¡G
C:\>e: [Enter] ¡÷¤Á´«¨ì E: E:\>cd \dos\ascii2 [Enter] ¡÷¤Á´«¨ì ASCII2.ASM ©Ò¦bªº¥Ø¿ý E:\DOS\ASCII>ml ascii2.asm [Enter] ¡÷²ÕĶ¨Ã³sµ² Microsoft (R) Macro Assembler Version 6.11 Copyright (C) Microsoft Corp 1981-1993. All rights reserved. Assembling: ascii2.asm Microsoft (R) Segmented Executable Linker Version 5.31.009 Jul 13 1992 ¡÷ML.EXE ¦Û°Ê°õ¦æ LINK.EXE Copyright (C) Microsoft Corp 1984-1992. All rights reserved. Object Modules [.obj]: ascii2.obj/t Run File [ascii2.com]: "ascii2.com" List File [nul.map]: NUL Libraries [.lib]: Definitions File [nul.def]: E:\DOS\ASCII>
°õ¦æ ASCII2.COM Àɦp¤U¹Ï¡G
¥E¬Ý¤§¤U¡Aµo²{¨Ï¥Î ML.EXE ²ÕĶ¡Aì©l½X«e±¡B«á±¦h¤F³\¦h¦æ¡A¦ü¥G«Ü¤£¤è«K¡A¦ý¬O³o¨Ç¦h¥X¨Óªº³¡¤À¡A¤£½×µ{¦¡½X¦h©Î¤Ö¡A³£´X¥G¤£ÅÜ¡C©³¤U´N¤£¦Pªº³¡¤À¡A¸Ô²Ó»¡©ú¡C
°²«ü¥O¡u.MODEL¡v¥Î¨Ó³]©w°O¾ÐÅé¼Ò¦¡ ( memory model )¡B»y¨¥Ãþ«¬ ( language type )¡B°ïÅ|©Ê½è ( stack option )¡C³q±`¡u.MODEL¡v©ñ¦bì©lµ{¦¡¤@¶}©lªº¦a¤è¡A¤@©wn©ñ¦b©w¸q¥ô¦ó°Ï¬q¤§«e¡A¦Ó¥B¥u¯à¥X²{¤@¦¸¡A¨ä»yªk¬O¡G
.MODEL °O¾ÐÅé¼Ò¦¡¡i,»y¨¥Ãþ«¬¡j¡i,°ïÅ|©Ê½è¡j
¥ý¨Ó»¡°O¾ÐÅé¼Ò¦¡¡A¦b DOS ¯u¹ê¼Ò¦¡¤U¡A°O¾ÐÅé¼Ò¦¡¦³¤»ºØ¡A«OÅ@¼Ò¦¡¥u¦³¤@ºØ¡A¦p¤Uªí¡G
°O¾ÐÅé¼Ò¦¡ | °Ï¬q¤À¥¬ |
TINY | ¸ê®Æ°Ï¬q¡Bµ{¦¡½X°Ï¬q³£¦b¦P¤@°Ï¬q¤º¡A³o¬O«Ø¥ß COM ¥i°õ¦æÀɪº°O¾ÐÅé¼Ò¦¡ |
SMALL | ¸ê®Æ°Ï¬q¡Bµ{¦¡½X°Ï¬q¦U¦b¤£¦Pªº¨âӰϬq |
COMPACT | ¥u¦³¤@Óµ{¦¡½X°Ï¬q¡A¦ý¬O¦³¦n´XÓ¤£¦P°Ï¬qªº¸ê®Æ°Ï¬q |
MEDIUM | ¥u¦³¤@Ó¸ê®Æ°Ï¬q¡A¦ý¬O¦³¦n´XÓ¤£¦P°Ï¬qªºµ{¦¡½X°Ï¬q |
LARGE | µ{¦¡½X°Ï¬q©M¸ê®Æ¬q³£¦³¦n´XÓ |
HUGE | µ{¦¡½X°Ï¬q©M¸ê®Æ¬q³£¦³¦n´XÓ¡A¨Ã¥B¦³¥²nªº¸Ü¡A¨äÅܼƪø«×¥i¥H¶W¹L 64KB |
FLAT | ¼¶¼g 32 ¦ì¤¸ªº Windows §@·~¨t²Î¨Ï¥Îªº°O¾ÐÅé¼Ò¦¡ |
¨Ï¥Î TINY °O¾ÐÅé¼Ò¦¡®É¡A·|²£¥Í COM ¥i°õ¦æÀÉ¡A³o¬O¦]¬° ML.EXE ·|¦Û°Ê§â¡u/TINY¡v( »P /T °Ñ¼Æ¬Û¦P ) °Ñ¼Æ¶Çµ¹ LINK.EXE¡A¥HP©óÅý LINK.EXE ²£¥Í COM ÀÉ¡CCOM ¥i°õ¦æÀɪº COM ¬O command ªº·N«ä¡CLINK.EXE ¥i¥H¤U¹F³\¦h°Ñ¼Æ¡A¨C¤@ºØ°Ñ¼Æªº·N¸q¤£¦P¡A¥i¥H¿é¤J¡uLINK /?¡v¬Ý¬Ý¦³þ¨Ç°Ñ¼Æ¡C
SMALL¡BCOMPACT¡BMEDIUM¡BLARGE¡BHUGE ³o¤ºØ°O¾ÐÅé¼Ò¦¡²£¥Í EXE ¥i°õ¦æÀÉ¡A³oºØ¥i°õ¦æÀɸû¬°½ÆÂø¡A¥i°Ñ¾\²Ä¤Q¤@³¹¡C
»y¨¥Ãþ«¬¡A¦³ C¡BBASIC¡BFORTRAN¡BPASCAL¡BSYSCALL »P STDCALL ¤»ºØ¡A³o¨Ç»y¨¥Ãþ«¬©M©I¥s®É°Ñ¼Æªº¦w±Æ¦³Ãö¡A¤]´N¬O»¡¡A»y¨¥Ãþ«¬¬O¥Î¨Ó³]©w©I¥s¨ó©w ( calling convention ) ¡A³oùضȦC¥Xªí®æ¤£»¡©ú¡Aµ¥¨ì²Ä¤Q³¹°Æµ{¦¡¡]¤G¡^®É¦A»¡©ú¡C
»y¨¥Ãþ«¬ | STDCALL | SYSCALL | C | BASIC | FORTRAN | PASCAL |
¥ÑþӰѼƶ}©l±À¤J°ïÅ| | ¥k | ¥k | ¥k | ¥ª | ¥ª | ¥ª |
½Öt³d²M°£°ïÅ| | °Æµ{¦¡ | ¥Dµ{¦¡ | ¥Dµ{¦¡ | °Æµ{¦¡ | °Æµ{¦¡ | °Æµ{¦¡ |
¬O§_¤¹³\¤£©w°Ñ¼Æ | ¬O ( ¨£©³¤U ) | ¬O | ¬O | §_ | §_ | §_ |
¥J²ÓÀˬd¤W±»y¨¥Ãþ«¬ªºªí®æ¡A§A´N·|µo²{¡A¨Æ¹ê¤W BASIC¡BFORTRAN¡BPASCAL ³o¤TºØ»y¨¥Ãþ«¬¨ä¹ê¬O¤@¼Ò¤@¼Ë¡CSTDCALL ªº°ïÅ|²M°£¥®É¬O¥Ñ°Æµ{¦¡§¹¦¨¡A¦ý¨Ï¥Î VARARG ®É¬O¥Ñ¥Dµ{¦¡²M°£ªº¡C
°ïÅ|©Ê½è¥u¦³¨âºØ¿ï¶µ¡G①NEARSTACK¡G°ïÅ|°Ï¬q»P¸ê®Æ°Ï¬q¦b¦P¤@°Ï¬q¡A¦pªG¬Ù²¤¡u°ïÅ|©Ê½è¡v¡A¹w³]Ȭ° NEARSTACK¡F②FARSTACK¡G°ïÅ|°Ï¬q»P¸ê®Æ°Ï¬q¦b¤£¦P°Ï¬q¡A¥B°ïÅ|°Ï¬q¤£¦b°Ï¬q¸s²Õ ( DGROUP ) ¤º¡C
¦b²Õ¦X»y¨¥ì©lµ{¦¡ùØ¡Aµ{¦¡½X·|©ñ¦bµ{¦¡½X°Ï¬q¤¤¡A¸ê®Æ·|©ñ¦b¸ê®Æ°Ï¬qùØ¡Cµ{¦¡½X°Ï¬q¥Ñ .CODE ³B¶}©l¡A¦¹°Ï¬q¶}©l¤§³B¡A¤]¬O¤W¤@ӰϬqªºµ²§ô¤§³B¡C¦P¼Ëªº¡A¸ê®Æ°Ï¬q¥Ñ .DATA ³B¶}©l¡A¦¹°Ï¬q¶}©l³B¤]¬O¤WӰϬqµ²§ô¤§³B¡C¥¦Ìªº»yªk¦p¤U¡G
.CODE ¡i°Ï¬q¦WºÙ¡j .DATA
.CODE »P .DATA ³o¨â±ø°²«ü¥O¤À§O©w¸q¤Fµ{¦¡½X°Ï¬q»P¸ê®Æ°Ï¬q¥Ñ¦¹¶}©l¡C¨Æ¹ê¤W¡A©w¸q°Ï¬q¦³Â²©ö»P§¹¾ã¨âºØ¤èªk¡A³oùرĥβ©öªº¤èªk©w¸qµ{¦¡½X»P¸ê®Æ°Ï¬q¡A²Ä¤Q¤@³¹¦A»¡©ú§¹¾ãªº°Ï¬qÀ³¦p¦ó©w¸q¡C
¨CӰϬq³£¦³¦WºÙ¡A¨Ï¥Î²©ö¤è¦¡©w¸q°Ï¬q®É¡A°Ï¬q¦WºÙ±Ä¥Î¤º©w¦WºÙ¡C¦b TINY¡BSMALL¡BCOMPACT¡BFLAT °O¾ÐÅé¼Ò¦¡®É¡Aµ{¦¡½X°Ï¬qªº¤º©w¦WºÙ¬O¡u_TEXT¡v¡F¦pªG¬O MEDIUM¡BLARGE¡BHUGE ¼Ò¦¡®É¡A¤º©wªº¦WºÙ¬O¡uµ{¦¡¦WºÙ_TEXT¡v¡C¸ê®Æ°Ï¬qªº¤º©w¦WºÙ³£¬O¡u_DATA¡v¡C¡u.CODE¡v©Î¡u.DATA¡v³£¥²¶·¦b¡u.MODEL¡v¤§«á¡C
¹ï©ó TINY ¼Ò¦¡¦Ó¨¥¡Aµ{¦¡½X°Ï»P¸ê®Æ°Ï¬q³£¦b¦P¤@°Ï¬q¡A¦]¦¹©w¸qµ{¦¡½X°Ï¬q¤§«á¡A¤£»Ýn©w¸q¸ê®Æ°Ï¬q¡C¨º¥i¤£¥i¥H¥u©w¸q¸ê®Æ°Ï¬q©O¡H³o¬O¤£¦æªº¡Aì¦]¬O§A±o§i¶D¹q¸£¸Ó°õ¦æ¤°»ò«ü¥O¤~¦æ¡C
¦b²Õ¦X»y¨¥ì©lµ{¦¡ùØ¡A¡u;¡v¥i¥H¦b¤@¦æùتº¥ô¦ó¦ì¸m¡A¤Z¬O¦b¡u;¡v¤§«á¨ì¤@¦æµ²§Àªº¤å¦r³£·|³Q²ÕĶ¾¹©¿²¤¡A¥i¥H§@¬°µù¸Ñ¤§¥Î¡Cµù¸Ñ¬OÅý¤Hª¾¹D¡A³o¤@¦æ©Î³o´X¦æµ{¦¡ªº§@¥Î¡AÅý¤H¯à°÷¤F¸Ñµ{¦¡¹B§@¡A¶i¦Óקï©Î°£¿ù¡Cµ{¦¡³]pªº¤HÀ³¾¨¶q¯d¤Uµù¸Ñ¡A¥H«K¤é«áקï¡C§Y¨Ï¦b§A½s¼gµ{¦¡ªº·í¤U¡A«Ü²M·¡µ{¦¡ªº¤j¤p²Ó¸`¡A¦ý¹L¤F´X¶g¡B´XÓ¤ë´N®e©ö²H§Ñ¡A¦]¦¹¤£¥i¤£¯d¤Uµù¸Ñ¡C
¦bì©l½Xùر¡A¼g¤Uªºµù¸Ñ³Ì¦n»¡©úºtºâªk¡B©Ò¥Îªºì²z¡BÅܼƩҥNªíªº·N¸q¡K¡K©Î¬O·í®Éªº·Qªkµ¥µ¥¡A¶V¸Ô²Ó¶V¦n¡F¤£n¼g¤@¨ÇµL·N¸qªºµù¸Ñ¡A¨Ò¦p¤U±ªºµù¸Ñ¬O¨S¦³·N¸qªº¡C
;*************************************** ;³o¬Oµù¸Ñ
¦³®Éµù¸Ñ¤Óªø¡A¥²¶·¨Ï¥Î¦n´X¦æ¤å¦r®É¡A¥i¥H¥Î COMMENT ¨Ó·í¦¨µù¸Ñ¡ACOMMENT ªº»yªk¬O¡G
COMMENT ¤À¹j¦r¤¸ µù¸Ñ¤å¦r ¤À¹j¦r¤¸
¤À¹j¦r¤¸¥i¥H¬O¥ô·N¦r¤¸¡A¦ý¬O¤£¥i¥H¥X²{¦bµù¸Ñ¤å¦r¤¤¡A°²¦p³o¼Ëªº¸Ü¡A²ÕĶ¾¹·|»{¬°µù¸Ñµ²§ô¤F¡A¦Óµo¥Í¿ù»~¡Cµù¸Ñ©ñ¦b¨âÓ¤À¹j¦r¤¸¤§¶¡¡A¥i¥H¦³³\¦h¦æ¡A¥B«e±¤£»Ýn¥[¤W¡u;¡v¡C
ASCII2.ASM ªº²Ä¨C¤@¦æªº«á±³£¦³¡u;¡v¡A³o¬Oµù¸Ñ¡C¬Æ¦ÜÁÙ¦³²Ä 2¡B5¡B13 ¦æ¡A¾ã¦æ³£¬Oµù¸Ñ¡A³o¤T¦æ¬O¬°¤F¤À¶}°Ï¬q»P°Æµ{¦¡¡C
±µµÛ»¡©ú²Ä¥|¦æªº¡uORG 100h¡v¡CORG ªº»yªk¬O
ORG ¦ì§}
¤W±ªºªº¦ì§}¬O¥Î¨Ó«ü©w¦b ORG ¤§«áªº«ü¥O¦b¦¹¦ì§}¶}©l¡C
·í DOS ¸ü¤J COM ¥i°õ¦æÀÉ°õ¦æ®É¡ADOS ·|«O¯d°Ï¬q«eªº 256 Ӧ줸²Õ¡A§@¬° COM °õ¦æÀÉ»P¨t²Î¥æ´«¸ê®Æ©Ò¥Î¡A³o¶ô°Ï°ìºÙ¬°¡uµ{¦¡«e¸m°Ï¡v( program segment prefix¡A²ºÙ PSP )¡C¦]¦¹µ{¦¡¥²¶·±q²Ä 256 ¦ì¤¸²Õ¥H«á¡A¦]¦¹¥Î¡uORG 100h¡vÅýµ{¦¡±q 100h ¶}©l¡C
¦b DEBUG ùر¡A¼Æ¦r¨t²Î¥u¯à¨Ï¥Î¤Q¤»¶i¦ì¡C¦ý¥Î ML.EXE ²ÕĶ®É¡A¼Æ¦r¨t²Î¥i¥H¥Î¤Q¶i¦ì¡B¤G¶i¦ì¡B¤K¶i¦ì©M¤Q¤»¶i¦ì¡A¹w³]¬O¤Q¶i¦ì¡C¦pªG¬YÓ¼ÆÈn¨Ï¥Î¨ä¥L¶i¦ì¨t²Î¡A¥²¶·¦b¼ÆȫᱼХܡA¤G¶i¦ì¼Ð¥Ü¡ub¡v¡B¤K¶i¦ì¼Ð¥Ü¡uo¡v¡B¤Q¤»¶i¦ì¼Ð¥Ü¡uh¡v¡A¤Q¶i¦ì¼Ð¥Ü¡ud¡v¡A³o¨Ç b¡Bo¡Bh¡Bd ¤]¥i¥H¥Î¤j¼g¡C¡u100h¡v´Nªí¥Ü¤Q¤»¶i¦ìªº 100¡A´«ºâ¦¨¤Q¶i¦ì´N¬O 256D¡C
¤Q¤»¶i¦ìªº¼ÆÈ¥]§t A¡ãF¡A¦pªG¤Q¤»¶i¦ìªº¼ÆȬO¥H A¡ãF °_ÀY¡A¥²¶·¦b³Ì«e±¥[¤W¡u0¡v¡A§_«h ML.EXE ·|»{¬°¬OÅܼƦWºÙ¡C¨Ò¦p¤Q¶i¦ìªº 160 µ¥©ó¤Q¤»¶i¦ìªº A0¡A¦ý¬O¤£¥i¼g¦¨¡uA0H¡v¡A¥²¶·¼g¦¨¡u0A0H¡v¡A§_«h²ÕĶ¾¹·|§â A0 ·í¦¨ÅܼƦWºÙ¡C¨Ò¦p©³¤Uªºµ{¦¡¡G
MOV AX,A0H ¡÷¿ù»~ MOV AX,0A0H ¡÷¥¿½T
¦b ASCII2.ASM ªº²Ä¤»¡B²Ä¤E¦æ¤@¶}©lªº¡ustart:¡v»P¡unext:¡v³£¬O©w¸q¬YӼаO¡A¤]¦³®ÑÄy½Ķ¦¨¼ÐÅÒ¡C¼Ð°O¬O¥H¡u:¡vµ²§À¡C¨Æ¹ê¤W¡A¸g¹L²ÕĶ«á¡A¼Ð°O¬O¬YÓ¦ì§}¡A©M²Ä¤G³¹¥Î DEBUG ²ÕĶªº ASCII2.COM ¬Û¤¬¤ñ¸û¡A´N«Ü²M·¡¤F¡C
¦b DEBUG ùØ¥H¦ì§}ªí¥Ü¡A¸ûÃø²z¸Ñ¡F¦ý¦bì©lµ{¦¡¤¤¡A¥H¤å¦rªí¥Ü¡A´N«Ü¦n²z¸Ñ¤F¡C°£¦¹¤§¥~¡A¥Î ML.EXE ²ÕĶì©lµ{¦¡¡AML.EXE ·|¦Û¦æpºâ¼Ð°O©Ò¥Nªíªº¦ì§}¡A¤£¶·¤H¤upºâ¡A«D±`¤è«K¡C
¼Ð°Oªº²Ä¤@Ó¦r¥²¶·¥H^¤å¦r¥À¡B©³½u¡B@¡B?¡B$ µ¥¬°¶}ÀY¡A¨ä«áÁÙ¥i¥H¥Îªü©Ô§B¼Æ¦r¡A·íµM^¤å¡B©³½u¡B@ ¤´µM¥i¥H¨Ï¥Î¡C¹ï ML.EXE 6.11 ª©¨Ó»¡¡A³Ì¦h¥u¯à±µ¨ü 247 Ó¦r¤¸ªº¼Ð°O¡A¤w¸g«D±`¨¬°÷¤F¡C¥t¥~¼Ð°O¤£¯à©M°²«ü¥O©Î¬O x86/x87 «ü¥O¶°¤@¼Ë¡C
ASCII2.ASM ³Ì«á¤@¦æªº END °²«ü¥O¡AEND ªº»yªk¬O¡G
END ¼Ð°O
END ¬O§i¶D²ÕĶ¾¹¡Aì©l½X¨ì¦¹µ²§ô¡CEND «á±±µµÛªº¼Ð°O¬Oµ{¦¡ªº¶i¤JÂI¡A³oӼаOÀ³¸Ón¦bµ{¦¡½X°Ï¬q¤¤ªº¬Y³B¡A¦¹³B¬Oµ{¦¡²Ä¤@Ó°õ¦æªº x86 «ü¥O¡C¦pªG¦b END ¤§«áÁÙ¦³¤å¦r¡A³£·|³Q²ÕĶ¾¹©¿²¤¡A©Ò¥Hµù¸Ñ¤]¥i¥H©ñ¦b END ¤§«á¡C
±q¤W±¬Ý¨Ó¡A²Õ¦X»y¨¥ì©lµ{¦¡³£¦³ÓÃþ¦üªº¼ÒªO¡A©ÎªÌ»¡¦³Ãþ¦üªº¬[ºc¡C¦pªG¬O½s¼g COM ¥i°õ¦æÀÉ¡A¼ÒªO¦p¤U¡G
.MODEL TINY ;¨Ï¥Î TINY °O¾ÐÅé¼Ò¦¡ ;*************************************************************************************************** .CODE ;µ{¦¡½X°Ï¬q¶}©l ORG 100h ;µ{¦¡½X¦b 100h ³B¶}©l ;--------------------------------------------------------------------------------------------------- start: jmp begin ;¸ê®Æ¦ì©ó¦¹³B ;¸ê®Æ¦ì©ó¦¹³B begin: ;µ{¦¡½X¦ì©ó¦¹³B ;µ{¦¡½X¦ì©ó¦¹³B int 20h ;*************************************************************************************************** END start
²Ä¤T³¹®É¡A¤¶²Ð¤F¤@Ó PRINTSTR.COM µ{¦¡¡A²{¦b¤p¤ì°¸±N¥¦¼g¦¨ PRINTSTR.ASM ì©l½X¡A¥Î ML.EXE ²ÕĶ¨Ã³sµ²¡Aì©l½X¦p¤U¡G
1 2 3 4
5 6 7 8
9 10 11 12
13 |
.MODEL TINY ;¨Ï¥Î TINY °O¾ÐÅé¼Ò¦¡
;***************************************************************************************************
.CODE ;µ{¦¡½X°Ï¬q¶}©l
ORG 100h ;µ{¦¡½X¦b 100h ³B¶}©l
;---------------------------------------------------------------------------------------------------
start: jmp begin
string DB "I love assembly language.$"
begin: mov ah,9
mov dx,OFFSET string
int 21h
int 20h
;***************************************************************************************************
END start |
§â¤W±ªºÀɮצs¦¨¡uE:\HomePage\SOURCE\DOS\PRINTSTR\PRINTSTR.ASM¡v«á¡A±Ò°Ê¡uVirtual PC¡v¤ºªº¡uMS-DOS 6.20¡vµêÀÀ¾÷¾¹¡CµM«á¤Á´«¨ì¡uE:\DOS\PRINTSTR¡v¤l¥Ø¿ý¡G
C:\>e: [Enter] ¡÷¤Á´«¨ì E: E:\>cd \dos\printstr [Enter] ¡÷¤Á´«¨ì PRINTSTR.ASM ©Ò¦bªº¥Ø¿ý E:\DOS\PRINTSTR>ml printstr.asm [Enter] ¡÷²ÕĶ¨Ã³sµ² Microsoft (R) Macro Assembler Version 6.11 Copyright (C) Microsoft Corp 1981-1993. All rights reserved. Assembling: ascii2.asm Microsoft (R) Segmented Executable Linker Version 5.31.009 Jul 13 1992 Copyright (C) Microsoft Corp 1984-1992. All rights reserved. Object Modules [.obj]: printstr.obj/t Run File [ascii2.com]: "printstr.com" List File [nul.map]: NUL Libraries [.lib]: Definitions File [nul.def]: E:\DOS\PRINTSTR>printstr [Enter] ¡÷°õ¦æ PRINTSTR I love assembly language. E:\DOS\PRINTSTR>
OFFSET ªº»yªk¬O
OFFSET ¹Bºâ¤¸
¦b PRINTSTR.ASM ªº²Ä¤E¦æ«ü¥O¬O¡umov dx,OFFSET string¡v¨ä¤¤ªº OFFSET ¬O¤°»ò·N«ä©O¡H¹ï·Ó²Ä¤T³¹¦b DEBUG ªº PRINTSTR.COM ±oª¾¡A³o¤@¦æ¬On§â¦r¦êªº¦ì§}¡A¶ñ¤J¨ì DX ùØ¡A¦b DEBUG ùت½±µ¶ñ¼g¦r¦êªº¦ì§}§Y¥i¡A¦ý¬On¶ñ¤Jªº¼ÆȬO¦h¤Ö¡A±o§âµ{¦¡¼g¦n¤~¯àª¾¹D¦r¦ê¦ì§}¡A¦pªGn¥Î¤âºâ¡A«D±`³Â·Ð¡C
°²¦pn¥Î ML.EXE ²ÕĶ¡A´N±o¨Ï¥Î¡uOFFSET¡v¹Bºâ¤l¡COFFSET ´N¬OÅý²ÕĶ¾¹¡A§â OFFSET «á±±µµÛªº¹Bºâ¤¸°¾²¾¦ì§}pºâ¥X¨Ó¡A¦A°µ¨ä¥L¥Î³~¡A¨Ò¦p¡umov dx,OFFSET string¡v´N¬OÅý ML.EXE ¥hpºâ string ªº¦ì§}¡AµM«á§â¦ì§}¦s¤J DX ¼È¦s¾¹¡Cn±j½Õªº¬O¡A¬O string ªº¦ì§}¡A¨Ã¤£¬O string ªº¤º®e¡C
¦p¥k¹Ï©Ò¥Ü¡Astring ¦b¦ì§} 0102 ³B¡A¦]¦¹¡uOFFSET string¡v¨ä¹ê´N¬O¥Nªí 0102¡A¡umov dx,OFFSET string¡v¨ä¹ê´N¬O¡umov dx,0102¡v¡A°õ¦æ§¹¦¹«ü¥O«á¡ADX ´Nµ¥©ó 0102 ¤F¡C
¨º°²¦p§â²Ä¤E¦æ¼g¡umov dx,string¡v¥i¤£¥i¥H©O¡Hµª®×¬O¤£¥i¥Hªº¡A·|³y¦¨²ÕĶ¤Wªº¿ù»~¡C¦]¬°©w¸q string ¬O¥H¦ì¤¸²Õ©w¸q¡A¦Ó DX ªºªø«×¬O¦r²Õ¡Aªø«×¤£¦P©ó¬O²£¥Í¿ù»~¡C°²¦p§â²Ä¤C¦æ§ï¦¨¡ustring DW "I love assembly language.$"¡v¬O§_¥i¦æ¡Hµª®×¬O¤£¦æ¡A¦]¬°«á±ªº¦r¦ê¤Óªø¤Ó¤j¡AµLªk¦s¤J DX ùØ¡C°²¦p§â²Ä¤C¦æ¼g¦¨¡ustring DW "I "¡v¬O§_¥i¦æ¡Hµª®×¬O¥i¥¿±`²ÕĶ¤£·|¥X¿ù¡A¦ý¬O°õ¦æ«áµ²ªG¤£¹ï¡A³o¬O¦]¬°¦¹«ü¥O¬O§â¤Q¤»¶i¦ìªº 4920H ¦s¤J DX ùØ ( I ªº ASCII ½X¬° 49H¡AªÅ¥Õªº ASCII ½X¬O 20H )¡C
ÁÙ¦³¤@Ó¹Bºâ¤l»P OFFSET Ãþ¦ü¡A¨º´N¬O SEG¡A³oÓ«ü¥O¬Opºâ¹Bºâ¤¸ªº°Ï¬q¦ì§}¡C¨ä»yªk¬O
SEG ¹Bºâ¤¸
¥»³¹©ÒnÁ¿zªºÆ[©À´N¦¹µ²§ô¡A©³¤U¨Ó¦^ÅU¥»³¹¤º®e¡C
¥H¤å®Ñ³B²z³nÅé½s¼gì©l½X¡A¨Ã±Nì©l½X¦s¦¨°ÆÀɦW¬° ASM ªº¯Â¤å¦rÀÉ¡CµM«á¶}±Ò Microsoft Virtual PC ¤¤ªº MS-DOS 6.20 µêÀÀ¾÷¾¹¡A¤Á´«¨ìì©l½Xªº¤l¥Ø¿ý¡A¿é¤J¡uML ì©l½X.ASM¡v²ÕĶ¨Ã³sµ²¡C¦p¦³¿ù»~¡A¦^¨ì¤å®Ñ³B²z³nÅéÀˬdì©l½X¡C¦pªG¨S¦³¿ù»~¡A¨Ã¥¿±`°õ¦æ¡A¨º´N¦¨¥\¤F¡C
¡u.MODEL¡v¥Î¨Ó³]©w°O¾ÐÅé¼Ò¦¡¡B©I¥s¨ó©w¡B°ïÅ|©Ê½è¡C¹ï©ó COM µ{¦¡¦Ó¨¥¡AÀ³¸Ó¦bµ{¦¡ªº¤@¶}©l¡A³]©w¡u.MODEL TINY¡v¡C³o¼Ë¡A¦b²ÕĶ§¹¦¨«á¡AML.EXE ·|¦Û°Ê§â¡u/TINY¡v°Ñ¼Æ¶Çµ¹ LINK.EXE¡A¨Ï LINK.EXE »s³y¥X COM ¥i°õ¦æÀÉ¡C
.CODE »P .DATA ¤À§O¬O¥Î¨Ó©w¸qµ{¦¡½X°Ï¬q»P¸ê®Æ°Ï¬qªº¶}©l¡A¦P®É¤]¬O¤WӰϬqªºµ²§ô¡C
³o¨âÓ°²«ü¥O¬O¥Î¨Ó§@¬°µù¸Ñ¥Îªº¡C¦b¡u;¡v¤§«áªº¬Oµù¸Ñ¡A·|³Q²ÕĶ¾¹©¿²¤¡A§@¬°µù¸Ñ¥Î¡C¦Ó COMMENT ªº»yªk¬O
COMMENT ¤À¹j¦r¤¸ µù¸Ñ ¤À¹j¦r¤¸
¦b¤À¹j¦r¤¸¤§¶¡ªº¤å¦r¡A³£¬Oµù¸Ñ¡A¦Ó¥B¥i¥H¦³³\¦h¦æ¡C
ORG ªº»yªk¬O
ORG ¦ì§}
ORG «ü©w¨ä«áªº«ü¥O¥Ñ¤W±ªº¦ì§}¶}©l¡C
¼Ð°O¬O¬YÓ¦ì§}¡A¥H¡u:¡vµ²§ô¡A¥H¼Ð°O¥N´À¦ì§}¡A¤è«K¤£¤Ö¡C
END ªº»yªk¬O
END ¼Ð°O
END ¥Nªíì©l½X¨ì¦¹µ²§ô¡A¨ä«á©Ò±µµÛªº¼Ð°O¥Nªíµ{¦¡¶i¤JÂI¡C
OFFSET »P SEG ªº»yªk¤À§O¬O
OFFSET ¹Bºâ¤¸ SEG ¹Bºâ¤¸
³o¨âÓ°²«ü¥O³£¬O¥Î¨Ó¨ú±o¨ä«á©Ò±µµÛªº¹Bºâ¤¸¦ì§}¡AOFFSET ¨ú±oªº¬O¹Bºâ¤¸ªº°¾²¾¦ì§}¡ASEG ¨ú±oªº¬O¹Bºâ¤¸ªº°Ï¬q¦ì§}¡C
n»s§@ COM Àɪºì©lµ{¦¡¼ÒªO¦p¤U¡G
.MODEL TINY ;********************************************************************* .CODE ORG 100h ;--------------------------------------------------------------------- start: jmp begin ;¸ê®Æ¦ì©ó¦¹³B begin: ;µ{¦¡½X¦ì©ó¦¹³B ;µ{¦¡½X¦ì©ó¦¹³B int 20h ;********************************************************************* END start