--------------- FIDO MESSAGE AREA==> TOPIC: 145 ASSEMBLY LANG. Ref: F5G00129Date: 05/01/98 From: JANIS KRACHT Time: 02:04pm \/To: ALL (Read 1 times) Subj: New PDN files at < TOPIC: 145 ASSEMBLY LANG. Ref: F5G00130Date: 05/01/98 From: ANTHONY TIBBS Time: 04:37pm \/To: BERNHARD KUEMEL (Read 1 times) Subj: IDE "Sleep" Mode Bernhard Kuemel wrote in a message to Anthony Tibbs: AT> I know that IDE drives have a "sleep" mode (they'll spin down after a AT> certain length of time). In fact, my BIOS has an option to do this. AT> Is there some way to set the number of minutes before it'll spin down? AT> C/C++ or ASM code is fine... BK> I have 2 dos programs that do that: BK> ATSLEEP EXE 4224 22.11.97 15.07 BK> OFF EXE 5696 22.11.97 15.07 BK> IMHO they store the timeout value in the hard drive. The BK> maximum time is about 21 mins. One program allows seconds BK> input with a resolution of 5 s. That is what I had figured, as well. Only I was under the impression that it only went in increments of 1 minute. BK> ATSLEEP V1.01 (c) Copyright 1991 BK> by Dirk Seifert BK> Syntax : ATSLEEP Time1 [Time2] BK> - ATSLEEP setzt die Abschaltzeit nach BK> Festplatten-Zugriffen. - Bei einem erneuten Zugriff BK> schaltet sich die Festplatte BK> automatisch wieder an. BK> - Ein Wert von 0 setzt die Abschaltung auer Kraft. BK> - Andere Werte werden auf 5 Sekunden gerundet. BK> - Der Maximal-Wert betrgt 1275 Sekunden (=21.25 Minuten). BK> - Time1 gilt fr Festplatte 1. BK> - Time2 gilt fr Festplatte 2. Sorry, Bernhard, but I'm not very familiar with German. However, please correct me if I'm wrong: - ATSLEEP sets the spindown timer on an HDD. - When this timer expries, the drive will automatically wind down. - Enter a 0 to disable the timer. - Enter numbers in increments of 5 seconds. - The maximum wait time is 1275 seconds (=21.25 minutes) - Time1 is for drive 1 - Time2 is for drive 2 Yes? Take care, Anthony --- * Origin: The Tibbs' Place BBS * Private * Ottawa, ON, Canada (1:163/585.2) --------------- FIDO MESSAGE AREA==> TOPIC: 145 ASSEMBLY LANG. Ref: F5G00131Date: 05/01/98 From: JAMES VAHN Time: 06:43pm \/To: BRYAN SCHWARTZ (Read 1 times) Subj: Re: Java Bytecode > I was wondering if messages about Java bytecode are allowed on > this conference? Can you post a sample? This echo is primarily for 80x86 CPU's but if you can find an audience and the code is a low-level language... :-) --- GNU/Debian Linux * Origin: 300 miles East of Seattle, WA (1:346/3@fidonet) --------------- FIDO MESSAGE AREA==> TOPIC: 145 ASSEMBLY LANG. Ref: F5G00132Date: 05/10/98 From: TOM TORFS Time: 11:35pm \/To: FERNANDO ARIEL GONT (Read 1 times) Subj: Int 15h - function 86h Fernando Ariel Gont wrote in a message to All: FAG> 80h invalid command (PC, PCjr) FAG> 83h wait already in progress FAG> 86h function not supported (XT and later) FAG> I don't understand really well what the references such as "AT", FAG> "PC", (and so on) mean... For example, I have found that "PC" and FAG> "AT", and "PC" and "XT" are treated as different things... but FAG> why? (I mean, "AT" is a "PC" model) Well, actually the XT was an extension of the PC technology (eg. support for harddisks) and the AT was yet another extension. Several BIOS features were added or changed from one model to the other. FAG> My book says this function should be supported on "[AT][PS/2]"... FAG> but, reading the comments of the 86h status code ("XT and FAG> _*later*_") one would think that having a PC AT one should get the FAG> 86h status code.... I don't understand this, either... :( The above simply means that on pre-XT BIOSes you won't get a 86h error code if the function is not supported. greetings, Tom tomtorfs@village.uunet.be --- timEd/2 1.10+ * Origin: 80X86 BBS 32-15-24.62.32 V.34/V.FC (24h/24h) (2:292/516) --------------- FIDO MESSAGE AREA==> TOPIC: 145 ASSEMBLY LANG. Ref: F5G00133Date: 05/11/98 From: RICHARD VAN BERKUM Time: 08:51pm \/To: JASEN BETTS (Read 1 times) Subj: Read Keyboard Hello, I saw you had some questions about the keyboard ;-) I wrote this my self so it's probably not very optimized. But maybe it helps you. I also include a doc. about the keyboard stuff. I hope it will help you. bye Richard van Berkum. .model small .386p .stack .data scantabel db 8,1,"1234567890-=",8,8,"qwertyuiop[]",0dh,8,"asdfghjkl;'" db 8,8,"\zxcvbnm,./",8,8,8,32 shiftscan db 0,0,"!@#$%^&*()_+",8,8,"QWERTYUIOP{}",0dh,8,"ASDFGHJKL:",34,8,8 db "|ZXCVBNM<>?" key db 0 shift db 0 .code mov ax, @data mov ds, ax call init_kb start: cmp key, 0 je start mov al, key cmp shift, 1 je shift_tab mov bx, offset scantabel jmp no_shift_tab shift_tab: mov bx, offset shiftscan no_shift_tab: xlat mov key, al mov ah, 40h mov cx, 1 mov dx, offset key mov bx, 1 int 21h cmp key, 1 mov key, 0 jne start push ds mov ax, cs:[oldhigh] mov ds, ax mov dx, cs:[oldlow] mov ax, 2509h int 21h pop ds mov ax, 4c00h int 21h init_kb proc mov ax, 3509h int 21h mov cs:oldlow, bx mov cs:oldhigh, es push ds push cs pop ds mov dx, offset kb_isr mov ax, 2509h int 21h pop ds ret oldlow dw ? oldhigh dw ? init_kb endp kb_isr proc pusha mov dx, 60h sec_key: in al, dx cmp al, 0 je no_key cmp al, 2ah+80h jne keep_shift1 mov shift, 0 keep_shift1: cmp al, 36h+80h jne keep_shift mov shift, 0 keep_shift: test al, 80h jnz no_key cmp al, 2ah jne no_shift_l mov shift, 1 jmp sec_key no_shift_l: cmp al, 36h jne no_shift mov shift, 1 jmp sec_key no_shift: mov key, al ; get scancode no_key: mov dx, 61h in al, dx and al,01111111b out dx, al or al, 128 out dx, al ; disable/enable keyboard mov dx, 20h mov al, 20h out dx, al ; ack. pic popa iret kb_isr endp end Wout Mertens' Guide To Keyboard Programming v1.1 23 may 94 Table of Contents 0 Legal Info 0.1 Preface 1 Overall Information 1.1 Extended ASCII 1.2 Special Functions 2 DOS Interfacing 2.1 Functions 3 BIOS Interfacing 3.1 Functions 3.2 Keyboard Flags 3.3 Keyboard Buffer 4 Low-Level Interfacing 4.1 Interfacing And Configuring 4.2 Lay-Out 4.3 Scancodes 4.4 Int 9 5 Tech Stuff A Acknowledgments B How To Contact Me C The Answer To Life, The Universe And All The Rest D History 0. Legal Info This "Keyboard Guide" is (C) Copyright 1994 Wout Mertens. All rights reserved. THIS DOCUMENT AND THE ACCOMPANYING SOURCE CODE FILES ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. WOUT MERTENS WILL NOT BE HELD LIABLE FOR ANY DAMAGES OR LOSSES OF ANY KIND THAT RESULT FROM THE USE OR THE INABILITY TO USE THE INFORMATION PROVIDED IN THIS DOCUMENT OR THIS SOURCE CODE FILE, INCLUDING, BUT NOT LIMITED TO, LOSS OF PROPERTY OR INCOME. This document and its accompanying source code files are freeware, not public domain. They may be distributed freely provided that neither file is modified, and that they are distributed together along with FILE_ID.DIZ in their entirety, including the legal notice, and that: If they are distributed by a third party vendor, no more than $5 U.S. is charged for the disk on which the archive, containing this document and the accompanying source code files, is stored, except when distributed on CD-ROM. This legal information supersedes all previous notices. 0.1. Preface I wrote this document because I needed info, and thought I could get it this way. Boy was I wrong! I ended up finding it all by myself. Anyway, I hope you can use it. It is meant for people who know what interrupts are and that 0ah equals 10. Enjoy. Oh, almost forgot. I didn't give this text any page formatting (aside from spaces before and room after for ease of reading) because: - I read ALL my documents on-line - People have differing page sizes and then it would look like shit for some people and too short for others. If you want to print this, well, go ahead and format it, BUT DON'T EVEN *THINK* OF SPREADING IT !!! (Except when you ask my permission) Everytime you see something like d9h or 65h, it is a hexadecimal number. No trailing 0 was added for ease of typing. 1. Overall Information On the IBM, there are three ways, all alike, to access the keyboard. Via the operating system, via BIOS or via low-level access. Which way you use depends very much on the application you are writing. Games do not use DOS functions, for example. And a file-compressor is really not interested wether you are actually pressing 'Y' or not. Or how long. This is the way it works: Hardware BIOS Ĵ DOS Ĵ Ŀ ڴKeyboard DataĿ Ŀ Ŀ Ŀ Ŀ Ŀ key- Ĵint 9ĴkeyboardĴBIOS keyboardĴDOS keyboard board buffer functions functions ͼ Possible tap points The keyboard triggers IRQ 1 (Interrupt Request), also known as int 9. Int 9 then translates the keyboard codes into ASCII, or when necessary, extended ASCII, and places it into the keyboard buffer. Also, the shift and lock states are saved in the BIOS Data Area (seg 40h). The keyboard buffer is then used by the BIOS functions to interface with programs. The DOS functions use the BIOS keyboard functions to interface with programs as well, but on a higher and more protected (Ctrl-Brk etc) level. 1.1. Extended ASCII Extended ASCII is IBM's way of letting non-ASCII keys be recognized by programs. The BIOS will first send 0 and then the extended ASCII code. Here is the table: ķ Key Hex DecKey Hex DecKey Hex DecKey Hex Dec Ķ F1 3B 59Shift-F1 54 84Ctrl-F1 5E 94Alt-F1 68 104 F2 3C 60Shift-F2 55 85Ctrl-F2 5F 95Alt-F2 69 105 F3 3D 61Shift-F3 56 86Ctrl-F3 60 96Alt-F3 6A 106 F4 3E 62Shift-F4 57 87Ctrl-F4 61 97Alt-F4 6B 107 F5 3F 63Shift-F5 58 88Ctrl-F5 62 98Alt-F5 6C 108 F6 40 64Shift-F6 59 89Ctrl-F6 63 99Alt-F6 6D 109 F7 41 65Shift-F7 5A 90Ctrl-F7 64 100Alt-F7 6E 110 F8 42 66Shift-F8 5B 91Ctrl-F8 65 101Alt-F8 6F 111 F9 43 67Shift-F9 5C 92Ctrl-F9 66 102Alt-F9 70 112 F10 44 68Shift-F10 5D 93Ctrl-F10 67 103Alt-F10 71 113 Ľ ķ Key Hex DecKey Hex DecKey Hex DecKey Hex Dec Ķ Alt-A 1E 30Alt-P 19 25Alt-3 7A 122down 50 80 Alt-B 30 48Alt-Q 10 16Alt-4 7B 123left 4B 75 Alt-C 2E 46Alt-R 13 19Alt-5 7C 124right 4D 77 Alt-D 20 32Alt-S 1F 31Alt-6 7D 125up 48 72 Alt-E 12 18Alt-T 14 20Alt-7 7E 126End 4F 79 Alt-F 21 33Alt-U 16 22Alt-8 7F 127Home 47 71 Alt-G 22 34Alt-V 2F 47Alt-9 80 128PgDn 51 81 Alt-H 23 35Alt-W 11 17Alt-- 82 130PgUp 49 73 Alt-I 17 23Alt-X 2D 45Alt-= 83 131 Alt-J 24 36Alt-Y 15 21 ^left 73 115 Alt-K 25 37Alt-Z 2C 44NUL 03 3^right 74 116 Alt-L 26 38 Shift-Tab 0F 15^End 75 117 Alt-M 32 50Alt-0 81 129Ins 52 82^Home 77 119 Alt-N 31 49Alt-1 78 120Del 53 83^PgDn 76 118 Alt-O 18 24Alt-2 79 121^PrtSc 72 114^PgUp 84 132 Ľ ͻ 101-key Keyboard Extensions Supported by BIOS ķ Key Hex DecKey Hex DecKey Hex Dec Ķ F11 85 133Alt-Bksp 0E 14Alt - K / A4 164 F12 86 134Alt-Enter 1C 28Alt - K * 37 55 Shft-F11 87 135Alt-Esc 01 1Alt - K - 4A 74 Shft-F12 88 136Alt-Tab A5 165Alt - K + 4E 78 Ctrl-F11 89 137Ctrl-Tab 94 148Alt - K Enter A6 166 Ctrl-F12 8A 138 Alt-F11 8B 139Alt-up 98 152Ctrl- K / 95 149 Alt-F12 8C 140Alt-down A0 160Ctrl- K * 96 150 Alt-[ 1A 26Alt-left 9B 155Ctrl- K - 8E 142 Alt-] 1B 27Alt-right 9D 157Ctrl- K + 90 144 Alt-; 27 39 Alt-' 28 40Alt-Delete A3 163Ctrl- K Up [8] 8D 141 Alt-` 29 41Alt-End 9F 159Ctrl- K Cn [5] 8F 143 Alt-\ 2B 43Alt-Home 97 151Ctrl- K Dw [2] 91 145 Alt-, 33 51Alt-Insert A2 162Ctrl- K Ins[0] 92 146 Alt-. 34 52Alt-PageUp 99 153Ctrl- K Del[.] 93 147 Alt-/ 35 53Alt-PageDown A1 161 Ľ K indicates a key on the numeric keypad (when not in NumLock mode) 1.2. Special Functions There are a few functions and interrupts invoked by int 9: int 5 - Print Screen Handler int 15h fns 4fh - Check Scancode (See int 9) 85h - System Request Normally IRET int 23h - Ctrl-Break handler Feel free to revector any of them. 2. DOS Interfacing One of the ways to use the keyboard is to let DOS handle it. Pro: - The keyboard lay-out is unimportant - You can even do strings - The user doesn't actually have to type Contra: - You don't know if you are actually accessing the keyboard (like in "Really format drive C: ? Y/N" :-) - The functions are quite slow 2.1. Functions DOS provides a set of 7 functions to handle the keyboard: 01h Keyboard Input 06h Console I/O 07h No Echo Unfiltered Input 08h No Echo Filtered Input 0Ah Buffered Input 0Bh Input Status 0Ch Clear Keyboard Buffer & Input They all expect the keyboard to be file handle 0. If you want to let a program think you are typing something, you can replace this handle with a file containing the keystrokes it must read. This is what happens when you 'pipe' something in DOS. (Don't forget to change the handle back to the old one!) This also means you can use: 3Fh Read bytes from handle Fn 01h: Keyboard Input ---------------------- Expects: AH 01h Returns: AL Character fetched from the Standard Input Description: Reads (waits for) a character from the Standard Input Device. Echoes that character to the Standard Output Device. If Ctrl-Break is detected, INT 23h is executed. Notes: Extended ASCII keystrokes (ie, F1-F12, PgUp, cursor, etc) will require two calls to this function. The first call will return AL=0. The second will return AL with the extended ASCII code. Fn 06h: Console I/O ------------------- Expects: AH 06h DL 0 to 0FEh Character to send to the Standard Output 0FFh Request for input from the Standard Input Returns: ZF Clear (NZ) if character is ready \ on input requests AL Character read, if ZF is clear / (when DL=0FFh) Description: If DL is 0FFh, this performs a "no wait" console input, returning the Zero Flag (ZF) set (ZR) if there is no character ready. If a character is ready, returns ZF cleared (NZ) with the character that was read in AL. If DL is anything but 0FFh, DL is sent to the Standard Output. Notes: Does not check for Ctrl-Break. Call twice for Extended ASCII. Fn 07h: No Echo Unfiltered Console Input ---------------------------------------- Expects: AH 07h Returns: AL Character fetched from the Standard Input Description: Reads (waits for) a character from the Standard Input Device, returning that character in AL. Unfiltered: Does not detect Ctrl-Break, backspace, etc. Notes: Call twice for Extended ASCII character input. Use Fn 0Bh to check status (if you don't want to wait for a key). Fn 08h: No Echo Console Input