Advertisement
Guest User

Problem a

a guest
Oct 31st, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;a. Given the words A and B, A = 1010111001101100b and B = 0111110100100110b, ;obtain the word C in the following way:
  2. ;bit 0 and 2 of word C are the same as the bits 0 and 1 from word A;
  3. ;bit 1 of word C is the same as bit 1 of word B
  4. ;bits 3-5 of word C take the binary value 010
  5. ;bits 6-9 of word C are the same as bits 11-14 from word A
  6. ;bits 10-15 of word C take the invert value of bits 3-8 of word B
  7. assume cs:code, ds:data
  8. data segment
  9.   a dw 1010111001101100b
  10.   b dw 0111110100100110b
  11.   c dw ?
  12. data ends
  13.  
  14. code segment
  15. start:
  16.   mov ax, data ; we load in ds the address of data segment
  17.   mov ds, ax
  18.  
  19.   mov bx, 0
  20.   mov ax, a
  21.   and ax, 0000000000000001b
  22.   or bx, ax
  23.  
  24.   mov ax, a
  25.   and ax, 0000000000000010b
  26.   mov cl, 1
  27.   rol ax, cl
  28.   or bx, ax
  29.  
  30.   mov ax, b
  31.   and ax, 0000000000000010b
  32.   or bx, ax
  33.  
  34.   mov ax, 0000000000010000b
  35.   or bx, ax
  36.  
  37.   mov ax, a
  38.   and ax, 0111100000000000b
  39.   mov cl, 5
  40.   ror ax, cl
  41.   or bx, ax
  42.  
  43.   mov ax, b
  44.   and ax, 0000000111111000b
  45.   xor ax, 0000000111111000b
  46.   mov cl, 7
  47.   rol ax, cl
  48.   or bx, ax
  49.   mov c, bx
  50.  
  51.   mov ax, 4c00h
  52.   int 21h
  53. code ends
  54. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement