1 assume ds:data, cs:code, ss:stack 2 3 data segment 4 db 16 dup(0) 5 data ends 6 7 stack segment 8 db 16 dup(0) 9 stack ends 10 code segment 11 start: 12 mov ax, data 13 mov ds, ax 14 15 mov ax, stack 16 mov ss, ax 17 mov sp, 16 18 19 mov ah, 4ch 20 int 21h 21 code ends 22 end start
1 assume ds:data, cs:code, ss:stack 2 3 data segment 4 db 4 dup(0) 5 data ends 6 7 stack segment 8 db 8 dup(0) 9 stack ends 10 code segment 11 start: 12 mov ax, data 13 mov ds, ax 14 15 mov ax, stack 16 mov ss, ax 17 mov sp, 8 18 19 mov ah, 4ch 20 int 21h 21 code ends 22 end start
1 assume ds:data, cs:code, ss:stack 2 3 data segment 4 db 20 dup(0) 5 data ends 6 7 stack segment 8 db 20 dup(0) 9 stack ends 10 code segment 11 start: 12 mov ax, data 13 mov ds, ax 14 15 mov ax, stack 16 mov ss, ax 17 mov sp, 20 18 19 mov ah, 4ch 20 int 21h 21 code ends 22 end start
1 assume ds:data, cs:code, ss:stack 2 code segment 3 start: 4 mov ax, data 5 mov ds, ax 6 7 mov ax, stack 8 mov ss, ax 9 mov sp, 20 10 11 mov ah, 4ch 12 int 21h 13 code ends 14 15 data segment 16 db 20 dup(0) 17 data ends 18 19 stack segment 20 db 20 dup(0) 21 stack ends 22 end start
基于上述四个实验任务的实践、观察,总结并回答:
① 对于如下定义的段,程序加载后,实际分配给该段的内存空间大小是 16*Math.ceil(N/16)。
1 xxx segment 2 db N dup(0) 3 xxx ends
② 如果将程序task1_1.asm, task1_2.asm, task1_3.asm, task1_4.asm中,伪指令 end start 改成 end , 哪一个程序仍然可以正确执行。结合实践观察得到的结论,分析、说明原因。
答:只有task1_4.asm能够正确执行。通过实践观察到:task1_1~task1_3中的cs都没有原本需要执行的代码。没有了end start,即表示程序中没有界定代码执行结束位置,在task1_1~task1_3中,执行了数据段而代码段执行失败,在task1_4中,因为代码段定义在最开始,所以说task1_4可以成功执行。
1 assume cs:code 2 code segment 3 start: 4 mov ax,0b800h 5 6 mov ds,ax 7 mov bx,0f00h 8 mov ax,0403h 9 10 mov cx,80 11 s: 12 mov ds:[bx],ax 13 add bx,2 14 loop s 15 16 mov ah, 4ch 17 int 21h 18 code ends 19 end start
1 assume cs:code 2 data1 segment 3 db 50, 48, 50, 50, 0, 48, 49, 0, 48, 49 ; ten numbers 4 data1 ends 5 6 data2 segment 7 db 0, 0, 0, 0, 47, 0, 0, 47, 0, 0 ; ten numbers 8 data2 ends 9 10 data3 segment 11 db 16 dup(0) 12 data3 ends 13 14 code segment 15 start: 16 mov ax, data1 17 mov ds,ax 18 mov bx,0 19 mov cx,10h 20 s: 21 mov ax,ds:[bx] 22 add ax,ds:[bx+10h] 23 mov ds:[bx+20h],ax 24 inc bx 25 loop s 26 27 mov ah, 4ch 28 int 21h 29 code ends 30 end start
1 assume cs:code 2 3 data1 segment 4 dw 2, 0, 4, 9, 2, 0, 1, 9 5 data1 ends 6 7 data2 segment 8 dw 8 dup(?) 9 data2 ends 10 11 code segment 12 start: 13 mov ax,data1 14 mov ds,ax 15 mov ax,data2 16 mov ss,ax 17 mov sp,16 18 mov bx,0 19 mov cx,8 20 s :push ds:[bx] 21 add bx,2 22 loop s 23 24 mov ah, 4ch 25 int 21h 26 code ends 27 end start
1 assume cs:code, ds:data 2 data segment 3 db 'Nuist' 4 db 2,3,4,5,6 5 data ends 6 7 code segment 8 start: 9 mov ax, data 10 mov ds, ax 11 12 mov ax, 0b800H 13 mov es, ax 14 15 mov cx, 5 16 mov si, 0 17 mov di, 0f00h 18 s: mov al, [si] 19 and al, 0dfh 20 mov es:[di], al 21 mov al, [5+si] 22 mov es:[di+1], al 23 inc si 24 add di, 2 25 loop s 26 27 mov ah, 4ch 28 int 21h 29 code ends 30 end start
答:line19的代码为:and al,0dfh,其中and表示按位进行与操作,即将AL于DF(1101 1111)进行与操作,就是把左边第三位置为0
答:db的用途是为后面的数字分配一个存储单元。
1 assume cs:code, ds:data 2 3 data segment 4 db 'Pink Floyd ' 5 db 'JOAN Baez ' 6 db 'NEIL Young ' 7 db 'Joan Lennon ' 8 data ends 9 10 code segment 11 start: 12 mov ax,data 13 mov ds,ax 14 mov bx,0 15 mov cx,4 16 s: or [bx],byte ptr 00100000b 17 add bx,16 18 loop s 19 20 mov ah, 4ch 21 int 21h 22 code ends 23 end start
1 assume cs:code, ds:data, es:table 2 3 data segment 4 db '1975', '1976', '1977', '1978', '1979' 5 dw 16, 22, 382, 1356, 2390 6 dw 3, 7, 9, 13, 28 7 data ends 8 9 table segment 10 db 5 dup( 16 dup(' ') ) ; 11 table ends 12 13 code segment 14 start: 15 mov ax,data 16 mov ds,ax 17 mov ax,table 18 mov es,ax 19 20 mov cx,5 21 mov si,0 22 mov bx,0 23 s: mov ax,[si] 24 mov es:[bx],ax 25 mov ax,[si+2] 26 mov es:[bx+2],ax 27 add bx,10h 28 add si,4 29 loop s ;年份 30 31 mov cx,5 32 mov si,20 33 mov bx,5 34 s1:mov ax,[si] 35 mov es:[bx],ax 36 mov ax,0 37 mov es:[bx+2],ax 38 add bx,16 39 add si,2 40 loop s1; ;收入 41 42 mov cx,5 43 mov si,30 44 mov bx,10 45 s2:mov ax,[si] 46 mov es:[bx],ax 47 add bx,16 48 add si,2 49 loop s2 ;雇员人数 50 51 mov cx,5 52 mov si,5 53 s3:mov ax,es:[si] 54 mov bl,es:[si+5] 55 div bl 56 mov es:[si+8],al 57 add si,16 58 loop s3 ;求人均收入 59 60 mov ah, 4ch 61 int 21h 62 code ends 63 end start