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

Can someone help me to solve this? I was doing it but it\'s kind of hard for me

ID: 3786394 • Letter: C

Question

Can someone help me to solve this? I was doing it but it's kind of hard for me when trying to do the loop I don't know how to do it I keep getting errors..... I was trying to do it by a bubble sort, it has to be either bubble sort or selective sort. Thanks!!

Write a 68000 assembly language program to sort a list of unsigned integers into ascending order. Your program should begin at address $1000. Before the program begins, the following information needs to be set up: The address of the first integer in the list should be stored in location $400 by means of an assembler directive. I suggest you begin your list at location $420. The address of the last integer in the list should be stored in location $404 by means of an assembler directive. Your list should contain at least 20 numbers, though you should try it with more when you’re sure your program is working.Use assembler directives to place an unordered list of randomly chosen numbers into memory between the above addresses, inclusively. You are free to manually specify any numbers you like as long as they can be represented as bytes. Recall that an unsigned integer of byte size can represent values from 0 to 255. When your program runs, it should scan through the list of numbers and rearrange them into proper ascending order. You are free to have your program use any method for sorting numbers. The final result should be all of the original numbers in order (smallest number at the first location in the list, largest number at the last location in the list).

Explanation / Answer

An Assembly Language Program sort a given series in ascending order

Data Segment

arr1 db 8,2,7,4,3

Data Ends

Code Segment

Assume cs:code, ds:data

Begin:

    mov ax, data

    mov ds, ax

    mov es, ax

    mov bx, OFFSET arr1

    mov cx, 5

    mov dx, cx

    L1:     

       mov si, 0

       mov ax, si

       inc ax

       mov di, ax

       mov dx, cx

    L2:

       mov al, [bx][si]

       cmp al, [bx][di]

       jg L4

    L3:

       inc si

       inc di

       dec dx

       cmp dx, 00

       je L1

       jg L2

    L4:

       mov al, [bx][si]

       mov ah, [bx][di]

       mov [bx][si], ah

       mov [bx][di], al

       inc si

       inc di      

       dec dx

       cmp dx, 00

       je L1

       jg L2

    Exit:

       mov ax, 4c00h

       int 21h

Code Ends

End Begin

If you do not specify any letter then the number is understood to be Decimal (By default).


DATA SEGMENT
     ARR DW 3333,4444,1111,9999,5555,2222,7777,8888,6666
     LEN DW $-ARR
  
DATA ENDS
CODE SEGMENT
    ASSUME DS:DATA CS:CODE
START:
      MOV AX,DATA
      MOV DS,AX
           
      MOV CX,(LEN/2)-1
OUTER:
      LEA SI,ARR
      MOV BX,0     
INNER:
      INC BX
      MOV AX,ARR[SI]
      INC SI
      INC SI
      CMP AX,ARR[SI]
      JB SKIP
   
      XCHG AX,ARR[SI]
      MOV ARR[SI-2],AX
   
SKIP:
      CMP BX,CX
      JL INNER
              
      LOOP OUTER
          
      MOV AH,4CH
      INT 21H   
CODE ENDS
END START

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