מבוסס על שקפים מאת יאן ציטרין

Slides:



Advertisements
Similar presentations
Instruction Clock Cycles Generally, 1 cycle per memory access: – 1 cycle to fetch instruction word – +1 cycle if or #Imm – +2 cycles.
Advertisements

MSP430 Assembly Paul Roper
Microprocessor Fundamentals Week 5 Mount Druitt College of TAFE Dept. Electrical Engineering 2008.
CSE378 ISA evolution1 Evolution of ISA’s ISA’s have changed over computer “generations”. A traditional way to look at ISA complexity encompasses: –Number.
LC-3 Computer LC-3 Instructions
S. Barua – CPSC 240 CHAPTER 5 THE LC-3 Topics Memory organization Registers Instruction set Opcodes.
Execution of an instruction
Pentium Addressing Modes
Chapters 4 & 5: LC-3 Computer Architecture Machine Instructions Assembly language Programming in Machine and Assembly Language.
Chapter 11 Instruction Sets: Addressing Modes and Formats HW: 11.4, 5, 13, 16 (Due 11/15)
Part II: Addressing Modes
Chapter 5 The LC-3. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5-2 Data Movement Instructions Load --
Memory/Storage Architecture Lab 컴퓨터의 개념과 실습 Assembly Example.
Lecture Set 4 Programming the 8051.
In1210/01-PDS 1 TU-Delft Instructions and addressing.
Topics covered: Instruction Set Architecture CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Lecture 8: Loading and Storing to Memory CS 2011 Fall 2014, Dr. Rozier.
Type of addressing mode
Instruction Set Architectures Continued. Expanding Opcodes & Instructions.
1 Contents: 3.1 Instruction format and Addressing Modes 3.2 Instruction Introduction Chapter 3 Instruction system.
Microprocessors I 8051 Addressing Modes CS Prof. Msc. Ivan A. Escobar
Programmable System on Chip
ELEC 418 Advanced Digital Systems Dr. Ron Hayne
Chapter 7 Assembly Language
ECE 382 Lesson 3 ECE 382Website:
Chapter 11 Instruction Sets
ARM Registers Register – internal CPU hardware device that stores binary data; can be accessed much more rapidly than a location in RAM ARM has.
COMP2121: Microprocessors and Interfacing
Processor Instructions set. Learning Objectives
ECE 382 Lesson 4 Lesson Outline Readings
Chapter 7 Assembly Language
Alvaro Mauricio Peña Dariusz Niworowski Frank Rodriguez
Chapter 4 Addressing modes
8051 Addressing Modes The way, using which the data source or destination addresses are specified in the instruction mnemonic for moving the data, is.
Microcomputer Programming
Assembly Lang. – Intel 8086 Addressing modes – 1
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Computer Organization and Assembly Language (COAL)
ECE 445 CS1251 Computer Organization Carl Hamacher
SCHOOL OF ELECTRONICS ENGINEERING Electronics and Communication
LC-3 Details and Examples
Topic 6 LC-3.
(Array and Addressing Modes)
MIPS Instruction Encoding
How NOT to design an ISA x86.
ADDRESSING MODES AND INSTRUCTION SET
Conditional Jumps and Time Delays
Chapter 7 Assembly Language
MIPS Instruction Encoding
Computer Science 210 Computer Organization
Stack Relative Deferred (sf) Indexed (x) Stack Indexed (sx)
Instruction Set Architectures Continued
Under Address Modes Source: under
Introduction to Micro Controllers & Embedded System Design
(Array and Addressing Modes)
Computer Science 210 Computer Organization
Stack Relative Deferred (sf) Indexed (x) Stack Indexed (sx)
Chapter 7 Assembly Language
Chapter 7 Assembly Language
Conditional Jumps and Time Delays
Evolution of ISA’s ISA’s have changed over computer “generations”.
Under Address Modes Source: under
Evolution of ISA’s ISA’s have changed over computer “generations”.
Instruction Set Summary
Operands and Addressing Modes
Evolution of ISA’s ISA’s have changed over computer “generations”.
ARM Load/Store Instructions
(Array and Addressing Modes)
Chapter 5 The LC-3.
Presentation transcript:

מבוסס על שקפים מאת יאן ציטרין תרגול 4 שיטות מעון – המשך הוראות לאסמבלר מבוסס על שקפים מאת יאן ציטרין

Auto-Increment Indirect Auto-Decrement Indirect שיטות מעון: סיכום Mode Name Syntax Register Rn 1 Register Indirect (Rn) or @Rn 2 Auto-Increment (Rn)+ 3 Auto-Increment Indirect @(Rn)+ 4 Auto-Decrement -(Rn) 5 Auto-Decrement Indirect @-(Rn) 6 Indexed X(Rn) 7 Indexed Indirect @X(Rn) הערה: ניתן להשתמש ב- @0(ri) © את"ם - תרגול מס' 4

Immediate Addressing Mode 2,7 #k סינטקס op #k, d 7768 10008 10028 אחרי שליפת הפקודה ומייד לפני פענוח ערך ה-PC קודם ב-2 1000 pc ... 7768 op (pc)+, d זהו ה-EA לכן האופרנד הנו k 10008 k (constant) 10028 משום שמשתמשים בשיטה 2 ה-PC מקודם פעם נוספת … 10048 סינטקס בשיטה כזאת ניתן לשים את ערך האופרנד מייד אחרי הפקודה (מכאן השם של השיטה) op #k, d © את"ם - תרגול מס' 4

Immediate Addressing (example) Source mode + reg 01 27 00 10008 177776 10028 mov #177776, r0 opcode Destination mode + reg בעזרת הטריק הזה ניתן להשתמש בערכים קבועים בשפת האסמבלי r0 © את"ם - תרגול מס' 4

Absolute Addressing Mode 3,7 @#A סינטקס op @#A, d 7768 10008 10028 אחרי שליפת הפקודה ומייד לפני פענוח ערך ה-PC קודם ב-2 1000 pc ... 7768 op @(pc)+, d 10008 זוהי הכתובת של ה-EA A היינה ה-EA A (address) 10028 משום שמשתמשים בשיטה 3 ה-PC מקודם פעם נוספת … 10048 סינטקס בשיטה כזאת ניתן לשים את הכתובת האפקטיבית מייד אחרי הפקודה op @#A, d © את"ם - תרגול מס' 4

Absolute Addressing (example) Source mode + reg 01 37 00 10008 2000 10028 mov @#2000, r0 opcode Destination בעזרת הטריק הזה ניתן להשתמש בכתובות אבסולוטיות בשפת האסמבלי (מכאן השם) r0 22 20008 © את"ם - תרגול מס' 4

Relative Addressing Mode 6,7 A סינטקס op A, d 7768 10008 10028 10048 אחרי שליפת הפקודה ומייד לפני פענוח ערך ה-PC קודם ב-2 1000 pc ... 7768 op X(pc), d 10008 זהו ה-offset ביחס לכתובת הרצויה A X=A- 1004 10028 … 10048 סינטקס בשיטה כזאת ניתן לשים את ה- offset עד לכתובת האפקטיבית מייד אחרי הפקודה A=X+(PC) op A, d © את"ם - תרגול מס' 4

Relative Addressing (example) 01 67 00 10008 1000 10028 mov 2004, r0 בעזרת הטריק הזה ניתן להשתמש בכתובות יחסיות בשפת האסמבלי (מכאן השם) r0 3000 20048 … 10048 pc יתרון של כתובות יחסיות: אם התוכנית כולה זזה בזיכרון לא צריך לשנות אותם (בניגוד לכתובות אבסולוטיות) זה יהיה ברור יותר כשנלמד "קישור וטעינה" 2004 = 1000 + 1004 offset ה-PC החדש © את"ם - תרגול מס' 4

Relative Deferred Mode 7,7 @A סינטקס op @A, d 7768 10008 10028 10048 אחרי שליפת הפקודה ומייד לפני ביצועה ערך ה-PC קודם ב-2 1000 pc ... 7768 op @X(pc), d 10008 זהו ה-offset ביחס לכתובת של הכתובת הרצויה A X=A- 1004 10028 … 10048 בשיטה כזאת ניתן לשים את ה- offset עד לכתובת של הכתובת האפקטיבית מייד אחרי הפקודה A=X+(PC) כאן A הנה הכתובת של כתובת האופרנד סינטקס op @A, d © את"ם - תרגול מס' 4

Relative Deferred (example) 01 77 00 10008 2000 10028 mov @3004, r0 r0 5000 30048 … 10048 pc 1000 3004 = 2000 + 1004 offset ה-PC החדש 22 50008 © את"ם - תרגול מס' 4

שיטות מעון עם PC: סיכום Mode Name Syntax תוכן המילה השנייה 2,7 3,7 6,7 Immediate #220 האופרנד 3,7 Absolute @#220 הכתובת האפקטיבית 6,7 Relative 220 המרחק בין ה-EA לבין הכתובת של המילה הבאה לביצוע 7,7 Deferred @220 המרחק בין הכתובת של ה-EA לבין הכתובת של המילה הבאה ביצוע © את"ם - תרגול מס' 4

הערות מבחינת האסמבלר תווית ומספר הם שווי משמעות האסמבלר מזהה פעולות אריתמטיות פשוטות #220+10 שקול ל #230 )לפעמים שימוש בסוגריים יוצר בעיות..) השיטותAbsolute & Relative מובילות לאותה EA ושתיהן מקובלות עלינו © את"ם - תרגול מס' 4

שיטות מעון: דוגמאות Address Value r1 222 pc 1000 220 440 444 77 666 נניח שלפני ביצוע כל פקודה בשקף הבא תוכן הזיכרון הנו: Address Value r1 222 pc 1000 220 440 444 77 666 555 © את"ם - תרגול מס' 4

שיטות מעון: דוגמאות (המשך) שיטות מעון: דוגמאות (המשך) Mode OP Src Dst r1 r2 pc mov 1 (r1) 2 (r1)+ 3 @(r1)+ 4 -(r1) 5 @-(r1) 6 222(r1) 7 @222(r1) 222 222 1002 222 444 1002 224 444 1002 224 666 1002 220 440 1002 220 77 1002 222 666 1004 222 555 1004 © את"ם - תרגול מס' 4

שיטות מעון: דוגמאות ל- PC modes OP Src Dst r2 pc 2,7 mov #100 3,7 @#220 6,7 220 7,7 @220 100 1004 440 1004 440 1004 77 1004 © את"ם - תרגול מס' 4

הוראות לאסמבלר .blkw n הקצאת n מילים בזיכרון (ללא אתחול) .blkw 4 לדוגמא, כדי להקצות 4 מילים : .word w1, w2,…, wn הקצאת n מילים בזיכרון (ואתחולן) .word 10, 20, 30, 40 לדוגמא, כדי להקצות מילים 10,20,30,40: .byte b1, b2,…, bn הקצאת n בתים בזיכרון .byte 1,2,3,4 לדוגמא, כדי להקצות בתים 1,2,3,4: © את"ם - תרגול מס' 4

הוראות לאסמבלר (המשך) 13 = 138 13. = 1310 ב- PDP-11 מספר ייחשב כאוקטלי כברירת המחדל. כדי שמספר ייחשב כעשרוני יש להוסיף אחריו נקודה. מספר אוקטאלי (ללא נקודה) המכיל ספרות 8 או 9 לא גורם לשגיאה, אך ערכו לא צפוי. 'A = 101 כדי לייצג ASCII של תו יש לכתוב לפניו גרש (') movb #'A, r0 למשל: .ascii<str> כדי להקצות מקום לבתים של המחרוזת str ולאתחל אותם בערכי ascii של תווי המחרוזת .ascii<ATAM> למשל, כדי להקצות מקום למחרוזת “ATAM” . = torg + A הקידוד של הפקודה הבאה ימצא בכתובת A . = torg + 1000 .even הקידוד הבא ימצא בכתובת הזוגית הקרובה © את"ם - תרגול מס' 4

הוראות לאסמבלר (דוגמא) כתובת שפת המכונה שפת האסמבלי . = torg + 1000 001000 000000 main: halt 001002 000000 000000 000000 .blkw 6 . = torg + 2000 002000 000001 000002 000003 .word 1, 2, 3 002006 001 002 003 .byte 1, 2, 3 002011 000 .even 002012 141 142 143 str: .ascii<abc> 002015 101 char: .byte 'A © את"ם - תרגול מס' 4

תוכנית – הדגמת שימוש בשיטות מעון נדגים את שיטות המעון השונות בעזרת דוגמא הבאה: בין הכתובות 10008-10178 מאורגן מערך המורכב מזוגות מילים: תוכן, כתובת, תוכן, כתובת, ... יש לכתוב תוכנית המעבירה כל תוכן נתון לתא בזיכרון שכתובתו מופיעה אחרי התוכן הנתון. © את"ם - תרגול מס' 4

למשל: 177777 10008 000650 10028 000234 10048 000200 10068 055555 10148 1234 10168 ... 10208 … 00008 2008 6508 1234 8 תוכן כתובת © את"ם - תרגול מס' 4

רגיסטר, רגיסטר עקיף . = torg + 500 main: mov #1000, r0 loop: mov (r0), r1 add #2, r0 mov (r0), r2 mov r1, (r2) cmp r0, #1020 bne loop halt . = torg + 1000 arr: .word 1, 2000, 2, 2002, 3, 2004, 4, 2006 © את"ם - תרגול מס' 4

הגדלה אוטומטית ישירה . = torg + 500 main: mov #1000, r0 loop: mov (r0)+, r1 mov (r0)+, r2 mov r1, (r2) cmp r0, #1020 bne loop halt . = torg + 1000 arr : .word 1, 2000, 2, 2002, 3, 2004, 4, 2006 © את"ם - תרגול מס' 4

הגדלה אוטומטית ישירה ועקיפה . = torg + 500 main: mov #1000, r0 loop: mov (r0)+, @(r0)+ cmp r0, #1020 bne loop halt . = torg + 1000 arr : .word 1, 2000, 2, 2002, 3, 2004, 4, 2006 © את"ם - תרגול מס' 4

הקטנה אוטומטית . = torg + 500 main: mov #1020, r0 loop: mov -(r0), r1 cmp r0, #1000 bne loop halt . = torg + 1000 arr : .word 1, 2000, 2, 2002, 3, 2004, 4, 2006 © את"ם - תרגול מס' 4

אינדקס ישיר . = torg + 500 main: mov #0, r0 loop: mov 1000(r0), r1 add #4, r0 cmp r0, #20 bne loop halt . = torg + 1000 arr : .word 1, 2000, 2, 2002, 3, 2004, 4, 2006 © את"ם - תרגול מס' 4

אינדקס ישיר ועקיף . = torg + 500 main: mov #0, r0 loop: mov 1000(r0), @1002(r0) add #4, r0 cmp r0, #20 bne loop halt . = torg + 1000 arr : .word 1, 2000, 2, 2002, 3, 2004, 4, 2006 © את"ם - תרגול מס' 4

תוכן 177777 10008 2008 000650 כתובת 10028 6508 000234 10048 000200 10068 1234 8 055555 10148 r0 1234 10168 r1 ... 10208 טבלת מעקב לתוכניות - שקף להדפסה והצגה על המטול. r2 r7(pc) © את"ם - תרגול מס' 4