Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Tom Rettigs Library - call dosfunc with <c registers>, <n flags> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 CALL DOSFUNC WITH <C registers>, <N flags>
 Provides access to INT 21H DOS function calls.
 <registers> is altered to contain register contents after INT 21H call.

 <registers> is a 32-byte character string containing the desired
             contents of registers AX, BX, CX, DX, SI, DI, DS, ES
             as hexadecimal strings.  It must contain something
             for every register in the above order. If a register
             is not needed, assign it "0000".  If DS or ES are
             given "0000", it is ignored and their current contents
             are preserved.
 <expN> is a numeric memory variable used to return flags after
        the INT 21H function call.

 * Get time format (i.e., 12- or 24-hour clock) of the
 * country specified in Config.sys

 * See the MS-DOS Programmer's Reference or the
 * DOS Technical Reference Manual for details.

 m_buffer = ALLOCATE( 32 )
 m_seg    = SUBSTR(m_buffer, 1, 4)
 m_off    = SUBSTR(m_buffer, 5, 4)
 IF "" = m_buffer
    ? "Memory allocation error"
    RETURN
 ENDIF
 m_country = COUNTRY()
 IF m_country <= 254
    m_ax = "38" + SUBSTR(HEX(m_country), 3, 2)
    m_bx = "0000"
 ELSE
    m_ax = "38FF"
    m_bx = HEX(m_country)
 ENDIF
 m_cx = "0000"    && Don't care
 m_dx = m_off     && Offset of allocated buffer
 m_si = "0000"    && Don't care
 m_di = "0000"    && Don't care
 m_ds = m_seg     && Segment of allocated buffer
 m_es = "0000"    && Don't care
 m_regs = m_ax + m_bx + m_cx + m_dx + m_si + m_di + m_ds + m_es
 m_flags = 0
 CALL DOSFUNC WITH m_regs, m_flags

 * Was carry flag set (m_flags % 2)?
 IF m_flags % 2 = 1
    ? "Invalid country code"
    RETURN
 ENDIF
 m_timeform = PEEKBYTE(m_seg, m_off+17)
 IF m_timeform % 2 = 0
    ? "Current country uses 12-hour clock"
 ELSE
    ? "Current country uses 24-hour clock"
 ENDIF

 * Release memory
 IF .NOT. DEALLOC(m_buffer, 32)
    ? "Error -- releasing memory."
 ENDIF

 Also see the Country.prg sample program.

 Hazard
    Invalid register contents can cause serious errors,
    including computer lock-up and data destruction.

    Be sure to consult a reliable source, such as IBM's or Microsoft's
    DOS technical references, or The Peter Norton Programmer's Guide
    to the IBM-PC.


             Placed in the Public Domain by Tom Rettig Assoc.

See Also: ALLOCATE() DEALLOC() HEX() PEEK...() POKE...() REG() ROMBIOS

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson