Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Addressing mode
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Simple addressing modes for code== Some simple addressing modes for code are shown below. The nomenclature may vary depending on platform. ===Absolute or direct=== +----+------------------------------+ |jump| address | +----+------------------------------+ (Effective PC address = address) The effective address for an absolute instruction address is the address parameter itself with no modifications. ===PC-relative=== +----+------------------------------+ |jump| offset | jump relative +----+------------------------------+ (Effective PC address = next instruction address + offset, offset may be negative) The effective address for a [[program counter|PC]]-relative instruction address is the offset parameter added to the address of the next instruction. This offset is usually signed to allow reference to code both before and after the instruction.<ref name="maxfield" > Max Maxfield. [https://www.eeweb.com/building-a-4-bit-computer-assembly-language-and-assembler-part-1/ "Building a 4-Bit Computer: Assembly Language and Assembler"]. Section "Addressing modes". 2019. </ref> This is particularly useful in connection with [[Branch (computer science)|jump instructions]], because typical jumps are to nearby instructions (in a high-level language most '''if''' or '''while''' statements are reasonably short). Measurements of actual programs suggest that an 8 or 10 bit offset is large enough for some 90% of conditional jumps (roughly ±128 or ±512 bytes).<ref>{{cite web|last1=Kong|first1=Shing|last2=Patterson|first2=David|author-link2=David Patterson (computer scientist)|title=Instruction set design|year=1995|at=Slide 27|url=http://www.cs.berkeley.edu/~pattrsn/152/lec3.ps}}</ref> For jumps to instructions that are not nearby, other addressing modes are used. Another advantage of PC-relative addressing is that the code may be [[position-independent code|position-independent]], i.e. it can be loaded anywhere in memory without the need to adjust any addresses. ===Register indirect=== +-------+-----+ |jumpVia| reg | +-------+-----+ (Effective PC address = contents of register 'reg') The effective address for a register indirect instruction is the address in the specified register. For example, (A7) to access the content of address register A7. The effect is to transfer control to the instruction whose address is in the specified register. Many RISC machines, as well as the CISC [[IBM System/360]] and successors, have subroutine call instructions that place the [[return statement|return address]] in an address register—the register indirect addressing mode is used to return from that subroutine call.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)