|

楼主 |
发表于 2020-4-2 09:20:14
|
显示全部楼层
只要你能看懂。
比如说自由矩形填充和Printf用来显示ASCII字符:
- FreeSquareFill8x6 PROC
- EXPORT FreeSquareFill8x6
- PUSH {R4-R6,R14}
- CMP R0,#0x7A
- BHI FS6InvaildInput
- ;The R0 is restricted to 0x7A, for only 128 pixels are contained in one page, any value
- ;higher than it will result the maximum X-offset of the prescriptive square area surpasses
- ;valid range.
- CMP R1,#0x07
- BLO FS6InvaildInput
- ;The R1 is restricted to 0x07, for a 8x6 square area can not be contented if the Y coordinate
- ;is less than 7.
- MOVS R4,#0x07
- SUB R4,R1,LSR#0x03
- ;Translate Y-coordinate to page offset value. R4=7-R1/8.
- ADD R0,R4,R0,LSL#0x03
- ;Calculate initial offset address whereby the location of the first element concerned can be
- ;confirmed.
- AND R1,#0x07
- ADDS R1,#0x19
- ;Calculate bit offset value defined by Y-coordinate. R1=25+R1%8.
- LDR R4,=GraphyBuff
- ;Load graphy data head address.
- CMP R3,#0x00
- MOVNE R3,#0xFF
- ;If R3 is non zero, the content written to graphy buff will be reversed first.
- ADDS R0,R4
- ;MOV pointer to the first element of the first page which is to be modified.
- MVN R4,#0xFF
- RORS R4,R1
- ;Generate bit mask.
- MOVS R14,#0x06
- FS6SegModifyLoop LDRB R5,[R2],#0x01
- ;Load a byte from data source and move pointer to next byte.
- LDR R6,[R0]
- ;Load a word from graphy buff.
- EORS R5,R3
- ;Bit reversal.
- RORS R5,R1
- ANDS R6,R4
- ORRS R5,R6
- ;Mask unconcerned bits and consolidate two data blocks.
- STR R5,[R0],#0x08
- ;Write back to graphy buff and move pointer to next segment to be modified.
- SUBS R14,#0x01
- BNE FS6SegModifyLoop
- ;Fill the buff with given data, stops after finishing all segments.
- FS6InvaildInput POP {R4-R6,R15}
- ENDP
- ;This function aims to provide a approach that user can fill a appointed 8x6 suqare area
- ;without the limit of location.
- FreeSquareFill8x8 PROC
- EXPORT FreeSquareFill8x8
- PUSH {R4-R6,R14}
- CMP R0,#0x78
- BHI FS8InvaildInput
- ;The R0 is restricted to 0x78, for only 128 pixels are contained in one page, any value
- ;higher than it will result the maximum X-offset of the prescriptive square area surpasses
- ;valid range.
- CMP R1,#0x07
- BLO FS8InvaildInput
- ;The R1 is restricted to 0x07, for a 8x8 square area can not be contented if the Y coordinate
- ;is less than 7.
- MOVS R4,#0x07
- SUB R4,R1,LSR#0x03
- ;Translate Y-coordinate to page offset value. R4=7-R1/8.
- ADD R0,R4,R0,LSL#0x03
- ;Calculate initial offset address whereby the location of the first element concerned can be
- ;confirmed.
- AND R1,#0x07
- ADDS R1,#0x19
- ;Calculate bit offset value defined by Y-coordinate. R1=25+R1%8.
- LDR R4,=GraphyBuff
- ;Load graphy data head address.
- CMP R3,#0x00
- MOVNE R3,#0xFF
- ;If R3 is non zero, the content written to graphy buff will be reversed first.
- ADDS R0,R4
- ;MOV pointer to the first element of the first page which is to be modified.
- MVN R4,#0xFF
- RORS R4,R1
- ;Generate bit mask.
- MOVS R14,#0x08
- FS8SegModifyLoop LDRB R5,[R2],#0x01
- ;Load a byte from data source and move pointer to next byte.
- LDR R6,[R0]
- ;Load a word from graphy buff.
- EORS R5,R3
- ;Bit reversal.
- RORS R5,R1
- ANDS R6,R4
- ORRS R5,R6
- ;Mask unconcerned bits and consolidate two data blocks.
- STR R5,[R0],#0x08
- ;Write back to graphy buff and move pointer to next segment to be modified.
- SUBS R14,#0x01
- BNE FS8SegModifyLoop
- ;Fill the buff with given data, stops after finishing all segments.
- FS8InvaildInput POP {R4-R6,R15}
- ENDP
- ;This function aims to provide a approach that user can fill a appointed 8x8 suqare area
- ;without the limit of location.
- Printf PROC
- EXPORT Printf
- IMPORT ASCII8x6
- PUSH {R4-R6,R14}
- MOVS R4,R1
- MOVS R5,R2
- MOVS R6,R0
- MOVS R7,R3
- ;
- LDR R8,=ASCII8x6
- ;
- B StartDrawCharacter
- DrawCharacter CBZ R0,StringEnd
- ;
- CMP R0,#0x7E
- MOVHI R0,#0x20
- SUBS R0,#0x20
- MOVLO R0,#0x00
- ;
- MOVS R1,#0x06
- MLA R2,R0,R1,R8
- ;
- MOVS R1,R5
- MOVS R0,R4
- ;
- MOVS R3,R7
- ;
- BL FreeSquareFill8x6
- ;
- StartDrawCharacter LDRB R0,[R6],#0x01
- ;
- ADDS R4,#0x06
- ;
- B DrawCharacter
- StringEnd POP {R4-R6,R15}
- ENDP
复制代码
|
|