显示字符的方法
1. 利用bios中断
DOS显示字符串的功能调用为:
MOV Dx,字符串的偏移地址
MOV AH.9
INT 21H
DOS显示字符的功能调用为:
MOV AH.2
MOV DL,字符ASCII码
INT 21H
(1)
dsegsegment
mess db'hello',13,10,'$'
dseg ends
csegsegment
assumecs:cseg
movax,dseg
mov ds,ax
leadx,mess
mov ah,9
int 21h
mov ah,4ch
int 21h
cseg ends
end
这段代码的hello若改成helloworld
就必须改成
dseg segment
mess db 'helloworld',13,10,'$'
dseg ends
stack segment
db 100 dup(0)
stack ends
cseg segment
assume cs:cseg,ss:stack
mov ax,dseg
mov ds,ax
lea dx,mess
mov ah,9
int 21h
mov ah,4ch
int 21h
cseg ends
end
因为系统默认的堆栈大小不够,简称的堆栈溢出
(2)
code segment
assume cs:code
mov cx,26
mov dl,'A'
next:mov ah,02h
int 21h
inc dl
loop next
mov ah,4ch
int 21h
code ends
end
2. 利用显存[0xb8000—0xbffff]来显示字符
code segment
assume cs:code
mov ax,0b800h
movds,ax
moval,41h
movah,0
movds:[0],al
mov ah,4ch
int21h
code ends
end
这个程序会在debug的上面显示