从键盘上接受两个4位十六进制数,在下一行以二进制形式输出两数的异或的结果。并将此二进制数的结果中的第3到第0与第15位到第12位对调,再以十六进制输出!
终于自己搞定了。论坛里问不出这样的程序啊!
data segment
newline db 0dh, 0ah, '$'
top1 db 'the first word(minuscule):', '$'
top2 db 'the second word(minuscule):', '$'
;the first word:abcd
a db ?
b db ?
c db ?
d db ?
;the second word:efgk
e db ?
f db ?
g db ?
h db ?
;the temp varivable
i db ?
j db ?
k db ?
l db ?
;save the xor result
m db ?
n db ?
o db ?
p db ?
data ends
code segment
assume cs:code, ds:data
start: mov ax , data
mov ds , ax
;**************top1
mov dx, offset top1
mov ah, 9
int 21h
;***********enter a
mov ah, 1
int 21h
mov ah, 'a'
cmp ah, al
jna Fun0
jnc Fun1
Fun0:sub al, 57h
jnc NEXT0
Fun1:sub al, 30h
NEXT0:mov a, al
;***********enter b
mov ah, 1
int 21h
mov ah, 'a'
cmp ah, al
jna Fun2
jnc Fun3
Fun2:sub al, 57h
jnc NEXT1
Fun3:sub al, 30h
NEXT1:mov b, al
;***********enter c
mov ah, 1
int 21h
mov ah, 'a'
cmp ah, al
jna Fun14
jnc Fun15
Fun14:sub al, 57h
jnc NEXT2
Fun15:sub al, 30h
NEXT2:
mov c, al
;***********enter d
mov ah, 1
int 21h
mov ah, 'a'
cmp ah, al
jna Fun4
jnc Fun5
Fun4:sub al, 57h
jnc NEXT3
Fun5:sub al, 30h
NEXT3:
mov d, al
;**************newline
mov dx, offset newline
mov ah, 9
int 21h
;**************top2
mov dx, offset top2
mov ah, 9
int 21h
;***********enter e
mov ah, 1
int 21h
mov ah, 'a'
cmp ah, al
jna Fun6
jnc Fun7
Fun6:sub al, 57h
jnc NEXT4
Fun7:sub al, 30h
NEXT4:
mov e, al
;***********enter f
mov ah, 1
int 21h
mov ah, 'a'
cmp ah, al
jna Fun8
jnc Fun9
Fun8:sub al, 57h
jnc NEXT5
Fun9:sub al, 30h
NEXT5:
mov f, al
;***********enter g
mov ah, 1
int 21h
mov ah, 'a'
cmp ah, al
jna Fun10
jnc Fun11
Fun10:sub al, 57h
jnc NEXT6
Fun11:sub al, 30h
NEXT6:
mov g, al
;***********enter h
mov ah, 1
int 21h
mov ah, 'a'
cmp ah, al
jna Fun12
jnc Fun13
Fun12:sub al, 57h
jnc NEXT7
Fun13:sub al, 30h
NEXT7:
mov h, al
;**********the newline
mov dl, offset newline
mov ah, 9
int 21h
;******xor function
mov al, a
mov bl, e
xor al, bl
mov m, al
mov bl, 2
;****enhance the ah
mov ah, 0
div bl
mov i, ah
;****can use the for
mov ah, 0
div bl
mov j, ah
mov ah, 0
div bl
mov k, ah
mov l, al
;pirnt (a xor e) the binary
mov dl, l
add dl, 30h
mov ah, 2
int 21h
mov dl, k
add dl, 30h
mov ah, 2
int 21h
mov dl, j
add dl, 30h
mov ah, 2
int 21h
mov dl, i
add dl, 30h
mov ah, 2
int 21h
;******xor function
mov al, b
mov bl, f
xor al, bl
mov n, al
mov bl, 2
;****enhance the ah
mov ah, 0
div bl
mov i, ah
;****can use the for
mov ah, 0
div bl
mov j, ah
mov ah, 0
div bl
mov k, ah
mov l, al
;pirnt (a xor e) the binary
mov dl, l
add dl, 30h
mov ah, 2
int 21h
mov dl, k
add dl, 30h
mov ah, 2
int 21h
mov dl, j
add dl, 30h
mov ah, 2
int 21h
mov dl, i
add dl, 30h
mov ah, 2
int 21h
;******xor function
mov al, c
mov bl, g
xor al, bl
mov o, al
mov bl, 2
;****enhance the ah
mov ah, 0
div bl
mov i, ah
;****can use the for
mov ah, 0
div bl
mov j, ah
mov ah, 0
div bl
mov k, ah
mov l, al
;pirnt (a xor e) the binary
mov dl, l
add dl, 30h
mov ah, 2
int 21h
mov dl, k
add dl, 30h
mov ah, 2
int 21h
mov dl, j
add dl, 30h
mov ah, 2
int 21h
mov dl, i
add dl, 30h
mov ah, 2
int 21h
;******xor function
mov al, d
mov bl, h
xor al, bl
mov p, al
mov bl, 2
;****enhance the ah
mov ah, 0
div bl
mov i, ah
;****can use the for
mov ah, 0
div bl
mov j, ah
mov ah, 0
div bl
mov k, ah
mov l, al
;pirnt (a xor e) the binary
mov dl, l
add dl, 30h
mov ah, 2
int 21h
mov dl, k
add dl, 30h
mov ah, 2
int 21h
mov dl, j
add dl, 30h
mov ah, 2
int 21h
mov dl, i
add dl, 30h
mov ah, 2
int 21h
;**************newline
mov dl, offset newline
mov ah, 9
int 21h
;print the 0X result 'pnom'
mov al, p
mov ah, 10
cmp ah, al
jna Func0
jnc Func1
Func0:add al, 57h
jnc NEXTC0
Func1:add al, 30h
NEXTC0:mov dl, al
mov ah, 2
int 21h
mov al, n
mov ah, 10
cmp ah, al
jna Func2
jnc Func3
Func2:add al, 57h
jnc NEXTC1
Func3:add al, 30h
NEXTC1:mov dl, al
mov ah, 2
int 21h
mov al, o
mov ah, 10
cmp ah, al
jna Func4
jnc Func5
Func4:add al, 57h
jnc NEXTC2
Func5:add al, 30h
NEXTC2:mov dl, al
mov ah, 2
int 21h
mov al, m
mov ah, 10
cmp ah, al
jna Func6
jnc Func7
Func6:add al, 57h
jnc NEXTC3
Func7:add al, 30h
NEXTC3:mov dl, al
mov ah, 2
int 21h
;*******move to dos
mov ah, 4ch
int 21h
code ends
end start
本文地址:http://com.8s8s.com/it/it26155.htm