Originally posted by s11ss at 2008-12-9 22:48:
By no keypress, do you mean directly pressing Enter? If only function 0 is used, then al is 0d
No keypress means not touching the keyboard at all.
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
DigestI
View 15,156 Replies 45
Originally posted by s11ss at 2008-12-9 22:48:
By no keypress, do you mean directly pressing Enter? If only function 0 is used, then al is 0d
| Rater | Score | Time |
|---|---|---|
| s11ss | +7 | 2008-12-10 14:53 |
Originally posted by 本是 at 2008-12-10 14:31:
In the program above, mov ax,0 is 3 bytes long. Changing it to mov ah,0 or xor ah,ah or sub ah,ah saves 1 byte.
Actually, the shortest program of this kind only needs 8 bytes.
DEBUG
a
mov ah,0
int 16h
mov ah,4Ch
...
@echo off
call inc 2>nul
if %errorlevel%==1 (
>inc.src echo ecs:100 B8 00 01 CD 16 B8 00 00 74 02 CD 16 B4 4C CD 21
>>inc.src echo rcx
>>inc.src echo 10
>>inc.src echo w
>>inc.src echo q
debug inc.com < inc.src 2>nul 1>nul
del inc.src
)
:loop
inc
echo %errorlevel%
if not %errorlevel%==0 (
if %errorlevel%==81 goto :eof ::q or Q exit
if %errorlevel%==113 goto :eof
)
ping -n 2 127.1>nul
goto loopOriginally posted by s11ss at 2008-12-10 14:55:
What I mean is not using function 1 of int 16h, and it seems it still works~
Actually it seems you don't need to write a com either, you can call it directly with debug :)
a
MOV AX,0100
INT 16
MOV AX,0000
JZ 010C
INT 16
MOV AH,4C
INT 21
g
q@echo off
:loop
debug <c.txt>nul
echo %errorlevel%
if not %errorlevel%==0 (
if %errorlevel%==81 goto :eof ::q or Q exit
if %errorlevel%==113 goto :eof
)
ping -n 2 127.1>nul
goto loopa
mov ah,0
int 16
mov ah,4C
int 21
g
q@echo off
:loop
debug <a.txt>nul
echo %errorlevel%
if not %errorlevel%==0 (
if %errorlevel%==81 goto :eof ::q or Q exit
if %errorlevel%==113 goto :eof
)
ping -n 2 127.1>nul
goto loop
goto :main
a
;MOV AX,0100
;INT 16
MOV AX,0000
;JZ 010C
INT 16
MOV AH,4C
INT 21
g
q
:main
@echo off
:loop
debug <"%~f0">nul
echo %errorlevel%
if not %errorlevel%==0 (
if %errorlevel%==81 goto :eof ::q or Q exit
if %errorlevel%==113 goto :eof
)
ping -n 2 127.1>nul
goto loop
@echo off
goto main
a
MOV AL,
CMP AL,20
JNZ 0110
MOV AH,01
INT 16
MOV AX,0000
JZ 0112
INT 16
MOV AH,4C
INT 21
g
q
:main
chcp 437|graftabl 936>nul
set/p =input:<nul
::with a parameter (any parameter), wait for one character of input and return it through errorlevel
debug a.com i<"%~f0">nul 2>nul
echo %errorlevel%
:loop
::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
debug<"%~f0">nul
echo %errorlevel%
if not %errorlevel%==0 (
if %errorlevel%==81 goto :eof ::q or Q exit
if %errorlevel%==113 goto :eof
)
ping -n 2 127.1>nul
goto loop| Rater | Score | Time |
|---|---|---|
| zh159 | +20 | 2008-12-11 09:31 |
@echo off
goto main
a
MOV AL,
CMP AL,20
JNZ 0110
MOV AH,01
INT 16
MOV AX,0000
JZ 0112
INT 16
MOV AH,4C
INT 21
g
q
:main
chcp 437|graftabl 936>nul
set/p =Waiting...<nul&set/a n=0
:loop
set/a n+=1
set/p =.%n%<nul
debug<"%~f0">nul
if not %errorlevel%==0 (
if %errorlevel%==81 goto :eof ::q or Q exit
if %errorlevel%==113 goto :eof
)
if %n% gtr 5 goto p1
ping -n 2 127.1>nul
goto loop
:p1
echo.
echo Time's up, run automatically!
pause| Rater | Score | Time |
|---|---|---|
| Helloworld | +1 | 2008-12-11 13:19 |