;
;有個題目,要求把?C?語言的程序,改成匯編的,鏈接如下:
;
;看他原來的程序,是驅(qū)動?8*8?LED?點陣顯示字符的。
;
;根據(jù)程序,做而論道畫出了點陣驅(qū)動電路,運行C程序后顯示如下所示:
;
;
;LED?所顯示的全部字符都在下面給出了,有些字符的圖形,還是很有創(chuàng)造力的,呵呵
;
;做而論道寫出了功能相同的匯編程序,全部代碼如下:
;8?*?8?LED?點陣
????ORG???0000H
????JMP???START
;-----------------------
RED:
????DB??0x18,0x00,0x18,0x18,0x18,0x18,0x18,0x18;//i
????DB??0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0xFC,0xFC;//l
????DB??0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C;//o
????DB??0x00,0x00,0x44,0x44,0x44,0x44,0x28,0x10;//v
????DB??0x00,0x3E,0x02,0x02,0x3E,0x02,0x02,0x3E;//e
????DB??0x81,0xA5,0xDB,0xC3,0xA5,0x99,0x81,0xFF;//u
;-----------------------
START:
????MOV???DPTR,?#RED
????MOV???R2,?#254
LP0:MOV???R3,?#0
LP1:MOV???R5,?#100
LP2:MOV???R4,?#0
LP3:MOV???A,?R3
????ADD???A,?R4
????CALL??DISP
????INC???R4
????CJNE??R4,?#8,?LP3
????DJNZ??R5,?LP2
;-----------------
????MOV???A,?R3
????ADD???A,?#8
????MOV???R3,?A
????CJNE??R3,?#48,?LP1
????SJMP??LP0
;-----------------------
DISP:
????MOVC??A,?@A?+?DPTR
????MOV???P2,?A
????MOV???P0,?R2
????MOV???A,?R2
????RL????A
????MOV???R2,?A
????DJNZ??R7,?$
????DJNZ??R7,?$
????MOV???P2,?#0
????RET
;-----------------------
END
;做而論道把匯編程序提交后,卻出現(xiàn)下面的提示:
;
;>_<!!?您的回答可能違反了知道內(nèi)容規(guī)范,暫時僅您自己可見??砂l(fā)起申訴找回。
;
;這種事情,出現(xiàn)過多次,申訴后,也沒有什么結(jié)果的。
;
;呵呵,百度知道的某些網(wǎng)管,判斷能力、水平,真難以用語言描述。
;
;
;本題目給出的?C?程序如下:
#include?
#define?uchar??unsigned?char
#define?uint???unsigned?int
uchar?code??RED[]?=?{
????0x18,0x00,0x18,0x18,0x18,0x18,0x18,0x18,//i
????0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0xFC,0xFC,//l
????0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,//o
????0x00,0x00,0x44,0x44,0x44,0x44,0x28,0x10,//v
????0x00,0x3E,0x02,0x02,0x3E,0x02,0x02,0x3E,//e
????0x81,0xA5,0xDB,0xC3,0xA5,0x99,0x81,0xFF?//u
????};
void?delay(uint?t)
{
????for(;?t?>?0;?t--);
}
void?main()
{
????uchar?r,?j,?q?=?0,?t?=?0;
????while(1)??{
??????for(r?=?0;?r?<?40;?r++)?{
????????for(j?=?q;?j?<?q?+?8;?j++)?{
??????????P0?=?(~(0x01?<<?t));
??????????P2?=?RED[j];?delay(200);?P2?=?0;
??????????t++;??t?%=?8;
????????}
??????}
??????q?+=?8;??q?%=?48;
????}
}
大家可以試試,兩種程序的功能,是否相同。
有位網(wǎng)友,利用反匯編?C?語言的方法,得出了匯編語言程序,程序長得多且不說,而且還編譯不成功。