Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

On a clear disk you can seek forever. -- P. Denning


programming / comp.lang.asm.x86 / lg2k-1

SubjectAuthor
o lg2k-1aen

1
Subject: lg2k-1
From: aen...@nospicedham.spamtrap.com
Newsgroups: comp.lang.asm.x86
Organization: Aioe.org NNTP Server
Date: Tue, 8 Sep 2020 04:55 UTC
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: aen...@nospicedham.spamtrap.com
Newsgroups: comp.lang.asm.x86
Subject: lg2k-1
Date: Tue, 08 Sep 2020 04:55:14 GMT
Organization: Aioe.org NNTP Server
Lines: 74
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <5f570e64.424310953@nntp.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="977adf50e65fb70f12ad8b1d87377ca3";
logging-data="1709"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+s/E9epTJWikelX+cL9mAEn8CaJepaSl4="
Cancel-Lock: sha1:dBgjTbb7pVWT6BEZTyyr9ruPY0E=
View all headers
Hi!

I wrote this little sucker a long time ago.  The algorithm to draw it
is I think from the TAOCP series of books, and it was mentioned that
it appears on the cover of a book, but I simply can't find that
reference anymore.  Does anyone regognize it?
----------
lg2k-1.asm
----------
org     100h
fninit
fldcw   [CW_floor]
mov     ah,0fh
int     10h
mov     byte[old_mode],al
mov     ax,0eh
int     10h
mov     ebp,1
..0: lea eax,[ebp*2-1]   ; 2k - 1.
mov     [temp],eax
fld1
fild    dword[temp]
fyl2x
fld     st0             ; lg 2k - 1.
fistp   qword[temp]
fild    qword[temp]
fsubp   st1,st0         ; lg 2k - 1 (mod 1).
fmul    dword[f100_0]
fistp   qword[temp]
mov     edx,[temp]
add     edx,edx
lea     ecx,[ebp*4+ebp]
add     ecx,ecx
mov     ax,0c0fh
..1: int 10h
inc     ecx
cmp     ecx,640
jb      .1
inc     ebp
cmp     ebp,64
jb      .0
xor     ah,ah
int     16h
mov     ax,[old_mode]
int     10h
mov     ax,4c00h
int     21h

align   16
temp    dq      0.0
f100_0  dd      100.0
CW_floor        dw      0000011101111111b
old_mode        dw      0

This can BTW be nicely visualized with dosbox-debug.exe, since it runs
in its own window.

Download the fitting version for your DOSBox here:
https://www.vogons.org/viewtopic.php?t=7323
A nice description can be found here:
https://zwomp.com/index.php/2020/05/01/understanding-the-dosbox-debug-screen/

Copy dosbox-debug to the same directory as dosbox.exe, then do:
nasm -f bin -o lg2k-1.com lg2k-1.asm
copy the com file to where you mounted c in DOSBox.

Then start dosbox-debug and in the dosbox window type:
debug lg2k-1
Change to the debug window, scroll the code pane down to inc ebp,and
set a breakpoint at it with F9, then repeatedly hit the F5 button and
you can watch it drawing.
--
aen



1
rocksolid light 0.7.2
clearneti2ptor