; -----------------------------------------------------------------------------
; The Hobbit - Boot Loader (c) Melbourne House
; reverse engineered by Eelco Huininga
; DOS Filename   : $.!BOOT
; Acorn filename : $.!BOOT
; Load address   : FFFF2000
; Exec address   : FFFF2000
; Length         : 00000059
; -----------------------------------------------------------------------------

; -----------------------------------------------------------------------------
; OS call addresses
; -----------------------------------------------------------------------------
oscli              = &FFF7                        ; OSCLI


; -----------------------------------------------------------------------------
; Start of code
; -----------------------------------------------------------------------------

.boot
2000  A2 0A        ..    LDX #boot1 MOD 256
2002  A0 20        .     LDY #boot1 DIV 256
2004  20 F7 FF      ..   JSR oscli
2007  4C 1C 20     L.    JMP boot2

.boot1
200A  2A 4C 4F 41  *LOA  EQUS "*LOAD O.BOOT 3000" ; Load the second stage loader
200E  44 20 4F 2E  D O.
2012  42 4F 4F 54  BOOT
2016  20 33 30 30   300
201A  30           0
201B  0D           .     EQUB &0D

.boot2
201C  A9 00        ..    LDA #&3000 MOD 256       ; Source address
201E  85 00        ..    STA &00
2020  A9 30        .0    LDA #&3000 DIV 256
2022  85 01        ..    STA &01
2024  A9 D2        ..    LDA #&02D2 MOD 256       ; Number of bytes
2026  85 02        ..    STA &02
2028  A9 02        ..    LDA #&02D2 DIV 256
202A  85 03        ..    STA &03
202C  A9 D1        ..    LDA #&05D1 MOD 256       ; Destination address
202E  85 04        ..    STA &04
2030  A9 05        ..    LDA #&05D1 DIV 256
2032  85 05        ..    STA &05
2034  A0 00        ..    LDY #&00

.boot3
2036  B1 00        ..    LDA (&00),Y
2038  91 04        ..    STA (&04),Y
203A  E6 00        ..    INC &00                  ; Increase source address
203C  D0 02        ..    BNE boot4
203E  E6 01        ..    INC &01

.boot4
2040  E6 04        ..    INC &04                  ; Increase destination address
2042  D0 02        ..    BNE boot5
2044  E6 05        ..    INC &05

.boot5
2046  A5 02        ..    LDA &02
2048  D0 02        ..    BNE boot6
204A  C6 03        ..    DEC &03

.boot6
204C  C6 02        ..    DEC &02
204E  A5 02        ..    LDA &02                  ; Check if number of bytes has reached zero
2050  05 03        ..    ORA &03
2052  F0 02        ..    BEQ boot7
2054  D0 E0        ..    BNE boot3

.boot7
2056  4C D1 05     L..   JMP &05D1                ; Jump to the second stage loader
