caramoan tour package

caramoan tour package

Author Topic: 8051 Assembly Code question  (Read 3201 times)

Offline the_next_big_name

  • Size D Battery
  • ******
  • Posts: 250
  • Pogi/Ganda Points: 2
8051 Assembly Code question
« on: May 01, 2009, 07:31:02 PM »
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...

Philippine Electronics Forum

8051 Assembly Code question
« on: May 01, 2009, 07:31:02 PM »

Offline 'yus

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4251
  • Pogi/Ganda Points: 299
  • Gender: Male
  • hw -> fw -> sw
    • yus' projects
Re: 8051 Assembly Code question
« Reply #1 on: May 01, 2009, 09:20:15 PM »
^ patingin naman ng code mo.. :)
join  - Philippine Electronics and Robotics Enthusiasts Club - www.philrobotics.com

Philippine Electronics Forum

Re: 8051 Assembly Code question
« Reply #1 on: May 01, 2009, 09:20:15 PM »

Offline the_next_big_name

  • Size D Battery
  • ******
  • Posts: 250
  • Pogi/Ganda Points: 2
Re: 8051 Assembly Code question
« Reply #2 on: May 01, 2009, 09:30:37 PM »
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 byte
WAIT: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            ;settimer
nxt:JNB RI,nxt            ;wait for character to come in
  etc...etc  ...
down:ljmp here

duon sa wait1 di gumagana kase hahanapin nya na yung sync char 255..pero dati gumagana yan eh

Philippine Electronics Forum

Re: 8051 Assembly Code question
« Reply #2 on: May 01, 2009, 09:30:37 PM »

Offline leoren_tm

  • Size AAA Battery
  • ***
  • Posts: 87
  • Pogi/Ganda Points: 2
Re: 8051 Assembly Code question
« Reply #3 on: May 12, 2009, 11:48:56 AM »
WAIT: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
    CLR RI; baka kulang un code mo?
    WAIT1:JNB RI,WAIT1           ;wait for character to come in

un  WAIT1:JNB RI,WAIT1 line code mo, will be useless, kase naset na un RI flag from   WAIT:JNB RI,WAIT
mahirap un polling kase possible mafreeze un mcu mo, if mali un pattern
 
suggestion: try use interrupt then set the flag

Philippine Electronics Forum

Re: 8051 Assembly Code question
« Reply #3 on: May 12, 2009, 11:48:56 AM »

Offline beginner wan

  • Diesel Generator
  • *
  • Posts: 1451
  • Pogi/Ganda Points: 46
  • Gender: Male
  • Think Positive! Matutupad yang dream mo!
    • [im]Duino
Re: 8051 Assembly Code question: CJNE
« Reply #4 on: June 03, 2009, 10:08:22 PM »
mga masters, lalu na sa mga 8051 enthusiasts dyan, baka pwede patulong naman.. medyo naguluhan lang ako sa CJNE (compare jump if not equal). eto yung code ko..

Code: [Select]
MAIN_STATE EQU R0

ORG 0000h
     .
     .
     .
     .

        MOV  MAIN_STATE, #0

 LOOP:
        MOV     A, MAIN_STATE
CJNE A, #0, STATE1
JMP LCD_ROUTINES

STATE1:
CJNE A, #1, STATE2
JMP KEYPAD_ROUTINES

STATE2:
CJNE A, #2, LOOP
JMP KEYPAD_ACTIONS


LCD_ROUTINES:
        .
        .
        .
        JMP LOOP

      .
      .
      .

END
       

nagtataka lang ako, di pumapasok yung program ko sa LCD_ROUTINE. ano kayang problema?  ???
i;0.?QrEpM?4DEZZ]bkH{w@F<38.Jq@92Ds3KPQj60?EA7U\3M<A84J|AI.H
R@>&?Ej,@;5H)o::7KE/:?QcXf?gX'39=,Z_Q[eYXc

Philippine Electronics Forum

Re: 8051 Assembly Code question: CJNE
« Reply #4 on: June 03, 2009, 10:08:22 PM »

Offline toasted siopao

  • She loves me, she loves me not, she loves me...
  • Global Moderator
  • Gas Turbine
  • *****
  • Posts: 2574
  • Pogi/Ganda Points: 107
  • Gender: Female
    • TeknoBlogger
Re: 8051 Assembly Code question
« Reply #5 on: June 03, 2009, 10:17:07 PM »
The CJNE instruction compares the first two operands and branches to the specified destination if their values are not equal. If the values are the same, execution continues with the next instruction. - http://www.keil.com/support/man/docs/is51/is51_cjne.htm

Parang ok naman code mo, gawin mo kaya #00h, hehehe....


Offline beginner wan

  • Diesel Generator
  • *
  • Posts: 1451
  • Pogi/Ganda Points: 46
  • Gender: Male
  • Think Positive! Matutupad yang dream mo!
    • [im]Duino
Re: 8051 Assembly Code question
« Reply #6 on: June 03, 2009, 10:31:37 PM »
hehehe.. tingin ko din sir ok naman eh.. diko lang alam bakit di sya pumapasok sa routine ko.. kahit #00h ayaw gumana eh..
i;0.?QrEpM?4DEZZ]bkH{w@F<38.Jq@92Ds3KPQj60?EA7U\3M<A84J|AI.H
R@>&?Ej,@;5H)o::7KE/:?QcXf?gX'39=,Z_Q[eYXc

Offline toasted siopao

  • She loves me, she loves me not, she loves me...
  • Global Moderator
  • Gas Turbine
  • *****
  • Posts: 2574
  • Pogi/Ganda Points: 107
  • Gender: Female
    • TeknoBlogger
Re: 8051 Assembly Code question
« Reply #7 on: June 03, 2009, 10:40:12 PM »
Baka ang layo na ng location ng para sa LCD routine mo.

Try mo LJMP.

Offline beginner wan

  • Diesel Generator
  • *
  • Posts: 1451
  • Pogi/Ganda Points: 46
  • Gender: Male
  • Think Positive! Matutupad yang dream mo!
    • [im]Duino
Re: 8051 Assembly Code question
« Reply #8 on: June 03, 2009, 10:43:17 PM »
hndi naman sir.. pasok naman sya.. saka kung malayo di ba sasabihin naman ng compiler yun? address out of range?  ??? hehehe.. ewan ko bakit ganun.. kaka-frustrate..  :-\
i;0.?QrEpM?4DEZZ]bkH{w@F<38.Jq@92Ds3KPQj60?EA7U\3M<A84J|AI.H
R@>&?Ej,@;5H)o::7KE/:?QcXf?gX'39=,Z_Q[eYXc

Offline toasted siopao

  • She loves me, she loves me not, she loves me...
  • Global Moderator
  • Gas Turbine
  • *****
  • Posts: 2574
  • Pogi/Ganda Points: 107
  • Gender: Female
    • TeknoBlogger
Re: 8051 Assembly Code question
« Reply #9 on: June 03, 2009, 10:46:03 PM »
JMP command, based dito sa binabasa ko instruction set is @A + DPTR, mukhang yung tinuturo na address ng content ng A mo + DPTR, dun lulundag ang PC mo.

Offline toasted siopao

  • She loves me, she loves me not, she loves me...
  • Global Moderator
  • Gas Turbine
  • *****
  • Posts: 2574
  • Pogi/Ganda Points: 107
  • Gender: Female
    • TeknoBlogger
Re: 8051 Assembly Code question
« Reply #10 on: June 03, 2009, 10:48:21 PM »
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.htm

The 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.htm

Try SJMP, AJMP or LJMP.

Offline beginner wan

  • Diesel Generator
  • *
  • Posts: 1451
  • Pogi/Ganda Points: 46
  • Gender: Male
  • Think Positive! Matutupad yang dream mo!
    • [im]Duino
Re: 8051 Assembly Code question
« Reply #11 on: June 03, 2009, 10:53:58 PM »
salamat sa tips sir glenjoy.. update ko to pag gumana.. salamat..
i;0.?QrEpM?4DEZZ]bkH{w@F<38.Jq@92Ds3KPQj60?EA7U\3M<A84J|AI.H
R@>&?Ej,@;5H)o::7KE/:?QcXf?gX'39=,Z_Q[eYXc

Offline nucleus

  • Gas Turbine
  • **
  • Posts: 2573
  • Pogi/Ganda Points: 123
  • Gender: Male
Re: 8051 Assembly Code question
« Reply #12 on: June 04, 2009, 12:38:22 AM »
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...

boss 255 = 11111111 in binary ;)
Hi! I'm nucleus and i carry the charge 8)

Hindi ako nandito para makipagkumpitensya kanino man

Offline beginner wan

  • Diesel Generator
  • *
  • Posts: 1451
  • Pogi/Ganda Points: 46
  • Gender: Male
  • Think Positive! Matutupad yang dream mo!
    • [im]Duino
Re: 8051 Assembly Code question
« Reply #13 on: June 04, 2009, 12:40:07 PM »
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.htm

The 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.htm

Try SJMP, AJMP or LJMP.

ayaw pa din sir glenjoy..  :-\

diko pala nasabi, meron akong interrupt dito.. pero sinave ko naman yung mga registers ko.. pero ayaw pa din nya pumasok dun sa sub-routine ko..  :-[
i;0.?QrEpM?4DEZZ]bkH{w@F<38.Jq@92Ds3KPQj60?EA7U\3M<A84J|AI.H
R@>&?Ej,@;5H)o::7KE/:?QcXf?gX'39=,Z_Q[eYXc

Offline 'yus

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4251
  • Pogi/Ganda Points: 299
  • Gender: Male
  • hw -> fw -> sw
    • yus' projects
Re: 8051 Assembly Code question
« Reply #14 on: June 04, 2009, 09:35:42 PM »
ok pala itong proteus.. ngayon ko lang nagamit ang built-in 8051 assembler nya.. :D
na-try ko itong sample code kanina, gumana naman sa proteus simulation.. :)
Code: [Select]
;#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 R7
LOOPA:                         
   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 registers
LOOP:
   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 
*code for led blinker on pin P1.0

nakaka-miss mag DS89C420.. hehe..
join  - Philippine Electronics and Robotics Enthusiasts Club - www.philrobotics.com

Offline marcelino

  • Technical People
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: 8051 Assembly Code question
« Reply #15 on: June 04, 2009, 09:44:32 PM »
^nice.... alam nyo, ginawa ko din yung development board ni glenjoy. but right after ko magawa, nakilala ko na yung PIC. ;D
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Offline beginner wan

  • Diesel Generator
  • *
  • Posts: 1451
  • Pogi/Ganda Points: 46
  • Gender: Male
  • Think Positive! Matutupad yang dream mo!
    • [im]Duino
Re: 8051 Assembly Code question
« Reply #16 on: June 04, 2009, 10:09:46 PM »
na-solve ko na yung problem ko.. kaso parang weird..  ;D
i;0.?QrEpM?4DEZZ]bkH{w@F<38.Jq@92Ds3KPQj60?EA7U\3M<A84J|AI.H
R@>&?Ej,@;5H)o::7KE/:?QcXf?gX'39=,Z_Q[eYXc

Offline DCore

  • Size AAA Battery
  • ***
  • Posts: 76
  • Pogi/Ganda Points: 6
  • Gender: Male
Re: 8051 Assembly Code question
« Reply #17 on: June 05, 2009, 03:53:40 PM »
nice post for 8051 code....  post niyo naman ang mga great project ninyo about 8051 and its corresponding code.
_________________________
There's nothing like EAFF (easy, affordable, fast & fun)

Offline the_next_big_name

  • Size D Battery
  • ******
  • Posts: 250
  • Pogi/Ganda Points: 2
Re: 8051 Assembly Code question
« Reply #18 on: June 09, 2009, 11:01:16 PM »
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 byte
WAIT: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            ;settimer
nxt:JNB RI,nxt            ;wait for character to come in
  etc...etc  ...
down:ljmp here

duon sa wait1 di gumagana kase hahanapin nya na yung sync char 255..pero dati gumagana yan eh

clear ri lang pala kailngan...dinileteko pala yung line na yun kase i have to leave it on the helves for awhile...nakalimutan kong ibalik nung balikan ko yung project....silly me

Offline clarkent

  • Lead Acid Battery
  • *******
  • Posts: 505
  • Pogi/Ganda Points: 20
  • Gender: Male
  • iehs
Re: 8051 Assembly Code question
« Reply #19 on: August 01, 2009, 08:44:32 PM »
ano po bang assembler ang gamit mo sir? penge naman po ng link.hehe tnx
if you think you can or think you can't, you're probably right -h.ford

Philippine Electronics Forum

Re: 8051 Assembly Code question
« Reply #19 on: August 01, 2009, 08:44:32 PM »

 

Privacy Policy

Contact Us: elabph@yahoo.com