Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

It's all magic. :-) -- Larry Wall in <7282@jpl-devvax.JPL.NASA.GOV>


programming / comp.lang.asm.x86 / Re: Life

SubjectAuthor
* LifeKerr-Mudd,John
+* Re: LifeSteve
|`* Re: LifeTerje Mathisen
| `- Re: LifeKerr-Mudd,John
`- Re: LifeRobert Riebisch

1
Subject: Life
From: Kerr-Mudd,John
Newsgroups: comp.lang.asm.x86
Organization: dis
Date: Mon, 13 Apr 2020 12:01 UTC
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: notsay...@nospicedham.invalid.org (Kerr-Mudd,John)
Newsgroups: comp.lang.asm.x86
Subject: Life
Date: Mon, 13 Apr 2020 12:01:19 -0000 (UTC)
Organization: dis
Lines: 90
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <XnsAB9E848488925admin127001@144.76.35.198>
Injection-Info: reader02.eternal-september.org; posting-host="921d93f8a8e26d7d38ec8f2522799255";
logging-data="11966"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18N/A2oUZBe1MHlzKpZ1UY93osI4AL8Nps="
User-Agent: Xnews/2006.08.24
Cancel-Lock: sha1:Dt2ie0Jaup0N+N0kznxc79Z9z2s=
View all headers
John Horton Conway left us 2 days ago;
https://en.wikipedia.org/wiki/John_Horton_Conway#Conway's_Game_of_Life

I've been looking at this tiny life implementation in asm:

I think I've figured out how it works; the new life/death is very clever.
(I can't recall where I got it from now; I may have changed some comments
)

; Life simulator, 72 bytes  - Vladislav Kaipetsky and Tenie Remmel
;                 65 bytes  - Mark Andreas

; If no args, regs on startup are:

; AX = BX = 0000h
; SI = IP = 0100h
; DI = SP = FFFEh

;IDEAL
;MODEL TINY
;P386
;CODESEG

;; MJ nasm Feb 2020
cpu 186
ORG 100h

Start:  int     1ah             ; ah=00: cx=hours, dx=tic counter

        mov     al,13h          ; Set mode 13h
        int     10h
        push    09000h          ; DS = last 64K segment
        pop     ds
        push    0A000h          ; ES = video memory
        pop     es
        xchg    ax,dx           ; tick in ax
RandLoop:
        rol     ax,1            ; Generate random number
        adc     [bx],al         ;;; set starting life pattern
        dec     bx
        jnz     RandLoop

; BX will not be equal to 3 the first time this loop is executed, but
; it will be for all other times.   As SI = 0100h and DI = FFFEh on
; startup, SI - DI will be equal to 258.

LifeLoop:
        xchg    cx,ax           ; reset acc
AccLoop:
        add     cl,[di+bx-64]   ; Add in this column
        add     cl,[si+bx-2]                       
        add     cl,[si+bx+318]                     
        dec     bx              ; Loop back        
        jnz     AccLoop

        mov     al,[si]         ; Get center cell
        stosb                   ;;; to screen
        stc                     ; 3 = birth, 4 = stay (tricky):
        rcr     al,cl           ; 1.00?0000x --> 0.0x100?00 (rcr 3)
        and     al,20h          ; ^carry   |         ^
                                ;          +---> 0.00x100?0 (rcr 4)
        or      [si],al         ; Add in new cell     ^
        shr     byte [di-65],5  ; Shift value in prev row

        mov     bl,3            ; 3 iterations in AccLoop
        inc     si              ; Loop while not zero
        jnz     LifeLoop

        mov     ah,1            ; Check for key
        int     16h
        jz      LifeLoop        ; Loop if no key

        xchg    ax,bx           ; Set text mode
        int     10h
        ret                     ; Return

;End     Start
;Note from John:
;You may replace the key check with the following snippet:
;        in      al,60h
;        das
;        jc      LifeLoop





--
Bah, and indeed, Humbug.



Subject: Re: Life
From: Steve
Newsgroups: comp.lang.asm.x86
Organization: Aioe.org NNTP Server
Date: Mon, 13 Apr 2020 12:20 UTC
References: 1
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Bog...@Embarq.com (Steve)
Newsgroups: comp.lang.asm.x86
Subject: Re: Life
Date: Mon, 13 Apr 2020 12:20:27 GMT
Organization: Aioe.org NNTP Server
Lines: 18
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <c1.2b8.49174C$06w@NOVOSAD3.EMBARQ.COM>
References: <XnsAB9E848488925admin127001@144.76.35.198>
Reply-To: Bogus@Embarq.com
Injection-Info: reader02.eternal-september.org; posting-host="921d93f8a8e26d7d38ec8f2522799255";
logging-data="23631"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/MGV3o1IOTtKBqyj4hja5Gzqs54WltszA="
Cancel-Lock: sha1:gt7um9TXyEIEvdII8htwkskKLzQ=
View all headers
Hi,

"Kerr-Mudd,John" <notsaying@nospicedham.invalid.org> writes:
John Horton Conway left us 2 days ago;
https://en.wikipedia.org/wiki/John_Horton_Conway#Conway's_Game_of_Life

   Sorry to hear that.  His biography "Genius at Play, The
Curious Mind of John Conway", by Siobhan Roberts was a
was an interesting book.  Worth reading.

I've been looking at this tiny life implementation in asm:

   Wow.  That will take some time to figure out.

Regards,

Steve N.



Subject: Re: Life
From: Terje Mathisen
Newsgroups: comp.lang.asm.x86
Organization: Aioe.org NNTP Server
Date: Mon, 13 Apr 2020 14:06 UTC
References: 1 2
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: terje.ma...@nospicedham.tmsw.no (Terje Mathisen)
Newsgroups: comp.lang.asm.x86
Subject: Re: Life
Date: Mon, 13 Apr 2020 16:06:21 +0200
Organization: Aioe.org NNTP Server
Lines: 45
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <r71rks$fi2$1@gioia.aioe.org>
References: <XnsAB9E848488925admin127001@144.76.35.198>
<c1.2b8.49174C$06w@NOVOSAD3.EMBARQ.COM>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="921d93f8a8e26d7d38ec8f2522799255";
logging-data="1421"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19WvichSXlXaphymm/zgPYWQe+a5pQmn18="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101
Firefox/60.0 SeaMonkey/2.53.1
Cancel-Lock: sha1:TUk8kn7rMEiHXKQMWYpG0L7goK0=
View all headers
Steve wrote:
Hi,

"Kerr-Mudd,John" <notsaying@nospicedham.invalid.org> writes:
John Horton Conway left us 2 days ago;
https://en.wikipedia.org/wiki/John_Horton_Conway#Conway's_Game_of_Life

Ouch, that's very sad. I first read about Life in Scientific American decades ago. SInce then I have thought about and written a bunch of code to implement it.

The fastest I came up to must have been my submission to Mike Abrash Code Optimization challenge: I knew that I was doing the minimum possible instructions/cell so nobody would beat me on a 386 cpu (I used 32-bit instructions in a 16-bit program). Unfortunately, the competition target was the 486, which was the first x86 with a cache.

David Stafford's code was in fact twice as fast as mine, because he maintained a live list so he only needed to update cells around currently live cells, so even though I ran much faster for the first 200 (or so) iterations when we started with a random 50% live cells, hw blew me away on the remaining 1800 iterations.

    Sorry to hear that.  His biography "Genius at Play, The
Curious Mind of John Conway", by Siobhan Roberts was a
was an interesting book.  Worth reading.

I've been looking at this tiny life implementation in asm:

    Wow.  That will take some time to figure out.

Indeed. A quick read totally failed to show me how it works. :-)

Terje

Regards,

Steve N.



--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"



Subject: Re: Life
From: Robert Riebisch
Newsgroups: comp.lang.asm.x86
Organization: none
Date: Mon, 13 Apr 2020 14:32 UTC
References: 1
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Robert.R...@nospicedham.arcor.de (Robert Riebisch)
Newsgroups: comp.lang.asm.x86
Subject: Re: Life
Date: Mon, 13 Apr 2020 16:32:56 +0200
Organization: none
Lines: 11
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <r71t6j$6uh$1@dont-email.me>
References: <XnsAB9E848488925admin127001@144.76.35.198>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="921d93f8a8e26d7d38ec8f2522799255";
logging-data="8013"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19xncrfetkP2ud7rLnPk/nxl0DSIywJPas="
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
Cancel-Lock: sha1:9WjQpDtSI5DzBq5KC2SK6B6FcI8=
View all headers
Kerr-Mudd,John wrote:

John Horton Conway left us 2 days ago;
https://en.wikipedia.org/wiki/John_Horton_Conway#Conway's_Game_of_Life

Just to mention: "On 11 April 2020, at age 82, he died of COVID-19 at
his home in New Jersey."

--
Robert Riebisch



Subject: Re: Life
From: Kerr-Mudd,John
Newsgroups: comp.lang.asm.x86
Organization: dis
Date: Tue, 14 Apr 2020 11:59 UTC
References: 1 2 3
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: notsay...@nospicedham.invalid.org (Kerr-Mudd,John)
Newsgroups: comp.lang.asm.x86
Subject: Re: Life
Date: Tue, 14 Apr 2020 11:59:18 -0000 (UTC)
Organization: dis
Lines: 32
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <XnsAB9F842291392admin127001@144.76.35.198>
References: <XnsAB9E848488925admin127001@144.76.35.198> <c1.2b8.49174C$06w@NOVOSAD3.EMBARQ.COM> <r71rks$fi2$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="884234c95c7a49a79a3843829e1c0e5c";
logging-data="4176"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/63wcnRjBcIwvstaZXE3nnwEB2A5u13F8="
User-Agent: Xnews/2006.08.24
Cancel-Lock: sha1:0rC1g5maauXQ+NG+JIOiuRakp80=
View all headers
On Mon, 13 Apr 2020 14:06:21 GMT, Terje Mathisen
<terje.mathisen@nospicedham.tmsw.no> wrote:

Steve wrote:
Hi,

"Kerr-Mudd,John" <notsaying@nospicedham.invalid.org> writes:
John Horton Conway left us 2 days ago;

I've been looking at this tiny life implementation in asm:

    Wow.  That will take some time to figure out.

Indeed. A quick read totally failed to show me how it works. :-)


It stores the life state(s) in an array at 0x9000. this uses bit 0 for
current life and bit 5 for new life.
After setting things up with a "random" pattern, the main loop passes
through all points in the array, then checks for a key to end.
The secondary loop is per pixel and gathers the total for the 9 [current
& surrounding] cells into cl. The "stc; rcr al,cl; and al,0x20" cunningly
sets the new life value in bit 5, clearing the other bits. This bit is
moved from newlife to currlife in the already processed part; avoiding
any overlap.




--
Bah, and indeed, Humbug.



1
rocksolid light 0.7.2
clearneti2ptor