質問

I have a few questions about assembly which I am learning and I am confused by.

  1. What is the difference between bx and bp and ss and sp? The book says that bx is base register and bp is base pointer. Does this mean they are the same thing?

  2. What is the difference with mov ax, bx, mov ax, [bx], mov ax, bp and mov ax, [bp]?

  3. What does disp mean in indexed addressing mode? For example mov al, disp[bx]? or mov al, disp[si]? The book does not explain meaning of disp.

  4. Register is in CPU not RAM right?

    Please excuse my English, it is not my first langugage.

役に立ちましたか?

解決

Oh my, these 16-bit registers became all but obsolete in 1984. Sorry you have an old book. Nevertheless modern processors still use these things, so your question makes sense. I actually wrote some 16-bit assembly back in the day and oddly enough I remember it. Yikes.

  1. BX, BP, SS, and SP are just four separate registers. BX, BP, and SP are general purpose registers (the other 16-bit GPRs are AX, CX, DX, SI, and DI) and SS is a segment register, which you don't use too often (it is implicitly used when you reference BP and SP). A full answer to what each of these registers are far would take up far more space than a usual SO answer should. But to answer your specific question BX and BP are two different registers, not the same one. BP is normally used to index stack frames, and BX is normally used to index into structures or arrays.

  2. MOV AX, BX moves the contents of BX into AX, while MOV AX, [BX] moves the contents of the memory location whose value is in DS:BX into AX. That is, if BX contained the value 500, then the first instruction moves 500 into AX, while the second moves the contents of address 500 (technically 500 bytes past the beginning of segment DS) into AX. (Note there are some subtle differences in the way MOV instructions like this are interpreted in different assemblers, such as MASM and NASM.)

  3. DISP is just an abbreviation for "displacement", a number added to the value in a register to compute something like the address of a variable in a stack frame or an element in a structure. In instructions like MOV AX, [BX+25] then 25 is the displacement.

  4. Yes, registers are part of a CPU.

他のヒント

4: In the x86 architecture, registers are indeed in the CPU and not in RAM. Okay, I don't know of any post-1970 architectures where registers are not manifested in the CPU, but I do know of architectures (8051, for example) where registers are in the same address space as RAM is - or at least the registers are a sub-address space: instructions that access RAM can just as easily access registers, using exactly the same instruction codes, and whether the access goes off-chip to RAM or stays on-chip to the registers, depends only on the address used. In x86 though, the registers' live values are not accessible at all with memory-referencing instructions. (Unless you explicitly or implicitly save them to memory first, but we aren't talking about that here.)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top