实验任务(1)~(4):
接下来是实验任务五
源代码如下:
assume cs:code a1 segment db 1,2,3,4,5,6,7,8 a1 ends b1 segment db 1,2,3,4,5,6,7,8 b1 ends c1 segment db 0,0,0,0,0,0,0,0 c1 ends code segment start: mov ax,a1 mov ds,ax mov bx,0 mov ax, c1 mov es,ax mov cx,8 s1: mov ax,[bx] mov es:[bx],ax inc bx loop s1 mov ax,b1 mov ds,ax mov bx,0 mov ax,c1 mov es,ax mov cx,8 s2: mov al,[bx] mov ah,0 add es:[bx],ax inc bx loop s2 mov ax,4c00h int 21h code ends end start
实验前查看数据如下:
试验后查看数据如下:
所以实现了数据相加的功能
实验任务六:
用push指令将a段中的前8个字型数据,逆序存储到b段中
汇编代码如下:
assume cs:code a segment dw 1,2,3,4,5,6,7,8,9,0ah,0bh,0ch,0dh,0eh,0fh,0ffh a ends b segment dw 8 dup(0) b ends code segment start: mov ax,a mov ds,ax mov bx,0 mov ax, b mov ss,ax mov sp,10h mov cx,8 s: push [bx] add bx,2 loop s mov ax,4c00h int 21h code ends end start
push操作前,查看逻辑段b的8个字单元信息截图:
执行后:
总结与体会:
写实验任务五时,实现加法一开始直接用:
s2: mov ax,[bx] add es:[bx],ax inc bx loop s2
得出实验结果是错的
后改为:
s2: mov al,[bx] mov ah,0 add es:[bx],ax inc bx loop s2
得到正确答案
要分清字节与字的区别
来源:https://www.cnblogs.com/wtblogwt/p/10011026.html