Start as mario and have the L+up 'sprint' code (and possibly the Moonjump code) turned on. Stand on the bridge to the castle then, sprint and dive (press A while running) into the wall behind where you started your save file from.
If you did it right you should teleport high up into the air and stay in the diving position. If you press A or B, you will fall.
Happy glitching!