Author |
Message |
|
JacobdeHaan
Member
Joined: 10 Jul 2003 Posts: 165
|
Posted: 14 Jul 2003 02:05:53 am Post subject: |
|
|
I've been having tons of fun with ASM in 28 days, but I just got stuck on the second excersice of day ten. I tried to do it, but failed miserably.
Quote: Write a program that will show which graphing mode is active, and allows the user to change it. Use these keys:
[1] — Function
[2] — Polar
[3] — Parametric
[4] — Sequence
This is what I tried
Code: .nolist
#define end .end
#define END .end
#define equ .equ
#define EQU .equ
#include "include/ti83plus.inc"
.list
.org 9D95h
bcall(_runindicoff)
bcall(_clrlcdfull)
ld hl,0
ld (currow),hl
graph:
bit grffuncm,(iy+grfmodeflags)
jr nz,function
bit grfpolarm,(iy+grfmodeflags)
jr nz,polar
bit grfparamm,(iy+grfmodeflags)
jr nz,param
ld hl,sequence
bcall(_puts)
jr getkey
getkey:
bcall(_getkey)
cp kclear
jr z,quit
cp k1
jr z,setfun
cp k2
jr z,setpol
cp k3
jr z,setpar
jr setseq
quit:
ret
setfun:
set grffuncm,(iy+grfmodeflags)
jr graph
setpol:
set grfpolarm,(iy+grfmodeflags)
jr graph
setpar:
set grfparamm,(iy+grfmodeflags)
jr graph
setseq:
set grfrecurm,(iy+grfmodeflags)
jr graph
function: ld hl,func
bcall(_puts)
jr getkey
polar: ld hl,pol
bcall(_puts)
jr getkey
param: ld hl,par
bcall(_puts)
jr getkey
par: .db "parametric ",0
pol: .db "polar ",0
func: .db "function ",0
sequence: .db "sequence ",0
.end
.end
The tutorial said that you use the set and res commands to set system flags, but they didn't work for me. I looked at the answer to the excersice, and he didn't even use those commands to do the program. His went like this to set the mode:
Code: set_func:
ld (iy+GrfModeFlags),%00010000
jr DispCurMode
set_polar:
ld (iy+GrfModeFlags),%00100000
jr DispCurMode
set_param:
ld (iy+GrfModeFlags),%01000000
jr DispCurMode
set_recur:
ld (iy+GrfModeFlags),%10000000
jr DispCurMode
I re-read the tutorial, and I coulnd't figure out why he did this.
In conclusion, how do you know what to store into (iy+grfmodeflags) to set that flag, or any other flag. (the binary doesn't make any sense to me)
Also, if you aren't supposed to use the set/res commands in this program, when do you use them?
This seems to be a simple question compared to all the others on this board, so I bet the answer to this is really simple.
Thanks in advance for any help. |
|
Back to top |
|
|
NETWizz Byte by bit
Bandwidth Hog
Joined: 20 May 2003 Posts: 2369
|
Posted: 14 Jul 2003 04:07:55 am Post subject: |
|
|
Fellow Programmers,
To practice flags, there is nothing better than enabling both Horiz, and G-T split modes at the same time. |
|
Back to top |
|
|
Adm.Wiggin aka Tianon
Know-It-All
Joined: 02 Jun 2003 Posts: 1874
|
Posted: 14 Jul 2003 11:23:49 am Post subject: |
|
|
ok, 'bout the binary... u have the bit number of the flag right?
here is the binary (under is the bit countoff) :
%10101010
%76543210
make sense?
so set 5,(IY + 100)
would be the same as
ld (IY + 100),%00100000
get it?
EDIT
Whoa Jbirk! Scary but cool!
Last edited by Guest on 14 Jul 2003 12:37:27 pm; edited 1 time in total |
|
Back to top |
|
|
JacobdeHaan
Member
Joined: 10 Jul 2003 Posts: 165
|
Posted: 14 Jul 2003 10:43:23 pm Post subject: |
|
|
Thanks, I understand , I knew you guys would know the answer.
So about the set 5,(IY + 100) and ld (IY + 100),%00100000, which one is faster and smaller, or are they essentially the same thing as far as the calculator is concerned? |
|
Back to top |
|
|
Adm.Wiggin aka Tianon
Know-It-All
Joined: 02 Jun 2003 Posts: 1874
|
Posted: 14 Jul 2003 10:47:39 pm Post subject: |
|
|
they are ESSENCIALLY the same thing... but i dunno, ive never used the ld one |
|
Back to top |
|
|
JacobdeHaan
Member
Joined: 10 Jul 2003 Posts: 165
|
Posted: 14 Jul 2003 10:49:26 pm Post subject: |
|
|
Ok, now that I "understand" flags, I'm wondering what you would use Asm_Flag1, 2, and 3 for. Like what would be a good example of their use? |
|
Back to top |
|
|
Adm.Wiggin aka Tianon
Know-It-All
Joined: 02 Jun 2003 Posts: 1874
|
Posted: 14 Jul 2003 10:56:02 pm Post subject: |
|
|
well, as temp vars they would be good... MirageOS uses them... |
|
Back to top |
|
|
JacobdeHaan
Member
Joined: 10 Jul 2003 Posts: 165
|
Posted: 14 Jul 2003 11:21:30 pm Post subject: |
|
|
Alright, I give 'em a try.
Thanks yall for the quick and easy responses. |
|
Back to top |
|
|
CoBB
Active Member
Joined: 30 Jun 2003 Posts: 720
|
Posted: 15 Jul 2003 01:13:16 am Post subject: |
|
|
JacobdeHaan wrote: Thanks, I understand , I knew you guys would know the answer.
So about the set 5,(IY + 100) and ld (IY + 100),%00100000, which one is faster and smaller, or are they essentially the same thing as far as the calculator is concerned?
I'd like to refute Adm. Wiggin's statement: they aren't essentially the same.
set 5,blabla sets bit 5 of blabla and leaves other bits intact.
ld blabla,%00100000 obviously adjusts all the bits at once.
Set/res/bit is slower than ld/and/or/xor, but they allow you to manipulate single bits of various registers and memory locations without having to corrupt the accumulator. You should never use them with the A register though, that's a waste of speed.
Example: set 5,a should be replaced with or %00100000. However, set 5,b could be substituted with push af \ ld a,b \ or %00100000 \ ld b,a \ pop af. Even if you don't need to retain the value of A and leave out the push-pop, set is still better. |
|
Back to top |
|
|
NETWizz Byte by bit
Bandwidth Hog
Joined: 20 May 2003 Posts: 2369
|
Posted: 15 Jul 2003 01:16:08 am Post subject: |
|
|
Adm.Wiggin wrote: ok, 'bout the binary... u have the bit number of the flag right?
here is the binary (under is the bit countoff) :
%10101010
%76543210
make sense?
so set 5,(IY + 100)
would be the same as
ld (IY + 100),%00100000
get it?
EDIT
Whoa Jbirk! Scary but cool!
They are not at all the same!
ld (iy+100),%00100000
The above sets a bit, but also resets (changes to 0) every other bit on the entire byte
set 5,(iy + 100) sets bit 5 but does not touce any other bit.
Now that I have meantioned this, I should probably note that there is no opcode to do the ld (IY+100),# instrution.
You need to use the accumulator when writing to ram.
e.g. ld a,#
ld (IY+100),a
get it? |
|
Back to top |
|
|
NETWizz Byte by bit
Bandwidth Hog
Joined: 20 May 2003 Posts: 2369
|
Posted: 15 Jul 2003 01:17:29 am Post subject: |
|
|
CoBB wrote: JacobdeHaan wrote: Thanks, I understand , I knew you guys would know the answer.
So about the set 5,(IY + 100) and ld (IY + 100),%00100000, which one is faster and smaller, or are they essentially the same thing as far as the calculator is concerned?
I'd like to refute Adm. Wiggin's statement: they aren't essentially the same.
set 5,blabla sets bit 5 of blabla and leaves other bits intact.
ld blabla,%00100000 obviously adjusts all the bits at once.
Set/res/bit is slower than ld/and/or/xor, but they allow you to manipulate single bits of various registers and memory locations without having to corrupt the accumulator. You should never use them with the A register though, that's a waste of speed.
Example: set 5,a should be replaced with or %00100000. However, set 5,b could be substituted with push af \ ld a,b \ or %00100000 \ ld b,a \ pop af. Even if you don't need to retain the value of A and leave out the push-pop, set is still better.
dammit cobb, you beat me to the punch by 3 minutes. |
|
Back to top |
|
|
JacobdeHaan
Member
Joined: 10 Jul 2003 Posts: 165
|
Posted: 15 Jul 2003 01:57:45 am Post subject: |
|
|
Lol!
Anyways, I think I know what you are talking about. I just did the next tutorial on bitwise instructions, and it shed a bit of light on the situation. Thanks! |
|
Back to top |
|
|
Adm.Wiggin aka Tianon
Know-It-All
Joined: 02 Jun 2003 Posts: 1874
|
Posted: 15 Jul 2003 12:14:32 pm Post subject: |
|
|
yes, i was wondering about that as well... i guess ur right! |
|
Back to top |
|
|
JacobdeHaan
Member
Joined: 10 Jul 2003 Posts: 165
|
Posted: 15 Jul 2003 08:34:55 pm Post subject: |
|
|
Well, I believe proof that I somewhat understand what I'm doing is that I tried Jbirk's suggestion, and it worked.
Btw, very cool, with the screen split up into 3 parts. |
|
Back to top |
|
|
Adm.Wiggin aka Tianon
Know-It-All
Joined: 02 Jun 2003 Posts: 1874
|
Posted: 16 Jul 2003 12:20:36 pm Post subject: |
|
|
yes, did it scare u as much as it did me? i was like, "Oh no, that cant be good", but then i typed something and realized, that is what it is supposed to do! |
|
Back to top |
|
|
JacobdeHaan
Member
Joined: 10 Jul 2003 Posts: 165
|
Posted: 17 Jul 2003 01:19:03 am Post subject: |
|
|
Ya, I think I was kinda afraid there for a few seconds, but I also was "stupid" enough to try Jbirks Evil App, so I know he'll do enough to scare you, but not kill your calculator. |
|
Back to top |
|
|
Adm.Wiggin aka Tianon
Know-It-All
Joined: 02 Jun 2003 Posts: 1874
|
Posted: 17 Jul 2003 11:31:46 am Post subject: |
|
|
i did BOTH on an emu
Last edited by Guest on 17 Jul 2003 11:31:53 am; edited 1 time in total |
|
Back to top |
|
|
|