Comments (3)
There's a few issues here:
- AT&T mov syntax is backwards, which is why we ended up flipping the variable order
- I don't think we can use the same m(variable) syntax we use in the other ASM format, I don't see mention of it in AT&T syntax.
all registers in AT&T syntax must be prefixed with "%", all literals must be prefixed with "$", dereferencing seems to be done by wrapping the register with "(" and ")" https://csiflabs.cs.ucdavis.edu/~ssdavis/50/att-syntax.htm
Our old definition was
#define ASM_MOV_REG_VAR(register, variable) \
__asm__ __volatile__("mov %0, %%" EXPAND_AND_QUOTE(register) : : "m"(variable) : )
I tried
__asm__ __volatile__("mov $" EXPAND_AND_QUOTE(variable) ", %" EXPAND_AND_QUOTE(register) )
but this results in "error: 32-bit absolute addressing is not supported in 64-bit mode"
$(variable) should grab the value held by the pointer and move it into the register if I understand correctly.
from squally.
@zcanann I'm not sure I understand what the %0 is doing here I understand it points to a stack variable, but yeah we're pretty far from having this right. Here's the example usage
Vec3 ProximityObject::getVelocity()
{
Vec3 velocityCopy = this->velocity;
const volatile float* velocityPtrX = &velocityCopy.x;
const volatile float* velocityPtrY = &velocityCopy.y;
const volatile float* velocityPtrZ = &velocityCopy.z;
static const volatile int* freeMemory = new int[128];
// Push velocity variables onto FPU stack
ASM(push EAX)
ASM(push EBX)
ASM(push ECX)
ASM(push ESI)
ASM_MOV_REG_VAR(EAX, velocityPtrX);
ASM_MOV_REG_VAR(EBX, velocityPtrY);
ASM_MOV_REG_VAR(ECX, velocityPtrZ);
ASM_MOV_REG_VAR(ESI, freeMemory);
ASM(fld dword ptr[ECX])
ASM(fld dword ptr[EBX])
ASM(fld dword ptr[EAX])
from squally.
I think we can avoid at&t syntax here
Here's what stux said
here's how you get your pointer into a register:
int main(){
int x = 42;
int* x_ptr = &x;
asm volatile("nop");
asm volatile("mov rax, %0" : : "r"(x_ptr) : "rax");
asm volatile("nop");
x = 23;
}
generated assembly:
push rbp
mov rbp,rsp
sub rsp,0x20
mov rax,QWORD PTR fs:0x28
mov QWORD PTR [rbp-0x8],rax
xor eax,eax
mov DWORD PTR [rbp-0x14],0x2a ;write 42 to x
lea rax,[rbp-0x14] ; get the address of x
mov QWORD PTR [rbp-0x10],rax ; store the address of x into x_ptr
nop ;sequence begin
mov rdx,QWORD PTR [rbp-0x10]
mov rax,rdx
nop ;sequence end
mov DWORD PTR [rbp-0x14],0x17 ;write 23 to x
mov eax,0x0
mov rcx,QWORD PTR [rbp-0x8]
xor rcx,QWORD PTR fs:0x28
je 1188 <main+0x4f>
call 1030 <__stack_chk_fail@plt>
leave
ret
from squally.
Related Issues (20)
- World Music Stops after first zone [Windows] HOT 2
- Error Installing mpg123 As Part of dep.py HOT 17
- Get rid of insane band-aid fixes to object spawn bug HOT 1
- Better Swim Anims
- Audio-loop of fire not seamless HOT 1
- Memory leak in Music HOT 1
- Language speed normalization
- Vcpkg fails to install mpg123 on fresh install HOT 1
- Syntax Highlighting for Floats Doesn't Capture Negative Sign HOT 1
- No Emerge/Submerge SFX if Squally is up against a wall.
- Non-deterministic Crash on First Two Fights on OSX HOT 2
- Manjaro Linux Launch Issues
- Incomplete build instructions
- [Bug] Lion / Horse Mixup HOT 1
- Im trying to install game for couple days and no success HOT 2
- MSBuild Version with C++ Support
- No Such File: 'cereal/cereal.hpp' HOT 3
- Can't (successfully) run 'python dep.py init' HOT 2
- 'pop' crashes the game HOT 1
- Steam installation crashes on M1 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from squally.