avatar10010 发表于 2014-10-3 13:29:48

课程设计 1(代码相对较少饿)

本帖最后由 avatar10010 于 2014-10-3 23:33 编辑

;初学汇编,希望给点意见,将代码更加精{:1_1:}
assume cs:code

code segment
year      db   '19751976197719781979198019811982198319841985',
                      '1986198719881989199019911992199319941995'
income   dd   16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514,
                      345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000
memberdw3,7,9,13,28,38,130,220,476,778,1001,1442,2258,
                      2793,4037,5635,8226,11542,14430,15257,17800

start:
      mov ax,0b800h+160*4/16   ;4代表行号
      mov es,ax

      mov bh,2      ;设置颜色(绿色)
      xor si,si
      xor di,di
      xor bp,bp
      mov cx,21                ;设置循环次数
line:
      ;Year
      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      mov bl,year
      mov es:,bx
      mov bl,year
      mov es:,bx
      mov bl,year
      mov es:,bx
      mov bl,year
      mov es:,bx
      ;Income
      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      add bp,12
      mov ax,word ptr income
      mov dx,word ptr income
      call dtoc
      ;Member
      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      add bp,18
      mov ax,member
      xor dx,dx
      call dtoc
      ;Average
      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      add bp,14
      push cx
      mov ax,word ptr income
      mov dx,word ptr income
      mov cx,member
      call divdw
      call dtoc
      add si,2
      add di,4
      add bp,116
      pop cx      
loop line      
      mov ax,4c00h
      int 21h

dtoc:
      push si
      push cx      
      xor si,si
s:
      mov cx,10
      call divdw
      add cl,30h
      mov ch,bh
      push cx
      inc si
      mov cx,ax
      jcxz return1
      jmp s
return1:
      mov cx,si      
      mov si,bp
return2:
      pop es:
      add si,2
      loop return2
      pop cx
      pop si
      ret

divdw:
      push bx
      push ax    ;保存低16位
      mov ax,dx;此时ax的值是高16位
      xor dx,dx
      div cx         ;H/N
      mov bx,ax;bx的值为(int)H/N,dx的值是(rem)H/N
      pop ax
      div cx         ;L/N
      mov cx,dx
      mov dx,bx
      pop bx
      ret

code ends
end start

小靚同学Leon 发表于 2014-10-3 15:13:05

0x1.代码请用代码格式发
0x2.新手可以看下置顶的帖子再发帖哦

avatar10010 发表于 2014-10-3 23:32:52

小靚同学Leon 发表于 2014-10-3 15:13
0x1.代码请用代码格式发
0x2.新手可以看下置顶的帖子再发帖哦

谢谢,我已经改正了

大个的糖果 发表于 2014-11-1 03:06:32

页: [1]
查看完整版本: 课程设计 1(代码相对较少饿)