Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
274 views
Welcome To Ask or Share your Answers For Others

1 Answer

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 into the string.

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...