Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- .DATA
- arr dw 1,2,3,4,5,6,7,8
- n dw 8 ;the size of array
- n1 dw 4 ;first half of the array index
- t_sum dw 0
- .code
- proc main
- mov cx,n
- mov dx,0
- mov si,0
- ;push array element into the stack
- st:
- mov ah,2
- mov dx,arr[si]
- add dx,48
- push dx
- add si,2
- loop st
- call rev_show ;call the reverse proc
- call sum ;call the sum proc
- call mult ;call mult proc
- endp
- ;show the array element in to reverse order
- proc rev_show
- mov si,0
- mov cx,n
- add sp,2
- revst:
- pop bx
- mov arr[si],bx
- mov dx,arr[si]
- int 21h
- mov dx,' '
- int 21h
- sub arr[si],48
- add si,2
- loop revst
- endp rev_show
- ;sum proc
- proc sum
- mov si,0
- mov cx,n1
- mov ax,0
- sum_up:
- add ax,arr[si]
- add si,2
- loop sum_up
- mov t_sum,ax ;store the value of ax in a t_sum
- endp sum
- ;mult proc
- proc mult
- mov cx,n1
- mov ax,1
- mul_up:
- mul arr[si]
- add si,2
- loop mul_up:
- endp mult
- ;move in to the register
- mov bx,ax
- mov ax,t_sum
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement