Skip to content

Commit

Permalink
crt0 global labels position fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sverx committed Nov 10, 2020
1 parent adf661d commit 6c60aa1
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 70 deletions.
10 changes: 5 additions & 5 deletions crt0/crt0_sms.rel
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ S _SMS_isr Ref0000
A _CODE size 0 flags 0 addr 0
A _HEADER size 0 flags 8 addr 0
A _HEADER0 size 8 flags 8 addr 0
S _SMS_crt0_RST08 Def0008
A _HEADER1 size 9 flags 8 addr 8
S _SMS_crt0_RST18 Def0011
S _SMS_crt0_RST08 Def0008
A _HEADER2 size 18 flags 8 addr 18
S _SMS_crt0_RST18 Def0018
A _HEADER3 size 2B flags 8 addr 38
A _HEADER4 size 104 flags 8 addr 66
S _OUTI32 Def0129
Expand All @@ -38,13 +38,13 @@ R 00 00 02 00
T 00 00 F3 ED 56 31 F0 DF 18 22 00
R 00 00 02 00 0D 09 04 00
T 08 00
R 00 00 02 00
R 00 00 03 00
T 08 00
R 00 00 03 00
T 08 00 0E BF F3 ED 69 ED 61 FB C9
R 00 00 03 00
T 11 00
R 00 00 03 00
T 18 00
R 00 00 04 00
T 18 00
R 00 00 04 00
T 18 00 7D D3 BE 7C D6 00 00 D3 BE C9
Expand Down
125 changes: 62 additions & 63 deletions crt0/src/crt0_sg.s
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; You should have received a copy of the GNU General Public License
; along with this library; see the file COPYING. If not, write to the
; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
; MA 02110-1301, USA.
Expand All @@ -29,84 +29,83 @@
; might be covered by the GNU General Public License.
;--------------------------------------------------------------------------

.module crt0
.globl _main
.module crt0
.globl _main

.area _HEADER (ABS)
;; Reset vector
.org 0
di ; disable interrupt
im 1 ; interrupt mode 1 (this won't change)
jp init
.area _HEADER (ABS)
;; Reset vector
.org 0
di ; disable interrupt
im 1 ; interrupt mode 1 (this won't change)
jp init

.org 0x38 ; handle IRQ
jp _SG_isr
.org 0x38 ; handle IRQ
jp _SG_isr

.org 0x66 ; handle NMI
jp _SG_nmi_isr
.org 0x66 ; handle NMI
jp _SG_nmi_isr

.org 0x70
.org 0x70
init:
ld sp,#0xc3f0 ; set stack pointer at end of RAM
xor a ; clear RAM (to value 0x00)
ld hl,#0xc000 ; by setting value 0
ld (hl),a ; to $c000 and
ld de,#0xc001 ; copying (LDIR) it to next byte
ld bc,#0x03f0 ; for 1 KB minus 16 bytes
ldir ; do that
ld sp,#0xc3f0 ; set stack pointer at end of RAM
xor a ; clear RAM (to value 0x00)
ld hl,#0xc000 ; by setting value 0
ld (hl),a ; to $c000 and
ld de,#0xc001 ; copying (LDIR) it to next byte
ld bc,#0x03f0 ; for 1 KB minus 16 bytes
ldir ; do that

;; Initialise global variables
call gsinit
call _SG_init
ei ; re-enable interrupts before going to main()
call _main
jp _exit

;; Initialise global variables
call gsinit
call _SG_init
ei ; re-enable interrupts before going to main()
call _main
jp _exit

.rept 128 ; this is a block of 128 OUTI
outi ; made for enabling UNSAFE but FAST
.endm ; short data transfers to VRAM
_outi_block:: ; _outi_block label points to END of block
ret
.rept 128 ; this is a block of 128 OUTI
outi ; made for enabling UNSAFE but FAST
.endm ; short data transfers to VRAM
_outi_block:: ; _outi_block label points to END of block
ret

;; Ordering of segments for the linker.
.area _HOME
.area _CODE
.area _INITIALIZER
.area _GSINIT
.area _GSFINAL
;; Ordering of segments for the linker.
.area _HOME
.area _CODE
.area _INITIALIZER
.area _GSINIT
.area _GSFINAL

.area _DATA
.area _INITIALIZED
.area _BSEG
.area _BSS
.area _HEAP
.area _DATA
.area _INITIALIZED
.area _BSEG
.area _BSS
.area _HEAP

.area _CODE
.area _CODE
__clock::
ld a,#2
rst 0x08
ret
ld a,#2
rst 0x08
ret

_exit::
;; Exit - special code to the emulator
ld a,#0
rst 0x08
;; Exit - special code to the emulator
ld a,#0
rst 0x08
1$:
halt
jr 1$
halt
jr 1$

.area _GSINIT
.area _GSINIT
gsinit::
ld bc, #l__INITIALIZER
ld a, b
or a, c
jr Z, gsinit_next
ld de, #s__INITIALIZED
ld hl, #s__INITIALIZER
ldir
ld bc, #l__INITIALIZER
ld a, b
or a, c
jr Z, gsinit_next
ld de, #s__INITIALIZED
ld hl, #s__INITIALIZER
ldir
gsinit_next:

.area _GSFINAL
ret
.area _GSFINAL
ret

4 changes: 2 additions & 2 deletions crt0/src/crt0_sms.s
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@
ld sp, #0xdff0 ; set stack pointer at end of RAM
jr init
;--------------------------------------------------------------------------
_SMS_crt0_RST08::
.org 0x08 ; Reset 08h - write HL to VDP Control Port
_SMS_crt0_RST08::
ld c, #0xBF ; set VDP Control Port
di ; make it interrupt SAFE
out (c),l
out (c),h
ei
ret
;--------------------------------------------------------------------------
_SMS_crt0_RST18::
.org 0x18 ; Reset 18h - write HL to VDP Data Port
_SMS_crt0_RST18::
ld a,l ; (respecting VRAM time costraints)
out (#0xBE),a ; 11
ld a,h ; 4
Expand Down

0 comments on commit 6c60aa1

Please sign in to comment.