Author |
Message |
|
splinter
Newbie
Joined: 04 Apr 2010 Posts: 21
|
Posted: 04 Apr 2010 07:32:09 am Post subject: |
|
|
Hi i'm new here and i'm from germany so my english isn't that good.
I was wondering how to make a line break, well I already found a solution but this solution has caused another problem...
Here is my code that is doing an output, a line break and another output:
Code: #define TI83
#include "ion.inc"
; ## ION-HEADER (Begin)##
.binarymode TI83
.org progstart
ret
jr nc,main
title .db "Line Break",0
; ## ION HEADER (END) ##
.deflong break()
ld A, 1
add A, currow
ld (currow), A
ld A, 0
ld (curcol), A
.enddeflong
main:
call _clrLCDFULL
ld A, 0
ld (currow), A
ld (curcol), A
ld HL, str_msg
call _puts
call _getkey
break()
ld HL, str_msg2
call _puts
call _getkey
ret
str_msg .db "Some text",0
str_msg2 .db "Also some text",0
I'm using Brass to assemble the code so I'm using .deflong ... .enddeflong instead of MACRO ... ENDMACRO or something like that.
First the value 0 is loaded in currow and curcol then the program outputs a string and calls the macro break() which causes a line break.
In the macro i add 1 to the current value of currow and load the amount into currow so the cursor is always in the next line.
After that, the program should output another string but it doesn't, it only outputs the first character like this:
Some text
A
that's all.
So how to fix this?
greets
[EDIT]
Sorry for this stupid question, I just found out how to make a line break without handling with currow: call _newline or: bcall(_newline)
Sometimes the solution is too simple to get it...
Last edited by Guest on 04 Apr 2010 11:26:20 am; edited 1 time in total |
|
Back to top |
|
|
FloppusMaximus
Advanced Member
Joined: 22 Aug 2008 Posts: 472
|
Posted: 05 Apr 2010 10:01:20 pm Post subject: |
|
|
Quote: ld A, 1
add A, currow
This is not what you want. What is the difference between ld a, currow and ld a, (currow)?
Also, most assemblers should give you an error, or at least a warning, on the second line. In fact, I'm rather surprised that Brass would let you do that. |
|
Back to top |
|
|
splinter
Newbie
Joined: 04 Apr 2010 Posts: 21
|
Posted: 08 Apr 2010 10:57:07 am Post subject: |
|
|
I was really sure that I add 1 to the current cursor position.
So whats the difference between ld A, currow and ld A, (currow)
Am I loading the address of currow into A (or at least the first eight bits because an address is 16 bits long, isn't it?) when I type this line?: ld A, currow |
|
Back to top |
|
|
calc84maniac
Elite
Joined: 22 Jan 2007 Posts: 770
|
Posted: 08 Apr 2010 01:12:35 pm Post subject: |
|
|
Splinter wrote: I was really sure that I add 1 to the current cursor position.
So whats the difference between ld A, currow and ld A, (currow)
Am I loading the address of currow into A (or at least the first eight bits because an address is 16 bits long, isn't it?) when I type this line?: ld A, currow
That is correct (it actually loads the least significant eight bits. Typically, assemblers will warn if the value is too large)
ld a,(currow) will load A from an absolute position in memory, which for convenience's sake we have named "currow" |
|
Back to top |
|
|
splinter
Newbie
Joined: 04 Apr 2010 Posts: 21
|
Posted: 08 Apr 2010 03:14:33 pm Post subject: |
|
|
OK, thanks for the explanation.
But I don't understand the last line you wrote (I'm from Germany).
I thought ld A, (currow) will load the value of currow into A?
If not, how do I add 1 and the current cursor position (currow)?
One last (maybe) question: What is this currow called? Is this a variable (constant)
Last edited by Guest on 08 Apr 2010 03:27:28 pm; edited 1 time in total |
|
Back to top |
|
|
calc84maniac
Elite
Joined: 22 Jan 2007 Posts: 770
|
Posted: 08 Apr 2010 03:38:08 pm Post subject: |
|
|
Splinter wrote: OK, thanks for the explanation.
But I don't understand the last line you wrote (I'm from Germany).
I thought ld A, (currow) will load the value of currow into A?
If not, how do I add 1 and the current cursor position (currow)?
One last (maybe) question: What is this currow called? Is this a variable (constant)
You can increase the value of currow like this:
Code: ld a,(currow)
inc a
ld (currow),a
currow is just a 16-bit constant pointer, "844Bh"
So this code really assembles to
Code: ld a,(844Bh)
inc a
ld (844Bh),a
|
|
Back to top |
|
|
splinter
Newbie
Joined: 04 Apr 2010 Posts: 21
|
Posted: 08 Apr 2010 03:54:52 pm Post subject: |
|
|
Ah, OK, thanks now I understand.
So i can only add a register and a constant pointer like so: add REGISTER, (constPointer) or add (constPointer), REGISTER?
[EDIT]
It works! Thanks!
Code: ld A, (currow)
inc A
ld (currow), A
ld A, 0
ld (curcol), A
I'm very happy now :biggrin:
Last edited by Guest on 08 Apr 2010 04:03:56 pm; edited 1 time in total |
|
Back to top |
|
|
calc84maniac
Elite
Joined: 22 Jan 2007 Posts: 770
|
Posted: 08 Apr 2010 08:41:50 pm Post subject: |
|
|
Unfortunately, in z80 you are quite limited in what registers you can use in commands.
8-bit add works as follows:
add a,<r> where <r> is one of the following: B,C,D,E,H,L,(HL),A (these are the typical arguments in most 8-bit commands)
So you could do:
Code: ld hl,currow
add a,(hl)
In fact, the inc command can take any of those 8 arguments as well. So you can optimize your code like:
Code: ld hl,currow
inc (hl)
|
|
Back to top |
|
|
splinter
Newbie
Joined: 04 Apr 2010 Posts: 21
|
Posted: 09 Apr 2010 05:07:05 am Post subject: |
|
|
OK, thank you.
I should rather read my tutorial twice
Anyway, thanks to you.
I can also simply do it like this:
Code:
ld A, (currow)
add A, 1
ld (currow), A
If I want to add a specified number to currow.
greets
Last edited by Guest on 09 Apr 2010 05:07:42 am; edited 1 time in total |
|
Back to top |
|
|
|