我这里用汇编编写一个51的程序 提示了一个错误 但是我觉得是没有错误的 麻烦你帮看看
这是错误提示:shishi.asm(58): error A48: DATA-ADDRESS EXPECTED
它指向下面这句话:MOV 20H.0,INTA
其中INTA是这样定义的:INTA equ p3.4
我觉得不应该有错误了
总的程序如下:
INA equ p3.4 ;¹âµç¿ª¹ØA ±¾À´ABΪµ¼Í¨×´Ì¬
INB equ p3.7 ;¹âµç¿ª¹ØB
out1 equ p2.0 ;µç´Å·§¼ÌµçÆ÷
out2 equ p2.7 ;µã»ð¼ÌµçÆ÷
out3 equ p2.1 ;¹Ä·ç»úÖ÷¼ÌµçÆ÷,0:open;1:close
out4 equ p2.5 ;¹Ä·ç»ú¸ßµÍËÙÇл»¼ÌµçÆ÷,0:low;1:high
org 0000h //³ÌÐòÔÚ0000hºó¿ªÊ¼
ajmp 0030h //µ÷µ½Ö÷³ÌÐò 00µ½30Ö®¼äÊÇÖжϺ¯ÊýµÄÈë¿Ú Ö÷³ÌÐòÔÚ30Ö®ºó ËùÒÔÒªÌøת
org 0030h //³ÌÐòÔÚÖ÷³ÌÐòÖ´ÐÐ
START:
MOV SP,#60H //ÉèÖöÑÕ»Ö¸Õë¼Ä´æÆ÷ ÆäֵΪ60
MOV IP,#00H //ÉèÖÃÖжÏÓÅÏȼ¶¼Ä´æÆ÷ ËùÓÐÖжϵÄÓÅÏȼ¶¶¼Îª×î¸ß¼¶
MOV IE,#00H //ÉèÖÃÖжÏʹÄܼĴæÆ÷ ½ûÖ¹ËùÓеÄÖжÏ
MOV 20H,#00H //³õʼ»¯20H 21H 22HͨÓüĴæÆ÷
MOV 21H,#00H
MOV 22H,#00H
CLR OUT1 //ÇåÁãp2.0 µç´Å·§¼ÌµçÆ÷
CLR OUT2 //ÇåÁãp2.7 µã»ð¼ÌµçÆ÷
CLR OUT3 //ÇåÁãp2.1 ¹Ä·ç»úÖ÷¼ÌµçÆ÷,0:open;1:close
CLR OUT4 //ÇåÁã¹Ä·ç»ú¸ßµÍËÙÇл»¼ÌµçÆ÷,0:low;1:high
main:
LCALL D4300MS //µ÷ÓÃD4300MS ³¤µ÷Óà ×Ó³ÌÐò×î´óΪ64KB
MOV 22H,21H //°Ñ21HµÄÖµ¸´ÖƵ½22H
MOV 21H,20H
ACALL READIN //¾ø¶Ôµ÷Óà ×Ó³ÌÐò×î´óΪ2KB
STAT3:
;JB 22H.1,STAT4 ;B¶Ï¿ª
JB 21H.1,STAT4 ;B¶Ï¿ª Ϊ1תÒÆ
JB 20H.1,STAT4 ;B¶Ï¿ª
AJMP NEXT
STAT4:
JNB 21H.0,A0B0 ;Aµ¼Í¨×ªÒÆ ²»Îª1תÒÆ
AJMP MAIN
NEXT:
JB 20H.0,A1B0 ;A¶Ï¿ª×ªÒÆ Îª1תÒÆ
A0B0: ;Aµ¼Í¨Bµ¼Í¨
CLR OUT1 ;µç´Å·§Í¨µç
CLR OUT2 ;µã»ðÕ벻ͨµç
CLR OUT3 ;¹Ä·ç»ú¿ª
CLR OUT4 ;¹Ä·ç»úµÍËÙÔËÐÐ
AJMP MAIN
A1B0: ;A¶Ï¿ªBµ¼Í¨
SETB OUT1 ;µç´Å·§¶Ïµç
SETB OUT2 ;µã»ðÕëͨµç
ACALL D700MS ;ÑÓʱ0.7Ãë
CLR OUT3 ;¹Ä·ç»ú¿ª
SETB OUT4 ;¹Ä·ç»ú¸ßËÙÔËÐÐ
ACALL D4300MS;ÑÓʱ4.3Ãë
CLR OUT2 ;µã»ðÕ벻ͨµç
AJMP MAIN
E_MAIN:
AJMP MAIN
;READ INPUT
READIN: ;ABde״̬ɨÃè³ÌÐò ¿ªÊ¼Ê±AB¶¼µÈÓÚ0 µ±Óб仯µÄʱºòÍ˳ö µ«²¢²»ÖªµÀÊÇÄǸö±ä»¯ÁË ±ä»¯Á˾Í˵Ã÷ABÓÐÒ»¸ö±äΪ1ÁË
MOV 20H,#00H ;³õʼ»¯20H
SETB INA ;ÖÃλINA Òª¶ÁIO¿Ú¾Í±ØÐëÏÈÖÃλ¸ÃIO¿Ú p3.4 ¹âµç¿ª¹ØA
MOV 20H.0,INA ;°ÑINA p3.4 ¹âµç¿ª¹ØA µÄ״̬±£´æµ½20H.0
SETB INB
MOV 20H.1,INB ;°Ñp3.7 ¹âµç¿ª¹ØBµÄ״̬±£´æµ½20H.1
MOV A,20H ;°Ñ20HµÄÊý¾ÝתÒƵ½ÀÛ¼ÓÆ÷AÖÐ
MOV R7,#10H ;°Ñ10·Åµ½R7Àï
DJNZ R7,$ ;Ñ»·16´Î ÑÓʱ16´Î
MOV 20H,#00H ;Çå³ý20H Êý¾ÝÒѾÒƽ»¸øA
SETB INA ;ÔٴλñÈ¡AµÄÊäÈë
MOV 20H.0,INA
SETB INB
MOV 20H.1,INB
CJNE A,20H,READIN ;Compare Jump Not Equal ±È½Ï²»ÏàµÈתÒÆÖ¸Áî 20HÀïµÄÊýÖµºÍA±È½Ï Èô²»ÏàµÈÔòתÒƵ½READIN¼´±¾³ÌÐò¿ªÍ· ÔÙ´ÎɨÃè ±ÜÃâ¸ÉÈÅ ²»ÏàµÈÔò˵Ã÷ÊÇÔëÉù Õâ¾ä»°µÄ×÷ÓþÍÖ»ÊÇ˵Ã÷ûÓÐÔëÉù°ÕÁË
CJNE A,21H,E_READIN ;תÒƵÄʱºòµ÷ÓÃÍ˳öÖ¸Áî Í˳öREADIN ¾ÍÊÇ˵µ±21HµÄÖµºÍA²»ÏàµÈµÄʱºòÍ˳öREADIN MOV 21H,20H 21HµÄÄÚÈÝΪ00 ÓÐÒ»¸öµ¼Í¨Í˳ö Õâ¾ä»°²ÅÊÇÅжÏÓÐûÓб仯
AJMP READIN ;ÎÞÌõ¼þתÒÆ»ØREADIN º¯Êý¿ªÊ¼ ÔÙ´ÎÑ»·É¨Ãè
READ_B: ;B¶Ï¿ª,0.7ÃëÄÚ¶ÁAÊÇ·ñµ¼Í¨±äΪ0£© AÔÚINAµÈÓÚ1µÄʱºòµ¼Í¨ µ¼Í¨Îª1 ¶Ï¿ªÎª0
JNB 20H.1,READ_A ;B¶Ï¿ª ÍùÏÂ×ß Î»Ìõ¼þתÒÆ Î»Îª0ʱתÒÆ BµÄ״̬´æ·ÅÔÚ20H.1ÀïÃæ Èô20H.1µÈÓÚ0ÔòתÒƵ½READ_A ·ñÔò˳ÐòÖ´ÐÐ 20H.1µÈÓÚ0Ôò˵Ã÷±ä»¯µÄ²»ÊÇB ±¾À´ÊǶϿªµÄ¼´0ËùÒÔ˵ÊÇAµ¼Í¨
RAL: MOV R5,#7 ;×°ÔØR5.6.7
RAL3: MOV R6,#95
RAL2: MOV R7,#210 ;µ¼Í¨Îª0 ¶Ï¿ªÎª1
RAL1: SETB INA ;°ÑAÖÃÒ» ÏÂÒ»²½¾ÍÒª¶ÁÈ¡AµÄÖµ µ±Aµ¼Í¨ÊÇ INAµÈÓÚ0
JNB INA,SAV4 ;A¶Ï¿ªÍùÏÂ×ß µ¼Í¨µÄʱºòתÒÆ Ö±½ÓÑ°Ö·²»Îª1ʱתÒÆ Èç¹ûINAµÈÓÚ0 תÒƵ½SAV4 Ö»ÒªAµ¼Í¨£¨±äΪ0£© ¾ÍÌø³ö¶Á³ö µ±È»³¬Ê±µÄʱºòÒ²»áÌø³ö
DJNZ R7,RAL1 ;R7¼õ1²»Îª0 Ìøת Ö´ÐÐ7 210+210*95+7*210*95=159810´Î
DJNZ R6,RAL2
DJNZ R5,RAL3
AJMP E_READIN ;³¬Ê± Ìøתµ½E_READIN
READ_A: ;Aµ¼Í¨,0.7ÃëÄÚ¶ÁBÊÇ·ñ¶Ï¿ª
JB 20H.0,E_READIN ;µ±Aµ¼Í¨µÄʱºòתÒÆ Î»Îª1תÒÆ
RBL: MOV R5,#7
RBL3: MOV R6,#95
RBL2: MOV R7,#210
RBL1: SETB INB
JB INB,SAV4 ;µ±Bµ¼Í¨µÄʱºòתÒÆ µ¼Í¨Îª0 ¶Ï¿ªÎª1 λΪ1תÒÆ
DJNZ R7,RBL1
DJNZ R6,RBL2
DJNZ R5,RBL3
AJMP E_READIN
SAV4: ;B¶Ï¿ª,Aµ¼Í¨
CLR 20H.0
SETB 20H.1
E_READIN:
RET
;ÑÓʱ0.7Ãë
d700ms: mov r5, #7 ;°Ñ7×°µ½r5ÖÐ
d100ms: mov r6, #199
d500us: mov r7, #250 ;°Ñ250×°Èër7ÖÐ d500usÖ´ÐÐÁË
djnz r7, $ ;¼õ1²»ÎªÁãתÒÆÖ¸Áî dec 1 jump if not zero ÏȽ«r7µÄÊý¼õ1 ÅжÏÊÇ·ñΪ0 ²»Îª0¾ÍÌøµ½ÐбêΪRELµÄµØ·½Ö´ÐРΪ0¾Í²»×ªÒÆ ¼ÌÐøÖ´ÐÐÏÂÃæµÄÓï¾ä
djnz r6, d500us ;²»ÎªÁã¾ÍÌøµ½d500usµÄµØ·½¼ÌÐøÖ´ÐÐ Ò²¾ÍÊÇÔÙ¼õ250´Î Ò»¹²¼õ250*199=49750´Î
djnz r5, d100ms ;ºÍÉÏÃæÒ»Ñù Ò»¹²¼õÁË250+199*250+7*199*250=398250´Î
RET
;ÑÓʱ4.3Ãë
d4300ms:mov r5, #43
d100ms1:mov r6, #198
d500us1:mov r7, #251
djnz r7, $ ;±êÖ¾·û$ ÊDZ¾ÌõÖ¸ÁîµÄÆðʼµØÖ·µÄÒâ˼ ¾ÍÊÇ˵Èç¹ûr7¼õ1²»ÎªÁã ÄÇôÓÖ¼ÌÐøÖ´Ðб¾ÌõÖ¸Áî¾ÍÊÇÒ»¸öÑÓʱ DINZµÄº¯Êý¶¨Ò壺DJNZ Rn, Rel
djnz r6, d500us1
djnz r5, d100ms1
RET
END
- mov c,INTA
- mov 20.0H,c
复制代码一周热门 更多>