home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 3,352 of 4,675   
   bilsch to All   
   test   
   24 Apr 18 01:26:29   
   
   From: king621@nospicedham.comcast.net   
      
   bits 16   
   org 0x7e00   
      
   SECTION  .data   
   pbuf   times 80 db 0   
   string	db 'junk'   
   scbufc	dw 320	;byte count of screen buffer   
   times 512-($-$$) db 'k'   
      
   SECTION  .text   
   	mov ax,0xb800   
   	mov es,ax		;mostly es used for screen buffer   
   	mov di,1   
   loop1:	mov byte[es:di],0x0f	;bg=0=blk fg=0xf=wht   
   	inc di   
   	inc di   
   	cmp di,3999		;4000=25x80x2, 2 = char + bgfg   
   	jbe loop1   
      
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
   	mov ax,ds   
   	mov es,ax   
   	mov si,pbuf			;new line buffer   
   	mov di,string			   
   	   
   lup8:	mov al,[di]		;di always been shl di,5 except first time is 0   
      	mov byte[si],al		;for o/p by prstr   
   	inc si   
   	inc di   
   	cmp di,4			;'junk' is 4   
   	jbe lup8   
      
   	mov ax,0x6789   
   	push ax				;2 bytes of data for hxout   
   	mov ax,4   
   	push ax				;# of hex digits for hxout to convert   
   	call hxout			;hxout uses si   
   ovr:   
   	inc si   
   	mov byte[si],0		;0-term.   
   	mov si,pbuf			   
   	call prstr   
   	mov byte[es:di],'X'	   
       	jmp $   
      
      
   hxout:	pop dx			;save return addr   
   	pop cx			;# of digits to convert   
   	pop ax			;4 digits   
   	push dx   
   xo4:	rol ax,4		;put hi hex digit on right   
   	push ax			;save rol'd ax   
   	and al,0x0f		;masks digit on right   
   	add al,'0'		;0 thru 9   
   	cmp al,'9'   
   	jbe xo5   
   	add al,0x7		;A thru F   
   xo5: 	inc si   
   	mov byte[si],al	   
   	pop ax			;rol'd version of ax   
   	dec cx   
   	jnz xo4 		;one digit per loop   
   	ret	   
      
   prstr:	push es   
   	push di   
   	push si   
   	mov ax,0xb800   
   	mov es,ax   
   	mov di,word[scbufc]	   
   prstr1:	mov al,[si]   
   	cmp al,0		;zero only if al is 0   
   	je dun3		   
   	mov [es:di],al		;display the char in al   
   	inc di   
   	inc di   
   	inc si   
   	jmp prstr1   
   dun3:	mov ax,di   
   	mov dl,160		;160=2x80,  2 = bgfg + char   
   	div dl			;ah has remainder   
   	sub dl,ah		;result is pad   
   	movzx ax,dl		;zero-extend dl   
   	add word[scbufc],ax	;   
   	pop si   
   	pop di   
   	pop es		   
   	ret   
      
   times 512-($-$$) db 'm'   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca