You are on page 1of 4

DOSSEG

MODEL SMALL.
STACK 30H.
DATA.
X1 DW 12H
X2 DB 2H
X3 DD 10H
X4 DB 2
CODE.
MOV AX,@DATA
MOV DS,AX
MOV BX,3
MOV CX,2
ADD BX,CX
INC BX
DEC CX
ADD X1,CX
ADD X2,CX error: operand types do't match ;
ADD X3,CX error: operand types do't match ;
ADD X4,CX error:operand types don't match ;
ADD X2,X4 error: illegal memory reference ;
ADD DS,3H error: illegal use of segment register ;
ADD X1,3
ADD X1,BX
MOV AH,4CH
INT 21H
END

lst. ‫من خالل الملف‬

‫حجم‬
‫عنوان‬
‫التعليمة‬ ‫التعليمة بلغة االلة‬ ‫التعليمة باالسمبلي‬ ‫رقم التعليمة‬
‫االزاحة‬
)‫(بالبايت‬
00 3 B8 0000 MOV AX,"DATA Inst1
03 2 8E D8 MOV DS,AX Inst2
05 3 BB 0003 MOV BX,3 Inst3
08 3 B9 0002 MOV CX,2 Inst4
0B 2 D9 03 ADD BX,CX Inst5
0D 1 43 INC BX Inst6
0E 1 49 DEC CX Inst7
0F 4 0E 0000 01 ADD AX,CX Inst8
13 5 8306000003 ADD X1,3 Inst9
18 4 1E 0000 01 ADD X1,BX Inst10
1C 2 B4 4C MOV AH,4CH Inst11
1E 2 CD 21 INT 21 Inst12

‫ بايت‬1 ‫ كل رقمين سادس عشريين تعتبر‬:‫حجم التعليمة‬

‫ حجم التعليمة السابقة‬+‫عنوان االزاحة للتعليمة= عنوان التعليمة السابقة‬


‫مثال‬
INST3 ‫ حجم التعليمة‬+ INST3 ‫= عنوان االزاحة للتعليمة‬INST4 ‫عنوان االزاحة للتعليمة‬
08=3+05=
ds:09 00
X1
Suppose data X1,X2,X3,X4 are loaded starting at address 09 ds:0A 12
ds:10 02 X2
Offset of x1 in data segment is 09 .Logical address of x1 is ds:09 ds:11 00
Offset of x2 in data segment is 10. Logical address of x2 is ds:10 ds:12 00
Offset of x3 in data segment is 11. Logical address of x3 is ds:11 X3
ds:13 00
Offset of x4 in data segment is 15 . Logical address of x4 id dsL15 ds:14 10
ds:15 02 X4

INST1 occupies bytes 0,1,2 cs:00


INST2 occupies bytes 3,4 cs:01 INST1
INST3 occupies bytes 5,6,7 cs:02
And so on
cs:03
INST2
Offset address of instruction is the address of the lowest byte in the cs:04
instruction cs:05
cs:06 INST3
Examples cs:07
Offset address of INST1 is the address of lowest byte =00 cs:08
Logical address if INST1 is cs:00
cs:09 INST4
Offset address of INST2 is the address of the lowest byte=03
Logical address of INST2 is cs:03 cs:0A
Offst address of INST3 is the address of the lowest byte=05 cs:0B
INST5
Logical address of INST3 is cs:05 cs:0C
And so on cs:0D INST6
cs:0E INST7
cs:0F
) Instruction Pointer ‫ (مؤشر التعليمة‬IP ‫المسجل‬
A CPU register that contains the offset address of the next instruction cs:10 INST8
( point to the next instruction) cs:11
‫ تنفيذ البرنامج‬cs:12
IP=00 ‫ للتعليمة االولى اى ان‬offset‫ بعنوان االزاحة‬IP ‫) يتم تحميل المسجل‬1 cs:13
‫ للتعليمة‬offset ‫ بعنوان االزاحة‬IP ‫) بعد تنفيذ التعليمة االولى يتم تحميل المسجل‬2 cs:14
IP=03 ‫ أى ان‬.‫الثانية‬ cs;15 INST9
‫ للتعليمة‬offset ‫ بعنوان االزاحة‬IP ‫) بعد تنفيذ التعليمة الثانية يتم تحميل المسجل‬3
IP=05 ‫الثالثة اى ان‬ cs:16
cs:17
cs:18
cs;19
INST10
cs:1A
cs:1B
cs:1C
INST11
cs:1D
cs:1E
INST12
cs:1F
‫البرنامج االتي لجمع محتويات المتغيرات ‪ grade1,grade2,grade3‬و تخزين النتيجة في النتغير ‪sum‬‬

‫‪Add sum,grade1‬‬ ‫هذه الجمل غير جائزة الن معاملي التعليمة‬


‫‪Add sum,grade2‬‬ ‫‪ add‬ال يجوز ان يكونا مواقع ذاكرة و‬
‫‪Add sum,grade3‬‬ ‫لذلك نلجأ الى نقل وسطي‬

‫‪DOSSEG‬‬
‫‪.MODEL SMALL‬‬
‫‪.STACK 40H‬‬

‫‪.DATA‬‬
‫‪GRADE1‬‬ ‫‪DW‬‬ ‫‪30H‬‬
‫‪GRADE2‬‬ ‫‪DW‬‬ ‫‪3H‬‬
‫‪GRADE3‬‬ ‫‪DW‬‬ ‫‪2‬‬
‫‪SUM‬‬ ‫‪DW‬‬ ‫?‬

‫‪.CODE‬‬
‫‪MOV AX,@DATA‬‬
‫‪MOV DS,AX‬‬

‫‪MOV‬‬ ‫‪AX,GRADE1‬‬
‫‪ADD‬‬ ‫‪AX,GRADE2‬‬
‫‪ADD‬‬ ‫‪AX,GRADE3‬‬
‫‪MOV‬‬ ‫‪SUM,AX‬‬

‫‪MOV AH,4CH‬‬
‫‪INT 21H‬‬
‫‪END‬‬

‫تتبع البرنامج باستخدام ال ‪debug‬‬


‫االوامر‬
‫‪ : D ds:0 10‬عرض محتويات قطاع البيانات بدأ من البايت ‪ ds:0‬الى البايت ‪ds:10h‬‬
‫عرض محتويات قطاع البيانات بدأ من ‪ cs:0‬الى ‪cs:2‬‬ ‫‪D cs:0 2‬‬

‫تمرين‪ :‬اعرض لغة االلة للتعليمة الثالثة‬

‫اوامر ال ‪debug‬‬
‫‪T‬‬
‫‪T=100‬‬
‫‪T=100 5‬‬
‫‪T4‬‬
Page 474

You might also like