⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 10-to-16.asm

📁 自己写的一些MASM的小程序
💻 ASM
字号:
;把1000-4095的十进制数转化为十六进制数
data    segment
decimal db 5,0,5 dup(0)
hex   db 4 dup(0)
prompt db 'please enter a decimal number no biger than 4095:$'
string db 0ah,0dh,'the number you enter is incorroct!!!',0ah,0dh,'$' 
string1 db 0ah,0dh,'the hex number is:$'
data    ends
stack1  segment para stack
        dw 20h dup(0)
stack1  ends
coseg   segment
        assume cs:coseg,ds:data,ss:stack1
start:  mov ax,data
        mov ds,ax
        mov dx,offset prompt
        mov ah,09h
        int 21h
        mov dx,offset decimal
        mov ah,0ah
        int 21h
        cmp decimal[2],'0'
        jz lop
        cmp decimal[2],'1'
        jz lop
        cmp decimal[2],'2'
        jz lop
        cmp decimal[2],'3'
        jz  lop
        cmp decimal[2],'4'
        jz  lop
error1:  mov dx,offset string
         mov ah,09h
         int 21h
         jmp start
 lop:   mov si,3
        mov cx,3
 lop1:  mov bl,decimal[si]
        call dec1
        jc error1
        inc si
        loop lop1
        mov cx,4
        mov si,2
 lop2:  sub decimal[si],30h
         inc si
         loop lop2
        xor ax,ax
        mov al,decimal[4]
        mov bl,0ah
        mul bl
        add al,decimal[5]
        xor ah,ah
        mov cx,ax
        mov al,decimal[3]
        mov bl,64h
        mul bl
        add cx,ax
        mov ax,03e8h
        xor bx,bx
        mov bl,decimal[2]
        xor bh,bh
        mul bx
        add ax,cx
        cmp ax,1000h
        jnc error1
        mov cx,3
        mov si,2
lop3:   xor dx,dx
        mov bx,10h
        div bx
        mov hex[si],dl
        dec si
        loop lop3
        mov cx,3
        mov si,0
lop4:   cmp hex[si],9h
        ja lop5
        add hex[si],30h
        inc si
        loop lop4
        jmp lop6
lop5:   add hex[si],37h
        inc si
        loop lop4
lop6:   mov hex[3],24h
        mov dx,offset string1
        mov ah,09h
        int 21h
        mov dx,offset hex
        mov ah,09h
        int 21h
        mov ah,4ch
        int 21h
 dec1    proc
         cmp bl,'0'
         jb error
         cmp bl,'9'
         ja error
         clc
         ret
 error:  mov dx,offset string
         mov ah,09h
         int 21h
         stc
         ret
 dec1    endp
coseg   ends
        end start

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -