条件,如果一个字节中1的中间有0,这样的位也要被置1,
例如,
一个字节为:#01001100B转化为#01111100B
谢谢了。
网友评论:待转数据放在R7,转完后放于ACC
CONVERT:
MOVA,#00000011b
CJNER7,#10H,$+3
JCL1
MOVA,#00111111b
L1:CJNEA,7,$+3
JCL2
RRCA;0000000100011111
SJMPL3
L2:RLCA;0000011101111111
L3:CJNEA,7,$+3
JNCL4
RLCA;00000011000011110011111111111111
L4:MOVR6,A
MOVA,R7
CPLA
INCA
ORLA,R7
ANLA,R6
RET
网友评论:好像我们今天微机原理实验的考试题目啊,easy!
网友评论:明天再来...
网友评论:实际中我的数是有12位的,我现在的做法就是先从左判断,看判断到第几位为1,然后在从右判断,判断到第几位为1.然后将它们中间的位全定义为1.
网友评论:人家ljm810010可是一说就明白,LZ要多努力啊。
网友评论:SUB_CONV:
MOVB,A;1
ANLA,#11111100B;2
CJNEA,B,LR1;4
ANLA,#11110000B;5
CJNEA,B,LR2;7
ANLA,#11000000B;8
CJNEA,B,LR3;10
;RET
NOP;11
NOP;12
SJMPLR88B;14
;----------------------------
LR1:
MOVA,B;5
ANLA,#00111111B;6
CJNEA,B,LRL11;8
ANLA,#00001111B;9
CJNEA,B,LRL12;11
ANLA,#00000011B;12
CJNEA,B,LRL13;14
LR88B:
SJMPLR88;16
LRL11:
;MOVA,#01111110B;9
;ORLA,B;10
;RET
ORLB,#01111110B;10
NOP;11
LRL12:
;MOVA,#00011110B;12
;ORLA,B;13
;RET
ORLB,#00011110B;13
NOP;14
LRL13:
MOVA,#00000110B;15
ORLA,B;16
RET
;--------------------------------
LR2:
MOVA,B;8
ANLA,#00111111B;9
CJNEA,B,LR21;11
ANLA,#00001111B;12
CJNEA,B,LR22;14
;RET
SJMPLR88;16
LR21:
;MOVA,#01111000B;12
;ORLA,B;13
;RET
ORLB,#01111000B;13
NOP;14
LR22:
MOVA,#00011000B;15
ORLA,B;16
RET
;-------------------------------
LR3:
MOVA,B;11
ANLA,#00111111B;12
CJNEA,B,LR31;14
;RET
SJMPLR88;16
LR31:
MOVA,#01100000B;15
ORLA,B;16
LR88:
RET
网友评论:【非典】一出鬼神惊,非要稳坐盟主地位。
网友评论:SUB_CANV:
MOVR7,A;1
ANLA,#0FH;2
ADDA,#(DT_TAB-$-3);3
MOVCA,@A+PC;5
JNZL1;7
MOVA,R7;8
SWAPA;9
ADDA,#(DT_TAB-$-3);10
MOVCA,@A+PC;;12
MOVR7,A;13
MOVA,#0FH;14
L1A:
ANLA,R7;15
SWAPA;16
SJMPL3;18
L1:
XCHA,R7;8
ANLA,#0F0H;9
JNZL2;11
MOVA,#0F0H;12
SJMPL1A;14
L2:
SWAPA;12
ADDA,#(DT_TAB-$-3);13
MOVCA,@A+PC;15
ORLA,#0FH;16
XCHA,R7;17
ORLA,#0F0H;18
L3:
ANLA,R7;19
RET
DT_TAB:
DB00000000B;0000
DB00011111B;0001
DB00111110B;0010
DB00111111B;0011
DB01111100B;0100
DB01111111B;0101
DB01111110B;0110
DB01111111B;0111
DB11111111B;1001
DB11111110B;1010
DB11111111B;1011
DB11111100B;1100
DB11111111B;1101
DB11111110B;1110
DB11111111B;1111
;------------------ENDOFSUB_CANV-----
网友评论:方法相似,也是查表,还有一个21cys,50bytes的。
网友评论:SUB_CANV:
MOVB,A;1
ANLA,#00111111B;2
CJNEA,B,L2;4
;00XX-XXXX
ANLA,#00001111B;5
CJNEA,B,L1;7
;0000-XXXX
ADDA,#(DT_TAB-$-3);8
MOVCA,@A+PC;10SSSS-XXXX
ANLA,#11110000B;11
SWAPA;12
NOP;13
RET
L1:;00??-XXXX
ADDA,#(DT_TAB-$-3);8
MOVCA,@A+PC;10SSSS-XXXX
ANLA,#00001111B;11
ORLA,#00010000B;12
ORLA,B;13
RET
L2:;??XX-XXXX
ANLA,#00001111B;5
JZL3;7
;??XX-XXXX
ADDA,#(DT_TAB-$-3);8
MOVCA,@A+PC;10SSSS-XXXX
ANLA,#00001111B;11
ORLA,#01110000B;12
ORLA,B;13
RET
L3:;??XX-0000B
MOVA,B;8
SWAPA;9
ADDA,#(DT_TAB-$-3);10
MOVCA,@A+PC;12;SSSS-XXXX
ANLA,#11110000B;13
RET
DT_TAB:
DB00000000B;0000
DB00011111B;0001
DB00101110B;0010
DB00111111B;0011
DB01001100B;0100
DB01111111B;0101
DB01101110B;0110
DB01111111B;0111
DB10001000B;1000
DB11111111B;1001
DB11101110B;1010
DB11111111B;1011
DB11001100B;1100
DB11111111B;1101
DB11101110B;1110
DB11111111B;1111
;-----------ENDOFSUB_CANV-----
网友评论:18周期,66字节
;=================================
Convert:
movr7,a
movr6,a
anla,#00001111b
adda,#(Tab1-$-3)
movca,@a+pc
xcha,r7
swapa
anla,#00001111b
adda,#(Tab2-$-3)
movca,@a+pc
adda,r7
movca,@a+pc
orla,r6
ret
Tab0:db00000000b,00000000b,00000000b,00000110b,00000000b,00011110b,00011000b,00011110b
db00000000b,01111110b,01111000b,01111110b,01100000b,01111110b,01111000b,01111110b
Tab1:db2,3,3,3,4,5,5,5,4,5,5,5,4,5,5,5
Tab2:db0,4,4,4,8,12,12,12,8,12,12,12,8,12,12,12
20周期,54字节
;==============================
Convert:
movr7,a
movr6,a
anla,#00001111b
adda,#(Tab1-$-3)
movca,@a+pc
xcha,r7
swapa
anla,#00001111b
adda,#(Tab1-$-3)
movca,@a+pc
rla
rla
adda,r7
movca,@a+pc
orla,r6
ret
Tab1:db4,5,5,5,6,7,7,7,6,7,7,7,6,7,7,7,0,0
Tab0:db00000000b,00000000b,00000000b,00000110b,00000000b,00011110b,00011000b,00011110b
db00000000b,01111110b,01111000b,01111110b,01100000b,01111110b,01111000b,01111110b
网友评论:Convert:
movr7,a
rra
orla,r7
anla,#55h
movr6,a
swapa
rla
orla,r6
anla,#0fh
adda,#(Tab-$-3)
movca,@a+pc
orla,r7;dengm的点睛之笔
ret
Tab:db00h,00h,00h,1eh,00h,06h,18h,1eh,00h,7eh,60h,7eh,78h,7eh,78h,7eh
end
用C来表达,就这两句:
Dest=(Source|(Source>>1))&0x55;
Dest=Tab[(Dest|(Dest>>3))&0x0f]|Source;
网友评论:SUB_CANV:
MOVB,A;1
ANLA,#00111111B;2
CJNEA,B,L2;4
;00XX-XXXX
ANLA,#00001111B;5
CJNEA,B,L1;7
;0000-XXXX
ADDA,#(DT_TAB1-$-3);8
MOVCA,@A+PC;10SSSS-0000
SWAPA;11
NOP;12
RET
L1:;00??-XXXX
ADDA,#(DT_TAB2-$-3);8
MOVCA,@A+PC;100001-XXXX
ORLA,B;11
NOP;12
RET
L2:;??XX-XXXX
ANLA,#1111B;5
JZL3;7
;??XX-XXXX
ADDA,#(DT_TAB2-$-3);8
MOVCA,@A+PC;100001-XXXX
ORLA,#01110000B;11
ORLA,B;12
RET
L3:;??XX-0000B;7
MOVA,B;8
SWAPA;9
ADDA,#(DT_TAB1-$-3);10
MOVCA,@A+PC;12;SSSS-0000
RET
DT_TAB1:
DB00000000B;0000
DB00010000B;0001
DB00100000B;0010
DB00110000B;0011
DB01000000B;0100
DB01110000B;0101
DB01100000B;0110
DB01110000B;0111
DB10001000B;1000
DB11110000B;1001
DB11100000B;1010
DB11110000B;1011
DB11000000B;1100
DB11110000B;1101
DB11100000B;1110
DB11110000B;1111
DT_TAB2:
DB00000000B;0000
DB00011111B;0001
DB00011110B;0010
DB00011111B;0011
DB00011100B;0100
DB00011111B;0101
DB00011110B;0110
DB00011111B;0111
DB00011000B;1000
DB00011111B;1001
DB00011110B;1010
DB00011111B;1011
DB00011100B;1100
DB00011111B;1101
DB00011110B;1110
DB00011111B;1111
网友评论:这样下去意义不大了,楼主都没说有什么实际应用的意义。
;===========9周期79字节=============
Convert:
movr7,a
anla,#3fh
cjnea,7,L1
adda,#(Tab-$-3)
movca,@a+pc
ret
L1:mova,#81h
subba,r7
orla,r7
ret
Tab:db00H,01H,02H,03H,04H,07H,06H,07H,08H,0FH,0EH,0FH,0CH,0FH,0EH,0FH
db10H,1FH,1EH,1FH,1CH,1FH,1EH,1FH,18H,1FH,1EH,1FH,1CH,1FH,1EH,1FH
db20H,3FH,3EH,3FH,3CH,3FH,3EH,3FH,38H,3FH,3EH,3FH,3CH,3FH,3EH,3FH
db30H,3FH,3EH,3FH,3CH,3FH,3EH,3FH,38H,3FH,3EH,3FH,3CH,3FH,3EH,3FH
end
网友评论:;===========12周期42字节=============
CONVERT:
MOVR7,A;1
ANLA,#11110000B;2
JZL2;4
ANLA,#11000000B;5
CJNEA,#0,L1;7
SUBBA,R7;8
ANLA,#00011111B;9
ORLA,R7;10
RET;12
L1:
MOVA,#80H;8
SUBBA,R7;9
ORLA,R7;10
L1B:RET;12
L2:
MOVA,R7;5
ADDA,#(TAB-$-3);6
MOVCA,@A+PC;8
SJMPL1B;10
TAB:
db00H,01H,02H,03H,04H,07H,06H,07H
DB08H,0FH,0EH,0FH,0CH,0FH,0EH,0FH
;$$$$$$$$$$$$$$$ENDOFFSUBCONVERT$$$
;===========13周期46字节=============
Convert:
movr7,a;1
anla,#00111111B;2
cjnea,7,L1;4
ANLA,#00001111B;5
CJNEA,7,L2;7
adda,#(Tab-$-3);8
movca,@a+pc;10
NOP
ret;12
L1:
MOVA,#(10000000B+1);5
subba,r7;6
NOP
NOP
SJMPL3;10
L2:
mova,#(11100000B+1);8
subba,r7;9
ANLA,#00011111B;10
L3:
orla,r7;11
ret;13
Tab:db00H,01H,02H,03H,04H,07H,06H,07H,08H,0FH,0EH,0FH,0CH,0FH,0EH,0FH
;$$$$$$$$$$$$$$$ENDOFFSUBCONVERT$$$
网友评论:CANVERT:
JNZL1;2
SJMPL2;4
L1:
MOVCA,@A+PC;4
L2:
RET;6
;DB00
DB1
DB2
DB3
DB4
DB7
......
.....
DB254
DB255
网友评论:来个总结,能否用程序的执行时间与代码长度的乘积作为评分标准?如果合理的话,呵呵41楼程序15*32=480比45楼程序12*41=492略胜一筹;不过我总觉得返回指令RET的时间不应算在内,因为过程完了,要返回是以后的事了。如果这样算的话,45楼10*41=410又比41楼13*32=416优胜一点~~~
网友评论:CANVERT:
MOVCA,@A+PC;2
RET;4
DB1
DB2
DB3
DB4
DB7
......
.....
DB254
DB255
网友评论:时间*10+空间*1;一般用10个bytes换1周期比较合理
46楼:6*10+261=321(单位资源)
45楼:12*10+42=162(单位资源)
43楼:9*10+79=169(单位资源)
42楼:14*10+76=216(单位资源)
41楼:15*10+32=182(单位资源)
45楼与43楼并列第一41楼第二
网友评论:绝对是我6楼的观点得第一
网友评论:你程序有BUG。demgn的程序每条指令都隐藏着不可告人的秘密。
网友评论:;*********12周期42bytes
Convert:
MOVR7,A;1
ANLA,#11110000B;2
JZL2;4
ANLA,#11000000B;5
CJNEA,#0,L1;7
SUBBA,R7;8
ANLA,#00011111B;9
ORLA,R7;10
RET;12
L1:
MOVA,#80H;8
SUBBA,R7;9
ORLA,R7;10
L1B:RET;12
L2:
MOVA,R7;5
ADDA,#(TAB-$-3);6
MOVCA,@A+PC;8
SJMPL1B;10
TAB:
db00H,01H,02H,03H,04H,07H,06H,07H
DB08H,0FH,0EH,0FH,0CH,0FH,0EH,0FH
;$$$$$$$$$$$$$$$ENDOFFSUBCONVERT$$$
网友评论:MOVR7,A
ADDA,#11000000B
JNCL1
MOVA,#81H
SUBBA,R7
ORLA,R7
RET
L1:
ADDA,#(0100000B+TAB-$-3)
MOVCA,@A+PC
RET
Tab:db00H,01H,02H,03H,04H,07H,06H,07H,08H,0FH,0EH,0FH,0CH,0FH,0EH,0FH
db10H,1FH,1EH,1FH,1CH,1FH,1EH,1FH,18H,1FH,1EH,1FH,1CH,1FH,1EH,1FH
db20H,3FH,3EH,3FH,3CH,3FH,3EH,3FH,38H,3FH,3EH,3FH,3CH,3FH,3EH,3FH
db30H,3FH,3EH,3FH,3CH,3FH,3EH,3FH,38H,3FH,3EH,3FH,3CH,3FH,3EH,3FH
网友评论:;11CYS56BYTES
CONV:
MOVR7,A;1
ANLA,#11100000B;2
JZL2;4
CJNEA,#00100000B,L1;6
SUBBA,R7;7
ORLA,R7;8
ANLA,#00111111B;9
RET;11
L1:
MOVA,#80H;7
SUBBA,R7;8
ORLA,R7;9
RET;11
L2:
MOVA,R7;5
ADDA,#(TAB-$-3);6
MOVCA,@A+PC;7
NOP;9
RET;11
Tab:db00H,01H,02H,03H,04H,07H,06H,07H,08H,0FH,0EH,0FH,0CH,0FH,0EH,0FH
db10H,1FH,1EH,1FH,1CH,1FH,1EH,1FH,18H,1FH,1EH,1FH,1CH,1FH,1EH,1FH
网友评论:周未应去陪女友,怎么还这么多人混坛?哎,搞技术的~~
网友评论:;11(周期)*10+44(字节)=154[终结]版
CONVERT:
MOVR7,A;1
ADDA,#11011111B;2
JCL100;4
;0TO00100000B
JBACC.4,L80;6
ADDA,#(00100001B+TAB50-$-4);7
MOVCA,@A+PC;9
RET;11
TAB50:
DB1,2,3,4,7,6,7,8
DB15,14,15,12,15,14,15,16
L80:
CPLA;7
ANLA,#01FH;8
ORLA,R7;9
RET;11
L100:
ADDA,#11100000B;5
JCL110;7
CPLA;8
ORLA,R7;9
RET;11
L110:
XRLA,#00111111B;8
ORLA,R7;9
RET;11
;------------------------------------
12(周期)*10+32(字节)=152
CONVERT8:
MOVR7,A;1
ADDA,#11101111B;2
JCLL100;4
;0TO00010000B
ADDA,#00001100B
JCLL80
MOVA,R7
SJMPLL90
LL80:
XRLA,#00001011B
ANLA,#111B
ORLA,R7
LL90:
RET;12
;=============================
LL100:
ADDA,#11010000B
JCLL110
CPLA
ANLA,#11111B
ORLA,R7
RET;12
LL110:
XRLA,#00111111B
ORLA,R7
NOP
RET;12
;-----------------------------
网友评论:这怎么行,无敌的感觉是很痛苦喔!
I真的服了YOU!
网友评论:实际意义是我接了一排子的
传感器,每个位表示一个传感器,用来检测轮胎宽度,12个传感器一字排开,当测到哪几个传感器有效时判断它们之间的宽度。我不像个位汇编高人,我只让我的程序能正常运行,没有你们那种力求完美的心。程序我也弄好了,就是先从左到右检测,遇到1记下第几位,在从右往左,遇到1记住第几位。简简单单的实现,但对各位的佩服犹如滔滔江水连绵不绝....
网友评论:CONVERT:
;INPUT:
;B:AB:BIT9..15A:BIT0..7
;OUTPUT:
;B:A
JNZL_CV_11
ACALLL_CV10
XCHA,B
RET
L_CV_11:
XCHA,B
JZL_CV10
ORLA,#1
CALLL_CV
L_CV10:
XCHA,B
L_CV:
MOVR7,A
ANLA,#0F0H
JZL_CV1
ANLA,#11000000B
MOVR6,#00011111B
JZL_CV2
MOVR6,#01111111B
SJMPL_CV2
L_CV1:
MOVA,R7
ANLA,#1100B
JZL_CV3
MOVR6,#111B
L_CV2:
MOVA,R7
CPLA
INCA
ANLA,R6
L_CV3:ORLA,R7
RET
;--------------------------------
网友评论:你需要的只是左右两边的“1”之间的间距,中间的要不要填充为1根本不重要。忽悠啊...
网友评论:CONV:
;INPUT:B:A
;OUTPUT:A
MOVR6,#0
MOVR7,#1
CLRF0
CALLL_CV
MOVA,B
CALLL_CV
MOVA,R6
RET
L_CV:
MOVR5,#8
L_CV1:
RRCA
JBF0,L_CV5
JNCL_CV8
SETBF0
INCR6
SJMPL_CV8
L_CV5:
INCR7
JNCL_CV8
MOVR6,A
MOVA,R7
XCHA,R6
L_CV8:
DJNZR5,L_CV1
RET