Search This Blog

Wednesday, January 2, 2013

;Q.1 Write a Program to find simple interest
; Assume input from memory directly

data segment
     amount dw 2000 ; assume 2000 as amount
     interest_rate db 15 ; 15% interest rate
     period dw 2    ; for two years  
     simple_interest dw  00h
   
ends

code segment
start:
    ; set data segment register
    mov ax, data
    mov ds, ax
    mov ax, amount ; move amount into AX 
    mul interest_rate ; multiply amount with interest rate
    mul period ; muliply result with period   
    mov bx, 100   ; 100 is copied into bx because divtion take parameter as REG or Memory
    div bx    ;  simple interest = (amount*rate*peroid)/100
    mov simple_interest, ax ;  copy simple interest from  ax        
    ; simple interest program ends here 
    mov ax, 4c00h ; exit to operating system.
    int 21h       ; 21 is DOS interrupt ......... value is ax determines operation
ends

end start ; set entry point and stop the assembler.

No comments:

Post a Comment