📄 bytecp.68k
字号:
*################ CPM-68k ################*bytecp.s*+++++++++++++++++++++++++++++++++++++++++* modified for max speed (copies longs words or bytes)* arguments <from address><to address><bytes>* Codata C link system .globl _bytecp, _byteclr .text_bytecp: link a6,#0 ;Save sp and registers movem.l d6-d7/a4-a5,-(sp) move.l 16(a6),d7 ;Gets length in bytes movea.l 8(a6),a5 ;Gets from address movea.l 12(a6),a4 ;Gets to address cmpi.l #0,d7 ;Checks if length is 0 beq endcp move.w a5,d6 ;Checks if either address is odd move.w a4,d0 or.b d0,d6 ;Or number of bytes is odd or.b d7,d6 andi.b #1,d6 bne chars ;If so then do character copy clr.l d0 ;Sets d0 to indicate word copy move.b d7,d6 ;Checks if length not in longs andi.b #2,d6 beq long addq.l #1,d0 ;If not set d0 to flag wordlong: asr.l #2,d7 ;Number of longs* 1 is subtracted from length to change the loop to a db loop where* nloops == len -1 subq.l #1,d7 blt oneword ;Special case one word only move.w d7,d6 ;Moves lower half of length into d6 swap d7 ;Sets d7 to top half of lengthloopl: move.l (a5)+,(a4)+ ;Transfers data; dbf d6,loopl ;Inner loop move.w #$FFFF,d6 ;Sets d6 for 64k loops dbf d7,loopl ;Outer loop andi.b #1,d0 beq endcponeword: move.w (a5)+,(a4)+ ;Writes last word in word copyendcp: movem.l (sp)+,d6-d7/a4-a5 ;Recovers registers unlk a6 rtschars: subq.l #1,d7 ;Decrements d7 for dbra type loops move.w d7,d6 ;Moves lower half of length into d6 swap d7 ;Sets d7 to top half of lengthloopc: move.b (a5)+,(a4)+ ;Transfers data; dbf d6,loopc ;Inner loop move.w #$FFFF,d6 ;Sets d6 for 64k loops dbf d7,loopc ;Outer loop bra endcp** Byteclr clears an area of memory* Interface from C byteclr(<address><nobytes>)* _byteclr: link a6,#0 ;Save sp and registers movem.l d6-d7/a5,-(sp) movea.l 8(a6),a5 ;Gets from address move.l 12(a6),d7 ;Gets length in bytes cmpi.l #0,d7 ;Checks if length is 0 beq endclr move.w a5,d6 ;Checks if either address is odd or.b d7,d6 ;Or number of bytes is odd andi.b #1,d6 bne charclr ;If so then do character copy clr.l d0 ;Sets d0 to indicate word copy move.b d7,d6 ;Checks if length not in longs andi.b #2,d6 beq longclr addq.l #1,d0 ;If not set d0 to flag wordlongclr: asr.l #2,d7 ;Number of longs* 1 is subtracted from length to change the loop to a db loop where* nloops == len -1 subq.l #1,d7 blt onewordclr ;Special case one word only move.w d7,d6 ;Moves lower half of length into d6 swap d7 ;Sets d7 to top half of lengthlooplclr: clr.l (a5)+ ;Clears area dbf d6,looplclr ;Inner loop move.w #$FFFF,d6 ;Sets d6 for 64k loops dbf d7,looplclr ;Outer loop andi.b #1,d0 beq endclronewordclr: clr.w (a5)+ ;Writes last word in word copyendclr: movem.l (sp)+,d6-d7/a5 ;Recovers registers unlk a6 rtscharclr: subq.l #1,d7 ;Decrements d7 for dbra type loops move.w d7,d6 ;Moves lower half of length into d6 swap d7 ;Sets d7 to top half of lengthloopcclr: clr.b (a5)+ ;Transfers data; dbf d6,loopcclr ;Inner loop move.w #$FFFF,d6 ;Sets d6 for 64k loops dbf d7,loopcclr ;Outer loop bra endclr
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -