2020/c64/main.asm

138 lines
1.9 KiB
NASM
Raw Normal View History

2020-12-06 17:07:35 +00:00
// vim: filetype=kickass
#import "math.inc"
* = $0801 // BASIC start address (#2049)
.byte $0d,$08,$dc,$07,$9e,$20,$34,$39 // BASIC loader to start at $c000...
.byte $31,$35,$32,$00,$00,$00 // puts BASIC line 2012 SYS 49152
* = $c000
.const SCREEN_RAM = $0400
.const COLOR_RAM = $d800
.const kernal_scinit = $ff81
.const kernal_chrout = $ffd2
.const kernal_write_byte = $e716
.const zp_temp = $02
.const cursor_pointer_lo = $05
.const cursor_pointer_hi = $06
//
// main
//
main:
jsr clear_screen
// lda #0
// sta $d020
// sta $d021
jsr day01
!loop:
// inc $d020
jmp !loop-
string:
.text "The quick brown newline jumped over the lazy dog."
.byte '\n'
.byte 0
string_cr:
.text "The quick brown carriage return jumped over the lazy dog."
.byte '\r'
.byte 0
day01:
lda #<str_input
sta $03
lda #>str_input
sta $04
jsr write_string
lda #<day01_input
sta $03
lda #>day01_input
sta $04
jsr write_string
lda #<str_converted
sta $03
lda #>str_converted
sta $04
jsr write_string
lda #<day01_input
sta $03
lda #>day01_input
sta $04
.break
ldy #0
!line:
lda #0
sta $22
sta $23
!digit:
lda ($03), y
cmp #'\n'
beq !break+
i16_mul10($22, $23)
lda ($03), y
sec
sbc #'0'
i16_i8_add_a($22, $23)
iny
jmp !digit-
!break:
sty $24
lda $23
jsr print_hex_0x
lda $22
jsr print_hex
jsr print_newline
jsr print_carriage_return
ldy $24
iny
lda ($03), y
bne !line-
!done:
rts
day01_input:
.import text "../rust/inputs/day01_example"
.byte 0
str_input:
.text "# Input"
.byte '\n', 0
str_converted:
.byte '\n'
.text "# Converted"
.byte '\n', 0
buffer:
.fill $0100, 0
#import "screen.asm"