Of Pentium 4s, only a very few LGA775 Prescott models, Prescott-2M, and 65nm Cedar Mill variants support NX/XD-bit. Only the "J" model 32-bit P4 has NX-bit while all the others that do are 64-bit. And only G1 stepping P4s had LAHF and SAHF instructions to actually run Win 8.1 in 64-bit mode (the others were stuck with 32-bit 8.1 or 10, or Win 7-64).
Note that the BIOS must expose these features in order for them to work.