MMC lab assig 2

an anonymous user · April 08, 2021 · Assembly
%macro scall 4     ; macro declare
mov rax,%1
mov rdi,%2
mov rsi,%3
mov rdx,%4

Section .data
print db "Mean of number 10.2,11.4,13.6,15.8,16.9 is = "
printlen equ $-print
arr dd 10.2,11.4,13.6,15.8,16.9
point db "."
pointlen equ $-point
divisior dd 5.0
tent dd 10000.0

section .bss
mean resd 1        ;store mean result
mean1 rest 1       
counter resb 1     ;10 byte storage
counter1 resb 1    ;for 2 digit number
temp resb 1

section .text
global _start
scall 1,1,print,printlen    ;display message

mov esi,arr
mov cx,05
fldz            ;00 on top of stack

fadd dword[esi]    ;floating point addition
add esi,4
dec cx
jnz up
fdiv dword[divisior]   ;floating point division
fst dword[mean]        ;copies st(0) to destination

fmul dword[tent]       ;floating point multiplication
fbstp tword[mean1]     ;store BCD interger and pop
mov ebp,mean1

call display
scall 60,0,0,0      ;end code
display:        ;procedure for display purpose
add ebp,9
mov byte[counter],10  

cmp byte[ebp],00
je skip
cmp byte[counter],02
jne loop1
scall 1,1,point,pointlen

mov bl,byte[ebp]
mov byte[counter1],2     ;Counter1 for display 2 didgit number
rol bl,4 		  ;rotate by 4
mov byte[ebp],bl
and bl,0FH
cmp bl,09H
jbe loop3
add bl,07H

add bl,30H		 
mov byte[temp],bl
scall 1,1,temp,1	   ;display result
mov bl,byte[ebp]
dec byte[counter1]
jnz loop2

dec ebp
dec byte[counter]
jnz above



Please sign up or log in to contribute to the discussion.