1 / 28

Addressing Modes

Addressing Modes. std@kmitnb.ac.th. Addressing. การแอดเดรสซิ่ง เป็นวิธีการที่จะเข้าถึงข้อมูลในที่ต่าง ๆ ซึ่งการแอดเดรสที่ต่างกันจะทำให้การเขียนโปรแกรมมี ความยากง่ายต่างกันออกไป.

elwyn
Télécharger la présentation

Addressing Modes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Addressing Modes std@kmitnb.ac.th

  2. Addressing การแอดเดรสซิ่ง เป็นวิธีการที่จะเข้าถึงข้อมูลในที่ต่าง ๆ ซึ่งการแอดเดรสที่ต่างกันจะทำให้การเขียนโปรแกรมมี ความยากง่ายต่างกันออกไป

  3. คำสั่ง โอเปอร์แลนด์ โอเปอร์แลนด์ ปลายทาง ต้นทางInstruction Destination Source MOV AX, BXADD AND OR โครงสร้างคำสั่งทั่วไป

  4. Addressing Modes 1.Immediate addressing 2.Register addressing 3.Direct addressing 4.Register indirect addressing 5.Base relative addressing 6.Indexed addressing 7.Base relative indexed addressing

  5. การแอดเดรสซิ่งแบบไม่ติดต่อหน่วยความจำการแอดเดรสซิ่งแบบไม่ติดต่อหน่วยความจำ • Immediate addressing • Register addressing

  6. การแอดเดรสซิ่งแบบติดต่อหน่วยความจำการแอดเดรสซิ่งแบบติดต่อหน่วยความจำ • Direct addressing • Register indirect addressing • Base relative addressing • Indexed addressing • Base relative indexed addressing

  7. 1.Immediate Addressing Mode • เป็นการติดต่อข้อมูลแบบค่าคงที่ขนาด 8 บิตหรือ 16 บิต • ค่าคงที่จะตามหลังรหัสคำสั่ง (Opcode) • มักใช้ในการกำหนดค่าให้กับรีจิสเตอร์ หรือหน่วยความจำ • ไม่สามารถใช้เป็นโอเปอร์แรนด์ปลายทางได้

  8. Immediate... • ค่าของเลข 16 บิต • แบบคิดเครื่องหมายจะมีค่าอยู่ระหว่าง -32768 (8000H) ถึง 32767 (7FFFH) • แบบไม่คิดเครื่องหมายจะมีค่าอยู่ระหว่าง 0-65535 (0FFFFH)

  9. Immediate... • ค่าของเลข 8 บิต • แบบคิดเครื่องหมายจะมีค่าอยู่ระหว่าง -128 (80H) ถึง 127 (7FH) • แบบไม่คิดเครื่องหมายจะมีค่าอยู่ระหว่าง 0-255 (0FFH)

  10. Immediate... • ตัวอย่าง • MOV AL, 44 • MOV AX, 44H • MOV DI, 0 • MOV BX, ”AB” • MOV CL, 11100000B • MOV Byte ptr[1234H], 12

  11. 2.Register Addressing Mode • เป็นการติดต่อข้อมูลในรีจิสเตอร์ 8 บิต • AH, AL, BH, BL, CH, CL, DH, DL • หรือรีจิสเตอร์ 16 บิต • AX, BX, CX, DX, SI, DI, SP, BP, CS, DS, ES, SS

  12. Register... • สามารถใช้รีจิสเตอร์เป็นโอเปอร์แรนด์ต้นทางหรือปลายทางได้ • ยกเว้นในกรณีที่ใช้ CS, DS, SS, ES เป็นโอเปอร์แรนด์ปลายทาง ต้องกำหนดให้ AX เป็นโอเปอร์แรนด์ต้นทางเท่านั้น

  13. Register... • ตัวอย่าง • MOV AL, BL • MOV AX, BX • MOV SP, BP • MOV DS, AX • MOV BX, DS

  14. 3.Direct Addressing Mode • เป็นการติดต่อข้อมูลไปที่หน่วยความจำโดยระบุตำแหน่งที่จะติดต่อลงไปในเครื่องหมาย [ ] โดยตรง

  15. Direct... • ตัวอย่าง • MOV AL, NUMB • MOV BX, SHOW • MOV NAME, BL • MOV BP, DATA1 • MOV AX, [1234H]

  16. 4.Register Indirect Addressing Mode • เป็นการติดต่อข้อมูลในหน่วยความจำโดยใช้การกำหนดตำแหน่งของข้อมูลที่จะติดต่อลงในรีจิสเตอร์ BX, BP, SI หรือ DI แทนการกำหนดค่าตรง ๆ ในวงเล็บ • ใช้ในการโปรแกรมเพื่อจัดการกับข้อมูลเป็นกลุ่ม

  17. Register Indirect... • ตัวอย่าง • MOV AX, [BX] • MOV BL, [BP] • MOV [SI], DX • MOV [DI], DL • MOV Byte ptr[BX], 5

  18. 5.Base Relative Addressing Mode • เป็นการติดต่อข้อมูลในหน่วยความจำโดยใช้การกำหนดตำแหน่งของ • รีจิสเตอร์เบส (BX,BP) บวกกับ • ค่าสัมพัทธ์ (Relative) • ค่าสัมพัทธ์เป็นได้ทั้งค่าบวกและลบ • มีขนาดได้ทั้ง 8 บิต และ 16 บิต

  19. Base Relative... • BX,BP : ใช้ในการเก็บจุดเริ่มต้นของตาราง • ค่าสัมพัทธ์ (Relation) : ชี้ข้อมูลในตาราง

  20. Base Relative... • เมื่อใช้ BX เป็นตัวอ้างอิงจะเป็นการติดต่อไปยัง Data Segment ต้องใช้ DS หา Physical address • เมื่อใช้ BP เป็นตัวอ้างอิงจะเป็นการติดต่อไปยัง Stack Segment ต้องใช้ SS หา Physical address

  21. Base Relative... • MOV AX,[BX+2] • Physical add = DS x 10H + BX + 2 • MOV [BP-100],AX • Physical add = SS x 10H + BP - 100

  22. Base Relative... • ตัวอย่าง • MOV AX, [BX+100H] • MOV BL, ARRY[SI] • MOV [BX+2], DX • MOV TABLE[BP], DL

  23. 6.Indexed Addressing Mode • เป็นการติดต่อข้อมูลในหน่วยความจำโดยการอ้างอิงผ่าน • รีจิสเตอร์อินเด็กซ์ (SI,DI) รวมกับ • ค่าขจัด (Displacement) • SI,DI : เก็บดัชนีในการชี้ข้อมูลในตาราง • ค่าขจัด : ชี้จุดเริ่มต้นตาราง

  24. Indexed... • MOV AL,1000[SI] • Physical add = DS x 10H + 1000 + SI • MOV BL,TABLE[DI] • Physical add = DS x 10H + TABLE + DI

  25. Indexed... • ตัวอย่าง • MOV AX, [1000+DI] • MOV BL, 1000[SI] • MOV [TABLE+SI], DX • MOV TABLE[DI], DL

  26. 7.Base Relative Indexed Addressing Mode • เป็นการติดต่อข้อมูลในหน่วยความจำโดยการอ้างอิงผ่าน • รีจิสเตอร์อินเด็กซ์ (SI,DI) • รีจิสเตอร์เบส (BX,BP) • และค่าสัมพัทธ์ (Relative)

  27. Base Relative Indexed... • MOV AL,1000[BX+SI] • Physical add = DSx10H+1000+BX+SI • MOV BL,TABLE[BP+DI] • Physical add = SSx10H+TABLE+BP+DI

  28. Base Relative Indexed... • ตัวอย่าง • MOV AX, [BX+DI+20H] • MOV BL, HOME[BP+SI] • MOV NAME[BX+SI+2], DX • MOV LIST[BP+DI], DL

More Related