Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New features (XOR, bitwise operators)
#2
britlion Wrote:Was working for me too.

Boriel, I assume that XOR is used like AND and OR and NOT ?
XOR is the LOGICAL (not bitwise) one. Works like AND, OR, NOT. It's rarely seldom used (I've only seen it implemented in XBASIC). Basically, it checks if only one of the two given conditions is true. For more than two conditions, you should use parenthesis, etc...
Instead of:
Code:
IF X > 5 AND NOT (y < 10) OR NOT (X > 5) AND y < 10 THEN
   ...
END IF
You can write now:
Code:
IF X > 5  XOR y < 10 THEN
   ...
END IF
Which not only is shorter to write, but also faster to run (and take less memory).
Britlion Wrote:How about align? I assume it moves code up to the next 256 byte block (staggeringly useful stuff, that).
What's the syntax and working for that?
The syntax is ALIGN n (N an expression, mostly an integer number).
Code:
;; Aligns the code to start at 256 * n
;; (0, 256, 512, ...)
ALIGN 256
britlion Wrote:Does it just leave a blank space?
(Can we work out how much?)
It leaves "undefined" (usually 0-filled) bytes. The amount of bytes wasted depends on your code position. It simply fills the space until your next code is aligned. This is useful for some speed up optimizations (mostly in x86 architectures). In Z80, for drawing sprites, there's a trick (apenao is using it for his sprites routine). Aligning the code in a 256 boundary (might waste up to 255 bytes!), can speed up read/write memory transfers, since every INC HL and INC DE could be replaced by INC L and INC E respectively which are some t-states faster.
britlion Wrote:Do we automatically get an @label to reference the point - or do we start the block after the align with one?
How do we work out what page it is? @label/256?
Just use a label following the ALIGN N sentence. This label will be a the beginning of your aligned block. You can also use that label in numerical expressions such as MYLABEL / 256.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)