assume cs:code
data segment
I DW 10 dup (0)
SAX DW ?
data ends
code segment
start: mov ax,12666
mov bx,data
mov ds,bx
mov si,0
call dtoc
mov dh,8
mov dl,3
mov cl,2
call show_str
mov ax,4c00h
int 21h
;==================================
;字符串显示
;==================================
show_str:
PUSH SI
PUSH DI
PUSH CX
PUSH DX
MOV AX,0B800H
MOV ES,AX
SUB DI,DI
ADD DL,DL
SUB AX,AX
MOV AL,DL
MOV DI,AX
MOV AL,DH
MOV AH,0
MOV BX,160
MUL BX
ADD DI,AX
LOOP_: MOV AL,DS:[SI]
CMP AL,0
JZ EXIT_
INC SI
MOV ES:[DI],AL
INC DI
MOV ES:[DI],CL
INC DI
JMP LOOP_
EXIT_:
POP DX
POP CX
POP DI
POP SI
RET
;==================================
;ASCII码转换DTOC
;==================================
dtoc:
PUSH SI
PUSH DI
PUSH BP
PUSH CX
MOV CX,0
MOV BX,10
TEST AX,DX
JNZ EXIT
MOV SAX,AX
MOV AX,DX
XOR DX,DX
CMP AX,0
JZ AX_PROC
DX_PROC:DIV BX
ADD DX,30H
PUSH DX
SUB DX,DX
INC CX
CMP AX,0
JNZ DX_PROC
AX_PROC:
MOV AX,SAX
TEST AX,DX
JNZ POP_
AX_: DIV BX
ADD DX,30H
PUSH DX
XOR DX,DX
INC CX
CMP AX,0
JNZ AX_
POP_:
POP DS:[SI]
INC SI
LOOP POP_
EXIT: POP CX
POP BP
POP DI
POP SI
ret
code ends
end start
|