summaryrefslogtreecommitdiff
path: root/programs/sub-suite/utils.s
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2021-02-25 12:43:11 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2021-02-25 12:43:11 -0500
commit35a18609864470b3dc49f3a9a6cb6ec93e57300d (patch)
treec52364211b25723b2cf4595ed6c4bc2d45195062 /programs/sub-suite/utils.s
parent8d7f27d9a0b61d3694a62f3e54be885d8073f02b (diff)
- Implemented the multiply expression into the assembler.
- Implemented support for the SIB addressing mode into the assembler. SIB is short for "Scale Index, and Base", and works much like x86's version of SIB (scale*index+base), although my version supports any scale value between 1, and 256. - Redid the line shifting routine in SuBEditor. It now uses memcpy, and memset to do that, and also supports shifting the line left, or right by any number of characters.
Diffstat (limited to 'programs/sub-suite/utils.s')
-rw-r--r--programs/sub-suite/utils.s91
1 files changed, 44 insertions, 47 deletions
diff --git a/programs/sub-suite/utils.s b/programs/sub-suite/utils.s
index 6479099..8f4a643 100644
--- a/programs/sub-suite/utils.s
+++ b/programs/sub-suite/utils.s
@@ -10,12 +10,12 @@ print_hi:
lea d, (sp+1) ; Get the address of the hex string buffer.
mov f, #$10 ; Set digit count to 16.
jsr print_hex ; Print the address.
- mov.q (b), (a) ; Print the lower half of the hex string to the string buffer.
- mov.q (b+8), (a+8) ; Print the upper half of the hex string to the string buffer.
+ mov.q (b), (d) ; Print the lower half of the hex string to the string buffer.
+ mov.q (b+8), (d+8) ; Print the upper half of the hex string to the string buffer.
add b, #$10 ; Add 16 to the index.
mov.w (b), #': ' ; Print a colon, and space to the string buffer.
add b, #2 ; Add two to the string buffer pointer.
- tba a ; Return the string buffer pointer after the printed string.
+ tba ; Return the string buffer pointer after the printed string.
ads #$10 ; Cleanup the stack frame.
plb.q ; Restore B.
rts ; End of print_hi.
@@ -34,7 +34,7 @@ print_lo:
lea f, 2 ; Set the digit count to two.
mov s, b ; Get the low nibble offset.
jsr print_hex ; Print the low nibble offset.
- mov.w (x), (a) ; Place the hex digits in the string buffer.
+ mov.w (x), (d) ; Place the hex digits in the string buffer.
add x, #2 ; Add two to the string buffer pointer.
inb ; Increment the nibble offset.
cpb #$10 ; Are we at the last offset?
@@ -55,34 +55,38 @@ print_lo:
pla.q ; Restore A.
rts ; End of print_lo.
-
print_chunk:
pha.q ; Preserve A.
phb.q ; Preserve B.
phx.q ; Preserve X.
phy.q ; Preserve Y.
- sbs #2 ; Make room for the hex string buffer.
+ sbs #16 ; Make room for the hex string buffer.
and #0 ; Reset A.
- tab ; Reset B.
+ tay ; Reset Y.
+ ldy #2 ; Set the number of 8 byte chunks to read to 2.
mov x, d ; Get the address of the string buffer.
- mov y, s ; Get the starting address.
+ mov b, s ; Get the starting address.
lea d, (sp+1) ; Get the address of the hex string buffer.
- xor s, s ; Reset S.
+; xor s, s ; Reset S.
+@print_hex:
+ lda #16 ; Set the hex string index to 16.
+ mov f, a ; Set the digit count to 16.
+ dey ; Decrement the chunk count.
+ bng @end ; The chunk count is negative, so we're done.
+ mov.q s, (b) ; Read 8 bytes from that address.
+ jsr print_hex ; Print 8 bytes.
+ add b, #8 ; Add 8 to the address.
@loop:
- lea f, 2 ; Set the digit count to two.
- mov s, (y+b) ; Get the byte at that address.
- jsr print_hex ; Print the byte.
- mov.w (x), (a) ; Print the hex string to the string buffer.
- add x, #2 ; Add two to the string buffer pointer.
- inb ; Increment the byte index.
- cpb #$10 ; Have we read 16 bytes?
- beq @end ; Yes, so we're done.
- mov (x), #' ' ; No, so print a space to the string buffer.
- inx ; Increment the string buffer pointer.
- bra @loop ; Keep looping.
+ sub #2 ; Subtract two from the hex string index.
+ mov.w (x), (d+a) ; Print the hex string to the string buffer.
+ mov (x+2), #' ' ; Print a space to the string buffer.
+ add x, #3 ; Add three to the string buffer pointer.
+ cmp #0 ; Did we print 8 bytes?
+ beq @print_hex ; Yes, so read 8 more bytes.
+ bra @loop ; No, so keep looping.
@end:
- mov (x), #0 ; Null terminate the string.
- ads #2 ; Cleanup the stack frame.
+ mov (x-1), #0 ; Null terminate the string.
+ ads #16 ; Cleanup the stack frame.
ply.q ; Restore Y.
plx.q ; Restore X.
plb.q ; Restore B.
@@ -91,45 +95,38 @@ print_chunk:
print_hex:
+ pha.q ; Preserve A.
phb.q ; Preserve B.
phx.q ; Preserve X.
phy.q ; Preserve Y.
lea b, hex_char ; Get the address of the hex character table.
- and f, f ; Is the digit count zero?
- set x, eq ; Set the auto digit count flag if so.
- mne f, #$10 ; Also set the digit count to 16 if the digit count is zero.
mov a, f ; Get the digit count.
- add a, d ; Add the string pointer with the digit count.
+ set x, eq ; Set the auto digit count flag if so.
+ lne #16 ; Also set the digit count to 16 if so.
+ cmp #17 ; Is the digit count greater than 16?
+ lcs #16 ; Set the digit count to 16 if so.
+ add d, a ; Add the string pointer with the digit count.
@loop:
mov y, s ; No, so mask the low nibble of the value.
and y, #$F ;
- dec ; Decrement the string pointer.
- mov (a), (b+y) ; Place the hex digit character in the string.
- lsr s, #4 ; Is the next nibble zero?
+ dec d ; Decrement the string pointer.
+ mov (d), (b+y) ; Place the hex digit character in the string.
+ lsr s, #4 ; Get the next nibble.
bne @loop1 ; No, so decrement the digit count.
@isauto:
- and x, x ; Is the auto digit count flag set?
- bne @end ; Yes, so we're done.
-@loop1:
cpx #1 ; Is the auto digit count flag set?
- sbc f, #0 ; Decrement the digit count if not.
- mov y, f ; Get the digit count.
- or y, x ; Are both the digit count, and the auto digit count flag zero?
- bne @loop ; No, so keep looping.
+ beq @end ; Yes, so we're done.
+@loop1:
+ dec ; Decrement the digit count.
+ bne @loop ; The digit count is non zero, so keep looping.
@end:
ply.q ; Restore Y.
plx.q ; Restore X.
plb.q ; Restore B.
+ pla.q ; Restore A.
rts ; End of print_hex.
-charcpy:
- ldx idx3 ; Get the string index.
- sta strbuf, x ; Save it in the string buffer.
- inc idx3 ; Increment the string index.
- rts ; End of charcpy.
-
-
strcmpg:
lea strcmp ; Get the address of strcmp.
mov.q d, ptr ; Get the first pointer.
@@ -324,11 +321,11 @@ print_sfast:
pha.q ; Preserve A.
and #0 ; Reset A.
@loop:
- inc ; Increment the index.
- cmp (d+a-1), #0 ; Did we hit the end of the string?
+ cmp (d+a), #0 ; Did we hit the end of the string?
beq @end ; Yes, so we're done.
- mov (s+a-1), (d+a-1) ; No, so print the character to the buffer.
- mov scr, (d+a-1) ; Print the character to the screen.
+ mov (s+a), (d+a) ; No, so print the character to the buffer.
+ mov scr, (d+a) ; Print the character to the screen.
+ inc ; Increment the index.
bra @loop ; Keep looping.
@end:
pla.q ; Restore A.