梦踏长空吧 关注:223贴子:12,729
  • 4回复贴,共1
assume cs:code,ss:stack,ds:data
data segment
db '1. display '
db '2. brows '
db '3. replace '
db '4. modify '
data ends
stack segment
db ' '
stack ends
code segment
start:mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
mov sp,10H
mov bx,3
mov cx,4;循环次数
s1: push cx
mov cx,4
mov si,0
s2:mov al,[bx][si]
and al,11011111b
mov [bx][si],al
inc si
loop s2
pop cx
add bx,10H
loop s1
mov ax,4c00h
int 21h
code ends
end start


IP属地:上海1楼2018-04-20 20:33回复
    实验7
    assume cs:code,ds:data,es:table,ss:stack
    data segment
    db '1975','1976','1977','1978','1979','1980','1981','1982','1983'
    db '1984','1985','1986','1987','1988','1989','1990','1991','1992'
    db '1993','1994','1995'
    ;以上是表示21年的字符串 4 * 21 = 84
    dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
    dd 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000
    ;以上是表示21年公司总收入的dword型数据 4 * 21 = 84
    dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226
    dw 11542,14430,15257,17800
    ;以上是表示21年公司雇员人数的21个word型数据 2 * 21 = 42
    data ends
    table segment
    db 21 dup ('year summ ne ?? ') ; 'year summ ne ?? ' 刚好16个字节
    table ends
    stack segment
    db 10H dup (0)
    stack ends
    code segment
    start:
    mov ax,data
    mov ds,ax
    mov ax,table
    mov es,ax
    mov ax,stack
    mov ss,ax
    mov sp,10H
    mov cx,21;外层循环次数
    mov bx,0;外层起点(数组下标)
    mov si,0;存放源地址数组下标
    mov dx,0;源地址数组下标 2字节变化
    s1:mov di,0;目标变址寄存器
    mov ax,[si]
    mov es:[bx][di],ax
    add di,2
    mov ax,2[si]
    mov es:[bx][di],ax
    add di,2
    mov byte ptr es:[bx][di],' ';第1个空格
    inc di
    mov ax,84[si]
    mov es:[bx][di],ax
    add di,2
    mov ax,86[si]
    mov es:[bx][di],ax
    add di,2
    mov byte ptr es:[bx][di],' ';第2个空格
    inc di
    push si
    mov si,dx
    mov ax,168[si]
    mov es:[bx][di],ax
    add di,2
    mov byte ptr es:[bx][di],' ';第3个空格
    inc di
    mov ax,210[si]
    mov es:[bx][di],ax
    pop si
    add dx,2
    add si,4
    add bx,10h
    loop s1
    mov ax,4c00H
    int 21h
    code ends
    end start


    IP属地:上海2楼2018-04-21 10:03
    回复
      ;0b872 0b800
      ;00000010b,00100100b,01110001b
      assume cs:code,ss:stack,ds:data
      data segment
      db 'welcome to masm!'
      db 00000010b,00100100b,01110001b,0,0
      data ends
      stack segment
      db 10h dup(0)
      stack ends
      code segment
      start: mov ax,data
      mov ds,ax
      mov ax,0b800h+160*11/16+62/16;回去试一试
      mov es,ax
      mov cx,3
      mov si,0;颜色数组指针
      mov di,0;屏幕区域指针
      s1: push cx
      mov cx,16
      mov bx,0;ds段指针
      s2: mov al,[bx]
      mov es:[di],al
      mov al,16[si]
      mov es:[di+1],al
      add di,2
      inc bx
      loop s2
      add di,160-32;换行
      inc si
      pop cx
      loop s1
      mov ax,4c00h
      int 21h
      code ends
      end start


      IP属地:上海3楼2018-04-22 11:12
      回复
        显示字符串 子程序


        IP属地:上海4楼2018-04-22 13:58
        回复
          显示字符串 子程序
          ;在指定的位置,用指定的颜色,显示一个用0结束的字符串
          ;dh 行号 dl 列号 cl 颜色 ds:si 指向字符串的首地址
          ;show_str
          assume cs:code,ds:data,es:display,ss:stack
          data segment
          db 'w',0
          data ends
          stack segment
          db 16 dup(0)
          stack ends
          display segment
          db 1024 dup(0)
          display ends
          code segment
          start:mov ax,data
          mov ds,ax
          mov ax,stack
          mov ss,ax
          mov ax,0b800h
          mov es,ax;es存放屏幕段基址
          mov dh,8
          mov dl,3
          mov cl,00000010b;绿色
          mov si,0;si指向字符串的首地址ds=0
          call show_str
          mov ax,4c00h
          int 21h
          show_str:
          ;推入段寄存器
          push cx
          ;计算屏幕字符的起始位置并赋予给di←(dh-1)*160+dl*2
          dec dh
          mov al,160
          mul dh
          mov di,ax;di=(dh-1)*160
          mov ax,2
          mul dl
          add di,ax
          ;dx之后没用了,所以dl用来存颜色
          mov dl,cl
          ;着色,先判断字符串是否为0,如果为0跳到着色之后,否则死循环jmp
          s:mov ch,0
          mov cl,[si]
          jcxz next
          mov al,[si]
          mov es:[di],al
          mov es:[di+1],dl
          add di,2
          inc si
          jmp s
          ;弹出段寄存器
          next:pop cx
          ret
          code ends
          end start


          IP属地:上海5楼2018-04-22 13:58
          回复