Skip to content

CS401 - Computer Architecture and Assembly Language Programming

2 Topics 18 Posts
  • 0 Votes
    2 Posts
    643 Views
    zaasmiZ
    https://www.youtube.com/watch?v=Ydpw1c3SjkI
  • CS401 Assignment 2 Solution and Discussion

    Solved cs401 assignment 2 solution discussion fall 2019
    3
    0 Votes
    3 Posts
    2k Views
    zareenZ
    Q1. Write a subroutine that will find the first even number from an array of your VU ID and calculate its factorial. (10 Marks) Note: Skip 0’s in your VU ID as shown below, VU ID: BC190206435 After skipping 0’s, array would be: Array: 1, 9, 2, 6, 4, 3, 5 The first even number is 2 in the array so its factorial will be calculated and saved in AX register. Solution: [org 0x100] jmp start data: dw 1, 9,2,6,4,3,5 ;initiliazation checkEven: mov dl,0002h mov ax,[data+bx] mov cx,[data+bx] xor ah,ah xor ch,ch div dl cmp ah,00h ;checking remainder je fact add bx,2 jmp checkEven fact: mov ax,0001 mov dx,0000 mult: mul cx loop mult ret start: mov si,00h mov bx,si call checkEven mov ax,0x4c00 int 0x21 Q2. Write a code in assembly language (using appropriate jumps) equivalent to this given code in C. (10 Marks) #include <stdio.h> int main() { int n1=1, n2=2; int largest; if( n1>n2) largest=n1; else largest = n2; return 0; } Solution: Assembly code: [org 0x100] jmp start n1 db 1 n2 db 2 largest db 0 start: mov ax, [n1] xor ah,ah mov bx, [n2] cmp ax,bx ja large mov [largest],bx large: mov [largest],ax mov ax, 0x4c00 int 21h
How to Build a $1,000/Month PAK VS BAN Live Live Cricket Streaming
File Sharing

0

Online

3.0k

Users

2.8k

Topics

8.2k

Posts
| |