- [Fixed] BIT instruction doesn't work
- 11 Jul 2019 04:15:01 pm
- Last edited by sledgehogg on 12 Jul 2019 05:59:06 pm; edited 1 time in total
Hi so I'm working on an assembly program that detects if you have a Ti-OS version that supports MathPrint, and then detects whether it's turn on. If it's on it then: turns it off, displays some text with macros that wouldn't work with mathprint, and then turns MathPrint on again. Else it just displays the text. Problem is, the BIT instruction to check if MathPrint is on, doesn't work. Here's the source code.
This is one of my first z80 programs so don't judge:
Code:
The problem lies on line 25, with the bit instruction:
Code:
Please note that i got the information about $44 from here:
http://wikiti.brandonw.net/index.php?title=83Plus:Flags:44
I just don't get what's wrong since i used the exact same syntax in this program, that works a charm.
Code:
try it for yourself, it works fine.
If you know what i did wrong or what i can do to fix it, please help.
Thanks in advance.
EDIT: everything's fine now, don't even bother.
This is one of my first z80 programs so don't judge:
Code:
.nolist
#include "ti83plus.inc"
#define b_call(label) rst $28 \.dw label
.list
.org $9D93 ;normally, the origin would be at $9D95, but we are storing two bytes under this so we take two from $9D95.
.db t2ByteTok, tAsmCmp ;".db" means do byte. Same as ".byte". Comma is because of endianness. see what these actually are in ti83+.inc
b_call(_ClrScrnFull) ;clears the screen, haven't had luck with _ClrLCDFull for some reason
;this part of the code determines if you have version 2.50 or later.
b_call(_GetBaseVer) ;stores the Ti OS version in a and b. if you have 2.55, 2 is stored in a, 55 is stored in c.
cp 2 ;compares a to 2. if a >= 2 then the c flag is reset, if a < 2 it's set.
jr c,nomath ;if c is set, then jump to nomath, eg. mathprint is not supported.
LD HL, $0403 ;for debugging
LD (CurRow), HL ;
LD A, 'I' ;
B_CALL(_PutC) ;
ld a, b
cp 50 ;compares a(b) to 50, which is where mathprint was introduced.
jr c,nomath
LD A, 'I' ;for debugging
b_call(_PutC) ;
;this part determines whether or not mathprint is enabled
bit 5,(iy+$44) ;if bit 5 in flag 44h is reset, mathprint is off and z flag is set. PROBABLY AN ISSUE HERE
jr nz, math ;if z flag is not set, then mathprint is on and we should go to math, else it'll just continue down.
;this part displays the text
nomath:
b_call(_HomeUp); this would make _NewLine not work, if MathPrint was on
ld hl, text ;standard way of loading a string into hl.
b_call(_PutS) ;Puts the String stored in hl onto the screen at the cursor location.
b_call(_NewLine)
ret ;this won't quit the program, since it is a part of the call instruction.
;this part turns off mathprint, calls nomath, and then enables it again
math:
res 5,(iy+$44) ;resets bit 5 in $89F0, which is also iy+$44, this disables MathPrint.
LD A, 'I' ;for debugging, this doesn't display so THIS IS WHERE THE PROBLEM IS.
b_call(_PutC) ;
call nomath ;goes to nomath, returns at next "ret".
set 5,(iy+$44) ;sets bit 5 in iy+$44, which enables MathPrint.
ret
text:
.db "Hello world!", 0
.end
The problem lies on line 25, with the bit instruction:
Code:
bit 5,(iy+$44)
Please note that i got the information about $44 from here:
http://wikiti.brandonw.net/index.php?title=83Plus:Flags:44
I just don't get what's wrong since i used the exact same syntax in this program, that works a charm.
Code:
.nolist
#include "ti83plus.inc"
#define b_call(label) rst $28 \.dw label
.list
.org $9D93
.db t2ByteTok, tAsmCmp
b_call(_ClrScrnFull)
ld hl, 0
ld (CurRow), hl
bit 5,(iy+$44)
jr z, off
ld hl, on
b_call(_PutS)
b_call(_NewLine)
ret
off:
ld hl, zero
b_call(_PutS)
b_call(_NewLine)
ret
on:
.db "mathprint is on", 0
zero:
.db "mathprint is off", 0
.end
try it for yourself, it works fine.
If you know what i did wrong or what i can do to fix it, please help.
Thanks in advance.
EDIT: everything's fine now, don't even bother.