assume cs:code
data segment
db 'welcome to class'
db 16 dup (0)
data ends
code segment
start:
code ends
end start
完整代码:
assume cs:code
data segment
db 'welcome to class'
db 16 dup(0)
data ends
code segment
start:
mov ax,data
mov ds,ax
mov si,0
mov cx,8
s:mov ax,[si]
mov[si+16],ax
add si,2
loop s
mov ax,4c00h
int 21h
code ends
end start
测试前:
测试后:
2. 计算data段中第一组数据的4次方,结果保存在后面一组dword单元中。
assume cs:code
data segment
dw 1,2,3,4,5,6,7,8
dd 0,0,0,0,0,0,0,0
data ends
code segment
start:
code ends
end start
完整代码:
assume cs:code
data segment
dw 1,2,3,4,5,6,7,8
dd 0,0,0,0,0,0,0,0
data ends
code segment
start:mov ax,data
mov ds,ax
mov si,0
mov di,16
mov cx,8
s:mov bx,[si]
call cube
mov [di],ax
mov [di].2,dx
add si,2
add di,4
loop s
mov ax,4c00h
int 21h
cube:mov ax,bx
mul bx
mul bx
mul bx
ret
code ends
end start
assume cs:code
data segment
db 'Beginner`s All-purpose Symbolic Instruction Code.',0
data ends
code segment
start:
mov ax,data
mov ds,ax
mov si,0
call letter
mov ax,4c00h
int 21h
letter:
code ends
end start
完整代码:
assume cs:codesg
datasg segment
db "Beginner's All-purpose Symbolic Instruction Code.", 0
datasg ends
codesg segment
start: mov ax, datasg
mov ds, ax
mov si, 0
call letterc
mov ax, 4c00h
int 21h
letterc:
push ax
push bx
push cx
push dx
letterc_ok:
xor cx, cx
mov cl, ds:[si]
jcxz letterc_ret
cmp cx, 'a'
jb next
and byte ptr ds:[si], 11011111b
next: inc si
jmp letterc_ok
letterc_ret:
pop dx
pop cx
pop bx
pop ax
ret
codesg ends
end start
测试前:
测试后:
4. 编程,将data段中以0结尾的每个单词转成大写。
assume cs:code
data segment
db '1. display',0
db '2. brows',0
db '3. replace',0
db '4. modify ',0
data ends
code segment
start:
code ends
end start
完整代码:
assume cs:code
data segment
db '1. display',0
db '2. brows',0
db '3. replace',0
db '4. modify',0
data ends
code segment
start:
mov ax,data
mov ds,ax
mov si,0
call s
mov ax,4c00h
int 21h
s: mov cx,[si]
jcxz s1
mov al,[si]
and al,11011111b
mov [si],al
inc si
jmp short s
s1: mov al,[si+1];比较下一个是否为字母
cmp al,'z' ;ASCII小于z则继续
jb s2
ret
s2: cmp al,'A' ;ASCII大于A则继续
inc si
ja s
ret
code ends
end start