汇编_8086作业

D:/www_local/asm/test/test10.asm
assume cs:codesg,ds:datasg
datasg segment
	db 'welcome to masm!',0	;以零结尾
	;db 4ah,71h,0cah   ;定义3重颜色
datasg ends	

codesg segment
start:  mov ax,datasg
		mov ds,ax
		mov dh,2 		;在第8行显示
		mov dl,0 		;在第3列显示
		mov cl,71h		;定义颜色
		mov si,0		;si指向字符串
		;==========关联===============
		call show_str
		mov ax,4c00h
		int 21h
		
   show_str:mov bx,0
			mov ax,0b800h	;指向现存段
			mov es,ax
			mov al,160		;8 bit
			mul dh			;8 bit  result in ax
			
			add bx,ax
			
			mov al,2		;8 bit
			mov ah,0
			mul dl			;8 bit  result in ax
			add bx,ax		;bx存放的是显示的偏移地址
			
			
		s:	;mov bl,71h		;由于cx要循环判断,所以颜色用bl记录
			mov cl,ds:[si]		;第八位存放字符串
			mov ch,0		
			jcxz game_over	;如果cx为0即遇到结束符号,返回
			;如果不为零,在指定位置显示
			mov byte ptr es:[bx+di],cl   ;先写ascii
			mov byte ptr es:[bx+1+di],0cah		;再写颜色属性
			
			add di,2	;指向下个显示位置
			inc si	;指向下个字符串
			jmp short s
   
   
   
   game_over:ret
		
		
		
		
codesg ends
end start


D:/www_local/asm/test/test10_1.asm
assume cs:codesg,ss:stacksg
stacksg segment
	db 16 dup(0)
stacksg ends
;计算1000000/10 即000f4240h  000ah
codesg segment
start:  mov ax,stacksg
		mov ss,ax
		mov sp,10h 		
		mov dx,000fh	;被除数的高十六位
		mov ax,4240h	;被除数的low十六位
		mov cx,000ah	;十六位的除数
		call divdw
		mov ax,4c00h
		int 21h
  divdw:  ;先要把被除数的低十六位保存计算高十六位
		push ax
		mov ax,dx
		mov dx,0		
		div cx	;以上3句是先除高位结果dx为余数AX为商
		mov bx,ax	;将商先缓存
		pop ax		;将ax还原为被除数的第十六位
		div cx		;高十六位dx是前面的余数 此时余数存放于dx 商放于ax
		mov cx,dx	;将余数转到cx中
		mov dx,bx	;将高十六�  位除后的商放入dx�
		ret
		
		
		
		
		
codesg ends
end start


D:/www_local/asm/test/test8.asm
assume cs:codesg
codesg segment
	mov ax,4c00h
	int 21h
start:  mov ax,0            
	s:	nop
		nop
		
		mov si,offset s2
		mov ax,cs:[si]
		mov di,offset s
		mov cs:[di],ax  ;上面4句实现了将s2处的机器码复制到s处替换掉nop nop
				
	s0: jmp short s
	
	s1: mov ax,0FFFFh
		int 21h
		mov ax,0ffffh
	s2: jmp short s1   ;jmp记录着便宜距离
		
codesg ends
end start


D:/www_local/asm/test/test8_0.asm
assume cs:codesg
codesg segment
    mov ax,4c00h
    int 21h
start: mov ax,0            
    s: nop                 ;占一字节,机器码90
       nop                 
       mov di,offset s     
       mov si,offset s2    
       mov ax,cs:[si]      ;(ax)=jmp short s1指令对应的机器码EBF6
       mov cs:[di],ax      ;jmp short s1覆盖s处指令2条nop指令
   s0: jmp short s         ;关键是机器码:EBF6 jmp 向上8字节
   s1: mov ax,0
       int 21h
       mov ax,0
   s2: jmp short s1       
       nop
codesg ends
end start


D:/www_local/asm/test/test9.asm
assume cs:codesg,ds:datasg,ss:stacksg
datasg segment
	db 'welcome to masm!'	;16个字节
	db 4ah,71h,0cah   ;定义3重颜色
datasg ends	
stacksg segment
	db 16 dup(0)
stacksg ends
codesg segment
start:  mov ax,datasg
		mov ds,ax
		mov ax,0b884h ;b800是duan b884h是中间哪行
		mov es,ax ;要写的目的	
		mov ax,stacksg
		mov ss,ax
		mov sp,10h	;==========关联===============
		
		mov di,0   ;控制显示3行    每次递增a0h
		mov cx,3	;控制显示3行
flag2:	push cx

		mov bx,0	;控制写出16个字符一个字符占两个字节(ASCII和属性)
		mov si,0	;控制读取16个字节
		mov cx,16
flag:	mov al,[si]
		mov byte ptr es:[bx+di].0b0h,al   ;先写ascii
		mov al,10h[di]	;读取颜色
		mov byte ptr es:[bx+di].0b1h,al		;再写颜色属性
		add bx,2		
		add si,1
		loop flag
		
		pop cx
		add di,0a0h	;转到下一行 即跳过80乘以2等于160个字节
		loop flag2
		mov ax,4c00h
		int 21h
codesg ends
end start


D:/www_local/asm/test/test9_1.asm
assume cs:codesg
codesg segment
	
start:  mov ax,0b810h ;b800是第一行 现在是第二行
		mov ds,ax
		mov bx,0
		mov byte ptr [bx],01h
		inc bx
		mov byte ptr [bx],01h
		inc bx
		mov byte ptr [bx],02h
		inc bx
		mov byte ptr [bx],02h
		mov ax,4c00h
		int 21h
codesg ends
end start


d:/www_local/asm/0.asm
assume cs:abc
abc segment
        mov ax,1234h
        mov ax,4c00h
        int 21h
abc ends
end

d:/www_local/asm/1.asm
assume cs:abc
abc segment
    start:    	mov ax,1234h
				mov bx,5678h
				add ax,1111h
				mov ax,4c00h
				int 21h
abc ends
end start

d:/www_local/asm/2.asm
assume cs:abc
abc segment
    start:    	mov ax,2h
				mov cx,11
		flag:	add ax,ax
				loop flag				
				mov ax,4c00h
				int 21h
abc ends
end start

d:/www_local/asm/3.asm
assume cs:abc
abc segment
    start:    	mov ax,0ffffh
				mov ds,ax
				mov bx,6
				mov dx,0
				mov al,[bx]
				mov ah,0
				mov cx,3
		flag:	add dx,ax
				loop flag				
				mov ax,4c00h
				int 21h
abc ends
end start

d:/www_local/asm/4.asm
assume cs:abc
abc segment
    start:    	mov ax,0ffffh
				mov ds,ax
				mov al,ds:[0]
				mov bl,ds:[1]
				mov cl,ds:[2]
				mov dl,ds:[3]

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

d:/www_local/asm/5.asm
assume cs:abc
abc segment
    start:    	mov bx,0
				mov ax,0ffffh
				mov ds,ax
				mov ax,0020h
				mov es,ax
				mov cx,12
		flag:	mov al,ds:[bx]
				mov es:[bx],al
				inc bx
				loop flag
				mov ax,4c00h
				int 21h
abc ends
end start

d:/www_local/asm/6.asm
assume cs:abc
abc segment
    start:    	mov bx,0
				mov ax,0ffffh
				mov ds,ax
				mov dx,0
				mov cx,12
		flag:	mov al,ds:[bx]
				mov ah,0
				add dx,ax
				inc bx
				loop flag
				mov ax,4c00h
				int 21h
abc ends
end start

d:/www_local/asm/7.asm
assume cs:abc
abc segment
dw 0123H,0456H,0789H,1111H,1111H,1111H,1111H,1111H
    start:    	mov ax,0
				mov bx,0
				mov cx,8
		flag:	add ax,cs:[bx]				
				add bx,2

				loop flag
				mov ax,4c00h
				int 21h
abc ends
end start

d:/www_local/asm/8.asm
assume cs:abc
abc segment
dw 0123H,0456H,0789H,1111H,1111H,1111H,1111H,1111H
dw 0h,0h,0h,0h,0h,0h,0h,0h
    start:    	mov ax,cs
				mov ss,ax
				mov sp,20h
				mov bx,0
				mov cx,8
		flag:	push cs:[bx]
				add bx,2
				loop flag
				mov bx,0
				mov cx,8
		flag2:	pop cs:[bx]
				add bx,2
				loop flag2
				mov ax,4c00h
				int 21h
abc ends
end start

d:/www_local/asm/9.asm
assume cs:codesg,ds:datasg,ss:stacksg
datasg segment
	dw 0123H,0456H,0789H,1111H,1111H,1111H,1111H,1111H
datasg ends

stacksg segment
	dw 0h,0h,0h,0h,0h,0h,0h,0h
stacksg ends

codesg segment
    entry:    	mov ax,datasg
				mov ds,ax
				mov ax,stacksg
				mov ss,ax
				mov sp,20h
				mov bx,0
				mov cx,8
		flag:	push [bx]
				add bx,2
				loop flag
				mov bx,0
				mov cx,8
		flag2:	pop [bx]
				add bx,2
				loop flag2
				mov ax,4c00h
				int 21h
codesg ends
end entry

d:/www_local/asm/10.asm
assume cs:codesg,ds:datasg,ss:stacksg
datasg segment
	dw 0123H,0456H,0789H,1111H,1111H,1111H,1111H,1111H
datasg ends

stacksg segment
	dw 0h,0h,0h,0h,0h,0h,0h,0h
stacksg ends

codesg segment
    entry:    	mov ax,stacksg
				mov ss,ax
				mov sp,10h
				mov ax,datasg
				mov ds,ax
				push ds:[0]
				push ds:[2]
				pop ds:[2]
				pop ds:[0]
				mov ax,4c00h
				int 21h
codesg ends
end entry

d:/www_local/asm/11.asm
assume cs:codesg,ds:datasg,ss:stacksg
datasg segment
	dw 0123H,0456H
datasg ends

stacksg segment
	dw 0h,0h
stacksg ends

codesg segment
    entry:    	mov ax,stacksg
				mov ss,ax
				mov sp,16h
				mov ax,datasg
				mov ds,ax
				push ds:[0]
				push ds:[2]
				pop ds:[2]
				pop ds:[0]
				mov ax,4c00h
				int 21h
codesg ends
end entry

d:/www_local/asm/12.asm
assume cs:codesg,ds:datasg,ss:stacksg
codesg segment
    entry:    	mov ax,stacksg
				mov ss,ax
				mov sp,16h
				mov ax,datasg
				mov ds,ax
				push ds:[0]
				push ds:[2]
				pop ds:[2]
				pop ds:[0]
				mov ax,4c00h
				int 21h
codesg ends
datasg segment
	dw 0123H,0456H
datasg ends

stacksg segment
	dw 0h,0h
stacksg ends


end entry

D:/www_local/asm/test/131.asm
assume cs:codesg
a segment
    db 1,2,3,4,5,6,7,8
a ends
b segment
    db 1,2,3,4,5,6,7,8
b ends
cc segment
    db 0,0,0,0,0,0,0,0
cc ends
codesg segment
    entry:    	mov ax,a
				mov ds,ax
				mov ax,b
				mov es,ax
				mov ax,cc
				mov ss,ax
				mov bx,0
				mov cx,8
		flag:	mov al,ds:[bx]
				mov ss:[bx],al
				mov al,es:[bx]
				add ss:[bx],al
				inc bx
				loop flag
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/13.asm
assume cs:codesg

a segment

    db 1,2,3,4,5,6,7,8

a ends

b segment

    db 1,2,3,4,5,6,7,8

b ends

cc segment

    db 0,0,0,0,0,0,0,0

cc ends



codesg segment
    entry:    	mov ax,a
				mov ds,ax
				mov ax,cc
				mov es,ax
				mov bx,0
				mov cx,8
		flag:	mov al,ds:[bx]
				mov es:[bx],al
				inc bx
				loop flag
				mov ax,b
				mov ds,ax
				mov bx,0
				mov cx,8
		flag2:	mov al,ds:[bx]
				add es:[bx],al
				inc bx
				loop flag2
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/14.asm
assume cs:codesg
a segment
    dw 1h,2h,3h,4h,5h,6h,7h,8h
a ends
b segment
    dw 0h,0h,0h,0h,0h,0h,0h,0h
b ends
codesg segment
    entry:    	mov ax,b
				mov ss,ax
				mov sp,10h
				mov ax,a
				mov ds,ax
				mov bx,0
				mov cx,8
		flag:	push [bx]
				add bx,2
				loop flag
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/15.asm
assume cs:codesg,ds:datasg

datasg segment
    db 'abcd'
	db '0123'
datasg ends
codesg segment
    entry:    	mov ax,datasg
				mov ds,ax
				mov al,'a'
				mov bl,'b'
				
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/16.asm
assume cs:codesg,ds:datasg

datasg segment
    db 'abcd'
	db '0123'
datasg ends
codesg segment
    entry:    	mov ax,datasg
				mov ds,ax
				mov bx,0
				mov cx,4
		flag:	mov al,[bx]
				and al,11011111b
				mov [bx],al
				inc bx
				loop flag
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/17.asm
assume cs:codesg,ds:datasg
datasg segment
    db 'abcd'
	db '0123'
datasg ends
codesg segment
    entry:    	mov ax,datasg
				mov ds,ax
				mov bx,0
				mov al,[0] ;这种写法是错误
				mov al,ds:[bx+1]
				mov al,ds:[2+bx]
				mov al,ds:3[bx]
				mov al,ds:[bx].24
		
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/18.asm
assume cs:codesg,ds:datasg
datasg segment
    db 'abcd'
	db 'ABCD'
datasg ends
codesg segment
    entry:    	mov ax,datasg
				mov ds,ax
				mov bx,0
				mov cx,5
		flag:	mov al,0[bx]
				and al,11011111b
				mov 0[bx],al
				mov al,5[bx]
				or  al,00100000b
				mov 5[bx],al
				inc bx
				loop flag
		
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/19.asm
assume cs:codesg,ds:datasg
datasg segment
    db 'abcd'
	db '....'
datasg ends
codesg segment
    entry:    	mov ax,datasg
				mov ds,ax
				mov si,0
				mov cx,4
		flag:	mov al,0[si]
				mov 4[si],al
				inc si
				loop flag
		
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/20.asm
assume cs:codesg,ds:datasg,ss:stacksg

codesg segment
    entry:    	mov ax,datasg
				mov ds,ax
				mov ax,stacksg
				mov ss,ax
				mov sp,8
				mov bx,0
				mov cx,4
		flag:	mov si,0
				push cx
				mov cx,4
		flag0:	mov al,[bx][2+si]
				and al,11011111b
				mov [bx][2+si],al
				inc si
				loop flag0
		
				pop cx
				add bx,6
				loop flag
				
				mov ax,4c00h
				int 21h
codesg ends

datasg segment
    db '1.abcd'
	db '2.abcd'
	db '3.abcd'
	db '4.abcd'
datasg ends
stacksg segment
	dw 0h,0h,0h,0h
stacksg ends

end entry

d:/www_local/asm/21.asm
assume cs:codesg,ds:datasg,ss:stacksg
datasg segment
    db '1.ab'
	db '2.ab'
datasg ends
stacksg segment
	dw 0h,0h,0h,0h
stacksg ends
codesg segment
    entry:    	mov ax,datasg
				mov ds,ax
				mov ax,stacksg
				mov ss,ax
				mov sp,8
				mov bx,0
				mov cx,2
		flag:	mov si,0
				push cx
				mov cx,2
		flag0:	mov al,[bx][2+si]
				and al,11011111b
				mov [bx][2+si],al
				inc si
				loop flag0		
				pop cx
				add bx,4
				loop flag
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/22.asm
assume cs:codesg

codesg segment
    entry:    	
				mov dx,0001h
				mov ax,86a1h
				mov bx,100
				div bx
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/23.asm
assume cs:codesg

codesg segment
    entry:    	
				mov ax,1001
				mov bl,100
				div bl
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/24.asm
assume cs:codesg,ds:datasg
datasg segment
	dd 100001
	dw 100
	dw 0h
datasg ends

codesg segment
    entry:    	mov ax,datasg
				mov ds,ax
				mov ax,ds:[0] ;put low 16bit into ax
				mov dx,ds:[2] ;put high 16bit into dx
				div word ptr ds:[4]
				mov ds:[6],ax
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/25.asm
assume cs:codesg,ds:datasg,es:table
datasg 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   ;peoples
datasg ends
table segment
    db 21 dup ('year summ ne ?? ') ;total 21 years
table ends
codesg segment
    entry:    	mov ax,datasg
				mov ds,ax ;source
				mov ax,table
				mov es,ax ;产生关联
				;================================
				mov bx,0
				mov bp,0
				mov cx,21
		flag2:	mov dx,cx
							;================================
				mov si,0  ; si=si+1byte
				mov cx,4 ;‘1975’
		flag:	mov al,ds:[bx].0h[si]  ;y e a r
				mov es:[bp].0h[si],al  ;y e a r
				mov al,ds:[bx].54h[si]  ;income
				mov es:[bp].5h[si],al  ;income
				add si,1
				loop flag
							;================================
				add bx,4
				add bp,16
				mov cx,dx
				loop flag2
				
				;===============拷贝人数=================
				mov bx,0
				mov bp,0
				mov cx,21
		flag3:  mov ax,ds:0a8h[bx]  ;people
				mov es:0ah[bp],ax  ;people
				add bx,2
				add bp,16
				loop flag3
				;================计算人均收入16================
				mov bx,0
				mov si,0
				mov bp,0
				mov cx,21
		flag4:  mov ax,ds:54h[bx]  ; low
				mov dx,ds:54h[bx+2]  ; high
				div word ptr ds:0a8h[si]	;people
				
				mov es:0dh[bp],ax  ;division shang
				add bx,4	;income 4byte
				add si,2  ;people 2byte
				add bp,16	;target 
				loop flag4
				
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/26.asm
assume cs:codesg


codesg segment
    entry:    	mov ax,0
				jmp short s
				add ax,1
				add ax,ax
			s:	add ax,1
				
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/27.asm
assume cs:codesg


codesg segment
    entry:    	mov ax,0
				;jmp near ptr s
				jmp far ptr s
				db 256 dup(0)
				add ax,1
				add ax,ax
			s:	add ax,1
				
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/28.asm
assume cs:codesg


codesg segment
    entry:    	mov ax,0123h
				mov ds:[0],ax
				mov ds:[2],4567h
				jmp dword ptr ds:[0]
				;jmp near ptr s
				;jmp far ptr s
				
				
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/29.asm
assume cs:codesg


codesg segment
    entry:    	mov ax,0123h
				jmp short s
				db 138 dup(0)
			s:	mov ax,4567h
				
				
				;jmp dword ptr ds:[0]
				;jmp near ptr s
				;jmp far ptr s
				
				
				
				mov ax,4c00h
				int 21h
codesg ends



end entry

d:/www_local/asm/30.asm
assume cs:codesg,ss:stacksg
stacksg segment
	db 16 dup(0)
stacksg ends
codesg segment
				mov ax,4c00h
				int 21h
				
    entry:    	mov ax,stacksg
				mov ss,ax
				mov sp,16
				
				mov ax,0
				push ax
				ret   ;相当于pop ip
				
codesg ends



end entry

d:/www_local/asm/31.asm
assume cs:codesg,ss:stacksg
stacksg segment
	db 16 dup(0)
stacksg ends
codesg segment
				mov ax,4c00h
				int 21h
				
    entry:    	mov ax,stacksg
				mov ss,ax
				mov sp,16
				
				mov ax,0
				push cs
				push ax
				ret   ;相当于pop ip     ,pop cs
				
codesg ends



end entry

d:/www_local/asm/32.asm
assume cs:codesg,ss:datasg
datasg segment
	db 16 dup(0)
datasg ends
codesg segment
				
				
    entry:    	mov ax,datasg
				mov ss,ax
				mov sp,16
				
				mov word ptr ss:[0],offset s
				mov ss:[2],cs
				
				call dword ptr ss:[0]
				nop
				
		s:		mov ax, offset s
				sub ax,ss:[0ch]  ;s处的偏移减去nop处的偏移
				mov bx,cs
				sub bx,ss:[0eh]
				
				
				
				mov ax,4c00h
				int 21h
				
codesg ends



end entry

d:/www_local/asm/33.asm
assume cs:codesg,ss:datasg
datasg segment
	dw 1,2,3,4,5,6,7,8
	dd 8 dup(0)
datasg ends
codesg segment
    entry:    	mov ax,datasg
				mov ds,ax
				mov si,0   ;读取源
				mov di,0	;写入目的
				mov cx,8
		flag:	mov bx,ds:[si]
				call cube
				mov ds:10h[di],ax;把结果放到下一组内存单元
				mov ds:12h[di],dx
				add si,2
				add di,4
				loop flag
				
				mov ax,4c00h
				int 21h
				
		cube:	mov ax,bx
				mul bx
				mul bx
				ret  ;结果高16位在dx  第16位在ax
				
				
				
				
				
codesg ends



end entry

你可能感兴趣的:(汇编)