請問8051七段顯示器程式修改

想請問各位大大修改程式的問題,我想把程式修改成顯示0~9 再從9~0 回來 不過不清楚修改的重點在哪 請問為大大幫忙解釋一下 程式如下:

;file name = 7seg.asm for port 1 flash (program 03-2)

;****************************************************************

ORG 0H ;reset start here

START: ;

MOV R2,#0 ;set 7-seg code index

MOV DPTR,#TABLE ;load table address

LOOP1: MOV A,R2 ;load A with index number

MOVC A,@A+DPTR ;translate number into 7seg code

MOV P1,A ;output 7seg code to port1

CALL DELAY ;delay some time for look slowly

CALL DELAY ;delay

INC R2 ;increase index number

CJNE R2,#10,LOOP1 ;if index not equal 10,jmp next

JMP START ;restart

DELAY: MOV R7,#0 ;delay parameter

$1: MOV R6,#0 ;

DJNZ R6,$ ;

DJNZ R7,$1 ;

RET ;

; 7 segment led display code [pabcdefg] for 0--9

TABLE DB 10000001B ;0's 7seg code

DB 11001111B ;1's 7seg code

DB 10010010B ;2's 7seg code

DB 10000110B ;3's 7seg code

DB 11001100B ;4's 7seg code

DB 10100100B ;5's 7seg code

DB 10100000B ;6's 7seg code

DB 10001111B ;7's 7seg code

DB 10000000B ;8's 7seg code

DB 10000100B ;9's 7seg code

END

這個程式是顯示0~9 就停止ㄌ 要從0~9~0 跑回來請問要怎麼修改! 感恩 幫忙解決一下一問 謝謝!

1 Answer

Rating
  • 1 decade ago
    Favorite Answer

    最簡單的方法

    程式大體不變

    如下

    ;file name = 7seg.asm for port 1 flash (program 03-2)

    ;****************************************************************

    ORG 0H ;reset start here

    START: ;

    MOV R2,#0 ;set 7-seg code index

    MOV DPTR,#TABLE ;load table address

    LOOP1: MOV A,R2 ;load A with index number

    MOVC A,@A+DPTR ;translate number into 7seg code

    MOV P1,A ;output 7seg code to port1

    CALL DELAY ;delay some time for look slowly

    CALL DELAY ;delay

    INC R2 ;increase index number

    CJNE R2,#20,LOOP1 ;if index not equal 10,jmp next

    JMP START ;restart

    DELAY: MOV R7,#0 ;delay parameter

    $1: MOV R6,#0 ;

    DJNZ R6,$ ;

    DJNZ R7,$1 ;

    RET ;

    ; 7 segment led display code [pabcdefg] for 0--9

    TABLE DB 10000001B ;0's 7seg code

    DB 11001111B ;1's 7seg code

    DB 10010010B ;2's 7seg code

    DB 10000110B ;3's 7seg code

    DB 11001100B ;4's 7seg code

    DB 10100100B ;5's 7seg code

    DB 10100000B ;6's 7seg code

    DB 10001111B ;7's 7seg code

    DB 10000000B ;8's 7seg code

    DB 10000100B ;9's 7seg code

    DB 10000100B ;9's 7seg code

    DB 10000000B ;8's 7seg code

    DB 10001111B ;7's 7seg code

    DB 10100000B ;6's 7seg code

    DB 10100100B ;5's 7seg code

    DB 11001100B ;4's 7seg code

    DB 10000110B ;3's 7seg code

    DB 10010010B ;2's 7seg code

    DB 11001111B ;1's 7seg code

    END

    2009-06-11 11:53:54 補充:

    此行改成#20喔

    CJNE R2,#20,LOOP1 ;if index not equal 10,jmp next

    Source(s): 自己的經驗
Still have questions? Get your answers by asking now.