简体   繁体   中英

What does “Addressed by” in Assembly language mean

I was just wondering if when you say "the data address by BP (or any register)" is the same as [BP] notation, and if not what does it mean? Examples are appreciated as well

I'm assuming this is 16 bit real mode. Assume that bp = 0xFFFE, and ss = 0x1000. Note that using bp as a base register implies using ss as the segment register.

        mov     ax,ss:[bp]    ;load ax with data from address 0x1FFFE

The math for calculating the address is to multiply the value in the segment register by 16, then to add the offset. For 8086, the offset can be a combination of an immediate offset plus a base register: bx or bp, plus an index register: si or di. An example link to 8086 addressing modes:

https://courses.engr.illinois.edu/ece390/books/artofasm/CH04/CH04-2.html

In order to access a byte at some address, with most processors you can put the address you want to access in a general purpose register then using the proper instruction and/or addressing mode you can access data at or starting at that address.

In pseudo code

mov r0,#0x12345678
mov r1,#0x11223344
str r1,[r0]

So I put the address 0x12345678 in register 0 and I put the value I want to write to that address in r1. Then I tell the processor to store the value in r1 (0x11223344) in memory at the address contained in r0 (0x12345678). The processor reads the register r0, takes that value which is the address, and uses that on the address bus, and the value it reads from r1 on the data bus and performs the store (write). In this case I am doing a 32 bit write to that address.

Syntax and instruction set varies from one architecture/target to another. Some instruction sets let you do the load or store (sometimes just use mov or move generically for both load and store) directly to memory with the address specified in the instruction, often those will offer an addressing mode that is register based and not immediate. Other instruction sets you must use registers to hold the address you want to access for all transactions.

It simply means that BP contains an address and that that address is used to access data. Using a syntax [BP] means you want the memory contents addressed by the register, not the contents of the register itself. In other words, if BP contains an address,

MOV AX,BP 

copies the address (the contents of BP ) into AX , but

MOV AX,[BP]

copies the contents of the memory addressed by BP into AX .

That is what they mean when they write "addressed by".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM