Pages

CS401 ASSIGNMENT NO. 1 SPRING 2023 || 100% RIGHT SOLUTION || ASSEMBLY LANGUAGE PROGRAMMING || BY VuTech

CS401 ASSIGNMENT NO. 1 SPRING 2023 || 100% RIGHT SOLUTION || ASSEMBLY LANGUAGE PROGRAMMING || BY VuTech

CS401 ASSIGNMENT NO. 1 SPRING 2023 || 100% RIGHT SOLUTION || ASSEMBLY LANGUAGE PROGRAMMING || BY VuTech 

Visit Website For More Solutions
www.vutechofficial.blogspot.com

KINDLY, DON’T COPY PASTE

QUESTION-1

Write an assembly language program to store your Roll Number(Number part only) and calculate their sum.

ANSWER:


; Program to store roll numbers and calculate their sum
section .data
    roll_numbers db 10, 20, 30, 40, 50  ; Example roll numbers (number part only)
    num_rolls equ $ - roll_numbers      ; Number of roll numbers
    sum db 0                            ; Variable to store the sum
section .text
    global _start
_start:
    mov ecx, num_rolls      ; Counter for loop
    mov esi, roll_numbers   ; Pointer to roll_numbers array
    xor eax, eax            ; Clear eax register for sum calculation
loop_start:
    mov al, [esi]           ; Load the current roll number
    add [sum], al           ; Add the roll number to the sum
    inc esi                 ; Move to the next roll number
    loop loop_start         ; Continue loop until ecx becomes zero
    ; Print the sum
    mov eax, 4              ; System call number for write
    mov ebx, 1              ; File descriptor for stdout
    mov ecx, sum            ; Address of the sum variable
    mov edx, 1              ; Number of bytes to write
    int 0x80                ; Call the kernel
    ; Exit the program
    mov eax, 1              ; System call number for exit
    xor ebx, ebx            ; Exit status
    int 0x80                ; Call the kernel


QUESTION-2

Find the offset address where Physical address is 4A37Bh and the segment address is 40FFh.

SOLUTION:

To find the offset address given a physical address and a segment address, you need to perform a calculation using the following formula:

Offset Address = (Segment Address × 16) + Physical Address

In this case, the segment address is 40FFh and the physical address is 4A37Bh. Let's plug in these values into the formula:

Offset Address = (40FFh × 16) + 4A37Bh

To perform the calculation, we need to convert the hexadecimal values to decimal values:

Segment Address = 40FFh = 16639 (in decimal)

Physical Address = 4A37Bh = 304123 (in decimal)

Now, substitute these values into the formula:

Offset Address = (16639 × 16) + 304123

Calculating the values:

Offset Address = 266224 + 304123

Offset Address = 570347

Therefore, the offset address corresponding to a physical address of 4A37Bh and a segment address of 40FFh is 570347.




KINDLY, DON’T COPY PASTE
SUBSCRIBE, SHARE, LIKE AND COMMENTS FOR MORE UPDATES
SEND WHATSAPP OR E-MAIL FOR ANY QUERY
0325-6644800
kamranhameedvu@gmail.com
Visit Website For More Solutions
www.vutechofficial.blogspot.com