title: MASM Dereference pointer Twice?
body: <p>Straight and to the point I am stuck at a piece of my code. Within checkdigit proc I am trying to move the value that are at the corresponding memory locations into registers and using the [] to dereference the pointers. However, looking through this I am assuming you can not dereference a pointer twice, as I have pushed the addresses of these 'varaibles' on to the stack to use, and I guess creating another pointer. The current code will pass the memory locations of the values that I want to pass to the registers, however I am unable to dereference the memory location to get to my values. Any help would be appreciated even if it means I will not be able to use the current code. Thank you.</p>
  
  <pre><code>;valid pin program
  
  
   include c:/Irvine/Irvine32.inc
  
   NULL        EQU  0
  CR      EQU 0dh
  LF      EQU  0ah
   nextdigit EQU  4
  
   range     EQU  8[ebp]
   digit     EQU  12[ebp]
  
  .data
  
   outfile byte   "resultpin.txt", NULL
   infile  byte   "Pin.txt", NULL
   input   dword  ?
   output  dword  ?
  
   buffer_size = 130
  
   buffer    byte  buffer_size dup (?), NULL
   bytesread dword ?
   buffpos   dword 0
   pinpos    dword 1
  
   digitnum  dword 0
  
   range1    dword     '4', '8', NULL
   range2    dword     '2', '5', NULL
   range3    dword     '5', '9', NULL
   range4    dword     '1', '4', NULL
   range5    dword     '3', '6', NULL
  
   rangeray  dword     range1, range2, range3, range4, range5, NULL
   rangepos  dword     12                            
  ;memory offset is 60
  
   equal     byte      "=", NULL
  
   great     byte      "PIN is valid", NULL
  
   fault1    byte     "/Digit position ", NULL
   fault2    byte      "is invalid/", NULL
  
   faultray  dword     fault1, fault2, NULL          
  ;memory offset is 29
   faultpos  dword     17
  
   gap       byte      LF, CR, NULL
  
  
  .code
  main proc
  
        lea edx, outfile              ;create &amp; open output file
      call CreateOutputFile
      mov output, eax
  
        lea  esi,infile               ;open input file linkage
        call openfiles
  
        lea  esi,buffer
        mov  ecx,digitnum
        call countdigits
  
        call resetregs
  
        lea  esi,buffer
        lea  edi,rangeray
        add  edi,-60                  ;start at beginning of rangeray
        mov  ecx,digitnum
   L1:
        push esi
        push edi
        push ebp
  
        call checkdigit
        pop  ebp
        pop  edi
        pop  esi
        loop L1
   main endp
  
   openfiles proc
        lea edx,[esi]                 ;open file      
      call OpenInputFile
      mov input, eax 
  
      mov  eax, input               ;read input 
     file
      lea  edx, buffer
      mov  ecx, buffer_size
      call ReadFromFile
      mov  bytesRead, eax
        ret
   openfiles endp
  
   countdigits proc
     nextnumber:
        mov  dl,[esi]                 ;if not a 
    number bypass inc ecx
        cmp  dl,'0'
        jl   notdigit
        cmp  dl,'9'
        jg   notdigit
  
        inc ecx
  
     notdigit:
        inc  esi
        mov  dl,[esi]
        cmp  dl,NULL                  ;if esi 
  is NULL then return out of proc
        jne  nextnumber
  
        mov  digitnum,ecx
        ret
   countdigits endp
  
   checkdigit proc
        mov  ebp,esp
        mov  ebx,digit
        mov  edx,range
        cmp  ebx,edx
        jl   notvalid
        mov  ebx,0
     notvalid:
        ret
   checkdigit endp
  
   resetregs proc
        mov  eax,0                    ;reset 
    following registers
        mov  ebx,0
        mov  ecx,0
        mov  edx,0
        mov  dl,0
        mov  al,0
        ret
   resetregs endp
  
  
  end main
  </code></pre>