When opcode is executed by the evm, every number on the stack is a 256-bit (32 byte) number. Small numbers like 5 fit in one byte and can be conveniently put on the stack with PUSH1 0x5
, reducing the size of your contract code in bytes as opposed to PUSH32 0x5
(which takes 33 bytes after compiling to bytecode), but both instructions will put the 32-byte number 0x00...005 on the stack. Since you might regard an "empty number" as the number 0, you can conveniently put the 256-bit number "0" on the stack with PUSH0
instead of PUSH1 0x0
, using 1 byte instead of the previous 2 bytes in the size of your program and also reducing the amount of gas used.
Q1) PUSH1 and up need a number. PUSH1 0x5
will compile, but PUSH1
won't.
Q2) PUSH0 does not allocate 0 bytes on the stack. It allocates 32 bytes, all 0. You cannot specify an argument to PUSH0: PUSH0 0x0
won't compile.
Q3) See Q2.