Last active
November 7, 2018 20:24
-
-
Save aberranthacker/f71aa89c5a1666d7e6acac4b7b53cb19 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; vim: set fileformat=dos filetype=asmpdp11 tabstop=8 noexpandtab shiftwidth=8 autoindent : | |
| .Title SRAMT | |
| .Ident /V0.01/ | |
| .MCall .TTYIn, .TTYOut, .Print, .Exit | |
| PR7 = 7*40 ; highest priority to CPU | |
| PR0 = 0 ; lowest priority to CPU | |
| .ASect | |
| .=1000 | |
| Start: | |
| MTPS PR7 ; disable interrupts | |
| MOV #170000,R5 ; R5 - start of second window | |
| ; R4 - current address to test | |
| ; R3 - value to convert to string | |
| ; R2 - test value | |
| ; R1 - address of last digit in a number | |
| ; R0 | |
| CLR @#176000 ; switch to page 0 | |
| NextPage: | |
| MOV #160000,R1 ;fill memory cells with their addresses {{{ | |
| MOV #2048.,R0 | |
| 1$: MOV R1,R2 | |
| MOV R2,(R1)+ | |
| SOB R0,1$ ; }}} | |
| MOV @#176000,R3 ; print page number {{{ | |
| MOV #<PageNumStr+19.+1>,R1 | |
| CALL InsOctNum | |
| .Print #PageNumStr ; }}} | |
| MOV #160000,R4 ; reset current address | |
| FirstPattern: | |
| ; check if memory cell contains it's address ; {{{ | |
| MOV R4,R2 | |
| MOV (R4),R3 | |
| CMP R2,R3 | |
| BEQ ZEROES | |
| CALL ErrorMsg ; }}} | |
| ZEROES: ; zeroes {{{ | |
| CLR R2 | |
| MOV R2,(R4) | |
| MOV (R4),R3 | |
| CMP R2,R3 | |
| BEQ ONES | |
| CALL ErrorMsg ; }}} | |
| ONES: ; ones {{{ | |
| COM R2 | |
| MOV R2,(R4) | |
| MOV (R4),R3 | |
| CMP R2,R3 | |
| BEQ ASL | |
| CALL ErrorMsg ; }}} | |
| ASL: ; shifting one {{{ | |
| MOV #1,R2 | |
| 1$: MOV R2,(R4) | |
| MOV (R4),R3 | |
| CMP R2,R3 | |
| BEQ 2$ | |
| CALL ErrorMsg | |
| 2$: ASL R2 | |
| BCC 1$ ; loop until 1 is squeezed out of register }}} | |
| ROL: ; shifting zero {{{ | |
| MOV #177776,R2 | |
| 1$: MOV R2,(R4) | |
| MOV (R4),R3 | |
| CMP R2,R3 | |
| BEQ 2$ | |
| CALL ErrorMsg | |
| 2$: SEC | |
| ROL R2 | |
| BCS 1$ ; loop until 0 is squeezed out of register }}} | |
| CHEQUER: ; 1010101010101010 {{{ | |
| MOV #125252,R2 | |
| MOV R2,(R4) | |
| MOV (R4),R3 | |
| CMP R2,R3 | |
| BEQ 1$ | |
| CALL ErrorMsg ; }}} | |
| ; 0101010101010101 {{{ | |
| 1$: COM R2 | |
| MOV R2,(R4) | |
| MOV (R4),R3 | |
| CMP R2,R3 | |
| BEQ NextCell | |
| CALL ErrorMsg ; }}} | |
| NextCell: INC R4 | |
| INC R4 | |
| CMP R4,R5 | |
| BNE FirstPattern | |
| INC @#176000 | |
| BNE NextPage | |
| MTPS PR0 ; enable interrupts | |
| .Exit | |
| ErrorMsg: ;--------------- {{{ | |
| ; actual value is in R3 already | |
| MOV #<ErrorStr+59.+1>,R1 | |
| CALL InsOctNum | |
| MOV @#176000,R3 ; page number | |
| MOV #<ErrorStr+11.+1>,R1 | |
| CALL InsOctNum | |
| MOV R4,R3 ; address | |
| MOV #<ErrorStr+27.+1>,R1 | |
| CALL InsOctNum | |
| MOV R2,R3 ; test pattern | |
| MOV #<ErrorStr+44.+1>,R1 | |
| CALL InsOctNum | |
| .Print #ErrorStr | |
| RETURN | |
| ;--------------------------------------- }}} | |
| ;0 1 2 3 4 5 6 | |
| ;0123456789012345678901234567890123456789012345678901234567890 | |
| ErrorStr: .ASCIZ "Page: 123456 address: 123456 expected: 123456 actual: 123456" | |
| PageNumStr: .ASCIZ "Current page: 123456 " | |
| .Even | |
| InsOctNum: ;--------------- {{{ | |
| ;R3 - value to convert | |
| ;R2 - most significant word for division | |
| ;R1 - address of last digit in a number | |
| MOV R2,-(SP) | |
| MOV #6,R0 ;R0 - number of digits in the number | |
| 1$: CLR R2 ;R2 - most significant word | |
| DIV #10,R2 ;R3 - least significant word | |
| ADD #'0,R3 ;add ASCII code for "0" to remainder | |
| MOVB R3,-(R1) | |
| MOV R2,R3 | |
| SOB R0,1$ | |
| MOV (SP)+,R2 | |
| RETURN | |
| ;--------------------------------------- }}} | |
| .BLKW 64. ; reserve 64 words for stack | |
| .End Start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment