. (a) Write a program using 8086 assembly Language (with proper comments) that accepts three different digits as input from the keyboard. Each digit is first converted to a binary equivalent. The binary values of these three digits are compared and the middle value is put in the AL register. This AL register is multiplied with each value of a byte array of size 6, which is stored in the memory. The result of the multiplication is stored in the same memory location. You may assume the byte array has the values 02h, 06h, 08h, 03h, 01h, 05h. Make suitable assumptions, if any

, , No Comments

 Certainly, below is an example of a program written in 8086 assembly language that performs the described tasks. The program uses the DOS interrupt service for input and output operations. Please note that this is a simple example, and additional error checking and handling could be added for a more robust program.


```assembly

section .data

    prompt_msg db "Enter three different digits: $"

    binary_msg db "Binary Equivalent: $"

    result_msg db "Result after multiplication: $"

    newline db 0xA, 0xD, '$'


section .bss

    digits resb 3

    binary resb 8

    array resb 6


section .text

    global _start


_start:

    ; Display prompt message

    mov ah, 9

    mov dx, prompt_msg

    int 21h


    ; Accept three digits as input

    mov ah, 1

    int 21h

    sub al, '0'  ; Convert ASCII to integer

    mov [digits], al


    mov ah, 1

    int 21h

    sub al, '0'  ; Convert ASCII to integer

    mov [digits + 1], al


    mov ah, 1

    int 21h

    sub al, '0'  ; Convert ASCII to integer

    mov [digits + 2], al


    ; Display binary equivalent of the digits

    mov ah, 9

    mov dx, binary_msg

    int 21h


    ; Convert each digit to binary and display

    mov ecx, 3

    mov esi, digits

    mov edi, binary

convert_loop:

    movzx eax, byte [esi]

    call binary_conversion

    add al, '0'

    mov [edi], al

    mov ah, 2

    mov dx, binary

    int 21h


    inc esi

    inc edi

    loop convert_loop


    ; Multiply AL register with each value in the array

    mov ecx, 6

    mov esi, array

    mov al, [digits + 1]  ; Middle value

multiply_loop:

    movzx bl, byte [esi]

    imul bl

    mov [esi], al

    inc esi

    loop multiply_loop


    ; Display the result after multiplication

    mov ah, 9

    mov dx, result_msg

    int 21h


    ; Display the modified array

    mov ecx, 6

    mov esi, array

display_result_loop:

    mov al, [esi]

    add al, '0'

    mov ah, 2

    mov dx, newline

    int 21h


    inc esi

    loop display_result_loop


    ; Exit the program

    mov ah, 4Ch

    int 21h


binary_conversion:

    ; Convert the value in EAX to binary and store it in AL

    mov ecx, 8

    mov ebx, 2

    xor edx, edx

binary_conversion_loop:

    div ebx

    add dl, '0'

    dec ecx

    mov [edi + ecx], dl

    test eax, eax

    jnz binary_conversion_loop

    ret

```


This program takes three digits as input, converts them to binary, multiplies the middle digit with each value in the array, and displays the result after multiplication.

0 टिप्पणियाँ:

Post a Comment