Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with .org and equ #100

Closed
kleenexfeu opened this issue Jun 16, 2017 · 4 comments
Closed

Problems with .org and equ #100

kleenexfeu opened this issue Jun 16, 2017 · 4 comments

Comments

@kleenexfeu
Copy link

Hello,
First of all, thanks for such an amazing work, your assembler makes assembly really easy to insert

Using it, I wanted to create structures or enums like this:
.org Myloc
start_new_battle_struct equ .
DoubleWordMega equ (.-start_new_battle_struct) :: .word 0, 0
YourWordLocation equ (.-start_new_battle_struct) :: .word 0
simulated_hitmarker equ (.-start_new_battle_struct) :: .word 0
SlowStartLocation equ .-start_new_battle_struct :: .word 0
size_new_battle_struct equ .-start_new_battle_struct

but it seems that all the things defined through these equ take the value 0.
Are these results normal?

Also, I have a suggestion about the equ :
Would it be possible to make the assembler read all the equ before assembling? They can't be defined twice anyway, and in some case it'd be a lot more practical.

Thanks for your time!

@Kingcom
Copy link
Owner

Kingcom commented Jun 16, 2017

You have to think of equ as being similar to C's #define: it's basically a text (token) replacement, and does not get evaluated where it's defined. Whenever an identifier with the value of the left side of an equ is encountered, it gets replaced by the right side, and then evaluated at that position. This all happens on the token level, before the actual parsing. You should be able to achieve what you want by mostly using labels instead of equ:

.org Myloc
start_new_battle_struct:
DoubleWordMega:  .word 0, 0
YourWordLocation: .word 0
...
.if 1 ; two ways to define the size, pick one
  end_new_battle_struct:
  size_new_battle_struct equ (end_new_battle_struct-start_new_battle_struct)
.else ; this would add an extra label to the symbol table, may not be desired
  .definelabel size_new_battle_struct, .-start_new_battle_struct
.endif

Reading all equs before the actual parsing would at the very least require an additional pass over the input data, and will likely lead to additional complications and unintended side effects. For example, equ could probably be used to overwrite a builtin command that is used before the equ definition (again much like #define).

@kleenexfeu
Copy link
Author

kleenexfeu commented Jun 18, 2017

OK it does make sense, thanks for your answer!
Turned out I didn't get what was in the readme because .definelabel is the directive I needed. It's similar to as' .equ, right?

Still something about equ though: it's not case sensitive, is that intentional?

Also, is there a place more appriopriate to ask questions? Because I have some and they are not issue or something like that. Like : what are all the dll needed to use the assembler? I couldn't find the answer to that question in the source code, and depending the computer I'm using and the version of the OS, I'm not always able to run the built program

@Kingcom
Copy link
Owner

Kingcom commented Jun 18, 2017

If equ is a #define, then .definelabel is a const int. It gets evaluated in place and the actual value is then used wherever it's referenced. All symbols are case insensitive, for better or worse.

There isn't really a better place, unfortunately. The dependencies should be pretty light though, basically only the Visual Studio 2015 C++ redistributable (64 or 32 bit, depending on the version you built) as far as I'm aware.

@kleenexfeu
Copy link
Author

Ok, thank you again for your responses!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants