0

What would be the equivalent in att syntax for defining some easier-to-read constants at the top of a file?

SYS_READ   equ     0          ; read text from stdin
SYS_WRITE  equ     1          ; write text to stdout
SYS_EXIT   equ     60         ; terminate the program
STDIN      equ     0          ; standard input
STDOUT     equ     1          ; standard output

My thought would be something like:

.section .rodata
SYS_READ:    .byte     0
SYS_WRITE:   .byte     1
# ...

Is this correct or close? If not, what would be the suggested way to define a bunch of constants at the top of an assembly program?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
David542
  • 104,438
  • 178
  • 489
  • 842
  • Read the GAS manual, it has a `.equ` directive which is exactly equivalent. Or a `SYS_READ = 0` syntax for assemble-time constants. Obviously you don't want to put actual data into `.rodata`, that wouldn't be equivalent and you'd have to load it instead of using an immediate. – Peter Cordes Sep 16 '20 at 19:29
  • @PeterCordes in the above case, should I use: `sys_read=0` or `sys_read .equ 0` or define it in the `.rodata` section? – David542 Sep 16 '20 at 19:30
  • You should read the manual or the linked duplicates. That's why I linked this question to them instead of writing a full answer in comments or as an answer. – Peter Cordes Sep 16 '20 at 19:31

0 Answers0