5 dup ($) 
Author Message
 5 dup ($)

A little background.  I'm writing a subset of a full assembler, something
akin to the inline assemblers which are available with most compilers.  As
long as it can assemble any existing opcode, aswell as handle "db, dw, etc"
and EQUs, I'll be happy.

I've come across a question which IMO has two valid answers.  As I don't
have to worry about breaking existing code and I don't have any particular
reason to choose one or the other, so I figure you'd be the right people to
ask.  Assuming the current value of location counter ($) is 0, if an
assembler encounters "dd 5 dup ($)" what do you think the assembler should
generate?
a) dd 0, 0, 0, 0, 0
or
b) dd 0, 4d, 8d, 12d 16d

Tasm goes with the former, but then I don't much care what tasm thinks.  So,
if you have any thoughts one way or the other, I'd be interested to read
them.

regards,
-Brent
doomsday AT optusnet DOT com DOT au

PS: While I'm writing a post

pH> Are there *any* programmers who *aren't* also involved with music? <g>

That'd be me ;)



Mon, 31 Oct 2005 23:21:59 GMT  
 5 dup ($)
MASM interprets the assembler directive

        ADDRESS DD 5 DUP ($)

as

        ADDRESS DD ADDRESS,ADDRESS,ADDRESS,ADDRESS,ADDRESS

Personally, I would prefer the interpretation

        ADDRESS DD ADDRESS,ADDRESS+4,ADDRESS+8,ADDRESS+12,ADDRESS+16

which, under different syntax, is the interpretation of the mainframe assembler.

Since you are writing your own assembler, the choice is yours.

-----------------------

Quote:

> A little background.  I'm writing a subset of a full assembler, something
> akin to the inline assemblers which are available with most compilers.  As
> long as it can assemble any existing opcode, aswell as handle "db, dw, etc"
> and EQUs, I'll be happy.

> I've come across a question which IMO has two valid answers.  As I don't
> have to worry about breaking existing code and I don't have any particular
> reason to choose one or the other, so I figure you'd be the right people to
> ask.  Assuming the current value of location counter ($) is 0, if an
> assembler encounters "dd 5 dup ($)" what do you think the assembler should
> generate?
> a) dd 0, 0, 0, 0, 0
> or
> b) dd 0, 4d, 8d, 12d 16d

> Tasm goes with the former, but then I don't much care what tasm thinks.  So,
> if you have any thoughts one way or the other, I'd be interested to read
> them.

> regards,
> -Brent
> doomsday AT optusnet DOT com DOT au

> PS: While I'm writing a post

> pH> Are there *any* programmers who *aren't* also involved with music? <g>

> That'd be me ;)



Tue, 01 Nov 2005 09:04:38 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. +R as a name for DUP >R

2. UNDROP an alternative to ?DUP

3. DUP >R

4. dup

5. Memory behavior of String#dup

6. dup, clone, and "deep copy"

7. self being altered even when .dup'ed

8. dup vs clone

9. Resb and dup in NASM

10. Problem with DUP

11. Resb and dup in NASM

12. DUP

 

 
Powered by phpBB® Forum Software