CS401 Assignment Solution 2018
#1
 
Cs401 assignment No 1
Solution :

 [org 0x100]
jmp start
data:    dw  8,2,0,0,-1,-1,-7,-7,-9                    
swap:   db 0                                                                
start:    mov bx,0                                                         ; initialize array index to zero
            mov byte [swap],0                                          ; rest swap flag to no swaps              
loop1:  mov ax, [data+bx]                                           ; load number in ax
            cmp ax, [data+bx+2]                                       ; compare with next number
            jae noswap                                                      ;no swap if already in order
           
            mov dx,[data+bx+2]                                        ; load second element in dx
            mov [data+bx+2], ax                                       ;store first number in second
            mov [data+bx], dx                                           ; store second number in first
            mov byte [swap], 1                                         ;flag that a swap has been done
 
noswap:           add bx,2                                              ; advance bx to next index
                        cmp bx, 11                                          ; are we at last index
                        jne loop1                                             ; if not compare next two
                        cmp byte [swap], 1                             ;check if a swap has been done
                        je start                                                 ; if yes make another pass
                        mov ax, 0x4c00                                               ;terminate program
                        int 0x21
[img=648x439]file:///C:/Users/sam/AppData/Local/Temp/OICE_2C0630CB-512F-4478-9498-F9B951A3EB7D.0/msohtmlclip1/01/clip_image001.jpg[/img][img=644x420]file:///C:/Users/sam/AppData/Local/Temp/OICE_2C0630CB-512F-4478-9498-F9B951A3EB7D.0/msohtmlclip1/01/clip_image002.jpg[/img][img=654x418]file:///C:/Users/sam/AppData/Local/Temp/OICE_2C0630CB-512F-4478-9498-F9B951A3EB7D.0/msohtmlclip1/01/clip_image003.jpg[/img]
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  CS401 GDB Solution Mishi Khan 0 123 02-05-2019, 11:36 PM
Last Post: Mishi Khan
  CS402 Assignment Solution Mishi Khan 0 56 02-05-2019, 11:18 PM
Last Post: Mishi Khan
  CS411 Complete Assignment Solution Mishi Khan 0 67 01-31-2019, 01:30 AM
Last Post: Mishi Khan
  CS401 Assignment 2 Mishi Khan 0 92 01-29-2019, 07:32 PM
Last Post: Mishi Khan
  cs-401 assignment 3 of spring 2018 saharmehdi 1 1,108 07-31-2018, 08:53 PM
Last Post: Iqra kouser
  Required CS401 - Computer Architecture and Assembly Assignment solution Javed Latif 1 1,686 05-10-2018, 09:23 AM
Last Post: Iqra kouser
  Need CS401 Assignment Solution shah zeb 1 2,980 11-15-2017, 01:05 PM
Last Post: Pakistani
  need cs401 assignment solution Sadaf Afzal 2 1,024 11-14-2017, 08:28 PM
Last Post: Admin
  CS401 Assignment 1 Solution Fall 2017 Admin 0 3,174 11-14-2017, 08:25 PM
Last Post: Admin
  CS401 Assignment 3 Solution Pakistani 0 2,581 07-21-2017, 01:34 PM
Last Post: Pakistani



Users browsing this thread:
1 Guest(s)