Created
April 22, 2019 22:21
-
-
Save killdash9/de53865f9af7aea6188919ca016636f5 to your computer and use it in GitHub Desktop.
HTTP Server written in EDSAC assembly
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 is a minimal HTTP server written in EDSAC assembly. | |
It uses initial orders 1 | |
The program itself starts on line 31 to align instructions with their resident memory addresses | |
It will run in the great EDSAC simulator found at | |
http://nhiro.org/learn_language/repos/EDSAC-on-browser/index.html] | |
T333S | |
E50S [GOTO main program, load lookup table] | |
PS [NEEDLE_CHAR and lastchar and output prep] | |
PS [HAYSTACK_CHAR] | |
U900S [input buffer update location] | |
P50S [lookup table location] | |
P1S [2 for incrementing ] | |
PS [input characters stored here] | |
PL [1 for incrementing] | |
P13L [g] | |
P1L [e] | |
P2L [t] | |
P10S [ ] | |
A900S [initial input buffer read location] | |
A400S [initial lookup table read location] | |
P9S [lookup table delimiter for separating (cr)] | |
U2S [for subroutines] | |
U400S [initial lookup table write location] | |
P12S [lf] | |
A48S[load lookup table][get lookup table loc] | |
T54S[write write instruction] | |
I38S[read input] | |
A38S[get input into A] | |
ZS[U400?S write A(input) to memory] | |
S46S[compare to delimiter cr/@] | |
G69S[not delimiter. go to increment.] | |
TS | |
A46S | |
S38S | |
G69S[not delimiter. go to increment.] | |
A38S[is delimiter. compare against last char] | |
S33S | |
G69S[not repeated. go to increment.] | |
TS | |
A33S | |
S38S | |
G69S[not repeated. go to increment.] | |
E76S[repeated. goto read 404.] | |
TS[increment, clear A first.] | |
A54S[load current pointer] | |
A37S[+2/1] | |
T54S[save incremented pointer] | |
A38S[store last char] | |
T33S[store last char] | |
E52S[loop to read next char] | |
A54S[read 404][load current pointer] | |
A37S[+2/1] | |
T81S[save incremented write pointer ] | |
I38S[read input] | |
A38S[get input into A] | |
ZS[U400?S write A(input) to memory] | |
S46S[compare to delimiter cr/@] | |
G89S[not delimiter. go to increment.] | |
TS | |
A46S | |
S38S | |
G89S[not delimiter. go to increment.] | |
E289S[is delimiter, go to print startup message] | |
TS [increment][clear] | |
A81S[load pointer] | |
E77S[loop back to increment code] | |
TS [called on bad request][clear] | |
A46S [load eof input delim (cr)] | |
T900S [write it] | |
E156S[proceed to lookup table. should end up in 404] | |
PS | |
PS | |
PS | |
PS | |
ZS [read request. should be at 100] | |
I38S[read a character] | |
A38S[put character in A] | |
S40S[subtract E] | |
G92S [if it's not, report error] | |
TS[clear a] | |
A40S[put E in A] | |
S38S[subtract character] | |
G92S [report error if <0] | |
I38S[read a character] | |
A38S[put character in A] | |
S41S[subtract E] | |
G92S [if it's not, report error] | |
TS[clear a] | |
A41S[put E in A] | |
S38S[subtract character] | |
G92S [report error if <0] | |
I38S[read a character] | |
A38S[put character in A] | |
S42S[subtract T] | |
G92S [if it's not, report error] | |
TS[clear a] | |
A42S[put T in A] | |
S38S[subtract character] | |
G92S [report error if <0] | |
I38S[read a character] | |
A38S[put character in A] | |
S43S[subtract !] | |
G92S [if it's not, report error] | |
TS[clear a] | |
A43S[put ! in A] | |
S38S[subtract character] | |
G92S [report error if <0] | |
A35S [read initial input pointer] | |
T137S [Initialize input pointer] | |
I38S [ read char into 38 ] | |
A38S | |
ZS [input pointer, UbufS] | |
S43S [subtract space] | |
G145S [jump ahead to increment section because it's not a space] | |
TS [clear A] | |
A43S [add space] | |
S38S [subtract input] | |
G145S [jump ahead to increment section because it's not a space] | |
E150S [ it's a space, break out of loop ] | |
TS [inputpointer++: clear a] | |
A137S [load input pointer] | |
A37S [+2] | |
T137S [save new input pointer] | |
E135S [loop back to get new input char] | |
TS [---add delimiter cr to mark end of input---] | |
A137S [load input pointer] | |
T154S [save new input pointer for delim] | |
A46S [load cr delimiter] | |
ZS [save delimiter at end of input UbufS] | |
TS[clear] | |
A45S [read initial lookup pointer] | |
T162S [initialize lookup pointer] | |
A44S [--search lookup table--][reset input pointer] | |
T160S [initialize input pointer] | |
ZS [compare-chars][input read pointer, AbufS] | |
T33S [save the char to 33] | |
ZS [lookup read pointer,AbufS. need to shift.] | |
U34S [save the char to 34 (haystack)] | |
S33S [compare lookup against input] | |
G186S[jump to skip-to-next] | |
TS | |
A33S | |
S34S | |
G186S[jump to skip-to-next] | |
TS[they are equal, check for end delim] | |
A33S | |
S46S [ compare against cr] | |
G178S[jump to next-char] | |
TS | |
A46S | |
S33S [ compare against cr] | |
G179S[jump to next-char] | |
E203S[jump to print response call] | |
TS [next-char][clear pointer] | |
A160S [load pointer] | |
A37S [+2] | |
T160S [save pointer] | |
A162S [load pointer] | |
A37S [+2] | |
T162S [save pointer] | |
E160S [ jump to compare-chars] | |
TS [clear A] [skip-to-next] | |
TS [noop, this was a pause before] | |
A189S [save calling address] | |
G210S [call skip-over-next-delim] | |
A191S [save calling address] | |
G210S [call skip-over-next-delim] | |
A162S [see if we are at the end of the lookup table by checking for delimiter][first we need to get the lookup pointer] | |
T195S [save lookup pointer to next instruction] | |
ZS [lookup pointer A?S, read current lookup char into a] | |
U34S[save to haystack] | |
S46S[compare against delim] | |
G206S[goto not delim] | |
TS | |
A46S | |
S34S | |
G206S[goto not delim] | |
A203S[at delim, print 404] | |
G231S[print response] | |
E100S[read next request] | |
TS[not delim. clear a, then] | |
E158S [look at next entry in lookup table] | |
ZS | |
ZS | |
A47S[subroutine skip-over-next-delim. wheeler jump] | |
T225S[subroutine return order] | |
A162S [copy current lookup read pointer] | |
T214S | |
ZS [lookup read pointer AbufS,copied from 162 ] | |
U34S[save to haystack] | |
S46S[compare against delim] | |
G226S[goto advance-char] | |
TS | |
A46S | |
S34S | |
G226S[goto advance-char] | |
A214S [we are at delim. set 162(lookup read pointer) to 1+current and return][load pointer] | |
A37S[+2] | |
T162S | |
ZS [wheeler jump return] | |
TS[advance-char][clear pointer] | |
A214S [load pointer] | |
A37S[+2] | |
T214S [save pointer] | |
E214S [loop back] | |
A47S[subroutine read headers and print current lookup pointer. wheeler jump] | |
T277S[subroutine return order] | |
TS[was stop for debugging] | |
TS[clear out last char at 33] | |
T33S | |
I38S[get next char] | |
A38S[compare it against CR] | |
S46S | |
G245S [not cr, proceed] | |
TS | |
A46S | |
S38S | |
G245S [not cr,proceed] | |
E236S[is cr,ignore it in headers, loop back to get next char] | |
TS[proceed, compare this and last char against nl] | |
A38S | |
S49S | |
G261S [not nl] | |
TS | |
A49S | |
S38S | |
G261S [not nl] | |
A38S | |
S33S | |
G261S [not nl] | |
TS | |
A33S | |
S38S | |
G261S [not nl] | |
E266S [both are newlines. Proceed to output section of subroutine] | |
TS[not nl] | |
A38S[save cur as last] | |
T33S | |
E236S[loop back to read next char] | |
ZS | |
A162S [copy current lookup read pointer. Assume it's on a delim at this time, so advance.][this was at 233] | |
A37S [advance] | |
T269S [save it to next instruction] | |
ZS [lookup read pointer AbufS,copied from 162] | |
U34S[save to haystack] | |
S46S[compare against delim] | |
G278S[goto print-char] | |
TS | |
A46S | |
S34S | |
G278S[goto print-char] | |
ZS [wheeler jump return][we are at delim. return] | |
TS[print-char][clear pointer] | |
A34S[load char to print] | |
L1024S[shift to print it] | |
T33S[write shifted char to NEEDLE] | |
O33S[print it] | |
A269S [load pointer] | |
A37S[+2] | |
T269S [save pointer] | |
E269S [loop back to read the next one] | |
ZS | |
O333S[end of startup message] | |
TS[print startup message] | |
O297S[start of startup message] | |
A290S | |
A37S[+1/2] | |
U290S[set incremented output location] | |
S288S | |
G289S[loop back if not at end] | |
E100S[jump up to read first request] | |
PS | |
RS | |
ES | |
SS | |
SS | |
!S | |
RS | |
US | |
NS | |
!S | |
TS | |
OS | |
!S | |
SS | |
US | |
BS | |
MS | |
IS | |
TS | |
!S | |
RS | |
ES | |
QS | |
US | |
ES | |
SS | |
TS | |
!S | |
OS | |
NS | |
!S | |
TS | |
AS | |
PS | |
ES | |
&S | |
/@ | |
*HTTP#/1,1!200!*OK& | |
& | |
HELLO!FROM!EDSAC& | |
TRY!REQUESTING!THESE!OTHER!PAGES& | |
#/*WILKES& | |
#/*WHEELER& | |
@ | |
/WILKES@ | |
*HTTP#/1,1!200!*OK& | |
& | |
MAURICE!WILKES!LED!THE!TEAM!RESPONSIBLE!& | |
FOR!THE!DESIGN!AND!CONSTRUCTION!OF!EDSAC& | |
@ | |
/WHEELER@ | |
*HTTP#/1,1!200!*OK& | |
& | |
DAVID!WHEELER!CREATED!THE!INITIAL!ORDERS!& | |
WHICH!ALLOWED!A!PROGRAM!TO!BE!LOADED!INTO!& | |
MEMORY!FROM!PAPER!TAPE& | |
@ | |
@ | |
*HTTP#/1,1!404!*NOT!FOUND& | |
& | |
PAGE!NOT!FOUND& | |
@ | |
GET!/!HTTP/1.0@&@& | |
GET!/WILKES!HTTP/1.0@&@& | |
GET!/WHEELER!HTTP/1.0@&@& | |
GET!/NONEXISTENTFILE!HTTP/1.0@&@& |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment