¡¡¤³¤ì¤Þ¤ÇÀâÌÀ¤·¤¿¤è¤¦¤Ë¡¢MSX BASIC ver2.0¤Ï¶¯ÎϤʵ¡Ç½¤òÈ÷¤¨¤Æ¤¤¤Þ¤¹¤¬¡¢¤µ¤é¤Ë¼Â¹Ô®ÅÙ¤ò¾å¤²¤¿¤¤¡¢¤¢¤ë¤¤¤ÏMSX2¤Î¥Ï¡¼¥É¥¦¥§¥¢µ¡Ç½¤ò¤È¤³¤È¤ó¤Þ¤Ç°ú¤½Ð¤·¤¿¤¤¤È»×¤Ã¤¿¤é¡¢¤ä¤Ï¤ê¤É¤¦¤·¤Æ¤â¿¾¯¤Î¥Þ¥·¥ó¸ì¤Ï»ÈÍѤ»¤¶¤ë¤òÆÀ¤Þ¤»¤ó¡£ËܾϤǤϡ¢¤½¤ÎɬÍפ¬À¸¤¸¤¿»þ¤Î¤¿¤á¤Ë¡¢BASIC¤«¤é¥Þ¥·¥ó¸ì¥×¥í¥°¥é¥à¤ò¸Æ¤Ó½Ð¤¹ÊýË¡¡¢¤ª¤è¤Ó¤½¤ÎºÝ¤ËÃΤäƤª¤¯¤Ù¤¤¤¤¯¤Ä¤«¤Î¾ðÊó¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹¡£
4.1¡¡USR´Ø¿ô
¡¡BASIC¤«¤é¤Î¥Þ¥·¥ó¸ì¤Î¸Æ¤Ó½Ð¤·¤Ï¡¢°Ê²¼¤Î¼ê½ç¤Ç¹Ô¤¤¤Þ¤¹¡£USR´Ø¿ô¤Î¥«¥Ã¥³¤ÎÃæ¤Ï¡¢°ú¿ô¤È¤·¤Æ¥Þ¥·¥ó¸ì¤ËÃͤòÅϤ¹¤¿¤á¤ËÍѤ¤¤é¤ì¤Þ¤¹¡£°ú¿ô¤Ï¿ô¼°¡¢Ê¸»ú¼°¤Î¤¤¤º¤ì¤Ç¤â¤«¤Þ¤¤¤Þ¤»¤ó¡£
¡¡¡¡¡ DEF USRʸ¤Ç¡¢¥Þ¥·¥ó¸ì¥×¥í¥°¥é¥à¤Î¼Â¹Ô³«»Ï¥¢¥É¥ì¥¹¤ò»ØÄꤹ¤ë¡£
¡¡¡¡¢ USR´Ø¿ô¤Ç¥Þ¥·¥ó¸ì¤ò¸Æ¤Ó½Ð¤¹¡£
¡¡¡¡£ ¥Þ¥·¥ó¸ì¤«¤éBASIC¤ËÌá¤ë¾ì¹ç¤Ï¡¢RETÌ¿Îá(C9H)¤ò¼Â¹Ô¤¹¤ë¡£
Îã)¡¡C000ÈÖÃϤ¬¼Â¹Ô¥¢¥É¥ì¥¹¤Ç¤¢¤ë¥Þ¥·¥ó¸ì¥×¥í¥°¥é¥à¤ò¸Æ¤Ó½Ð¤¹¡£
DEF USR=&HC000 A=USR(0)
4.2¡¡USR´Ø¿ô¤Î°ú¿ô¤ÈÌá¤êÃͤˤè¤ë¥Ç¡¼¥¿¤Î¼õ¤±ÅϤ·
¡¡BASIC¤«¤é¥Þ¥·¥ó¸ì¤Ë°ú¿ô¤òÅϤ¹¾ì¹ç¡¢¥Þ¥·¥ó¸ì¦¤Ç¤Ï¥ì¥¸¥¹¥¿A¤ÎÆâÍÆ¤Ç¤½¤Î·¿¤òÃΤ뤳¤È¤¬¤Ç¤¤Þ¤¹(ɽ2.23)¡£ÌÜŪ¤ÎÃͤϰú¿ô¤Î·¿¤Ë¤è¤ê¿Þ2.13¤Î¤è¤¦¤Ê·Á¼°¤Ç³ÊǼ¤µ¤ì¤Æ¤¤¤Þ¤¹¤«¤é¡¢¤½¤ì¤Ë±þ¤¸¤ÆÃͤò¼õ¤±¼è¤ê¤Þ¤¹¡£Îã¤È¤·¤Æ¡¢Ê¸»úÎ󷿤ΰú¿ô¤ò¼õ¤±¼è¤ë¥×¥í¥°¥é¥à¤ò¥ê¥¹¥È2.1¤Ë¼¨¤·¤Þ¤¹¡£
2 | 2¥Ð¥¤¥ÈÀ°¿ô·¿ |
3 | ʸ»úÎó·¿ |
4 | ñÀºÅټ¿ô·¿ |
8 | ÇÜÀºÅټ¿ô·¿ |
ɽ2.23¡¡¥ì¥¸¥¹¥¿A¤ËÂåÆþ¤µ¤ì¤ë°ú¿ô¤Î·¿
¥ê¥¹¥È2.1¡¡Ê¸»ú·¿¤Î°ú¿ô¤Î»ÈÍÑÎã
;============================================================ ; List 2.1 print string with USR function ; to use, do DEF USR=&HB000 : A$=USR("STRING") ;============================================================ ; CHPUT EQU 00A2H ;character output ORG 0B000H RDARG: CP 3 RET NZ ;parameter is not string PUSH DE POP IX ;IX := string descriptor LD A,(IX+0) ;get string length LD L,(IX+1) ;get string pointer(low) LD H,(IX+2) ;get string pointer(high) OR A RET Z ;if length=0 RD1: PUSH AF LD A,(HL) ;get a character CALL CHPUT ;put a character POP AF DEC A RET Z INC HL JR RD1 END
¡¡µÕ¤Ë¡¢°ú¿ô¤È¤·¤ÆÅϤµ¤ì¤¿¤³¤ì¤é¤ÎÃͤò¥Þ¥·¥ó¸ì¤ÎÃæ¤Ç½ñ¤´¹¤¨¤ë¤³¤È¤Ë¤è¤Ã¤ÆUSR´Ø¿ô¤ÎÃͤȤ·¤ÆBASIC¤Ë°ú¤ÅϤ¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£¤³¤Î¾ì¹ç¡¢VALTYP(F663H)¤òÊѹ¹¤¹¤ë¤³¤È¤Ë¤è¤êÌá¤êÃͤòBASIC¤«¤é¤Î°ú¿ô¤Î·¿°Ê³°¤Î¤â¤Î¤ËÊѹ¹¤¹¤ë¤³¤È¤â²Äǽ¤Ç¤¹¡£¤¿¤À¤·¡¢Ê¸»úÎ󷿤ξì¹ç¡¢Ê¸»ú¿ô¤òÊѤ¨¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£
4.3¡¡Ì¿Îá¤ÎÁýÀß
¡¡MSX¤Ç¤Ï¸½ºß¡ÈCMD¡É¤È¡ÈIPL¡É¤È¤¤¤¦Í½Ìó¸ì¤¬Ì¤»ÈÍѤˤʤäƤª¤ê¡¢¤³¤ÎͽÌó¸ì¤Î¥Õ¥Ã¥¯(¤½¤ì¤¾¤ìFE0DH,FE03H)¤ò¼«Ê¬¤ÇºîÀ®¤·¤¿Ç¤°Õ¤Î¥Þ¥·¥ó¸ì¥ë¡¼¥Á¥ó¤Ë¥¸¥ã¥ó¥×¤¹¤ë¤è¤¦½ñ¤´¹¤¨¤ë¤À¤±¤Ç¡¢¿·¤·¤¤Ì¿Îá¤òºîÀ®¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£´Êñ¤ÊÎã¤ò¥ê¥¹¥È2.2¤Ë¼¨¤·¤Þ¤¹¡£
¥ê¥¹¥È2.2¡¡CMDÌ¿Îá¤ÎÁýÀß
;================================================================= ; List 2.2 make CMD command ( turn on/off the CAPS LOCK ) ; to initialize command: DEF USR=&HB000 : A=USR(0) ; to use command: CMD ;================================================================= ; CHGCAP EQU 0132H ;CAPS LAMP on/off CAPST EQU 0FCABH ;CAPS LOCK status HCMD EQU 0FE0DH ;CMD HOOK ORG 0BOOOH ;----- CMD initialize ----- ¤³¤ÎÉôʬ¤ò¼Â¹Ô¤¹¤ë¤ÈCMD¥³¥Þ¥ó¥É¤¬ÁýÀߤµ¤ì¤ë LD BC,5 ;NEW HOOK SET LD DE,HCMD LD HL,HDAT LDIR RET ;----- new HOOK data ----- ¥Õ¥Ã¥¯(FE0DH)¤Ë½ñ¤¹þ¤à5¥Ð¥¤¥È¥Ç¡¼¥¿ HDAT: POP AF JP CAPKEY NOP ;----- executed by CMD ----- CMD¥³¥Þ¥ó¥É¤Î¼ÂÂÎ CAPKEY: CALL CHGCAP LD A,(CAPST) CPL LD (CAPST),A RET END
¡¡¥Õ¥Ã¥¯¤Ë½ñ¤¹þ¤àºÇ½é¤Î¡ÈPOP AF¡É¤Ï¡¢¤³¤Î¾ì¹ç¡ÈCMD¡É¤Î¼Â¹Ô¤Î»þ¤Ë¥¹¥¿¥Ã¥¯¤ËÀѤޤì¤ë¥¨¥é¡¼½èÍý¥¢¥É¥ì¥¹¤ò¼Î¤Æ¤ë¤¿¤á¤Î¤â¤Î¤Ç¤¹¡£¤³¤ì¤òÆþ¤ì¤Æ¤ª¤«¤Ê¤¤¤È¡¢¡ÈRETÌ¿Îá¡É¤ÇBASIC¤ËÌá¤ë¤Ï¤º¤¬¥¨¥é¡¼½èÍý¥ë¡¼¥Á¥ó¤Ë¥¸¥ã¥ó¥×¤·¤Æ¤·¤Þ¤¤¤Þ¤¹¡£¥æ¡¼¥¶¡¼¥ë¡¼¥Á¥óÆâ¤Ç¥¨¥é¡¼¤ò½Ð¤·¤¿¤¤¾ì¹ç¤Ï¤³¤Î¥¢¥É¥ì¥¹¤ò¼è¤Ã¤Æ¤ª¤¯¤Î¤â1¤Ä¤ÎÊýË¡¤Ç¤¹¡£
¡¡¤Ê¤ª¡¢¤³¤ì¤é¤Î¥Õ¥Ã¥¯¤ÏËÜÍè¤Ï¾Íè¤Î³ÈÄ¥ÍѤ˥ꥶ¡¼¥Ö¤·¤Æ¤¢¤ë¾ì½ê¤Ê¤Î¤Ç¡¢¾¦ÍѤΥ¢¥×¥ê¥±¡¼¥·¥ç¥ó¡¦¥×¥í¥°¥é¥à¤Ç»ÈÍѤ·¤Æ¤Ï¤¤¤±¤Þ¤»¤ó¡£
4.4¡¡CMDÌ¿Îá¤Î³ÈÄ¥
¡¡¤è¤êÊ£»¨¤Ê¥¹¥Æ¡¼¥È¥á¥ó¥È¤Î³ÈÄ¥¤ò¹Ô¤¦¤Ë¤Ï¡¢CMDÌ¿Îá¤Ë¤â°ú¿ô¤òÅϤ»¤ë¤ÈÊØÍø¤Ç¤¹¡£¥Þ¥·¥ó¸ì¤ò¸Æ¤Ó½Ð¤·¤¿¸å¡¢HL¥ì¥¸¥¹¥¿¤¬BASIC¥Æ¥¥¹¥ÈÃæ¤Î¡ÈCMD¡É¤Î¼¡¤Î°ÌÃÖ¤ò»Ø¤·¤Æ¤¤¤Þ¤¹¤«¤é¡¢¤³¤ì¤òÍøÍѤ·¤Æ¸å¤Ë³¤¯Ê¸»úÎó¤Îɾ²Á¤ò¹Ô¤¨¤ÐÌÜŪ¤Ï²Ì¤¿¤»¤Þ¤¹¡£¤³¤ì¤é¤ò¹Ô¤¦¤¿¤á¤Ë͸ú¤È»×¤ï¤ì¤ëÆâÉô¥ë¡¼¥Á¥ó¤ò¡¢°Ê²¼¤Ë¼¨¤·¤Þ¤¹¡£
¡ü CHRGTR(4666H/MAIN)¡Ä¡Ä¡Ä¡Ä¡Ä¥Æ¥¥¹¥È¤«¤é1ʸ»ú¼è¤ê½Ð¤¹(¿Þ2.14)¡£
ÆþÎÏ:HL¢«¥Æ¥¥¹¥È¤ò»Ø¤¹¥¢¥É¥ì¥¹
½ÐÎÏ:HL¢«¼è¤ê½Ð¤·¤¿Ê¸»ú¤Î¥¢¥É¥ì¥¹
¡¡¡¡A¢«¼è¤ê½Ð¤·¤¿Ê¸»ú
¡¡¡¡Z¥Õ¥é¥°¢«Ê¸Ëö(:¤Þ¤¿¤Ï00H)¤Ê¤é¤ÐON
¡¡¡¡CZ¥Õ¥é¥°¢«0¡Á9¤Ê¤é¤ÐON
µ¡Ç½:(HL+1)¤Î¾ì½ê¤Î¥Æ¥¥¹¥È¤«¤é1ʸ»ú¼è¤ê½Ð¤¹¡£¥¹¥Ú¡¼¥¹¤Ï¥¹¥¥Ã¥×¤µ¤ì¤ë¡£
¡ü FRMEVL(4C64H/MAIN)¡Ä¡Ä¡Ä¡Ä¡Ä¥Æ¥¥¹¥ÈÃæ¤Î¼°¤òɾ²Á¤¹¤ë(¿Þ2.15)¡£
ÆþÎÏ:HL¢«¥Æ¥¥¹¥ÈÃæ¤Î¼°¤ÎÀèÆ¬¥¢¥É¥ì¥¹
½ÐÎÏ:HL¢«¼°¤Î¼¡¤Î¥¢¥É¥ì¥¹
¡¡¡¡[VALTYP(F663H)]¢«·¿¤Ë±þ¤¸¤Æ2,3,4,8¤ÎÃͤ¬Æþ¤ë¡£
¡¡¡¡[DAC(F7F6H)]¢«¼°¤Îɾ²Á·ë²Ì
µ¡Ç½:¼°¤òɾ²Á¤·¡¢·¿¤Ë±þ¤¸¤Æ½ÐÎϤ¹¤ë¡£
¡ü FRMQNT(542FH/MAIN)¡Ä¡Ä¡Ä¡Ä¡Ä¼°¤ò2¥Ð¥¤¥ÈÀ°¿ô·¿¤Çɾ²Á¤¹¤ë¡£
ÆþÎÏ:HL¢«¥Æ¥¥¹¥ÈÃæ¤Î¼°¤ÎÀèÆ¬¥¢¥É¥ì¥¹
½ÐÎÏ:HL¢«¼°¤Î¼¡¤Î¥¢¥É¥ì¥¹
¡¡¡¡DE¢«¼°¤Îɾ²Á·ë²Ì
µ¡Ç½:¼°¤òɾ²Á¤·¡¢À°¿ô·¿(INT)¤Ç½ÐÎϤ¹¤ë¡£·ë²Ì¤¬2¥Ð¥¤¥ÈÀ°¿ô·¿¤ÎÈϰϤËǼ¤Þ¤é¤Ê¤¤¾ì¹ç¤Ë¤Ï¡ÈOverflow¡É¥¨¥é¡¼¤òȯÀ¸¤·¡¢BASIC¥³¥Þ¥ó¥É¥ì¥Ù¥ë¤ËÌá¤ë¡£
¡ü GETBYT(521CH/MAIN)¡Ä¡Ä¡Ä¡Ä¡Ä¼°¤ò1¥Ð¥¤¥ÈÀ°¿ô·¿¤Çɾ²Á¤¹¤ë¡£
ÆþÎÏ:HL¢«¥Æ¥¥¹¥ÈÃæ¤Î¼°¤ÎÀèÆ¬¥¢¥É¥ì¥¹
½ÐÎÏ:HL¢«¼°¤Î¼¡¤Î¥¢¥É¥ì¥¹
¡¡¡¡A,E¢«¼°¤Îɾ²Á·ë²Ì(A¤ÈE¤Ë¤ÏƱ¤¸Ãͤ¬¤Ï¤¤¤ë)
µ¡Ç½:¼°¤òɾ²Á¤·¡¢1¥Ð¥¤¥È·¿¤Ç½ÐÎϤ¹¤ë¡£·ë²Ì¤¬1¥Ð¥¤¥ÈÀ°¿ô·¿¤ÎÈϰϤ˼ý¤Þ¤é¤Ê¤¤¾ì¹ç¤Ë¤Ï¡ÈIllegal function call¡É¥¨¥é¡¼¤òȯÀ¸¤·¡¢BASIC¥³¥Þ¥ó¥É¥ì¥Ù¥ë¤ËÌá¤ë¡£
¡ü FRESTR(67D0H/MAIN)¡Ä¡Ä¡Ä¡Ä¡Äʸ»úÎó¤òÅÐÏ¿¤¹¤ë¡£
ÆþÎÏ:[VALTYP(F663H)]¢«·¿(ʸ»úÎó¤Ç¤Ê¤¤¤È¥¨¥é¡¼¤Ë¤Ê¤ë)
¡¡¡¡[DAC(F7F6H)]¢«¥¹¥È¥ê¥ó¥°¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ø¤Î¥Ý¥¤¥ó¥¿
½ÐÎÏ:HL¢«¥¹¥È¥ê¥ó¥°¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ø¤Î¥Ý¥¤¥ó¥¿
µ¡Ç½:FRMEVL¤ÇÆÀ¤¿Ê¸»úÎ󷿤ηë²Ì¤òʸ»úÎóÎΰè¤ËÅÐÏ¿¤·¡¢¤½¤Î¥¹¥È¥ê¥ó¥°¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÆÀ¤ë¡£Ê¸»úÎó¤òɾ²Á¤·¤¿¾ì¹ç¤ÏÁ°µ¤ÎFRMEVL¤ÈÁȤ߹ç¤ï¤»¤Æ°Ê²¼¤Î¤è¤¦¤Ë»ÈÍѤ¹¤ë¤Î¤¬°ìÈÌŪ¤Ç¤¢¤ë¡£
¡¡¡§ CALL FRMEVL PUSH HL ;¥Æ¥¥¹¥È¥Ý¥¤¥ó¥¿¤ò¥»¡¼¥Ö¤¹¤ë CALL FRESTR EX DE,HL ;¥¹¥È¥ê¥ó¥°¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÆÀ¤ë POP HL LD A,(DE) ;ÆþÎϤµ¤ì¤¿Ê¸»úÎó¤ÎŤµ¤òÆÀ¤ë ¡¡¡§
¡ü PTRGET(5EA4H/MAIN)¡Ä¡Ä¡Ä¡Ä¡ÄÊÑ¿ô¤Î³ÊǼ¥¢¥É¥ì¥¹¤òÆÀ¤ë(¿Þ2.16)¡£
ÆþÎÏ:HL¢«¥Æ¥¥¹¥ÈÃæ¤ÎÊÑ¿ô̾¤ÎÀèÆ¬¥¢¥É¥ì¥¹
¡¡¡¡[SUBFLG(F6A5H)]¢«0:ñ½ãÊÑ¿ô,0°Ê³°:ÇÛÎóÊÑ¿ô
½ÐÎÏ:HL¢«ÊÑ¿ô̾¤Î¼¡¤Î¥¢¥É¥ì¥¹
¡¡¡¡DE¢«ÌÜŪ¤ÎÊÑ¿ô¤ÎÆâÍÆ¤¬³ÊǼ¤µ¤ì¤Æ¤¤¤ë¥¢¥É¥ì¥¹
µ¡Ç½:ÊÑ¿ô(¤Þ¤¿¤ÏÇÛÎóÊÑ¿ô)¤Î³ÊǼ¥¢¥É¥ì¥¹¤òÆÀ¤ë¡£ÌÜŪ¤ÎÊÑ¿ô¤ÎÎΰ褬³ÎÊݤµ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï¡¢Îΰè¤Î³ÎÊݤâ¹Ô¤ï¤ì¤ë¡£[SUBFLG]¤ÎÃͤò0°Ê³°¤ËÀßÄꤷ¤Æ¤ª¤¯¤È¡¢ÇÛÎó¤Î¸Ä¡¹¤ÎÍ×ÁǤǤϤʤ¯¡¢¤½¤ÎÇÛÎó¤ÎÀèÆ¬¥¢¥É¥ì¥¹¤¬ÆÀ¤é¤ì¤ë¡£
¡ü NEWSTT(4601H/MAIN)¡Ä¡Ä¡Ä¡Ä¡ÄǤ°Õ¤Î¥Æ¥¥¹¥È¤ò¼Â¹Ô¤¹¤ë¡£
ÆþÎÏ:HL¢«¼Â¹Ô¤¹¤ë¥Æ¥¥¹¥È¤Î¥¢¥É¥ì¥¹
½ÐÎÏ:¡½¡½
µ¡Ç½:¥Æ¥¥¹¥È¤Î¼Â¹Ô¤ò¹Ô¤¦¡£¥Æ¥¥¹¥È¤Ï¿Þ2.17¤Î¾õÂ֤ȤʤäƤ¤¤ëɬÍפ¬¤¢¤ë¡£
¡¡¤³¤ì¤é¤ÎÆâÉô¥ë¡¼¥Á¥ó¤Ï¡¢BASIC¥Æ¥¥¹¥È¤òÂоݤȤ¹¤ë¤â¤Î¤Ç¤¢¤ë¤¿¤á¡¢¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤ÏBASIC¤ÈƱÍͤΥ¨¥é¡¼½èÍý¤¬¹Ô¤ï¤ì¤Þ¤¹¡£¤½¤Î¾ì¹ç¡¢¥Õ¥Ã¥¯H.ERRO(FFB1H)¤Î½ñ¤´¹¤¨¤Ë¤è¤ê¡¢¥æ¡¼¥¶¡¼¤¬¥¨¥é¡¼½èÍý¤ò¹Ô¤¦¤³¤È¤â¤Ç¤¤Þ¤¹(E¥ì¥¸¥¹¥¿¤Ë¥¨¥é¡¼Èֹ椬Æþ¤ë)(¥ê¥¹¥È2.3)¡£
¥ê¥¹¥È2.3¡¡¥¨¥é¡¼½èÍý¥ë¡¼¥Á¥ó¤ÎÊѹ¹
;============================================================ ; List 2.3 Your own error ; To use, do DEF USR=&HB000 : A=USR(0) ;============================================================ ; HERR EQU 0FFB1H ;error hook SYNERR EQU 2 ;syntax err code CHPUT EQU 0A2H ;character output NEWSTT EQU 4601H ;run READYR EQU 409BH ORG 0B000H ;----- command initialize ----- ¤³¤ÎÉôʬ¤ò¼Â¹Ô¤¹¤ë¤È¥¨¥é¡¼½èÍý¥ë¡¼¥Á¥ó¤¬Êѹ¹¤µ¤ì¤ë LD BC,5 ;SET NEW HOOK LD DE,HERR LD HL,HDAT RET HDAT: JP ERROR NOP NOP ;----- error routine ----- ¥¨¥é¡¼½èÍý¥ë¡¼¥Á¥ó¤Î¼ÂÂÎ ERROR: LD A,E ;when in error, E holds error code CP SYNERR ;syntax error ? RET NZ :no LD HL,DATA1 ;yes LOOP: LD A,(HL) ;put new error message CP '$' JR Z,EXIT PUSH HL CALL CHPUT POP HL INC HL JR LOOP EXIT: JP READYR DATA1: DEFM '޷ެŽÊޝ ŽÏŽÁ޶ŽÞ޲ŽÁެޝŽÀ' ;new error message DEFB 07H,07H,07H,'$' END
4.5¡¡³ä¤ê¹þ¤ß»ÈÍÑË¡
¡¡Z80CPU¤Ë¤ÏINT¤ÈNMI¤Î2¤Ä¤Î³ä¤ê¹þ¤ßü»Ò¤¬¤¢¤ê¤Þ¤¹¤¬¡¢MSX¤Ç»ÈÍѤ·¤Æ¤¤¤ë¤Î¤ÏINT¤Î¤ß¤Ç¤¹¡£INTü»Ò¤Ë¤Ï60[Hz]¤Î¿®¹æ¤¬ÆþÎϤµ¤ì¤Æ¤ª¤ê¡¢1ÉäË60²ó¤Î¥¿¥¤¥Þ³ä¤ê¹þ¤ß¤¬¼Â¹Ô¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£Z80¤Î³ä¤ê¹þ¤ß¥â¡¼¥É¤¬1¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¤¿¤á¡¢³ä¤ê¹þ¤ß¤¬¤«¤«¤ë¤È38HÈÖÃϤ¬¥³¡¼¥ë¤µ¤ì¡¢¤½¤³¤«¤é¥¿¥¤¥Þ³ä¤ê¹þ¤ß¥ë¡¼¥Á¥ó¤Ø¥¸¥ã¥ó¥×¤·¡¢¥¡¼ÆþÎϤò¤Ï¤¸¤á¤È¤¹¤ë¼ï¡¹¤Î½èÍý¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£
¡¡¤³¤Î¥¿¥¤¥Þ³ä¤ê¹þ¤ß¥ë¡¼¥Á¥ó¤Ï¡¢ÅÓÃæ¤Ç¥Õ¥Ã¥¯H.TIMI(FD9FH)¤Ë¥¸¥ã¥ó¥×¤·¤Þ¤¹¡£¤³¤Î¥Õ¥Ã¥¯¤òÍøÍѤ¹¤ë¤³¤È¤Ç¡¢¤³¤Î¥¿¥¤¥Þ³ä¤ê¹þ¤ß¥ë¡¼¥Á¥ó¤ËǤ°Õ¤Îµ¡Ç½¤òÄɲ乤뤳¤È¤¬²Äǽ¤Ç¤¹¡£¤³¤³¤ÇÃí°Õ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤Î¤Ï¡¢Ä̾盧¤³¤Ë¤ÏRETÌ¿Î᤬½ñ¤«¤ì¤Æ¤¤¤ë¤À¤±¤Ç¤¹¤¬¡¢¥Ç¥£¥¹¥¯¤Ê¤É¤Î¼þÊÕµ¡´ï¤¬Àܳ¤µ¤ì¤Æ¤¤¤Æ¡¢¤¹¤Ç¤Ë¤³¤Î¥Õ¥Ã¥¯¤¬»ÈÍÑÃæ¤Î»þ¤Ç¤¹¡£¤³¤Î¾ì¹ç¡¢ÃΤ餺¤Ë½ñ¤´¹¤¨¤ë¤È¤½¤ì¤é¼þÊÕµ¡´ï¤¬°Ê¸å»ÈÍÑÉÔǽ¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¦¤Î¤Ç¡¢¤É¤Î¥Þ¥·¥ó¤Ç¤âÀµ¾ï¤Ë¼Â¹Ô¤Ç¤¤ë¤è¤¦¤Ë¤¹¤ë¤¿¤á¤Ë¤Ï¡¢¤¢¤é¤«¤¸¤á¤½¤ì¤ËÂФ¹¤ë½èÍý¤ò¤·¤Æ¤ª¤¯É¬Íפ¬¤¢¤ê¤Þ¤¹¡£³ä¤ê¹þ¤ß¤Î»ÈÍÑÎã¤È¤È¤â¤Ë¤³¤ì¤é¤ÎÂнè¤Î°ìÎã¤ò¥ê¥¹¥È2.4¤Ë¼¨¤·¤Þ¤¹¡£
¥ê¥¹¥È2.4¡¡¥¿¥¤¥Þ³ä¤ê¹þ¤ß¥Õ¥Ã¥¯¤ÎÀµ¤·¤¤»ÈÍÑË¡
;============================================================ ; List 2.4 How to use HOOK safely ; This routine uses TIMER INTERRUPT HOOK ; and turn on/off CAPS LOCK ; To start, do DEF USR=&HB000 : A=USR(0) ; To end, do DEF USR=&HB030 : A=USR(1) ;============================================================ ; CHGCAP EQU 0132H ;CAP LAMP on/off CAPST EQU 0FCABH ;CAP LOCK status TIMI EQU 0FD9FH ;timer interrupt HOOK JPCODE EQU 0C3H TIMER EQU 020H ORG 0B000H ;----- interrupt on ----- ¥Õ¥Ã¥¯½ñ¤´¹¤¨»þ¤Ë¤Ï°ÊÁ°¤Î¥Õ¥Ã¥¯¤òÊݸ¤¹¤ë INTON: DI LD HL,TIMI ;OLD HOOK SAVE LD DE,HKSAVE LD BC,5 LDIR LD A,JPCODE ;NEW HOOK SET LD (TIMI),A LD HL,INT LD (TIMI+1),HL EI RET ORG 0B030H ;----- interrupt off ----- Êݸ¤·¤Æ¤ª¤¤¤¿¥Õ¥Ã¥¯¤ò¸µ¤ËÌᤷ¤Æ½ªÎ»¤¹¤ë INTOFF: DI LD HL,HKSAVE ;RECOVER HOOK LD DE,TIMI LD BC,5 LDIR EI RET ;----- interrupt routine ----- INT: PUSH AF LD A,(CAPST) OR A JR Z,CAPON CAPOFF: LD A,(COUNT1) DEC A LD (COUNT1),A JR NZ,FIN LD A,TIMER LD (COUNT1),A XOR A LD (CAPST),A LD A,0FFH CALL CHGCAP JR FIN CAPON: LD A,(COUNT2) DEC A LD (COUNT2),A JR NZ,FIN LD A,TIMER LD (COUNT2),A LD A,0FFH LD (CAPST),A XOR A CALL CHGCAP FIN: POP AF CALL HKSAVE ;old HOOK call RET COUNT1: DEFB TIMER COUNT2: DEFB TIMER HKSAVE: NOP ;old HOOK save area NOP NOP NOP RET END