🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.asm
Article #1411

Re: Wyświetlanie liczb od 90 do 100

#1411
From: Doleś
Date: Sun, 05 Aug 2007 18:23
127 lines
3329 bytes
Teraz napisałem ten program i działa poprawnie (użyłem Twojego - Bogdan 
- algorytmu).Mianowicie kod źródłowy jest taki:
>  format ELF executable		
>  entry _start
>  segment readable executable
> 
>  lf = 10
>  stdout = 1
>  sys_write = 4
> 
> 
> 
> _start:
> 
> 	mov	eax, 90			
> 
> wyswietlaj:
> 	call	_pisz_ld		
> 					
> 	call	_nwln			
> 					
> 	add	eax, 1			
> 	cmp	eax, 101		
> 	jb	wyswietlaj		
> 					
> 
> 	mov	eax, 1			
> 	xor	ebx, ebx		
> 	int	80h			
> 
> 
> 
> 
> 
> _pisz_ld:
> 
> 
> 
> 	pushfd
> 	push	ecx
> 	push	edx
> 	push	eax
> 	push	esi
> 
> 	xor	esi, esi
> 	mov	ecx, 10
> 
> ._pisz_ld_petla:
> 	xor	edx, edx
> 	div	ecx
> 
> 	or	dl, "0"
> 	mov	[_pisz_bufor+esi], dl						
> 	inc	esi			
> 
> 	test	eax, eax
> 	jnz	._pisz_ld_petla
> 
> ._pisz_ld_wypis:
> 	mov	al, [_pisz_bufor+esi-1]
> 	call	_pisz_z
> 
> 	dec	esi
> 	jnz	._pisz_ld_wypis
> 
> 	pop	esi
> 	pop	eax
> 	pop	edx
> 	pop	ecx
> 	popfd
> 
> 	ret
> 
> 
> _pisz_z:
> 
> 	push	eax
> 	push	ebx
> 	push	ecx
> 	push	edx
> 
> 	mov	[_pisz_bufor+39], al
> 
> 	mov	eax, sys_write		
> 	mov	ebx, stdout		
> 				
> 	lea	ecx, [_pisz_bufor+39]
> 	mov	edx, 1
> 	int	80h
> 
> 	pop	edx
> 	pop	ecx
> 	pop	ebx
> 	pop	eax
> 
> 	ret
> 
> 
> _nwln:
> 
> 
> 	push	eax
> 
> 	mov	al, lf
> 	call	_pisz_z
> 
> 	pop	eax
> 	ret
> 
> 
> 
>  segment readable writeable
> 
> _pisz_bufor:	times	40	db 0	

Tylko, że nie jestem ani trochę zadowolony z tego programu. Bo to co za 
sztuka przepisać czyiś kod i zmienić nieco kilka linijek ? Jakoś nie 
bardzo udowodniłem sobie iż potrafię. A to, że wcześniejszym sposobem 
nie wyświetlę liczby to zauważyłem. Albo miałem 10 razy w nowej linni 
znak "Z" albo coś skopałem w kodzie i miałem w każdej lini jakiś śmieć 
(w sensie dziwny znak np "]" a potem "^"). Myślałem sobie żeby taką 
liczbę jak np 92 wyświetlić jako ciąg znaków ASCII "9" i "2" a potem 
tylko odpowiednio operatorem [] inkrementować drugi element ciągu czyli 
tę wspomianą dwójkę. Tylko jak bym potem załatwił sprawę zamiany mojej 
liczby dwucyfrowej na trzycyfrową ? Byłoby dużo grzebaniny. Niemniej nie 
jestem usatysfakcjonowany tym powyższym kodem, bo jakby nie patrzeć to 
nie mój wytwór.
Technical Details
Message-ID: <f954kd$7n4$1@atlantis.news.tpi.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.nask.pl!news.nask.org.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail
References: <f8upq6$pn3$1@nemesis.news.tpi.pl> <f8v85h$a75$1@inews.gazeta.pl> <f8v9aq$c19$1@atlantis.news.tpi.pl> <f94vu8$4uk$1@inews.gazeta.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.nask.pl!news.nask.org.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail
From: Doleś <doles2@gmail.com>
Newsgroups: pl.comp.lang.asm
Subject: Re: Wyświetlanie liczb od 90 do 100
Date: Sun, 05 Aug 2007 20:23:18 +0200
Organization: tp.internet - http://www.tpi.pl/
Lines: 127
Message-ID: <f954kd$7n4$1@atlantis.news.tpi.pl>
References: <f8upq6$pn3$1@nemesis.news.tpi.pl> <f8v85h$a75$1@inews.gazeta.pl> <f8v9aq$c19$1@atlantis.news.tpi.pl> <f94vu8$4uk$1@inews.gazeta.pl>
NNTP-Posting-Host: abwv116.neoplus.adsl.tpnet.pl
Mime-Version: 1.0
X-Trace: atlantis.news.tpi.pl 1186338253 7908 83.8.245.116 (5 Aug 2007 18:24:13 GMT)
X-Complaints-To: usenet@tpi.pl
NNTP-Posting-Date: Sun, 5 Aug 2007 18:24:13 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.5 (X11/20070716)
In-Reply-To: <f94vu8$4uk$1@inews.gazeta.pl>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit