» Goto page Previous  1, 2
You're loading a 16-bit value into pencol, which is overwriting penrow. Penrow and pencol are both 8-bit values that are contiguous in memory, so when you write a 16-bit value to pencol, you overwrite both penrow and pencol. You have two options, the optimized version:

Code:
```ld hl, (40*256)+30 ld (pencol), hl```
Code:
```ld a,30 ld (pencol),a ld a,40 ld (penrow),a```

Code:
``` ld hl, (40*256)+30 ```

Care to explain this bit?
Also, would it still have worked had I used any other register such as b ?
techboy6601 wrote:

Code:
``` ld hl, (40*256)+30 ```
Care to explain this bit?
I care to do so. Basically, hl, bc, de, ix, iy, sp, and pc are 16-bit (2-byte) registers. hl, de, and bc are particularly useful in that you can access then as two 8-bit registers, like h and l, or as a combined 16-bit value hl. These two are equivalent:

Code:
```ld h,40 ld l,30 OR ld hl,(40*256)+30```

Decimal 40 in binary is 00101000. Decimal 30 in binary is 00011110. If you were to load h with 40 and l with 30, h would contain %00101000, l would contain %00011110, and hl would just be h and l concatenated, the 16-bit value %0010100000011110.

Now the fun part. 2^8 = 256, so if you multiply a value by 256, you're basically inserting 8 zeroes at the end of its binary representation. (40*256)+30 = 10270. In binary, that value is 0010100000011110. Look familiar?
Utilizing that knowledge, I have created this:

Code:
``` ld hl, (40*256)+30     ld (curcol), hl     ld hl, RAM     bcall(_PutS) RAM: .db "RAM", 0 ```

However, this is happening:

Can you explain this phenomenon?

EDIT What does Eh represent?[/b]
Your screenshot isn't working here, but I assume the problem is that there is no ret after bcall(_PutS) so the program continues and tries to execute your string.
benryves wrote:
Your screenshot isn't working here, but I assume the problem is that there is no ret after bcall(_PutS) so the program continues and tries to execute your string.
I think a more pressing problem is trying to use values of 40 and 30 with curcol and currow, considering that curcol={0,15} and currow={0,7}.
New question:

How would one disable the run indicator?
That would be BCALL(RunIndicOff)

http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:4570

And as you should before you exit your program turn it back on with
BCALL(RunIndicOn)
Ahah. Thanks.
You can also save the overhead of a bcall by setting/resetting the run indicator flag directly:

Code:
```res indicrun,(iy+indicflags) set indicrun,(iy+indicflags)```

Code:
``` set indicrun, (iy+indicflags) ```

This always intrigued me. I know what it does, but how?

EDIT http://wikiti.brandonw.net/index.php?title=83Plus:Flags:12

Looking at this page, I figured out why it was indicrun and indicflags. But what is iy, and why is it in parentheses with a + sign?
IY is one of 2 index registers. These are special registers that can act as a pointer to data with an offset. like (hl), this is (iy+2) or w/e. IY is used by TIOS to point to an area in RAM that hold a bunch of flags.
Adding to that, if you change the value of iy during the execution of your program, eg. ld iy,10, you need to set it back to it's original value (i think it's \$89F0?) before quitting or using any bcalls that rely on the flags, because the OS expects IY to always have that value. That's how you can do IY+XX to change the flags, because it always holds the same address in memory.

Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

»
» Goto page Previous  1, 2
» All times are UTC - 5 Hours

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum