复习教材5-8章:
包含多个逻辑段的汇编源程序结构
寻址方式
汇编指令loop, div用法
1.1
assume ds:data, cs:code, ss:stack data segment db 16 dup(0) data ends stack segment db 16 dup(0) stack ends code segment start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp, 16 mov ah, 4ch int 21h code ends end start
① 在debug中将执行到line17结束、line19之前,记录此时:寄存器(DS) = __076A__, 寄存器(SS) =
__076B__, 寄存器(CS) = __076C__
② 假设程序加载后,code段的段地址是X,则,data段的段地址是__x-1__, stack的段地址是__x-2__。
1.2
assume ds:data, cs:code, ss:stack data segment db 4 dup(0) data ends stack segment db 8 dup(0) stack ends code segment start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp, 8 mov ah, 4ch int 21h code ends end start
① 在debug中将执行到line17结束、line19之前,记录此时:寄存器(DS) = __076A__, 寄存器(SS) =
__076B__, 寄存器(CS) = __076C__
② 假设程序加载后,code段的段地址是X,则,data段的段地址是__x-1__, stack的段地址是__x-2__。
1.3
assume ds:data, cs:code, ss:stack data segment db 20 dup(0) data ends stack segment db 20 dup(0) stack ends code segment start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp, 20 mov ah, 4ch int 21h code ends end start
① 在debug中将执行到line17结束、line19之前,记录此时:寄存器(DS) = __076A__, 寄存器(SS) =
__076C__, 寄存器(CS) = __076E__
② 假设程序加载后,code段的段地址是X,则,data段的段地址是__x-2__, stack的段地址是__x-4__。
1,4
assume ds:data, cs:code, ss:stack code segment start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp, 20 mov ah, 4ch int 21h code ends data segment db 20 dup(0) data ends stack segment db 20 dup(0) stack ends end start
① 在debug中将执行到line17结束、line19之前,记录此时:寄存器(DS) = __076C__, 寄存器(SS) =
__076E__, 寄存器(CS) = __076A__
② 假设程序加载后,code段的段地址是X,则,data段的段地址是__x+2__, stack的段地址是__x+4__。
1、对于如下定义的段,程序加载后,实际分配给该段的内存空间大小是 __[N/16+1]*16__
2、 如果将程序task1_1.asm, task1_2.asm, task1_3.asm, task1_4.asm中,伪指令 end start 改成
end , 哪一个程序仍然可以正确执行。结合实践观察得到的结论,分析、说明原因。
task1_4.asm end表示程序就会从头开始。1_4可以直接从头运行,所以1_4能够正确运行。
assume cs:code code segment mov ax, 0b800h mov ds, ax mov bx, 00f00h mov cx, 50 s:mov byte ptr [bx], 3 inc bx mov byte ptr [bx], 4 inc bx loop s mov ah, 4ch int 21h code ends end
assume cs:code data1 segment db 50, 48, 50, 50, 0, 48, 49, 0, 48, 49 ; ten numbers data1 ends data2 segment db 0, 0, 0, 0, 47, 0, 0, 47, 0, 0 ; ten numbers data2 ends data3 segment db 16 dup(0) data3 ends code segment start: mov ax, data1 mov ds, ax mov cx, 10h mov bx, 0 s:mov al, [bx] mov [bx+20h], al mov al, [bx+10h] add [bx+20h], al inc bx loop s mov ah, 4ch int 21h code ends end start
assume cs:code data1 segment dw 2, 0, 4, 9, 2, 0, 1, 9 data1 ends data2 segment dw 8 dup(?) data2 ends code segment start: mov ax, data1 mov ds, ax mov ax, data2 mov es, ax mov bx, 0 mov bp, 000eh mov cx, 8h s:mov ax, [bx] mov es:[bp], ax dec bp dec bp inc bx inc bx loop s mov ah, 4ch int 21h code ends end start
assume cs:code, ds:data data segment db 'Nuist' db 2,3,4,5,6 data ends code segment start: mov ax, data mov ds, ax mov ax, 0b800H mov es, ax mov cx, 5 mov si, 0 mov di, 0f00h s:mov al, [si] and al, 0dfh mov es:[di], al mov al, [5+si] mov es:[di+1], al inc si add di, 2 loop s mov ah, 4ch int 21h code ends end start
1、源代码中line19的作用是?
让字母变为大写。
2、源代码中data段line4的字节数据的用途是?
设置字符在屏幕上的颜色。
assume cs:code, ds:data data segment db 'Pink Floyd ' db 'JOAN Baez ' db 'NEIL Young ' db 'Joan Lennon ' data ends code segment start: mov ax, data mov ds, ax mov bx, 0 mov cx, 4 s:mov al, [bx] or al, 00100000b mov [bx], al add bx, 10h loop s mov ah, 4ch int 21h code ends end start
assume cs:code, ds:data, es:table data segment db '1975', '1976', '1977', '1978', '1979' dw 16, 22, 382, 1356, 2390 dw 3, 7, 9, 13, 28 data ends table segment db 5 dup( 16 dup(' ') ) ; table ends code segment start: mov ax, data mov ds, ax mov ax, table mov es, ax mov bx, 0 mov cx, 5 mov si, 0 s:mov di, bx add di, bx mov ax, [di] mov es:[si], ax mov ax, [di+2] mov es:[si+2], ax mov byte ptr es:[si+4], ' ' mov word ptr es:[si+5], 0 mov ax, [bx+20] mov es:[si+7], ax mov byte ptr es:[si+9], ' ' mov ax, [bx+30] mov es:[si+10], ax mov byte ptr es:[si+12], ' ' mov ax, [bx+20] div byte ptr [bx+30] mov byte ptr es:[si+13], 0 mov byte ptr es:[si+14], al mov byte ptr es:[si+15], ' ' add bx, 2 add si, 16 loop s mov ah, 4ch int 21h code ends end start