Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an assembly language program that sorts a list of dates and then prints ou

ID: 662998 • Letter: W

Question

Write an assembly language program that sorts a list of dates and then prints out the dates sorted oldest to newest.

The dates are in the format of DD- MMM-YYYY, e.g. ?23-JUL-2010?.

Define and implement the following as procedures or macros (your choice) and use them to accomplish this task:

DateToNumber

Parameter is the address of a string.

Turns the string form of the date, DD-MMM-YYY, into a unique 32-bit number.

The date numbers are unsigned and sort the same as the dates they represent.

For example, if 23-JUL-2010 is the number 42, then 24-JUL-2010 will be bigger than 42 and 22-JUL-2010 will be smaller than 42.

Returns the 32-bit date number.

NumberToDate

Parameter is a 32-bit unsigned number.

Turns the number back into its corresponding date string.

Returns the address of the string.

BubbleSort

Parameters are the address of an array of 32-bit unsigned numbers and the length of the array.

Sorts the array in place from smallest to largest.

No return value.

Any pointers or tips would help! Thank you very much in advance!

Explanation / Answer

Date conversion i am not sure..if you get that one...directly can input this sorting program

.MODEL SMALL
.STACK
.DATA
LIST DB 03H,034H,02H,01H,05H
N DW $-LIST
ORDER EQU 0 ;implies ascending order
MSG DB 'THE SORTED ARRAY IS:: $'

.CODE
MOV AX,@DATA
MOV DS,AX
MOV BX,N
DEC BX

NXTPASS:MOV CX,BX
MOV SI,00H

NXTCOMP:MOV AL,LIST[SI]
INC SI
CMP AL,LIST[SI]
IF ORDER EQ 0 ;ascending
JB NEXT
ELSE ;descending
JA NEXT
ENDIF
XCHG AL,LIST[SI]
MOV LIST[SI-1],AL

NEXT:LOOP NXTCOMP
DEC BX
JNZ NXTPASS
LEA DX,MSG
MOV AH,09H
INT 21H
MOV BX,N
MOV SI,00H

AGAIN: MOV AL,LIST[SI]
ADD AL,'0'
MOV DL,AL
MOV AH,02H
INT 21H
MOV AH,02H
MOV DL,' '
INT 21H
INC SI
DEC BX
JNZ AGAIN
MOV AH,4CH
INT 21H
END

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote