title: How do I use a BSS var to move string into register NASM
body: <p>I'm trying to move a string into a BSS var, I've tried various methods but I have a feeling that unless I hardcode the string or use a read to grab the string I'm fighting a futile battle, the problem I'm having is although I can get the text data into the right register more data accompanies it which trashes the output and some how trashes the value of vdlen (if I directly assign a value to ecx in WriteFile the proper length is put however attempting to use vdlen causes it to way off radar)</p>
  
  <p>How do I get the right results (ie "Hello!" in "text.txt") ? </p>
  
  <pre><code>section .bss
        vdata resw 10
        vdlen resb 3
        vfd resb 1
        vfn resb 15
        err resb 2
  section .text
        mov eax,vfn
        mov dword [eax],'test'
        mov dword [eax+3], '.txt'
        mov ebx,vdata
        mov dword [ebx], 'Hell'
        mov dword [ebx+3],'o!'
        mov ecx,vdlen
        mov [ecx], 0x03h
        jmp WriteFile
  ProgramEnd:
        mov eax,1
        mov ebx,[err]
        int 80h
  WriteFile:
        mov eax,5   ;Syscall for open()
        mov ebx,vfn
        mov ecx, 65  ; mode Write-only Create
        mov edx, 420 ; permissions rw-r-r
        int 80h      ; Linux Kernel Interrupt
  
        mov [vfd],eax ; get file descriptor
  
        mov eax,4   ;Syscall for write()
        mov ebx,[vfd] ; FD argument
        mov ecx,[vdata] ; this is where my issue is
        mov edx,[vdlen] ; length of vdata
        int 80h
  
        mov [err],eax
        jmp ProgramEnd
  </code></pre>