PowerPoint 簡報

Similar documents
DPJJX1.DOC

<4D F736F F D20B3E6B4B9A4F930365F32A443AC71C5E3A5DCBEB9B1B1A8EE2E646F63>

12232A LED LED LED EL EL CCFL EL CCF

微處理機期末專題

untitled

1-1 SH79F6431 A. 2( ) 9~15V ( 12V) U2 U3 3.3V SH79F B. 1(VCC/GND) SH79F6431 C. VDDIO SH79F6431 P4 P5 P0.6 P0.7 VDDIO VDDIO=5V D. 2 V 1.0

1 TPIS TPIS 2 2

HD61202 HD HD61203 HD61202, HY HY HD61202 HD61202 HD61203 HD =4096 RAMRAM LCD 2HD HD HD /32--

目 录

Microsoft Word - 專題封面.doc

untitled

Microsoft PowerPoint - chap4.ppt

() () () () () () () () DDRAM () II

1.1 ML_ONOFF = 1 Q 3 Q 8 C 0.3V M 2 L 1 ML_ONOFF = 0 Q 3 Q 8 C 1. + R31 VCC R21 10K ML_ONOFF R15 0:off 1:on 1K Green Light VCC=5V L1 Q VDD=12V C

TSINGTEK DISPLAY CO.,LTD LCD CONTROLLER & DRIVER ST7920 OR EQUIVALENT (f) 639 2A f B1

» n ¹ú KS0108 x ÍÍÙ q n KS0108 KS KS0107 KS0108 KS *32 128*64 192*64 KS0108 KS0108 KS0107 KS =4096 RAM RAM LCD 2 KS

Microsoft PowerPoint - chap3.ppt

<4D F736F F D203130B5A5C6ACBBFACAB5D1E9D6B8B5BCCAE92E646F63>

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit

CA24064B LED LED LED EL EL CCFL EL CCF /

单片机学习教程

2 Keil µ vision 2.1 1) Keil µ vision2 V2.34 µ vision3 2) Sino_Keil.exe Keil c:\keil\ 3) JET51 USB PC C:\Keil\ USB PC 4) S-L

第 15 章 程 式 編 写 語 言 15.1 程 式 編 写 語 言 的 角 色 程 式 編 寫 語 言 是 程 式 編 寫 員 與 電 腦 溝 通 的 界 面 語 法 是 一 組 規 則 讓 程 式 編 寫 員 將 字 詞 集 合 起 來 電 腦 是 處 理 位 元 和 字 節 的 機 器, 與

,768 32,767 32K JMP Jnnn (386+) LOOP CALL [Label:] JMP short/near/far address L10: jmp jmp L20: L10 L20

專題最終版.doc

untitled

untitled

Microsoft Word - P3.doc

Microsoft Word - IRFWX_A051_C_SyncMOS_with_STC_APN_SC_.doc

µPSD3000 系列

学习MSP430单片机推荐参考书


投影片 1

Microsoft Word 定址法實驗.doc

幻灯片 1

51 C 51 isp 10 C PCB C C C C KEIL

微處理機

Microsoft PowerPoint - chap5.ppt

单片机原理及应用实验指导书.doc

Microsoft Word - FM12232C.doc

Microsoft PowerPoint - C15_LECTURE_NOTE_05.ppt

Microsoft PowerPoint - C15_LECTURE_NOTE_04.ppt

逢 甲 大 學

(Load Project) (Save Project) (OffLine Mode) (Help) Intel Hex Motor

Microsoft PowerPoint - C15_LECTURE_NOTE_04.ppt

第5章:汇编语言程序设计

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

Microsoft Word - ISSFA-0134_A_AP_User-definedDownload_SC_.doc

1 CPU

a b c d e f g C2 C1 2

Microsoft PowerPoint - C15_LECTURE_NOTE_05.ppt

Microsoft Word - 澎湖田調報告_璉謙組.doc


CH559指令周期.doc


ICD ICD ICD ICD ICD

Microsoft PowerPoint - chap7.ppt

W77E58中文手册

7688使用手冊V10.doc

Microsoft Word - FG12232A.doc

AT89C2051中文资料.doc

电 阻 应 变 式 传 感 器 是 将 被 测 量 的 力, 通 过 它 产 生 的 金 属 弹 性 变 形 转 换 成 电 阻 变 化 的 元 件 由 电 阻 应 变 片 和 测 量 线 路 两 部 分 组 成 电 阻 应 变 片 产 生 的 误 差, 主 要 来 源 于 温 度 的 影 响, 本

Ps22Pdf

Microsoft PowerPoint - chap2.ppt

PowerPoint 簡報

<4D F736F F D20C7B6C8EBCABDCFB5CDB3C9E8BCC6CAA6B0B8C0FDB5BCD1A75FD1F9D5C22E646F63>

dfgdafhdafhdafhdafh

Microsoft PowerPoint - C15_LECTURE_NOTE_11

Microsoft PowerPoint - C15_LECTURE_NOTE_06

untitled

Microsoft PowerPoint - C15_LECTURE_NOTE_15

AVR单片机指令系统.PDF

(Guangzhou) AIT Co, Ltd V 110V [ ]! 2


Microsoft Word - ~ doc

微型计算机原理及应用试题 机电96

??????????????????

A Preliminary Implementation of Linux Kernel Virus and Process Hiding

untitled

Microsoft PowerPoint - chap12.ppt

(2) Function 0BH: Function 0CH: (pixel, picture element) Function 0DH: Function 0FH: Function 13H:

System Design and Setup of a Robot to Pass over Steps Abstract In the research, one special type of robots that can pass over steps is designed and se

家装知识(六)

2/80 2

Microsoft PowerPoint - C15_LECTURE_NOTE_06

General Description: Preliminary TTP916 Consumer IC VCD/DVD LCD Green mode Stand-by mode( 1W ) Features: 2.2V-5.5V LCD RAM read condition 2.6V-5.5V RC

車在走天在看 PC前的三輪車日記

EK-STM32F

AL-M200 Series

untitled

1

PIC16F F MPLAB 08 16F LED 15 LED

滬 港 股 票 市 場 交 易 互 聯 互 通 機 制 上 市 公 司 常 問 問 題 滬 港 股 票 市 場 交 易 互 聯 互 通 機 制 ( 滬 港 通 ) 是 在 中 國 內 地 與 香 港 兩 地 證 券 市 場 建 立 的 交 易 及 結 算 互 聯 互 通 機 制 在 滬 港 通 項

逢 甲 大 學

Bus Hound 5

员工签到录

Improved Preimage Attacks on AES-like Hash Functions: Applications to Whirlpool and Grøstl

untitled

四、通 讯 规 约

Microsoft Word - ISSFA-0237_A_SM39R_series_EEPROM_APN_TC_.doc

Transcription:

微算機原理與實驗 (UEE 2301/1071 ) Chap 5. MCS-51 Addressing Modes 宋開泰 Office:EE709 Phone:5731865( 校內分機 :31865) E-mail:ktsong@mail.nctu.edu.tw URL:http://isci.cn.nctu.edu.tw 1

Addressing Modes Addressing mode is the way the assembler determines the effective address of the operand of an instruction. For 8051, there are 8 addressing modes: Direct Indirect Register Immediate Relative Absolute Long Index 2

Direct Addressing Mode ( 直接定址法 ) 1). 運算元 (operand) 之 address 直接寫在指令上 2). Example : MOV A, 66H ;(A) (66H) 3). 適用範圍 : (1). Internal Data Memory : Byte address 00H ~ 7FH MOV A, 66H (2). SFR : 20 bytes (8051) or 25 bytes (8052) 80H ~ F0H MOV A, 89H ;89H is TMOD register (3). Internal Data Memory : Bit address 00H~7FH SETB 23H (4). SFR : Bit address 80H~F8H SETB CPL C C 3

Indirect Addressing Mode ( 間接定址法 )(1/4) 1). 以暫存器 R0, R1, SP or DPTR 儲存運算元位址, 即欲存取之資料的位址不直接寫在指令中, 而是事先存放於特定的 Register 中 2). 當間接定址用之 Register 出現在指令時, 其前面會有一前置符號 @ MOV R0, # 50H MOV A, @R0 ;(A)=(50H) 4

Indirect Addressing (2/4) 3). 適用範圍 : (1). Internal Data Memory : 以 @R0, @R1 來儲存位址 MOV A, @R0 ;(A)=(50H) (2). Stack : 以 SP 來儲存位址 POP 30H (3). External Data Memory : 用 @R0, @R1 or @DPTR MOVX @DPTR, A (4). Internal Data Memory 的 lower 4 bits (b3~b0) : 以 @R0, @R1 來儲存位址 XCHD A, @R0 5

Indirect Addressing(3/4) 以暫存器 R0, R1, SP, DPTR 儲存運算元位址, 欲存取之資料位址不直接寫在指令中 間接定址用之 Register 出現在指令時其前面會有 @ 符號 MOV A, @R1 41H 40H 3FH 3EH 32H 31H 30H 55H 01H 23H 20H if R1 中為 40H, 而 internal memory address 40H 中有 data 55H, 則 (A) (40H) A=55H stack, 以 SP 來儲存位址 POP POP DPH DPL Stack(Internal RAM) SP 30H Data pointer 0123H POP SP stack pointer 20H 先是 2FH, 再 20H 6

PUSH PUSH Operation SP contains 09H Indirect Addressing (4/4) DPL Data pointer: 0123H DPH (SP) (SP)+1 ((SP)) (direct) Stack pointer set to 0BH 23H (0AH) 01H (0BH) 0BH 0AH SP 09H 01H 23H XX 7

Register Addressing Mode ( 暫存器定址法 ) 1). 將欲存取之 Register 直接寫在指令中 2). Example : MOV A, R0 ;(A)=(R0) 3). 適用之 Register: (1). 4 組 Register Banks : R0~R7 ADD A, R5 (2). A, B, AB, DPTR : INC A MUL AB INC DPTR 8

[ 比較 ] 下列二個指令作用相同 MOV A, R7 ;Register addressing, ;Machine code : 1 byte (6E) MOV A, 07H ;Direct addressing, ;Machine code : 2 bytes (E5 06) 9

Immediate Addressing Mode ( 立即定址法 ) 1). 欲存取之資料直接寫在指令中, 其前面有一 # 2). Example : MOV A, #36H ;(A)= 36H ADD A, #24H ;(A)=(A)+24H 10

用在 jump instructions. Relative addressing 8-bit signed offset -128~+127 SJMP THERE(assembled into address 1000H) THERE Represents an instruction at location 1040H 而 SJMP THERE 在 1000H 及 1001H. The assembler will assign a relative offset of 3EH as byte 2 of the instruction. position independent code 1040H-1002H=3EH (PC) (PC)+2 (PC) (PC)+byte_2 11

Calculating the Offset 12

ACALL; AJMP; Absolute addressing Absolute Call Absolute Jump within the 2K page of the current code memory Upper 5bits determine the 2K page address A15 Current page A11 A10 11-byte 2Kpage (00001)111 0100 0110 0 F 4 6 H A0 11 bits determine the address within a 2K page Page 31 Page 1 Page 0 1000H 0FFFH 0800H 07FFH 0000H 13

Memory map of pages 14

ACALL and AJMP 2-byte instruction 00001 AJMP 111 1 st byte(a10~a8+opcode) 10001 ACALL 01000110 2 nd byte(a7~a0) page31 2K page page0 17FFH 1000H An ACALL instruction is in memory locations 1024H and 1025H, The subroutine to which the call is directed begins in memory location 17A6H, what are the machine language bytes for the ACALL instruction? Solution: F1A6H 15

Determine the Address ACALL; Absolute Call, unconditionally calls a subroutine AJMP; Absolute jump Within the 2K page of code memory Upper 5 bits determine the 2k page A15 A11 A10 A0 不變 11-bit 2K page 00001 111 0100 0110 AJMP THERE 0100 0110 2 nd Byte The label THERE represents an instruction at address 0F46H. 11 bits determine the address within a 2k page 111(00001) 1 st Byte 16

Long addressing LCALL LJMP 3-byte instructions, 16-bit addressing as bytes 2 and 3. 64K space LJMP 8AF2H The Assembler allows programmer to use generic JMP or CALL mnemonic. JMP SJMP AJMP CALL ACALL LCALL LJMP 17

Index Addressing(used in lookup tables)(1/3) 1) uses a base register( 基底暫存器 ), initialized to the beginning of the table) PC or DPTR(data pointer) 2) Use the Accumulator A as an offset. A : index register, ( 索引暫存器 ) MOVC A, @A+DPTR 3) look-up table 只能讀, 不能寫 ( 只有用在程式記憶體 ) 18

Index Addressing(2/3) 基本型式 : MOV A, #ENTRY_NUMBER CALL LOOK_UP LOOK_UP: INC A MOVC A, @A+PC RET TABLE: DB data, data, data, 例 1. REL_PC INC A MOVC A, @A+PC RET DB 66H DB 77H DB 88H DB 99H A=01H A=77H 19

例 2. Index Addressing(3/3) SQUARE: INC A MOVC A, @A+PC RET TABLE: DB 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 如果不用 Look-up table SQUARE: MOV A, #6 CALL SQUARE PUSH 0F0H MOV MUL POP RET 0F0H, A AB 0F0H 20

8051 addressing modes 21

MCS-51 Common-cathode

Lab #2 7-Segment Display 撰寫一個倒數計時器程式, 程式啟動後會在七段顯示器上從 0 倒數至 9, 再從 9 倒數至 0, 間隔時間為 1 秒, 循環顯示 23

Sample program ORG 00H JMP START ORG 50H START: MOV A,#10 MOV DPTR,#TABLE LOOP: SHOW: PUSH A DEC A MOVC A,@A+DPTR MOV P1,A ACALL DELAY POP A DJNZ A,SHOW JMP START

DELAY: MOV R2,#10 D1: MOV R0,#250 D2: MOV R1,#250 DJNZ R1,$ DJNZ R0,D2 DJNZ R2,D1 RET TABLE: DB 11000000B,11111001B,10100100B,10110000B ;O-3 DB 10011001B,10010010B,10000010B,11111000B ;4-7 DB 10000000B,10010000B,10001000B,10000011B ;8-C DB 11000110B,10100001B,10000110B,10001110B ;D-F END

Lab#2 Part II - Four 7-Segment Display 7447: BCD- to 7 segment decoder IC

IC-7447 由於 7SEG 4 實驗模組已經內建 BCD to 7 SEG 解碼 IC 7447, 這顆 IC 可將 BCD 碼轉換為對應七段顯示器的顯示碼 LCD, 7SEGx4 Display(F9)

7-Segment Display MCS-51 Commoncathode

7447: BCD-to-7 segment decoder IC 29

Port connection Vcc Vcc Vcc Vcc Common-anode

實驗原理 透過 8051 I/O port high-order nibble 送出位置控制碼, 使得程式可以控制要在哪一個七段顯示器上顯示出數字 8051 I/O port low-order nibble 輸出 BCD 碼以顯示數字 如何讓四顆 7 段顯示器看起來同時亮? 由於此 IC 一次只能讓一顆 7 段顯示器作用, 因此我們必須快速的讓四個 7 段顯示器輪流顯示, 每次顯示約 1/10 秒 ( 視覺暫留時間 )

位數控制 顯示的數字 1110 #1 1101 #2 1011 #3 0111 #4

腳位對照 使用 JP05 (1)Pin 腳由左到右依序是 1~8 (2)1~4( 紅色 ) 控制數字 (3)5~8( 橘色 ) 控制位數

DEMO 項目 (1) 請撰寫一個程式, 使得四個七段顯示器能夠顯示出 1357 (2) 請撰寫一個程式, 使得四個七段顯示器從 0 數到 200, 每間隔 0.25 秒加 10, 直到 200 並停留在顯示 200

35 ORG 00H AJMP MAIN ORG 50H MAIN: MOV R2,#00H LOOP: MOV P0,#FFH MOV A,R2 MOV DPTR,#SSTABLE MOVC A,@A+DPTR MOV P0,A ACALL DELAY INC R2 CJNE R2,#4,LOOP AJMP MAIN SSTABLE: DB E5H,D6H,B7H,78H DELAY: MOV R6,#10H DL1: MOV R7,#10H DJNZ R7,$ DJNZ R6,DL1 RET END

DEMO1 參考流程圖

從 199 數到 0 參考流程圖 請撰寫一個程式, 使得四個七段顯示器從 0 數到 199, 每間隔 0.25 秒加 1, 直到 199 再回數到 0

結報 在結報中試說明 DEMO2 中如何處 理進位以及借位的問題