Mid Report
Mid Report
Section:
“D”
CODE:
.model small
.stack 100h
.data
choice_msg db 'Enter your choice (1 for integer, 2 for ASCII): $'
input_msg db 'Enter the value: $'
output_msg db 'Converted value: $'
newline db 0Dh, 0Ah, '$'
invalid_choice_msg db 'Invalid choice. Please enter 1 or 2.$'
.code
main:
mov ax, @data
mov ds, ax
; Invalid choice
mov ah, 09h
lea dx, invalid_choice_msg
int 21h
jmp exit_program
convert_to_ascii:
; Display input message
mov ah, 09h
lea dx, input_msg
int 21h
jmp exit_program
convert_to_integer:
; Display input message
mov ah, 09h
lea dx, input_msg
int 21h
jmp exit_program
exit_program:
; Move cursor to next line
mov ah, 09h
lea dx, newline
int 21h
; Exit program
mov ah, 4Ch
int 21h
end main
OUTPUT:
QUESTION NO 2:
A) Simulate a program that takes inputs a string in array store and then print the stored
string in reverse order on screen and check if string is palindrome or not.
CODE:
.model small
.stack 100h
.data
prompt_msg db 'Enter a string: $'
reverse_msg db 'Reverse of the string: $'
palindrome_msg db 'The string is palindrome.$'
not_palindrome_msg db 'The string is not palindrome.$'
newline db 0Dh, 0Ah, '$'
max_size equ 50
.code
main:
mov ax, @data
mov ds, ax
OUTPUT:
QUESTION NO 3:
b) Construct a Program in assembly language that take perform following Calculations
Output= 1s complement of (X) +2"d complement of (Y)+Z.
Here x=3, y=2 and Z=9
CODE:
.model small
.stack 100h
.data
x dw 3
y dw 2
z dw 9
output dw ?
.code
main:
mov ax, @data
mov ds, ax
; Exit program
mov ah, 4Ch
int 21h
print_num proc
push ax
push bx
push cx
push dx
mov bx, 10
print_digits:
pop dx ; Pop digit from stack
add dl, '0'
mov ah, 02h
int 21h
loop print_digits
pop dx
pop cx
pop bx
pop ax
ret
print_num endp
end main
OUTPUT: