Slide 10.5: Defining and using procedures
Slide 11.1: Conditional processing
Home

USES Operator


The USES operator, coupled with the PROC directive, lets you list the names of all registers modified within a procedure. It performs two tasks:
  1. Generate PUSH instructions that save the registers on the stack at the beginning of the procedure.
  2. Generate POP instructions that restore the register values at the end of the procedure.
The USES operator immediately follows PROC, and is itself followed by a list of registers on the same line separated by spaces or tabs (not commas).

 Converting Lowercase Letters into Uppercase Letters by Using 
 PUSHAD Instruction   USES Operator 
 INCLUDE Irvine32.inc
 .data
 buffer  BYTE  64 DUP (0)
 .code
 main PROC
     mov   edx, OFFSET buffer
     mov   ecx, (SIZEOF buffer) - 1
     call  ReadString
     mov   esi, OFFSET buffer
     mov   ecx, LENGTHOF buffer - 1

 L1: cmp   BYTE PTR [esi], 'a'
     jl    L2
     cmp   BYTE PTR [esi], 'z'
     jg    L2
     call  convert
 L2: inc   esi
     loop  L1

     mov   edx, OFFSET buffer
     call  WriteString
     exit
 main ENDP

 convert PROC
    
mov cl, [esi] sub cl, 'a' add cl, 'A' mov [esi], cl popad ret convert ENDP END main
 INCLUDE Irvine32.inc
 .data
 buffer  BYTE  64 DUP (0)
 .code
 main PROC
     mov   edx, OFFSET buffer
     mov   ecx, (SIZEOF buffer) - 1
     call  ReadString
     mov   esi, OFFSET buffer
     mov   ecx, LENGTHOF buffer - 1

 L1: cmp   BYTE PTR [esi], 'a'
     jl    L2
     cmp   BYTE PTR [esi], 'z'
     jg    L2
     call  convert
 L2: inc   esi
     loop  L1

     mov   edx, OFFSET buffer
     call  WriteString
     exit
 main ENDP

mov cl, [esi] sub cl, 'a' add cl, 'A' mov [esi], cl ret convert ENDP END main