COA Module 2 Notes
COA Module 2 Notes
MODULE 2 Part 2
Addressing Modes
• Programmers use organizations called data structures to represent the data used in computations.
These include lists, linked lists, arrays, queues, and so on.
• The different ways in which the location of an operand is specified in an instruction are referred
to as addressing modes.
• Note: Operands are nothing but data or information on which operation has to be performed.
• Effective Address (EA) – It is the address of the operand/data. It is calculated depending upon the
different types of addressing modes.
• Variables and constants are the simplest data types and are found in almost every computer
program.
• In assembly language, a variable is represented by allocating a register or a memory location to
hold its value.
• Thus, the value can be changed as needed using appropriate instructions.
• Two of the addressing modes that can be used to access variables are:
• Register mode
• Absolute mode
• Register Mode– The operand is the contents of a processor register; the name (address) of the
register is given in the instruction.
• Absolute Mode– The operand is in a memory location; the address of this location is given
explicitly in the instruction. This mode is also called Direct mode.
• The instruction
Move LOC,R2
uses these two modes.
Here LOC represents a memory location (absolute mode) and R2 is a register (register mode).
• Processor registers are used as temporary storage locations where the data in a register are accessed
using the Register mode.
• The Absolute mode can represent global variables in a program.
• A declaration such as
Integer A,B
in a HLL program will cause the compiler to allocate a memory location to each of the variables
A and B. Whenever they are referenced later in the program, the compiler can use the Absolute
mode to access these variables.
• But using a subscript to denote Immediate mode is not appropriate in assembly languages.
• Instead sharp sign (#) is used in front of the value to indicate that this value is to be used as an
immediate operand.
• Hence we write the instruction above in the form
Move #200,R0
• This statement can be implemented using Immediate mode and Absolute mode as follows:
Move B,R1
Add #6,R1
Move R1,A
• Constants are also used in assembly language to increment a counter, test for some bit pattern and
so on.
• In the figure 2.11a, the contents of R0 is to be added with the contents of memory location B
whose address is present in R1.
• The operand is present in main memory location B which is to be added with R1.
• A general-purpose register R1 is used to store the address of memory location B.
• Since the operand in memory location B is being accessed indirectly through the general-purpose
register R1, this type of addressing is called Indirect addressing mode (through general purpose
register).
• Instead of using general-purpose register, a memory location can also be used to store the address
of the memory location holding the operand (in this case B) as shown in figure 2.11b.
• Here the register or memory location that contains the address of an operand is called a pointer.
• In the above example, register R1 (fig 2.11a) and memory location A (fig 2.11b) are acting as
pointers.
• By changing the contents of a pointer, which points to the address of the operand, another operand,
can be accessed by keeping the same add instruction. (Treasure hunt analogy)
• Consider the figure below-
• The program uses indirect addressing to add the list of numbers starting from the memory location
NUM1.
• Register R2 is used as a pointer to the numbers in the list, and the operands are accessed indirectly
through R2.
• Counter value n is loaded from the memory location N into R1.
• The address value of the first number in the list is NUM1. Here immediate addressing mode is
used to place this address into R2.
• Then R0 is cleared to zero.
• The address of the next instruction Add (R2),R0 is given the name LOOP.
• Here the operand at the location NUM1 is fetched and added to R0.
• The second Add instruction adds 4 to the contents of pointer R2, so that it will contain the address
value of NUM2.
NUM2 2004 3
NUM3 2008 4
NUM4 2012 6
NUM5 2016 8
• Let N=5. Let us assume that the memory locations NUM1 to NUM5 has the addresses and contents
as shown in above table.
• Step 1: The counter value 5 present in N is copied to R1.
• Step 2: The value of the address of NUM1 which is 2000 is copied to R2.
• Step 3: R0 is cleared to zero.
• Step 4: Add (R2),R0 i.e the contents of R2=2000 which is the address of memory location
NUM1 where operand value 1 is stored and this value is added to the contents of R0 which is 0
[1+0=1]. This result is stored in R0.
• Step 5: Add #4,R2 → this instruction adds a value of 4 to the contents of R2 which is presently
2000 [2000+4=2004]. Therefore, the contents of R2 is now 2004 which is the address of NUM2.
• Step 6: R1 is decremented by the value of one, i.e R1=5-1=4.
• Step 7: Since the count value is not equal to zero, the execution jumps back to LOOP.
• Step 8: Add (R2),R0 i.e the contents of R2=2004 which is the address of memory location
NUM2 where operand value 3 is stored and this value is added to the contents of R0 which is 1
[1+3=4]. This result is stored in R0.
• Step 9: Add #4,R2 → this instruction adds a value of 4 to the contents of R2 which is presently
2004 [2004+4=2008]. Therefore, the contents of R2 is now 2008 which is the address of NUM3.
• Step 10: R1 is decremented by the value of one, i.e R1=4-1=3.
• Step 11: Since the count value is not equal to zero, the execution jumps back to LOOP.
• This process is repeated until the count value becomes zero.
• Step 12: The final sum present in R0 is copied to the memory location named SUM.
• In figure a, the index register, R1, contains the address of a memory location, and the value X
defines an offset (or displacement) from this address to the location where the operand is found.
• The contents of index register R1 is 1000, which is an address and to this address the offset value
20 is added which gives the value 1020.
• The address 1020 is the address at which the operand, which is to be added with the contents of
R2, is present.
• In figure b, the constant X corresponds to a memory address, and the contents of the index register
define the offset of the operand.
• In this method, the memory address value 1000 is added to the index register value i.e 20 to get
the value 1020, which is the address at which the operand to be added with R2 is present.
• In either case, the effective address is the sum of two values; one is given explicitly in the
instruction, and the other is stored in a register.
• To see the usefulness of the indexed addressing, consider a simple example involving a list of test
• A four-word memory block comprises a record that scores the relevant information for each
student.
• Each record consists of the student’s ID, followed by the scores the student earned on three tests.
• There are n students in the class, and the value n is stored in location N.
• The addresses given in the figure for the student IDs and test scores assume that the memory is
byte addressable and that the word length is 32 bits.
• The above figure can be considered as a two-dimensional array having n rows and four columns,
where each row contains the entries for one student and the columns give the IDs and test scores.
• Suppose that we wish to compute the sum of all scores obtained on each of the tests and store these
three sums in memory locations SUM1, SUM2 and SUM3.
• A possible program for this task is given in the figure below.
• In the body of the loop, the program uses the Index addressing mode in the manner depicted in
figure a, to access each of the three scores in a student’s records.
• Register R0 is used as the index register.
• Before entering the loop, R0 is set to point to the ID location of the first student record; thus it
contains the address LIST.
• On the first pass through the loop, test scores of the first student are added to the running sums
held in the registers R1, R2 and R3, which are initially cleared to 0.
• These scores are accessed using the Index addressing modes 4(R0), 8(R0) and 12(R0).
• The index register R0 is then incremented by 16 to point to the ID location of the second student.
• Register R4, initialized to contain the value n, is decremented by 1 at the end of each pass through
the loop.
• When the contents of R4 reach 0, all students records have been accessed, and the loop terminates.
• Until then the conditional branch instruction transfers control back to the start of the loop to process
the next record.
• The last three instructions transfer the accumulated sums from registers R1, R2 and R3, into the
memory locations SUM1, SUM2 and SUM3 respectively.
• (Ri,Rj) → here the effective address is the sum of the contents of the registers Ri and
Rj. The second register (i.e Rj) is usually called the base register. This form of indexed
addressing provides more flexibility in accessing operands, because both components
of the effective address can be changed.
• X(Ri,Rj) → here the effective address is the sum of the constant X and the contents of
registers Ri and Rj. This added flexibility is useful in accessing multiple components
inside each item in a record i.e this mode implements a three-dimensional array.
Relative Addressing
• Instead of using a general-purpose register, we can also use PC as an index register.
• Then, X(PC) can be used to address memory location that is X bytes away from the location
presently pointed to by the program counter.
• Relative Mode – The effective address is determined by the index mode using PC in place of
general-purpose register Ri.
• The most common use of this addressing mode is to access specific target address, in case of
branch instructions.
Branch>0 LOOP
this causes the program execution to go to the branch target location identified by the name LOOP
if branch condition is satisfied.
• This location, i.e the location of the branch name LOOP, can be computed by specifying it as an
offset from the current value of the PC.
• Since the branch target may be either before or after the branch instruction, the offset is given as a
signed number.
Additional Modes
• There are two modes which can access data items in successive locations in memory.
• Autoincrement Mode – The effective address of the operand is the contents of the register
specified in the instruction. After accessing the operands, the contents of this register are
automatically incremented to point to the next item in a list.
Assembly Language
• Machine instructions are represented by patterns of 0s and 1s.
• In programs, we use symbolic names to represent this patterns (ex. Move, Add) which are
acronyms for the symbolic names called Mnemonics.
• A set of mnemonics and the rules for their use constitute a programing language referred to as an
assembly language.
• The assembly language is a readable representation of the machine language for the processor.
• Assembler coverts the assembly language instructions into machine language instructions.
• Assembler program is one of a collection of utility programs that are part of system software.
• The user program in its original alphanumeric text format is called source program.
• The assembled machine language program is called object program.
• Consider a Move instruction as → MOVE R0,SUM
• Here the mnemonic MOVE represents the binary pattern, or OP Code, which indicates the
operation performed by the instruction.
• The OP-code mnemonic is followed by at least one blank space character. Then the information
that specifies the operands is given.
• Since there are several possible addressing modes for specifying the operand locations, the
assembly language must indicate which mode is being used.
• For example,
ADD #5,R3 → Absolute Addressing mode
ADDI 5,R3 → Immediate Addressing mode
MOVE #5,(R2) or MOVEI 5,(R2) → Indirect Addressing mode
Assembler Directives
• The Assembler Directives give directions to the assembler during the assembly process but are not
translated into machine instructions.
• The directives control the generation of machine code and organization of the program.
• For example, SUM EQU 200
• When the object program is run, the above instruction is not executed and it is simply informs the
assembler that the name SUM should be replaced by the value 200, whenever SUM appears in the
program. This instruction does not appear in the object program.
• The assembly program first gets translated into object program and is stored in the main memory.
• The assembler does not know the memory address where the machine instructions and the required
data items are to be stored after the program is loaded for execution.
• If the memory address to store the instructions and data are not specified in the program, they will
be stored in randomly in any memory locations.
• For an assembler to store the object program in a specified location, it has to know
• How to interpret the names
• Where to place the instructions in the memory
• Where to place the data operands in the memory
• Assembler directives are used to provide all the above information to the assembler.
• ORIGIN – It directs the assembler to start the memory allotment for the particular segment,
block or code from the declared address in ORIGIN instruction. For example, the instruction
‘ORIGIN 204’ in the figure indicates that the instructions written after this line (next 2 lines
in this particular program) are saved from the address 204 in the memory. Then the
instruction ‘ORIGIN 100’ indicates that the lines following this instruction will be saved
from the address 100 in the memory.
• DATAWORD – It indicates that the a data value of 100 is to be placed in the memory word
at the address 204 with the label N.
• RESERVE – It declares that a particular block of memory is to be reserved for data. In the
program, 400 bytes of memory will be reserved under the label NUM1.
• RETURN – It indicates the point at which execution of the program should be terminated.
It causes the assembler to insert an appropriate machine instruction that returns control to
the operating system of the computer.
• END – It marks the end of an assembly language program text and it ignores the source
lines available later on.
Most assembly languages require statements in a source program to be written in the form
Label Operation Operands Comment
• These four fields are separated by an appropriate delimiter, typically one or more lank characters.
• Label- is an optional name associated with memory address where the machine language
instruction produced from the statement willbe loaded.Labels may be associated with the data
items.Such labels in the figure are SUM,N,NUM1,START and LOOP.
• Operation Field-This field contains OP code mnemonic of the desired instruction or assembler
directive. It contains addressing information for accessing one or more operands,depending on the
type of instruction.
• Comment Field-It is ignored by the assembler and is used for documentation purpose to make the
program easier to understand.
➢ Note: Assembly languages differ in detail and complexity from one computer to another.
• In the above figure, the keyboard and the display are separate devices.
• The action of striking a key on the keyboard does not automatically cause the corresponding
character to be displayed on the screen.
• One block of instructions in the I/O program transfers the character into the processor, and another
associated block of instructions causes the character to be displayed.
• Consider the problem of moving a character code from the keyboard to the processor.
• Striking a key stores the corresponding character code in a 8-bit buffer register associated with the
keyboard and let it be called DATAIN, as shown in the above figure.
• To inform the processor that a valid character is in DATAIN, a status control flag, SIN, is set to 1.
• A program monitors SIN, and when SIN is set to 1, the processor reads the contents of DATAIN.
• When the character is transferred to the processor, SIN is automatically cleared to 0.
• If a second is entered at the keyboard, SIN is again set to 1 and the process repeats.
• A similar process takes place when characters are transferred from the processor to the display.
• A buffer register, DATAOUT, and a status control flag, SOUT, are used for this transfer.
• When SOUT equals to 1, the display is ready to receive a character.
• The processor monitors SOUT, and when SOUT is set to 1, the processor transfers a character
code to DATAOUT.
• The transfer of a character to DATAOUT clears SOUT to 0; when the display device is ready to
receive a second character, SOUT is again set to 1.
• The buffer registers DATAIN and DATAOUT and the status flags SIN and SOUT are part of
circuitry commonly known as device interface.
• The circuitry for each device is connected to the processor via a bus as shown in the previous
figure.
• In order to perform I/O transfers, we need machine instructions that can check the state of the
status flag and transfer data between the processor and the I/O devices.
• The first instruction tests the status flag and the second performs the branch.
• The processor monitors the status flag by executing a short wait loop and proceeds to transfer the
input data from DATAIN to the processor register R1, when SIN is set to 1 as a result of key being
struck.
• The Input operation resets SIN to 0.
MoveByte R1,DATAOUT
• It is a common practice to include SIN and SOUT in device status registers, one for each of the
two devices.
• Let us assume that bit b3 in registers INSTATUS and OUTSTATUS corresponds to SIN and
SOUT, respectively.
• The read operation may be now implemented as
READWAIT Testbit #3,INSTATUS
Branch=0 READWAIT
MoveByte DATAIN,R1
• The Testbit instruction tests the state of one bit in the destination location, where the bit position
to be tested is indicated by the first operand.
• If the bit tested is equal to 0, then the condition of the branch is true, and a branch is made to the
beginning of the wait loop.
• When the device is ready, that is, when the bit tested becomes equal to 1, the data are read from
the input buffer or written onto the output buffer.
• Program-controlled I/O requires continuous involvement of the processor in the I/O activities.
• It is desirable to avoid situations like wait loop to avoid wasting of processor execution time.
• Other I/O techniques, based on the use of interrupts, may be used to improve the utilization of the
processor.
• The above figure shows a stack of word data items in the memory of a computer.
• It contains numerical values, with 43 at the bottom and -28 at the top.
• A processor register called stack pointer (SP) is used to keep track of the address of the element
of the stack that is at the top at any given time.
• The stack pointer could be any general-purpose register or a register dedicated to this function.
• If we assume a byte addressable memory with 32-bit word length, the push operation can be
implemented as
Subtract #4,SP
Move NEWITEM,(SP)
where the Subtract instruction subtracts the source operand by 4 from the destination operand
contained in SP and places the result in SP.
• These two instructions move the word from location NEWITEM onto the top of the stack,
decrementing the stack pointer by 4 before the move.
• The pop operation can be implemented as
Move (SP),ITEM
Add #4,SP
• These two instructions move the top value from the stack into the location ITEM and then
increment the stack pointer by 4 so that it points to the new top element.
• The figure below shows the effect of push and pop operations on stack.
• If the processor has the Autoincrement and Autodecrement addressing modes, then the push
operation can be performed by the single instruction
Move NEWITEM,-(SP)
and the pop operation can be performed by
Move (SP)+,ITEM
• When a stack is used in a program, it is usually allocated a fixed amount of space in the memory.
• In this case, we must avoid pushing an item onto the stack when the stack has reached its maximum
size.
• Also, we must avoid attempting to pop an item off an empty stack, which could result in
programming error.
• Suppose that a stack runs from location 2000 (BOTTOM) down no further than location 1500.
• The stack pointer is loaded initially with the address value 2004.
• Recall that SP is decremented by 4 before new data are loaded on the stack
• Hence, an initial value of 2004 means that the first item pushed onto the stack will be at location
2000.
• To prevent either pushing an item on a full stack or popping an item off an empty stack, the single-
instruction push and pop operations can be replaced by the instruction sequences as shown in the
figure below.
• There are two important differences between how a stack and a queue are implemented.
• One end of the stack i.e bottom is fixed, while the other end rises and falls as data are pushed and
popped.
• Also a single pointer is needed to point to the top of the stack at any given time.
• On the other hand, both ends of a queue move to higher addresses as data are added at the back
and removed from the front.
• So two pointers are needed to keep track of the two ends of the queue.
• Another difference between stack and a queue is that, without further control, a queue would
continuously move through the memory of a computer in the direction of higher addresses.
• One way to limit the queue to a fixed region in the memory is to use a circular buffer.
• Let us assume that the memory addresses from BEGINNING to END are assigned to the queue.
• The first entry in the queue is entered into the location BEGINNING and successive entries are
appended to the queue by entering them at successively higher addresses.
• By the time the back of the queue reaches END, space will have been created at the beginning if
some items have been removed from the queue.
• Hence the back pointer is reset to the value BEGINNING and the process continues.
• Care must be taken to detect when the region assigned to the data structure is either completely
full or completely empty, just like a stack.
Subroutines
• Subroutine is a subtask (in the form of block of instructions) which is performed many times on
different data values.
• To saves space only one copy of the instructions that constitute subroutine is placed in the memory
and any program that require the use of subroutine simply reaches to its starting location.
• When a program branches to a subroutine we say that it is calling the subroutine.The instruction
that performs this branch operation is named a call instruction.
• After a subroutine has been executed, the calling program must resume execution, continuing
immediately after the instruction that called the subroutine. The subroutine is said to return to the
program that called it y executing Return instruction.
• PC is used to point to the appropriate location when the subroutine is called and again to point
back to the same location where the program execution has been left.
• Hence the contents of the PC must be saved by the call instruction to enable correct return to the
calling program.
• The way in which a computer makes it possible to call and return from subroutines is referred to
as its subroutine linkage method.
• The simplest subroutine linkage method is to save the return address is specific location,which
may be register dedicated to this function and such register is called the link register.
• When the subroutine completes its task, the Return instruction to the calling program by branching
indirectly through the link register.
The Call instruction is just a special branch instruction that performs the following operations-
• Store the contents of the PC in the link register
• Branch to the target address specified by the instruction
The Return instruction is a special branch instruction contained in the link register
Branch to the address contained in the link register.
• Call instruction Pushes the contents of the PC on to the processor stack and loads the subroutine
address into the PC.
• The Return instruction pops the return address from the processor stack in to the PC.
Parameters Passing
• When calling a subroutine, a program must provide to the subroutine the parameters, that is, the
operands or their addresses, to be used in the computation.
• Later the subroutine returns other parameters, in this case, the results of the computation.
• This exchange of information between a calling program and subroutine is referred to as parameter
passing.
• Parameter or in memory locations, where they can be accessed by the subroutine. Alternatively,
the parameters may be placed on the processor stack.
• Passing parameters through processor registers is straight forward and efficient.
• Subroutine uses three registers. They contain valid data that belong to the calling program, their
contents should be saved by pushing them on to the stack.
• We have used a single instruction, Move multiple, to store the contents of register R0 through R2
on the stack.
• Many processor have such instruction. The top of the stack is now at level3.
• The subroutine accesses the parameters n andNUM1 from the stack using indexed addressing.
Note that it does not change the pointer because valid data items are still at the top of the stack.
• The value is loaded into R1as the initial value of the count, and the address NUM1 is loaded into
R2, which is used as a pointer to scan the list entries.
• At the end of the computation, register R0 contains the sum.
• Before the subroutine returns to the calling program, the contents of R0 are placed on the stack,
replacing the parameter NUM1, which is no longer needed.
• Then the contents of three registers used by the subroutine are restored from the stack.
• Now the top item on the stack is the return address at level2.
• After the subroutine returns, the calling program stores the result in location SUM and lowers the
top of the stack to its original level by incrementing the SP by 8.
Additional Instructions
Logical Instructions
• Logic operations such as AND, OR, and NOT, applied to individual bits, are the basic building
blocks of digital circuits.
• It is also useful to be able to perform logic operations in software, which is done using instructions
that apply these operations to all bits of a word or byte independently and in parallel.
• For example, the instruction
Not dst
compliments all bits contained destination operand.
Not R0
Add #1,R0
• The above instructions help us to find the 2’s compliment of a number stored in R0. For example
if +3 (0011) is initially stored in R0, the first line NOT R0 finds the 1’s compliment of +3 which
is 1100 and it is again stored in R0. The next line adds a value 1 to the contents of R0 to get 1101
(-3). This gives us the 2’s compliment of +3.
• In some computers, a single instruction can perform 2’s compliment directly as given below.
Negate R0
• Logical instruction And performs the bit-wise AND operation on the source and destination
operands.
• The And instruction is often used in practical programming tasks where all the bits of an operand
except for some specified field are to be cleared to 0.
• For example, let R0=1010011. Let’s say, the three left most bits are to be retained and all other
remaining 4 bits are to be cleared to 0 to get 1010000. This can be done using the And instruction
as
And #1110000,R0
Here the contents of R0 are bitwise ANDed with the vaule 1110000 to get the value 1010000. The
left most three bits ‘101’ are ANDed with 1’s in the number 1110000 and hence they are retained.
The remaining bits are ANDed with 0 and hence they are cleared to 0. Finally R0=1010000.
Shift and Rotate Instructions
• There are many applications that require the bits of an operand to be shifted right or left some
specified number of positions.
• For general operands, we use logical shift and for a number, we use an arithmetic shift, which
preserves the sign of the number.
Logical Shifts
• Two logical shift instructions are needed, one for shifting left (LShiftL) and another for shifting
right (LShiftR).
• These instructions shift an operand over a number of bit positions specified in a count operand
contained in the instruction.
• The general form of logical left shift operation is
LShiftL count,dst
• The count operand may be given as an immediate operand, or it may be contained in a processor
register.
• Vacated positions in the right are filled with zeros, and the bits shifted out from the left side are
passed through the carry flag, C, and then dropped.
• Involving the C flag in shift operations is useful in performing arithmetic operations on large
numbers that occupy more than one word.
• The figure a below shows an example of shifting the contents of register R0 left by two bit
positions.
• The logical shift right instruction, LShiftR, works in the same manner except that I shifts to the
right as shown in figure b.
Digit-Packing Example
• Consider two decimal digits 13 (0001 0011) and 25 (0010 0101) located at memory byte locations
LOC and LOC+1. Here these numbers are said to be unpacked format.
• The task is to represent each of these digits in the 4-bit BCD code and store both of them in a single
byte location PACKED (35→0011 0101).
• This result is said to be in packed-BCD format.
• This can be done using the program below.
• Let the memory location LOC has its address 1000 where the value 13 is stored and LOC+1 has
its address as 1004 and 25 is stored in it.
•
Label Address Value
LOC 1000 13
LOC+1 1004 25
Instructions Contents
Arithmetic Shifts
• Shifting a number by one bit position to the left is equivalent to multiplying it by 2; and shifting it
to the right is equivalent to dividing it by 2.
• Of course, overflow might occur on shifting left and the remainder is lost in shifting left.
• Another important observation is that on a right shift the sign bit must be repeated as the fill-in bit
for the vacated position.
• This requirement on right shifting distinguishes arithmetic shifts from logical shifts in which the
fill-in bit is always 0.
• Otherwise, the two shifts are very similar in their operation.
• AShiftR, arithmetic right shift, shifts the number by specified number of positions to the right and
fiils in the vacant positions with the sign bit as shown in figure c.
• The arithmetic left shift is exactly same as the logical left shift.
Rotate Operations
• In shift operations, the bits that are shifted out of the operand are lost, except for the last bit shifted
out which is retained in the carry flag C.
• To preserve all bits, a set of rotate instructions can be used.
• They move the bits that are shifted out of one end of the operand back into the other end.
• Two versions of both the left and right rotate instructions are usually provided.
• In one version, the bits of the operand are simply rotated and in the other version, the rotation
includes the C flag.
• The figure below shows the left and right operations with and without the C flag being included in
the rotation.
• Note that when the C flag is not included in the rotation, it still retains the last bit shifted out of the
end of the register.
• RotateL – rotate left without carry
• RotateLC – rotate left with carry
• RotateR – rotate right without carry
• RotateRC – rotate right with carry
• The main use for the rotate instructions is in algorithms for arithmetic operations other than
addition and subtraction.
Glossary
Register: A small unit of very fast memory that is directly accessible to the CPU, and is mostly
used to store inputs, outputs or intermediate results of computation.
Offset: The difference between a target memory address and a base address.
Stack: A linear data structure in which the last data item is the first retrieved; a LIFO queue.