MAIN_STATE EQU R0ORG 0000h . . . . MOV MAIN_STATE, #0 LOOP: MOV A, MAIN_STATE CJNE A, #0, STATE1 JMP LCD_ROUTINESSTATE1: CJNE A, #1, STATE2 JMP KEYPAD_ROUTINES STATE2: CJNE A, #2, LOOP JMP KEYPAD_ACTIONSLCD_ROUTINES: . . . JMP LOOP . . .END
ano ba dahilan bakit kailangan ng 8051 yung ascii code na 255? i am sure na yung assembly program ko was working then all of a suuden, it stopped functioning properly kase nga hinahanap nya na para ting yung sync code na 255...
The JMP instruction transfers execution to the address generated by adding the 8-bit value in the accumulator to the 16-bit value in the DPTR register. Neither the accumulator nor the DPTR register are altered. No flags are affected by this instruction. - http://www.keil.com/support/man/docs/is51/is51_jmp.htmThe AJMP instruction transfers program execution to the specified address. The address is formed by combining the 5 high-order bits of the address of the following instruction (for A15-A11), the 3 high-order bits of the opcode (for A10-A8), and the second byte of the instruction (for A7-A0). The destination address must be located in the same 2KByte block of program memory as the opcode following the AJMP instruction. No flags are affected. - http://www.keil.com/support/man/docs/is51/is51_ajmp.htmTry SJMP, AJMP or LJMP.
;#INCLUDE "8051EQU.INC"; RESET ;reset routine ORG 0H ;locate routine at 00H AJMP START ;jump to START;;**************************************************************************INITIALIZE: ;set up control registers; MOV TCON,#00H MOV TMOD,#00H MOV PSW,#00H MOV IE,#00H ;disable interrupts RET;;**************************************************************************;; Real code starts below. The first two routines are for delays so we; can slow down the blinking so we can see it. (Without a delay, it; would blink so fast it would look like it was always on.;;**************************************************************************;DELAYMS: ;millisecond delay routine; ; MOV R7,#00H ;put value of 0 in register R7LOOPA: INC R7 ;increase R7 by one (R7 = R7 +1) MOV A,R7 ;move value in R7 to Accumlator (also known as A) CJNE A,#0FFH,LOOPA ;compare A to FF hex (256). If not equal go to LOOPA RET ;return to the point that this routine was called from;;**************************************************************************;DELAYHS: ;half second delay above millisecond delay; ; MOV R6,#00H ;put 0 in register R6 (R6 = 0) MOV R5,#002H ;put 2 in register R5 (R5 = 2)LOOPB: INC R6 ;increase R6 by one (R6 = R6 +1) ACALL DELAYMS ;call the routine above. It will run and return to here. MOV A,R6 ;move value in R6 to A JNZ LOOPB ;if A is not 0, go to LOOPB DEC R5 ;decrease R5 by one. (R5 = R5 -1) MOV A,R5 ;move value in R5 to A JNZ LOOPB ;if A is not 0 then go to LOOPB. RET;;**************************************************************************;START: ;main program (on power up, program starts at this point) ACALL INITIALIZE ;set up control registersLOOP: CPL P1.0 ;ComPLement (invert) P1.0 (this makes LED change) ACALL DELAYHS ;go to above routine that causes a delay AJMP LOOP ;go to LOOP(always jump back to point labeled LOOP)END
HERE:JNB RI,HERE ;wait for character to come in MOV A,SBUF ;get data in A CJNE A,#0FFH,DOWN ;chk if the char is synch byte ie.offh or 255 CLR RI ;get ready to get next byteWAIT:JNB RI,WAIT ;wait for character to come in MOV A,SBUF ;get data in A CJNE A,#01H,NXT ;chk if the char is 1 WAIT1:JNB RI,WAIT1 ;wait for character to come in MOV A,SBUF ;get data in A mov a,31h ;store timer in minutes set_timer ;settimernxt:JNB RI,nxt ;wait for character to come in etc...etc ...down:ljmp hereduon sa wait1 di gumagana kase hahanapin nya na yung sync char 255..pero dati gumagana yan eh