summaryrefslogtreecommitdiff
path: root/programs
diff options
context:
space:
mode:
Diffstat (limited to 'programs')
-rw-r--r--programs/sub-suite/libc.s99
-rw-r--r--programs/sub-suite/subasm.s6
-rw-r--r--programs/sub-suite/subeditor.s47
3 files changed, 123 insertions, 29 deletions
diff --git a/programs/sub-suite/libc.s b/programs/sub-suite/libc.s
index b34d2d3..3de1094 100644
--- a/programs/sub-suite/libc.s
+++ b/programs/sub-suite/libc.s
@@ -411,6 +411,60 @@ free:
; Caller preserved registers: D, S, F.
; Callee preserved registers: B.
+;memcpy:
+;; inc step ;
+; phb.q ; Preserve B.
+; phx.q ; Preserve X.
+; xor b, b ; Reset B.
+; mov a, f ; Get the size.
+; and #7 ; Get the size, mod 8.
+; mov x, f ; Preserve the size.
+; lsr f, #3 ; Divide the size by 8.
+; beq @rem ; The quotient is zero, so copy the remaining number of bytes.
+;@loop:
+; mov.q (d+8*b), (s+8*b) ; Copy 8 bytes from the source, into the destination.
+; inb ; Increment the counter.
+; cmp b, f ; Is the counter the same as the size?
+; bne @loop ; No, so keep looping.
+;@rem:
+; lsl f, #3 ; Multiply the quotient by 8.
+; cmp #0 ; Is the remainder zero?
+; beq @end ; Yes, so we're done.
+; lea b, 8 ; No, so set our offset to 8.
+; sub b, a ; Subtract 8 by the remainder.
+; and #0 ; Reset A.
+; dec ; Set the bitmask to -1.
+; lsl b, #3 ; Multiply the offset by 8.
+; lsr b ; Shift the bitmask right by the offset.
+; mov.q b, (s+f) ; Get 8 bytes from the source.
+; xor.q b, (d+f) ; Mask out the destination bytes.
+; and b ; Get The masked source.
+; xor.q (d+f), a ; Copy the remaining bytes from the source, into the destination.
+;@end:
+; mov f, x ; Restore the size.
+; mov a, d ; Set the return value to the destination pointer.
+; plx.q ; Restore X.
+; plb.q ; Restore B.
+; rts ; End of memcpy.
+
+
+;memcpy:
+; phb.q ; Preserve B.
+; phx.q ; Preserve X.
+; phy.q ; Preserve Y.
+; mov b, f ; Get the size.
+; mov x, d ; Get the destination.
+; mov y, s ; Get the source.
+; txa ; Set the return value to the destination pointer.
+;@copy:
+; mmv.r ; Copy the size bytes from the source, into the destination.
+;@end:
+; ply.q ; Restore Y.
+; plx.q ; Restore X.
+; plb.q ; Restore B.
+; rts ; End of memcpy.
+
+
memcpy:
phb.q ; Preserve B.
xor b, b ; Reset B.
@@ -433,6 +487,51 @@ memcpy:
; Caller preserved registers: D, S, F.
; Callee preserved registers: B.
+;memset:
+;; inc step ;
+; phb.q ; Preserve B.
+; phx.q ; Preserve X.
+; lea b, 8 ; Set the loop counter to 8.
+; psh s ; Get the constant.
+;@const_loop:
+; lsl s, #8 ; Make room for the next byte.
+; mov s, (sp+1) ; Get the next byte.
+; deb ; Decrement the loop counter.
+; bne @const_loop ; The counter is non zero, so keep looping.
+; ins ; Clean up the frame.
+;@init:
+; mov a, f ; Get the size.
+; and #7 ; Get the size, mod 8.
+; mov x, f ; Preserve the size.
+; lsr f, #3 ; Divide the size by 8.
+; beq @rem ; The quotient is zero, so copy the remaining number of bytes.
+;@loop:
+; mov.q (d+8*b), s ; Set all 8 destination bytes, to the constant value.
+; inb ; Increment the counter.
+; cmp b, f ; Is the counter the same as the size?
+; bne @loop ; No, so keep looping.
+;@rem:
+; lsl f, #3 ; Multiply the quotient by 8.
+; cmp #0 ; Is the remainder zero?
+; beq @end ; Yes, so we're done.
+; lea b, 8 ; No, so set our offset to 8.
+; sub b, a ; Subtract 8 by the remainder.
+; and #0 ; Reset A.
+; dec ; Set the bitmask to -1.
+; lsl b, #3 ; Multiply the offset by 8.
+; lsr b ; Shift the bitmask right by the offset.
+; mov.q b, s ; Get 8 bytes from the constant value.
+; xor.q b, (d+f) ; Mask out the destination bytes.
+; and b ; Get The masked source.
+; xor.q (d+f), a ; Copy the remaining bytes from the source, into the destination.
+;@end:
+; mov f, x ; Restore the size.
+; mov a, d ; Set the return value to the destination pointer.
+; plx.q ; Restore X.
+; plb.q ; Restore B.
+; rts ; End of memset.
+
+
memset:
phb.q ; Preserve B.
xor b, b ; Reset B.
diff --git a/programs/sub-suite/subasm.s b/programs/sub-suite/subasm.s
index 56d13c2..ba8d2fb 100644
--- a/programs/sub-suite/subasm.s
+++ b/programs/sub-suite/subasm.s
@@ -139,8 +139,10 @@ subasm:
mov s, (s) ; Get the command ID.
cmp s, #7 ; Is the command ID greater than the command count?
bcs @end ; Yes, so we're done.
- lsl s, #1 ; No, so multiply the command ID by two.
- lea.w s, (cmd_srt+s) ; Get the pointer, from the command subroutine table.
+; lsl s, #1 ; No, so multiply the command ID by two.
+; lea.w s, (cmd_srt+s) ; Get the pointer, from the command subroutine table.
+ lea b, cmd_srt ; No, so get the address of the command subroutine table.
+ mov.w s, (b+2*s) ; Get the pointer, from the command subroutine table.
and #0 ; Reset A.
tab ; Reset B.
jsr s ; Run the command's subroutine.
diff --git a/programs/sub-suite/subeditor.s b/programs/sub-suite/subeditor.s
index 83fe179..e44feb3 100644
--- a/programs/sub-suite/subeditor.s
+++ b/programs/sub-suite/subeditor.s
@@ -268,12 +268,11 @@ cmd_cpy:
sta scr_trow ; Save it for later.
lea d, (buffer) ; Get the screen buffer.
mov s, y ; Get the cursor index.
- lea f, 1 ; Set the decrement offset to the left flag.
- jsr find_end ; Find the end of the line.
- div #maxcol+1 ; Get the ending line.
- ldb scr_str ; Has the screen been scrolled?
- beq @start ; No, so don't subtract the screen's starting point from the line number.
-@offset:
+; jsr find_end ; Find the end of the line.
+; mov f, a ; Save the end of the line.
+; div #maxcol+1 ; Get the ending line.
+ jsr get_endrow ; Get the ending line.
+; inc step ;
sub scr_str ; Offset the row position, back by the screen's starting point.
@start:
sta scr_row ; Set the row position to the end of the line.
@@ -361,24 +360,21 @@ find_end:
phb.q ; Preserve B.
phx.q ; Preserve X.
phy.q ; Preserve Y.
- phe.q ; Preserve E.
mov a, s ; Set the loop counter.
div #maxcol+1 ; Get the row position.
tay ; Save the row position.
mov b, d ; Preserve the string pointer.
mov x, s ; Preserve the cursor position.
mov d, a ;
- xor s, s ; Reset S.
@loop:
- inc d ; Increment the line.
- mov e, d ; Save the line.
- jsr getbit ; Get the linewrap bit.
- mov d, e ; Get the line.
- cmp #1 ; Is this the end of the line?
- beq @loop ; No, so keep looping.
-@loop2_1:
- mov a, d ; Get the ending row position.
- sub a, f ; Decrement the row position by the offset.
+ xor s, s ; Reset S.
+ iny ; Increment the line.
+ mov d, y ; Get the line.
+ jsr getbit ; Is this the end of the line?
+ bne @loop ; No, so keep looping.
+@loop2_init:
+ tya ; Get the ending row position.
+ dec ; Decrement the row position.
mul #maxcol+1 ; Get the loop counter.
cmp a, x ; Is the new loop counter less than the old loop counter?
mcc a, x ; Set the loop counter to the old loop counter if so.
@@ -389,7 +385,6 @@ find_end:
cmp (d+a-1), #0 ; Did we hit the null terminator?
bne @loop2 ; No, so keep looping.
@end:
- ple.q ; Restore E.
ply.q ; Restore Y.
plx.q ; Restore X.
plb.q ; Restore B.
@@ -445,7 +440,6 @@ printc:
@update1:
lea d, (buffer) ; Get the screen buffer.
mov s, y ; Get the cursor index.
- lea f, 1 ; Set the decrement offset to one.
jsr get_endrow ; Get the ending line.
mov d, a ;
mov s, scr_trow ; Get the current row position.
@@ -635,7 +629,6 @@ back:
sta scr_trow ;
lea d, (buffer) ; Get the screen buffer.
mov s, y ; Get the cursor index.
- lea f, 0 ; Set the decrement offset to zero.
jsr get_endrow ; Get the ending line.
sta scr_row ; Set our row position to the end of the line.
@find_st:
@@ -664,7 +657,6 @@ back:
@find_end:
lea d, (buffer) ; Get the screen buffer.
mov s, y ; Get the cursor index.
- lea f, 1 ; Set the decrement offset to one.
jsr get_endrow ; Yes, so Get the ending line.
mov d, a ;
mov s, scr_trow ; Get the current row position.
@@ -890,9 +882,7 @@ shftln:
cmp s, f ; No, but is the cursor position greater than, or equal to the shift length?
bcc @end ; No, so we're done.
@find_end:
- lea f, 1 ; Set the decrement offset to the left flag.
jsr find_end ; Find the end of the line.
- mov f, e ; Get the shift length.
sub a, c ; Decrement the old end position, if the left flag is set.
tab ; Save the old end position for later.
mov a, f ; Get the shift length.
@@ -920,9 +910,13 @@ shftln:
mov a, bp ; Get the new end position.
div #maxcol+1 ; Get the new ending line.
mov e, a ; Save the ending line.
+ mov r11, f ; Get the shift length.
xor f, f ; Reset F.
and c, c ; Is the left flag set?
meq f, b ; Save the remainder of the ending line if not.
+; div #maxcol+1 ; Get the line length.
+; dec ; Decrement the line length.
+; mov bp, a ; Save the line length.
tya ; Get the cursor position.
div #maxcol+1 ; Get the cursor line.
mov bp, a ; Save the cursor line.
@@ -933,16 +927,15 @@ shftln:
div #maxcol+1 ; Get the old ending line.
cmp bp, a ; Is the cursor line greater than, or equal to the old ending line?
mcs a, bp ; Get the cursor line if so.
- inc ; Increment the line.
+ cmp r11, #maxcol+1 ; Is the shift length greater than, or equal to the max column count?
+ adc #0 ; Increment the starting line if so.
and c, c ; Is the left flag set?
mne a, e ; Set the ending line to the new ending line if so.
tab ; Save the ending line.
and c, c ; Is the left flag set?
bne @inc ; Yes, so increment the starting line.
cmp y, b ; No, but is the starting line less than the ending line?
- bcs @loop ; No, so don't increment.
- iny ; Yes, so increment the starting line.
- bra @getbit ; Get the bit.
+ bcc @inc ; Yes, so increment the starting line.
@loop:
xor s, s ; Reset S.
cmp y, b ; Is the current line greater than the ending line?