|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 许楠 于 2012-1-6 12:01 编辑
还未看小甲鱼老师的视频,自己摸索写2段代码,一会儿看看小甲鱼老师怎么做的
第一段代码是第12,13,14行每行取中 显示那三行字
assume cs:codesg
data segment
db 'welcome to masm!'
data ends
codesg segment
start:
mov ax,data
mov ds,ax
mov bx,0
mov ax,0B800h
mov es,ax
mov di,720h
mov cx,16
s:
mov al,byte ptr ds:[bx]
mov ah,00000010b
mov word ptr es:[di],ax
inc bx
add di,2
loop s
mov di,7c0h
mov cx,16
mov bx,0
s1:
mov al,byte ptr ds:[bx]
mov ah,00100100b
mov word ptr es:[di],ax
inc bx
add di,2
loop s1
mov di,860h
mov cx,16
mov bx,0
s2:
mov al,byte ptr ds:[bx]
mov ah,01110001b
mov word ptr es:[di],ax
inc bx
add di,2
loop s2
mov ax,4c00h
int 21h
codesg ends
end start
第二段代码是以第13行取中,横向依次显示那3行字,用了栈,AX本来也应该放栈里的,可是脑袋绕不过来了
assume cs:codesg
data segment
db 'welcome to masm!'
data ends
stack segment
dw 8 dup (0)
stack ends
codesg segment
start:
mov ax,data
mov ds,ax
mov bx,0
mov ax,0B800h
mov es,ax
mov ax,stack
mov ss,ax
mov sp,8
mov di,7a0h ;16个字=32字节,3个字段就是96个字节,每行160字节,取中是80字节,
mov cx,3 ;96取中是48字节,80-48=32个字节,每屏25行,中间是13行,13行首偏移地址为780
mov dl,0 ;所以780h+32h=7a0
mov dh,01110001b
push dx
mov dh,00100100b
push dx
mov dh,00000010b
push dx
pop dx
s:
mov bp,cx ;栈被用了,用BP存CX吧
mov cx,16
s1:
mov ah,dh
mov al,byte ptr ds:[bx]
mov word ptr es:[di],ax
inc bx
add di,2
loop s1
pop dx
mov bx,0
mov cx,bp
loop s
mov ax,4c00h
int 21h
codesg ends
end start
|
|