*12456789012345678901245678901234567890124567890123456789 * DEMO.ASM * This simple program adds the contents of * address $0000 (labeled VAR0) to the contents of * address $0001 (labeled VAR1) and stores the resulting * sum at address $0002 (labeled SUM), provided * the addition process happens without overflow. * If an overflow occurs during the addition process, * the overflow flag OVERFL (stored at address $0003) * is set to $FF; else, it stays $00. * Include definition of variables for MC68HC11 #INCLUDE 'A:\VAR_DEF.ASM' * Define program variables ORG DATA VAR0 RMB 1 ;reserve 1 byte for VAR0 VAR1 RMB 1 ;reserve 1 byte for VAR1 SUM RMB 1 ;reserve 1 byte for sum OVERFL RMB 1 ;reserve 1 byte for overflow flag * Start main program ORG PROGRAM LDAB #00 ;assume no overflow (optimistic!) LDAA VAR0 ;load VAR0 in accumulator A ADDA VAR1 ;add VAR1 to accumulator A BVC LABEL1 ;jump if no overflow * We have overflow! COMB ;Invert accumulator B ($00 to $FF) LABEL1 STAA SUM ;store result of addition STAB OVERFL ;store accB into overflow flag SWI ;stop the microcontroller