Problem : Programming in Assembly [ Points] The following assembly program is supposed to: receive three integer numbers from the console, call a function, name sort, function sort arranges the three input numbers in non-decreasing order, then, the program should print the resulting list and ends. Note. Function sort takes three integers as input. Example: if the program receives 0 as input, it should print 0. Five parts of the program have been replaced with five empty boxes; and, in each box, you need to write ONE complete instruction (not more or less) such that the program works properly..model large.stack 0h.data msg db "This program receives integer numbers and sorts them in decreasing order.$" msg db "Enter the first number (00-): $" msg db "Enter the second number (00-): $" msg db "Enter the third number (00-): $" msg db "The sorted numbers are: $" cr db 0dh, 0ah, '$' n dw? n dw? n dw? array db dup (?) decimal_ db dup (?) decimal_ db dup (?) decimal_ db dup (?).code.startup mov ax, @data mov ds, ax ;set segment registers lea dx, msg ;print message mov ah, lea dx, cr ;carriage return and newline lea dx,msg lea dx, msg ;print message "Enter the first number: " mov bx, offset n call storenumber mov ah, lea dx, cr ;carriage return and newline lea dx, msg ;print message "Enter the second number: " mov bx, offset n call storenumber Page /8
mov ah, lea dx, cr ;carriage return and newline lea dx, msg ;print message "Enter the third number: " mov bx, offset n call storenumber mov ah, lea dx, cr ;carriage return and newline lea dx, msg ;print message "The sorted numbers are: " mov dx, offset n mov di, offset n mov si, offset n mov ax, n mov bx, n mov cx, n call sort mov ax, n mov bx, offset decimal_ call convert call print mov ax, n mov bx, offset decimal_ call convert call print mov ax, n mov bx, offset decimal_ call convert call print FIN: mov ax, c00h.exit ;call sort procedure ;load ax with the value of n ;load bx with the address of decimal_ array ;call convert to decimal procedure ;call print procedure ;load ax with the value of n ;load bx with the address of decimal_ array ;call convert to decimal procedure ;call print procedure ;load ax with the value of n ;load bx with the address of decimal_ array ;call convert to decimal procedure ;call print procedure ;exit to operating system print proc near ;this procedure prints the numbers mov di, ;load di with for indexing mov cx, ;load the counter with AGAIN: dec di ;decrement di mov ah, ;load ah with for display mov dl, [bx+di] ;load dl with the value of array[bx+di] add dl,0h ;display value on console loop AGAIN ;repeat until the counter reaches 0 mov dl, 0h ret print endp ;load dl with the ASCII value for space ;display a space ;return to caller ;end procedure Page /8
convert proc near ;This procedure converts the hex numbers ;to decimal and stores them in an array mov si, ;load si with the value for dividing mov di, 0 ;load di with 0 for indexing mov cx, ;load the counter with the value L: mov dx, 0 ;load dx with 0 for dividing -bit number div si ;divide dx-ax by si mov [bx+di], dx mov [bx+di], dx ;load the array with the remainder inc di ;increment di to address next element loop L ;repeat until cx reaches 0 ret ;return to caller convert endp ;end procedure storenumber proc near ;This procedure receives the numbers from the user mov di, 0 ;load di with 0 for indexing mov ah, ;load ah with for receiving input READ: ;receive the number and store in al sub al, 0h ;add 0h to the value to convert to ASCII mov array[di], al ;store the value in array[di] inc di ;increment di to address next element cmp di, ;compare di with jb READ ;if below jump to READ mov di, 0 ;set di to 0 for indexing mov ax, 0 ;set ax to 0 mov al, array[di] ;load al with the first digit mov cx, ;load cx with mul cl ;multiply al by mov dx, ax ;store the result in dx mov ax, 0 ;load ax with 0 inc di ;increment di to address next digit mov al, array[di] ;load al with the second digit add dx, ax ;add the second digit to the first mov [bx], dx ;Store in the contents of variable ret ;addressed by bx. ;return to caller storenumber endp ;end procedure sort proc far cmp bx, ax jl LABEL_ cmp cx, bx jl LABEL_ jmp FINISH LABEL_: xchg bx, ax cmp cx, bx ;This procedure sorts the numbers in ascending order. ;compare second number to the first number ;if the second value is lower, jump to LABEL_ ;compare the third value with the second value ;if the third is lower, jump to LABEL_ ;numbers are sorted, jump to FINISH ;exchange the second number with the first ;compare the third number with the second Jl LABEL_ jl LABEL_ jmp FINISH ;the numbers are sorted, jump to FINISH LABEL_: xchg cx, bx ;exchange the third value with the second Page /8
cmp bx, ax ;compare the second value with the third jg FINISH ;if the second value is greater, jump to FINISH xchg bx, ax FINISH: mov n, ax mov n, bx mov n, cx ret sort endp ;exchange the second and first values ;The numbers are sorted ;store the lesser value in n ;store the middle value in n ;store the greater value in n ;return to caller ;end procedure end Page /8
Problem : Design Questions Modify/complete the following figure to select memory address for address range 0F800H-0FFFFH. [ Points] A0--A D0--D U NMCCB A RD A A A A A U ALS 8 0 8 A0 A A A A A A A A8 A A OE CE VPP O0 O O O O O O O A A8 A IO/M UD ALS0 8 Page /8
Problem : Design Questions (continued) a) Without using an inverter gate, modify/complete the following figure to select memory address for address range B0000H-BFFFFH. [ Points] A A A A A A8 A b) What is the memory address range of the th EPROM (the one that is shaded) of above figure? [ Points] BA000H BBFFFH Page /8
Problem : Design Questions (continued) a) Modify/complete the following figure to select memory address for address range 0000H-FFFH. [ Points] D0 -- D A0 -- A U AT U AT U AT A8 #RD A A A A IO/M U A B C G GA GB HCT8 Y0 Y Y Y Y Y Y Y 8 0 8 A0 A A A A A A A A8 A A A A A A OE CE VPP O0 O O O O O O O 8 8 0 8 A0 A A A A A A A A8 A A A A A A OE CE VPP A O0 O O O O O O O 8 8 0 8 A0 A A A A A A A A8 A A A A A A OE CE VPP O0 O O O O O O O 8 b) What is the memory address range of the nd EPROM (the one in the middle) of above figure? [ Points] 8000H FFFFH Page /8
Problem : Short Answer Questions: [ Points] Note: some instruction may not be correct. a) What time is usually used to debounce a keyboard? -0 ms b) Where is the I/O port number stored for a variable I/O instruction? Register DX c) To which register are data input by the bit IN instruction? Register AX d) Which type of JMP instruction assembles if the distance is 00H bytes? Near e) What happens if the.while 0 instruction is placed in a program? Nothing f) How much memory is found in the DOS transient program area? 0 KB g) Which interrupts are available to users? to Page 8/8