王爽 《彙編語言》課程設計1

`assume cs:codeoop

data segment db '1975','1976','1977','1978','1979','1980','1981','1982','1983','1984' db '1985','1986','1987','1988','1989','1990','1991','1992','1993','1994','1995' ;214個字節,EA+0,年份 dd 16,22,382,1356,2390,8000,1600,24486,50065,97479,140417,197514 dd 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5973000 ;214個字節, EA+84,收入 dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226 dw 11542,11430,15257,17800 ;21*2個字節, EA+84+84,人數 data endscode

code segmentit

start: mov ax,0b800H mov es,axtest

mov ax,data
	mov ds,ax

	mov cx,21

	mov bx,0
	mov bp,0a0h
	mov si,84
	mov di,84
	mov ax,0
s:	;年份
	push cx ;保存循環次數		
	mov ax,bp 
	push ax ;每次循環bp首地址 

	mov cx,80
	setz:
		mov word ptr es:[bp],0 ;清空原有數據
		add bp,2
	loop setz
	mov bp,ax

	add bp,20

	call out3

	add bp,20

	;總收入
	mov ax,ds:[bx+si] ;總收入低位
	mov dx,ds:[bx+si+2] ;總收入高位
	push ax
	push dx

	push bx	
	push si
	push di

	push bp ;先把下表收起來

	call design

	pop ax ;把以前收起來的下表拿出
	add ax,30
	mov bp,ax


	pop di
	pop si
	pop bx

	

	;add bp,20
	;僱員人數

	mov ax,ds:[bx+84+di]
	mov dx,0

	push bx
	push si
	push di		

	push bp

	call design

	pop ax ;把以前收起來的下表拿出
	add ax,30
	mov bp,ax
	
	pop di
	pop si
	pop bx

	;平均收入
	pop dx
	pop ax
	div word ptr ds:[bx+84+di] ;除於僱員數

	push bx
	push si
	push di

	mov dx,0 ;把餘數清空

	push bp
	call design

	pop ax ;把以前收起來的下表拿出
	add ax,30
	mov bp,ax

	pop di
	pop si
	pop bx

	pop bp
	add bp,160
	

	add bx,4
	sub di,2
	pop cx
loop s	

mov ax,4c00H
int 21H

design:	mov cx,10

		call test1

		ret  ;返回調用者

test1:	mov di,sp


doit:	mov cx,10

		push ax
		mov ax,dx
		mov dx,0
		div cx
		mov bx,ax

		pop ax
		div cx
		mov cx,dx  ;餘數
		mov dx,bx  ;處理Divdw,保存高位

		add cx,30H
		push cx

		mov cx,ax
		jcxz out1

		
		jmp short doit

out1: 	pop ax

		mov byte ptr es:[bp],al
		
		inc bp
		mov byte ptr es:[bp],02H		
		inc bp

		mov cx,sp
		sub cx,di
		jcxz out2

		jmp short out1

out2:	ret 
out3:   
		mov ax,ds:[bx]		
		mov byte ptr es:[bp],al
		inc bp
		mov byte ptr es:[bp],02H
		inc bp
		mov byte ptr es:[bp],ah
		inc bp
		mov byte ptr es:[bp],02H		
		inc bp

		mov ax,ds:[bx+2]
		mov byte ptr es:[bp],al
		inc bp
		mov byte ptr es:[bp],02H
		inc bp
		mov byte ptr es:[bp],ah
		inc bp
		mov byte ptr es:[bp],02H	
		add bp,3

		ret

code ends循環

end start`call

相關文章
相關標籤/搜索