简体   繁体   中英

Intel 8051 EdSim51 7 Segment Display

Why does when I remove the "B" in the binary on the code, it messes up when displaying the number?

ORG 0000H
START:
    SETB P3.3
    SETB P3.4
    MOV P1, #11111001
    CALL DELAY
    CLR P3.3
    MOV P1, #10100100
    CALL DELAY
    CLR P3.4
    SETB P3.3
    MOV P1, #10110000
    CALL DELAY
    CLR P3.3
    MOV P1, #10011001
    CALL DELAY
    JMP START
DELAY: MOV R0, #45H
    DJNZ R0, $
    RET
END

Thank you

Because the assembler looks at the last character to determine the base of the number.

If you use:

MOV P1, #10B

It means the binary value 10, giving a decimal 2.

If you use:

MOV P1, #10

It means the decimal 10.

If you use:

MOV P1, #10H

It means the hex value 10, giving a decimal 16.

Note: Your assembler should have warned you about a number overflow or so.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM