No Recent Activity
About neilobremski

Basic Information

Age
40
About neilobremski
Biography:
I started programming in GW-BASIC by copying and manipulating example listings given to me by a friend. I didn't have access to any books or other references so my initial education was trial and error alone. It was enough to hook me and now I find myself looking back fondly on those early days of struggle and excitement.
Location:
Seattle, USA
Interests:
Walking, Writing, Reading, Music
Occupation:
Computer Programmer

Statistics

Total Posts
55
Posts Per Day
0.05
General Information
Last Activity
October 16th, 2019 02:28 PM
Join Date
October 9th, 2016
Referrals
0
Home Page
http://gibdon.com/
View neilobremski's Blog

Fast String Reverse in Assembler

by neilobremski on August 17th, 2017 at 02:57 PM
I became interested in string reversal, a common interview question I remember getting, while investigating methods of converting integers to strings. In the discussion thread I started [1] I used disassembled code from MSC 5.1's itoa() routine. I always feel guilty using someone else's code verbatim in projects written from scratch, even if it was assembly code. Below is the inner loop (14 bytes) assuming a load address of 0x100 using DEBUG.

Code:
```0100 DEC DI
0101 LODSB
0102```

Read More

Categories
Asm

Random Cubic Polynomial in Assembler

by neilobremski on July 27th, 2017 at 09:17 AM
I finally reached back into some of my first assembler [1] to write a routine called cubicnom() that generates a random cubic polynomial as the title implies. This pulls together several recent bits of code to seed the random number generator using a string and sprintf the results to a location in memory.

First, here's a random() function which accepts range parameters BX to CX. Thus if I pass in 1 and 9, respectively, then I'll get back

Read More

Categories
Asm

Seeding Randomness with a String

by neilobremski on July 25th, 2017 at 09:38 AM
Random numbers are great but sometimes you want them to be consistently random (an oxymoron!) so that you can rely on their pattern being the same. For example, in Magenta's Maze everything is generated from random numbers that are seeded by the spell name. This is a string which is boiled down to an integer that is used to reset the pseudo-random number generator. Thus, the level generated for a certain string is always the same even across computers and time.

In the first version,

Read More

Categories
Uncategorized

RAND() in Assembler

by neilobremski on July 24th, 2017 at 03:50 PM
The puzzles of Magenta's Maze are generated using the barely sufficient rand() function supplied by MSC 5.1. There are some issues with this, most notably that the highest bit of the 16-bit word output is always zero. The way we C programmers were taught to use this function was to modulus the result by the maximum amount desired thus providing 0 to N - 1 (where N is the maximum). This is unfortunately how Magenta's Maze uses it to place objects within the map and rotate the magic circles.

Read More

Categories
Asm

C's itoa() in Assembler with mini-sprintf bonus

by neilobremski on July 20th, 2017 at 02:14 PM
I've been poking around for a quick way to convert 16-bit words into digit characters a la the itoa() function in C. [1] I thought and searched a lot around dividing by constants and clever ways of converting numbers to strings. In the end, I chose the K&R method as the base for my algorithm [2] which goes like this:

1. Divide number by base (10).
2. Write remainder as next digit (converting to ASCII by adding 30h).
3. Use quotient as number and repeat loop if non-zero.
4. Reverse

Read More

Categories
Asm