Assembly: DUP command (MASM/TASM)

Contributor Icon Contributed by William_Wilson Date Icon March 9, 2006  
Tag Icon Tagged: Computer programming

how to use the DUP – duplicate command, nested or un-nested


As it sounds, DUP duplicates text.

Straight Example:

text DB 10 DUP (’W’) ;initializes 20 bytes to W

the number after DB defines how many bytes to repeat for, and then the ‘W’ defines what to repeat.

Nested:

barCode DB 4 DUP(3 DUP (’l’),2 DUP (’|’),5 DUP (’I’))

reserves 40 bytes in total, initialized to: lll||IIIIIlll||IIIIIlll||IIIIIlll||IIIII
each pass through creates lll||IIIII then this is repeated 4 times as it is nested within another DUP command.

Questions/Comments: william_a_wilson@hotmail.com
-William. § (marvin_gohan)

Previous recipe | Next recipe |
 
  • ghoxt47
    very odd
  • Dl
    Why my program(for Dos) work with sf db 80 dup 80(?) and doesn't work with db 80 dup 80(1) ?
blog comments powered by Disqus