PEEK.COM ======== Purpose: -------- Allows the testing the value of any byte in low memory or any subset of bits of any byte in a batch file by returning the requested byte or subset as an ERRORLEVEL value. Format for PEEK.COM: -------------------- PEEK xx:yy [ AND zz ] [ comment ] "xx:yy" = address, hexadecimal (segment:offset) "zz" = optional bit mask, hexadecimal " comment " any text that can't be mistaken for the optional bit mask -- must not start with "AND" if optional bit mask is omitted -- useful for documenting PEEK command without extra REM statement. PEEK [comment] If the first item on the command-line is not a valid address then a short description of the command format is displayed. Examples: --------- PEEK 40:10 AND 02 test for math co-processor IF ERRORLEVEL 2 GOTO OK ECHO Sorry, a math co-processor is required for this programme. GOTO DONE :OK mathprog :DONE In a batch file run from a RAM disk (otherwise you repeatedly access your disk drive until there is a keypress): ECHO Load mouse driver? Press Alt for "no" and Ctrl for "yes". KWAIT: PEEK 40:17 AND 0C check ALT and Ctrl key bits IF ERRORLEVEL 8 GOTO CONT IF NOT ERRORLEVEL 4 GOTO KWAIT C:\DOS\mouse.com :CONT PEEK 40:49 check video mode IF NOT ERRORLEVEL 8 IF ERRORLEVEL 7 GOTO MONOCHRM colorprg GOTO DONE :MONOCHRM monoprog :DONE Format for information below: ----------------------------- PEEK xxxx:yyyy -- eee or PEEK xxxx:yyyy AND zz -- eee "xx:yy" = address, hexadecimal (0:0 to FFFF:FFFF) "zz" = optional bit mask, hexadecimal (0 to FF) "eee" = returned ERRORLEVEL, 0 to 255, decimal Some Useful addresses for PEEK.COM: ----------------------------------- PEEK 40:10 -- Equipment Word, low byte PEEK 40:10 AND C1 -- 0 = no floppy drives 1 = 1 floppy drive 65 = 2 floppy drives 129 = 3 floppy drives (PC/XT only) 193 = 4 floppy drives (PC/XT only) PEEK 40:10 AND 02 -- 2 = math co-processor installed (else 0) PEEK 40:10 AND 04 -- 4 = mouse port on system board (AT only) PEEK 40:10 AND 0C -- 0 = 16K motherboard RAM (PC/XT only) 4 = 32K motherboard RAM (PC/XT only) 8 = 48K motherboard RAM (PC/XT only) 12 = 64K motherboard RAM (PC/XT only) PEEK 40:10 AND 30 -- initial video mode on boot-up: 0 = video adapter determines initial video mode (AT) 16 = colour, 40 columns by 25 rows (mode 1) 16 = colour, 80 columns by 25 rows (mode 3) 16 = monochrome, 80 columns by 25 rows (mode 7) PEEK 40:11 -- Equipment Word, high byte PEEK 40:11 AND 0E -- number of serial ports 0 = none 2 = 1 port 4 = 2 ports 6 = 3 ports 8 = 4 ports PEEK 40:11 AND 10 -- 16 = game port installed (else 0) (PC/XT only) PEEK 40:11 AND 20 -- 32 = internal modem (else 0) (some ATs only) PEEK 40:11 AND C0 -- number of parallel printer ports 0 = none 64 = 1 port 128 = 2 ports 192 = 3 ports PEEK 40:17 -- keyboard shift flags # 1 PEEK 40:17 AND 01 -- 1 = Right Shift down (else 0) PEEK 40:17 AND 02 -- 2 = Left Shift down (else 0) PEEK 40:17 AND 04 -- 4 = Control key (left or right) down (else 0) PEEK 40:17 AND 08 -- 8 = Alt key down (left or right) (else 0) PEEK 40:17 AND 10 -- 16 = Scroll Lock on (else 0) PEEK 40:17 AND 20 -- 32 = Num Lock on (else 0) PEEK 40:17 AND 40 -- 64 = Caps Lock on (else 0) PEEK 40:17 AND 80 -- 128 = Insert toggle on (else 0) PEEK 40:18 -- keyboard shift flags # 2 PEEK 40:18 AND 01 -- 1 = Left Ctrl down (101/102 keyboards only) PEEK 40:18 AND 02 -- 2 = Left Alt down (101/102 keyboards only) PEEK 40:18 AND 04 -- 4 = Sys Req key down (except 83-key keyboards) PEEK 40:18 AND 08 -- 8 = Pause enabled PEEK 40:18 AND 10 -- 16 = Scroll Lock key down PEEK 40:18 AND 20 -- 32 = Num Lock key down PEEK 40:18 AND 40 -- 64 = Caps Lock key down PEEK 40:18 AND 80 -- 128 = Insert key down PEEK 40:49 -- current video mode PEEK 40:4A -- number of character columns on the screen PEEK 40:6C -- low byte of timer-tick double word. Makes a handy pseudo-random number generator if your sample rate is infrequent enough with enough unpredictable intervals between samples. PEEK 40:70 -- midnight rollover flag (cleared on the next query to BIOS time routines) 0 = no rollover, 1 = rollover. PEEK 40:75 -- number of hard drives PEEK 40:84 -- (number of character rows on the screen) - 1 PEEK 50:00 -- Print Screen status 0 = print screen ready 1 = print screen in progress (or disabled by software) 255 = error on last print screen PEEK F000:FFFE -- computer model byte (only approximate as some companies didn't follow the IBM standard and some other values may be possible with some other systems) 255 = original PC 254 = PC XT or Olivetti M240 253 = PC jr 252 = PC AT, PS/1, and some PS/2 models 251 = PC XT with enhanced keyboard 250 = PS/2 models 25 and 30; Olivetti M111 249 = PC Convertable 248 = most PS/2 models, Olivetti P500 and P800 154 = Compaq XT/Compaq Plus 48 = Sperry PC 45 = Compaq PC/Compaq Deskpro For more addresses and values, check out any good BIOS reference or Ralf Brown's Interrupt list.