0
\$\begingroup\$

I am looking at an ST7066U controller for a 2x16 LCD. The datasheet has these assembly instructions that I would like to change to C code.

CHK_BUSY: ;Check Busy Flag
CLR RS
SETB RW
SETB E
JB P1.7,$
CLR E
RET 

What does JB P1.7, $ mean?

\$\endgroup\$
2
  • 3
    \$\begingroup\$ This type of question is usually answered directly by just looking at the datasheet or assembly language reference for your particular processor. \$\endgroup\$
    – user4574
    Nov 30, 2020 at 16:49
  • 2
    \$\begingroup\$ High-time you start to learn how to read datasheets. \$\endgroup\$
    – Mitu Raj
    Nov 30, 2020 at 19:03

2 Answers 2

5
\$\begingroup\$

The JB instruction branches to the address specified in the second operand if the value of the bit specified in the first operand is 1. The bit that is tested is not modified. No flags are affected by this instruction.

Source: https://www.keil.com/support/man/docs/is51/is51_jb.htm

\$\endgroup\$
2
  • \$\begingroup\$ I read that in the datasheet, I understood that part, if the first operand P1.7 is HIGH, then it shall go to the address in the second operand $, however I didn't understand it in this context, which address does $ points to? \$\endgroup\$ Nov 30, 2020 at 23:53
  • \$\begingroup\$ The $ refers to the address of the instruction itself, so the instruction is executed over and over again, until the device is no longer busy. \$\endgroup\$ Jul 20, 2022 at 7:29
4
\$\begingroup\$

The ST7066U's datasheet has some example code for the 8051 MPU.

From the 8051's instruction set:

Operation:   JB
Function:    Jump if Bit Set
Syntax:      JB bit addr, reladdr

Instructions         OpCode  Bytes  Flags
JB bit addr,reladdr  0x20    3      None

Description: JB branches to the 
address indicated by reladdr if 
the bit indicated by bit addr 
is set. 
If the bit is not set program 
execution continues with the 
instruction following the JB 
instruction.
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.