dmsc / emu2

Simple x86 and DOS emulator for the Linux terminal.
GNU General Public License v2.0
406 stars 31 forks source link

Another little FCB issue. 'Option Characters' #61

Closed tsupplis closed 11 months ago

tsupplis commented 11 months ago

'/ ' is a separator character for the FCB building on DOS > 2.X 🙁

A tested fix in (src/loader.c:21) is:

static int valid_fcb_sep(int i)
{
    return isspace(i) || i == ',' || i == '=' || i == ';' ||
        (i == '/' && FCB_PARSE_DOS > 2);
}

under dos >3:

pspdump /a/b
CD 20 FF 9F 00 9A F0 FE  1D F0 C8 5A 00 F0 28 01  |  . .........Z..(. 
2F CC 10 01 2F CC 2F CC  01 03 01 00 02 FF FF FF  |  /..././......... 
FF FF FF FF FF FF FF FF  FF FF FF FF 01 07 DC FF  |  ................ 
57 07 14 00 18 00 57 07  FF FF FF FF 00 00 00 00  |  W.....W......... 
05 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
CD 21 CB 00 00 00 00 00  00 00 00 00 00 41 20 20  |  .!...........A   
20 20 20 20 20 20 20 20  00 00 00 00 00 42 20 20  |          .....B   
20 20 20 20 20 20 20 20  00 00 00 00 00 00 00 00  |          ........ 
05 20 2F 61 2F 62 0D 00  00 00 00 00 00 00 00 00  |  . /a/b.......... 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 

under emu2: pspdump /a/b

CD 20 00 A0 00 9A F0 FE  1D F0 22 00 00 00 23 00  |  . ........"...#. 
00 00 24 00 00 00 FE FF  00 00 00 00 00 00 00 00  |  ..$............. 
00 00 00 00 00 00 00 00  00 00 00 00 81 00 60 FE  |  ..............`. 
87 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
CD 21 CB 00 00 00 00 00  00 00 00 00 00 20 20 20  |  .!...........    
20 20 20 20 20 20 20 20  00 00 00 00 00 20 20 20  |          .....    
20 20 20 20 20 20 20 20  00 00 00 00 00 00 00 00  |          ........ 
04 2F 61 2F 62 0D 00 00  00 00 00 00 00 00 00 00  |  ./a/b........... 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |  ................ 
dmsc commented 11 months ago

Hi!

Do you know of any program that needs this?

I suppose it will not hurt to merge anyways.

Thank you!

dmsc commented 11 months ago

Hi again,

I tested under DOS-1.0, 1.1, 2.0, 2.1, 3.3 and 5.0.

The '/' is a file separator in DOS versions 1.0, 3.3 and 5.0. So, it seems that compatibility was lost in DOS 1.1 and then fixed in DOS 3.*

I will apply a patch.

dmsc commented 11 months ago

Attached are the test binary and results, the test program source is:

; Assemble with "nasm pspfcb.asm -o pspfcb.com"
;
        cpu 8086
        bits 16
        section .code

        org     100h

start:
    call open_dump

    mov  cx, 127
    mov  ax, ds
    mov  es, ax

    ; Dump filename from FCB 1
    mov  si, 5ch
    mov  cx, 12
    call hex_dump
    ; Dump filename from FCB 2
    mov  si, 6ch
    mov  cx, 12
    call hex_dump

    call close_dump
    xor  ax, ax
    int  21h

out_fcb:
    db 0, 'PSPFCB  LOG'
    dw 0
    dw 0
    dq 0
    dw 0
    dw 0
    db 0,0,0,0,0,0,0,0
    db 0
    dq 0

open_dump:
    ; open existing file
    lea  dx, [out_fcb]
    mov  ah, 0fh
    int  21h
    or   al,al
    je   no_create

    ; Can't open existing file, create new
    mov  ah, 16h
    int  21h
    or   al,al
    jne  err

no_create:
    ; setup for blocks of 1 byte
    mov word [out_fcb+0eh], 1
    ; and point position to end of file
    mov ax, [out_fcb + 10h]
    mov [out_fcb + 21h], ax
    mov ax, [out_fcb + 12h]
    mov [out_fcb + 23h], ax
    ret

err:
    mov  dx, err_msg
    mov  ah, 09h
    int  21h
    mov  ah,0
    int  21h

err_msg:
    db   'Error at file open', 0dh, 0ah, '$'

close_dump:
    ; open
    lea  dx, [out_fcb]
    mov  ah, 10h
    int  21h
    or   al,al
    jne  err
    ret

; Display a memory dump of length CX, from ES:SI,
; including hex and ascii data
hex_dump:

    push cx
    ; Cleanup DTA
    mov  di, 80h
    mov  cx, 67
    mov  al, ' '

clr_line:
    mov  [di], al
    inc  di
    loop clr_line

    mov  al, '|'
    mov  [80h+48],al
    mov  [80h+65],al
    mov  ax, 0a0dh
    mov  [80h+66],ax

nxt_line:
    pop  cx
    or   cx,cx
    jz   ret_exit
    xor  bx, bx
    xor  di, di

nxt_char:
    ; Generate the bytes one at a time
    or  cx,cx
    je  end_line
    dec cx
    es lodsb

    ; print byte
    mov  ah,al
    cmp  al, ' '
    jb   print_dot
    cmp  al, 127
    jb   print_cok
print_dot:
    mov  al, '.'
; Print a character
print_cok:
    mov  [80h+49+bx], al
    inc  bx

    mov  al,ah
    ; print hex
    call fill_b
    inc  di

    cmp  bx, 10h
    jl   nxt_char

; We have one line, print
    push cx
    call write_line
    jmp  nxt_line

fill_b:
    call fdig
fdig:
    rol  al,1
    rol  al,1
    rol  al,1
    rol  al,1
    mov  dl,al
    and  dl,15
    cmp  dl,9
    jbe  .num
    add  dl,7
.num add  dl,'0'
    mov  [80h+di], dl
    inc  di
ret_exit:
    ret

fill_line:
    mov  al, ' '
    mov  [80h+49+bx], al
    inc  bx
    mov  [80h+di], al
    inc  di
    mov  [80h+di], al
    inc  di
    inc  di
end_line:
    cmp  bx, 10h
    jl   fill_line

; Write last line to file and exit

write_line:
    mov  ah, 28h
    mov  cx, 68
    lea  dx, [out_fcb]
    int  21h
    ret

testfcb.zip