digitalWrite(pin,INPUT_PULLUP) is the same as digitalWrite(pin,2) (INPUT_PULLUP is just #define). That in turn is the same as digitalWrite(pin,HIGH), because 2 is not equal to 0.
See source https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring_digital.c
The key part of the code for digitalWrite is:
if (val == LOW) {
*out &= ~bit;
} else {
*out |= bit;
}
where *out is a pointer to the PORTx register, and bit is (1<<(number of pin within port).
When the corresponding bit in the PORTx register is set, if the pin is an output, it will drive the pin HIGH, and if it's set as input, it will enable the pullups.
Corresponding code from pinMode, if it matters to anyone:
if (mode == INPUT) {
uint8_t oldSREG = SREG;
cli();
*reg &= ~bit;
*out &= ~bit;
SREG = oldSREG;
} else if (mode == INPUT_PULLUP) {
uint8_t oldSREG = SREG;
cli();
*reg &= ~bit;
*out |= bit;
SREG = oldSREG;
} else {
uint8_t oldSREG = SREG;
cli();
*reg |= bit;
SREG = oldSREG;
}
here, *reg is pointer to the DDRx register, which sets whether the pin is an input or output.
The saving of SREG, cli() to disable interrupts, then restoring SREG after (which will turn interrupts back on, if they were on before) is needed to make the operation atomic (ie, to prevent an interrupt from happening in in the middle of that read-modify-write process implied by |= and &=); there is a similar safeguard in digitalWrite, only outside of the if statement.
(note that above discussion applies to AVR micros, not ones with other architectures)