汇编学习笔记-实验5[2]

来源:互联网 发布:苏州淘宝开店培训 编辑:程序博客网 时间:2024/06/07 14:00
assume cs:code  a segment  db 1,2,3,4,5,6,7,8  a ends  b segment  db 1,2,3,4,5,6,7,8  b ends  c segment  db 0,0,0,0,0,0,0,0  c ends  code segment  start:mov bx,0  mov cx,8    mov ax,a  mov ds,ax  mov dx,[bx]  mov ax,b  mov ds,ax s:add dx,[bx]  mov ax,c  mov ds,ax  mov [bx],dx  inc bx  loop s  mov ax,4c00h  int 21h  code ends  end start  


 

 

 

将a段和b段中的数据依次相加,将结果保存到c段中

assume cs:codea segmentdb 1,2,3,4,5,6,7,8a endsb segmentdb 1,2,3,4,5,6,7,8b ends c segment db 0,0,0,0,0,0,0,0c endscode segmentstart: mov ax,a  mov ds,ax   mov bx,0  ; a:0        mov cx,8     s:mov ax,[bx] ;a:0处的数据放入ax中add ax,[bx+16] ;b[bx+16] 为 b 定义段中内容加上ax中的内容(a+b) 送入ax中mov [bx+32],ax ;c   [bx+32] 为c定义段中内容,将a+b的内容送入 c中inc bx ;bx+1  因为是字节型数据,loop smov ah,4chint 21hcode endsend start