Kros Dai’ Blog No excuse, no panic

MCS-51(8086)的一个汇编

  到昨天为止,用了一个星期写了一个汇编程序,是这个学期课程设计的作业。这大概是我接触到的最长的一个汇编了吧,感觉真BT。

  目的很简单,就是有八个按钮,分别控制千、百、十、个位的+-(比如按百位的+数字就加100),带进位,在4个7晶体管上显示相应的4位数字,初始值为0000。



ORG 8000H
               LJMP MAIN
ORG 8003H
               LJMP PKEYI
ORG         8100H
MAIN:       MOV R1,#7BH
               MOV R6,#4H
START:     MOV @R1,#0
               DEC R1
               DJNZ R6,START
               LCALL INI79
               LCALL RDIR
PROGN:     JNB 00H,PROGN
               CLR 00H
               MOV R0,#40H
               MOV A,@R0
               CJNEA,#00,NEXT1
               LCALL PROGN0
NEXT1:     CJNE A,#02,NEXT2
               LCALL PROGN1
NEXT2:     CJNE A,#03,NEXT3
               LCALL PROGN2
NEXT3:     CJNE A,#04,NEXT4
               LCALL PROGN3
NEXT4:     CJNE A,#05,NEXT5
               LCALL PROGN4
NEXT5:     CJNE A,#06,NEXT6
               LCALL PROGN5
NEXT6:     CJNE A,#07,NEXT7
               LCALL PROGN6
NEXT7:     CJNE A,#08,PROGN
               LCALL PROGN7
               LCALL 8900H
               LJMP PROGN
ORG 8400H
PROGN0:   MOV R1,#7BH
               MOV A,@R1
               CJNE A,#9H,ADD0
               MOV @R1,#00H
               LJMP EXIT0
ADD0:       INC @R1
EXIT0:      LCALL 8900H
               RET
ORG 8450H
PROGN1:    MOV R1,#7BH
               MOV A,@R1
               CJNE A,#0H,SUB0
               LJMP EXIT1
SUB0:       DEC @R1
EXIT1:      LCALL 8900H
               RET
ORG 8500H
PROGN2:   MOV R1,#7AH
               MOV A,@R1
               CJNE A,#9H,ADD1
               MOV @R1,#0H
               LCALL PROGN0
               LJMP EXIT2
ADD1:       INC @R1
EXIT2:      LCALL 8900H
               RET
ORG 8550H
PROGN3:   MOV R1,#7AH
               MOV A,@R1
               CJNE A,#0H,SUB1
               MOV @R1,#9H
               LCALL PROGN1
               LJMP EXIT3
SUB1:       DEC @R1
EXIT3:      LCALL 8900H
               RET
ORG 8600H
PROGN4:   MOV R1,#79H
               MOV A,@R1
               CJNE A,#9H,ADD2
               MOV @R1,#0H
               LCALL PROGN2
               LJMP EXIT4
ADD2:       INC @R1
EXIT4:      LCALL 8900H
                 RET
ORG 8650H
PROGN5:   MOV R1,#79H
               MOV A,@R1
               CJNE A,#9H,SUB2
               MOV @R1,#9H
               LCALL PROGN3
               LJMP EXIT5
SUB2:       DEC @R1
EXIT5:      LCALL 8900H
               RET
ORG 8700H
PROGN6:   MOV R1,#78H
               MOV A,@R1
               CJNE A,#9H,ADD3
               MOV @R1,#0H
               LCALL PROGN4
               LJMP EXIT6
ADD3:       INC @R1
EXIT6:      LCALL 8900H
               RET
ORG 8750H
PROGN7:   MOV R1,#78H
               MOV A,@R1
               CJNE A,#0H,SUB3
               MOV @R1,#9H
               LCALL PROGN5
               LJMP EXIT7
SUB3:       DEC @R1
EXIT7:      LCALL 8900H
               RET
ORG 8800H
INI79:       MOV DPTR,#0DFFFH
               MOV A,#0DCH
               MOVX @DPTR,A
WNDU:      MOVX A,@DPTR
               JB ACC.7,WNDU
               MOV A,#0
               MOVX @DPTR,A
               MOV A,#34
               MOVX @DPTR,A
               MOV IE,#81H
               RET
ORG 8900H
RDIR:        MOV DPTR,#0DFFFH
               MOV A, #90H
               MOVX @DPTR,A
               MOV R0,#7BH
               MOV R7,#4
               MOV DPTR,#0DEFFH
RDL0:        MOV A,@R0
               ADD A,#6
               MOVC A,@A+PC
               CPL A
               MOVX @DPTR,A
               DEC R0
               DJNZ R7,RDL0
               RET
SEG:         DB 3FH,6,5BH,4FH,
               DB 66H,6DH,
               DB 7DH,7,7FH,6FH,
               DB 77H,7CH
               DB 39H,5EH,79H,71H,
               DB 73H,3EH,
               DB 31H,6FH,1CH,23H,40H,3,
               DB 18H,38H,0
ORG 8A00H
PKEYI:      PUSH PSW
               PUSH DPL
               PUSH DPH
               PUSH ACC
               PUSH B
               SETB PSW.3
               MOV DPTR,#0DFFFH
               MOVX A,@DPTR
               ANL A,#0FH
               JZ PKYR
               MOV A,#40H
               MOVX @DPTR,A
               MOV DPTR,#0DEFFH
               MOVX A,@DPTR
               MOV R2,A
               ANL A,#18H
               RR A
               RR A
               RR A
               MOV B,#2
               MUL AB
               XCH A,R2
               ANL A,#3
               ADD A,R2
               MOV R0,#40H
               MOV @R0,A
               SETB 0
PKYR:        POP B
               POP ACC
               POP DPH
               POP DHL
               POP PSW
               RET1

明天要交的Java作业

  编类似贪食蛇的小程序,给一个二维数组描述蛇的移动轨迹,按照给定的表示蛇身的字符、蛇身的长度,在屏幕上打印出移动轨迹。

  其中我最疑惑的就是怎么用\b实现清屏,我反复试验后发现\b始终不能移到\n的前面。因此暂时用了个比较傻的办法,一次输出很多换行符把上次输出的内容推到屏幕外面……现在默认的是蛇从上游到下,并且一定从第一行移动到最后一行。暂时没有判断给出的地图是否有效。详细的见源程序&.class



手机游戏/图片/铃声的免费网站

  今天才知道原来可以不用移动的“百宝箱”也能下载到手机游戏,并且是免费又好玩的!突然之间很悲凉的感觉,以前付了那么多冤枉钱买那些玩了1/10遍就删掉的游戏。

  http://www.joyes.com 上面有很多超级经典的游戏俄罗斯方块沙罗曼蛇贪食蛇三国大富翁波斯王子大航海时代……我一下午都在拼命下,就嫌6100内存实在太小,一直犹豫不决到底删掉哪个好,弄得现在被迫停机……看来下个开始需要订个GPRS套餐了……



MCS-51(8086)的一个汇编

  到昨天为止,用了一个星期写了一个汇编程序,是这个学期课程设计的作业。这大概是我接触到的最长的一个汇编了吧,感觉真BT。

  目的很简单,就是有八个按钮,分别控制千、百、十、个位的+-(比如按百位的+数字就加100),带进位,在4个7晶体管上显示相应的4位数字,初始值为0000。



ORG 8000H
               LJMP MAIN
ORG 8003H
               LJMP PKEYI
ORG         8100H
MAIN:       MOV R1,#7BH
               MOV R6,#4H
START:     MOV @R1,#0
               DEC R1
               DJNZ R6,START
               LCALL INI79
               LCALL RDIR
PROGN:     JNB 00H,PROGN
               CLR 00H
               MOV R0,#40H
               MOV A,@R0
               CJNEA,#00,NEXT1
               LCALL PROGN0
NEXT1:     CJNE A,#02,NEXT2
               LCALL PROGN1
NEXT2:     CJNE A,#03,NEXT3
               LCALL PROGN2
NEXT3:     CJNE A,#04,NEXT4
               LCALL PROGN3
NEXT4:     CJNE A,#05,NEXT5
               LCALL PROGN4
NEXT5:     CJNE A,#06,NEXT6
               LCALL PROGN5
NEXT6:     CJNE A,#07,NEXT7
               LCALL PROGN6
NEXT7:     CJNE A,#08,PROGN
               LCALL PROGN7
               LCALL 8900H
               LJMP PROGN
ORG 8400H
PROGN0:   MOV R1,#7BH
               MOV A,@R1
               CJNE A,#9H,ADD0
               MOV @R1,#00H
               LJMP EXIT0
ADD0:       INC @R1
EXIT0:      LCALL 8900H
               RET
ORG 8450H
PROGN1:    MOV R1,#7BH
               MOV A,@R1
               CJNE A,#0H,SUB0
               LJMP EXIT1
SUB0:       DEC @R1
EXIT1:      LCALL 8900H
               RET
ORG 8500H
PROGN2:   MOV R1,#7AH
               MOV A,@R1
               CJNE A,#9H,ADD1
               MOV @R1,#0H
               LCALL PROGN0
               LJMP EXIT2
ADD1:       INC @R1
EXIT2:      LCALL 8900H
               RET
ORG 8550H
PROGN3:   MOV R1,#7AH
               MOV A,@R1
               CJNE A,#0H,SUB1
               MOV @R1,#9H
               LCALL PROGN1
               LJMP EXIT3
SUB1:       DEC @R1
EXIT3:      LCALL 8900H
               RET
ORG 8600H
PROGN4:   MOV R1,#79H
               MOV A,@R1
               CJNE A,#9H,ADD2
               MOV @R1,#0H
               LCALL PROGN2
               LJMP EXIT4
ADD2:       INC @R1
EXIT4:      LCALL 8900H
                 RET
ORG 8650H
PROGN5:   MOV R1,#79H
               MOV A,@R1
               CJNE A,#9H,SUB2
               MOV @R1,#9H
               LCALL PROGN3
               LJMP EXIT5
SUB2:       DEC @R1
EXIT5:      LCALL 8900H
               RET
ORG 8700H
PROGN6:   MOV R1,#78H
               MOV A,@R1
               CJNE A,#9H,ADD3
               MOV @R1,#0H
               LCALL PROGN4
               LJMP EXIT6
ADD3:       INC @R1
EXIT6:      LCALL 8900H
               RET
ORG 8750H
PROGN7:   MOV R1,#78H
               MOV A,@R1
               CJNE A,#0H,SUB3
               MOV @R1,#9H
               LCALL PROGN5
               LJMP EXIT7
SUB3:       DEC @R1
EXIT7:      LCALL 8900H
               RET
ORG 8800H
INI79:       MOV DPTR,#0DFFFH
               MOV A,#0DCH
               MOVX @DPTR,A
WNDU:      MOVX A,@DPTR
               JB ACC.7,WNDU
               MOV A,#0
               MOVX @DPTR,A
               MOV A,#34
               MOVX @DPTR,A
               MOV IE,#81H
               RET
ORG 8900H
RDIR:        MOV DPTR,#0DFFFH
               MOV A, #90H
               MOVX @DPTR,A
               MOV R0,#7BH
               MOV R7,#4
               MOV DPTR,#0DEFFH
RDL0:        MOV A,@R0
               ADD A,#6
               MOVC A,@A+PC
               CPL A
               MOVX @DPTR,A
               DEC R0
               DJNZ R7,RDL0
               RET
SEG:         DB 3FH,6,5BH,4FH,
               DB 66H,6DH,
               DB 7DH,7,7FH,6FH,
               DB 77H,7CH
               DB 39H,5EH,79H,71H,
               DB 73H,3EH,
               DB 31H,6FH,1CH,23H,40H,3,
               DB 18H,38H,0
ORG 8A00H
PKEYI:      PUSH PSW
               PUSH DPL
               PUSH DPH
               PUSH ACC
               PUSH B
               SETB PSW.3
               MOV DPTR,#0DFFFH
               MOVX A,@DPTR
               ANL A,#0FH
               JZ PKYR
               MOV A,#40H
               MOVX @DPTR,A
               MOV DPTR,#0DEFFH
               MOVX A,@DPTR
               MOV R2,A
               ANL A,#18H
               RR A
               RR A
               RR A
               MOV B,#2
               MUL AB
               XCH A,R2
               ANL A,#3
               ADD A,R2
               MOV R0,#40H
               MOV @R0,A
               SETB 0
PKYR:        POP B
               POP ACC
               POP DPH
               POP DHL
               POP PSW
               RET1

最高气温26.5度

  今天最高气温达到26.5度,是上海30年来的同期最高值。

  晚上我去食堂吃饭时衣服都湿了,回来洗把脸之后坐在阳台上,风吹上来竟然有夏天的感觉……



This site is licensed under a Creative Commons License .