Caesar Cipher程序未将输出写入屏幕

问题描述 投票:-1回答:1

我正在尝试使用汇编编写凯撒密码程序。没有错误,但运行时不显示任何内容,并且以静默方式退出。这是我写的。

.MODEL small
.STACK 64
.DATA

  ORG     0000h            ;Start of code   
  MSG1 DB "Please input your string [Max 15 chars]: $"
  int 21h
  KEY1 DB "Please input your required shift  [RANGE 0 -F]: $"
  MSG2 DB "YOUR ENCRYPTED MESSAGE  IS : $"
  ErrorKey DB "Key Value out of range-please renter it range 0-F : $"
  STR1 DW 15 DUP('$') ;store plain text
  KEYV DB ?  ;to store the value of the key 
  STR2 DW 15 DUP(?); store encrypted message

.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX

;to display message 1 
MOV DX, OFFSET MSG1
MOV AH,09H
INT 21H               

;now the user enters the message
mov ax, 0000h
int 16h

mov ax, 0000h ; This key press it just to pause the program so you can see.
Int 16h       ; that you can’t see your own input
mov STR1,ax ;moving the message to be stored in str1

;to display Key message 
MOV DX, OFFSET KEY1
MOV AH,09H
INT 21H           


;now the user enters the key
KEY:
mov al, 0000h
int 16h

mov ax, 0000h ; This key press it just to pause the program so you can see.
Int 16h       ; that you can see your own input
mov KEYV,al ;moving the message to be stored in KEYV        


;now checking that the value of the key is within the correct range
CHECK: 
CMP KEYV,0FH  ;
JG show;       if value greater than F go to show
CMP KEYV,10H  ; if value below or equal F go to encrypt
JB ENCRYPT ; 

show:   
;to display Error Key message 
MOV DX, OFFSET ErrorKey
MOV AH,09H
INT 21H           
;restore the key value         
Jp KEY



 ENCRYPT:   MOV SI,OFFSET STR1  ;put the message in SI
            MOV BL,KEYV
            MOV DI,OFFSET STR2 
            MOV CX,15   

 ENCPROCESS:             
            MOV AL ,BYTE PTR[SI]  ;move first byte of PT in AL
            ADD  AL,BL   ;37 Add to it the key value
            MOV [DI],AL;     ;store the encrypted byte in DI
            INC SI 
            INC DI
            LOOP ENCPROCESS 


 ;to display encrypted message
MOV DX, OFFSET STR2
MOV AH,09H
INT 21H   




MAIN ENDP
END MAIN

我在做什么错?

我正在尝试使用汇编编写凯撒密码程序。没有错误,但运行时不显示任何内容,并且以静默方式退出。这是我写的。.MODEL小.STACK 64 .DATA ...

assembly encryption emulation x86-16
1个回答
0
投票

在其中放置断点/逐节调试以缩小问题的范围

© www.soinside.com 2019 - 2024. All rights reserved.