Jump to content
IGNORED

Understanding of code


Captain Cozmos

Recommended Posts

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

 

Link to comment
Share on other sites

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

  • Thanks 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...