中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 关于 批处理中 密码输入隐藏 我老师给出的解释
« [1] [2] [3] [4] »
作者:
标题: 关于 批处理中 密码输入隐藏 我老师给出的解释 上一主题 | 下一主题
bjsh
银牌会员





积分 2000
发帖 621
注册 2007-1-1
状态 离线
『楼 主』:  关于 批处理中 密码输入隐藏 我老师给出的解释

关于那段

  Quote:

  1. : by Herbert Kleebauer
  2. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3. @echo off
  4. echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5x>in.com
  5. set /p password=Enter password:<nul
  6. for /f "tokens=*" %%i in ('in.com') do set password=%%i
  7. pause
  8. del in.com
  9. echo.
  10. echo The Password is:"%password%"
  11. pause
         BJSH发表于:  2007-04-19  08:13

中的
echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5x>in.com
这一句问了一下我的老师;他给我讲解是这样的:我觉得更清楚更容易理解些;
拿出来分享一下

这个例子中的文件名是加了单引号,这就意味着这是一个外部命令,
也就是说,它是要被执行的。

in.com经过反汇编后,代码如下:

00000000: 685031                    push 3150
00000003: 58                        pop ax     ; AX=3150
00000004: 353030                    xor ax,3030 ; AX=0160
00000007: 50                        push ax
00000008: 5B                        pop bx ; BX=0160
00000009: 50                        push ax
0000000A: 5A                        pop dx ; DX=0160
0000000B: 42                        inc dx
0000000C: 42                        inc dx
0000000D: 42                        inc dx  ; DX=0163
0000000E: 666823622323              push 23236223
00000014: 6658                      pop eax ; EAX=23236223
00000016: 662D56406024              sub eax,24604056 ; EAX=FEC321CD
0000001C: 6650                      push eax
0000001E: 665D                      pop ebp ; EBP=FEC321CD
00000020: 66332F                    xor ebp,dword ptr [bx] ; EBP=EBP ^ [0160]
00000023: 66312F                    xor dword ptr [bx],ebp ; [0160]=FEC321CD
                                                            ; +0160 CD
                                                            ; +0161 21
                                                            ; +0162 C3
                                                            ; +0163 FE
其中+0160 与 +0161中的两个字节CD 21反汇编出来就是int 21h指令
+0162中的C3反汇编出来就是ret指令
最后那个+163中的FE是DOS输入功能0Ah的参数(前面的DX=0163就是指向了这个FE),
表示最多允许输入254个字符(包括回车在内)
00000026: 352B2B                    xor ax,2B2B  ; AX=0AE6,其中0Ah是DOS功能号,
                                                  ; E6没有用处
00000029: 7535                      jnz 00000060 ; 这里肯定会发生跳转,相当于jmp 160
0000002B: 78                                     ; 最后的78无用
0000002C: 0D                                     ; 0D与0A是echo时自动
0000002D: 0A                                     ; 产生的回车换行符
程序跳转到160后,就会执行以下指令:
int 21h ; 此时AH=0Ah, DX=0163h, 因此执行DOS的输入功能,
        ; 输入内容自动保存到+165开始的缓冲区中,而for循环会把各个字符逐个读出
ret     ; 程序返回到操作系统,自动结束

总结一下,这个in.com的作用是通过键盘输入一串字符,长度不超过254个(含回车)。
这个批处理还是比较巧妙的,它用一串可显示的字符串构造了一个可执行代码,实现了
键盘输入功能,配合for循环使得在批处理中可以实现不回显输入。

P.S.: 根据分析,这个批处理中的echo语句所包含的一堆乱码里的最后
      那个字符(即>前面++u5x中的x)可以删除不要。也可就是说,
          echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5x>in.com
      可以改成
          echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5>in.com

   此帖被 +14 点积分     点击查看详情   
评分人:【 vkill 分数: +2  时间:2007-4-20 01:35
评分人:【 estar 分数: +4  时间:2007-4-20 01:59
评分人:【 lxmxn 分数: +4  时间:2007-4-26 01:49
评分人:【 不得不爱 分数: +5  时间:2007-10-16 18:17
评分人:【 mmfy 分数: -1  时间:2009-7-27 03:42


2007-4-19 21:25
查看资料  发送邮件  发短消息 网志   编辑帖子
sisos
初级用户





积分 20
发帖 10
注册 2007-4-15
状态 离线
『第 2 楼』:  

虽然看了有点晕,但是基本理解了是怎么一回事,谢谢lz

2007-4-19 23:32
查看资料  发送邮件  发短消息 网志   编辑帖子
htysm
高级用户




积分 866
发帖 415
注册 2005-12-4
状态 离线
『第 3 楼』:  

强。



欢迎你到批处理爱好者联盟QQ群:18023953
2007-4-20 00:26
查看资料  发送邮件  发短消息 网志   编辑帖子
wydos
中级用户





积分 304
发帖 117
注册 2006-4-4
状态 离线
『第 4 楼』:  

强!不过还是看不懂!

2007-4-20 01:00
查看资料  发送邮件  发短消息 网志  OICQ (327337973)  编辑帖子
estar
中级用户





积分 346
发帖 103
注册 2004-4-6
状态 离线
『第 5 楼』:  

来晚了,加分顶!

2007-4-20 02:00
查看资料  发送邮件  发短消息 网志   编辑帖子
hulongzhuo
中级用户




积分 294
发帖 135
注册 2007-3-9
状态 离线
『第 6 楼』:  

不错,正要这样一个代码!!!!

2007-4-20 04:26
查看资料  发短消息 网志   编辑帖子
13579246810
初级用户





积分 45
发帖 21
注册 2007-3-14
状态 离线
『第 7 楼』:  

感激 涕零 !!太伟大了!

2007-4-20 06:22
查看资料  发送邮件  发短消息 网志   编辑帖子
flyinspace
银牌会员





积分 1206
发帖 517
注册 2007-3-25
状态 离线
『第 8 楼』:  



  Quote:
Originally posted by bjsh at 2007-4-19 08:25 AM:
关于那段

中的
echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5x>in.com
这一句问了一下我的老师;他给我讲解是这样的:我觉得更清楚更容易理解些;
拿出来分 ...

哦。这个倒是明白。。。

不过没还要他想得巧妙:)汇编高手来着呢。



知,不觉多。不知,乃求知
2007-4-20 07:23
查看资料  发短消息 网志   编辑帖子
zqz0012005
中级用户




积分 297
发帖 135
注册 2006-10-21
状态 离线
『第 9 楼』:  

我靠!echo还有这等功能!

2007-4-20 07:49
查看资料  发短消息 网志  OICQ (411976538)  编辑帖子
caucfeiyu
初级用户




积分 108
发帖 35
注册 2007-4-12
来自 河北廊坊
状态 离线
『第 10 楼』:  

新手啊,看不懂!还得继续学习啊!学无止境啊!

2007-4-24 09:46
查看资料  发送邮件  发短消息 网志   编辑帖子
yzshde007
新手上路





积分 5
发帖 3
注册 2007-3-25
状态 离线
『第 11 楼』:  

呵呵 ``没有永远的绝对``我相信我能超过你``

2007-4-25 23:44
查看资料  发送邮件  发短消息 网志   编辑帖子
lxmxn
版主




积分 11386
发帖 4938
注册 2006-7-23
状态 离线
『第 12 楼』:  

不错,终于可以解释那一段是什么原理了。

我想以后一些批处理不能完成的简单功能的汇编代码,如果都为ASCII码中可显示字符,应该都可以用这个方法来构造吧。

2007-4-26 01:52
查看资料  发送邮件  发短消息 网志   编辑帖子
wert123
中级用户





积分 301
发帖 135
注册 2007-5-15
状态 离线
『第 13 楼』:  

厉害啊~~~

[ Last edited by wert123 on 2007-6-2 at 10:25 AM ]

2007-6-2 10:22
查看资料  发短消息 网志   编辑帖子
qzwqzw
银牌会员

天的白色影子


积分 2342
发帖 635
注册 2004-3-6
状态 离线
『第 14 楼』:  

这里是usenet上关于in.com的讨论
其中提到了in.com的源码
可惜是摩托罗拉的汇编代码
看起来是有些费劲

  Quote:
===== dd9d6451a63628c6 - 067a017af143d6a8 =====
===== alt.msdos.batch.nt - need no echo for set /p - Mon, Nov 24 2003 9:40 =====


Uno wrote:
> > @echo off
> > echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5>in.com
> > set  /p password=Enter password:<nul
> > for /f "tokens=*" %%i in ('in.com') do set password=%%i
> > del in.com
> > echo.
> > echo The Password is:"%password%"

> It doesn't work,the first character echoed is

What doesn't work? It works fine here in W2k.

> This works:

Let's take a look at your source:

        @=$100
        br.w    start                ; a short branch would be sufficient, but
                                     ; you wouldn't need the branch instruction
                                     ; at all if you would put the data behind the code

handle: dc.w    0                    ; you don't need this variable
fil:    dc.b    "c:\temp\oihjs",0    ; why do you need this file, write to stdout

sor:    blk.b   120,0                ; 120 needles bytes in your code

start:  move.w   #fil,r1
        eor.w    r2,r2
        move.b   #$3c,m0
        trap     #$21                ; how about testing the carry flag for errors?
                                     ; why don't save the handle
        move.w   #0,r5
pro:    move.b   #$07,m0
        trap     #$21
        cmp.b    #$0d,r0
        beq.b    fin
        move.b   r0,sor(r5.w)        ; why not test for buffer overflow (>120 characters)
        inc.w    r5
        br.b     pro

fin:    move.w   #fil,r1
        move.b   #2,r0
        move.b   #$3d,m0             ; you have already opend the file with fct 0x3c
        trap     #$21                ; why do you open it again?
        move.w   r0,handle           ; why not just put the handle in BX
        move.w   #sor,r1
        move.w   handle,r3
        move.w   #38,r2              ; why do you write 38 bytes to the file? write
        move.b   #$40,m0             ; exactly as many bytes as read in the loop above
        trap     #$21
        move.b   #$4c,m0             ; if you don't use the return code a simple ret is
        trap     #$21                ; shorter

> echo Enter password
> pass.com
> set /p a=<c:\temp\oihjs

Write to stdout in pass.com (there is no need to generate a
temporary file) and use:

for /f "tokens=*" %%i in ('pass.com') do set a=%%i
> echo Password is %a%
> del c:\temp\oihjs
> del pass.com



===== 64caaf380175e875 - 10adb2216a0e63ab =====
===== alt.msdos.batch.nt - New Project: Creating a web form to make a batch file execute on ausers machine? - Thurs, Jan 16 2003 11:37 =====


Musafir wrote:

> Herbert Kleebauer <k...@unibwm.de> wrote in message <news:3E266907.56E09070@unibwm.de>...

> > @echo off
> > echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5>in.com
> > set  /p password=Enter password:<nul
> > for /f "tokens=*" %%i in ('in.com') do set password=%%i
> > del in.com
> > echo.
> > echo The Password is:"%password%"

> How does that work?? in.com is a program that takes the user input
> without echo-ing it to the console? I also noticed that changing the
> variable 'password' to 'pass' causes the script to fail.

in.com just writes the typed text to stdout. Whether you name the
variable password or pass doesn't matter at all. What do you mean
with the script fails?


> I guess the crux of the question is, how do you get to that crazy
> stream of characters for in.com?

in.com is a 5 line assembler program:

        move.b  #$0a,m0
        move.w  #buf,r1
        trap    #$21
        rts.w
buf:    dc.b    80

The same code with opcodes in the ascii range (so you can use the
echo command to dynamically generate it) is a little bit longer:

        move.w  #$160^$3030,-(sp)
        move.w  (sp)+,r0
        eor.w   #$3030,r0
        move.w  r0,-(sp)
        move.w  (sp)+,r3
        move.w  r0,-(sp)
        move.w  (sp)+,r1
        inc.w   r1
        inc.w   r1
        inc.w   r1
        move.l  #$23236223,-(sp)
        move.l  (sp)+,r0
        sub.l   #$24604056,r0
        move.l  r0,-(sp)
        move.l  (sp)+,r4
        eor.l   (r3.w),r4
        eor.l   r4,(r3.w)
        eor.w   #$2b2b,r0
        bne.b   $160


===== 6366179533ac8f8f - 3d2c548f8a5ee250 =====
===== comp.os.msdos.misc - Password input.... - Fri, Oct 4 2002 1:18 =====


Philip Harris wrote:

> I have spent a short while trying to get an NT/dos batch file to
> prompt for and get a password (without coughing it to the screen)
> I'm newly returned to dos programming from many years as a Unix
> scripting expert (if it can't be done in sed it can't be done!)
> so when I noticed that everyone seems to write/call/delete temporary
> like there's no tomorrow I was a bit saddened (what happens if two
> people are running the same thing at the same time...)  So I took
> a long look at the web,applied my devious mind and came up with
> the following.

All this debug code just because you are worried about
temporary files? Here a solution with a temporary file (in.com):

@echo off
echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5>in.com
set  /p password=Enter password:<nul
for /f "tokens=*" %%i in ('in.com') do set password=%%i
del in.com
echo.
echo The Password is:"%password%"


===== 12b5947a81662410 - 481fa996c5f6ca92 =====
===== alt.msdos.batch.nt - Hiding Password input from user - Thurs, May 2 2002 3:35 =====


Eric wrote:

> I have a script I use in Win2K which will accept input from a user,
> and I have used it for numerous things in the past.  However, now I
> have an implimentation which requires a user to input thier password.
> What I would like to do, is at the point where the user is inputing
> the password, hide that output from the screen.  Either by masking it,
> or hiding it all together.  Any suggestions???

@echo off
echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5>in.com
set  /p password=Enter password:<nul
for /f "tokens=*" %%i in ('in.com') do set password=%%i
del in.com
echo.
echo The Password is:"%password%"

::
:: The source code:
::
::        @=$100
::        move.w  #$160^$3030,-(sp)
::        move.w  (sp)+,r0
::        eor.w   #$3030,r0
::        move.w  r0,-(sp)
::        move.w  (sp)+,r3
::        move.w  r0,-(sp)
::        move.w  (sp)+,r1
::        inc.w   r1
::        inc.w   r1
::        inc.w   r1
::        move.l  #$23236223,-(sp)
::        move.l  (sp)+,r0
::        sub.l   #$24604056,r0
::        move.l  r0,-(sp)
::        move.l  (sp)+,r4
::        eor.l   (r3.w),r4
::        eor.l   r4,(r3.w)
::        eor.w   #$2b2b,r0
::        bne.b   $160


===== 1c25426d9a8ab4b6 - 4ab6d4497df2d023 =====
===== alt.lang.asm - Ad-hoc Parsing? - Wed, Dec 29 2004 5:23 =====


Phil Carmody wrote:
> Herbert Kleebauer <k...@unibwm.de> writes:
> > The whole sub thread is about the statement, that batch scripting in
> > DOS/Windows is at least as flexible as csh/sh/bash scripting in
> > Unix/Linux.
> Therefore
> if people (T.M., Robert, myself) have been discussing the unix
> shell without explicitly mentioning an OS, that means they have been making
> statements _strictly_ about just the shell itself.

Maybe you should switch from your write only mode to read mode.
The discussion was about Linux compared to Windows:

  +---------------------------------------------------------------------
  | From: "T.M. Sommers" <t...@nj.net>
  | Subject: Re: [ Attn: Randy ] Ad-hoc Parsing?
  | Date: Thu, 16 Dec 2004 18:38:13 GMT
  |
  | > and this is exactely where Linux completely fails,
  | > and why almost no real final users want to use it.
  |
  | Linux has plenty of users; so does BSD.
  |
  | There are more people in the world than grannies and tots.  If
  | you are aiming your OS at grannies and tots, then obviously it
  | must be usable by them, but if you are aiming your OS at people
  | who want to get real work done, then you have different
  | requirements.  One of the biggest advantages of Unix-like shells
  | is that they allow the user to do things that the creator of the
  | shell never imagined.
  +---------------------------------------------------------------------

The statement in the above posting is, that the command
line interface in Unix is more powerful and flexible than
the command line interface in Windows, because of the much
better Unix-like shells (sh, csh, bash, ...) used in Unix/Linux
compared to the command.com/cmd.exe shells in DOS/Windows.

My answer was, that scripts in DOS/Windows (using the less
powerful shells command.com or cmd.exe) are at least as
flexible as the Unix scripts using the more powerful
Unix-like shells, because they can extend their abilities
by directly including CPU instructions (because of the
header free .com file format).

Your statement: "It (bash) can execute the .com file as
easily as a command.com or cmd.exe batch file can", can
in the above context only be interpreted as "It (bash
in Unix) can ....". This is simple wrong. Then you changed
your mind and said, that you meant "It (bash in Windows) can ...".
This simple doesn't make any sense in the above context.

When I say, that, despite the less powerful Windows shells,
Windows scripting is as flexible as Unix scripting because
of the ability to include CPU instructions, then it doesn't
make any sense to say, bash in Windows can also include
CPU instructions and therefore bash scripts (in Windows)
are at least as flexible as bash scripts (in UNIX).

> > The reason is, that there is a header free executable
> > file format in DOS/Windows which makes it possible to directly
> > embed cpu instructions within a DOS/Windows batch script.

> WRONG. For fuck's sake, Herbert, evolve. Your logic is just plain crap.
> Therefore you cannot logically say that
> the existence of .COM files "makes it possible to" do anything
> of the sort.

I never said this. I said, it "makes it practicable". I have
a whole collection of such small com programs (which consist of
a few echo lines only) which I include in batch files. But I would
never have done this, if I had to include Win32 exe files. It
also would be possible, but it is impractical.

> > The statement "It (bash) can execute the .com file as easily as
> > a command.com or cmd.exe batch file can" without the addition
> > "when bash is used in DOS/Windows" is not true. If it were true,
> > than bash used with any operating system had to be able to execute
> > .com files.

> Nope - it was a comparison of one scripting language to another
> scripting language. I make no reference to the OS it is running
> on; you ASSume that bash runs only under unix. I'm not going to
> feel guilt that you are ignorant that bash runs under MS windows
> too.

Something with your logic must be wrong. Command.com and cmd.exe
are bound to DOS/Windows, therefore a command/cmd script can
always initiate the execution of .com program (it doesn't
execute the com program itself). Bash is not bound to DOS/Windows,
so bash can't always initiate the execution of .com program. Only
when used in DOS/Windows, bash also can start a .com program.
Therefore the statement "It (bash) can execute the .com file
as easily as a command.com or cmd.exe batch file can" simple
is wrong.

> I repeatedly made statements about bash. You interpreted them
> to only refer to bash on unix. Your mistake. Get over it.

The same mistake. You didn't make statements about bash, but
about bash in Windows. A statement about bash has to be true
independent of the operating system.  

> > echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5>in.com
> > is nothing but this CPU instructions:
> > And this is possible because of the .com file format.

> Rearrange the following 5 letters to make a word - WRNOG.
> If it's possible in unix to create ELF binaries using sh, then it (the
> ability to drop small executables) _cannot_ be "because of the .com file
> format".

You really should start to read: "is NOTHING but this CPU instructions".
Now show me your elf binary which "is NOTHING but this CPU instructions"

> > > I can't live without features like independent stdout/stderr
> > > redirecting and ${//} in bash, and the powerful single and double
> > > quoting rules in all sensible unix shells, so I certainly can say
> > > that I need the additional flexibility that bash gives me.

> > Sorry, but that is "functionality" but not "flexibility". I never
> > said, that bash isn't much more powerful than comannd.com/cmd.exe.

> > In this sub thread  "flexibility" was defined by:

> > "T.M. Sommers" wrote:

> > > One of the biggest advantages of Unix-like shells
> > > is that they allow the user to do things that the creator of the
> > > shell never imagined.

> That is a statement about shells.

Yes, about the flexibility of a shell but you are speaking about the
functionality of shell.


> > Now let's make a little test how flexible bash is. Let us do
> > something which "the creator of the shell never imagined"
> > (maybe the creator of the bashl had imagined this, so it is build
> > into bash already, then we will have to find another example).

> OK, you're still talking about shells. Excellent, you've stayed
> on topic for a whole paragraph.

I'm always on topic. And on topic here means bash in Unix, not
bash in Windows.

> > Here a solution for DOS/Windows which don't even use the
> > advanced features of cmd.exe so it can also be executed
> > in pure DOS.
> > Now show us a much easier solution using bash/Linux.

> What the _fuck_ has linux got to do with a comparison between shells?

Because this whole sub thread is about scripting in Unix/Linux
using Unix-lile shells compared to scripting in Windows using
command.com/cmd.exe.


> -- 8< --------------------------------------------------------------------
> #!/bin/sh
> umask 0
> rm -f y_n.com
> echo -e 'Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=\r'>y_n.com
:
> -- 8< --------------------------------------------------------------------
> So, what was the flexibility advantage that batch files have over
> bash scripts again?

That will run only in DOS/Windows but we are speaking about
the flexibility of unix-like scripts in Unix. Come on, you
told us:
          > Is 45 bytes not a small enough ELF executable for you?

and this is an assembly group, so use your assembly skills and show
us how easy it is to extend the ability of bash in Linux to allow
a mouse click on a YES and NO button. As I have shown, 7 echo lines
are sufficent in a DOS batch script (no extrnal program needed).

> You're ->this<- close to joining
> The_Sage and alex the yepper in the killfile.

After the logic you have presented in this thread, I'm not sure
whether you are not The_Sage.


===== 3be1f9dcb404d3c0 - bf942de44bb610da =====
===== alt.msdos.batch.nt - masking passwords - Sun, Aug 4 2002 11:29 =====


ian wrote:

> I have a script which requires the user to enter a password, How would
> I stop the password from being displayed on the screen. I have been
> able to do this in windows 95\98\ME but the script doesn't seem to
> work the same in NT\2k\XP and I'm not quite sure why. Any help would
> be appreciated

In 2k/XP you can use the following (in NT you have to replace the
"set /p" line by "echo Enter password"):

@echo off
echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5>in.com
set  /p password=Enter password:<nul
for /f "tokens=*" %%i in ('in.com') do set password=%%i
del in.com
echo.
echo The Password is:"%password%"

::
:: The source code:
::
::        @=$100
::        move.w  #$160^$3030,-(sp)
::        move.w  (sp)+,r0
::        eor.w   #$3030,r0
::        move.w  r0,-(sp)
::        move.w  (sp)+,r3
::        move.w  r0,-(sp)
::        move.w  (sp)+,r1
::        inc.w   r1
::        inc.w   r1
::        inc.w   r1
::        move.l  #$23236223,-(sp)
::        move.l  (sp)+,r0
::        sub.l   #$24604056,r0
::        move.l  r0,-(sp)
::        move.l  (sp)+,r4
::        eor.l   (r3.w),r4
::        eor.l   r4,(r3.w)
::        eor.w   #$2b2b,r0
::        bne.b   $160


===== 9d94049fbdc871f7 - d6c02181c6d79618 =====
===== comp.os.msdos.programmer - DOS debug.exe and 16-bit I/O? - Fri, Oct 28 2005 7:45 =====


Scuch wrote:
> Now i know there's a less simple way to do it: use Debug to assemble a
> tiny program.  But im trying to avoid this solution, or installing any
> third-party software.  Part of the idea is the ability to tell a
> customer over the phone to just pull up a command prompt and read bytes
> back to me if they ever have a problem.

And why don't you give the customer a "first-party software" written
by yourself? All you need is a in instruction and a simple output
routine. If you don't want to use a binary you can also use a batch
file. Here an example of a simple byte IO (you have to modify it, if
you want word IO):

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>in.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>in.com
echo ?@}IIHpkg~K=H?U_PgRN@k?k?GzBNEr@NWbMs?Qm`LKLFQp{@PEKH@`Qpk>>in.com
echo w@CI?J_KE@qo{Oe{\O{Xv@EuxCq`{SfkP?@oko@CaBEFANO@PrTj@{Pe~r>>in.com
echo ?B@K?B?K0x>>in.com

::in.com 8 379
::echo %errorlevel%

in.com 7 379
if not errorlevel 1 echo busy=0
if     errorlevel 1 echo busy=1
in.com 6 379
if not errorlevel 1 echo ack=0
if     errorlevel 1 echo ack=1
in.com 5 379
if not errorlevel 1 echo pe=0
if     errorlevel 1 echo pe=1
in.com 4 379
if not errorlevel 1 echo slct=0
if     errorlevel 1 echo slct=1
in.com 3 379
if not errorlevel 1 echo error=0
if     errorlevel 1 echo error=1
in.com 2 379
if not errorlevel 1 echo NUL=0
if     errorlevel 1 echo NUL=1
in.com 1 379
if not errorlevel 1 echo NUL=0
if     errorlevel 1 echo NUL=1
in.com 0 379
if not errorlevel 1 echo NUL=0
if     errorlevel 1 echo NUL=1

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

The source:

; 5.11.04 in hex1 hex2
; read bit hex1 from inport hex2 to errorlevel (0-1)
; if hex1>7 erorlevel is set to read byte (0-255)

        @=$100

        move.w  #$81,r5
        eor.w   r2,r2
        move.b  -1.b(r5.w),r2
        bsr.w   get_hex
        move.w  r1,r3
        bsr.w   get_hex
        in.b    r1,r0
        cmp.w   #8,r3
        bhs.b   _10
        btst.w  r3,r0
        scs.b   r0
_10:    move.b  #$4c,m0
        trap    #$21

get_hex:
        eor.w   r1,r1
        move.w  #_10,_200
_10:    dec.w   r2
        bmi.b   _30
        eor.w   r0,r0
        move.b  (r5.w),r0
        inc.w   r5
        or.b    #$20,r0
        cmp.b   #'0',r0
        blo.b   _20
        cmp.b   #'f',r0
        bhi.b   _20  
        cmp.b   #'9',r0
        bls.b   _40
        cmp.b   #'a',r0
        blo.b   _20
        sub.b   #'a'-'9'-1,r0
_40:    sub.b   #'0',r0
        lsl.w   #4,r1
        add.w   r0,r1
        move.w  #_30,_200
        br.b    _10
_20:    jmp.w   (_200)
_30:    rts.w
_200:   dc.w    0



2007-6-2 10:37
查看资料  发短消息 网志   编辑帖子
tyh
初级用户





积分 80
发帖 43
注册 2007-4-21
状态 离线
『第 15 楼』:  

后面的看懵了。

2007-6-2 11:29
查看资料  发送邮件  发短消息 网志   编辑帖子
« [1] [2] [3] [4] »
请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: