home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH06 / PGM6_3.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-10-10  |  1.5 KB  |  100 lines

  1. ; Logical Operations
  2. ; This program demonstrates the AND, OR, XOR, and NOT instructions
  3.  
  4.         .386            ;So we can use extended registers
  5.         option    segment:use16    ; and addressing modes.
  6.  
  7. dseg        segment    para public 'data'
  8.  
  9.  
  10. ; Some variables we can use:
  11.  
  12. j        word    0FF00h
  13. k        word    0FFF0h
  14. l        word    ?
  15.  
  16. c1        byte    'A'
  17. c2        byte    'a'
  18.  
  19. LowerMask    byte    20h
  20.  
  21. dseg        ends
  22.  
  23.  
  24. cseg        segment    para public 'code'
  25.         assume    cs:cseg, ds:dseg
  26.  
  27. Main        proc
  28.         mov    ax, dseg
  29.         mov    ds, ax
  30.         mov    es, ax
  31.  
  32. ; Compute L := J and K (bitwise AND operation):
  33.  
  34.         mov    ax, J
  35.         and    ax, K
  36.         mov    L, ax
  37.  
  38. ; Compute L := J or K (bitwise OR operation):
  39.  
  40.         mov    ax, J
  41.         or    ax, K
  42.         mov    L, ax
  43.  
  44. ; Compute L := J xor K (bitwise XOR operation):
  45.  
  46.         mov    ax, J
  47.         xor    ax, K
  48.         mov    L, ax
  49.  
  50. ; Compute L := not L (bitwise NOT operation):
  51.  
  52.         not    L
  53.  
  54. ; Compute L := not J (bitwise NOT operation):
  55.  
  56.         mov    ax, J
  57.         not    ax
  58.         mov    L, ax
  59.  
  60. ; Clear bits 0..3 in J:
  61.  
  62.         and    J, 0FFF0h
  63.  
  64. ; Set bits 0..3 in K:
  65.  
  66.         or    K, 0Fh
  67.  
  68. ; Invert bits 4..11 in L:
  69.  
  70.         xor    L, 0FF0h
  71.  
  72. ; Convert the character in C1 to lower case:
  73.  
  74.         mov    al, c1
  75.         or    al, LowerMask
  76.         mov    c1, al
  77.  
  78. ; Convert the character in C2 to upper case:
  79.  
  80.         mov    al, c2
  81.         and    al, 5Fh        ;Clears bit 5.
  82.         mov    c2, al
  83.  
  84.  
  85.  
  86. Quit:        mov    ah, 4ch            ;DOS opcode to quit program.
  87.         int    21h            ;Call DOS.
  88. Main        endp
  89.  
  90. cseg        ends
  91.  
  92. sseg        segment    para stack 'stack'
  93. stk        byte    1024 dup ("stack   ")
  94. sseg        ends
  95.  
  96. zzzzzzseg    segment    para public 'zzzzzz'
  97. LastBytes    byte    16 dup (?)
  98. zzzzzzseg    ends
  99.         end    Main
  100.