-
Notifications
You must be signed in to change notification settings - Fork 27
Support MACRO-11 in PDP-11 code generator and add RT-11 runtime. #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shattered
wants to merge
1
commit into
davidgiven:master
Choose a base branch
from
shattered:_4c009ae2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # XXX not ported yet | ||
|
|
||
| var argv: uint8[81]; | ||
| var argv_pointer: [uint8] := &argv[0]; | ||
|
|
||
| sub ArgvInit() is | ||
| var carry: uint8 := 0; | ||
| var prompt: [uint8] := "DCL>"; | ||
| var tmp: uint8[81]; | ||
| var ptr: [uint8]; | ||
|
|
||
| @asm ".gtlin", argv_pointer, ",", prompt; | ||
| @asm "adcb", carry; | ||
|
|
||
| print("error: "); print_i32(carry as uint32); print_nl(); | ||
| print("csi args: "); print(argv_pointer); print_nl(); | ||
| ptr := argv_pointer + StrLen(argv_pointer); | ||
|
|
||
| # undo CSI conversion: "a b c" -> "b c=a" | ||
| loop | ||
| ptr := @prev ptr; | ||
| var c := [ptr]; | ||
| if (c == '=') then break; end if; | ||
| if ptr == argv_pointer then return; end if; | ||
| end loop; | ||
|
|
||
| print("tmp: "); print(ptr); print_nl(); | ||
| print("tmp: "); print_char([ptr + 1]); print_nl(); | ||
|
|
||
| # found '=' char | ||
| [ptr] := 0; | ||
| CopyString(ptr + 1, &tmp[0]); | ||
| tmp[StrLen(ptr + 1) as uint8] := ' '; | ||
| CopyString(argv_pointer, &tmp[StrLen(ptr + 1) as uint8 + 1]); | ||
| CopyString(&tmp[0], argv_pointer); | ||
| print("unix args: "); print(argv_pointer); print_nl(); | ||
| end sub; | ||
|
|
||
| # Returns null is there's no next argument. | ||
| sub ArgvNext(): (arg: [uint8]) is | ||
| arg := argv_pointer; | ||
| end sub; | ||
|
|
||
| # vim: ts=4 sw=4 et |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| cowwrap { | ||
| ins = { "rt/rt11/cowgol.cos" }, | ||
| outs = { "$OBJ/rt/rt11/cowgol.coo" } | ||
| } | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from src.build import cowwrap | ||
|
|
||
| cowwrap(name="cowgolcoo", src="./cowgol.cos") |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| var LOMEM: [uint8]; | ||
| var HIMEM: [uint8]; | ||
| var HW: int16; | ||
| var API: int16; | ||
|
|
||
| @asm "; set LOMEM and HIMEM"; | ||
| @asm "mov limit+2,", LOMEM; | ||
| @asm ".gval #limit, #^O266"; # $USRLC | ||
| @asm ".setto r0"; | ||
| @asm "mov r0,", HIMEM; | ||
| @asm "clr", HW; | ||
| @asm "clr", API; | ||
| @asm ";"; | ||
|
|
||
| sub Exit() is | ||
| @asm "bisb\t#1, @#^O53"; | ||
| @asm "br\texit"; | ||
| end sub; | ||
|
|
||
| sub ExitWithError() is | ||
| @asm "bisb\t#4, @#^O53"; | ||
| @asm "br\texit"; | ||
| end sub; | ||
|
|
||
| sub AlignUp(in: intptr): (out: intptr) is | ||
| out := (in + 1) & ~1; | ||
| end sub; | ||
|
|
||
| sub print_char(c: uint8) is | ||
| if c == '\n' then | ||
| @asm ".ttyou #^O15"; | ||
| end if; | ||
| @asm ".ttyou", c; | ||
| end sub; | ||
|
|
||
| sub MemSet(buf: [uint8], byte: uint8, len: uint16) is | ||
| var bufend := buf + len; | ||
| loop | ||
| if buf == bufend then | ||
| return; | ||
| end if; | ||
| [buf] := byte; | ||
| buf := buf + 1; | ||
| end loop; | ||
| end sub; | ||
|
|
||
| sub print_oct_i16(value: uint16) is | ||
| var i: uint8 := 5; | ||
| print_char(((value >> 15) + '0') as uint8); | ||
| loop | ||
| var digit := (((value >> 12) & 7) + '0') as uint8; | ||
| print_char(digit); | ||
| value := value << 3; | ||
| i := i - 1; | ||
| if i == 0 then | ||
| break; | ||
| end if; | ||
| end loop; | ||
| end sub; | ||
|
|
||
| include "common.coh"; | ||
|
|
||
| # vim: ts=4 sw=4 et |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| # Unsigned 32-bit division. | ||
| # Computes r2r3/r0r1, putting the quotient in r2r3 and the remainder in r4r5. | ||
| &X _divremu4 | ||
| ; _divremu4 | ||
| ``: | ||
| ; The PDP11 has a 32/16->16%16 signed division instruction. Synthesising | ||
| ; 32/32->32%32 unsigned division from this is surprisingly hard, so for | ||
| ; now we don't bother and just use long division. | ||
|
|
||
| clr r4 ; reset remainder | ||
| clr r5 | ||
| mov r0, -(sp) ; move hi(RHS) onto the stack, as we need r0... | ||
| mov #32, r0 ; ...for the loop counter | ||
| br ``_entry | ||
|
|
||
| ``_loop: | ||
| dec r0 | ||
| beq ``_exit | ||
| ``_entry: | ||
| ashc #1, r2 ; left shift LHS | ||
| rol r5 ; ...moving the shifted out top bit into the remainder | ||
| rol r4 | ||
|
|
||
| cmp r4, (sp) ; if remainder < RHS, loop without subtracting | ||
| bcs ``_loop | ||
| bne ``_skip | ||
| cmp r5, r1 | ||
| bcs ``_loop | ||
|
|
||
| ``_skip: | ||
| inc r3 ; set the bottom bit of the quotient (guaranteed to be 0) | ||
| sub r1, r5 | ||
| sbc r4 ; remainder = remainder - RHS | ||
| sub (sp), r4 | ||
| br ``_loop | ||
| ``_exit: | ||
| mov (sp)+, r0 ; retract stack | ||
| rts pc | ||
|
|
||
| # Signed 32-bit division. | ||
| # Computes r2r3/r0r1, putting the quotient in r2r3 and the remainder in r4r5. | ||
| # This is a wrapper around _divremu4 above. | ||
| &X _divrems4 | ||
| ; _divrems4 | ||
| ``: | ||
| xor r2, r0 ; discover sign of result | ||
| mov r0, -(sp) ; save for later | ||
| xor r2, r0 ; recover result | ||
| mov r2, -(sp) ; save result for sign of remainder | ||
|
|
||
| tst r0 ; set flags from hi(rhs) | ||
| bpl ``_1 | ||
| com r0 ; negate r0r1 | ||
| com r1 | ||
| add #1, r1 ; add (setting carry) | ||
| adc r0 | ||
| ``_1: | ||
| tst r2 ; set flags from hi(lhs) | ||
| bpl ``_2 | ||
| com r2 ; negate r2r3 | ||
| com r3 | ||
| add #1, r3 | ||
| adc r2 | ||
| ``_2: | ||
|
|
||
| call `_divremu4 ; perform unsigned division | ||
|
|
||
| tst (sp) ; check sign of remainder | ||
| bpl ``_3 | ||
| com r4 | ||
| com r5 | ||
| add #1, r5 | ||
| adc r4 | ||
| ``_3: | ||
| tst 2(sp) ; check sign of quotient | ||
| bpl ``_4 | ||
| com r2 | ||
| com r3 | ||
| add #1, r3 | ||
| adc r2 | ||
| ``_4: | ||
| add #4, sp ; retract over stack | ||
| rts pc | ||
|
|
||
| # vim: ts=4 sw=4 et | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this belong in flags? I see it's being set to FCB_FLAG_READONLY, which looks like a flags value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flags are changed by read/write/flush functions, and I didn't want to change common code too much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping?