Sunday, April 1, 2012

Division of two numbers using 8086 in assembly language

assume cs:code,ds:data
data segment
org 2000h
num1 dw 8345h
num2 dw 2346h
rem dw 2d dup(0h)
quo dw 2d dup(0h)
data ends
code segment
start:mov ax,data
mov ds,ax
mov ax,num1
idiv num2
mov quo,ax
mov rem,dx
mov ah,4ch
int 21h
code ends
end start

3 comments:

  1. This program applicable in following conditions
    1)divisor and dividend must be single digit
    2)if divisor is greater then dividend and both are not divisible then return 0
    3)if divisor is less then dividend and both are not divisible then return 1
    4)if divisor and dividend are completely divisible then return accurate result.

    .model small
    .data
    msg1 db 'enter dividend:$'
    msg2 db 10,13,'enter divisor:$'
    result db 10,13,'result is :$'
    dividend db ?
    divisor db ?

    .code
    .startup
    mov ax,@data
    mov ds,ax

    mov ah,9
    lea dx,msg1
    int 21h
    mov ah,1
    int 21h
    sub al,30h
    mov dividend,al


    mov ah,9
    lea dx,msg2
    int 21h

    mov ah,1
    int 21h
    sub al,30h
    mov divisor,al

    mov al,dividend

    mov bl,divisor

    mov ah,0

    div bl

    mov ah,9
    lea dx,result
    int 21h
    mov ah,2
    add al,30h
    mov dl,al
    int 21h

    mov ah,4ch
    int 21h

    end

    ReplyDelete

DC motor control with Pulse Width Modulation Part 1

DC Motor intro DC motor is a device which converts electrical energy into kinetic energy. It converts the DC power into movement. The typica...