Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the board
Thread view  Mix view  Order
kerravon

E-mail

Ligao, Free World North,
26.12.2025, 20:08
 

ctty/dup2 in DOS4 (Developers)

In the DOS4 source code, I can see:

cmd\command\tcmd2b.asm

ICLLOOP:                                        ; Close basic handles
        MOV     AH,CLOSE
        INT     int_command
        INC     BX
        LOOP    ICLLOOP
        POP     BX                              ; Get handle
        MOV     AH,XDUP   
        INT     int_command                     ; Dup it to 0
        MOV     AH,XDUP   
        INT     int_command                     ; Dup to 1
        MOV     AH,XDUP
        INT     int_command                     ; Dup to 2
        MOV     AH,CLOSE                        ; Close initial handle
        INT     int_command


Now according to RBIL:

https://www.ctyme.com/intr/rb-2931.htm

BX should have the file handle. But I see 3 executions of Int int_command,
and I don't see BX changing from 0, to 1, to 2, between executions.

Any idea how this works?

Note - I'm trying to get "ctty com1:" to work on PDOS-generic, and I
don't really have the concept yet.

Thanks. Paul.

ecm

Homepage E-mail

Düsseldorf, Germany,
26.12.2025, 21:39

@ kerravon

ctty/dup2 in DOS4

> In the DOS4 source code, I can see:
>
> cmd\command\tcmd2b.asm
>
> ICLLOOP:                                        ; Close basic
> handles
> MOV     AH,CLOSE
> INT     int_command
> INC     BX
> LOOP    ICLLOOP
> POP     BX                              ; Get handle
> MOV     AH,XDUP   
> INT     int_command                     ; Dup it to 0
> MOV     AH,XDUP   
> INT     int_command                     ; Dup to 1
> MOV     AH,XDUP
> INT     int_command                     ; Dup to 2
> MOV     AH,CLOSE                        ; Close initial handle
> INT     int_command

>
> Now according to RBIL:
>
> https://www.ctyme.com/intr/rb-2931.htm
>
> BX should have the file handle. But I see 3 executions of Int int_command,
> and I don't see BX changing from 0, to 1, to 2, between executions.
>
> Any idea how this works?
>
> Note - I'm trying to get "ctty com1:" to work on PDOS-generic, and I
> don't really have the concept yet.
>
> Thanks. Paul.

The bx input is the same for all three, the device opened earlier. Before using the duplicate handle calls, the first three handles are closed so that the output handles are 0, 1, 2. Then the new handle is closed.

---
l

Back to the board
Thread view  Mix view  Order
23172 Postings in 2182 Threads, 404 registered users (0 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum