ParkourPenguin I post too much
Reputation: 143 Joined: 06 Jul 2014 Posts: 4383
|
Posted: Wed Aug 05, 2020 11:21 pm Post subject: |
|
|
Writing code (i.e. "mov [flag],0") will write bytes into memory the same way writing values (i.e. "dd 0") does. It's as if you wrote this:
Code: | flag:
dd 400
multi:
dd (float)1.1
dd (int)20569 | Since multi only takes up 4 bytes and flag is allocated just after multi, the second dd under multi overwrites the flag.
Labels don't really matter- they represent addresses in memory. Where the label is defined is the address it represents. e.g.:
Code: | multi:
dd (float)1.1
atul: | The label atul represents the address 4 bytes after multi. In this case, it's the same address as flag.
The order of allocs do matter. e.g. if you swapped the flag and multi allocs, the script would still be wrong, but it wouldn't overwrite the flag value.
The "flow of execution" is determined by the instructions (code) you write.
align just aligns values- i.e. puts them at an address some multiple of their size. It's not important if everything has its own alloc like in your original script, but in Betcha's refactoring, they might not be aligned. It's not terribly important (everything would still work); it's just that the cpu has to do more work to access unaligned values.
In the bottom left corner of these forums there should be a link that says "Watch this topic for replies". There should be a setting you can edit in your profile to do this by default (link to profile in top middle). _________________ I don't know where I'm going, but I'll figure it out when I get there.
|
|