I'm trying to write a program that can add entries to the root directory of a fat12 floppy disk,
my code works only if I'm writing to entries less than the 4th entry
here's my code could you guys help me...

       xor     ax,ax                   ;zero ax
       mov     bx,ax                   ;zero bx
       mov     dx,ax                   ;zero dx
       mov     si,ax                   ;zero si
       mov     di,ax    
       mov     bx,     ;the buffer
       mov     ax,19
       mov     cx,1                  ;read one sector
       call    read_sectors        ;read sectors from floppy
       call    getname              ;get file name from users
       mov     si,cname
       mov     bx,   ;save buffer address in bx

       add     bx,96               ;the entry number goes here(3rd entry)
  ;if i change the value of bx to for example 128 or 160
  ;it will not work
       mov     cx,11
       mov     al,byte       ;save name in buffer
       mov     byte ,al
       inc     si
       inc     bx
       loop    yeh
       mov     bx,    ;write the buffer back to the floppy disk
       mov     ax,19
       mov     cx,1                  ;write one sector
       call    write_sectors

Posted on 2008-08-13 20:10:34 by abuashraf
Try replacing 'mov bx,...' with 'lea bx,...'
MOV is used to move data from memory to register, from register to memory, or from register to register.
It is not used to load a register with a pointer to a buffer.
Thats what LEA is for (Load Effective Address).

I believe you're loading BX with the first 16 bits worth of data from the buffer, when you wanted BX to point TO the buffer ;)

Posted on 2008-08-15 02:43:37 by Homer
I tryied lea but my program just freeze. :sad:
I used mov with a program to print a list of files in the root directory,it worked well.
Posted on 2008-08-15 11:06:23 by abuashraf
I erased a stupid push and every thing working fine,thanks.
Posted on 2008-08-16 20:07:04 by abuashraf