I have tried making a basic Hello World program in ASM, but it keeps hanging and I don't know why.
This is my code:
.SEGMENT "START"
JMP BEGIN
.SEGMENT "INIT"
.SEGMENT "ONCE"
.SEGMENT "CODE"
CHROUT = $FFD2
HELLOTEXT:
.BYTE "HELLO, WORLD!",13,0
BEGIN:
LDX #0
LOOP:
LDA HELLOTEXT,X
BEQ DONE
JSR CHROUT
INX
BRA LOOP
DONE:
LDA 13
JSR CHROUT
RTS
Does anyone know what's wrong with the code?
Sorry about this, but this is my first time coding in ASM.
P.S. This may not be useful, but when I assembled this code, it threw up an error code and I can't figure out what it means.
"ld65: Error: Missing memory area assignment for segment 'START'
I can't figure out whats wrong with my code. :(
-
- Posts: 2
- Joined: Fri Jan 19, 2024 1:00 am
Re: I can't figure out whats wrong with my code. :(
You need a program counter directive.
That's usually * = or ORG, depending on the assembler.
ORG $400
or
* = $400
Also... it would help to tell us which assembler you are using.
That's usually * = or ORG, depending on the assembler.
ORG $400
or
* = $400
Also... it would help to tell us which assembler you are using.
Re: I can't figure out whats wrong with my code. :(
The ld65 error gives away that you're using the ca65 assembler from the cc65 project.
That ld65 (linker) error suggests that you are not using a proper command when assembling. I recommend that you use this command:
, where -o is the name of the resulting file, -t is the computer type, -C is the config file for X16 assembly, -u adds a BASIC stub at the beginning of the code so that you can run it, and hello.asm is the name of the source file.
I also recommend that you clean up the code a bit, removing memory segments not normally used in assembly programs. The resulting code could be like this, where all code ends up in the default CODE segment:
That ld65 (linker) error suggests that you are not using a proper command when assembling. I recommend that you use this command:
Code: Select all
cl65 -o HELLO.PRG -t cx16 -C cx16-asm.cfg -u __EXEHDR__ hello.asm
I also recommend that you clean up the code a bit, removing memory segments not normally used in assembly programs. The resulting code could be like this, where all code ends up in the default CODE segment:
Code: Select all
JMP BEGIN
CHROUT = $FFD2
HELLOTEXT:
.BYTE "HELLO, WORLD!",13,0
BEGIN:
LDX #0
LOOP:
LDA HELLOTEXT,X
BEQ DONE
JSR CHROUT
INX
BRA LOOP
DONE:
LDA 13
JSR CHROUT
RTS
-
- Posts: 2
- Joined: Fri Jan 19, 2024 1:00 am
Re: I can't figure out whats wrong with my code. :(
Thank you!
Last edited by Carsonnetic on Sat Dec 21, 2024 2:16 pm, edited 1 time in total.