NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: clone4crw on February 25, 2010, 05:18:33 AM

Title: Dyanamically renaming labels
Post by: clone4crw on February 25, 2010, 05:18:33 AM
So here's what I'm wondering: Is it at all possible to dynamically rename a label while a program is being executed? By this I mean treating it as a string and being able to be modified by the code itself? Just some idea that I had.

I guess if you're curious, I'm wasting my free time writing a 16-bit program that will render ASCII animations. Now, these animations for now are being declared as 'Frame001', 'Frame002', etc, and what I'm looking to do is have the program take a string "'Frame', 0x20, 0x20, 0x20, 0", and on the fly change the string accordingly to call up the next frame. (Rename it to 'Frame001', Frame002', etc)

Any ideas or anything?
Title: Re: Dyanamically renaming labels
Post by: Frank Kotler on February 25, 2010, 05:51:26 AM
Think about what a "label" is at runtime - or even in the binary code. Modifying a string isn't going to help.

What you might want to do, if the "frames" are not equal size, is create a table ("array"!) and step through it...

frametable dw frame1, frame2, frame3, frame2, frame1

If they're of equal size, you can calculate the position of each...

Does that help any?

Best,
Frank