Jump to content
IGNORED

Atari 8bit basic assembly language code


Recommended Posts

As I continue to stumble across assembly language routines used within basic like this (image).  Using the string address as a hook/entry point for basic to do three things at once.  1. launch high speed 6502 code from within BASIC, 2. pass value(s) to the code to work upon, 3. return a value from the ASM code back to BASIC (in this case X).

 

What I would like to do is collect many more of these and store them all like a toolbox library.  Quick easy way to add them to your BASIC program is LIST the desired code out to a LST TXT file and then ENTER that code from disk into your current program being coded.  For this to be convenient the routines need to be stored at obscure line numbers like 28000-30000?

 

This routine was just grabbed off of an old ANTIC disk which was creating a menu of files from the disk.  Filling time by plugging these codes into a hex editor to get the ASM program code to look at.

This one has the following ascii/atascii codes for what that is worth   (shrug)

68 68 E2 80 A6 C3 95 68 
E2 80 A6 C3 94 C2 A9 20 
C2 A8 E2 80 98 C3 94 C3 
88 C3 90 C3 BB 60 00

 

image.thumb.png.e68c743aae38ee04f70007b68e68a468.png

  • Like 1
Link to comment
Share on other sites

Putting machine code into strings in that format doesn't always work, there are a few values (29 , 34 and 125) come to mind, I think there

is one other.

To use those values, you have to build the string i.e.

A$="1GHJ%^&LJKHHGG"

A$(LEN(A$)+1)=CHR$(34): REM PUT IN DOUBLE QUOTE "

A$(LEN(A$)+1)="KSJHKAKL(*&67788"

 

Link to comment
Share on other sites

Hi!

19 hours ago, Ray Gillman said:

As I continue to stumble across assembly language routines used within basic like this (image).  Using the string address as a hook/entry point for basic to do three things at once.  1. launch high speed 6502 code from within BASIC, 2. pass value(s) to the code to work upon, 3. return a value from the ASM code back to BASIC (in this case X).

 

What I would like to do is collect many more of these and store them all like a toolbox library.  Quick easy way to add them to your BASIC program is LIST the desired code out to a LST TXT file and then ENTER that code from disk into your current program being coded.  For this to be convenient the routines need to be stored at obscure line numbers like 28000-30000?

 

This routine was just grabbed off of an old ANTIC disk which was creating a menu of files from the disk.  Filling time by plugging these codes into a hex editor to get the ASM program code to look at.

This one has the following ascii/atascii codes for what that is worth   (shrug)

68 68 E2 80 A6 C3 95 68 
E2 80 A6 C3 94 C2 A9 20 
C2 A8 E2 80 98 C3 94 C3 
88 C3 90 C3 BB 60 00

Your hex codes does not correspond to the ATASCII characters in the picture - just by inspection there are 16 ATASCII characters and you have 31 codes 😛

 

The correct codes are:  68 68 85 D5 68 85 D4 A9 00 A8 91 D4 C8 D0 FB 60

 

This correspond to the following assembly:

      pla
      pla
      sta     $D5
      pla
      sta     $D4
      lda     #$00
      tay
loop: sta     ($D4),y
      iny
      bne     loop
      rts

 

So, what it does is clear 256 bytes of memory, at the given address, to zero, and is called with the argument 1536, so it is clearing the "page 6". In FastBasic, this is the same as: MSET 1536, 256, 0

 

IMHO, if you plan on using a lot of pre written assembly routines in your BASIC program, it would be better to try learning assembly by reading and understanding the source of the routines.

 

Have Fun!

Link to comment
Share on other sites

12 hours ago, TGB1718 said:

Putting machine code into strings in that format doesn't always work, there are a few values (29 , 34 and 125) come to mind, I think there

is one other.

To use those values, you have to build the string i.e.

A$="1GHJ%^&LJKHHGG"

A$(LEN(A$)+1)=CHR$(34): REM PUT IN DOUBLE QUOTE "

A$(LEN(A$)+1)="KSJHKAKL(*&67788"

 

I remember 34 works if you just add it to the string with chr$(34), 125 is the clear screen code not sure about that one and 28 29 are the arrow up and down keys.  155 is 9B I don't see a command for that and 1C (28) doesn't show up in my compiler code list.  1D is ORA absolute,X so that may be a problem.  I'll try using it with the same CHR$(29) to add it to a string to see if it works like 34.  125 ADC Absolute, X is an important one even more so than 29.  I'd wager it has to be added manually as well to work  

Edited by Ray Gillman
Link to comment
Share on other sites

The problem codes are the ones that affect the screen when you LIST the program so if for instance

you string had 125 as a value, when you try to ?/list the string, it clears the screen :)

 

Did a bit of testing and the values that cause issues are

 

29, 125, 155 & 253

 

Not sure of the significance of 29, but it does cause the cursor to move to the top of the screen.

125 obviously clear screen

155 Atari carriage return

253 Bell character

 

all others seem to be insertable into a string that can be listed in BASIC

so only those 4 need the addition to the string using CHR$()

 

Little program that puts a space where the offending characters are, so string prints ok without them

 

image.thumb.png.cb6a3c2a2cdd38566d43e6931689b58f.png

Edited by TGB1718
  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...