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