introduction programming – process of composing several instructions to perform certain tasks....

28

Upload: bertram-chambers

Post on 17-Jan-2016

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several
Page 2: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

INTRODUCTION• Programming – process of composing several

instructions to perform certain tasks.• Program – product of programming which contains

several instructions.• Skills of programming / structure of programming

implementation:▫Essential and best instructions to perform a certain

task.▫How instructions organized in subprogram

(subroutine) so it can be reused as many times as possible.

▫Used minimum lines of instructions for maximum tasks.

• Addressing modes – procedure of fetching and sending data between source and destination.

Page 3: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

ADDRESSING MODES• MC68000 : 14 different

addressing modes divided into 6 groups.

• By understanding the addressing modes, we have EA (effective address).

• EA will help us identifies the location of an operand.

Page 4: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

REGISTER DIRECT ADDRESSING• Dn – Data register direct addressing.

(D1,D2,D3,D4,D5,D6,D7)• An – Address register direct addressing.

(A1,A2,A3,A4,A5,A6,A7)• Fastest and most compact because no reference to

memory.

Page 5: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

ABSOLUTE DATA ADDRESING• EA in memory. Ex : MOVE.L $1234,D4• Absolute short data:

▫ 16 bits address.▫ 000000 – 007FFF

FF8000 - FFFFFF• Absolute long data:

▫ 24 bits address.▫ 000000 – FFFFFF

Page 6: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

PROGRAM COUNTER RELATIVE / RELATIVE

• Program counter relative with offset▫ EA = offset + value in PC

= d16 + PCd16 will be sign-extends to 32 bits first.

00122002

Page 7: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

PROGRAM COUNTER RELATIVE / RELATIVE • Program counter relative with index and offset

▫ EA = index + offset + value in PC = Xn + d8 + value in PC

Xn – data or address registerd8 will be sign-extends to 32 bits first.

00010202

Page 8: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

REGISTER INDIRECT ADDRESSING• Address register indirectly referred.• 5 modes:

▫ Address register indirect.▫ Postincrement address register indirect.▫ Predecrement address register indirect.▫ Address register indirect with offset.▫ Address register indirect with index and offset.

Page 9: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

ADDRESS REGISTER INDIRECT

Page 10: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

POSTINCREMENT ADDRESS REGISTER INDIRECT

Page 11: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

PREDECREMENT ADDRESS REGISTER INDIRECT

Page 12: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

ADDRESS REGISTER INDIRECT WITH OFFSET

Page 13: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

ADDRESS REGISTER INDIRECT WITH INDEX AND OFFSET

Page 14: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

IMMEDIATE DATA ADDRESSING

Page 15: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

INCORRECT INSTRUCTIONS

Page 16: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

CONCEPT OF PROGRAMMING• Steps in program building:

▫Definition of problem.▫Logical design.▫Programming.▫Documentation of the program.▫Analysis the program.▫Test run the program.

Page 17: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

EXAMPLE• Definition of problem:

▫ Input data of two numbers. These two numbers are added. The product is stored in a memory location.

• Logical design – flow chart

Programming model of the microprocessor

(Figure 2.15 : Unit 2/38)

Page 18: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

EXAMPLE (cont.)• Programming.

Page 19: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

EXAMPLE (cont.)• Documentation of program.

Page 20: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

EXAMPLE (cont.)• Analysis the program

Page 21: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

EXAMPLE (cont.)• Analysis the program

Page 22: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

EXAMPLE (cont.)• Analysis the program

• Test run the program▫ ASM68K – assembler▫ SIM68K - simulator

Page 23: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

IMPLEMENTATION STRUCTURE OF PROGRAMMING

•Effective programming is the know how to identify the best or optimum tools. (composition of instructions and selection of addressing modes)

•Good program is with the features of least instruction lines, least executions duration, easy alteration and modifications.

•Structure of programming:▫Construct of sequential▫Construct of loop▫Construct of decision making by branch/jump▫Construct of subroutine

Page 24: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

CONSTRUCT OF SEQUENTIAL

• Basic, simple and straight forward.• Execute one instruction after another.

START

Instruction-1

END

Instruction-1

Instruction-n

Page 25: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

CONSTRUCT OF LOOP

• Some instruction need to be repeated – loop construct.• At the end of the program, assert an instruction to

instruct the program execution to go back to the first instruction.

Instruction-1

(a) Flow chart

Instruction-2

Instruction-n

START

LOOP

Instructions

:

JUMP LOOP LOOP

(b) Instructions

Page 26: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

CONSTRUCT OF DECISION MAKING BY BRANCH/LOOP

• Another structure of loop construct where the program is allowed to decide whether to implement the loop or not.

Page 27: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

CONSTRUCT OF SUBROUTINE

• To simplify a very long or complex program.• Grouping several instructions that tend to be repeated.

This subroutine need to be name for easy call.

Page 28: INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several

CONSTRUCT OF SUBROUTINE