Assigned Byte 0 Assigned Byte 1 B0 B1: Computer Organization & Assembly Language ASSIGNMENT#2 (FALL 2023)
Assigned Byte 0 Assigned Byte 1 B0 B1: Computer Organization & Assembly Language ASSIGNMENT#2 (FALL 2023)
❖ You are required to solve the assignment on this document and submit it on GCR (SoftCopy)
❖ You have to use your Roll No and consider it as decimal for the unique declaration purpose.
❖ Exclude the characters and the first two digits from your Roll number.
FOR EXAMPLE: If your number is 22i-7823, use 7823, where A0 assign the first digit of it.
                                             Assign Digit 0   Assign Digit   Assign Digit 2         Assign Digit 3
                                                                   1
          Short for Assigned Digit                A0               A1             A2                     A3
                                                     Page 1 of 3
                       COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                                  Page 2 of 3
                 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                             Page 3 of 3
                      COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                ASSIGNMENT#2 (FALL 2023)
   NOTE: AND performs a Boolean(bitwise) AND operation between each pair of matching bits in two
   operands and place result in the destination. AND instruction always clear overflow and carry flags. It
   modifies Sign, Zero and Parity flags.
                                                                                 Sign            1
                                                                                 Zero            0
                                                                                 Carry           0
                                                                        Flags
                                                                                 Overflow        0
                                                                                 Parity          1
                                                                                 Auxiliary       0
                                            CODE
 .data
         ary db 26 dup(?)
         arysize= $-ary
         ary_copy db arysize dup(0)
         endmem db 1
 .code
 main PROC
      mov esi,OFFSET ary
      mov edi,OFFSET ary_copy
      mov ax,000FFh
      mov ecx,arysize
      and al,061h
      mov bl,al
      and bl,0CFH       ;masking
      L1:
            mov [esi],al
            mov [edi],bl
            inc esi
            inc edi
            inc al
            inc bl
      LOOP L1
             INVOKE ExitProcess,0
     main ENDP
     END main
                                         MEMORY
                                                  Page 3 of 29
                      COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                ASSIGNMENT#2 (FALL 2023)
            0 1       2    3     4    5     6    7     8    9    A     B    C      D     E    F
  4000      61   62   63   64   65    66   67    68   69    6a   6b   6c    6d     6e    6f   70
  4010      71   72   73   74   75    76   77    78   79    7a   41   42    43     44    45   46
  4020      47   48   49   4a   4b    4c   4d    4e   4f    50   51   52    53     54    55   56
                                            CODE
 .data
         ary db 26 dup(?)
         arysize= $-ary
         ary_copy db arysize dup(0)
         endmem db 1
 .code
         mov esi,OFFSET ary
         mov edi,OFFSET ary_copy
         mov ax,0041h
         mov ecx,arysize
         mov bl,al
         OR bl,00100000b
         L1:
              mov [esi],al
              mov [edi],bl
              inc esi
              inc edi
              inc al
              inc bl
                                                  Page 4 of 29
                      COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                ASSIGNMENT#2 (FALL 2023)
LOOP L1
MEMORY
            0 1       2    3    4    5    6    7     8    9    A    B     C      D          E    F
  4000      41   42   43   44   45   46   47   48   49   4a    4b   4c   4d      4e         4f   50
  4010      51   52   53   54   55   56   57   58   59   5a    61   62   63      64         65   66
  4020      67   68   69   6a   6b   6c   6d   6e   6f   70    71   72   73      74         75   76
6. Update register after each line of code and update Flags after executing the following code
                                                                          AX           a5             93
                                                                          AX           5a             6c
                                                                          AX          00              00
                                                                          AX          ff              ff
                                                                          AX          00              00
                                                                          AX          5a              37
                                                                          Al          3               7
                                                                          AH          5               b
                                                                          AL          6               c
                                                                                      Sign            0
                                                                                      Zero            0
                                                                                      Carry           0
                                                                         Flags
                                                                                      Overflow        0
                                                                                      Parity          1
                                                                                      Auxiliary       0
7. Write a program that finds parity of number given below? HINT: Use XOR and LOOP to find parity
Answer:
.386
                                                Page 5 of 29
                       COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                 ASSIGNMENT#2 (FALL 2023)
.data
  parity dq 0a1b2c3d4e5f67890h ; pe=1
.code
main PROC
  mov esi, offset parity
  mov ecx, type parity
  xor eax, eax
  mov al, [esi]
  inc esi
  dec ecx
  l1:
     mov ah, [esi]
     xor al, ah
     inc esi
  loop l1
INSTRUCTIONS: (Question 8-11) Perform each of the following operations on word size 2’s complement
numbers and update the answer and value of flags after performing the arithmetic. Perform all the steps in the
“calculation” box, only filling the answer will not get any credit.
8. Update flags after arithmetic instruction? Also state which of the following jumps will taken or not taken
           Sign             1                                    Calculation
     Flags Zero            0                1111 1111 1111 1110
                                          + 1111 1100 0111 0000
                                                 Page 6 of 29
                      COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                ASSIGNMENT#2 (FALL 2023)
             Carry    1              ———————————————
                                     1 | 1111 1100 0110 1110 PE=0, ZF=0
             Overflow 0              ^ CV=1 ^PL=1       ^ AC=0
             Parity   1
                                     OV = CVxorPL = 0
                                     also, adding 2 negative numbers and getting a negative answer, so OV=0.
                                     also, answer = -914 > -32,768, so OV=0
9. Update flags after arithmetic instruction? Also state which of the following jumps will taken or not taken
            Sign             1                                     Calculation
            Zero             0               0111 1011 0001 1010
                                           + 0011 0001 0001 0101
            Carry            1
                                      ———————————————
            Overflow         1        0 | 1010 1100 0010 1111 PE=0, ZF=0
      Flags Parity                    ^ CV=0 ^PL=1          ^ AC=0
                             0
                                      OV = CVxorPL = 1
                                      also, subtracting a negative number from a positive number (adding 2
                                      positive numbers) and getting a negative answer, so OV=1
10. Update flags after arithmetic instruction? Also state which of the following jumps will taken or not taken
                                                  Page 7 of 29
                      COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                ASSIGNMENT#2 (FALL 2023)
            Sign              1                                   Calculation
            Zero              0              1111 1011 1100 1101
                                           + 1110 0100 1010 1010
            Carry             1
                                      ———————————————
            Overflow          0       1 | 1110 0000 0111 0111 PE=1, ZF=0
      Flags                           ^ CV=1 ^PL=1          ^ AC=1
            Parity            1
            Auxiliary         1       OV = CVxorPL = 0
                                      also, adding 2 negative numbers and getting a negative answer, so
                                      OV=0.
                                      also answer = -8073 > -32,768, so OV=0
11. Update flags after arithmetic instruction? Also state which of the following jumps will taken or not taken
           Sign              0                                    Calculation
           Zero              0               1111 1010 1011 1101
                             1             + 0110 1000 0100 1010
           Carry
                                      ———————————————
     Flags Overflow          0
                                      1 | 0110 0011 0000 0111 PE=0, ZF=0
           Parity            0        ^ CV=1 ^PL=0          ^ AC=1
           Auxiliary         1
                                      answer = 25,351 < 32,767, so OV=0
12. Update value of ax and cx registers after every iteration. Update any changes to the done to flag
                                                             1            2           3       4       5       6
                                                       CX    5        4           3       2       1       0
                                                       AX   1         2           3       4       5       6
                                                 Page 8 of 29
                       COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                 ASSIGNMENT#2 (FALL 2023)
                          Sign                  0                    Calculation
                          Zero                  1       The final calculation is ECX being
                                                0       decremented to 0
                          Carry
                    Flags                       0
                          Overflow
                          Parity                1
                          Auxiliary             0
                                                            Sign          1                  Calculation
                                                       NOT
                                                          Zero             0             0111 1111
                                            TAKEN     TAKEN                            + 1000 0000
                                                          Carry            1
                                    Ja                ✓                            ——————————
                                    Jg                    Overflow         1
                                            ✓                                      0 | 1111 1111 PE=1, ZF=0
                                                          Parity           1       ^CV=0 ^PL=1 ^AC=0
                                                                           0
                                                    Flags Auxiliary
                                                                                   OV=CVxorPL=1
                                                                                   also, answer=255 > 128, so OV=1
                                               NOT
                                                 Sign      1                                 Calculation
                                       TAKEN TAKEN
                                                            0
                                              ✓ Zero
                                  Jnl                                                     1111 1111 1111 1111
                                                            0                           + 0000 0000 0000 0000
                                  Jnle        ✓ Carry
                                                                                   ———————————————
                                  JL   ✓         Overflow 0                        0 | 1111 1111 1111 1111
                                                 Parity     1                      ^ CV=0 ^PL=1          ^ AC=0
                                           Flags Auxiliary 0
                                                                                   PE=1, ZF=0
                                                      Page 9 of 29
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
          ASSIGNMENT#2 (FALL 2023)
                     NOT
                     Sign        0             Calculation
            TAKEN TAKEN
                                 0
                    ✓Zero
       JNG                                  0000 0000 0010 0000
                                 1        + 0000 0000 0010 0011
       JNGE         ✓Carry           ———————————————
       JGE  ✓        Overflow    0
                                     0 | 0000 0000 0100 0011
                     Parity      0   ^ CV=0 ^PL=0          ^ AC=0
                     Auxiliary   0
              Flags                  PE=0, ZF=0
                                     OV=CVxorPL=0
                                     also, answer=67 < 32767, so OV=0
                 Page 10 of 29
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
          ASSIGNMENT#2 (FALL 2023)
                      NOT
                       Sign       0             Calculation
             TAKEN TAKEN
       JG              Zero       1          0000 0000 0000 0000
                     ✓
                                  0        + 0000 0000 0000 0000
       JNL   ✓         Carry
                                      ———————————————
       JLE             Overflow   0
             ✓                        0 | 0000 0000 0000 0000
                       Parity     1   ^ CV=0 ^PL=0          ^ AC=0
                Flags Auxiliary   0
                                      PE=1, ZF=1
                    NOT
                                      OV=CVxorPL=0
             TAKEN TAKEN
                                      also, 0 < 32,767 and 0>-32768, so
       JL            ✓                OV=0
       JNG   ✓
       JGE   ✓         Sign       0             Calculation
                       Zero       1   same as above
                 Flags            0
                       Carry
                       Overflow   0
                  Page 11 of 29
                     COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                               ASSIGNMENT#2 (FALL 2023)
14. Dry run program gives below update table for each iteration count total number of iterations took by the
    program
                                          CODE
 .data
           data dw    66h,0,045h,8,040h,9,-025h,9,-010h,011h
           swap db    0
 .code
     main PROC
         start:
          mov swap,0                         ;Reset swap flag to no swap
           mov ebx,0                           ;initialize array index to zero
 loop1:
         mov ax,[ebx+data]                   ;load number to ax
         cmp ax,[ebx+data+2]                 ;compare with next number
         jge noswap                         ;no swap if already inorder
              INVOKE ExitProcess,0
      main ENDP
      END main
                                               Page 12 of 29
            COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                      ASSIGNMENT#2 (FALL 2023)
                                                                 COUNT    SWAP
 66   0    45   8    40    9         -25       9     -10   11    0       0
66 0 45 8 40 9 -25 9 -10 11 1 0
66 45 0 8 40 9 -25 9 -10 11 2 1
66 45 8 0 40 9 -25 9 -10 11 3 1
66 45 8 40 0 9 -25 9 -10 11 4 1
66 45 8 40 9 0 -25 9 -10 11 5 1
66    45   8    40    9    0         -25       9     -10   11    6       1
                                                                         (carrying
                                                                         from above)
66 45 8 40 9 0 9 -25 -10 11 7 1
66 45 8 40 9 0 9 -10 -25 11 8 1
66    45   8    40    9    0          9        -10   11    -25   9       0
                                                                         (after last
                                                                         switch, swap
                                                                         resets to 0 if
                                                                         it was 1
                                                                         before)
66 45 8 40 9 0 9 -10 11 -25 10 0
66 45 8 40 9 0 9 -10 11 -25 11 0
66 45 40 8 9 0 9 -10 11 -25 12 1
66 45 40 9 8 0 9 -10 11 -25 13 1
66    45   40   9     8    0          9        -10   11    -25   14      1
                                                                         (carrying
                                                                         from above)
66 45 40 9 8 9 0 -10 11 -25 15 1
66    45   40   9     8    9          0        -10   11    -25   16      1
                                                                         (carrying
                                                                         from above)
66 45 40 9 8 9 0 11 -10 -25 17 1
66    45   40   9     8    9          0        11    -10   -25   18      0
                                                                         (after last
                                                                         switch, swap
                                                                         resets to 0 if
                               Page 13 of 29
               COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                         ASSIGNMENT#2 (FALL 2023)
                                                                                       it was 1
                                                                                       before)
66 45 40 9 8 9 0 11 -10 -25 19 0
66 45 40 9 8 9 0 11 -10 -25 20 0
66 45 40 9 8 9 0 11 -10 -25 21 0
66 45 40 9 8 9 0 11 -10 -25 22 0
66 45 40 9 9 8 0 11 -10 -25 23 1
66   45    40         9       9        8            0          11    -10    -25   24   1
                                                                                       (carrying
                                                                                       from above)
66 45 40 9 9 8 11 0 -10 -25 25 1
66   45    40         9       9        8           11          0     -10    -25   26   1
                                                                                       (carrying
                                                                                       from above)
66   45    40         9       9        8           11          0     -10    -25   27   0
                                                                                       (after last
                                                                                       switch, swap
                                                                                       resets to 0 if
                                                                                       it was 1
                                                                                       before)
66 45 40 9 9 8 11 0 -10 -25 28 0
66 45 40 9 9 8 11 0 -10 -25 29 0
66 45 40 9 9 8 11 0 -10 -25 30 0
66 45 40 9 9 8 11 0 -10 -25 31 0
66 45 40 9 9 8 11 0 -10 -25 32 0
66 45 40 9 9 11 8 0 -10 -25 33 1
66   45   40      9       9       11           8           0        -10    -25    34   1
                                                                                       (carrying
                                                                                       from above)
66   45   40      9       9       11           8           0        -10    -25    35   1
                                                                                       (carrying
                                                                                       from above)
66   45   40      9       9       11           8           0        -10    -25    36   0
                                                                                       (after last
                                                                                       switch, swap
                                                                                       resets to 0 if
                                                                                       it was 1
                                                                                       before)
                                           Page 14 of 29
               COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                         ASSIGNMENT#2 (FALL 2023)
66 45 40 9 9 11 8 0 -10 -25 37 0
66 45 40 9 9 11 8 0 -10 -25 38 0
66 45 40 9 9 11 8 0 -10 -25 39 0
66   45   40      9    9     11       8           0   -10   -25   40   0
66   45   40      9    11    9        8           0   -10   -25   41   1
66   45   40      9    11    9        8           0   -10   -25   42   1
                                                                       (carrying
                                                                       from above)
66   45   40      9    11    9        8           0   -10   -25   43   1
                                                                       (carrying
                                                                       from above)
66   45   40      9    11    9        8           0   -10   -25   44   1
                                                                       (carrying
                                                                       from above)
66   45   40      9    11    9        8           0   -10   -25   45   0
                                                                       (after last
                                                                       switch, swap
                                                                       resets to 0 if
                                                                       it was 1
                                                                       before)
66   45   40      9    11    9        8           0   -10   -25   46   0
66   45   40      9    11    9        8           0   -10   -25   47   0
66   45   40      9    11    9        8           0   -10   -25   48   0
66   45   40      11   9     9        8           0   -10   -25   49   1
66   45   40      11   9     9        8           0   -10   -25   50   1
66   45   40      11   9     9        8           0   -10   -25   51   1
66   45   40      11   9     9        8           0   -10   -25   52   1
66   45   40      11   9     9        8           0   -10   -25   53   1
66   45   40      11   9     9        8           0   -10   -25   54   0
66   45   40      11   9     9        8           0   -10   -25   55   0
66   45   40      11   9     9        8           0   -10   -25   56   0
66   45   40      11   9     9        8           0   -10   -25   57   0
66   45   40      11   9     9        8           0   -10   -25   58   0
66   45   40      11   9     9        8           0   -10   -25   59   0
66   45   40      11   9     9        8           0   -10   -25   60   0
66   45   40      11   9     9        8           0   -10   -25   61   0
66   45   40      11   9     9        8           0   -10   -25   62   0
66   45   40      11   9     9        8           0   -10   -25   63   0
                                  Page 15 of 29
                      COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                ASSIGNMENT#2 (FALL 2023)
15. You are working on the development of an encryption process for a secure communication protocol for a
    highly sensitive application. As part of the encryption process, the system needs to perform a series of
    bitwise operations on the provided data. Your task is to design and implement an assembly program that
    can do these series of transformations on a 32-bit integer number mDATA.
Suppose an 16-bit number mFLAGS, you have to transform the data by applying the series of following
4-bitwise operations on mDATA according to the specific bit value in mFLAGS as defined in the operation
description provided below:
Note: Not allowed to use any predefined rotate instruction like (ROL,ROR etc.)
Note: Not allowed to use any predefined rotate instruction like (ROL,ROR etc.)
                                                 Page 16 of 29
                        COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                  ASSIGNMENT#2 (FALL 2023)
31 15
You must provide your permutation table in a char array in the data section.
                                For Example:
                                the above permutation table can be represented in char array as “160709 … 15”,
                                where the bit positions are in ascending order,
                                i.e., 16 is the new position for bit 0,
                                and 07 is the new position for bit 1,
                                and so on.
Note: You have to generate 16-bit number mFLAGS using your Roll Number excluding the character and the
first digit. For example if the number is 22i-9986 the mFLAGS must be 29986.
Answer:
.386
.model flat, stdcall
.stack 4096
.data
   mData dd 1378cef6h
   separate1 db 0
   mFLAGS dw 20899
   separate2 db 0
   permPosition db 14, 15, 29, 3, 20, 4, 0, 6, 23, 5, 25, 7, 10, 11, 8, 28, 1, 24, 21, 9, 30, 16, 2, 18, 22, 17, 31, 26,
13, 12, 27, 19
.code
main Proc
jnc step2
  mov ebx, 0
  mov edx, mDATA
  shld edx, ebx, cl
  or edx, ebx
  mov mDATA, edx
step2:
                                                     Page 17 of 29
                  COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                            ASSIGNMENT#2 (FALL 2023)
jnc step3
step3:
jnc step4
step4:
jnc endCode
  mov ecx, 32
  mov esi, 3
  xor eax, eax
  xor ebx, ebx
  xor edx, edx
  l1:
     push eax
       test ax, 0FFh
       jz doNotDecrementESI
       mov bl, 8
       div bl
                                  Page 18 of 29
                 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                           ASSIGNMENT#2 (FALL 2023)
  test ah, ah
  jnz doNotDecrementESI
dec esi
  doNotDecrementESI:
pop eax
test bl, dl
jp replacing0
jnp replacing1
replacing0:
  test bh, dh
  jp replacing0with0
  jnp replacing0with1
replacing1:
  test bh, dh
  jp replacing1with0
  jnp replacing1with1
                                        Page 19 of 29
                   COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                             ASSIGNMENT#2 (FALL 2023)
     replacing0with1:
     replacing1with0:
       xor byte ptr [mData + edi], dh
     replacing0with0:
     replacing1with1:
     inc eax
   loop l1
endCode:
main ENDP
END main
                                        Page 20 of 29
                         COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                   ASSIGNMENT#2 (FALL 2023)
16. Dry run program gives below update table for each iteration count total number of iterations took by the
    program
                                                  CODE
 .data
     Multiplicand db 0                     ; Consider Assigned Number Digit
                                                 ; A0
              Multiplier db 9                   ; Consider Assigned Number Digit A3
Result db 0
.code
            mov ax,0
           mov cl,4
         mov al,multiplicand
         mov bl,multiplier
     checkbit:
         shr bl,1
         jnc skip
         add result,al
     skip:
         shl al,1
         loop checkbit
                                 al                           bl
     CF                     multiplicand                 Multiplier        CF                    result
 0                0     0             0    0         0    1        0   0   1         0       0       0      0
                                                                                     (carr   ying    from   above)
 0                0     0             0    0         0    0        1   0   0          0      0       0      0
                                                                                     (carr   ying    from   above)
0 0 0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0
17. Consider the following code and fill given registers and memory accordingly after each step?
    Note: Considering it as a 16 bit architecture
                                                  CODE
          ;   NOTE    ;ADC is add through carry
                                                   Page 21 of 29
                    COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                              ASSIGNMENT#2 (FALL 2023)
.data
        multiplicand dd 383h          ;Hexa of assigned word
        multiplier dw 005AAH
        result dd 0
.code
           mov ax,0
          mov ecx,16                                ;initialize bit count to
16
        mov dx, multiplier                         ;initialize bit mask
checkbit:
        shr dx,1
        jnc noadd                            ;skip addition if no carry
10 02d5 0 0 0 0 - 0 0 0706 0 0
                                        Page 22 of 29
                      COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                ASSIGNMENT#2 (FALL 2023)
                                               Page 23 of 29
                         COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                   ASSIGNMENT#2 (FALL 2023)
.code
main PROC
       mov eax,0
       mov ecx,16
       mov dx, multiplier
         checkbit:
           shr dx,1
           jnc noadd
19. Perform unsigned binary multiplication using following given flow chart?
      NOTE: Your computer width is 8-bit, Multiplicand is (1000)2 of the assigned number and Multiplier is (1100011)2 of
     the assigned number
                                                      Page 24 of 29
                       COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                 ASSIGNMENT#2 (FALL 2023)
0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 0 Shift
0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 Shift
0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 Shift
0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 Shift
0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 0 0 0 Shift
0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 Shift
0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 Shift
0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 Shift
                                                    Page 25 of 29
                   COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                             ASSIGNMENT#2 (FALL 2023)
AX Q Q-1 M Count
00 0110 0011 - 6
                                    Page 26 of 29
                   COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                             ASSIGNMENT#2 (FALL 2023)
00 0110 0011 - 1
                                   Page 27 of 29
                       COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                 ASSIGNMENT#2 (FALL 2023)
Answer:
AX Q M Count
                                                   Page 28 of 29
            COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                      ASSIGNMENT#2 (FALL 2023)
                              Page 29 of 29
                       COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
❖ You are required to solve the assignment on this document and submit it on GCR (SoftCopy)
❖ You have to use your Roll No and consider it as decimal for the unique declaration purpose.
❖ Exclude the characters and the first two digits from your Roll number.
FOR EXAMPLE: If your number is 22i-7823, use 7823, where A0 assign the first digit of it.
                                             Assign Digit 0   Assign Digit   Assign Digit 2         Assign Digit 3
                                                                   1
          Short for Assigned Digit                A0               A1             A2                     A3
                                                     Page 1 of 3
                       COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                                  Page 2 of 3
                 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                             Page 3 of 3
                        COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                  ASSIGNMENT#2 (FALL 2023)
❖ You are required to solve the assignment on this document and submit it on GCR (SoftCopy)
❖ You have to use your Roll No and consider it as decimal for the unique declaration purpose.
❖ Exclude the characters and the first two digits from your Roll number.
FOR EXAMPLE: If your number is 22i-7823, use 7823, where A0 assign the first digit of it.
                                              Assign Digit 0    Assign Digit      Assign Digit 2         Assign Digit 3
                                                                     1
          Short for Assigned Digit                 A0               A1                 A2                     A3
   Write Assigned Number Digit By Digit          0       8         9           9
                                              Assigned Byte 0     Assigned Byte 1
          Short for Assigned BYTE                   B0                  B1
             Byte in DECIMAL                        08                   99
      Convert byte to HEX    B0H, B1H                8                   63
     Convert byte OCTAL      B0Q, B1Q               10                  143
      Convert byte BINARY B0B, B1B                 1000              1100011
                                                          Assigned WORD
         Short for Assigned WORD                                 W
           WORD in DECIMAL(W)                                  0899
        Convert WORD to HEX (WH)                                383
        Convert WORD OCTAL (WQ)                                1603
        Convert byte BINARY (WB)                            1110000011
   Assigned double WORD in HEXA (DH)                        78237823H
EXAMPLE: Name is HAMZA DAUD
         ❖ If your name starts with MUHAMMAD kindly use your second name
                                                     Page 1 of 29
                        COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                  ASSIGNMENT#2 (FALL 2023)
  Short for
                   C0            C1             C2               C3          C4            C5          C6
 CHARACTER
  YOUR NAME
  CHARACTER
     BY            A             Y              E                S           H             A            E
  CHARACTER
1. Write equivalent Assembly instructions for the C++ code given below and also explain C++ code in given
   space?
                                                  Page 2 of 29
                      COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                ASSIGNMENT#2 (FALL 2023)
   NOTE: AND performs a Boolean(bitwise) AND operation between each pair of matching bits in two
   operands and place result in the destination. AND instruction always clear overflow and carry flags. It
   modifies Sign, Zero and Parity flags.
                                                                                 Sign            1
                                                                                 Zero            0
                                                                                 Carry           0
                                                                        Flags
                                                                                 Overflow        0
                                                                                 Parity          1
                                                                                 Auxiliary       0
                                            CODE
 .data
         ary db 26 dup(?)
         arysize= $-ary
         ary_copy db arysize dup(0)
         endmem db 1
 .code
 main PROC
      mov esi,OFFSET ary
      mov edi,OFFSET ary_copy
      mov ax,000FFh
      mov ecx,arysize
      and al,061h
      mov bl,al
      and bl,0CFH       ;masking
      L1:
            mov [esi],al
            mov [edi],bl
            inc esi
            inc edi
            inc al
            inc bl
      LOOP L1
             INVOKE ExitProcess,0
     main ENDP
     END main
                                         MEMORY
                                                  Page 3 of 29
                      COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                ASSIGNMENT#2 (FALL 2023)
            0 1       2    3     4    5     6    7     8    9    A     B    C      D     E    F
  4000      61   62   63   64   65    66   67    68   69    6a   6b   6c    6d     6e    6f   70
  4010      71   72   73   74   75    76   77    78   79    7a   41   42    43     44    45   46
  4020      47   48   49   4a   4b    4c   4d    4e   4f    50   51   52    53     54    55   56
                                            CODE
 .data
         ary db 26 dup(?)
         arysize= $-ary
         ary_copy db arysize dup(0)
         endmem db 1
 .code
         mov esi,OFFSET ary
         mov edi,OFFSET ary_copy
         mov ax,0041h
         mov ecx,arysize
         mov bl,al
         OR bl,00100000b
         L1:
              mov [esi],al
              mov [edi],bl
              inc esi
              inc edi
              inc al
              inc bl
                                                  Page 4 of 29
                      COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                ASSIGNMENT#2 (FALL 2023)
LOOP L1
MEMORY
            0 1       2    3    4    5    6    7     8    9    A    B     C      D          E    F
  4000      41   42   43   44   45   46   47   48   49   4a    4b   4c   4d      4e         4f   50
  4010      51   52   53   54   55   56   57   58   59   5a    61   62   63      64         65   66
  4020      67   68   69   6a   6b   6c   6d   6e   6f   70    71   72   73      74         75   76
6. Update register after each line of code and update Flags after executing the following code
                                                                          AX           a5             93
                                                                          AX           5a             6c
                                                                          AX          00              00
                                                                          AX          ff              ff
                                                                          AX          00              00
                                                                          AX          5a              37
                                                                          Al          3               7
                                                                          AH          5               b
                                                                          AL          6               c
                                                                                      Sign            0
                                                                                      Zero            0
                                                                                      Carry           0
                                                                         Flags
                                                                                      Overflow        0
                                                                                      Parity          1
                                                                                      Auxiliary       0
7. Write a program that finds parity of number given below? HINT: Use XOR and LOOP to find parity
Answer:
.386
                                                Page 5 of 29
                       COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                 ASSIGNMENT#2 (FALL 2023)
.data
  parity dq 0a1b2c3d4e5f67890h ; pe=1
.code
main PROC
  mov esi, offset parity
  mov ecx, type parity
  xor eax, eax
  mov al, [esi]
  inc esi
  dec ecx
  l1:
     mov ah, [esi]
     xor al, ah
     inc esi
  loop l1
INSTRUCTIONS: (Question 8-11) Perform each of the following operations on word size 2’s complement
numbers and update the answer and value of flags after performing the arithmetic. Perform all the steps in the
“calculation” box, only filling the answer will not get any credit.
8. Update flags after arithmetic instruction? Also state which of the following jumps will taken or not taken
           Sign             1                                    Calculation
     Flags Zero            0                1111 1111 1111 1110
                                          + 1111 1100 0111 0000
                                                 Page 6 of 29
                      COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                ASSIGNMENT#2 (FALL 2023)
             Carry    1              ———————————————
                                     1 | 1111 1100 0110 1110 PE=0, ZF=0
             Overflow 0              ^ CV=1 ^PL=1       ^ AC=0
             Parity   1
                                     OV = CVxorPL = 0
                                     also, adding 2 negative numbers and getting a negative answer, so OV=0.
                                     also, answer = -914 > -32,768, so OV=0
9. Update flags after arithmetic instruction? Also state which of the following jumps will taken or not taken
            Sign             1                                     Calculation
            Zero             0               0111 1011 0001 1010
                                           + 0011 0001 0001 0101
            Carry            1
                                      ———————————————
            Overflow         1        0 | 1010 1100 0010 1111 PE=0, ZF=0
      Flags Parity                    ^ CV=0 ^PL=1          ^ AC=0
                             0
                                      OV = CVxorPL = 1
                                      also, subtracting a negative number from a positive number (adding 2
                                      positive numbers) and getting a negative answer, so OV=1
10. Update flags after arithmetic instruction? Also state which of the following jumps will taken or not taken
                                                  Page 7 of 29
                      COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                ASSIGNMENT#2 (FALL 2023)
            Sign              1                                   Calculation
            Zero              0              1111 1011 1100 1101
                                           + 1110 0100 1010 1010
            Carry             1
                                      ———————————————
            Overflow          0       1 | 1110 0000 0111 0111 PE=1, ZF=0
      Flags                           ^ CV=1 ^PL=1          ^ AC=1
            Parity            1
            Auxiliary         1       OV = CVxorPL = 0
                                      also, adding 2 negative numbers and getting a negative answer, so
                                      OV=0.
                                      also answer = -8073 > -32,768, so OV=0
11. Update flags after arithmetic instruction? Also state which of the following jumps will taken or not taken
           Sign              0                                    Calculation
           Zero              0               1111 1010 1011 1101
                             1             + 0110 1000 0100 1010
           Carry
                                      ———————————————
     Flags Overflow          0
                                      1 | 0110 0011 0000 0111 PE=0, ZF=0
           Parity            0        ^ CV=1 ^PL=0          ^ AC=1
           Auxiliary         1
                                      answer = 25,351 < 32,767, so OV=0
12. Update value of ax and cx registers after every iteration. Update any changes to the done to flag
                                                             1            2           3       4       5       6
                                                       CX    5        4           3       2       1       0
                                                       AX   1         2           3       4       5       6
                                                 Page 8 of 29
                       COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                 ASSIGNMENT#2 (FALL 2023)
                          Sign                  0                    Calculation
                          Zero                  1       The final calculation is ECX being
                                                0       decremented to 0
                          Carry
                    Flags                       0
                          Overflow
                          Parity                1
                          Auxiliary             0
                                                            Sign          1                  Calculation
                                                       NOT
                                                          Zero             0             0111 1111
                                            TAKEN     TAKEN                            + 1000 0000
                                                          Carry            1
                                    Ja                ✓                            ——————————
                                    Jg                    Overflow         1
                                            ✓                                      0 | 1111 1111 PE=1, ZF=0
                                                          Parity           1       ^CV=0 ^PL=1 ^AC=0
                                                                           0
                                                    Flags Auxiliary
                                                                                   OV=CVxorPL=1
                                                                                   also, answer=255 > 128, so OV=1
                                               NOT
                                                 Sign      1                                 Calculation
                                       TAKEN TAKEN
                                                            0
                                              ✓ Zero
                                  Jnl                                                     1111 1111 1111 1111
                                                            0                           + 0000 0000 0000 0000
                                  Jnle        ✓ Carry
                                                                                   ———————————————
                                  JL   ✓         Overflow 0                        0 | 1111 1111 1111 1111
                                                 Parity     1                      ^ CV=0 ^PL=1          ^ AC=0
                                           Flags Auxiliary 0
                                                                                   PE=1, ZF=0
                                                      Page 9 of 29
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
          ASSIGNMENT#2 (FALL 2023)
                     NOT
                     Sign        0             Calculation
            TAKEN TAKEN
                                 0
                    ✓Zero
       JNG                                  0000 0000 0010 0000
                                 1        + 0000 0000 0010 0011
       JNGE         ✓Carry           ———————————————
       JGE  ✓        Overflow    0
                                     0 | 0000 0000 0100 0011
                     Parity      0   ^ CV=0 ^PL=0          ^ AC=0
                     Auxiliary   0
              Flags                  PE=0, ZF=0
                                     OV=CVxorPL=0
                                     also, answer=67 < 32767, so OV=0
                 Page 10 of 29
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
          ASSIGNMENT#2 (FALL 2023)
                      NOT
                       Sign       0             Calculation
             TAKEN TAKEN
       JG              Zero       1          0000 0000 0000 0000
                     ✓
                                  0        + 0000 0000 0000 0000
       JNL   ✓         Carry
                                      ———————————————
       JLE             Overflow   0
             ✓                        0 | 0000 0000 0000 0000
                       Parity     1   ^ CV=0 ^PL=0          ^ AC=0
                Flags Auxiliary   0
                                      PE=1, ZF=1
                    NOT
                                      OV=CVxorPL=0
             TAKEN TAKEN
                                      also, 0 < 32,767 and 0>-32768, so
       JL            ✓                OV=0
       JNG   ✓
       JGE   ✓         Sign       0             Calculation
                       Zero       1   same as above
                 Flags            0
                       Carry
                       Overflow   0
                  Page 11 of 29
                     COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                               ASSIGNMENT#2 (FALL 2023)
14. Dry run program gives below update table for each iteration count total number of iterations took by the
    program
                                          CODE
 .data
           data dw    66h,0,045h,8,040h,9,-025h,9,-010h,011h
           swap db    0
 .code
     main PROC
         start:
          mov swap,0                         ;Reset swap flag to no swap
           mov ebx,0                           ;initialize array index to zero
 loop1:
         mov ax,[ebx+data]                   ;load number to ax
         cmp ax,[ebx+data+2]                 ;compare with next number
         jge noswap                         ;no swap if already inorder
              INVOKE ExitProcess,0
      main ENDP
      END main
                                               Page 12 of 29
            COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                      ASSIGNMENT#2 (FALL 2023)
                                                                 COUNT    SWAP
 66   0    45   8    40    9         -25       9     -10   11    0       0
66 0 45 8 40 9 -25 9 -10 11 1 0
66 45 0 8 40 9 -25 9 -10 11 2 1
66 45 8 0 40 9 -25 9 -10 11 3 1
66 45 8 40 0 9 -25 9 -10 11 4 1
66 45 8 40 9 0 -25 9 -10 11 5 1
66    45   8    40    9    0         -25       9     -10   11    6       1
                                                                         (carrying
                                                                         from above)
66 45 8 40 9 0 9 -25 -10 11 7 1
66 45 8 40 9 0 9 -10 -25 11 8 1
66    45   8    40    9    0          9        -10   11    -25   9       0
                                                                         (after last
                                                                         switch, swap
                                                                         resets to 0 if
                                                                         it was 1
                                                                         before)
66 45 8 40 9 0 9 -10 11 -25 10 0
66 45 8 40 9 0 9 -10 11 -25 11 0
66 45 40 8 9 0 9 -10 11 -25 12 1
66 45 40 9 8 0 9 -10 11 -25 13 1
66    45   40   9     8    0          9        -10   11    -25   14      1
                                                                         (carrying
                                                                         from above)
66 45 40 9 8 9 0 -10 11 -25 15 1
66    45   40   9     8    9          0        -10   11    -25   16      1
                                                                         (carrying
                                                                         from above)
66 45 40 9 8 9 0 11 -10 -25 17 1
66    45   40   9     8    9          0        11    -10   -25   18      0
                                                                         (after last
                                                                         switch, swap
                                                                         resets to 0 if
                               Page 13 of 29
               COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                         ASSIGNMENT#2 (FALL 2023)
                                                                                       it was 1
                                                                                       before)
66 45 40 9 8 9 0 11 -10 -25 19 0
66 45 40 9 8 9 0 11 -10 -25 20 0
66 45 40 9 8 9 0 11 -10 -25 21 0
66 45 40 9 8 9 0 11 -10 -25 22 0
66 45 40 9 9 8 0 11 -10 -25 23 1
66   45    40         9       9        8            0          11    -10    -25   24   1
                                                                                       (carrying
                                                                                       from above)
66 45 40 9 9 8 11 0 -10 -25 25 1
66   45    40         9       9        8           11          0     -10    -25   26   1
                                                                                       (carrying
                                                                                       from above)
66   45    40         9       9        8           11          0     -10    -25   27   0
                                                                                       (after last
                                                                                       switch, swap
                                                                                       resets to 0 if
                                                                                       it was 1
                                                                                       before)
66 45 40 9 9 8 11 0 -10 -25 28 0
66 45 40 9 9 8 11 0 -10 -25 29 0
66 45 40 9 9 8 11 0 -10 -25 30 0
66 45 40 9 9 8 11 0 -10 -25 31 0
66 45 40 9 9 8 11 0 -10 -25 32 0
66 45 40 9 9 11 8 0 -10 -25 33 1
66   45   40      9       9       11           8           0        -10    -25    34   1
                                                                                       (carrying
                                                                                       from above)
66   45   40      9       9       11           8           0        -10    -25    35   1
                                                                                       (carrying
                                                                                       from above)
66   45   40      9       9       11           8           0        -10    -25    36   0
                                                                                       (after last
                                                                                       switch, swap
                                                                                       resets to 0 if
                                                                                       it was 1
                                                                                       before)
                                           Page 14 of 29
               COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                         ASSIGNMENT#2 (FALL 2023)
66 45 40 9 9 11 8 0 -10 -25 37 0
66 45 40 9 9 11 8 0 -10 -25 38 0
66 45 40 9 9 11 8 0 -10 -25 39 0
66   45   40      9    9     11       8           0   -10   -25   40   0
66   45   40      9    11    9        8           0   -10   -25   41   1
66   45   40      9    11    9        8           0   -10   -25   42   1
                                                                       (carrying
                                                                       from above)
66   45   40      9    11    9        8           0   -10   -25   43   1
                                                                       (carrying
                                                                       from above)
66   45   40      9    11    9        8           0   -10   -25   44   1
                                                                       (carrying
                                                                       from above)
66   45   40      9    11    9        8           0   -10   -25   45   0
                                                                       (after last
                                                                       switch, swap
                                                                       resets to 0 if
                                                                       it was 1
                                                                       before)
66   45   40      9    11    9        8           0   -10   -25   46   0
66   45   40      9    11    9        8           0   -10   -25   47   0
66   45   40      9    11    9        8           0   -10   -25   48   0
66   45   40      11   9     9        8           0   -10   -25   49   1
66   45   40      11   9     9        8           0   -10   -25   50   1
66   45   40      11   9     9        8           0   -10   -25   51   1
66   45   40      11   9     9        8           0   -10   -25   52   1
66   45   40      11   9     9        8           0   -10   -25   53   1
66   45   40      11   9     9        8           0   -10   -25   54   0
66   45   40      11   9     9        8           0   -10   -25   55   0
66   45   40      11   9     9        8           0   -10   -25   56   0
66   45   40      11   9     9        8           0   -10   -25   57   0
66   45   40      11   9     9        8           0   -10   -25   58   0
66   45   40      11   9     9        8           0   -10   -25   59   0
66   45   40      11   9     9        8           0   -10   -25   60   0
66   45   40      11   9     9        8           0   -10   -25   61   0
66   45   40      11   9     9        8           0   -10   -25   62   0
66   45   40      11   9     9        8           0   -10   -25   63   0
                                  Page 15 of 29
                      COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                ASSIGNMENT#2 (FALL 2023)
15. You are working on the development of an encryption process for a secure communication protocol for a
    highly sensitive application. As part of the encryption process, the system needs to perform a series of
    bitwise operations on the provided data. Your task is to design and implement an assembly program that
    can do these series of transformations on a 32-bit integer number mDATA.
Suppose an 16-bit number mFLAGS, you have to transform the data by applying the series of following
4-bitwise operations on mDATA according to the specific bit value in mFLAGS as defined in the operation
description provided below:
Note: Not allowed to use any predefined rotate instruction like (ROL,ROR etc.)
Note: Not allowed to use any predefined rotate instruction like (ROL,ROR etc.)
                                                 Page 16 of 29
                        COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                  ASSIGNMENT#2 (FALL 2023)
31 15
You must provide your permutation table in a char array in the data section.
                                For Example:
                                the above permutation table can be represented in char array as “160709 … 15”,
                                where the bit positions are in ascending order,
                                i.e., 16 is the new position for bit 0,
                                and 07 is the new position for bit 1,
                                and so on.
Note: You have to generate 16-bit number mFLAGS using your Roll Number excluding the character and the
first digit. For example if the number is 22i-9986 the mFLAGS must be 29986.
Answer:
.386
.model flat, stdcall
.stack 4096
.data
   mData dd 1378cef6h
   separate1 db 0
   mFLAGS dw 20899
   separate2 db 0
   permPosition db 14, 15, 29, 3, 20, 4, 0, 6, 23, 5, 25, 7, 10, 11, 8, 28, 1, 24, 21, 9, 30, 16, 2, 18, 22, 17, 31, 26,
13, 12, 27, 19
.code
main Proc
jnc step2
  mov ebx, 0
  mov edx, mDATA
  shld edx, ebx, cl
  or edx, ebx
  mov mDATA, edx
step2:
                                                     Page 17 of 29
                  COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                            ASSIGNMENT#2 (FALL 2023)
jnc step3
step3:
jnc step4
step4:
jnc endCode
  mov ecx, 32
  mov esi, 3
  xor eax, eax
  xor ebx, ebx
  xor edx, edx
  l1:
     push eax
       test ax, 0FFh
       jz doNotDecrementESI
       mov bl, 8
       div bl
                                  Page 18 of 29
                 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                           ASSIGNMENT#2 (FALL 2023)
  test ah, ah
  jnz doNotDecrementESI
dec esi
  doNotDecrementESI:
pop eax
test bl, dl
jp replacing0
jnp replacing1
replacing0:
  test bh, dh
  jp replacing0with0
  jnp replacing0with1
replacing1:
  test bh, dh
  jp replacing1with0
  jnp replacing1with1
                                        Page 19 of 29
                   COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                             ASSIGNMENT#2 (FALL 2023)
     replacing0with1:
     replacing1with0:
       xor byte ptr [mData + edi], dh
     replacing0with0:
     replacing1with1:
     inc eax
   loop l1
endCode:
main ENDP
END main
                                        Page 20 of 29
                         COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                   ASSIGNMENT#2 (FALL 2023)
16. Dry run program gives below update table for each iteration count total number of iterations took by the
    program
                                                  CODE
 .data
     Multiplicand db 0                     ; Consider Assigned Number Digit
                                                 ; A0
              Multiplier db 9                   ; Consider Assigned Number Digit A3
Result db 0
.code
            mov ax,0
           mov cl,4
         mov al,multiplicand
         mov bl,multiplier
     checkbit:
         shr bl,1
         jnc skip
         add result,al
     skip:
         shl al,1
         loop checkbit
                                 al                           bl
     CF                     multiplicand                 Multiplier        CF                    result
 0                0     0             0    0         0    1        0   0   1         0       0       0      0
                                                                                     (carr   ying    from   above)
 0                0     0             0    0         0    0        1   0   0          0      0       0      0
                                                                                     (carr   ying    from   above)
0 0 0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0
17. Consider the following code and fill given registers and memory accordingly after each step?
    Note: Considering it as a 16 bit architecture
                                                  CODE
          ;   NOTE    ;ADC is add through carry
                                                   Page 21 of 29
                    COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                              ASSIGNMENT#2 (FALL 2023)
.data
        multiplicand dd 383h          ;Hexa of assigned word
        multiplier dw 005AAH
        result dd 0
.code
           mov ax,0
          mov ecx,16                                ;initialize bit count to
16
        mov dx, multiplier                         ;initialize bit mask
checkbit:
        shr dx,1
        jnc noadd                            ;skip addition if no carry
10 02d5 0 0 0 0 - 0 0 0706 0 0
                                        Page 22 of 29
                      COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                ASSIGNMENT#2 (FALL 2023)
                                               Page 23 of 29
                         COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                   ASSIGNMENT#2 (FALL 2023)
.code
main PROC
       mov eax,0
       mov ecx,16
       mov dx, multiplier
         checkbit:
           shr dx,1
           jnc noadd
19. Perform unsigned binary multiplication using following given flow chart?
      NOTE: Your computer width is 8-bit, Multiplicand is (1000)2 of the assigned number and Multiplier is (1100011)2 of
     the assigned number
                                                      Page 24 of 29
                       COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                 ASSIGNMENT#2 (FALL 2023)
0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 0 Shift
0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 Shift
0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 Shift
0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 Shift
0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 0 0 0 Shift
0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 Shift
0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 Shift
0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 Shift
                                                    Page 25 of 29
                   COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                             ASSIGNMENT#2 (FALL 2023)
AX Q Q-1 M Count
00 0110 0011 - 6
                                    Page 26 of 29
                   COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                             ASSIGNMENT#2 (FALL 2023)
00 0110 0011 - 1
                                   Page 27 of 29
                       COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                                 ASSIGNMENT#2 (FALL 2023)
Answer:
AX Q M Count
                                                   Page 28 of 29
            COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
                      ASSIGNMENT#2 (FALL 2023)
Page 29 of 29