在装配code字符串缓冲区 [英] String buffer in assembly code

查看:178
本文介绍了在装配code字符串缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚已经结束我的code,允许以支付密码。它是这样的(FASM):

I just have ended my code which allow to cover your password. It goes like this(FASM):

org 100h

mov cx, 16

petla:
mov ah,08h
int 21h
cmp al,0dh
je OK
mov ah,02h
mov dl,42
int 21h

cmp cx,0
je Fail
loop petla

Fail:

mov dl, 0ah
int 21h
mov dx, pass2
mov ah,9
int 21h
jmp koniec

OK:

mov dl, 0ah
int 21h
mov dx, pass
mov ah,9
int 21h
jmp koniec


koniec:
mov ah,4ch
int 21h

pass db 'Password OK', 0Ah, 0Dh, '$'
pass2 db 'Password Fail', 0Ah, 0Dh, '$'

现在我需要打印真正的密码。我知道这个字符串缓冲区是必须的,以及如何缓冲的声明应该看起来像,但我真的不知道如何使用它,并使它发挥作用。
呼救:)
干杯。

And now I need to print the genuine password. I know the string buffer is a must and how declaration of the buffer should look like but I don't really know how to use it and make it work. Calling for help :) Cheers.

推荐答案

由于您的程序允许的 15个字符的密码,你可以设置缓冲区与输入:

Since your program allows the input of 15 characters of password, you could setup the buffer with:

Buffer db 16 dup ("$")

您初始化DI您的 petla 的循环之前注册,并把ASCII code你通过 STOSB 说明:

You initialize the DI register before your petla loop and put the ASCII code you got from the DOS function in the buffer via a stosb instruction:

  mov  di, Buffer
  mov  cx, 16
petla:
  mov  ah,08h
  int  21h
  cmp  al,0dh
  je   OK
  stosb
  mov  ah,02h
  mov  dl,42
  int  21h
  ;;;cmp cx,0
  ;;;je Fail
  loop petla

请注意,对于compairing CX = 0是没有用的仅仅是循环之前指令在code。

Please note that compairing for CX=0 is useless just before the loop instruction in your code.

这篇关于在装配code字符串缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆