Digital Design Ltd.
 
   Home
 
   The HeliNav System
 
   Custom Built Servers
   Virtual Private Networks
   PBX / VoIP Phone Systems 
   Website Monitoring
   Consumer Software
 
 • Software Development
     Software Library
 
   Electronic Design
 
   About Steve Bell
   Contact Us
   Why are you Calling Me?
 
   Bookmark This Website
 
 
 

 
 
 
 
 
Copyright © 2002-2008
Digital Design Ltd.
 
Time Zones for PCs
and Brushstrokes
are registered trademarks
of Digital Design Ltd.

Site Map
 

Example of 80X86 Assembler Code

The following example shows the typical structure of software written by Digital Design Ltd., and the level of commenting present:

;******************************************************
;***		   INTERFACE ROUTINES		    ***
;******************************************************
;
Read_Char	PROC			;read char from input buffer
;
;Entry: CL = port number
;
;Exit:	AL = char (z set if none)
;
	push	cx			;preserve registers
	push	bx
;
	cmp	cl,0			;only port 0 allowed
	jz	rc_1
;
	_Int_Error	03301h		;invalid port number
;
rc_1:	mov	al,Rx_InPtr
	sub	al,Rx_OutPtr		;inptr - outptr = num. chars
	jz	rc_zex			;if zero exit
;
	push	ax			;save inptr - outptr
;
	mov	bl,Rx_OutPtr
	mov	bh,0
	add	bx,OFFSET Rx_Buf	;point to char
	mov	al,[bx] 		;get char
	inc	Rx_OutPtr		;inc outptr
;
	mov	ah,Control
	shl	ah,1
	shl	ah,1			;7/8 bits now in bit 7
	and	ah,10000000b		;mask lower bits
	or	ah,01111111b		;set to 1's
	and	al,ah			;combine with char
	mov	ch,al			;temp save char
;
	pop	ax			;recover inptr - outptr
	dec	al			;adjust
	cmp	al,MARGIN_LOW
	jc	rc_hsk			;hsk needs to be turned on
;
rc_ex:	or	al,0FFh 		;reset z
	mov	al,ch			;get char back
	pop	bx			;recover registers
	pop	cx
;
	ret
;
;
rc_zex: xor	al,al			;set z
	pop	bx			;recover registers
	pop	cx
;
	ret
;
;
rc_hsk: 				;turn data back on
					;don't use ch (char)
	mov	al,In_Hsk		;get hsk
	and	al,al
	jz	rc_ex			;hsk already 'go' - exit
;
	mov	In_Hsk,GO		;set to 'go'
	test	Control,00010000b	;parallel / serial ?
	jnz	rc_par
;
rc_ser: test	Control,00000100b
	jz	rc_rts			;non xon hsk
;
	test	Control,00000010b
	jz	rc_xdup 		;xon, duplex
;
					;xon, input
	mov	al,XON
	mov	dx,COM1_DATA
	out	dx,al			;send xon
	jmp	SHORT rc_ex		;exit
;
;
rc_xdup:				;xon, duplex
	cli				;must not have ptrs change
	mov	dx,COM1_LSR
	in	al,dx
	and	al,00100000b		;Tx holding reg empty
	jz	rc_xdup1
	mov	al,XON			;empty
	mov	dx,COM1_DATA
	out	dx,al			;send xon
	sti				;int ok
	jmp	SHORT rc_ex		;exit
;
rc_xdup1:
	dec	Tx_OutPtr		;insert char at end of buffer
	mov	bl,Tx_OutPtr
	mov	bh,0
	add	bx,OFFSET Tx_Buf
	mov	BYTE PTR [bx],XON	;xon at end of buffer
	sti				;int ok
	jmp	SHORT rc_ex		;exit
;
;
rc_rts: mov	dx,COM1_MCR
	in	al,dx			;read MCR current
	or	al,00000011b		;set RTS, DTR on
	out	dx,al
	jmp	SHORT rc_ex		;exit
;
;
rc_par: _Int_Error	03302h		;parallel not supported
;
Read_Char	ENDP
;
;
;

Previous Page

 

Advanced Navigation - HeliNav Custom Built Servers Virtual Private Networks PBX / VoIP Phone Systems
Website Monitoring Software Products Software Development Electronic Design