Unit 4
Unit 4
ATIGRE (1644)
Question Bank (K scheme)
Name of subject: MICROPROCESSOR ALL CHAPTERS
Subject code: 314321 Course :CW
Semester: IV
(2 Marks)
ii)SUB:
.model small ; Define the memory model
.stack 100h ; Define stack size
ii)SUB:
.model small ; Define the memory model
Institute Code & Name: SANJAY GHODAWAT INSTITUTE,
ATIGRE (1644)
Question Bank (K scheme)
Name of subject: MICROPROCESSOR ALL CHAPTERS
Subject code: 314321 Course :CW
Semester: IV
ii) signed:
.model small ; Define the memory model
.stack 100h ; Define stack size
check_odd:
mov al, [si] ; Load the current element of the array into AL
and al, 01h ; AND AL with 01h to check if the number is odd (LSB = 1)
jz next_number ; If result is 0 (even), jump to next number
Institute Code & Name: SANJAY GHODAWAT INSTITUTE,
ATIGRE (1644)
Question Bank (K scheme)
Name of subject: MICROPROCESSOR ALL CHAPTERS
Subject code: 314321 Course :CW
Semester: IV
next_number:
inc si ; Move to the next number in the array
loop check_odd ; Loop until all 10 numbers are checked
find_largest:
mov al, [si] ; Load the current array element into AL
cmp al, largest ; Compare it with the current largest number
jbe next_element ; If AL <= largest, jump to next element
mov largest, al ; Update largest if a larger number is found
next_element:
inc si ; Move to the next element in the array
loop find_largest ; Repeat the loop until all elements are checked
; Initialize zero_count to 0
mov zero_count, 0 ; Reset zero_count to 0
count_zeros:
; Test the LSB (Least Significant Bit) of AL
test al, 01h ; AL & 01h - checks if the LSB is 0
jnz not_zero ; If LSB is 1 (not zero), jump to not_zero
no_borrow:
mov [dx], al ; Store the result in the result variable
ret
sub_bcd endp
copy_string2:
lea si, string2 ; Load address of string2 into SI
copy_string2_loop:
mov al, [si] ; Load byte from string2 into AL
mov [di], al ; Store byte from AL to result
inc si ; Move to next byte of string2
inc di ; Move to next byte of result
cmp al, 0 ; Check if we've reached the null terminator
je end_program ; Jump to program end if null terminator is found
jmp copy_string2_loop
end_program:
; End the program
mov ah, 4Ch ; DOS interrupt to exit program
int 21h ; Call interrupt to terminate the program
find_length:
mov al, [si] ; Load byte from string into AL
cmp al, 0 ; Compare AL with 0 (null terminator)
je done ; If AL is 0 (end of string), jump to done
inc si ; Move to the next character in the string
inc cx ; Increment the length counter
jmp find_length ; Repeat the process for the next character
done:
; Now CX contains the length of the string
; The length of the string is stored in CX register
negative_number:
; If the number is negative, display the negative message
lea dx, msg_negative ; Load the address of the negative message
mov ah, 09h ; DOS function to display string
int 21h ; Call DOS interrupt to display the string
end_program:
; End the program
mov ah, 4Ch ; DOS interrupt to exit program
int 21h ; Call interrupt to terminate the program
; Initialize counters to 0
mov byte ptr odd_count, 0
mov byte ptr even_count, 0
check_numbers:
mov al, [si] ; Load current array element into AL
and al, 1 ; Perform bitwise AND with 1 to check LSB (odd or even)
jz even_number ; Jump if the number is even (AL is 0)
next_element:
inc si ; Move to the next element in the array
loop check_numbers ; Repeat for all array elements
PrintNum proc
; Function to print number in AL
Institute Code & Name: SANJAY GHODAWAT INSTITUTE,
ATIGRE (1644)
Question Bank (K scheme)
Name of subject: MICROPROCESSOR ALL CHAPTERS
Subject code: 314321 Course :CW
Semester: IV
transfer_loop:
mov al, [si] ; Load byte from source (pointed by SI) into AL
mov [di], al ; Store byte from AL into destination (pointed by DI)