1
\$\begingroup\$

In the following video(at 10min):

https://www.youtube.com/watch?v=YELGX5XDCiY&list=PLgwJf8NK-2e55CdbY_WnY6pejPHoojCkJ&index=18

The microcontroller used in the video series is ATmega32.

Let's take the following assembly instruction to read the content of location 0x005F of EEPROM into PORTB

LDI R16,0xFF
OUT DDRB,R16  ; These instruction used to configure PORTB as output

WAIT: 
    SBIC EECR,EEWE  ;
    RJMP WAIT
    .
    .
    .
    .

It says that the loop is used to wait for EEWE to become zero. SBIC is an immediate subtraction with carry; is used to subtruct a bit (EEWE) from its own control 8bit register and yet check if EECR is zero (I expect to check the bit EEWE and not the whole register)

Could anyone please explain to me how SBIC works together with RJMP to check EEWE ? Could anyone explain to me how these two instructions (SBIC and RJMP)

\$\endgroup\$
0

1 Answer 1

3
\$\begingroup\$

SBIC isn't "subtract immediate with carry", that's SBCI.

SBIC is "skip [the next instruction] if bit [in an I/O register] is clear".

So the SBIC tests whether the bit EEWE in EECR is set. If it's set, the next instruction executes, and that instruction is a jump back to the SBIC. On the other hand, if that bit is zero, the RJMP is skipped and execution continues at the "...".

\$\endgroup\$

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