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

o lg2k-1aen

Subject: lg2k-1
Newsgroups: comp.lang.asm.x86
Organization: NNTP Server
Date: Tue, 8 Sep 2020 04:55 UTC
Newsgroups: comp.lang.asm.x86
Subject: lg2k-1
Date: Tue, 08 Sep 2020 04:55:14 GMT
Organization: NNTP Server
Lines: 74
Approved: - comp.lang.asm.x86 moderation team.
Message-ID: <>
Injection-Info:; posting-host="977adf50e65fb70f12ad8b1d87377ca3";
logging-data="1709"; mail-complaints-to=""; posting-account="U2FsdGVkX1+s/E9epTJWikelX+cL9mAEn8CaJepaSl4="
Cancel-Lock: sha1:dBgjTbb7pVWT6BEZTyyr9ruPY0E=
View all headers

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?
org     100h
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
fild    dword[temp]
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:
A nice description can be found here:

Copy dosbox-debug to the same directory as dosbox.exe, then do:
nasm -f bin -o 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.

rocksolid light 0.7.2