Posted on 2014-12-16 17:24
jacky_zz 阅读(149)
评论(0) 编辑 收藏 引用 所属分类:
ASM
; You may customize this and other start-up templates;
; The location of this template is c:\emu8086\inc\0_com_template.txt
org 100h
; add your code here
mov ax, cs
mov ds, ax
mov ss, ax
mov ax, 0xb800
mov es, ax
mov ax, 0x6f4e
;mov bx, 2
;mov bx, 8
mov bx, 10
;mov bx, 16
xor cx, cx
next_div:
mov dx, 0
div bx
push dx
inc cx
cmp ax, 0
jnz next_div
mov si, bx
xor bx, bx
cmp si, 16
jnz outp
;如果是显示16进制则在值前面加上0x
mov es:[bx], '0'
inc bx
mov es:[bx], 0x0c
inc bx
mov es:[bx], 'x'
inc bx
mov es:[bx], 0x0c
inc bx
outp:
pop dx
add dl, 0x30
cmp dl, 0x3a ;是A-F,要多加7
jl outc
add dl, 0x07
outc:
mov es:[bx], dl
inc bx
mov es:[bx], 0x0c
inc bx
loop outp
hlt