Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 3,453 of 4,675    |
|    bilsch01 to All    |
|    a variable definition is causing an erro    |
|    18 Jul 18 03:31:26    |
      From: king621@nospicedham.comcast.net              The code below is parts from a program that reads FAT16 partitions and       prints the root directory of the current one. Originally I could change       drives (partitions) and print the root directory of the next one, change       again and print that one. I used a 'dir' command to print the       directory. Suddenly it didn't work the same. The first time I entered       dir it printed the directory ok but when I changed to another drive and       entered dir it printed the directory of the first one printed. That is       the only directory that would print regardless of which drive I changed       to. I found out that the int 0x13 ah=0x42 was only being performed       successfully for the first time I entered dir command. Subsequent tries       set the carry flag (CF) indicating a failure and the buffer at j2snd       (segment 0x9e) wasn't updated for the next drive - so the program       printed the same directory listing for every dir command.              The code below doesn't have a dir command and doesn't print a directory.        Every time you hit the enter key the program executes the int13/ah42       sequence and prints the hex digits in the ah register if CF gets set.       So the first time you hit enter it prints nothing and subsequent times       it prints the hex digits. The hex digits are '42' - not an error       indication. I checked the code carefully and found an anomaly. When the       line:               cmd_findfl db 'findfl',0              is commented out the problem goes away. Then no CF gets set after       int13/ah=42 is performed. What the hell? I can't go on with arbitrary       things like that happening. Pleae help. Bill S.                     bits 16       org 0x7e00              SECTION .data              int13pkt times 16 db 0 ;space for int13/ah42 packet       ms_invdr db 'invalid drive letter',0       ms_inv13 db 'an input field has more than 12 characters',0       ms_inv2b db 'two blank spaces is illegal',0       ms_hi db ' Hello World!',0       ms_badc db 'unrecognized command',0       ms_help db 'clear, copy, date, dir, drive, findbs, findfl, help, hi,       parts, time, txt',0       ms_dt_err db ' no BIOS date/time.',0       ms_txcmds db ' alt-(O)pen alt-(C)lose alt-(S)ave alt-save(A)s       alt-e(X)it',0       ms_f2open db ' name of file to open:',0       ms_f2save db ' name of file to save:',0       ms_fdne db ' file does not exist. Create? y/n:',0       cmd_clear db 'clear',0       cmd_copy db 'copy',0       cmd_date db 'date',0       cmd_dir db 'dir',0       cmd_drive db 'drive',0       cmd_findbs db 'findbs',0       cmd_findfl db 'findfl',0 ;this line breaks it       cmd_help db 'help',0       cmd_hi db 'hi',0       cmd_parts db 'parts',0       cmd_time db 'time',0       cmd_txt db 'txt',0              kbuf times 64 db 0       buf1 times 13 db 0       buf2 times 13 db 0       buf3 times 13 db 0       buf4 times 13 db 0       pbuf times 80 db 0       arg2dne db 0       fname1 times 13 db 0       fname2 times 13 db 0       txoname times 13 db 0              scrbfc dw 0 ;byte count of screen buffer              bgfg db 0x0f ;bg/fg=blk/wht       js2nd dw 0x9e0 ;segment at end of jsec2              ptdat times 2 dw 0 ;partition data              lasdrv db 0 ;drive letter of last drive       curdrv db 0x61 ;drive letter of current drive - init is 'a'       txoflag db 0 ;       bign times 2 dw 0       bslba1 times 2 dw 0 ;32-bit sec# of bs of current drive       bslba2 times 2 dw 0 ;a copy of bslba1       clstr1 dw 0              times 0x600-($-$$) db 'k'              SECTION .text               mov si,0 ;location of this info packet in data seg.        mov word[si],16 ;packet size        mov word[si+2],1 ;# of sectors to load        mov word[si+4],0 ;offset - where to load sectors        mov word[si+6],js2nd ;segment - where to load sectors        mov word[si+8],0 ;starting absolute sector# in a quadword - mbr=0        mov word[si+10],0        mov word[si+12],0        mov word[si+14],0        mov dl,0x80 ;drive number        mov ah,0x42 ;extended read         int 0x13               mov ax,js2nd        mov es,ax        mov di,454 ;point to 32-bit sector # of 1st part.        mov ax,word[es:di]        mov word[ptdat],ax        mov ax,word[es:di+2]        mov word[ptdat+2],ax              mainloop:        mov ah,0        int 0x16 ; wait for keyboard i/p        mov di,ptdat        mov si,0 ;location of this info packet in data seg.        mov word[si],16 ;packet size        mov word[si+2],32 ;# of sectors to load - root dir.        mov word[si+4],0 ;offset - where to load sectors        mov word[si+6],js2nd ;segment - where to load sectors        mov ax,word[ds:di]        mov word[si+8],ax        mov ax,word[ds:di+2]         mov word[si+10],ax        add word[si+8],513 ;points to 1st sector of root dir.        adc word[si+10],0        mov word[si+12],0        mov word[si+14],0        mov dl,0x80 ;drive number        mov ah,0x42 ;extended read         int 0x13        jnc ok        mov cx,2       hxob: ;call with binary in ax, #digits in cx        rol ax,4 ;put hi hex digit on right        push ax ;save rol'd ax        and al,0x0f ;masks digit on right        add al,'0' ;0 thru 9        cmp al,'9'        jbe xo3x        add al,0x7 ;A thru F       xo3x: mov ah,0xe         int 0x10 ;write to screen        pop ax ;rol'd version of ax        dec cx        jnz hxob ;one digit per loop       ok: jmp mainloop              times 0x1A00-($-$$) db 'z' ;0x1A00=13x512       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca