NAME Example PUBLIC il ; make il and ih externally visible for linking purposes if needed PUBLIC ih PROG SEGMENT CODE ; declare relocatable segements CONST SEGMENT CODE ; (assembler will convert to absolute addresses) VAR1 SEGMENT DATA BITVAR SEGMENT BIT STACK SEGMENT IDATA RSEG BITVAR flag: DBIT 1 ; declare a single bit data value RSEG VAR1 ih: DS 1 ; 16 bit value in two bytes (i high and i low) il: DS 1 RSEG CONST table: DB 0AH,55H,0FFH,0EEH ;example of a lookup table in ROM RSEG STACK DS 10H ; 16 Bytes for stack CSEG AT 0 USING 0 ; Register-Bank 0 ; Execution starts at address 0 on power-up. JMP START RSEG PROG ; first set Stack Pointer START: MOV SP,#STACK-1 ; initialize the stack MOV PSW,#00 ; start using register bank 0 SETB flag ; demonstrate how to use the bit addressable space CLR flag ; LOOP1: CLR C ; clear the carry flag MOV A,il ; implement delay loop using the value on PORT2 ADD A,P2 ; MOV il,A JNC LOOP1 ; if no low order carry, continue the loop INC ih ; MOV A,ih ; JNZ LOOP1 ; if no high order overflow, continue the loop XRL P1,#01H ; in the event of a carry (from the 16 bit counter) toggle pin 0 of Port 1 SJMP LOOP1 ; do it again END