Skip to main content
Apropriate title, Spelling, Thank yo uremoved
Source Link
Raffzahn
  • 249.4k
  • 23
  • 722
  • 1k

Pushing put pointer and routine into Why does this 6502 code push a function address onto the stack before calling?

I am learning how to program the atariAtari 800 by examining some tutorial code that came with the IDE/Assembler I am using. I am using the MADS assembler for this.

putchar_ptr = $346 csrhinh = 752 character = $80 rowcrs = $54 colcrs = $55 org $2000 .proc main mva #1 csrhinh mva #6 rowcrs mva #16 colcrs mva #0 character next_character ldx character cpx #.len text beq stop lda text,x jsr putchar inc character jmp next_character stop jmp stop .proc putchar tax lda putchar_ptr+$1 pha lda putchar_ptr pha txa rts .endp .local text .byte 'Hi there!',$9b,'new line' .endl .endp run main 

I did reference the atariAtari 800 manual and the MADMADS-Assembler manual but I didn't find anything. The specific question I am asking is, in the putchar procedure, why is the accumulator pushed onto the stack? From what I can tell all it is loaded with is the location of the routine pointer on the first push and the put pointer on the second. A few possibilities I see are that I could be mistaken on what the routine actually is (the atari 800 manual wasn't very informative about that) or the push might point to something else other than the stack. I would say the latter is true but then we aren't pushing the character we are trying to print because of the txa instruction and the accumulator being reloaded. Thank you in advance to anyone who responds here!

Pushing put pointer and routine into stack?

I am learning how to program the atari 800 by examining some tutorial code that came with the IDE/Assembler I am using. I am using the MADS assembler for this.

putchar_ptr = $346 csrhinh = 752 character = $80 rowcrs = $54 colcrs = $55 org $2000 .proc main mva #1 csrhinh mva #6 rowcrs mva #16 colcrs mva #0 character next_character ldx character cpx #.len text beq stop lda text,x jsr putchar inc character jmp next_character stop jmp stop .proc putchar tax lda putchar_ptr+$1 pha lda putchar_ptr pha txa rts .endp .local text .byte 'Hi there!',$9b,'new line' .endl .endp run main 

I did reference the atari 800 manual and the MAD-Assembler manual but I didn't find anything. The specific question I am asking is, in the putchar procedure, why is the accumulator pushed onto the stack? From what I can tell all it is loaded with is the location of the routine pointer on the first push and the put pointer on the second. A few possibilities I see are that I could be mistaken on what the routine actually is (the atari 800 manual wasn't very informative about that) or the push might point to something else other than the stack. I would say the latter is true but then we aren't pushing the character we are trying to print because of the txa instruction and the accumulator being reloaded. Thank you in advance to anyone who responds here!

Why does this 6502 code push a function address onto the stack before calling?

I am learning how to program the Atari 800 by examining some tutorial code that came with the IDE/Assembler I am using. I am using the MADS assembler for this.

putchar_ptr = $346 csrhinh = 752 character = $80 rowcrs = $54 colcrs = $55 org $2000 .proc main mva #1 csrhinh mva #6 rowcrs mva #16 colcrs mva #0 character next_character ldx character cpx #.len text beq stop lda text,x jsr putchar inc character jmp next_character stop jmp stop .proc putchar tax lda putchar_ptr+$1 pha lda putchar_ptr pha txa rts .endp .local text .byte 'Hi there!',$9b,'new line' .endl .endp run main 

I did reference the Atari 800 manual and the MADS-Assembler manual but I didn't find anything. The specific question I am asking is, in the putchar procedure, why is the accumulator pushed onto the stack? From what I can tell all it is loaded with is the location of the routine pointer on the first push and the put pointer on the second. A few possibilities I see are that I could be mistaken on what the routine actually is (the atari 800 manual wasn't very informative about that) or the push might point to something else other than the stack. I would say the latter is true but then we aren't pushing the character we are trying to print because of the txa instruction and the accumulator being reloaded.

Source Link
user115898
  • 489
  • 4
  • 10

Pushing put pointer and routine into stack?

I am learning how to program the atari 800 by examining some tutorial code that came with the IDE/Assembler I am using. I am using the MADS assembler for this.

putchar_ptr = $346 csrhinh = 752 character = $80 rowcrs = $54 colcrs = $55 org $2000 .proc main mva #1 csrhinh mva #6 rowcrs mva #16 colcrs mva #0 character next_character ldx character cpx #.len text beq stop lda text,x jsr putchar inc character jmp next_character stop jmp stop .proc putchar tax lda putchar_ptr+$1 pha lda putchar_ptr pha txa rts .endp .local text .byte 'Hi there!',$9b,'new line' .endl .endp run main 

I did reference the atari 800 manual and the MAD-Assembler manual but I didn't find anything. The specific question I am asking is, in the putchar procedure, why is the accumulator pushed onto the stack? From what I can tell all it is loaded with is the location of the routine pointer on the first push and the put pointer on the second. A few possibilities I see are that I could be mistaken on what the routine actually is (the atari 800 manual wasn't very informative about that) or the push might point to something else other than the stack. I would say the latter is true but then we aren't pushing the character we are trying to print because of the txa instruction and the accumulator being reloaded. Thank you in advance to anyone who responds here!