kc5tja wrote:
Deeply-nested call-graphs (JSRs to JSRs to JSRs, etc) are a hallmark of writing software in a well-factored manner. You start out with basic primitives written in a stream of instructions, and you then can JSR to them as though they were a higher-level assembly instruction.
If you look at most high-level compiler output of the era, you'll notice that "subroutine-threaded code" like this was the norm, not the exception. Note that Forth is singularly famous for this style of code generation, although the technique technically predates Forth.
thank you for your reply, let me try to explain with some code.
...but anyway if basic was written with another high level language, i'm really curious about it!!!
here a piece of code, quite near the warm boot because it is used during the print of the banner using this core routine
Code:
; print string form AY
AB1E 20 87 B4 JSR $B487
; print string from $22/$23
AB21 20 A6 B6 JSR $B6A6
AB24 AA TAX
AB25 A0 00 LDY #$00
AB27 E8 INX
AB28 CA DEX
AB29 F0 BC BEQ $AAE7
AB2B B1 22 LDA ($22),Y
AB2D 20 47 AB JSR $AB47
AB30 C8 INY
AB31 C9 0D CMP #$0D
AB33 D0 F3 BNE $AB28
AB35 20 E5 AA JSR $AAE5
AB38 4C 28 AB JMP $AB28
look at jsr $AB47, that more or less is output one char.
it jump at:
Code:
; print character on CMD output file
AB3B A5 13 LDA $13
AB3D F0 03 BEQ $AB42
AB3F A9 20 LDA #$20 ; space
AB41 .BY $2C
AB42 A9 1D LDA #$1D ; csr right
AB44 .BY $2C
AB45 A9 3F LDA #$3F ; question mark
AB47 20 0C E1 JSR $E10C
AB4A 29 FF AND #$FF
AB4C 60 RTS
this is good, a little reuse of and #$ff
but now the jsr $e10c (kernel rom)
Code:
E10C 20 D2 FF JSR $FFD2
and..
Code:
FFD2 6C 26 03 JMP ($0326) ; (F1CA) output char on current device
again: i dont wanna say that it's easy (better it was easy) to write code in 8k space, but now i can understand why a PRINT was so slow!
anyway i'd love to find out if there is a project for reimplement the original asm code in a new highlevel language, that's why i'm playing rom digging.