王爽-汇编实验5

来源:互联网 发布:秋冬睡衣知乎 编辑:程序博客网 时间:2024/05/17 23:14

5-5

assume cs:codea segment    db 1,2,3,4,5,6,7,8a endsb segment    db 1,2,3,4,5,6,7,8b endsc segment    db 0,0,0,0,0,0,0,0c endscode segmentstart:    mov ax,a    mov ds,ax    mov ax,b    mov ss,ax    mov ax,c    mov es,ax    mov bx,0    mov cx,8s:    mov al,ds:[bx]    add al,ss:[bx]    mov es:[bx],al    inc bx    loop s    mov ax,4c00h    int 21hcode endsend start
各个段寄存器可以拿来用

ss段寄存器可以直接使用,而不是只能向栈一样使用,主要与偏移地址有关

5-6

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 0,0,0,0,0,0,0,0
b ends

code segment
start:
   mov ax,a
   mov ds,ax
   mov ax,b
   mov ss,ax
   mov sp,0010h

   mov bx,0
   mov cx,8

   s: push  ds:[bx]
      inc bx
      inc bx      ;bx 每次要加2 因为对栈进行操作每次两个字节   加一次bx偏移一个字节
      loop s
   
    mov ax,4c00h
    int 21h

code ends
end start

原创粉丝点击