www.vustudents.ning.com

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

# CS 401 Assignment 1 Fall 2021. Due Date= 9 December 2021

1. Write an assembly language program to swap the first four digits of your VUID with the last four digits leaving the middle one intact. For example, if the digits in your VUID are 1423 5 0986, then the VUID should be converted to 0986 5 1423.

Note: Make it sure to use the last 5 digits of your own VUID as name of the .asm file, otherwise zero marks will be awarded.

Requirements:

Following are required in a single MS-Word document:

• Assembly language program.
• Screenshot of the NASM command (assembling the .asm file).
• Screenshot of AFD debugger showing the final values in memory.

Best of luck!

Views: 942

Attachments:

### Replies to This Discussion

Stay touched with this discussion, Solution idea will be uploaded as soon as possible in replies here before the due date.

CS401 Assignment 1 Solution Spring 2021

Code

[org 0x0100]

jmp begin

VU_ID:  dw      1,      8,      0,      2,      0,      0,      1,      1,      6              ; array - consecutive memory locations (2 bytes per index)

sum:    dw      0                                                                           ; variable

; mnemonic destination, source

begin:                         mov ax, 0                             ; the result of addition will be stored in the AX register

mov bx, VU_ID                  ; address will be stored in the BX register

mov cx, 9                             ; the count of nine digits will be stored in the CX register

; 0 - 0 == 0

continue_Process:      cmp word [bx], 0                                             ; non-destructive subtraction in other words, the result of subtraction does not store anywhere but this result

; is used to set the flags only

je check_Is_Entire_Array_Traversed            ; if the value of index is equal to zero then jump (conditional jump)

add ax, [bx]                                                 ; add index's value to the AX register's value

check_Is_Entire_Array_Traversed:              add bx, 2                                     ; move to the next index (remember this is a address)

sub cx, 1                                     ; decrement our count

jnz continue_Process           ; continue process if the entire is not traversed

mov [sum], ax                                                                                               ; total sum is stored in variable

terminate:     mov ax, 0x4c00                                                                        ; ending instructions

int 0x21

The end

# CS 401 Assignment 1 Fall 2021 Solution link

CS401-Assignment-01-Solution-Fall-2021_VU_Ning.docx

# CS401 Assignment 1 Solution Fall 2021 100% Correct Solution

#cs401assignment1solutionfall2021 #cs401assignment1solution2022
CS401 Assignment 1 Solution Fall 2021 | CS401 Assignment Solution 2022

CS401 Assignment 1 Fall 2021 solution idea:

Code:

[org 0x0100]

jmp begin

VU_ID: dw 1, 8, 0, 2, 0, 0, 1, 1, 6 ; array - consecutive memory locations (2 bytes per index)
sum: dw 0 ; variable

; mnemonic destination, source

begin: mov ax, 0 ; the result of addition will be stored in the AX register
mov bx, VU_ID ; address will be stored in the BX register
mov cx, 9 ; the count of nine digits will be stored in the CX register

; 0 - 0 == 0
continue_Process: cmp word [bx], 0 ; non-destructive subtraction in other words, the result of subtraction does not store anywhere but this result
; is used to set the flags only
je check_Is_Entire_Array_Traversed ; if the value of index is equal to zero then jump (conditional jump)
add ax, [bx] ; add index's value to the AX register's value

check_Is_Entire_Array_Traversed: add bx, 2 ; move to the next index (remember this is a address)
sub cx, 1 ; decrement our count
jnz continue_Process ; continue process if the entire is not traversed

mov [sum], ax ; total sum is stored in variable

terminate: mov ax, 0x4c00 ; ending instructions
int 0x21

kindly mjy bna dy koi plz.....

1

2

3

4

5

## Latest Activity

shahzeel khan, Najwa Yaminah, spacedata and 2 more joined Virtual University of Pakistan
51 minutes ago
Najwa Yaminah replied to irshad kausar's discussion math
2 hours ago
Misha princess is now friends with Muhammad Sohaib Akhtar and Muhammad Umar daraz
5 hours ago
5 hours ago
Izhar Ahmad liked Mani Siddiqui's discussion تو نے دیکھا ہے کبھی
5 hours ago
Fatima khan posted a discussion

### Entrepreneurship Festival

7 hours ago
21 hours ago
DamianTyson joined + M.Tariq Malik's group

21 hours ago