• Please review our updated Terms and Rules here

Recent content by neilobremski

  1. N

    LEA prior to 386 has no multiplication capability ?

    Am I correct that LEA on the 8088/8086 does not support multiplication (by powers of 2)? I've only ever found examples for the 386 and the following excerpt [1] makes no mention of the ability to multiply: [1]. (Intel iAPX 86, 88 USER'S MANUAL, pg. 2-32) Is there a page that documents the...
  2. N

    8088 performance of PUSH/POP vs saving in spare register

    On the 8088, is saving/restoring in a spare register significantly faster than using PUSH/POP? PUSH/POP are single byte instructions which are fantastic for code size but they use memory as part of using the stack. PUSH/POP take 19 to 23 clock cycles together according to Intel specifications...
  3. N

    Fast String Reverse in Assembler

    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...
  4. N

    Random Cubic Polynomial in Assembler

    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...
  5. N

    Seeding Randomness with a String

    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...
  6. N

    RAND() in Assembler

    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...
  7. N

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

    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]...
  8. N

    Innovations in Integer to String (itoa) Methods for 8088?

    This afternoon I've been playing around with writing an itoa() equivalent in x86 assembler. The signature of this method is: void itoa(int input, char *buffer, int radix) The general idea is to divide by the radix, write the remainder as the next digit (in a lookup table of [hexa] decimal...
  9. N

    CGA Tiny Font (4x4)

    In accordance with yesterday's entry on text rendering, I've now created the routine for a "tiny" font. What this does is take the 8x8 glyphs and compresses them into 4x4 squares by creating a sort of average brightness of each pixel based on the surrounding 4. The four distinct colors of CGA...
  10. N

    CGA Text Blit

    I went back and forth over whether or not to write my own text rendering routine in assembler. DOS supplies a decent print string function [1] but it turned out to be insufficient to my needs. My requirements include the ability to change color mid-stream as well as repeat lines of pixel data...
  11. N

    Variable FPS Animation with DDA

    I just finished writing some code to animate movement and turning. When initially planning to tackled this task I was going to make a lot of assumptions and fix the framerate regardless of the computer speed. This would mean that on fast-enough computers the animation would run as expected but...
  12. N

    IDIV and IMUL do not set Sign Flag

    Or more specifically: What it comes down to is that you cannot safely jump (JS / JNS) based on a signed multiply or divide. MOV AX, FF00 ; CWD ; DX:AX = -256 MOV BX, 0012 ; BX = +18 IDIV BX ; JNS $+4 ; WRONG! NEG AX ; AX = ABS(DX:AX / BX) The fix is to re-test the highest byte of the result...
  13. N

    8 Bit Twice Shy aka Size Does Matter

    I've been working with 8-bit fixed point for pre-calculated SINE and COSINE values. One compromise of this is that the maximum positive value is only 127 which means I can only represent 127/128 (0.9921875) and not a whole ONE. Recently I encountered an odd bug where viewing my tile map from a...
  14. N

    Atomic read of 32-bit integer from memory on x86

    Is it possible to perform a 32-bit atomic read from memory on an 8086/8088 without disabling interrupts? I noticed the LDS and LES instructions read a full DWORD for the DS:SI or ES:DI far pointer respectively so I plopped together the following code which abuses the former a bit ... PUSH DS...
  15. N

    Square Raycast

    Magenta's Maze is a tile-based 3D game but the first version supported general 3D objects and used C's qsort() to depth sort objects by their first vertex value. Although this was flexible, it was unnecessary (again: tile-based) and slow! In redesigning it for assembler, I did away with the...
Back
Top