Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: squidgetx on November 08, 2010, 03:30:55 pm
-
Whats the smallest way of writing bits? (I don't care if it's Axe or Asm(HEX) type of thing)
So far the only thing I've come up with is {Pointer}±e^(7-Bit#)→{Pointer}
Use + for writing 1 to the bit, or - for writing 0 to the bit. The only problem is that writing 0 or 1 to a bit that already contains 0 or 1 respectively, will mess everything up.
Does anyone have any ideas?
-
{Pointer} xor %0000 0100
will write the third bit to one. just replace the 1 with whichever bit you're trying to write, and convert the binary into a decmal number. remember, if you're writing a bit to a two-byte area, you need to use the plot-style token instead of xor.
-
{Pointer} xor %0000 0100
will write the third bit to one. just replace the 1 with whichever bit you're trying to write, and convert the binary into a decmal number. remember, if you're writing a bit to a two-byte area, you need to use the plot-style token instead of xor.
Actually, xor will flip the 3rd bit back and forth. If the 3rd bit equals zero, xor will make the 3rd bit equal to 1. If it's 1, xor will make the 3rd bit equal to zero.
Try using {Pointer} and %11111011 to make the 3rd bit equal to zero, for example. Try using {Pointer} or %00000100 to make the 3rd bit equal to one.
-
Thanks both of you!
This makes things a lot easier
-
{Pointer} xor %0000 0100
will write the third bit to one. just replace the 1 with whichever bit you're trying to write, and convert the binary into a decmal number. remember, if you're writing a bit to a two-byte area, you need to use the plot-style token instead of xor.
Actually, xor will flip the 3rd bit back and forth. If the 3rd bit equals zero, xor will make the 3rd bit equal to 1. If it's 1, xor will make the 3rd bit equal to zero.
Try using {Pointer} and %11111011 to make the 3rd bit equal to zero, for example. Try using {Pointer} or %00000100 to make the 3rd bit equal to one.
oops. i forgot about that. of course, or will work too.
-
Out of curosity, are you wanting to make a particular bit one or zero, or does the bit you want to edit change every time that section of code executes?
-
General form: {Pointer}Asm(CBXX)→{Pointer}, where XX is a byte from the following table. In this table, I call bit 0 the least significant bit and bit 7 the most significant bit.
| RESET | SET |
BIT 0 | 85 | C5 |
BIT 1 | 8D | CD |
BIT 2 | 95 | D5 |
BIT 3 | 9D | DD |
BIT 4 | A5 | E5 |
BIT 5 | AD | ED |
BIT 6 | B5 | F5 |
BIT 7 | BD | FD |
-
Runer: Thanks, but I need a routine that will take the pointer and bit # as arguments, so I think Hot_Dog's {Pointer} or %00000100 will be sufficient :)
Hot_Dog; I'm using the bits as flags to show whether the player has completed a certain task or not, so I guess they need to be constant.
So I'm going to go with, if you were going to write it as a subroutine with r1 being the pointer and r2 being the bit number (in Axe's way, with 0 being the most significant), the best way to do this is {r1} or e^(7-r2)→{r1}
Or is it more efficient to write it out every time? (no subroutine calling) just tested it, I think subroutine is better (9 bytes per call I think) and I think the code is ~41 bytes
-
Here's the most optimized way, using standard subroutine calls, to either set or reset a bit of a pointed to byte, with bit 0 being the most significant bit. Input would be in the form of sub(SET/RES,bit,pointer).
Lbl SET
{} or sub(BIT)
Lbl SR2
→{r₂}
Return
Lbl RES
{} and (sub(BIT) xor ᴇFF)
Goto SR2
Lbl BIT
e^(7-r₁)
Return
-
Oh cool, thanks. So I'm guessing that the lack of an argument inside the {} is because it is taking HL as its argument, which is 'pointer' because when you store pointer to r2 it is stored to HL....like ans....kk i'm learning XD
Does every Axe operation leave stuff in HL?
-
Oh cool, thanks. So I'm guessing that the lack of an argument inside the {} is because it is taking HL as its argument, which is 'pointer' because when you store pointer to r2 it is stored to HL....like ans....kk i'm learning XD
Does every Axe operation leave stuff in HL?
Every loading or mathematical operation will put the result in hl. As I mentioned to someone a while ago in a different thread, the hl register is like the "Ans of Axe." All loading operations put the value into hl, and all mathematical operations put the operands into hl and de, calculate, and put the result back into hl. The nice thing about this method is that complex strings of operations can be handled easily. If parentheses or curly brackets are reached, the current value of hl can just be pushed onto the stack for later, and any operations in the parentheses or curly brackets can then be handled using hl. Every time the "depth" of the operation is increased, hl just needs to be pushed, and every time the "depth" decreases, hl can be popped right back.
Note: Just in case anyone reading this doesn't know what pushing and popping are, they are methods of saving and restoring data (respectively). Pushing loads a value onto the top of a stack of values, like a stack of physical objects. Popping takes the top value on the stack and retrieves that. Using this method, you can push multiple values onto the stack and retrieve them in the opposite order that you put them there, allowing things like parentheses to be handled very well. It's explained quite well here (http://future_history.freehostia.com/Files/Resources/ASM/ASMin28Days/lesson/day06.html).
-
Thanks for explaining push/pop. I always wondered what it did, but knew it involved the stack. That might help me a bit when learning ASM.
-
Wait!? DJ, you don't know ASM!?!? I've only been at it 2 weeks and I have almost completely remade Hexpipc (again, but this time it's only 500 bytes). Seriously though, I thought you (being the founder of this forum) would know ASM.
-
I think the language you know doesn't have any relation to how well you program or how fun you can make your games :) In fact many of the other Admins have little or no asm experience (myself included) and yet ive seen them make incredible games as well ^^
-
Wait!? DJ, you don't know ASM!?!? I've only been at it 2 weeks and I have almost completely remade Hexpipc (again, but this time it's only 500 bytes). Seriously though, I thought you (being the founder of this forum) would know ASM.
Let's see, the Admins experience in calc languages (from what I've noticed):
Builderboy: Basic - Excellent Axe - Excellent Asm - Beginner
DJ Omnimaga: Basic - Excellent Axe - Medium Asm - Beginner
Eeems: Basic - Medium Axe - Medium Asm - Medium
Hot_Dog: Basic - Medium Axe - Beginner Asm - Excellent
ztrumpet: Basic - Excellent Axe - Excellent Asm - Beginner
As you can see, not all of the admins know all the languages. :)
-
Wait!? DJ, you don't know ASM!?!? I've only been at it 2 weeks and I have almost completely remade Hexpipc (again, but this time it's only 500 bytes). Seriously though, I thought you (being the founder of this forum) would know ASM.
ASM is a totally different matter than BASIC. I coded BASIC for 9 years and Axe for 6 months. I attempted ASM 3 times, so far, with ASM in 28 days, to no avail. The way the tutorial is written is just not for me. I am planning a 4th attempt with Hot Dog's tutorials, though, now that I learned some memory stuff with Axe.
Also being founder of a forum doesn't mean I automatically know every language. Omnimaga started solely as a TI-BASIC group, after all. Axe just arrived later, and many people switched. Then came Hot Dog's tutorials, which made it easier for people to learn ASM. I think most ticalc.org staff barely programmed at all.
-
Okay. I just always got the impression that you knew ASM. By the way, where can I find Hot Dog's tutorials (link please)? As a side question, what programming languages do you know (calc or otherwise)?
-
Yeah I actually started TI-BASIC around 2001 and stuck with it until 2009 then moved to Axe. I just never could understand ASM. Hopefully maybe Hot Dog's tutorials will change that, though.
Here are his tutorials, by the way: http://www.omnimaga.org/index.php?action=downloads;sa=view;down=594
As for myself, I know TI-BASIC for the TI-81 and 83+ (I did a bit for other calcs but not much) and Axe language. I did VB6 in 2002-03 but I pretty much forgot the few things I learned. That's pretty much it. I was active a lot in BASIC programming around 2001-05 then I coded on and off afterward, while running Omnimaga.
-
Interesting. I do GNU C++, Java, BASIC, Axe, GML, and some ASM.