:這是我得到告訴現在我怎樣才能得到這個程序:單數字替代加密? (一個由1ž分至26)
include emu8086.inc
DEFINE_GET_STRING
; 'abcdefghijklmnopqrstvuwxyz'
jmp start
buffer db " ",0dh,0ah,'$'
size = $ - offset buffer ; declare constant
table2 db 'abcdefghijklmnopqrstvuwxyz'
table1 db 97 dup (' '), 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26
start:
lea di, buffer ; buffer offset.
mov dx, size ; buffer size.
call get_string
putc 0dh
putc 0ah
; encrypt:
lea bx, table1
lea bp, di
call parse
; show result:
;lea dx, di
; output of a string at ds:dP
putc 0ah
putc 0dh
; decrypt:
lea bx, table2
lea bp,di
call hamdy
; show result:
call print_string
; wait for any key...
mov ah, 0
int 16h
ret ; exit to operating system.
; subroutine to encrypt/decrypt
; parameters:
; si - address of string to encrypt
; bx - table to use.
parse proc near
osama:
cmp [bp] , '$' ; end of string?
je end_of_string
mov al, [bp]
cmp al, 'a'
jb skip
cmp al, 'z'
ja skip
; xlat algorithm: al = ds:[bx + unsigned al]
xlatb ; encrypt using table2.
mov [bp], al
mov ah,0
call print_num_uns
skip:
inc bp
jmp osama
end_of_string:
ret
parse endp
hamdy proc near
osama_1:
cmp [bp] , '$' ; end of string?
je end_of_string_1
mov al, [bp]
cmp al, 1
jb skip_1
cmp al, 26
ja skip_1
; xlat algorithm: al = ds:[bx + unsigned al]
xlatb ; encrypt using table2.
mov [bp], al
mov ah,0
skip_1:
inc bp
jmp osama_1
end_of_string_1:
ret
hamdy endp
DEFINE_PRINT_NUM_UNS
DEFINE_PRINT_STRING
end
這個問題可以通過解釋你所嘗試的以及你在哪裏遇到麻煩來改進。 – ComputerDruid 2014-12-11 01:00:33