201913380032許豪第三次實驗
一、
截圖
原始碼:
assume cs:code, ds:data
data segment
x db 1, 9, 3
len1 equ $ - x
y dw 1, 9, 3
len2 equ $ - y
data ends
code segment
start:
mov ax, data
mov ds, ax
mov si, offset x
mov cx, len1
mov ah, 2
s1:mov dl, [si]
or dl, 30h
int 21h
mov dl, ' '
int 21h
inc si
loop s1
mov ah, 2
mov dl, 0ah
int 21h
mov si, offset y
mov cx, len2/2
mov ah, 2
s2:mov dx, [si]
or dl, 30h
int 21h
mov dl, ' '
int 21h
add si, 2
loop s2
mov ah, 4ch
int 21h
code ends
end start
問題1:
242個位元組 程式執行到loop s1時,指令暫存器IP=001B指向下一條指令,而001B+00F2=010D,高位捨棄,即IP指向000D。問題2:
問題3:
二、
原始碼:
assume cs:code, ds:data
data segment
dw 200h, 0h, 230h, 0h
data ends
stack segment
db 16 dup(0)
stack ends
code segment
start:
mov ax, data
mov ds, ax
mov word ptr ds:[0], offset s1
mov word ptr ds:[2], offset s2
mov ds:[4], cs
mov ax, stack
mov ss, ax
mov sp, 16
call word ptr ds:[0]
s1: pop ax
call dword ptr ds:[2]
s2: pop bx
pop cx
mov ah, 4ch
int 21h
code ends
end start
(ax)=0021 (bx)=0026 (cx)=076C
除錯截圖:
三、
原始碼:
assume cs:code, ds:data
data segment
x db 99, 72, 85, 63, 89, 97, 55
len equ $- x
data ends
stack segment
stack ends
code segment
start:
mov ax, data
mov ds, ax
mov cx, len
mov si, offset x
s: mov ah, 0
mov al, ds:[si]
call printNumber
call printSpace
inc si
loop s
mov ah, 4ch
int 21h
printNumber:
mov bl, 10
div bl
mov dl, al
mov dh, ah
or dl, 30H
mov ah, 2
int 21h
mov dl, dh
or dl, 30H
int 21h
ret
printSpace:
mov ah, 2
mov dl, ' '
int 21h
ret
code ends
end start
截圖:
四、
原始碼:
assume cs:code, ds:data
data segment
str db 'try'
len equ $ - str
data ends
stack segment
db 16 dup(0)
stack ends
code segment
start:
mov ax, data
mov ds, ax
mov ax, 0b800h
mov es, ax
mov cx, len
mov si, 0
mov bl, 2
mov bh, 0
mov di, bh
call printStr
mov bh, 24
mov bl, bh
mov bh, 0
mov cx, bx
mov ax, 0
findLastRow:
add ax, 00A0H
loop findLastRow
mov di, ax
mov cx, len
mov si, 0
mov bl, 4
call printStr
mov ah, 4ch
int 21h
printStr:
s:
mov al, ds:[si]
mov ah, bl
mov es:[di], ax
inc si
inc di
inc di
loop s
ret
code ends
end start
截圖:
五、
原始碼:
assume cs:code, ds:data
data segment
stu_no db '201913380032'
len = $ - stu_no
data ends
stack segment
db 16 dup(0)
stack ends
code segment
start:
mov ax, data
mov ds, ax
mov ax, 0b800h
mov es, ax
mov bl, 17H
mov si, 0
call setBgColor
mov bh, 24
mov bl, bh
mov bh, 0
mov cx, bx
mov ax, 0
findLastRow:
add ax, 00A0H
loop findLastRow
mov di, ax
mov al, '-'
mov cx, 34
mov bl, 17H
call printLine
mov cx, len
mov si, 0
mov bl, 17H
call printStr
mov al, '-'
mov cx, 34
mov bl, 17H
call printLine
mov ah, 4ch
int 21h
printStr:
s:
mov al, ds:[si]
mov ah, bl
mov es:[di], ax
inc si
inc di
inc di
loop s
ret
printLine:
s1:
mov al, '-'
mov ah, bl
mov es:[di], ax
inc di
inc di
loop s1
ret
setBgColor:
mov cx, 2000
s2:
mov al, ' '
mov ah, bl
mov es:[si], ax
inc si
inc si
loop s2
ret
code ends
end start
截圖: