📄 temp.asm
字号:
curent1 MACRO
mov ah,9
mov dx,offset char1
int 21h
ENDM
curent2 MACRO
mov ah,9
mov dx,offset char2
int 21h
ENDM
SCREEN MACRO
ENDM
DSEG SEGMENT
current db 13,10,'$'
Char1 db "'s left tree:$"
Char2 db "'s right tree:$"
Char3 db "input root:$"
Char4 db "Preorder:$"
Char5 db "Inorder:$"
Char6 db "Postorder:$"
tree db 32 dup('#')
tree1 db 32 dup('#'),'$'
temp db ?
tem db ?
DSEG ENDS
SSEG SEGMENT PARA STACK 'stack'
dw 100h dup(0) ;Resize the stack by changing the number '100'
SSEG ENDS
CSEG SEGMENT
assume cs:CSEG, ds:DSEG, es:DSEG , ss:SSEG
INIT PROC ;Initialize procedure
mov ax, dseg
mov ds, ax
mov es, ax
ret ;return to the MAIN procedure
INIT ENDP
MAIN PROC ;Here is your program entry point
call INIT ;call the INIT procedure to initialize the program
call CLS
call HINT
mov ax, 4c00h ;The end of the program, return to the system
int 21h
MAIN ENDP
;TO DO: Add other procedures(PROC) here (as your requirement)
COMO PROC
mov ah,9
mov dx,offset current
int 21h
ret
COMO ENDP
CLS PROC
mov ah,2
mov bh,0
mov dh,0
mov dl,0
int 10h
mov ah,6
mov al,0
mov bh,7H
mov ch,0
mov cl,0
mov dh,24
mov dl,79
int 10h
ret
CLS ENDP
HINT PROC
mov ah,9
mov dx,offset char3
int 21h
mov ah,1
int 21h
cmp al,0dh
jz ppp
mov tree,al
mov temp,al
call como
mov al,1
mov ah,temp
push ax
call createb
pop ax
call como
mov ah,9
mov dx,offset char4
int 21h
mov al,1
call preorder
call como
mov ah,9
mov dx,offset char5
int 21h
mov al,1
call inorder
call como
mov ah,9
mov dx,offset char6
int 21h
mov al,1
call postorder
ppp: ret
HINT ENDP
createb proc
push bp
mov bl,al
mov bh,ah
push bx
mov dl,bh
mov ah,2
int 21h
curent1
mov ah,1
int 21h
mov temp,al
cmp al,0dh
jz n1
call como
mov al,2
mul bl
cmp al,32
jg n1
mov tem,al
dec al
mov si,offset tree
mov ah,0
add si,ax
mov al,temp
mov [si],al
mov al,tem
mov ah,temp
push ax
call createb
pop ax
n1: call como
pop bx
mov dl,bh
mov ah,2
int 21h
curent2
mov ah,1
int 21h
mov temp,al
cmp al,0dh
jz n2
call como
mov al,2
mul bl
cmp al,32
jg n2
inc al
mov tem,al
dec al
mov si,offset tree
mov ah,0
add si,ax
mov al,temp
mov [si],al
mov al,tem
mov ah,temp
push ax
call createb
pop ax
n2: pop bp
ret
createb endp
preorder proc
mov dx,offset tree
mov bl,al
dec al
mov ah,0
mov si,ax
mov al,tree[si]
cmp al,'#'
jz m1
mov dl,al
mov ah,2
int 21h
mov al,2
mul bl
push ax
call preorder
pop ax
inc al
push ax
call preorder
pop ax
m1: ret
preorder endp
inorder proc
mov dx,offset tree
mov bl,al
dec al
mov ah,0
mov si,ax
mov al,tree[si]
mov cl,al
cmp al,'#'
jz m2
mov al,2
mul bl
push ax
push cx
call inorder
pop cx
pop ax
push ax
mov dl,cl
mov ah,2
int 21h
pop ax
inc al
push ax
call inorder
pop ax
m2: ret
inorder endp
postorder proc
mov dx,offset tree
mov bl,al
dec al
mov ah,0
mov si,ax
mov al,tree[si]
mov cl,al
cmp al,'#'
jz m3
mov al,2
mul bl
push cx
push ax
call postorder
pop ax
inc al
push ax
call postorder
pop ax
pop cx
push ax
mov dl,cl
mov ah,2
int 21h
pop ax
m3: ret
postorder endp
CSEG ENDS
END MAIN
;----------------------------*The End*--------------------------------
;Warning:This program is demo,not stable!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -