Heat is nothing more than the motion of molecules within a substance, or the kinetic energy of the molecules. Heat will only pass from hot to cold.
The pressure of a gas may be defined in terms of how hard it pushes against its container or other objects it touches. The temperature and pressure of a gas are related to one and other. If you increase the temperature, the pressure will also increase if the volume is kept constant. If you change the pressure of a gas, the temperature will change as well. One may look upon the compression of a gas much like the compression of a spring. It takes a certain amount of energy to compress the spring a given distance. This energy is stored in the spring. When the spring is allowed to expand, the energy used to compress it is then released. When a gas is compressed, the energy shows up as an increase in temperature and pressure. When the gas is allowed to expand, (releasing the spring), the reduction in pressure will result in an appropriate temperature drop. If some of the stored heat is allowed to escape while the gas is compressed, the temperature of the gas after expansion will be lower than it was prior to the gas being compressed. Why? Heat is energy, and if heat energy is lost, a lower temperature will result when pressures are allowed to return to their initial value.