SoFunction
Updated on 2025-03-04

Implementation of assembly language and and or logical operation instructions

This article introduces the implementation of assembly language and, or logical operation instructions, and shares it with you

assume cs:code
code segment
    
       ; Logical operations  Operation according to binary bits
   start: mov ax,0
      
      mov al, 00001111B
      and al, 11110000B
      ;    00000000B  
 
 
 
      mov ax,0
      mov al, 00001111B
       or al, 11110000B
      ;    11111111B 
 
      mov ax,4c00H
      int 21H
       
  
code ends
 
end start

Through and or logical operation instructions, it is realized to uppercase to lowercase and lowercase to uppercase

assume cs:code, ds:data
 
data segment
  db 'puThon'
  db 'JAVA'
 
data ends
 
; z 122  7A 0111 1010 lower casez
       ;1101 1111
 
; Z 90  5A 0101 1010 capitalZ
      ; 0010 0000
 
code segment
 start: mov ax,data
     mov ds,ax
     mov bx,0
     mov cx,6
     
  ; lower case转capital
  upLet: mov al,ds:[bx]
      and al,11011111B
      mov ds:[bx], al
      inc bx
      loop upLet
  
  mov cx,4
  ; capital转lower case 
  upX: mov al,ds:[bx]
     or al,00100000B
     mov ds:[bx],al
     inc bx
     loop upX
 
     mov ax,4C00H
     int 21h
 
 
code ends
 
end start

Copy string

assume cs:code, ds:data
 
data segment
   db 'welcome to asm'
   db '--------------'
data ends
 
code segment
   start: mov ax, data
       mov ds, ax       
 
       mov cx, 7
       mov si,0
       mov di,16
       
   cp:  mov ax, ds:[si]
       mov ds:[di], ax
 
       add si,2
       add di,2
       loop cp
 
       mov ax,4C00H
       int 21H
 
code ends
 
end start

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.