课程设计一

本程序使用8086汇编语言从表格中读取数据,并将其转换为十进制字符串形式进行显示。数据包括年份、公司收入及员工数量等,通过精心设计的子程序实现了数据的有效转换和屏幕输出。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

放假后,距家过远,到家后整顿几天,不敢怠慢,继续复习8086ASM。

assume cs:codesg,ds:datasg,es:tablesg
tablesg 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'
	
    dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
    dd 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000
	
	dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226
    dw 11452,14430,15257,17800
tablesg ends

datasg segment
	db 32 dup(0)
datasg ends
	
codesg segment
start:	mov ax,datasg
			mov ds,ax
			mov ax,tablesg
			mov es,ax
			
			mov bx,0
			mov si,0
			mov di,0
			mov dh,0
			mov dl,40
			
			mov cx,21
	s2:	
			push cx
			mov ax,es:[bx]
			mov [si],ax
			mov ax,es:[bx].2
			mov [si].2,ax		;year
			add si,4
			
			mov byte ptr [si],' '
			inc si
			
			push dx
			
			mov ax,es:[bx].54h	;income of company
			mov dx,es:[bx].56h		
			push ax
			push dx
			
			call dtoc
			
			mov byte ptr [si],' '
			inc si
			
			mov ax,es:[di].0A8h	; employee number of company
			push ax
			
			mov dx,0
			call dtoc
			
			mov byte ptr [si],' '
			inc si
			
			pop cx
			pop dx
			pop ax
			call divdw
			call dtoc
			
			inc si
			mov byte ptr [si],0
			
			mov si,0;first address of string
			pop dx
			mov dl,20;column
			
			mov cl,00000010b;color
			call show_str

			mov si,0
			add bx,4
			add di,2
			
			inc dh
			
			pop cx
			
			loop s2
			
			mov ax,4c00h
			int 21h
			
			;function: Will dword data transform as expression string of decimalism,
			;				ends with zero.
			;arguments:The reg ax as dword data of low 16 digit.
			;					The reg dx as dword data of high 16 digit.
			;					ds:si point to first address of string.
			;return value:NULL
dtoc:	push ax
			push bx
			push cx
			push dx
			push di
			
			mov di,0
	s3:	mov cx,10
			call divdw
			add cx,30h
			push cx
			inc di
			mov cx,ax
			jcxz d1
			jmp s3
	d1:	mov cx,dx
			jcxz d2
			jmp s3
	d2:	mov cx,di
	d3:	pop ax
			mov [si],al
			inc si
			loop d3
			
			pop di
			pop dx
			pop cx
			pop bx
			pop ax
			ret
			;	function: Not overflow of dividing,dividend as dword,divisor as word,
			;					result as dword.
			;	argument: The reg ax as dword data of low 16 digit.
			;					The reg dx as dword data of high 16 digit.
			;					The reg cx as remainder.
			;	return value: The reg dx as high 16 digit of result.
			;						The reg ax as low 16 digit of result.
			;						The reg cx as remainder.
divdw:	push si
			push ax
			mov ax,dx
			mov dx,0
			div cx
			mov si,ax
			pop ax
			div cx
			mov cx,dx
			mov dx,si
			pop si
			ret
			;function:	To print out character in  memory.
			;arguments:	The reg dl's use for transform row.
			;					The reg dh's use for transform column.
			;					The ds:si point to first address of string.
			;					The reg cl's use for choose color of show.
show_str:	push dx
				push si
				push cx
				push bx
				push ax
				mov ax,es
				push ax
				
				mov ax,0b800h
				mov es,ax
				
				add dl,dl;dl*2+dh*160
				mov ah,0
				mov al,160; arithemic character position
				mul dh
				mov dh,0
				add ax,dx
				mov bx,ax
				
				mov dl,cl
				mov ch,0
			s1:mov cl,[si]
				mov es:[bx],cl
				mov es:[bx+1],dl
				inc si
				add bx,2
				jcxz ok1
				jmp short s1
		ok1:	pop ax
				mov es,ax
				pop ax
				pop bx
				pop cx
				pop si
				pop dx
				ret
				
codesg ends
end start



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值