title: NASM - Outputting string after applying caesar cipher
body: <p>Am trying to do a program which does the following: it takes a file's input: 10 characters, all CAPs, advances them all by 3 positions in the alphabet each, and those that go past the Z ascii code, then get 26 positions subtracted. Z->D, A->D, D->H, etc.</p>
  
  <p>Code: character + 3
  if (Code > 26) 
  Code: Code - 26</p>
  
  <p>My readByte function, which does precisely what it says: each line is well commented!</p>
  
  <pre><code>mov ecx, 0
  mov edi, buffer  ; buffer is memory address of 1st char of file  
  
  readByte:
  
  mov al, [edi]   ; move x's position content to al    
  add al, 3       ; add 3 to al
  cmp al, MAXHEX  ; compare with 'Z' 
  jg dec          ; if al &gt; 'Z', jump to dec
  call putChar    ; if al &lt; 'Z', print char
  jmp nextByte    ; grab next character!
  
  dec:
  sub al, 26      ; decrement al by 26
  call putChar    ; print char
  jmp nextByte    ; grab next char
  
  nextByte:
  
  cmp ecx,[filesize] ; compare counter and filesize I had returned from readFile
  jge terminar       ; if it has read all chars, end program
  inc ecx        ; increment counter 
  inc edi            ; advance to next file address position, so as to get next character
  jmp readByte       ; go read the byte again
  </code></pre>
  
  <p>And this is the putChar macro, which was handed to us for the essay:</p>
  
  <pre><code>; putChar   - write a char to stdout (stdout)
  ;   Argument(or whatever you call it in assembly)
  ;      al: char to write
  ;   Return: has none
  putChar:
      push ebx
      push ecx
      push edx
      push eax    ; al has the ascii code to write
      mov ecx, esp  ; esp points to top of stack
      mov edx, 1  ; write a character
      mov  eax, SYS_WRITE  ; 4
      mov  ebx, 1   ; channel of screen ecran - stdout
      int LINUX_CALL
      pop eax
      pop edx
      pop ecx
      pop ebx
      ret
  </code></pre>
  
  <p>Basically, I can get the program to work perfectly, if I change</p>
  
  <pre><code>add al, 3       ; add 3 to al
  </code></pre>
  
  <p>To a different value. I have no clue what's wrong. Spent atleat a dozen hours on this one simple thing.</p>