2020/c64/day01.asm

71 lines
889 B
NASM
Raw Normal View History

// vim: filetype=kickass
day01:
move_16_imm($03, $04, str_input)
jsr write_string
move_16_imm($03, $04, day01_input)
jsr write_string
move_16_imm($03, $04, str_converted)
jsr write_string
move_16_imm($03, $04, day01_input)
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