代码改变世界

实验九

2018-12-14 19:33  天培  阅读(200)  评论(1编辑  收藏  举报

1.补全t1

; 在屏幕上输出内存单元中的十进制两位数
assume cs:code, ds:data
data segment
     db 12
     db 0,0  ; 前一个字节用于保存商,后一个字节用于保存余数
data ends
code segment
start:
     mov  ax,data
     mov  ds,ax     ; 补全指令,使得ds <-- data段地址
      
      mov ah,0
      mov al,ds:[0]   ; ax <-- data段字节单元的被除数12
      mov bl,10
      div bl
      mov  ds:[1],al    ; 补全代码,让商保存到data段注释中指定的单元
      mov  ds:[2],ah    ; 补全代码,让余数保存到data段注释中指定的单元

      mov ah,2
      mov dl,ds:[1]    ; 补全代码,使得dl <-- data段中保存的商的字节单元数值
      add  dl,48    ; 补全代码,使得dl中的数值转换为数字字符
      int 21h

      mov ah,2
      mov dl,ds:[2]     ; 补全代码,使得dl <-- data段中保存余数的字节单元数值
      add dl,48      ; 补全代码,使得dl中的数值转换为数字字符      
      int 21h

      mov ax,4c00h
      int 21h
code ends
end start

  

2.补全t2

assume cs:code, ds:data
data segment
     db 12,35,96,55,67
data ends
code segment
start:mov ax,data
      mov ds,ax
      mov cx,5
      mov bp,0

    s:mov ah,0
      mov al,ds:[bp]
      mov bl,10
      div bl
      mov ds:[5+bp],al
      mov ds:[6+bp],ah

      mov ah,2
      mov dl,ds:[5+bp]
      add dl,30h
      int 21h

      mov ah,2
      mov dl,ds:[6+bp]
      add dl,30h
      int 21h

      mov ah,2
      mov dl,20h
      int 21h

      inc bp
      loop s

      mov ax,4c00h
      int 21h
code ends
end start

  

3.p187

assume cs:code,ds:data,es:table

data segment

     db 'welcome to masm!'

data ends

table segment

     dw 4000 dup (0)

table ends

code segment

start:   mov ax,data

     mov ds,ax

     mov ax,0b800h

     mov es,ax

     mov bx,0

     mov si,0

     mov cx,16

 

s0:  mov ax,[bx]

     mov es:[bx+720h][si],ax

     mov al,2

     mov es:[bx+721h][si],al

     inc bx

     inc si

    loop s0

 

     mov bx,0

     mov cx,16

     mov si,160

s1:  mov ax,[bx]

     mov es:[bx+720h][si],ax

     mov al,36

     mov es:[bx+721h][si],al

     inc bx

     inc si

     loop s1

 

     mov bx,0

     mov cx,16

     mov si,320

s2:  mov ax,[bx]

     mov es:[bx+720h][si],ax

     mov al,113

     mov es:[bx+721h][si],al

     inc bx

     inc si

     loop s2

 

     mov ax,4c00h

     int 21h

code ends

end start