Need to use 8 digital outputs as byte

Hi! I am very new to this technology. What I am looking for is a way to use one 8-bit IO port as byte - set all 8 pins as outputs, then write (or read) them at once as byte. Does UNO supports such functionality?

Alternative question - is there a way to program it directly in assembler?

Thanks!

Vladi

Does UNO supports such functionality?

Yes, but only one port has 8 pins, and that port includes the hardware serial pins. Look up Direct Port Manipulation.

Alternative question - is there a way to program it directly in assembler?

That depends on what "it" is. The Arduino can be programmed in assembler.

Thanks, PaulS! This worked fantastic! I am now very encouraged with the results. Now for the second part - C++ kills the poor thing - it takes about 10 times slower to do simple command like digitalWrite, and pretty much the same overhead software size wise. So - can you provide any docs or guidelines about how to upload assembler program to Arduino UNO? Are there any ready-made libraries to use, or I have to do everything from scratch?

Your help is really appreciated!

V.

Like Paul said, Direct Port Manipulation is your friend. E.g. you can set the state of 8 output pins by writing to PORTD:

PORTD = 255;  // set all pins in PORTD high

This is very fast, takes just a couple of clock cycles.

That assumes the data direction register, DDR, for PORTD (DDRD) has been set to output mode as well.
Or that pinMode(pinX) has been called for the 8 pins in setup.

See Section 14 of the datasheet:
"Three I/O memory address locations are allocated for each port, one each for the Data Register – PORTx, Data Direction Register – DDRx, and the Port Input Pins – PINx. The Port Input Pins I/O location is read only, while the Data Register and the Data Direction Register are read/write. However, writing a logic one to a bit in the PINx Register, will result in a toggle in the corresponding bit in the Data Register. In addition, the Pull-up Disable – PUD bit in MCUCR disables the pull-up function for all pins in all ports when set."

If one is going to jump into assembly programming, these kinds of things need to be addressed.

PetriH:
Like Paul said, Direct Port Manipulation is your friend. E.g. you can set the state of 8 output pins by writing to PORTD:

PORTD = 255;  // set all pins in PORTD high

This is very fast, takes just a couple of clock cycles.

Thanks, PetriH! This part I got, and it works very well! Playing with UNO I measured about 200 ns timing for simple increment of the whole port (when I do my own "internal loop"), while digitalWrite on a single bit is about 4 usec! For what I'll try to do this would be showstopper, so now my focus is on how to upload assembler written program to UNO, and what is available as libraries in assembler (if anything)...

Thanks again!