8086 Assembler Tutorial for Beginners (Part 2) Memory Access |
הדרכה בתכנות אסמבלר 8086 למתחילים (חלק 2)
גישה לזיכרון |
[BX + SI] [BX + DI] [BP + SI] [BP + DI] |
[SI] |
[BX + SI] + d8 |
[SI] + d8 [DI] + d8 [BP] + d8 [BX] + d8 |
[BX + SI] + d16 |
[SI] + d16 |
d8 - stays for 8 bit displacement. d16 - stays for 16 bit displacement. Displacement can be a immediate value or offset of a variable, or even both. It's up to compiler to calculate a single immediate value. Displacement can be inside or outside of [ ] symbols, compiler generates the same machine code for both ways. Displacement is a signed value, so it can be both positive or negative. Generally the compiler takes care about difference between d8 and d16, and generates the required machine code. For example, let's assume that DS = 100, BX = 30, SI = 70. The following addressing mode: [BX + SI] + 25 is calculated by processor to this physical address: By default DS segment register is used for all modes except those with BP register, for these SS segment register is used. There is an easy way to remember all those possible combinations using this chart: ![]() You can form all valid combinations by taking only one item from each column or skipping the column by not taking anything from it. As you see BX and BP never go together. SI and DI also don't go together. Here is an example of a valid addressing mode: [BX+5]. The value in segment register (CS, DS, SS, ES) is called a "segment", In order to say the compiler about data type,these prefixes should be used: BYTE PTR [BX] ; byte access. or WORD PTR [BX] ; word access.
Emu8086 supports shorter prefixes as well: |
d8
- מוגדר כנתון (היסט) של 8 סיביות.
הערך בקטע האוגר (CS,
DS, SS, ES) נקרא "סגמנט"
(גזרה), והערך באוגרי מצביע (BX,
SI, DI, BP) נקרא "אופסט".
כדי לומר למהדר לגבי סוג הנתונים,
צריכים להשתמש בקידומות הבאות:
תוכנת ה-
Emu8086 גם
מאפשרת קידומות קצרות יותר: |
Copyright 2002-2003 - Emu8086, Inc. All rights reserved. - Portions Copyright 1997-2003 Barry Allyn. All rights reserved.
Hebrew Version Copyright COVAL Computer Software - Copyright © 2003 R&D Private Advisers All rights reserved.
MOV instruction
|
פקודת
MOV
|
These types of operands are supported:
MOV REG, memoryREG: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP. memory: [BX], [BX+SI+7], variable, etc... immediate: 5, -24, 3Fh, 10001101b, etc... |
סוגי האופרנדים הנתמכים הם:
REG (אוגר):
AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP. |
For segment registers only these types of MOV are supported:
MOV SREG, memorySREG: DS, ES, SS, and only as second operand: CS. REG: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP. memory: [BX], [BX+SI+7], variable, etc... |
לאוגרי סגמנטים רק סוגי MOV הבאים נתמכים:
SREG (אוגר
סגמנט): DS, ES, SS ורק
כאופרנד שני אוגר הסגמנט CS. |
The MOV instruction cannot be used to set the value of the CS and IP registers. Here is a short program that demonstrates the use of MOV instruction: |
פקודת MOV
לא יכולה לשמש לקביעת הערך של האוגרים CS
ו- IP. להלן תוכנית קצרה שמציגה את השימוש של פקודת ה- MOV : |
#MAKE_COM#
; instruct compiler to make COM file. ORG 100h ; directive required for a COM program. MOV AX, 0B800h ; set AX to hexadecimal value of B800h. MOV DS, AX ; copy value of AX to DS. MOV CL, 'A' ; set CL to ASCII code of 'A', it is 41h. MOV CH, 01011111b ; set CH to binary value. MOV BX, 15Eh ; set BX to 15Eh. MOV [BX], CX ; copy contents of CX to memory at B800:015E RET ; returns to operating system. |
#MAKE_COM# ORG 100h MOV AX, 0B800h MOV DS, AX MOV CL, 'A' MOV CH, 01011111b MOV BX, 15Eh MOV [BX], CX RET |
#MAKE_COM#;מלמד
את המעבד ליצור |
You can copy & paste the above program to Emu8086 code editor, and press [Compile and Emulate] button (or press F5 key on your keyboard). The Emulator window should open with this program loaded, click How to do copy & paste:
As you may guess, ";" is used for comments, anything after ";" symbol is ignored by compiler. |
אתה יכול להעתיק ולהדביק
את התוכנית הקודמת לתוך העורך
Emu8086 , להפעיל "הידור
והדמיה" על ידי לחיצת הכפתור המתאים (או הקש
F5
במקלדת).
כפי שאתה יכול לנחש, ";" משתמש להערות, המהדר מתעלם מכל דבר כתוב לאחר ";" . |
Actually the above program writes directly to video memory, so you may see that MOV is a very powerful instruction. |
למעשה התוכנית הקודמת כותבת ישירות לזיכרון המסך, לכן אתה יכול לראות ש- MOV היא פקודה רב עוצמה. |
Copyright 2002-2003 - Emu8086, Inc. All rights reserved. - Portions Copyright 1997-2003 Barry Allyn. All rights reserved.
Hebrew Version Copyright COVAL Computer Software - Copyright © 2003 R&D Private Advisers All rights reserved.