自己写的,可以实现练习题的要求,而且个人感觉比网上常见的答案还精炼一些。
assume
cs:
codesg,
ds:
data
data segment
db ' welcome to masm! '
db 00000010B , 00100100B , 01110001B
dw 0b86eh,0b878h,0b882h
data ends
codesg segment
start:
mov cx, 3
s1:
mov ax, data ; set data address
mov ds, ax
mov si, cx ; set line in ds
mov ah, data: [ 15 +si] ; get font 00000010B,00100100B,01110001B
ADD si,cx ; Set si to be 6,4,2
mov ss, data: [ 17 +si] ; get line position of 0b86eh,0b878h,0b882h push cx
mov cx, 16
mov bx, 0
mov si, 0
s:
mov al, ds: [bx] ; individual char from 'welcome to masm!'
mov ss: [si+ 40 ], ax ; this DX should 'line position'
inc bx
add si, 2
loop s
pop cx
loop s1
mov ax, 4c00h
int 21h
codesg ends
data segment
db ' welcome to masm! '
db 00000010B , 00100100B , 01110001B
dw 0b86eh,0b878h,0b882h
data ends
codesg segment
start:
mov cx, 3
s1:
mov ax, data ; set data address
mov ds, ax
mov si, cx ; set line in ds
mov ah, data: [ 15 +si] ; get font 00000010B,00100100B,01110001B
ADD si,cx ; Set si to be 6,4,2
mov ss, data: [ 17 +si] ; get line position of 0b86eh,0b878h,0b882h push cx
mov cx, 16
mov bx, 0
mov si, 0
s:
mov al, ds: [bx] ; individual char from 'welcome to masm!'
mov ss: [si+ 40 ], ax ; this DX should 'line position'
inc bx
add si, 2
loop s
pop cx
loop s1
mov ax, 4c00h
int 21h
codesg ends
end start