Home > Net >  What differs the bp and si when memory addressing in assembly (emu8086)?
What differs the bp and si when memory addressing in assembly (emu8086)?

Time:05-02

I'm using emu8086 microprocessor emulator I wonder why when I try to place a value inside a memory address with SI it places right in DS:SI but when I try to place it with BP it goes to DS:BP 20h here's with SI

and here's with BP

I'm sure it's something with SI being 8 bits and BP 16 bits but I don't know why it goes like that

CodePudding user response:

Your program has a DATA section containing a single 17 byte string. This DATA section is followed immediately by the STACK section. Sections get paragraph aligned (16 bytes), so the DATA section is extended to have 32 bytes. This corresponds to 2 paragraphs and that is the difference that you see when looking at the values for DS and SS that mark the start of those sections:

DS=0710h
SS=0712h

An instruction that uses [si] addresses the DS segment, and an instruction that uses [bp] addresses the SS segment.

Because there's a difference of 32 bytes between these sections, you can address the first byte of the STACK section normally through mov al, [bp] (BP=0) but also via mov al, [0020h] or mov al, [ds:bp 32].


I'm sure it's something with SI being 8 bits and BP 16 bits

SI is a 16-bit register.
The 8-bit registers are AL, AH, BL, BH, CL, CH, DL, and DH.
The 16-bit registers are AX, BX, CX, DX, SI, DI, BP, SP, CS, DS, ES, and SS.

  • Related