📄 1.asm
字号:
stack segment stack 'stack'
dw 32 dup(?)
stack ends
data segment
OutBuf1 db 'Please input the num:$'
OutBuf2 db 'The Reslut is:$'
DecIn db 7,0,7 dup(?)
HexOut db 5 dup(?)
data ends
code segment
begin proc far
assume ss:stack,cs:code,ds:data
push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
mov dx,offset OutBuf1
mov ah,9
int 21H
mov dx,offset DecIn
mov ah,10
int 21H
mov dl,00AH
mov AH,2
int 21H
mov ch,0
mov cl,1[DecIn]
mov SI,offset DecIn + 2
mov ax,0
CMP byte ptr [SI],'-'
pushf
JNZ NEXT
INC SI
DEC cx
NEXT:
mov bl,[SI]
sub bl,30H
mov bh,0
mov dx,10
mul dx
add ax,bx
INC SI
loop NEXT
popf
mov DI,0
JNZ ZHENG
add ax,8000H
NEG ax
add ax,8000H
ZHENG:
mov bl,ah
and bl,0F0H
mov cl,4
shr bl,cl
CALL CHANGE
mov HexOut[DI],bl
INC DI
mov bl,ah
and bl,00FH
CALL CHANGE
mov HexOut[DI],bl
INC DI
mov bl,al
and bl,0F0H
mov cl,4
shr bl,cl
CALL CHANGE
mov HexOut[DI],bl
INC DI
mov bl,al
and bl,00FH
CALL CHANGE
mov HexOut[DI],bl
INC DI
mov HexOut[DI],'$'
mov dx,offset HexOut
mov bx,word ptr HexOut
CMP bx,03030H
JNZ THEN
add dx,2
THEN:
mov ah,9
int 21H
ret
begin endp
CHANGE PROC
CMP bl,00AH
JS NUM
add bl,7
NUM:
add bl,30H
MYEND:
ret
CHANGE ENDP
code ends
end begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -