0 Members and 2 Guests are viewing this topic.
BOOLEANS - Booleans are a whole byte because it takes extra instructions to extract/insert just one bit, which adds more than just another byte to the program just for using it; so it actually saves space that way.
Sorry DJ ... I began posting about it in both places, and got a decent initial response in both. However, it only REALLY took off at Cemetech, and thus decided to keep most of the posts there (they are time consuming, because they are thought out). Rather than just abandon [these people] altogether, I left notifications ... but I see how that could be a problem. I don't want to "steal" followers from one site to another, and I suppose I could have just copied posts and reposted them here. So much information was interchanged at Cemetech that I found it would be an overwhelming task to keep it all in both places; however, to give SOMETHING of substance, perhaps I will go back and take the key points and put them in a post here. That way there is a glimpse of what's going on, and some of the key discussion.However, my project is hosted at google code ( http://code.google.com/p/opia/ ), and even when I discuss it anywhere, I leave links there regularly, because that is where one must go to see the language documentation and source etc. (I am not going to host it in multiple places). I will, however, go back and put a lot of the key discussion here as well.Sorry for the misunderstanding! ... I promise a lot of information HERE soon.
switch(value) { case 1: ... 2: ... 3: ... } ---Jump Table--- --Look-Up-Table-- --Direct_Address-- ld a,(value) ;3 ld hl,cases ;3 ld hl,(value) ;3 ld ($+4),a ;3 ld bc,(value) ;4 jp (hl) ;1 jr N ;2 add hl,bc ;1 jp case_1 jp (hl) ;1 jp case_2 cases: jp case_3 .dw case_1 .dw case_2 .dw case_3 ---------------- ----------------- ------------------ = 8 (+3 per case) = 9 (+2 per case) = 4 bytes used (+0)
// enum usage enum Foo {X,Y,Z} Foo f1 = Foo.X; f2 := Foo.X; // switch "on Foo" switch(Foo) g1 = g1.X; // "g1.X" because g1 uses specific case-addresses g2 := switch(Foo).X; // g2 uses case-addresses that DIFFER from g1... g1 = g2; // ...which means that THIS IS NOT ALLOWED // switch on anonymous enum switch{X,Y,Z} h1 = h1.X; h2 := switch{X,Y,Z}.X; // Later on, g1 is used in a switch statement: switch(g1) { case X: ... case Y: ... case Z: ... // NO default code (all cases are explicit) }