Professional Documents
Culture Documents
MPExp 6 Gyrcirc
MPExp 6 Gyrcirc
numbers
Code:
a)Even Numbers:-
.model small
.stack 100h
.data
numbers db 10, 20, 5, 15, 25 ; Example array of numbers
numbers_size equ ($ - numbers) ; Size of the array
.code
main:
mov ax, @data
mov ds, ax
; Initialize pointers
lea si, numbers ; Point to the start of the numbers array
lea di, even_numbers_msg ; Point to the start of the even numbers message
find_even:
mov al, [si] ; Load the current number into AL
test al, 1 ; Test if the number is odd or even (check LSB)
store_even:
mov [di], al ; Store the even number in the even_numbers_msg buffer
add di, 2 ; Move to the next byte in the even_numbers_msg buffer
next_number:
inc si ; Move to the next number in the array
loop find_even ; Repeat until all numbers are processed
; Exit program
mov ah, 4Ch ; Exit program function
int 21h ; Call DOS
end main
Output:-
b)Odd Number:-
.model small
.stack 100h
.data
numbers db 10, 20, 5, 15, 25 ; Example array of numbers
numbers_size equ ($ - numbers) ; Size of the array
.code
main:
mov ax, @data
mov ds, ax
; Initialize pointers
lea si, numbers ; Point to the start of the numbers array
lea di, odd_numbers_msg ; Point to the start of the odd numbers message
store_odd:
mov [di], al ; Store the odd number in the odd_numbers_msg buffer
add di, 2 ; Move to the next byte in the odd_numbers_msg buffer
next_number:
inc si ; Move to the next number in the array
loop find_odd ; Repeat until all numbers are processed
; Exit program
mov ah, 4Ch ; Exit program function
int 21h ; Call DOS
end main
Output:-