![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-13 04:08 |
47,812 topics / 349,916 posts / today 1 new / 48,268 members |
| DOS批处理 & 脚本技术(批处理室) » With everyone's effort, batch files can say goodbye to choice |
| Printable Version 16,445 / 45 |
| Floor1 wangff | Posted 2008-12-09 11:37 |
| 初级用户 Posts 54 Credits 134 | |
|
Improved version is on the 26th floor:
Let's all improve it together! [ Last edited by wangff on 2008-12-11 at 10:34 ] |
|
| Floor2 wangff | Posted 2008-12-09 16:09 |
| 初级用户 Posts 54 Credits 134 | |
|
[ Last edited by wangff on 2008-12-10 at 21:35 |
|
| Floor3 s11ss | Posted 2008-12-09 19:33 |
| 银牌会员 Posts 566 Credits 2,098 | |
|
Brother wangff, could you explain how function 1 of int 16 is used?
|
|
| Floor4 wangff | Posted 2008-12-09 20:58 |
| 初级用户 Posts 54 Credits 134 | |
|
Keyboard Service (Keyboard Service—INT 16H)
Author: anonymous Source: collected and organized by China Self-Study Programming Net Release date: 2007-09-27 00H, 10H — read a character from the keyboard 03H — set repeat rate 01H, 11H — read keyboard status 04H — set keyboard click 02H, 12H — read keyboard flags 05H — push character and its scan code onto the stack (1), Functions 00H and 10H Function description: read a character from the keyboard Input parameters: AH=00H——read keyboard =10H——read extended keyboard, whether the extended keyboard is valid can be judged from the contents of memory location 0000:0496H Output parameters: AH=keyboard scan code AL=character ASCII code (2), Functions 01H and 11H Function description: read keyboard status Input parameters: AH=01H——check standard keyboard =11H——check extended keyboard Output parameters: ZF=1——no character input, otherwise, AH=keyboard scan code, AL=ASCII code. (3), Functions 02H and 12H Function description: read keyboard flags Input parameters: AH=02H——shift flags of the standard keyboard =12H——shift flags of the extended keyboard Output parameters: AL=keyboard flags (valid for both 02H and 12H), when each bit has the value 1, the meanings are as follows: bit 7—INS on state bit 3—ALT key pressed bit 6—CAPS LOCK on state bit 2—CTRL key pressed bit 5—NUM LOCK on state bit 1—left SHIFT key pressed bit 4—SCROLL LOCK on state bit 0—right SHIFT key pressed AH=extended keyboard flags (valid for 12H), when each bit has the value 1, the meanings are as follows: bit 7—SysReq key pressed bit 3—right ALT key pressed bit 6—CAPS LOCK key pressed bit 2—right CTRL key pressed bit 5—NUM LOCK key pressed bit 1—left ALT key pressed bit 4—SCROLL key pressed bit 0—left CTRL key pressed (4), Function 03H Function description: set repeat rate Input parameters: AH=03H For PC/AT and PS/2: AL=05H BH=repeat delay BL=repeat rate For PCjr: AL=00H——load default rate and delay =01H——increase initial delay =02H——halve the repeat frequency =03H——increase delay and halve the repeat frequency =04H——turn off keyboard repeat function Output parameters: none (5), Function 04H Function description: set keyboard click Input parameters: AH=04H AL=00H——turn off keyboard click function =01H——turn on keyboard click function Output parameters: none (6), Function 05H Function description: push character and its scan code onto the stack Input parameters: AH=05H CH=character description code CL=character ASCII code Output parameters: CF=1——operation successful, AL=00H, otherwise, AL=01H |
|
| Floor5 s11ss | Posted 2008-12-09 21:04 |
| 银牌会员 Posts 566 Credits 2,098 | |
|
Sorry, this doesn't count as an explanation, does it? At least give one or two examples to illustrate it :)
|
|
| Floor6 wangff | Posted 2008-12-09 21:28 |
| 初级用户 Posts 54 Credits 134 | |
|
(2), Function 01H
Function description: read keyboard status Input parameters: AH=01H——check standard keyboard Output parameters: ZF=1——no character input, otherwise, AH=keyboard scan code, AL=ASCII code. Not sure whether I made it clear? I type very slowly, please forgive me. |
|
| Floor7 s11ss | Posted 2008-12-09 22:03 |
| 银牌会员 Posts 566 Credits 2,098 | |
|
mov ah,0
int 16 Aren't the two lines above just reading input? Then what is function 1 for? |
|
| Floor8 wangff | Posted 2008-12-09 22:15 |
| 初级用户 Posts 54 Credits 134 | |
Originally posted by s11ss at 2008-12-9 22:03: ah=0: waits for input ah=1: only checks, does not read (it remains in the keyboard buffer), if there is input you still have to use ah=0 to read it out [ Last edited by wangff on 2008-12-9 at 22:17 ] |
|
| Floor9 s11ss | Posted 2008-12-09 22:20 |
| 银牌会员 Posts 566 Credits 2,098 | |
Originally posted by wangff at 2008-12-9 10:15 PM: C:\>debug -a 0B22:0100 mov ah,0 0B22:0102 int 16 0B22:0104 -t AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=0B22 ES=0B22 SS=0B22 CS=0B22 IP=0102 NV UP EI PL NZ NA PO NC 0B22:0102 CD16 INT 16 -p (the input here is a) AX=1E61 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=0B22 ES=0B22 SS=0B22 CS=0B22 IP=0104 NV UP EI PL NZ NA PO NC 0B22:0104 381C CMP ,BL DS:0000=CD - I still think using function 0 is enough [ Last edited by s11ss on 2008-12-9 at 22:22 ] |
|
| Floor10 wangff | Posted 2008-12-09 22:36 |
| 初级用户 Posts 54 Credits 134 | |
|
The example on the 2nd floor:
inc i ::with a parameter (any parameter), wait for one character of input and return it through errorlevel uses only ah=0 But: inc ::without parameters, detect whether there is a keypress; none:errorlevel=0, if yes then errorlevel=key value, can be used to dynamically detect keypresses while running then ah=1 must be used |
|
| Floor11 s11ss | Posted 2008-12-09 22:48 |
| 银牌会员 Posts 566 Credits 2,098 | |
Originally posted by wangff at 2008-12-9 10:36 PM: By no keypress, do you mean directly pressing Enter? If only function 0 is used, then al is 0d |
|
| Floor12 wangff | Posted 2008-12-09 23:02 |
| 初级用户 Posts 54 Credits 134 | |
|
This example shows it: using only ah=0 cannot achieve this effect [ Last edited by wangff on 2008-12-9 at 23:06 ] |
|
| Floor13 s11ss | Posted 2008-12-09 23:30 |
| 银牌会员 Posts 566 Credits 2,098 | |
|
I'll take my time to understand it, much obliged, brother wangff
|
|
| Floor14 s11ss | Posted 2008-12-09 23:59 |
| 银牌会员 Posts 566 Credits 2,098 | |
|
In ecs:100 A0 5D 00 3C 20 75 09 B4 01 CD 16 B8 00 00 74 02 CD 16 B4 4C CD 21 CD 21 CD 21 on the 2nd floor, why are there 3 int 21s?
|
|
| Floor15 wangff | Posted 2008-12-10 08:22 |
| 初级用户 Posts 54 Credits 134 | |
Originally posted by s11ss at 2008-12-9 23:59: Thanks to s11ss for being so careful. They were extra bytes copied from debug. Because of the 16h length limit they weren't saved into inc.com, so they didn't affect usage. I've corrected it. |
|
| 1 2 3 4 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |