please help with the code!

6 posts / 0 new
Last post
Online
Last seen: 1 hour 30 min ago
Joined: Jan 11 2025 - 14:57
Posts: 16
please help with the code!
AttachmentSize
Plain text icon Code.txt6.63 KB

I still can't compile this code, can someone help with this?

Offline
Last seen: 9 hours 36 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2668
You don't need to assemble or

You don't need to assemble or compile it, the hex bytes are already there, you just need to convert them to a binary file.  I don't know what generated that listing, but it would be pretty easy to convert on a modern system with something like a simple Perl script.

 

S.Elliott's picture
Online
Last seen: 20 min 35 sec ago
Joined: Jun 23 2022 - 16:26
Posts: 270
Not assembler, not Apple
softwarejanitor wrote:

I don't know what generated that listing, but it would be pretty easy to convert on a modern system with something like a simple Perl script.

 

It's not a listing, it's text capture from an interactive Monitor console on an unidentified 6502-based computer.  The syntax is similar to Commodore's Terminal Interface Monitor (TIM) but with additional commands.  So the target computer might be any platform where TIM was a popular Monitor console, such as KIM-1, PET, CBM, Super PET, VIC-20, Commodore 64, C-16, Commodore 128, or Plus-4.  Or maybe it's from a modern emulator that offers an extended TIM-style command console, such as VICE.

 

That machine code won't work at all on Apple nor clones.  The BASIC STUB is formatted like Microsoft BASIC, but it uses tokens that don't form legal statements in Applesoft.  (eg: passing a numeric argument "2062" after an INVERSE token "9E")  Likewise, the machine code calls into ROM addresses that don't contain callable subroutines.  (eg: JSR $F34A would call into the middle of a machine-code instruction, not a valid ROM entry point)

Offline
Last seen: 9 hours 36 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2668
S.Elliott wrote
S.Elliott wrote:
softwarejanitor wrote:

I don't know what generated that listing, but it would be pretty easy to convert on a modern system with something like a simple Perl script.

 

It's not a listing, it's text capture from an interactive Monitor console on an unidentified 6502-based computer.  The syntax is similar to Commodore's Termin

 

Fair enough, everything you say is correct.  I'm just saying, that it has already been assembled, and the bytes are there in the text.

 

I'm thinking your guess about it coming from a modern CBM-ish emulator may be on the right track.

 

S.Elliott's picture
Online
Last seen: 20 min 35 sec ago
Joined: Jun 23 2022 - 16:26
Posts: 270
A few KERNAL functions, identified by subroutine address
softwarejanitor wrote:
I'm thinking your guess about it coming from a modern CBM-ish emulator may be on the right track.

More specifically, the JSR targets are Commodore 64 subroutines.  A quick search for target addresses like $FE00 and $F34A turned up this list of C64 functions:

Commodore 64 standard KERNAL functions 

 

Whoever the user was, they took a shortcut by calling the "real address" of each subroutine instead of calling the KERNAL entry points.  That's an understandable shortcut, since the KERNAL entry points just contain "JMP" instructions to each subroutine.  Taking the shortcut saves 4 processor cycles, at the risk of incompatibility with other Commodore models with different ROMs.  Compatibility probably wasn't importanty to the user who wrote the code.

 

Just for general interest, here are some functions called from that code sample according to the KERNAL function addresses listed at the page linked above:

  • JSR FE00 - (aka: JSR FFBA) - SETLFS. Set file parameters
  • JSR F34A - (aka: JSR FFC0) - OPEN. Open file
  • JSR CF15 - not a KERNAL function
  • JSR F291 - (aka: JSR FFC3) - CLOSE.  Close file
  • JSR F32F - (aka: JSR FFE7) - CLALL. Clear file table; call CLRCHN
  • JSR F250 - (aka: JSR FFC9) - CHKOUT. Define file as default output
  • JSR AB1E - not a KERNAL function
  • JSR A659 - not a KERNAL function
  • JSR EDDD - (aka: JSR FFA8) - IECOUT. Write byte to serial bus
  • JSR F20E - (aka: JSR FFC6) - CHKIN. Define file as default input
  • JSR F157 - (aka: JSR FFCF) - CHRIN. Read byte from default input
  • JSR AB1E - not a KERNAL function
  • JSR BDCD - not a KERNAL function

 

[EDIT]

Knowing that the target platform was probably a Commodore 64, running Commodore BASIC (a Microsoft derivative), we can guess that the byte string "$00,$0b,$08,$c8,$07,$9e,$32,$30,$36,$31,$00,$00,$00" really is a stub of a one-line BASIC program:

 

 1992 SYS 2061

 

That's a call into the machine language subroutine at 2061, which is address $080D in hexadecimal.  It would appear that this listing is a transcript of a user who was using TIM to construct a machine code program that could be saved to tape or diskette under the disguise as a BASIC program.  That's not malicious or suspicious in itself -- it was a common method of distributing machine code programs on Commodore platforms so that the average user could load them from tape or disk via the LOAD command.

Offline
Last seen: 9 hours 36 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2668
S.Elliott wrote
S.Elliott wrote:
softwarejanitor wrote:
I'm thinking your guess about it coming from a modern CBM-ish emulator may be on the right track.

More specifically, the JSR targets are Commodore 64 subroutines.  A quick search for target addresses like $FE00 and $F34A turned up this list of C64 functions:

 

 Very interesting.  It is possible to do the same thing by putting an Applesoft progran into data like that with the token for Applesoft's CALL instead of the one for Commodore BASIC's SYS.

 

I actually used a similar technique back in the day to disguise a machine code program as Applesoft.  It wasn't for nefarious purposes per-se, it was more showing off.

 

The assignment was to write an Applesoft program that cleared the screen and then counted from 1 to 50000, displaying the count centered on the screen.  Whoever's code ran fastest won the challenge.

 

So I coded pretty much an optimal version in Applesoft, but I wasn't satisfied with that.  I wrote one in assembler taking pretty much every shortcut possible, like not actually using counter variables, but just incrementing the bytes in the screen memory.  To hide it the first like was "0 HOME:CALL xxxx:REM" with backspaces to cover over the call then another HOME.  If you LISTed it you saw what appeared to be just an Applesoft program unless you used SPEED= or something like that.

 

The teacher couldn't figure out how it worked.  He even tried re-typing the BASIC code, which of course ran about as quickly as anyone else's or better, but nowhere near what the machine code did.  I had to give him the SPEED= hint to figure it out.  He couldn't figure out how I had added the machine code onto the end of the program until I explained about changing the start and end pointers.

 

Yeah, it was cheating.  But that class was stupidly boring so I had time to kill.

 

Log in or register to post comments