Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Digital Archaeology » Computer Arcana » Commodore » Commodore 8-bit » Turbo Assembler question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Turbo Assembler question [message #207435] Thu, 06 January 2011 13:42 Go to next message
Etienne von Wettingfe[1] is currently offline  Etienne von Wettingfe[1]
Messages: 180
Registered: December 2004
Karma: 0
Senior Member
Hi all,

I just started playing around with Turbo Assembler.

I have come across a few examples to print text on the screen.

Like this:

LDX #$00
loop LDA message,x
STA $0400,x
INX
CPX #$04
BNE loop
RTS
message .text "hello"

However the text doesn't appear, some other ASCII characters appear. Now
apparently I have to add $40 first, then it does display the correct text.

Why do the examples claim to print text like my example without adding $40?
And why should you add $40 anyway, it kind of defeats the purpose of .text,
doesn't it?

--
Etienne von Wettingfeld
http://nl.linkedin.com/in/etiennewettingfeld
Re: Turbo Assembler question [message #207436 is a reply to message #207435] Thu, 06 January 2011 13:54 Go to previous messageGo to next message
Dombo is currently offline  Dombo
Messages: 209
Registered: December 2011
Karma: 0
Senior Member
Op 06-Jan-11 19:42, Etienne von Wettingfeld schreef:
> Hi all,
>
> I just started playing around with Turbo Assembler.
>
> I have come across a few examples to print text on the screen.
>
> Like this:
>
> LDX #$00
> loop LDA message,x
> STA $0400,x
> INX
> CPX #$04
> BNE loop
> RTS
> message .text "hello"
>
> However the text doesn't appear, some other ASCII characters appear. Now
> apparently I have to add $40 first, then it does display the correct text.
>
> Why do the examples claim to print text like my example without adding $40?

The character codes (or 'pointers') in screen memory are not ASCII(or
PETSCII for that matter).

> And why should you add $40 anyway,

You would have to subtract $40.

> it kind of defeats the purpose of .text,
> doesn't it?

Not necessarily, there are lots of possible destinations other than
screen memory where ASCII/PETSCII would be more useful than screen
character codes. Also when you use the ROM routines to output text you
will need PETSCII instead of the screen character codes.
Re: Turbo Assembler question [message #207440 is a reply to message #207435] Thu, 06 January 2011 14:54 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: VanessaE

On 06 Jan 2011 18:42:32 GMT
Etienne von Wettingfeld <etienne@xs4none.nl.invalid> wrote:

> Hi all,
>
> I just started playing around with Turbo Assembler.
>
> I have come across a few examples to print text on the screen.
>
> Like this:
>
> LDX #$00
> loop LDA message,x
> STA $0400,x
> INX
> CPX #$04
> BNE loop
> RTS
> message .text "hello"
>
> However the text doesn't appear, some other ASCII characters appear. Now
> apparently I have to add $40 first, then it does display the correct text.
>
> Why do the examples claim to print text like my example without adding $40?
> And why should you add $40 anyway, it kind of defeats the purpose of .text,
> doesn't it?

The better way to print text is to just use the Kernel's BSOUT routine, which
uses PETSCII:

LDX #0
loop LDA msg,X
BEQ end
JSR $FFD2 ; BSOUT
INX
BNE loop
end RTS

msg .text "hello, world"
.byte 13,0

The 0 at the end of the string causes the loop to exit at the BEQ
instruction, and it will also exit if it wraps past 255 characters. Since
this is the BSOUT routine, your X and Y indexes won't be mangled, and you can
use various color codes, cursor movements, etc. by giving their PETSCII codes
(such as that 13, the code for "Return").

--
"There are some things in life worth obsessing over. Most
things aren't, and when you learn that, life improves."
http://starbase.globalpc.net/~ezekowitz
Vanessa E <vaDEneLEssaTEezekTHowISitz@gmail.com>
Re: Turbo Assembler question [message #207441 is a reply to message #207435] Thu, 06 January 2011 17:56 Go to previous messageGo to next message
Joe Forster/STA is currently offline  Joe Forster/STA
Messages: 371
Registered: March 2013
Karma: 0
Senior Member
>      LDX #$00
> loop LDA message,x
>      STA $0400,x
>      INX
>      CPX #$04
>      BNE loop
>      RTS
> message .text "hello"

Isn't there a directive like ".scr", ".screen" or something that
stores characters in screen code rather than the default PETSCII?
Re: Turbo Assembler question [message #207443 is a reply to message #207436] Thu, 06 January 2011 23:20 Go to previous messageGo to next message
dott.Piergiorgio is currently offline  dott.Piergiorgio
Messages: 166
Registered: March 2012
Karma: 0
Senior Member
Il 06/01/2011 19:54, Dombo ha scritto:

> Not necessarily, there are lots of possible destinations other than
> screen memory where ASCII/PETSCII would be more useful than screen
> character codes. Also when you use the ROM routines to output text you
> will need PETSCII instead of the screen character codes.

Perhaps it's because my favorite genre of games are RPG's, but I think
that wanting a routine for handling screen chars is understandable (tile
graphics....)

Best regards from Italy,
dott. Piergiorgio.
Re: Turbo Assembler question [message #207446 is a reply to message #207440] Fri, 07 January 2011 08:14 Go to previous messageGo to next message
Etienne von Wettingfe[1] is currently offline  Etienne von Wettingfe[1]
Messages: 180
Registered: December 2004
Karma: 0
Senior Member
In article <20110106135431.2f268a41@gmail.com>,
VanessaE <vaDEneLEssTEaezeTHkoISwitz@gmail.com> wrote:

> The better way to print text is to just use the Kernel's BSOUT routine, which
> uses PETSCII:
>
> LDX #0
> loop LDA msg,X
> BEQ end
> JSR $FFD2 ; BSOUT
> INX
> BNE loop
> end RTS
>
> msg .text "hello, world"
> .byte 13,0
>
> The 0 at the end of the string causes the loop to exit at the BEQ
> instruction, and it will also exit if it wraps past 255 characters. Since
> this is the BSOUT routine, your X and Y indexes won't be mangled, and you can
> use various color codes, cursor movements, etc. by giving their PETSCII codes
> (such as that 13, the code for "Return").

Thank you Vanessa!

I was using $0400 so I knew where my text would appear. I assume $FFD2
pints at the current cursor position. How do you influence that?

--
Etienne von Wettingfeld [Mac OS X Snow Leopard]
http://www.linkedin.com/in/etiennewettingfeld
Re: Turbo Assembler question [message #207447 is a reply to message #207436] Fri, 07 January 2011 08:16 Go to previous messageGo to next message
Etienne von Wettingfe[1] is currently offline  Etienne von Wettingfe[1]
Messages: 180
Registered: December 2004
Karma: 0
Senior Member
In article <4d260ffd$0$30711$5fc3050@news.tiscali.nl>,
Dombo <dombo@disposable.invalid> wrote:

> Op 06-Jan-11 19:42, Etienne von Wettingfeld schreef:
>> Hi all,
>>
>> I just started playing around with Turbo Assembler.
>>
>> I have come across a few examples to print text on the screen.
>>
>> Like this:
>>
>> LDX #$00
>> loop LDA message,x
>> STA $0400,x
>> INX
>> CPX #$04
>> BNE loop
>> RTS
>> message .text "hello"
>>
>> However the text doesn't appear, some other ASCII characters appear. Now
>> apparently I have to add $40 first, then it does display the correct text.
>>
>> Why do the examples claim to print text like my example without adding $40?
>
> The character codes (or 'pointers') in screen memory are not ASCII(or
> PETSCII for that matter).
>
>> And why should you add $40 anyway,
>
> You would have to subtract $40.

Oops, meant to say that. Well, subtraction is kinda like a reverse
addition.

>> it kind of defeats the purpose of .text,
>> doesn't it?
>
> Not necessarily, there are lots of possible destinations other than
> screen memory where ASCII/PETSCII would be more useful than screen
> character codes. Also when you use the ROM routines to output text you
> will need PETSCII instead of the screen character codes.

Thanks, useful information!

--
Etienne von Wettingfeld [Mac OS X Snow Leopard]
http://www.linkedin.com/in/etiennewettingfeld
Re: Turbo Assembler question [message #207448 is a reply to message #207446] Fri, 07 January 2011 11:59 Go to previous messageGo to next message
iAN CooG is currently offline  iAN CooG
Messages: 613
Registered: April 2012
Karma: 0
Senior Member
Etienne von Wettingfeld <etienne@xs4none.nl.invalid> wrote:

> I was using $0400 so I knew where my text would appear. I assume $FFD2
> pints at the current cursor position. How do you influence that?

$FFF0/65520 Read / Set Cursor X/Y Position

--
-=[]=--- iAN CooG/HVSC & C64Intros ---=[]=-
C= is better than C++
Re: Turbo Assembler question [message #207449 is a reply to message #207441] Fri, 07 January 2011 12:07 Go to previous messageGo to next message
iAN CooG is currently offline  iAN CooG
Messages: 613
Registered: April 2012
Karma: 0
Senior Member
Joe Forster/STA <sta@c64.org> wrote:

> Isn't there a directive like ".scr", ".screen" or something that
> stores characters in screen code rather than the default PETSCII?

Not in any tass around, even in TurboMacroPro/Style.
You usually and #$3f the text bytes or even easily, transfer screen text to
memory in monitor if you're using a c64 with tass only.
Most of crossassemblers have such pseudoop instead. I have scru and scrl in
my own Dasm version.

--
-=[]=--- iAN CooG/HVSC & C64Intros ---=[]=-
Math problems? Call 1-800-10*(24+13)-(64-16)/2^14E2.
Re: Turbo Assembler question [message #207450 is a reply to message #207440] Fri, 07 January 2011 13:59 Go to previous messageGo to next message
rusure is currently offline  rusure
Messages: 1030
Registered: March 2012
Karma: 0
Senior Member
On Jan 6, 12:54 pm, VanessaE <vaDEneLEssTEaezeTHkoISw...@gmail.com>
wrote:
> On 06 Jan 2011 18:42:32 GMT
>
> The better way to print text is to just use the Kernel's BSOUT routine, which
> uses PETSCII:





Directly storing a screen full of characters is faster than printing
them using
the kernal ROM printer. I'm not sure if the odessy of a chracter has
to take
40 years or was the time required programmed into BSOUT on purpose.
Re: Turbo Assembler question [message #207451 is a reply to message #207448] Fri, 07 January 2011 18:52 Go to previous messageGo to next message
Anton Treuenfels is currently offline  Anton Treuenfels
Messages: 105
Registered: December 2011
Karma: 0
Senior Member
"iAN CooG" <GETianRIDcoog@OFaliceME.it.invalid> wrote in message
news:ig7gp1$ptp$1@news.eternal-september.org...
> Etienne von Wettingfeld <etienne@xs4none.nl.invalid> wrote:
>
>> I was using $0400 so I knew where my text would appear. I assume $FFD2
>> pints at the current cursor position. How do you influence that?
>
> $FFF0/65520 Read / Set Cursor X/Y Position

You could also simply add a "screen clear/home" character (decimal 147) to
the start of your output string. As long as the current output device is the
screen (device #3, the default), the routine at $FFD2 will interpret that
character as a command to clear the screen and place the cursor in the top
left corner.

- Anton Treuenfels
Re: Turbo Assembler question [message #207463 is a reply to message #207440] Mon, 10 January 2011 14:08 Go to previous messageGo to next message
Groepaz is currently offline  Groepaz
Messages: 640
Registered: December 2011
Karma: 0
Senior Member
VanessaE wrote:

> The better way to print text is to just use the Kernel's BSOUT routine,
> which uses PETSCII:

wether it is "better" is debatable really. there are more than enough cases
where you dont want to mess around with bsout.

--

http://www.hitmen-console.org http://magicdisk.untergrund.net
http://www.pokefinder.org http://ftp.pokefinder.org

Death has come to our windows.
<Jeremiah 9:21>
Re: Turbo Assembler question [message #207464 is a reply to message #207449] Mon, 10 January 2011 14:08 Go to previous messageGo to next message
Groepaz is currently offline  Groepaz
Messages: 640
Registered: December 2011
Karma: 0
Senior Member
iAN CooG wrote:

> Joe Forster/STA <sta@c64.org> wrote:
>
>> Isn't there a directive like ".scr", ".screen" or something that
>> stores characters in screen code rather than the default PETSCII?
>
> Not in any tass around, even in TurboMacroPro/Style.

..byte "blabla" ?

--

http://www.hitmen-console.org http://magicdisk.untergrund.net
http://www.pokefinder.org http://ftp.pokefinder.org

Wenn Sie schon Raubkopien machen, dann stellen Sie wenigstens sicher, dass
die Qualitaet gut ist. [...] Zeigen Sie etwas Respekt für das Gut, das Sie
stehlen.
<Terry Gilliam>
Re: Turbo Assembler question [message #207465 is a reply to message #207464] Mon, 10 January 2011 16:57 Go to previous messageGo to next message
iAN CooG is currently offline  iAN CooG
Messages: 613
Registered: April 2012
Karma: 0
Senior Member
Groepaz <groepaz@gmx.net> wrote:
> iAN CooG wrote:
>
>> Joe Forster/STA <sta@c64.org> wrote:
>>
>>> Isn't there a directive like ".scr", ".screen" or something that
>>> stores characters in screen code rather than the default PETSCII?
>>
>> Not in any tass around, even in TurboMacroPro/Style.
>
> .byte "blabla" ?

no?

TURBO MACRO PRO v1.1 OCT'05.
MODDED BY ELWIX, MO & THE WIZ OF STYLEA

1: bad line
1000 00 .byte "blabla"
DDDDDDDDDDDDDD
END OF PASS 1: $1000-$1000


:P

--
-=[]=--- iAN CooG/HVSC & C64Intros ---=[]=-
C= is better than C++
Re: Turbo Assembler question [message #207501 is a reply to message #207465] Wed, 12 January 2011 19:39 Go to previous message
Groepaz is currently offline  Groepaz
Messages: 640
Registered: December 2011
Karma: 0
Senior Member
iAN CooG wrote:

> Groepaz <groepaz@gmx.net> wrote:
>> iAN CooG wrote:
>>
>>> Joe Forster/STA <sta@c64.org> wrote:
>>>
>>>> Isn't there a directive like ".scr", ".screen" or something that
>>>> stores characters in screen code rather than the default PETSCII?
>>>
>>> Not in any tass around, even in TurboMacroPro/Style.
>>
>> .byte "blabla" ?
>
> no?

must have been a mod in the version i used back in the days then :)

--

http://www.hitmen-console.org http://magicdisk.untergrund.net
http://www.pokefinder.org http://ftp.pokefinder.org

Liberals by nature look for information and conservatives look for
ammunition.
<Al Franken>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Reverse-engineering the MOS 6502
Next Topic: Geos for Z80 4mhz
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Tue Sep 27 22:55:47 EDT 2022

Total time taken to generate the page: 0.01842 seconds