user37987: How does one control a digital pin directly avoiding the slow digitalWrite or digitalRead?

user40094: Unfortunately, Ratchet Freak's answer is specific to AVR, and isn't how the ESP8266 works.
It looks like the ESP8266 does indeed have registers for doing exactly this, which would let you set all 16 GPIO pins (GPIO0 through GPIO15, 16 is a different thing entirely) with a single operation. There's also a SET register, which sets the pins corresponding to 1 bits, and ignores pins corresponding to 0 bits, and a CLEAR register, which is the other way around. 
Something I found on a forum said a user went from ~800KHz to ~5.7MHz toggling pins using these direct registers, that sounds about right.
One version of this is found in eagle_soc.h. The relevant bits from the header to get you started:
#define GPIO_REG_READ(reg)                         READ_PERI_REG(PERIPHS_GPIO_BASEADDR + reg)
#define GPIO_REG_WRITE(reg, val)                 WRITE_PERI_REG(PERIPHS_GPIO_BASEADDR + reg, val)
#define GPIO_OUT_ADDRESS                         0x00
#define GPIO_OUT_W1TS_ADDRESS             0x04
#define GPIO_OUT_W1TC_ADDRESS             0x08

So, if I've understood this correctly (and I haven't done any real testing, just going off the spec sheet and the header and posts elsewhere):
GPIO_REG_WRITE(GPIO_OUT_ADDRESS, 0xF0F0);

would set GPIO 4-7 and 12-15 to high, and 0-3 and 8-11 to low. In one operation. But there's more! Look at those W1TS and W1TC names. Those are set and clear registers. Which means you don't have to mask things. Instead of grabbing the current value, masking a bit in or out, and then writing it back, you can use those:
GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, 0x1);

This will set GPIO0 high, and not affect any other bits.
This is also offered in a cleaner/simpler (??) form in esp8266_peri.h, which simplifies it to:
GPOS = 0x1;

for setting a bit. This is what's actually called by the arduino library's digitalWrite (for pins other than GPIO16):
extern void ICACHE_RAM_ATTR __digitalWrite(uint8_t pin, uint8_t val) {
  pwm_stop_pin(pin);
  if(pin < 16){
    if(val) GPOS = (1 << pin);
    else GPOC = (1 << pin);
[...]

But definitely be aware of this if you're doing anything fast, because writing multiple pins with a single operation is going to be way faster than multiple function calls. Without this, this chip can't even toggle bits as fast as a 16MHz Arduino.

user37987: After a weekend of searching and trying, here is what I was looking for:
It is slightly different than for the AVR chips. There is one register for setting the pins to HIGH and another one to set the pins to low.
Setting the pin HIGH:
GPOS = (1 << PIN_OUT);

Setting the pin LOW:
GPOC = (1 << PIN_OUT);

using this, I managed to speed up my code by a factor of three. It is not as dramatic as for the AVR chips, since the digitalWrite function is much more simple for the ESP8266.
Edit Further experiments show it is 10x faster: 910nsec for digitalWrite vs. 88nsec using GPOC or GPOS!

37987: <p>How does one control a digital pin directly avoiding the slow digitalWrite or digitalRead?</p>
 40094: <p>Unfortunately, Ratchet Freak's answer is specific to AVR, and isn't how the ESP8266 works.</p>

<p>It looks like the ESP8266 does indeed have registers for doing exactly this, which would let you set all 16 GPIO pins (GPIO0 through GPIO15, 16 is a different thing entirely) with a single operation. There's also a SET register, which sets the pins corresponding to 1 bits, and ignores pins corresponding to 0 bits, and a CLEAR register, which is the other way around. </p>

<p>Something I found on a forum said a user went from ~800KHz to ~5.7MHz toggling pins using these direct registers, that sounds about right.</p>

<p>One version of this is found in <code>eagle_soc.h</code>. The relevant bits from the header to get you started:</p>

<pre><code>#define GPIO_REG_READ(reg)                         READ_PERI_REG(PERIPHS_GPIO_BASEADDR + reg)
#define GPIO_REG_WRITE(reg, val)                 WRITE_PERI_REG(PERIPHS_GPIO_BASEADDR + reg, val)
#define GPIO_OUT_ADDRESS                         0x00
#define GPIO_OUT_W1TS_ADDRESS             0x04
#define GPIO_OUT_W1TC_ADDRESS             0x08
</code></pre>

<p>So, if I've understood this correctly (and I haven't done any real testing, just going off the spec sheet and the header and posts elsewhere):</p>

<pre><code>GPIO_REG_WRITE(GPIO_OUT_ADDRESS, 0xF0F0);
</code></pre>

<p>would set GPIO 4-7 and 12-15 to high, and 0-3 and 8-11 to low. In one operation. But there's more! Look at those <code>W1TS</code> and <code>W1TC</code> names. Those are set and clear registers. Which means you <em>don't</em> have to mask things. Instead of grabbing the current value, masking a bit in or out, and then writing it back, you can use those:</p>

<pre><code>GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, 0x1);
</code></pre>

<p>This will set GPIO0 high, and not affect any other bits.</p>

<p>This is also offered in a cleaner/simpler (??) form in <code>esp8266_peri.h</code>, which simplifies it to:</p>

<pre><code>GPOS = 0x1;
</code></pre>

<p>for setting a bit. This is what's actually called by the arduino library's digitalWrite (for pins other than GPIO16):</p>

<pre><code>extern void ICACHE_RAM_ATTR __digitalWrite(uint8_t pin, uint8_t val) {
  pwm_stop_pin(pin);
  if(pin &lt; 16){
    if(val) GPOS = (1 &lt;&lt; pin);
    else GPOC = (1 &lt;&lt; pin);
[...]
</code></pre>

<p>But definitely be aware of this if you're doing anything fast, because writing multiple pins with a single operation is going to be <em>way</em> faster than multiple function calls. Without this, this chip can't even toggle bits as fast as a 16MHz Arduino.</p>
 37987: <p>After a weekend of searching and trying, here is what I was looking for:</p>
<p>It is slightly different than for the AVR chips. There is one register for setting the pins to HIGH and another one to set the pins to low.</p>
<p>Setting the pin HIGH:</p>
<pre><code>GPOS = (1 &lt;&lt; PIN_OUT);
</code></pre>
<p>Setting the pin LOW:</p>
<pre><code>GPOC = (1 &lt;&lt; PIN_OUT);
</code></pre>
<p>using this, I managed to speed up my code by a factor of three. It is not as dramatic as for the AVR chips, since the digitalWrite function is much more simple for the ESP8266.</p>
<p><strong>Edit Further experiments show it is 10x faster</strong>: 910nsec for <code>digitalWrite</code> vs. 88nsec using <code>GPOC</code> or <code>GPOS</code>!</p>
