Right now I am learning 6502 assembly. Currently I am using the MADS assembler to program for the Atari 800. This program is just a small tutorial program that came with the assembler zip file I downloaded. The only piece of this program I did't understand is the jmp * operation, what does the '*' mean? Full program:

sm_ptr  = $58
ch  = $2f4  
chr = $2400 
rom_chr = $e000 
org $2000
.proc main  
mva #>chr ch    
ldx #0      
copy_loop
mva rom_chr,x chr,x
mva rom_chr+$100,x chr+$100,x
mva rom_chr+$200,x chr+$200,x
mva rom_chr+$300,x chr+$300,x
inx
bne copy_loop
ldx #0      
space_loop
mva charset.space,x chr,x
inx
cpx #8
bne space_loop 
ldy #0       
loop    
tya
sta (sm_ptr),y
iny
bne loop
jmp *
.local charset
space   
.byte %01000100 
.byte %00101000
.byte %01111100
.byte %01010100
.byte %11111110
.byte %10101010
.byte %10111010
.byte %00000000
.endl
.endp   
run main
  • 1
    What is mva? Is it a macro or does the Atari 800 have a non standard 6502? – JeremyP Oct 18 at 10:04
  • It’s a macro predefined in MADS. – mannaggia Oct 18 at 13:00
  • 1
    MVA is a move macro to transfer a byte using A as buffer. MVA adr1,adr2 gets resolved as LDA adr1 followed by STA adr2. – Raffzahn Oct 18 at 13:13
up vote 31 down vote accepted

MADS uses * in three ways (See MADS "Manual")

  • Using the current assembly address for calculation of an address, i.e. the one the actual statement is assembled to.
  • Multiplying in expressions.
  • Mark the beginning of a comment (until line end)

In above listing it will be interpreted as the address the JMP instruction is assembled to, so it will form an infinite loop, effectively halting the machine until Reset.

  • 1
    a.k.a HCF - Halt and Catch Fire – TripeHound Oct 18 at 10:15
  • 1
    Until an interrupt is received, isn't it? AFAICT a standard 6502 doesn't have a power-saving wait state and therefore isn't likely to "catch fire" with this kind of loop anyway (WDC 65C02 has WAI) – Random832 Oct 18 at 14:23
  • 1
    @Random832 Well, yes and no. Interrupts are served, but when finished control isretruned to this loop - unless the interrupt never returns (usual definition for Reset) or manipulates the return address. – Raffzahn Oct 18 at 15:07
  • 4
    @Random832 The Catch Fire part isn't really meant to be taken literally most of the time. – Cubic Oct 18 at 15:54

I suspect the * means the current instruction/location, as it does in some other assemblers, like PDP-8.  Often it would be used in an expression like *-label in the data section to get something's size, or *+3 perhaps, in code.

If that's the case for 6502 assembly, then jmp * means branch to self, or, infinite loop, which would be a form of halting the program.

This makes some sense as it comes at the end of main, which presumably has nothing to return to for a bare metal program.

Some assemblers (e.g. masm, Microsoft's x86 assembler) use $ for the same meaning.

  • 1
    It could, it doesn't seem to effect the main program. I'll test that hypothesis right now. – user115898 Oct 17 at 19:03
  • 1
    Thanks, it is correct that it is an infinite loop that just loops back the the same line. – user115898 Oct 17 at 19:08
  • FYI, assemblers that don't use * to mean the current location typically use .. The latter worked its way into other applications, e.g. editors like ed use it to mean the current line, and in Emacs many commands and function names use the word point to refer to the current buffer position. – Barmar Oct 18 at 21:07

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.