|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
实验十第一小题
assume cs:code,ds:data
data segment
db 'welcome to masm!',0
data ends
code segment
start: mov dh,8
mov dl,3
mov cl,2
mov ax,data
mov ds,ax
mov si,0
call show_str
mov ax,4c00H
int 21H
;=============================
show_str:mov ax,0b800H
mov es,ax
mov al,0a0H
dec dh
mul dh
mov bx,ax
dec dl
add dl,dl
add bl,dl
mov di,0
s:push cx
mov cl,ds:[di]
mov ch,0
jcxz ok
mov es:[bx+si],cl
pop cx
mov es:[bx+si+1],cl
inc di
add si,2
jmp short s
ok:ret
;===============================
code ends
end start
实验十第二小题
assume cs:code,ss:stack
stack segment
dw 8 dup (0)
stack ends
code segment
start:mov ax,4240h
mov dx,000fh
mov cx,0aH
call divdw
mov bp,sp
mov ax,4c00H
int 21H
;==========================
divdw: push ax
mov ax,dx
mov dx,0
div cx
push ax
sub bp,2
mov ax,ss:[bp]
div cx
mov cx,dx
pop dx
ret
;============================
code ends
end start
实验十第三小题
assume cs:code,ds:data,ss:stack
data segment
db 16 dup (0)
data ends
stack segment
dw 16 dup (0)
stack ends
code segment
start:mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
mov sp,32
mov ax,12666
mov si,0
call dtoc
mov dh,8
mov dl,3
mov cl,2
call show_str
mov ax,4c00H
int 21H
;===================================
show_str:push dx
push cx
push si
mov di,0
mov bl,dh
dec bl
mov al,160
mul bl
mov bx,ax
add dl,dl
add bl,dl
mov ax,0b800H
mov es,ax
mov al,cl
show_s:mov ch,0
mov cl,ds:[si]
jcxz show_ok
mov es:[bx+di],cl
mov es:[bx+di+1],al
add di,2
inc si
loop show_s
show_ok:pop dx
pop cx
pop si
ret
;====================================
dtoc:push ds
push ss
push sp
push ax
push si
s:mov dx,0
mov bx,10
div bx
mov cx,ax
jcxz ok
add dx,30H
pop dx
inc cx
loop s
s0:pop ds:[si]
inc si
loop s0
ok:pop si
pop ax
pop sp
pop ss
pop ds
;========================================
code ends
end start
|
|