Jump to content
IGNORED

Assembly help needed


yossibnv

Recommended Posts

I am trying to run assemly code on altirra 2.5 emulator and it crushes

i use assembler edtitor rom for the assembler programs

 

following the stack dump :

 

CPU: Illegal instruction hit: 0056

(8158: 14, 30) A=10 X=00 Y=00 S=FF P=30 ( ) 0055: 02 COLCRS bad

 

i've tried differnt cpu & memory setting like enabling illegal operations

i use 32 bit won 7 os .

 

My source code

10 *=$1000

20 lda #1000

30 end

Bug

G 1000

 

I

Link to comment
Share on other sites

You are trying to stuff a value larger than 255 into the accumulator. This can't be done because the registers on the 6502 are all 8-bits wide. Are you trying to _Read_ from address $1000 into the accumulator? If that's the case, then replace the # with $, to both ensure that you're reading from an address, and that you're reading from address $1000 hexadecimal, rather than 1000 decimal, which are two very different things.

 

-Thom

 

In short:

# = an immediate (literal) value, think constant.

$ = what follows is hexadecimal

 

-Thom

Link to comment
Share on other sites

hi,

thanks for reply Thom

 

so I've tried to fix my code and load the accumulator with decimal value smaller then 255

 

10 *=$1000
20 LDA #0
30 END
Bug

G 1000

 

and i get:

CPU: Illegal instruction hit: 1001
(16308: 35,107) A=00 X=00 Y=00 S=00 P=30 ( ) 1000: 00 00 BRK #$00
to make this post more efficient ,i would appreciate any suggested working assembly simple code , so i can start my own first steps
10X
Link to comment
Share on other sites

Spaces are significant with every Atari assembler I know of. Not saying there aren't any that don't do it that way, just that I don't know of them. By your post I am guessing your are using the Atari cart and not Altirra's built in debugger.

 

10 *=$1000
20 lda #1000
30 end

you need

10 *=$4000

20 lda #10
25 brk

30 .end

Then type

ASM

Note that the ASM/ED cart defaults to putting the .obj into memory. MAC/65 doesn't so you have to use the option .OPT OBJ at the head of the program. It's considered safer to not assemble into memory until you have got rid of any bugs. You always want to start your programs in higher memory because DOS will get stepped on by something assembling to $1000. Has to be a minimum of ~$2000 and that moves depending on how much code you put in the editor.

 

Think of the assembler as being in fields sort of like a spread sheet. You can't see the demarcations because they are white space, but they are there.

 

After the above assembles, do your

BUG

G4000

and you should get the register read out with $0A<10 decimal> in the A-reg

Link to comment
Share on other sites

thanks for all replies!! i am new to this forum and very satisfy

 

as i mentioned above i use altirra 2.5 emulator and assembler edtitor rom .

following your suggestion and running the given code(get 0 errors after running ASM command) ,

i get the following registers dump at the altirra console:

 

CPU: Illegal instruction hit: 9B01

(13715: 82, 2) A=0A X=00 Y=00 S=00 P=30 ( ) 9B00: 02 bad (what this bad mean?)
so the accumulator was loaded with the correct value (10 descimal=0A), but still i get the altirra crush window if i am not enabling the debugger on menu option:
debug==>enable debugger.
i also turn off the option System > CPU Options > Stop on BRK :
following the code:

10 *=$4000

20 lda #10
25 brk

30 .end

Link to comment
Share on other sites

Are you sure it's even assembling anything? You need 2 spaces after line numbers for instructions. Only 1 space gets interpreted as a label.

Go into DEBUG, enter:

L 1000

 

That gives disassembly of what you just put there.

 

END is optional, you don't really need it.

 

Also, it's a good idea to assemble a bit higher up in memory. If a DOS is loaded, then it'll probably occupy memory up to around $2000 or more. Plus your source code starts at the lowest point in free memory.

I usually just do small stuff at $4000.

Link to comment
Share on other sites

 

 

CPU: Illegal instruction hit: 9B01

(13715: 82, 2) A=0A X=00 Y=00 S=00 P=30 ( ) 9B00: 02 bad (what this bad mean?)

 

Wild guess, there is something in your code that is causing a JSR or JMP or VBXE is set in *OR* something along those lines that is causing your program to try and execute at ~$9B00. For some reason it is running into an $02 which could be<very likely> part of a display list code for ANTIC and seeing it as a bad instruction.

 

Hard to say why w/o seeing more info.

Link to comment
Share on other sites

I guess I am not making this clear. The asm/ed cart uses position to distinguish if something is a label, code, or directive. You are only using one space between the line number and the mnemonic, you need to use two spaces.

10 LDA => one space so the cart thinks you are trying to use 'LDA' as a label
10 LDA => two spaces so the cart thinks you are trying to use the 'LDA' as an instruction.
*BUT* it is field location, not necessarily white space. For instance you could do

10 LDA LDA $10

In this case the first LDA would be a label and the second would be an instruction. This is so you can do something like
20 JMP LDA and program control will pass to the LDA $10 part. Of course you wouldn't want to use an instruction as a label because it becomes confusing. I have been programming for years and I just confused myself! :)

This is one of the reasons why people like to use a real program editor. Most are smart enough to highlight your code so errors are easier to catch. Just entering code, it is automatically highlighted something like.

10 LDA LDA $10

 

or with colors so at a glance you can see the first LDA is being interpreted as a label.

Maybe it would be easier for you to see it with tabs instead of spaces.

 

10 *=4000
20 START
30 LDA #10
40 BRK
50 .END
Use windows highlight/copy function for the above code. Open Alirra with the ASM/ED cart and right click/paste it into the cart editor. It should assemble and work. If it doesn't work, you may have a bad cart image.
Link to comment
Share on other sites

I re-typed the code with the correct spaces and compiled it successfully ,i even get the correct results for the accumulator =0A (10 decimal)

 

the issue is only with altirra window crushes, if i am running the code without enabling debugger from the "Debug" menu.

 

so either this is the way to work with the asm/ED cart image or the image is damaged .

 

in case that it damaged i will be very appreciated to get a good link for working image.

 

the results i get now are fine :

CPU: Illegal instruction hit: 4003
(8614: 35,109) A=0A X=00 Y=00 S=00 P=30 ( ) 4002: 00 00 BRK #$00
the code:
10 *=4000
20 START
30 LDA #10
40 BRK
50 .END

 

thanks for help

  • Like 1
Link to comment
Share on other sites

I download the Altirra 2.60 test 20.(64 bit version for my 64 bit pc) loaded the asmed.com from the dos25.atr (I didn't really understood why i need to disable basic ,since i get the dos menu immediately without basic)

and run again the same code , i have noticed that when assembling the code using ASM command

the compiler drops an error on line 50 .BRK so i've removed the"." and it compiled fine.

but still the altirra crushe when i am typing :

ASM

no error

bug

> Debug

G 4000

the i get the alrirra crush win which says :"altirra error", wich enforce me to open debug window with following results:

CPU: Illegal instruction hit: 4003

(32700: 20, 70) A=0A X=00 Y=00 S=00 P=30 ( ) 4002: 00 00 BRK #$00
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...