Defining strings

In the data segment, you can rather conveniently 'stack' up your definition. Below is an example where I've made a string that starts with time:, with 28 bytes (set to zero?), then a couple of characters on the end.

SEGMENT data_seg PUBLIC 
  time_out   DB "time:"
             resb 28
             DB "%"
             DB "$

String lengths

The assembler can compute string lengths at assemble time. For the example above, you'd do...

time_out_length EQU $ - time_out

...and be free to use time_out_length anywhere you could normally use a literal. What does it mean? $ equates to the assembler's current location counter which I take it is the byte offset into the binary it's making. time_out likewise must be in this usage the byte offset of the time_out memory location within the binary. Thus, this line must be the very next one after the time_out definition!

-- MattWalsh - 25 Apr 2004

Topic revision: r1 - 25 Apr 2004 - MattWalsh
 
This site is powered by the TWiki collaboration platformCopyright © 2008-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback