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

In Nasm: In the following code what it\'s needed to sort the array in ascending

ID: 3806216 • Letter: I

Question

In Nasm:

In the following code what it's needed to sort the array in ascending order:

;;;;;;;;;;;;;;;;;;;;   MACRO DEFINITIONS   ;;;;;;;;;;;;;;;;;;;;

; A macro with two parameters

; Implements the write system call

   %macro writestring 2

       mov eax, 4 ;sys_write system call number

       mov ebx, 1 ;file descriptor std_out

       mov ecx, %1 ;message to write from parameter 1

       mov edx, %2 ;message length from parameter 2

       int 0x80

   %endmacro

;;;;;;;;;;;;;;;;;;;;   DATA SEGMENT   ;;;;;;;;;;;;;;;;;;;;

section   .data

msg1 db 'Before sorting: '

lenmsg1 equ $-msg1

msg2 db 'After sorting: '

lenmsg2 equ $-msg2

asciinums db '7','3','2','1','0','5','6','4','8','9'

lenasciinums equ $-asciinums

crlf db 0x0d, 0x0a

lencrlf   equ   $ - crlf              

section   .text

   global _start

_start:

writestring msg1, lenmsg1

   writestring asciinums, lenasciinums

   writestring crlf, lencrlf

   ;fill in missing lines of code here

  

writestring msg2, lenmsg2

   writestring asciinums, lenasciinums

   writestring crlf, lencrlf

   mov   eax, 1           ;terminate program

   int   0x80

  

Explanation / Answer

section   .data

msg1 db 'Before sorting: '

lenmsg1 equ $-msg1

msg2 db 'After sorting: '

lenmsg2 equ $-msg2

asciinums db '7','3','2','1','0','5','6','4','8','9'

lenasciinums equ $-asciinums

crlf db 0x0d, 0x0a

lencrlf   equ   $ - crlf              

section   .text

   global _start

_start:

writestring msg1, lenmsg1

   writestring asciinums, lenasciinums

   writestring crlf, lencrlf

   ;fill in missing lines of code here

  

writestring msg2, lenmsg2

   writestring asciinums, lenasciinums

   writestring crlf, lencrlf

   mov   eax, 1           ;terminate program

   int   0x80

  

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