Captain Cozmos Posted September 5, 2022 Share Posted September 5, 2022 I am going over some source code to update my understanding. Being Dino Eggs is going to be a polished AAA title I want to do the best job I can so can someone tell me how this set of statements work. A: EQU (0 << 2) B: EQU (1 << 2) C: EQU (2 << 2) This is actual code and it compiles like every other I have ever used but when I first seen this I thought it is a C statement. My understanding is when you assign a label with a value using EQU then that is it. So what is with the (1<<2) How does this effect the assembler. TIA CC Quote Link to comment Share on other sites More sharing options...
Tony Cruise Posted September 5, 2022 Share Posted September 5, 2022 Most assemblers allow a range of expressions when assigning values, that are evaluated at compile time and the final value output. This allows you to make your code more readable. The << and >> expressions are left and right bit shift statements and the value on the left will be left or right shifted the number of times of the right value. So in your examples: 0 << 2 = 0 1 << 2 = 4 i.e. 00000001 becomes 00000100 2 << 2 = 8 i.e. 00000010 becomes 00001000 1 Quote Link to comment Share on other sites More sharing options...
Captain Cozmos Posted September 5, 2022 Author Share Posted September 5, 2022 (edited) I was going to show a different example but I figured it out. No deleting post for some reason. Edited September 5, 2022 by Captain Cozmos Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.