Login
Forum Help



Post Your Message
Username: (Login)

Topic:
Message:
 


Previous Messages
Posted By

gerliczer
on 2019-03-24
16:21:58
 Re: Assembly - Can't execute my code?

As a Linux guy, you'd be better off with plus4emu than any other emulators.

On a different note, you may want to try Turbo Assembler 6 or Turbo Assembler Macro on real iron.

Posted By

KiCHY
on 2019-03-24
14:28:07
 Re: Assembly - Can't execute my code?

That basic launch does the job. In the original code, the problem is you tried to start your machine code program with the basic RUN command, but you didn't have any basic lines. You could start your program with SYS16384.

Posted By

ericjherd
on 2019-03-24
13:43:20
 Re: Assembly - Can't execute my code?

Doug, thank you! That worked!!! That's also an amazing BASIC launcher macro. Just what I needed to get started. Thanks to all of you who replied. I can't wait to get started...there's a lot for me to learn but I've wanted to learn 6502 for years and now I have everything I need.


--Eric

Posted By

Doug
on 2019-03-24
13:22:01
 Re: Assembly - Can't execute my code?

OK, try this:


.macro BASIC(launch, comment)
{
* = $1001 "Basic launcher"

.byte <end
.byte >end
.byte <2019, >2019
.byte $9e
.byte ' '
.var tensthous=(launch / 10000)
.var thous=(launch / 1000)
.var hunds=(launch / 100)
.var tens=(launch / 10)
.var units=mod(launch, 10)
.byte mod(tensthous, 10)+$30
.byte mod(thous, 10)+$30
.byte mod(hunds, 10)+$30
.byte mod(tens, 10)+$30
.byte units+$30
.text ": "
.text comment
.byte 0
end: .byte 0
.byte 0
}

BASIC(entry, "MY FIRST EXE")

entry: ldx #0
loop: lda mytext,x
jsr $FFD2
inx
cpx #11
bne loop
brk

mytext: .text "HELLO WORLD"



Save it as test.asm, just assemble it (it will produce test.prg). Load as a PRG file into Yape, list it to see what its going to do, then run it!

Cheers,
Doug

Posted By

ericjherd
on 2019-03-24
12:54:12
 Re: Assembly - Can't execute my code?

Thank you Doug for the reply, still no luck

*=$4000-2 "HELLO"
.word $4000
ldx #0
loop: lda mytext,x
jsr $FFD2
inx
cpx #11
bne loop
brk
mytext: .text "HELLO WORLD"


same results as before, with the following via monitor disassembly:

(C:$d90a) d 3ffe
.C:3ffe 00 BRK
.C:3fff 40 RTI
.C:4000 48 PHA
.C:4001 45 4C EOR $4C
.C:4003 4C 4F 20 JMP $204F
.C:4006 57 4F SRE $4F,X
.C:4008 52 JAM
.C:4009 4C 44 A2 JMP $A244
.C:400c 00 BRK
.C:400d BD 00 40 LDA $4000,X
.C:4010 20 D2 FF JSR $FFD2
.C:4013 E8 INX
.C:4014 E0 0B CPX #$0B
.C:4016 D0 F5 BNE $400D
.C:4018 00 BRK


I feel like I'm sooo close!

Posted By

Doug
on 2019-03-24
12:41:08
 Re: Assembly - Can't execute my code?

Hi Eric,

You're trying to execute the hello world string when you jump to $4000.
Move your mytext:.. line to AFTER the BRK. Should be ok then.

Doug

Posted By

ericjherd
on 2019-03-24
12:23:32
 Re: Assembly - Can't execute my code?

Thank you all so much for your advice and help so far...I think I'm getting really close.

I've decided to cross assemble using the KickAssembler. I'll take functionality over "cool" for right now happy

Still can't get the code to execute in an emulator, either yape or vice.

Source has been revised to the following:

*=$4000-2 "HELLO"
.word $4000
mytext: .text "HELLO WORLD"
ldx #0
loop: lda mytext,x
jsr $FFD2
inx
cpx #11
bne loop
brk


Compiling and running yields:

READY.
LOAD"*",8,1
SEARCHING FOR *
LOADING
READY.
RUN

READY


So, there are no errors, but nothing is displayed on the screen either! A disassembly starting at $3FFE reveals the following:

(C:$d90f) D 3ffe
.C:3ffe 00 BRK
.C:3fff 40 RTI
.C:4000 48 PHA
.C:4001 45 4C EOR $4C
.C:4003 4C 4F 20 JMP $204F
.C:4006 57 4F SRE $4F,X
.C:4008 52 JAM
.C:4009 4C 44 A2 JMP $A244
.C:400c 00 BRK
.C:400d BD 00 40 LDA $4000,X
.C:4010 20 D2 FF JSR $FFD2
.C:4013 E8 INX
.C:4014 E0 0B CPX #$0B
.C:4016 D0 F5 BNE $400D
.C:4018 00 BRK


So the code is definitely in there. I get the feeling I'm really close to figuring this out, I just need that "light bulb" moment! Also, typing in SYS with various start addresses from 16382, 16384, 16386 just lands me in the monitor.

Thanks for any advice!
--Eric

Posted By

gerliczer
on 2019-03-24
06:08:28
 Re: Assembly - Can't execute my code?

Try to use your favourite cross assembler. Unless you insist on the cool factor of doing it with the tools of the time period when the machine was commercially alive. Too much hassle with very little merit.

Posted By

SVS
on 2019-03-24
05:10:37
 Re: Assembly - Can't execute my code?

@ericjherd: Try use macro assembler with Yape: it works.
Then you can have some advantages: just for example it writes the object code in memory (where it can be run from), you can use full screen editor, etc.
Let me know.

P.S. - Put a BRK statement before the .END one in order to avoid the endless loop.

Posted By

siz
on 2019-03-24
04:21:09
 Re: Assembly - Can't execute my code?

Commodore PRG format add a two bytes header to store the load address of the program (the memory address where the program gets loaded when you add a ",1" after the LOAD"name",device command). That's the .word at the beginning of your code.
For JCL you won't need it. You can set your start address as *=$4000 and remove the .word $4000.

Posted By

ericjherd
on 2019-03-24
02:47:43
 Re: Assembly - Can't execute my code?

P.S., I'm a Linux user, or I would probably use the Plus4/IDE. I tried the Macro Assembler (stock Plus/4), but until my sd2iec arrives I have to use an emulator. I tried Macro Assembler with VICE but it just hangs....

Posted By

ericjherd
on 2019-03-24
02:33:06
 Assembly - Can't execute my code?

Hello Plus/4 World!

My first computer back in 1986 was a Plus/4, where I used it to write many a middle school report using the built in word processor.
I've recently purchased another one with a 1551, CM-141 monitor, and MPS-803 printer, and I'm trying to learn assembly. I've managed to download lots of relevant learning material, but the one thing none of them really address is *how to execute my code*. I'm so embarrassed!

For "period correctness", I'm using the JCL assembler. I'm trying to do a very simple hello world, I have a copy of the SVS UlitmateMap spreadsheet, and I can assemble the following code with no errors:

1000 *=$4000-2
1010 .WORD $4000 ;Stolen from the Plus4IDE...not sure why I'm reserving a word here
1020 CHROUT = $FFD2
1030 MYTEXT .BYTE 'HELLO WORLD'
1040 LDX #0
1050 LOOP LDA MYTEXT,X
1060 JSR CHROUT
1070 INX
1080 CPX #11
1090 BNE LOOP
1100 .END ; also tried JMP MYTEXT in case I was missing the output, doesn't matter end result is the same

(note that this isn't a cut and paste, so transcription errors may have occurred in this post)

I grabbed to $4000 address from the Plus4IDE sample1.asc. The tutorial I'm following doesn't specify a start address at all, so the first couple of lines I've added from either the JCL assembler documentation or the Plus4IDE sample1.asc file.
The end result is the same whether I choose $2000, $4000, or $8000 as the starting address.

I assemble the code with HELLO.X in the JCL assembler, which places the program in memory, and then (for the $4000 address), type SYS 16384 and I get nothing bud an endless loop of READY prompts. If I choose another address like $8000 (start of BASIC?) I get the same thing, or if I choose $2000 I get the monitor.

I've spent DAYS on this combing the forums, tutorials, etc. I'm at my wits end. I know 's something brain-dead simple.

Also, I know that you can (tokenize?) some BASIC lines in ML to get the program to do a SYS for you so you can do the standard DLOAD""HELLO" and the a RUN and it will call the correct address for you? Is that he missing piece?

Sorry for what must seem like a dumb question. Most of my development experience is in C/PHP, and Python in UNIX environments.

Any help would be very much appreciated!

--Eric

P.S I know that on the plus/4 that $FFD2 CHROUT is unnecessary as us plussers have a better option, I'm just following the 6502 tutorial


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon