OK, let's try to break it down in detail.
lukassevc wrote:I was trying to figure out what's the width of PC memory because when I read that the real mode can access only 1 MiB of memory and I was confused since the width of the data bus is 16 bits, which means that it should be correctly MiW or whatever, where W stands for word as 16 bits
The real reason is simple: because memory is addressed in bytes, not system words (more on the term 'words' shortly). Each address, regardless of the width of the address space, points to a specific byte in memory.
This means that adding one to a pointer - again, regardless of the size of the variable being pointed to - means it is pointing to the next byte in memory.
These bytes may be aggregated into larger variables, each comprised of two or more bytes, but the addresses still are to the individual bytes within that variable.
So in order to walk through an array of bytes using a pointer (rather than an index), you would add one to the pointer; to walk through an array of 16-bit values, you would add two to the pointer; to walk through an array of 128-byte data structures, you would increment the pointer by 128; and so forth.
Compilers for languages such as C will automatically adjust how much to increment a pointer by, which is what is referred to as 'pointer arithmetic'. It is simply hiding the implementation details to make things easier.
You also have matters of byte alignment, where certain variables must (or at least should) be aligned on addresses which are even multiples of 2, 4, 8, etc. in order to be usable at maximum performance. This is unrelated to the address width or data bus width, however.
Note regarding terminology: outside of the world of x86, 'word' refers to the 'system word', that is to say, the largest value a CPU can hold in a general-purpose register; thus, for a 32-bit ARM, a 'word' is 32 bits, while for a 64-bit ARM, a 'word' is 64 bits. The use of 'word', double-word', 'quad-word', in x86 usage is something of an artifact of the development of 16, 32, and eventually 64 bit models of the x86 line. None of this really changes the fact that the memory is addressed by individual bytes on all modern-day machines (there were systems which addressed by words longer than one byte in the past, but none are in regular use today).
As an historical aside, the size of a byte as eight bits is itself a convention, first adopted by IBM in the 1960s but becoming more or less universal by the late 1970s.
lukassevc wrote:And if so, how are instructions stored in the memory? For example the MOV instruction, are the opcode and the parameters stored on multiple addresses? And if so, what's the value of the other unused bits in the let's say QW opcode? Is it just 0?
This is going to depend on the Instruction Set Architecture (ISA), but for x86, instructions are of variable width, so the CPU has to decode the first byte in order to know how many other bytes it needs to fetch in order to decode the whole instruction. On older implementations of the ISA (which fetched directly from memory), this made it relatively slow to decode multi-byte instructions, but modern Intel and AMD CPUs not only cache the instruction stream, and pipeline the instructions to allow for complex decoding, they also use several clever tricks to break down instructions into simpler forms which are what actually get run.
For the MOV example, that mnemonic actually maps to several different instructions, which start with one of several different and distinct opcodes. The shortest of these is a single byte; others may be considerably longer. The CPU has to then fetch the rest of the instruction bytes, if any, in order to know things such as addresses.
This is in contrast to most other modern CPU ISAs, the majority of which are designed on the RISC (Reduced Instruction Set Computer) philosophy. One of the tenets if RISC is to use fixed-width instructions in order to simplify instruction decoding. Generally, RISC CPUs will have an instruction width of 32 bits (4 bytes) across the board, even for instructions operating directly on memory (which they general restrict to load and store operations, with everything else being done in registers - which is part of why most RISC designs have a register set of at least 16 general-purpose registers).
lukassevc wrote:And when I read from the drive is it stored on multiple addresses by 1 byte or by a QW and occupying much less address space?
Peripherals such as disk drives are a separate subject from the ISA and memory addressing, really - it all depends on the device and how it is mapped into either I/O space or memory (or both).
In the case of a disk drive, those are block devices - they always read a full block into memory, which generally means at minimum 512 bytes (one standard disk sector). Even if all you need is a single byte, it will always buffer at least one full block.
lukassevc wrote:And when I use the lods- instructions, it reads just the lower N bits of the whole QW?
No, it operates on the number of bytes indicated by the word size character (b/w/d/q), no more, no less.
lukassevc wrote:And does it mean that in the PM mode I can simply store whole UTF-8 character on a single memory address?
No, because each address is always one byte, and a UTF-8 character could be two or four bytes long.