Unfortunately, x86 coding is complex and irregular, and understanding this is hard work. The best "quick start" in encoding is a set of HTML pages on sandpile.org (it is short, but rather thorough).
First: http://sandpile.org/x86/opc_enc.htm - the do-it-yourself coding table shows about a dozen ways to encode instructions. The white cells in each row are required bytes in the instruction; the following gray cells exist (or not) based on various fields that appear earlier in the operation code. You should look at the lines starting with white โ0Fhโ, as well as with the first line. At the bottom of the same page are bit fields that appear in different "extended" fields of the operation code - you ignore everything except the line "modrm / sib" (first line).
Note that for all but the first line (this is a 1-byte operation code), the mod r / m byte should follow the operation code (for 1-byte operation codes, this depends on the command). This encodes the arguments for most instructions with two arguments. The table http://sandpile.org/x86/opc_rm.htm has values: one of the arguments must be a register, the other argument can be a register or indirect memory (the "reg" field encodes the register, the "mod" and "r / m" fields encode another argument). Usually, there is also a โdirectionโ bit elsewhere in the opcode indicating the order of the arguments. The operation code also indicates whether we will manipulate, for example, AL, AX, EAX or RAX (that is, different sizes) or one of the extended registers, so each 3-bit field is indicated as referring to many different registers.
In modrm, if the โmodโ bit is โ11โ, then the โr / mโ field is also case sensitive. Otherwise, it usually refers to a memory address created by adding a named register to the (optional) offset that appears after the modrm byte (this constant has a length of 0, 1, or 4 bytes, depending on the "mod" bit). The exception is that the โr / mโ bit is โ100โ (that is, 0x4), which is usually called โSPโ - in this case, the memory argument is described by the optional โsibโ byte, which immediately follows the modrm byte (any offset modrm appears after sib). For SIB encoding, see http://sandpile.org/x86/opc_sib.htm or go to the modrm page.
Finally, to understand where the direction and size came from, look at some opcode: http://sandpile.org/x86/opc_1.htm . The first four entries are "ADD", with arguments in two different orders and having two different widths. Thus, in this case, the lower bits of the instruction encode the direction and width.