السلام عليكم
عندنا مشروع في الجامعة تسليمه غداً لمادة المايكروبروسيسر 8086 يقوم بإخراج القيمة العظمى والصغرى والمتوسط الحسابي لمصفوفة مخزنة في الذاكرة بداخل البرنامج "ملف الكود" قيمها موجبة وسالبة Signed وطباعتها
الأن انهيت الجزء الخاص ب القيم العظمى والصغرى وامر طباعتهم ولكن واجهت مشكلة في امر المتوسط الحسابي
; multi-segment executable file template.
data segment
; add your data here!
Array dB 000h,013h,012h,020h,015h,07dh,0FEh,0D7h,055H,0f3h,02Dh,080h,0ffh,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
MaxI DB "The Maximum Value in Integer = $"
Min1 DB "The Minimum Value in Integer = $"
ten db 10
AVG DB "The Average Value in Integer = $"
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
; add your code here
LEA SI,ARRAY ; offset array to si pointer
MOV CL,[si+1] ; size of array
MOV Ch,[si] ; size of array
MOV bL,00 ; initial value of Minimum
XOR AX,AX ; fast way to make Register 0
MOV bH,BYTE PTR[SI] ; initial value of Maximum
L1:
CMP bL,BYTE PTR[SI] ; compare Minimum to the value of array
JL L2
MOV bL,BYTE PTR[SI] ; make bl Minimum with value of si
L2:CMP bH,BYTE PTR[SI] ;compare Maximum to the value of array
JG L3
MOV bH,BYTE PTR[SI] ;make bl Maximum with value of si
L3:
mov al,[si]
cwd
Test Al,Al
jS Nega
add DI,ax
adc dx,0
Jmp Result
nega:neg ax
sub DI,ax
sbb dx,0
Result:
INC si
loop L1
Call Maximum ; call and Print Maximum value of the array
TEST bl,BL ;test if bl positive or negative
js MinimumNN
MinimumNN: call MinimumN ; call and Print the Minimum value and if the value negative go and print negative integer value
JMP END
call Minimum
END: mov ah,4ch
int 21h
MinimumN PROC NEAR ;This Procedure To Convert The Hex Value to decimal values
lea dx,Min1 ; Show The Massage
mov ah,9
int 21h
xor ax,ax
xor dx,dx
xor cx,cx
mov al,bl ; To Make The Result of Negative Value of Minimum correct
NEG AL ;
mov cl,0ah
div cl
push ax
mov ah,00h
div cl
push ax
mov ah,00h
div cl
push ax
mov ax,0200h
mov dl,"-"
int 21h
pop dx
mov dl,dh
add dx,30h
int 21h
pop dx
mov dl,dh
add dx,30h
int 21h
pop dx
mov dl,dh
add dx,30h
int 21h
mov dl,10
int 21h
ret
MinimumN ENDP
Maximum PROC NEAR
lea dx,MaxI
mov ah,9 ; This Procedure To Convert The Hex Value to decimal values
int 21h
xor ax,ax
xor dx,dx
xor cx,cx
mov al,bh
mov cl,0ah
div cl
push ax
and ah,00h
div cl
push ax
and ah,00h
div cl
push ax
mov ax,0200h
pop dx
mov dl,dh
add dx,30h
int 21h
pop dx
mov dl,dh
add dx,30h
int 21h
pop dx
mov dl,dh
add dx,30h
int 21h
mov dl,10
int 21h
mov dl,0dh
mov ah, 2
int 21h
mov dl,0ah
mov ah, 2
int 21h
ret
Maximum ENDP
Minimum PROC NEAR ; If The Minimum Value is positive go here and print the result
lea dx,Min1
mov ah,9
int 21h
xor ax,ax
xor dx,dx
xor cx,cx
mov al,bl
mov cl,0ah
div cl
push ax
mov ah,00h
div cl
push ax
mov ah,00h
div cl
push ax
and ax,0200h
mov dl,"-"
int 21h
pop dx
mov dl,dh
add dx,30h
int 21h
pop dx
mov dl,dh
add dx,30h
int 21h
pop dx
mov dl,dh
add dx,30h
int 21h
mov dl,10
int 21h
mov dl,0dh
mov ah, 2
int 21h
mov dl,0ah
mov ah, 2
int 21h
ret
Minimum ENDP
average1 PROC NEAR
xor ax,ax
xor dx,dx
mov aX,dI
mov cl,0ah
div cl
push ax
mov ah,00h
div cl
push ax
mov ah,00h
div cl
push ax
mov ax,0200h
pop dx
mov dl,dh
add dx,30h
int 21h
pop dx
mov dl,dh
add dx,30h
int 21h
pop dx
mov dl,dh
add dx,30h
int 21h
mov dl,10
int 21h
ret
end start ; set entry point and stop the assembler.طبعاً average1 Proc مازال لم يستخدم بعد قيمة المتوسط الحسابي عندي خاطئة
الرجاء المساعدة