68000 Architecture Data Types and Addressing Modes 9206

  • Slides: 26
Download presentation
68000 Architecture, Data Types and Addressing Modes 9/20/6 Lecture 2 - Prog Model 1

68000 Architecture, Data Types and Addressing Modes 9/20/6 Lecture 2 - Prog Model 1

Lecture Overview o o Assembler Language Programmers Model n o 9/20/6 Registers Addressing Modes

Lecture Overview o o Assembler Language Programmers Model n o 9/20/6 Registers Addressing Modes Lecture 2 - Prog Model 2

Assembler Language o Programming language very close to the machine code for a language

Assembler Language o Programming language very close to the machine code for a language n n o All assemblers have two types of statements n n 9/20/6 Can be considered a native language for the architecture targeted. Assembler languages have a 1 -to-1 translation to machine code Executable instructions Assembler directives Lecture 2 - Prog Model 3

Assembler Directives o TTL n o EQU n **Links a pneumonic name to a

Assembler Directives o TTL n o EQU n **Links a pneumonic name to a value. Very valuable in making the program “readable”. Example to reserve 128 bytes for a stack. n STACK_FRAME n n n 9/20/6 “Title” – gives the program a user-defined name EQU 128 Define a stack frame of 128 bytes *** LINK A 1, # -STACK_FRAME Lecture 2 - Prog Model 4

Assembler Directives (2) o DC n n Define constant. Allows the programmer to set

Assembler Directives (2) o DC n n Define constant. Allows the programmer to set memory locations to specific values. Qualifier specifies data type: . B, . W, . L ORG $001000 FST DC. B 10, 66 Set constants of 10 and 66 DC. L $0 A 1234 Store $000 A 1234 in memory STR DC. B ‘April’ Store ASCII values 9/20/6 Lecture 2 - Prog Model 5

Assembler Directives (3) o DS n o ORG n o 9/20/6 Define the value

Assembler Directives (3) o DS n o ORG n o 9/20/6 Define the value of the location counter. Sets the memory address where the code is placed. SECTION n o Reserve bytes, words, or longwords of storage Set the address counter to zero for position independent code. END Lecture 2 - Prog Model 6

Assembler Code Example 9/20/6 Lecture 2 - Prog Model 7

Assembler Code Example 9/20/6 Lecture 2 - Prog Model 7

Programmers Model o When looking at any architecture what does the programmer see? n

Programmers Model o When looking at any architecture what does the programmer see? n n n 9/20/6 REGISTERS (General purpose) ADDRESS REGISTERS SPECIAL PURPOSE REGISTERS MEMORY Allowable operations and data transfers supported Lecture 2 - Prog Model 8

DATA REGISTERS o o o 9/20/6 A 32 -bit machine 8 general purpose Called

DATA REGISTERS o o o 9/20/6 A 32 -bit machine 8 general purpose Called D 0 to D 7 Any operation permitted on Di can also be done on Dj Data access 8, 16, 32 bits Lecture 2 - Prog Model 9

Address Registers o o o 9/20/6 8 Address Regs Labeled A 0 to A

Address Registers o o o 9/20/6 8 Address Regs Labeled A 0 to A 7 Entire 32 bits is single entity value Any operation permitted on Ai is also allowed on Aj 2’s complement value treatment Used in instructions to address memory Lecture 2 - Prog Model 10

Special Purpose Registers o 2 such registers n PC – Program Counter o n

Special Purpose Registers o 2 such registers n PC – Program Counter o n SR – Status Register o o o 9/20/6 Contains the address of the next instruction to be executed. 16 bits divided into two bytes MSB – System byte – control operation mode LSB – Condition codes Lecture 2 - Prog Model 11

Status Word 9/20/6 Lecture 2 - Prog Model 12

Status Word 9/20/6 Lecture 2 - Prog Model 12

Addressing Modes o o Modes supported are reflective of even the most modern architecture

Addressing Modes o o Modes supported are reflective of even the most modern architecture Some Notation n n o 9/20/6 [Dx] means the “contents of” % num means binary $ num means hexadecimal indicates transfer of information Table on page 27 lists meaning of symbols and notation Lecture 2 - Prog Model 13

Immediate Addressing o o o ACTION: The value of the operand (data) is loaded

Immediate Addressing o o o ACTION: The value of the operand (data) is loaded into the specified register at the time the program runs. The value of the operand is used in the operation Note that general form of instructions is n n Operation #Source, Destination MOVE. W #$8123, D 3 [D 3(0: 15)] $8123 o n MOVE. L #$8123, D 3 [D 3(0: 31)] $00008123 o 9/20/6 Fill the low order bytes of De Fills all 32 bits of register D 3 Lecture 2 - Prog Model 14

9/20/6 Lecture 2 - Prog Model 15

9/20/6 Lecture 2 - Prog Model 15

Absolute Addressing o o o Sometimes called “Direct Addressing” The address in memory being

Absolute Addressing o o o Sometimes called “Direct Addressing” The address in memory being referenced by the instruction is given in the instruction. Used when the address of the operand is known when the program is written. The instruction contains the operand’s address n n 9/20/6 FORM Operation source, destination MOVE. L D 3, $1234 [M($1234)] [D 3(16: 31)] [M($1236)] [D 3(0: 15)] MOVE. W $1234, D 3 [D 3(0: 15)] [M($1234)] Lecture 2 - Prog Model 16

Register Direct Addressing o o Register to register operation The assembler instruction lists both

Register Direct Addressing o o Register to register operation The assembler instruction lists both register which will be used for operand of the operation to be performed The 2 nd register listed is both the 2 nd operand of the operation and gets the results of the operation. Example: MOVE. L D 0, D 3 n 9/20/6 Effect: [D 3] [D 0] Lecture 2 - Prog Model 17

Address Register Indirect o o 9/20/6 Register Indirect means that the address of the

Address Register Indirect o o 9/20/6 Register Indirect means that the address of the operand is in a register, the address registers. Ex: Lecture 2 - Prog Model 18

Forms of Address Reg. Indirect o Address Register Indirect with postincrement n n o

Forms of Address Reg. Indirect o Address Register Indirect with postincrement n n o Address Register Indirect with predecrement n n 9/20/6 The contents of the address register are incremented by the appropriate amount after use That is, the data is referenced with the value currently in the address register. Then the contents of the register are incremented by the size referenced. Contents are decremented and then used What use may these have? Lecture 2 - Prog Model 19

Forms of Address Reg. Indirect (2) o Address Register Indirect with displacement n n

Forms of Address Reg. Indirect (2) o Address Register Indirect with displacement n n o Register Indirect with Index Addressing n n 9/20/6 A 16 -bit displacement is specified in instruction Displacement added to address register to obtain the effective address of the operand Effective address is calculated by adding the address register + 8 -bit signed displacement + contents of general purpose register Ref fig 2. 15 of text, pg. 39 Lecture 2 - Prog Model 20

PC Relative o o o 9/20/6 Similar to register indirect except that the address

PC Relative o o o 9/20/6 Similar to register indirect except that the address of the operand is specified with respect to the PC contents. Allows data to be located relative to the location of the program in memory, i. e. , relative to the Program Counter – allows WHAT? ? Restricted to only the source operand Lecture 2 - Prog Model 21

PC Relative o o 9/20/6 Allows data to be located relative to the location

PC Relative o o 9/20/6 Allows data to be located relative to the location of the program in memory, i. e. , relative to the Program Counter – allows position-independent code. What is position-independent code? Lecture 2 - Prog Model 22

PC Relative o o Allows data to be located relative to the location of

PC Relative o o Allows data to be located relative to the location of the program in memory, i. e. , relative to the Program Counter – allows position-independent code. What is position-independent code? n 9/20/6 Code that can be located anywhere (some caveats) in memory and executes the same. Lecture 2 - Prog Model 23

The Stack o With autoincrementing/autodecrementing of address register you have essentially 8 stacks. n

The Stack o With autoincrementing/autodecrementing of address register you have essentially 8 stacks. n o For Jump to Subroutine, register A 7 is used n o 9/20/6 In this way register A 0 through A 7 can become user defined stacks So you may not want to use address register A 7 for programs that calls to subroutines The stack grows down and the register points to the TOS element and has valid contents. Lecture 2 - Prog Model 24

Stack Operations o PUSH data onto stack n n n Stack grows down. TOS

Stack Operations o PUSH data onto stack n n n Stack grows down. TOS has valid data. Use the predecrement form o o POP data from stack n Use the postincrement form o 9/20/6 MOVE. W $4234, -(A 7) MOVE. W (A 7)+, D 4 Lecture 2 - Prog Model 25

Assignment o From Text HW 1 n n n 9/20/6 Problem 2 -1 parts

Assignment o From Text HW 1 n n n 9/20/6 Problem 2 -1 parts a, b, d, g Problem 2 -5 Problem 2 -6 Lecture 2 - Prog Model 26