Casting numbers say which part a block or head is; the stamp and date code say when and where the engine was built. Start with the VIN for what the car left the factory with, then check the engine itself, since engines get swapped.
Where the numbers are and what they mean
Displacement cast — The cubic-inch displacement numbers are cast into both sides of the cylinder block, between the engine mounting bracket bosses (behind the mount plates, between the freeze plugs). Late Jeep Grand Wagoneer 360s show "5.9L" instead.
Casting date code — Build date code is on a tag attached to the right-bank cylinder-head cover: 1st character = year (1978 manual: 2 = 1978; 1981 manual: 0 = 1980, 1 = 1981), 2nd-3rd = month, 4th = engine-type letter, 5th-6th = day. Example 2 05 H 15 = 304 2V 8.4:1 built May 15, 1978.
Engine stamp pad — Engine-type letter in the build code: H = 304 2V 8.4:1; N = 360 2V 8.25:1 (1978 and 1980-81). Oversize/undersize letter codes (B = bores +.010, M = mains -.010, P = rods -.010, C = cam bores +.010) are stamped next to the build code on the same tag. Georgia/Tennessee engines carry an extra non-repeating number on a pad on the left side of the block next to the front core plug.
Casting date code — Build Date Code on a machined surface on the right side of the block between No. 2 and No. 3 cylinders (232/258; 1981 manual words it "left side viewed from front"). 1978 format: year digit, 2-digit month, engine letter, 2-digit day (e.g. 2 03 A 18 = 258 1V 8.0:1, March 18 1978). 4.0 (1994): machined surface on the right side between No. 2 and No. 3 cylinders, format year, month, 2-letter engine code, day (e.g. 401MX12 = 1994 Jan 12, 4.0 MPI 8.7:1).
Engine stamp pad — Oversize/undersize letter code (B, M, P, C, e.g. PM) stamped on a boss between the ignition coil and the distributor; replacement short blocks have an S on the build-code surface.
How to tell a AMC 304 from a 360 vs 401
Read the displacement cast on either side of the block between the motor-mount bosses.
Bore x stroke (factory 1978): 304 = 3.75 x 3.44 in; 360 = 4.08 x 3.44 in. Same stroke, so the bore tells them apart.
Build-code letter: H = 304, N = 360 (1978-81 manuals).
How to tell a Jeep 4.0 from a 4.2 (258)
Bore x stroke: 258 = 3.75 x 3.895 in (232 = 3.75 x 3.50); 4.0 = 3.88 x 3.44 in (98.4 x 87.4 mm).
Build-code engine letters: the 4.0 uses a 2-letter code (MX = 4.0 MPI 8.7:1, 1994); the 258 uses a single letter (A = 258 1V 8.0:1 in 1978; C = 258 2V 8.0:1 in 1980-81).
Chamber and valves differ: 258 head 67.84-70.84 cc, 1.782-1.792/1.401-1.411 in valves; 4.0 head 55.22-58.22 cc, 1.905-1.915/1.495-1.505 in valves.