• Some Questions about 6502 Assembler...

    From David Mueller@david.mueller@post.rwth-aachen.de to comp.sys.cbm on Monday, July 14, 2003 08:36:33
    From Newsgroup: comp.sys.cbm

    Hi there...

    I don't know if this is the right Group, but since there ist no comp.lang.6502... :)
    I just startet again to program my c64 in Assembler (I'm quite astonished
    that I still know that much) and now I realize that I can't remember some
    very simple things:

    - How can I display the Value of an Adress on the Screen in _decimal_? IIRC there is some routine in the BASIC-Rom which can do this, but I'm not sure. and reading through the Memory-Map-Document from project 64 didn't help
    either

    - What is the fastest way to put text on the screen? I think it's by
    POKEing the Values right into the Scrren RAM ($0400) but I still know there are Kernel-Routines called "CHROUT" or "STROUT" or something like that.

    - How can I turn on and off the LED of the Floppy? I have seen some Demos which do this, should be just one POKE ?

    And generally I'm looking for some complete Documentation to the Opcodes of the 6502, even the "illegal" ones.

    Thank's a lot for your help!

    David
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Wolfram Sang@wolfram@iswi.org to comp.sys.cbm on Monday, July 14, 2003 10:58:36
    From Newsgroup: comp.sys.cbm


    And generally I'm looking for some complete Documentation to the Opcodes of the 6502, even the "illegal" ones.

    http://www.the-dreams.de/aay.html

    Hope it helps :)

    Best wishes

    Ninja / The Dreams

    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Thomas Mⁿller@eous@gmx.de to comp.sys.cbm on Monday, July 14, 2003 11:44:18
    From Newsgroup: comp.sys.cbm

    Hmm, I'd try

    ; Turn LED on
    LDA #$08
    ORA $1C00
    STA $1C00

    and

    ; Turn LED off
    LDA $1C00
    AND #$F7
    STA $1C00

    executed inside the 1541. There is no single routine for turning it off,
    only inside the power-up self-test. For turning the LED on, you could also
    try to do a "M-E" command with address $C118. But I think you have to upload these commands by yourself before you can turn the LED on and off... You definitely can't do this with POKEing in the C64 RAM.

    Thomas


    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From fritzr@fritzr@dc4pc.net (Fritz Reinders) to comp.sys.cbm on Tuesday, July 15, 2003 07:56:29
    From Newsgroup: comp.sys.cbm


    http://project64.c64.org/hw/c64.html

    more resources at
    http://www.funet.fi/pub/cbm/index.html
    ftp://ftp.funet.fi/pub/cbm/index.html
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From fjb@fjb@pathcom.com (Jim Butterfield) to comp.sys.cbm on Tuesday, July 15, 2003 23:27:44
    From Newsgroup: comp.sys.cbm

    On 14 Jul 2003 08:36:33 GMT, David Mueller
    <david.mueller@post.rwth-aachen.de> wrote:

    - How can I display the Value of an Adress on the Screen in _decimal_? IIRC >there is some routine in the BASIC-Rom which can do this, but I'm not sure.

    You can, of course, just do the arithemetic, by dividing repeatedly by
    10 .. each time, the remainder is a decimal digit which you can
    convert to ASC/PTSC printable with a simple OR command. (Division is
    a whole other subject). Another way to do the arithmetic elegantly is
    an algorithm to use decimal mode to quickly convert binary to decimal
    (again, details not included; if interested, ask).

    - What is the fastest way to put text on the screen? I think it's by
    POKEing the Values right into the Scrren RAM ($0400) but I still know there >are Kernel-Routines called "CHROUT" or "STROUT" or something like that.

    POKE-ing is faster than CHROUT; this last is a "universal output"
    routine that will send to screen, printer, disk file, whatever.

    If you're looking for a sudden screen change (wham!), you can build
    the screen at selected addresses elsewhere in memory and then, with
    suitable POKE commands, make THAT memory the screen address.

    --Jim



    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 80,000 Newsgroups - 16 Different Servers! =-----
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Matthew W. Miller@mwmiller@columbus.rr.com to comp.sys.cbm on Wednesday, July 16, 2003 04:53:27
    From Newsgroup: comp.sys.cbm

    On 14 Jul 2003 08:36:33 GMT, David Mueller
    <david.mueller@post.rwth-aachen.de> wrote:
    - How can I display the Value of an Adress on the Screen in _decimal_?
    IIRC there is some routine in the BASIC-Rom which can do this, but I'm
    not sure. and reading through the Memory-Map-Document from project 64
    didn't help either

    Memory map? Which one? Sheldon Leemon's _Mapping the Commodore 64_ is
    pretty thorough. Try LINPRT ($BDCD), which prints a number whose low
    byte is in .X and whose high byte is in .A.

    - What is the fastest way to put text on the screen? I think it's by
    POKEing the Values right into the Scrren RAM ($0400) but I still know
    there are Kernel-Routines called "CHROUT" or "STROUT" or something
    like that.

    Yes. CHROUT ($FFD2) prints the character in .A, STROUT ($AB1E) prints
    the zero-terminated string (less than 255 characters I believe?) at the address which is stored as low byte in .A, high byte in .Y.

    - How can I turn on and off the LED of the Floppy? I have seen some
    Demos which do this, should be just one POKE ?

    You would have to send custom programming to the drive's CPU. That's
    way beyond my ken. Suggestion: Disassemble one of those demos and
    rustle through it. ;)

    And generally I'm looking for some complete Documentation to the
    Opcodes of the 6502, even the "illegal" ones.

    First, note that the C64's CPU is a 6510, not 6502. The difference is
    subtle but profound. Especially if you're a daredevil using the
    undefined ('illegal') opcodes. :)
    Second, opcodes... wow, that's a biggie. Especially with the
    undefined ('illegal') opcodes, which aren't guaranteed to work
    consistently on, well, anything, including the same CPU from one moment
    to the next.

    Table: http://www.applefritter.com/apple1/members/pom1/Docs/m6502/6502-6510-8500-8502%20Opcodes.htm

    Descriptions: http://www.applefritter.com/apple1/members/pom1/Docs/m6502/6502%20C64%20Programmer%20Guide.txt

    Descriptions, including undocumented opcodes: http://www-2.cs.cmu.edu/~dsladic/vice/doc/64doc.txt http://wwwstud.ira.uka.de/~s_tomczy/opcodes.html

    Be careful, and remember that a little knowledge can be a dangerous
    thing. Let everyone on the newsgroup know when you code up something
    cool. :)
    --
    Matthew W. Miller <mwmiller@columbus.rr.com>
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From fjb@fjb@pathcom.com (Jim Butterfield) to comp.sys.cbm on Wednesday, July 16, 2003 12:44:22
    From Newsgroup: comp.sys.cbm

    On Tue, 15 Jul 2003 23:27:44 GMT, fjb@pathcom.com (Jim Butterfield)
    wrote:

    (... details not included; if interested, ask).

    In response to an email followup from David Mueller. Note that this
    is somewhat cryptic; my posting service doesn't seem to be able to
    cope with longer uploads. (Why? why?)

    How can I divide a Number by ten?

    Subtract ten repeatedly until the result is less than ten,
    while counting the subtractions. For a 16-bit number,
    subtract 10,000 repeatedly, then subtract 1000 repeatedly;
    each time, you'll get a decimal digit. That's generally how
    it's done in the kernal, but a general division algorithm may
    be better.

    I seem to remember that
    dividing by two is done by just rotating ...
    But I really can't remember how to do this with any number besides 2.

    You're right about "two"; other numbers take a little more
    coding. Here's how a general division algorithm works: Take
    the number to be divided, and tack a zero byte at the high-order
    end. Now shift the whole mess one bit to the left. Check the
    (previously zero) byte at the top, to see if it's higher that
    your divisor (ten in this case). If it is, subtract the
    divisor and set the low bit in the quotient. Repeat this
    shifting left, testing, subtracting if necessary, for as many
    times as you have bits in the original number; be sure to
    shift the quotient left each time, too. The remainder will be
    in the high (originally zero) bit.

    Try working this out on paper first; an elegant trick is to
    put the quotient into the space the original number occupied;
    thus, as the number moves out, the quotient moves in and the
    single left-shift sequence does both.

    And what is this algorithm, using the "decimal" mode?

    Simpler, and quite astonishing. Set up a decimal (BCD) zero
    result area. Now, for each bit of the argument:
    -shift the whole argument one bit left; don't touch the
    resulting carry bit;
    -in Decimal mode, add the BCD result area to itself. You'll
    be doubling the number (in BCD mode); and if the carry bit was
    set, you'll also add one.
    When you've done this for all the bits of the argument, the
    BCD area will contain the decimal value. You'll have to split
    apart the two digits in each byte, of course, for printing.

    --Jim



    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 80,000 Newsgroups - 16 Different Servers! =-----
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From kottira@kottira@chello.at (Franz Kottira) to comp.sys.cbm on Wednesday, July 16, 2003 15:41:42
    From Newsgroup: comp.sys.cbm

    Hi Paul,

    r_u_sure@mybluelight.com (Paul Rosenzweig) wrote in message news:<dda6e12f.0307141002.a239972@posting.google.com>...
    David Mueller <david.mueller@post.rwth-aachen.de> wrote in message news:<Xns93B86BEA88D45davidmuellerpostrwth@baneinc.my-fqdn.de>...
    Poking the screen is the fastest way to transmit data to the screen
    but to get results nearly equivalent to character printing, you
    need to subject character data to the following transformation:

    Fill a 7 element array with the following data:

    128,0,64,32,64,192,128,128

    Set the subscript of the array element to the ascii value of
    the character divided by 32. (Note that the zeroth element
    <128> is not used and is needed only to simplfy the logic)

    Exclusive OR the ascii value of the character with the
    selected array element and poke the result to the screen

    There is a faster way to translate pet-ascii to screencode:

    asl
    php
    asl
    plp
    ror
    lsr

    The result should be the same as with your methode.

    Franz
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From spacerogue5@spacerogue5@yahoo.com (Vasko Altiparmakov) to comp.sys.cbm on Thursday, July 17, 2003 02:39:27
    From Newsgroup: comp.sys.cbm

    David Mueller <david.mueller@post.rwth-aachen.de> wrote in message news:<Xns93B86BEA88D45davidmuellerpostrwth@baneinc.my-fqdn.de>...
    Hi there...

    I don't know if this is the right Group, but since there ist no comp.lang.6502... :)

    It should be right.

    I just startet again to program my c64 in Assembler (I'm quite astonished that I still know that much) and now I realize that I can't remember some very simple things:

    - How can I display the Value of an Adress on the Screen in _decimal_? IIRC there is some routine in the BASIC-Rom which can do this, but I'm not sure. and reading through the Memory-Map-Document from project 64 didn't help either

    Puting the value of an address on the screen if quite simple in
    hexadecimal. Maybe if you use BCD it can be done the same way in
    decimal? I don't have mutch expirience with BCD.

    - What is the fastest way to put text on the screen? I think it's by
    POKEing the Values right into the Scrren RAM ($0400) but I still know there are Kernel-Routines called "CHROUT" or "STROUT" or something like that.

    You should use standard Kernel routines. I don't have my reference
    book, and a am a lot off shape for C64. Basicly you put a zterminated
    string in memory and then call $ffd2 :( i think, with the start
    address of the text. The routine will put the text starting from
    curent cursor position. You can easily modify the cursor position on
    the zero-page, or by some Kernel routine.
    Standard Kernel routines for puting out text are fast enuff for normal
    work. You may need to write directly to the screen only when useing
    raster irq's.

    I don't know what you mean by Pokeing directly to screen. The basic
    poke command is veeeery slow. Million time slower than sta $[address].

    - How can I turn on and off the LED of the Floppy? I have seen some Demos which do this, should be just one POKE ?

    Can't help.

    And generally I'm looking for some complete Documentation to the Opcodes of the 6502, even the "illegal" ones.

    Run a search on Goole.

    Thank's a lot for your help!

    David

    It's not mutch of a help...

    You can figure out how to do what you want quikly, just find a list of
    Kernel i/o routines with a short description.

    Vasko
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From kottira@kottira@chello.at (Franz Kottira) to comp.sys.cbm on Friday, July 18, 2003 13:52:26
    From Newsgroup: comp.sys.cbm

    Hi Paul
    r_u_sure@mybluelight.com (Paul Rosenzweig) wrote

    In addition your scheme fails to match character printing
    for text with PETSCII values in the range from 96 to 127. These PETSCII values are very rare. Your alternative scheme should be considered when
    it is likely that only text with common PETSCII values will be encountered.

    Thank you for noting that. I never realized the failure, because I use
    the code-sequence for transferring keyboard input, and the keyboard
    does not output ascii-values between 96 and 127 (as far I know). But
    indeed, it could be a problem concerning any other input source.

    Franz
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From hannibal@hannibal@videocam.net.au (hannibal) to comp.sys.cbm on Friday, July 18, 2003 21:07:21
    From Newsgroup: comp.sys.cbm

    Hy guys

    If you look for documentation about c64 asm and C64 Ml coding
    tutorials, grab my huge collection:

    ftp://ftp.padua.org/pub/c64/Docs/ml-tutorial.zip http://bj.spline.de/stuff/ml-tutorial.zip


    Regards,
    Mihai
    --- Synchronet 3.18b-Win32 NewsLink 1.113