-2

I am working my way through http://www.amazon.com/Assembly-Language-Step-Step-Programming/dp/0470497025.

Currently, I'm trying to move some of the code around so that I can compile with GAS, instead of NASM (the book's default compiler), and I'm having trouble understanding what some of it means.

This is my source code of confusion

EatMsg: db *Eat at Joe's!* , 10

EatLen: equ $-EatMst

(it's in .section .data)

how would I rewrite it to work with GAS?

lurker
  • 56,987
  • 9
  • 69
  • 103

1 Answers1

1

Generally, you'd have to study the documentation of nasm to see what the construct is doing, then read the gas manual on how to achieve the equivalent thing.

In this case, db is defining some data bytes, and the equ defines an alias for the length, using $ for the current address. The code for gas is:

EatMsg:
    .ascii "*Eat at Joe's*"
    .byte 10
.equ EatLen, . - EatMsg

You could also incorporate the 10 (which is the ascii code of line feed) as \n into the string.

The simplest solution would be to simply install nasm, of course.

Jester
  • 56,577
  • 4
  • 81
  • 125