Skip to content

Commit 712c1d8

Browse files
committed
1 parent 578658f commit 712c1d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+721
-4
lines changed

16bit_transfer.asm

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
org $3400
2+
3+
lda $40
4+
sta $42
5+
lda $41
6+
sta $43
7+
8+
org $40
9+
.by $3e, $b7

24bit_add.asm

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
org $3400
2+
3+
adb $40 $43 $46
4+
lda $41
5+
adc $44
6+
sta $47
7+
lda $42
8+
adc $45
9+
sta $48
10+
11+
org $40
12+
.by $2a, $67, $35, $f8, $a4, $51

8bit_sub.asm

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
org $3400
2+
3+
sbb $40 $41 $42
4+
5+
org $40
6+
.by $77, $39

add_even_parity.asm

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
org $3400
2+
3+
ldx $40
4+
load_ascii
5+
ldy #$ff ; Sum of bits
6+
lda $40, x
7+
inc_sum
8+
iny
9+
next_bit
10+
lsr
11+
bcs inc_sum
12+
beq bits_done
13+
jmp next_bit
14+
bits_done
15+
tya
16+
and #%0000 0001
17+
beq next_ascii
18+
lda $40, x
19+
ora #%1000 0000 ; Set even parity
20+
sta $40, x
21+
next_ascii
22+
dex
23+
bne load_ascii
24+
25+
org $40 ; Number of ascii chars
26+
.by [end - $41]
27+
org $41
28+
.by "0123456ABC"
29+
end

asc2bin.asm

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
org $3400
2+
3+
ldx #7
4+
mva #0 $41 ; Bin result
5+
mva #$ff $40 ; Result of bin digit validity, 0 means all digits are 0 or 1, otherwise $ff
6+
ldy #1 ; Bit showing "1" on position of ASC digit
7+
next_digit
8+
lda $42, x
9+
and #$0f
10+
cmp #2
11+
bcs end ; Not a binary digit 0/1, end program
12+
cmp #1
13+
bcc next_bit; Binary digit "0", don't add to result
14+
tya
15+
ora $41
16+
sta $41
17+
next_bit
18+
tya
19+
asl ; Set 1 to current ASC digit position
20+
tay
21+
dex
22+
bpl next_digit
23+
inc $40 ; Set success, i.e. 0
24+
end
25+
26+
org $42
27+
.by '0', '0', '0', '0', '0', '0', '0', '1'

asc2dec.asm

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
org $3400
2+
3+
ldx #$ff ; It means the ASCII is not a decimal digit
4+
lda $40
5+
cmp #$30
6+
bcc save_result
7+
cmp #$40
8+
bcs save_result
9+
and #%0000 1111 ; Extract decimal digit
10+
tax
11+
save_result
12+
stx $41
13+
14+
org $40
15+
.by $37
16+

asc2hex.asm

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
org $3400
2+
3+
lda $40
4+
and #%0100 1111 ; Convert uppercase to lowercase and ascii digit to hex digit
5+
cmp #10 ; Is result a decimal digit?
6+
bcc store_result
7+
; Convert ASCII 'A' - 'Z' to hex digit
8+
sbc #'A'
9+
adc #9
10+
store_result
11+
sta $41
12+
13+
org $40
14+
.by 'c'
15+

bcd2bin.asm

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
org $3400
2+
3+
lda $40
4+
asl
5+
sta $42
6+
:2 asl
7+
clc
8+
adc $42
9+
ora $41
10+
sta $42
11+
12+
org $40
13+
.by $02, $09
14+

bin2asc.asm

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
org $3400
2+
3+
ldx #7
4+
lda $41
5+
check_bit
6+
tay
7+
and #1
8+
ora #$30
9+
sta $42, x
10+
tya
11+
lsr
12+
dex
13+
bpl check_bit
14+
15+
; Alternative solution. Cons: It changes original value in $41
16+
;
17+
; ldx #7
18+
; check_bit
19+
; lsr $41
20+
; lda #$30
21+
; adc #0
22+
; sta $42, x
23+
; dex
24+
; bpl check_bit
25+
26+
org $41
27+
.by %11010010
28+

bin2bcd.asm

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
org $3400
2+
3+
ldx #0 ; Number of tenth
4+
lda $40
5+
is_remainder_known
6+
cmp #10
7+
bcc save_result
8+
sbc #10
9+
inx
10+
jmp is_remainder_known
11+
save_result
12+
sta $42 ; Save remainder
13+
stx $41 ; Save tenth
14+
15+
org $40
16+
.by 29

check_even_parity_string.asm

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
org $3400
2+
3+
mva #$ff $40
4+
ldx $41
5+
sum_bits
6+
ldy #0 ; Sum of bits
7+
lda $41, x
8+
next_bit
9+
cmp #0
10+
beq check_parity_is_even
11+
asl
12+
bcc next_bit
13+
iny
14+
jmp next_bit
15+
check_parity_is_even
16+
tya
17+
and #%0000 0001
18+
bne parity_odd
19+
dex
20+
bne sum_bits
21+
inc $40
22+
parity_odd
23+
24+
org $41
25+
.by [end_str - start_str]
26+
org $42
27+
start_str
28+
.by $b1, $b2, $33
29+
end_str

checksum_data.asm

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
org $3400
2+
3+
lda #0
4+
ldx $41
5+
jmp is_sum_done
6+
sum
7+
eor $41, x
8+
dex
9+
is_sum_done
10+
bne sum
11+
sta $40
12+
13+
org $41
14+
.by 3
15+
org $42
16+
.by $28, $55, $26

count_1_bits.asm

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
org $3400
2+
3+
mva #0 $41
4+
lda $40
5+
ldx #8
6+
move_bit_to_c
7+
lsr
8+
bcc next_bit
9+
inc $41
10+
next_bit
11+
dex
12+
bne move_bit_to_c
13+
14+
org $40
15+
.by %00111011

dec2ascii.asm

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
org $3400
2+
3+
ldx #' '
4+
lda $40
5+
cmp #10
6+
bcs save_blank
7+
ora #'0'
8+
tax
9+
save_blank
10+
stx $41
11+
12+
org $40
13+
.by 7

decimal2seven_segment.asm

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
org $3400
2+
3+
lda #0
4+
ldx $41
5+
cpx #10
6+
bcs store_result ; Not a digit, zero result
7+
lda $50, x
8+
store_result
9+
sta $42
10+
11+
org $41
12+
.by 4
13+
org $50
14+
.by $3f, $06, $5b, $4f, $66, $6d, $7d, $07, $7f, $6f
15+

find_min.asm

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
org $3400
2+
3+
ldx $41
4+
lda $42
5+
check_min
6+
cmp $41, x
7+
bcc next_num
8+
lda $41, x ; New minimum
9+
next_num
10+
dex
11+
bne check_min
12+
sta $40
13+
14+
org $41
15+
.by 5
16+
org $42
17+
.by $67, $79, $15, $e3, $72

hex2asc.asm

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
org $3400
2+
3+
lda $40
4+
cmp #10
5+
bcc digit
6+
adc #['A' - '9' - 2] ; Prepare conversion to letter
7+
digit
8+
add #'0' ; Convert to digit or finish conversion to letter
9+
sta $41
10+
11+
; Alternative solution
12+
;
13+
; SED ; MAKE ADDITIONS. DECIMAL
14+
; CLC ; CLEAR CARRY TO START
15+
; LDA $40 ; GET HEXADECIMAL DIGIT
16+
; ADC #$90 ; DEVELOP EXTRA 6 AND CARRY
17+
; ADC #$40 ; ADD IN CARRY, ASCII OFFSET
18+
; STA $41 ; STORE ASCII DIGIT
19+
; CLD ; CLEAR DECIMAL MODE BEFORE ENDING
20+
21+
org $40
22+
.by $c
23+

justify_binary_fraction.asm

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
org $3400
2+
3+
ldx #0
4+
lda $40
5+
is_msb_set
6+
beq store_result
7+
bmi store_result
8+
inx
9+
asl
10+
jmp is_msb_set
11+
store_result
12+
sta $41
13+
stx $42
14+
15+
org $40
16+
.by $cb

last_non_blank_char.asm

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
org $3400
2+
SP = ' '
3+
CR = 0x0d
4+
5+
ldx #0
6+
cmp_next_char
7+
lda $42, x
8+
cmp #CR
9+
beq end
10+
cmp #SP
11+
beq next_char
12+
stx $40 ; Save index of last non blank char
13+
next_char
14+
inx
15+
jmp cmp_next_char
16+
end
17+
18+
org $42
19+
.by "A HAT ", CR

length_of_string.asm

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
org $3400
2+
3+
ldx #0 ; Index of char
4+
lda #$0d
5+
next_char
6+
cmp $41, x
7+
beq store_length
8+
inx
9+
jmp next_char
10+
store_length
11+
stx $40
12+
13+
org $41
14+
.by "RATHER", $0d

length_teletypewriter_msg.asm

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
org $3400
2+
STX = 2
3+
ETX = 3
4+
5+
ldx #0 ; Char index
6+
ldy #0 ; String length
7+
lda $41, x
8+
cmp #STX
9+
bne store_msg_length
10+
inx
11+
lda #ETX
12+
cmp_next_char
13+
cmp $41, x
14+
beq store_msg_length
15+
inx
16+
iny
17+
jmp cmp_next_char
18+
store_msg_length
19+
sty $40
20+
21+
org $41
22+
.by STX, "HELLO", ETX

0 commit comments

Comments
 (0)