Posted on 2014-12-26 16:09
jacky_zz 阅读(527)
评论(0) 编辑 收藏 引用 所属分类:
ASM
main:
org 0x0100
jmp start
stack:
db 256 dup(0)
tos:
dw 0
start:
mov ax, cs
mov ds, ax
mov ss, ax
mov sp, tos
mov ax, end
mov bx, main
sub ax, bx
mov bx, 2
div bx
cmp dx, 0
je next_step
inc ax
next_step:
mov bx, ax
mov si, 0
mov di, 0
.0:
cmp di, 0
je .1
mov ax, 0x0000
push ax
call print_char
pop ax
.1:
mov dx, cs:[si]
mov ch, 0x04
mov cl, 0x04
.2:
mov ax, 0
rol dx, cl
mov al, dl
and al, 0x0f
add al, 0x30
cmp al, 0x3a
jl .3
add al, 0x07
.3:
push ax
call print_char
pop ax
dec ch
cmp ch, 0
jne .2
inc di
add si, 2
dec bx
cmp bx, 0
jne .0
hlt
print_char:
push bp
push ax
push bx
mov bp, sp
mov ax, [bp+8]
mov ah, 0x0e
mov bx, 0x0000
int 0x10
pop bx
pop ax
pop bp
ret
end:
dw 0