-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4efd16a
commit 8728ec5
Showing
10 changed files
with
556 additions
and
760 deletions.
There are no files selected for viewing
This file contains 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,41 @@ | ||
type | ||
list { | ||
int val; | ||
list next; | ||
} | ||
endtype | ||
|
||
decl | ||
list head, tempNode, node; | ||
enddecl | ||
|
||
int main() { | ||
decl | ||
int temp, n, x, i; | ||
enddecl | ||
begin | ||
temp = initialize(); | ||
temp = exposcall("Write", -2, "Enter n: "); | ||
temp = exposcall("Read", -1, n); | ||
head = alloc(); | ||
tempNode = head; | ||
i = 0; | ||
while (i < n) do | ||
node = alloc(); | ||
temp = exposcall("Read", -1, x); | ||
node.val = x; | ||
tempNode.next = node; | ||
tempNode = node; | ||
i = i + 1; | ||
endwhile; | ||
temp = exposcall("Write", -2, "Linked List:"); | ||
head = head.next; | ||
i = 0; | ||
while (i < n) do | ||
temp = exposcall("Write", -2, head.val); | ||
head = head.next; | ||
i = i + 1; | ||
endwhile; | ||
return 0; | ||
end | ||
} |
This file contains 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,254 @@ | ||
0 | ||
2056 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
MOV SP,4098 | ||
MOV BP,4099 | ||
PUSH R0 | ||
CALL 2066 | ||
INT 10 | ||
PUSH BP | ||
MOV BP,SP | ||
PUSH R0 | ||
PUSH R0 | ||
PUSH R0 | ||
PUSH R0 | ||
MOV R0,"Heapset" | ||
PUSH R0 | ||
ADD SP,3 | ||
PUSH R0 | ||
CALL 0 | ||
SUB SP,5 | ||
MOV R1,BP | ||
MOV R0,1 | ||
ADD R1,R0 | ||
MOV [R1],R0 | ||
MOV R0,"Write" | ||
PUSH R0 | ||
MOV R0,-2 | ||
PUSH R0 | ||
MOV R0,"Enter n: " | ||
PUSH R0 | ||
PUSH R0 | ||
PUSH R0 | ||
CALL 0 | ||
SUB SP,5 | ||
MOV R0,5 | ||
MOV R1,SP | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV R2,BP | ||
MOV R1,1 | ||
ADD R2,R1 | ||
MOV [R2],R0 | ||
MOV R0,"Read" | ||
PUSH R0 | ||
MOV R0,-1 | ||
PUSH R0 | ||
MOV R1,BP | ||
MOV R0,2 | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV R0,R1 | ||
MOV R0,R0 | ||
PUSH R0 | ||
PUSH R0 | ||
PUSH R0 | ||
CALL 0 | ||
SUB SP,5 | ||
MOV R0,5 | ||
MOV R1,SP | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV R2,BP | ||
MOV R1,1 | ||
ADD R2,R1 | ||
MOV [R2],R0 | ||
MOV R0,"Alloc" | ||
PUSH R0 | ||
MOV R0,8 | ||
PUSH R0 | ||
ADD SP,2 | ||
PUSH R0 | ||
CALL 0 | ||
SUB SP,5 | ||
MOV R0,5 | ||
MOV R1,SP | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV [4096],R0 | ||
MOV R0,[4096] | ||
MOV [4097],R0 | ||
MOV R0,0 | ||
MOV R2,BP | ||
MOV R1,4 | ||
ADD R2,R1 | ||
MOV [R2],R0 | ||
MOV R1,BP | ||
MOV R0,4 | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV R2,BP | ||
MOV R1,2 | ||
ADD R2,R1 | ||
MOV R1,[R2] | ||
LT R0,R1 | ||
JZ R0,2372 | ||
MOV R0,"Alloc" | ||
PUSH R0 | ||
MOV R0,8 | ||
PUSH R0 | ||
ADD SP,2 | ||
PUSH R0 | ||
CALL 0 | ||
SUB SP,5 | ||
MOV R0,5 | ||
MOV R1,SP | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV [4098],R0 | ||
MOV R0,"Read" | ||
PUSH R0 | ||
MOV R0,-1 | ||
PUSH R0 | ||
MOV R1,BP | ||
MOV R0,3 | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV R0,R1 | ||
MOV R0,R0 | ||
PUSH R0 | ||
PUSH R0 | ||
PUSH R0 | ||
CALL 0 | ||
SUB SP,5 | ||
MOV R0,5 | ||
MOV R1,SP | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV R2,BP | ||
MOV R1,1 | ||
ADD R2,R1 | ||
MOV [R2],R0 | ||
MOV R1,BP | ||
MOV R0,3 | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV R1,[4098] | ||
MOV R2,1 | ||
ADD R2,R1 | ||
MOV R1,[R2] | ||
MOV R1,R2 | ||
MOV [R1],R0 | ||
MOV R0,[4098] | ||
MOV R1,[4097] | ||
MOV R2,2 | ||
ADD R2,R1 | ||
MOV R1,[R2] | ||
MOV R1,R2 | ||
MOV [R1],R0 | ||
MOV R0,[4098] | ||
MOV [4097],R0 | ||
MOV R1,BP | ||
MOV R0,4 | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV R1,1 | ||
ADD R0,R1 | ||
MOV R2,BP | ||
MOV R1,4 | ||
ADD R2,R1 | ||
MOV [R2],R0 | ||
JMP 2220 | ||
MOV R0,"Write" | ||
PUSH R0 | ||
MOV R0,-2 | ||
PUSH R0 | ||
MOV R0,"Linked List:" | ||
PUSH R0 | ||
PUSH R0 | ||
PUSH R0 | ||
CALL 0 | ||
SUB SP,5 | ||
MOV R0,5 | ||
MOV R1,SP | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV R2,BP | ||
MOV R1,1 | ||
ADD R2,R1 | ||
MOV [R2],R0 | ||
MOV R0,[4096] | ||
MOV R1,2 | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV [4096],R0 | ||
MOV R0,0 | ||
MOV R2,BP | ||
MOV R1,4 | ||
ADD R2,R1 | ||
MOV [R2],R0 | ||
MOV R1,BP | ||
MOV R0,4 | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV R2,BP | ||
MOV R1,2 | ||
ADD R2,R1 | ||
MOV R1,[R2] | ||
LT R0,R1 | ||
JZ R0,2524 | ||
MOV R0,"Write" | ||
PUSH R0 | ||
MOV R0,-2 | ||
PUSH R0 | ||
MOV R0,[4096] | ||
MOV R1,1 | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV R0,R0 | ||
PUSH R0 | ||
PUSH R0 | ||
PUSH R0 | ||
CALL 0 | ||
SUB SP,5 | ||
MOV R0,5 | ||
MOV R1,SP | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV R2,BP | ||
MOV R1,1 | ||
ADD R2,R1 | ||
MOV [R2],R0 | ||
MOV R0,[4096] | ||
MOV R1,2 | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV [4096],R0 | ||
MOV R1,BP | ||
MOV R0,4 | ||
ADD R1,R0 | ||
MOV R0,[R1] | ||
MOV R1,1 | ||
ADD R0,R1 | ||
MOV R2,BP | ||
MOV R1,4 | ||
ADD R2,R1 | ||
MOV [R2],R0 | ||
JMP 2428 | ||
MOV R0,0 | ||
MOV R1,BP | ||
MOV R2,2 | ||
SUB R1,R2 | ||
MOV [R1],R0 | ||
POP R0 | ||
POP R0 | ||
POP R0 | ||
POP R0 | ||
MOV BP,[SP] | ||
POP R0 | ||
RET |
This file contains 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
Oops, something went wrong.