ORG 100h
MOV si,sp ; Save stack pointer!
input_loop:
XOR ax,ax
INT 16h ; Use int16 to get a keystroke
CMP al,' ' ; is it a space char?
JE input_loop ; if space, get another char
PUSH ax ; Save current char on stack top!
CMP al,13 ; Terminating CR?
JNE input_loop
POP ax ; Get rid of last pushed char (terminating CR)
JMP test_stack
disp_loop:
POP dx ; DL will get the pushed char
MOV ah,2
INT 21h
test_stack:
CMP si,sp ; Is the stack back where we started?
JNE disp_loop
done: ; So,exit
MOV ax,0x4C00
INT 0x21
=--=--=--=--=--=--=--=--=--=--=--=--=
يمكن كتابة الرنامج بتعديل بسيط ليكون اسهل فى الفهم
=--=--=--=--=--=--=--=--=--=--=--=--=
ORG 100h
MOV cx,0
input_loop:
XOR ax,ax
INT 16h ; Use int16 to get a keystroke
inc cx
CMP al,' ' ; is it a space char?
JE input_loop ; if space, get another char
PUSH ax ; Save current char on stack top!
CMP al,13 ; Terminating CR?
JNE input_loop
POP ax ; Get rid of last pushed char (terminating CR)
JMP test_stack
disp_loop:
POP dx ; DL will get the pushed char
MOV ah,2
INT 21h
dec cx
test_stack:
CMP cx,0 ; Is the stack back where we started?
JNE disp_loop
done: ; So,exit
MOV ax,0x4C00
INT 0x21
=--=--=--=--=--=--=--=--=--=--=--=--=
شرح الكود
=--=--=--=--=--=--=--=--=--=--=--=--=
فى البداية نقوم بجعل الريجستر cx صفر نستخدم هذا الريجستر كعداد للاحرف التى قمنا بأدخالها
ثم نستخدم int 16 لادخل الاحرف
ثم نختبر اذا كان الحرف هو (مسطرة) يتجاهل هذا الحرف غير ذلك يقوم باضافتة فى ال stack ويزيد ال cx
قم يختر هل كان الزر هو ال enter
اذا كان نعم فهذا يعنى انك انتهيت من الكتابة وينتقل للخطوة التالية وهى الطباعة باستخدام int 21 ويطبع القيمة الموجودة فى dl
فيكون pop dl
اتمنى ان تستفيد يا اخى الحبيب