max_stars_repo_path
stringlengths 4
261
| max_stars_repo_name
stringlengths 6
106
| max_stars_count
int64 0
38.8k
| id
stringlengths 1
6
| text
stringlengths 7
1.05M
|
---|---|---|---|---|
Applications/VLC/audio volume/audio volume.applescript | looking-for-a-job/applescript-examples | 1 | 3158 | <filename>Applications/VLC/audio volume/audio volume.applescript
#!/usr/bin/osascript
tell application "VLC"
--set audio volume to 9999
--return audio volume
--set volume output volume 100
output volume of (get volume settings)
end tell
|
oddeven.asm | sirdangd/asm | 0 | 94098 | <reponame>sirdangd/asm
;odd even
;the value we are checking is in reg a
;reg b is 00h so that it can be compared to reg a each time to see if it is the same or not
;if reg a becomes negative, it will jump to the odd label and make reg c equal 0Fh
;if reg a becomes 0, it will jump to even making reg c 00h
;in the loop (decreaseReg:), reg a is subtracted by 2 each time
jmp start
;data
;code
start: nop
mvi a, 06h
mvi b, 00h
cmp b
jz even
decreaseReg: sui 02h
jm odd
cmp b
jz even
jp decreaseReg
odd: mvi c, 00h
jmp end
even: mvi c, 0fh
end: hlt |
user/bcachetest.asm | eric-qian-d/TCP | 0 | 27511 |
user/_bcachetest: file format elf64-littleriscv
Disassembly of section .text:
0000000000000000 <createfile>:
exit(0);
}
void
createfile(char *file, int nblock)
{
0: bd010113 addi sp,sp,-1072
4: 42113423 sd ra,1064(sp)
8: 42813023 sd s0,1056(sp)
c: 40913c23 sd s1,1048(sp)
10: 41213823 sd s2,1040(sp)
14: 41313423 sd s3,1032(sp)
18: 41413023 sd s4,1024(sp)
1c: 43010413 addi s0,sp,1072
20: 8a2a mv s4,a0
22: 89ae mv s3,a1
int fd;
char buf[BSIZE];
int i;
fd = open(file, O_CREATE | O_RDWR);
24: 20200593 li a1,514
28: 00000097 auipc ra,0x0
2c: 762080e7 jalr 1890(ra) # 78a <open>
if(fd < 0){
30: 04054a63 bltz a0,84 <createfile+0x84>
34: 892a mv s2,a0
printf("test0 create %s failed\n", file);
exit(-1);
}
for(i = 0; i < nblock; i++) {
36: 4481 li s1,0
38: 03305263 blez s3,5c <createfile+0x5c>
if(write(fd, buf, sizeof(buf)) != sizeof(buf)) {
3c: 40000613 li a2,1024
40: bd040593 addi a1,s0,-1072
44: 854a mv a0,s2
46: 00000097 auipc ra,0x0
4a: 724080e7 jalr 1828(ra) # 76a <write>
4e: 40000793 li a5,1024
52: 04f51763 bne a0,a5,a0 <createfile+0xa0>
for(i = 0; i < nblock; i++) {
56: 2485 addiw s1,s1,1
58: fe9992e3 bne s3,s1,3c <createfile+0x3c>
printf("write %s failed\n", file);
exit(-1);
}
}
close(fd);
5c: 854a mv a0,s2
5e: 00000097 auipc ra,0x0
62: 714080e7 jalr 1812(ra) # 772 <close>
}
66: 42813083 ld ra,1064(sp)
6a: 42013403 ld s0,1056(sp)
6e: 41813483 ld s1,1048(sp)
72: 41013903 ld s2,1040(sp)
76: 40813983 ld s3,1032(sp)
7a: 40013a03 ld s4,1024(sp)
7e: 43010113 addi sp,sp,1072
82: 8082 ret
printf("test0 create %s failed\n", file);
84: 85d2 mv a1,s4
86: 00001517 auipc a0,0x1
8a: bf250513 addi a0,a0,-1038 # c78 <malloc+0xe8>
8e: 00001097 auipc ra,0x1
92: a44080e7 jalr -1468(ra) # ad2 <printf>
exit(-1);
96: 557d li a0,-1
98: 00000097 auipc ra,0x0
9c: 6b2080e7 jalr 1714(ra) # 74a <exit>
printf("write %s failed\n", file);
a0: 85d2 mv a1,s4
a2: 00001517 auipc a0,0x1
a6: bee50513 addi a0,a0,-1042 # c90 <malloc+0x100>
aa: 00001097 auipc ra,0x1
ae: a28080e7 jalr -1496(ra) # ad2 <printf>
exit(-1);
b2: 557d li a0,-1
b4: 00000097 auipc ra,0x0
b8: 696080e7 jalr 1686(ra) # 74a <exit>
00000000000000bc <readfile>:
void
readfile(char *file, int nbytes, int inc)
{
bc: bc010113 addi sp,sp,-1088
c0: 42113c23 sd ra,1080(sp)
c4: 42813823 sd s0,1072(sp)
c8: 42913423 sd s1,1064(sp)
cc: 43213023 sd s2,1056(sp)
d0: 41313c23 sd s3,1048(sp)
d4: 41413823 sd s4,1040(sp)
d8: 41513423 sd s5,1032(sp)
dc: 44010413 addi s0,sp,1088
char buf[BSIZE];
int fd;
int i;
if(inc > BSIZE) {
e0: 40000793 li a5,1024
e4: 06c7c463 blt a5,a2,14c <readfile+0x90>
e8: 8aaa mv s5,a0
ea: 8a2e mv s4,a1
ec: 84b2 mv s1,a2
printf("test0: inc too large\n");
exit(-1);
}
if ((fd = open(file, O_RDONLY)) < 0) {
ee: 4581 li a1,0
f0: 00000097 auipc ra,0x0
f4: 69a080e7 jalr 1690(ra) # 78a <open>
f8: 89aa mv s3,a0
fa: 06054663 bltz a0,166 <readfile+0xaa>
printf("test0 open %s failed\n", file);
exit(-1);
}
for (i = 0; i < nbytes; i += inc) {
fe: 4901 li s2,0
100: 03405063 blez s4,120 <readfile+0x64>
if(read(fd, buf, inc) != inc) {
104: 8626 mv a2,s1
106: bc040593 addi a1,s0,-1088
10a: 854e mv a0,s3
10c: 00000097 auipc ra,0x0
110: 656080e7 jalr 1622(ra) # 762 <read>
114: 06951763 bne a0,s1,182 <readfile+0xc6>
for (i = 0; i < nbytes; i += inc) {
118: 0124893b addw s2,s1,s2
11c: ff4944e3 blt s2,s4,104 <readfile+0x48>
printf("read %s failed for block %d (%d)\n", file, i, nbytes);
exit(-1);
}
}
close(fd);
120: 854e mv a0,s3
122: 00000097 auipc ra,0x0
126: 650080e7 jalr 1616(ra) # 772 <close>
}
12a: 43813083 ld ra,1080(sp)
12e: 43013403 ld s0,1072(sp)
132: 42813483 ld s1,1064(sp)
136: 42013903 ld s2,1056(sp)
13a: 41813983 ld s3,1048(sp)
13e: 41013a03 ld s4,1040(sp)
142: 40813a83 ld s5,1032(sp)
146: 44010113 addi sp,sp,1088
14a: 8082 ret
printf("test0: inc too large\n");
14c: 00001517 auipc a0,0x1
150: b5c50513 addi a0,a0,-1188 # ca8 <malloc+0x118>
154: 00001097 auipc ra,0x1
158: 97e080e7 jalr -1666(ra) # ad2 <printf>
exit(-1);
15c: 557d li a0,-1
15e: 00000097 auipc ra,0x0
162: 5ec080e7 jalr 1516(ra) # 74a <exit>
printf("test0 open %s failed\n", file);
166: 85d6 mv a1,s5
168: 00001517 auipc a0,0x1
16c: b5850513 addi a0,a0,-1192 # cc0 <malloc+0x130>
170: 00001097 auipc ra,0x1
174: 962080e7 jalr -1694(ra) # ad2 <printf>
exit(-1);
178: 557d li a0,-1
17a: 00000097 auipc ra,0x0
17e: 5d0080e7 jalr 1488(ra) # 74a <exit>
printf("read %s failed for block %d (%d)\n", file, i, nbytes);
182: 86d2 mv a3,s4
184: 864a mv a2,s2
186: 85d6 mv a1,s5
188: 00001517 auipc a0,0x1
18c: b5050513 addi a0,a0,-1200 # cd8 <malloc+0x148>
190: 00001097 auipc ra,0x1
194: 942080e7 jalr -1726(ra) # ad2 <printf>
exit(-1);
198: 557d li a0,-1
19a: 00000097 auipc ra,0x0
19e: 5b0080e7 jalr 1456(ra) # 74a <exit>
00000000000001a2 <test0>:
void
test0()
{
1a2: 7139 addi sp,sp,-64
1a4: fc06 sd ra,56(sp)
1a6: f822 sd s0,48(sp)
1a8: f426 sd s1,40(sp)
1aa: f04a sd s2,32(sp)
1ac: ec4e sd s3,24(sp)
1ae: 0080 addi s0,sp,64
char file[2];
char dir[2];
enum { N = 10, NCHILD = 3 };
int n;
dir[0] = '0';
1b0: 03000793 li a5,48
1b4: fcf40023 sb a5,-64(s0)
dir[1] = '\0';
1b8: fc0400a3 sb zero,-63(s0)
file[0] = 'F';
1bc: 04600793 li a5,70
1c0: fcf40423 sb a5,-56(s0)
file[1] = '\0';
1c4: fc0404a3 sb zero,-55(s0)
printf("start test0\n");
1c8: 00001517 auipc a0,0x1
1cc: b3850513 addi a0,a0,-1224 # d00 <malloc+0x170>
1d0: 00001097 auipc ra,0x1
1d4: 902080e7 jalr -1790(ra) # ad2 <printf>
1d8: 03000493 li s1,48
printf("chdir failed\n");
exit(1);
}
unlink(file);
createfile(file, N);
if (chdir("..") < 0) {
1dc: 00001997 auipc s3,0x1
1e0: b4498993 addi s3,s3,-1212 # d20 <malloc+0x190>
for(int i = 0; i < NCHILD; i++){
1e4: 03300913 li s2,51
dir[0] = '0' + i;
1e8: fc940023 sb s1,-64(s0)
mkdir(dir);
1ec: fc040513 addi a0,s0,-64
1f0: 00000097 auipc ra,0x0
1f4: 5c2080e7 jalr 1474(ra) # 7b2 <mkdir>
if (chdir(dir) < 0) {
1f8: fc040513 addi a0,s0,-64
1fc: 00000097 auipc ra,0x0
200: 5be080e7 jalr 1470(ra) # 7ba <chdir>
204: 0c054163 bltz a0,2c6 <test0+0x124>
unlink(file);
208: fc840513 addi a0,s0,-56
20c: 00000097 auipc ra,0x0
210: 58e080e7 jalr 1422(ra) # 79a <unlink>
createfile(file, N);
214: 45a9 li a1,10
216: fc840513 addi a0,s0,-56
21a: 00000097 auipc ra,0x0
21e: de6080e7 jalr -538(ra) # 0 <createfile>
if (chdir("..") < 0) {
222: 854e mv a0,s3
224: 00000097 auipc ra,0x0
228: 596080e7 jalr 1430(ra) # 7ba <chdir>
22c: 0a054a63 bltz a0,2e0 <test0+0x13e>
for(int i = 0; i < NCHILD; i++){
230: 2485 addiw s1,s1,1
232: 0ff4f493 andi s1,s1,255
236: fb2499e3 bne s1,s2,1e8 <test0+0x46>
printf("chdir failed\n");
exit(1);
}
}
ntas(0);
23a: 4501 li a0,0
23c: 00000097 auipc ra,0x0
240: 5b6080e7 jalr 1462(ra) # 7f2 <ntas>
244: 03000493 li s1,48
for(int i = 0; i < NCHILD; i++){
248: 03300913 li s2,51
dir[0] = '0' + i;
24c: fc940023 sb s1,-64(s0)
int pid = fork();
250: 00000097 auipc ra,0x0
254: 4f2080e7 jalr 1266(ra) # 742 <fork>
if(pid < 0){
258: 0a054163 bltz a0,2fa <test0+0x158>
printf("fork failed");
exit(-1);
}
if(pid == 0){
25c: cd45 beqz a0,314 <test0+0x172>
for(int i = 0; i < NCHILD; i++){
25e: 2485 addiw s1,s1,1
260: 0ff4f493 andi s1,s1,255
264: ff2494e3 bne s1,s2,24c <test0+0xaa>
exit(0);
}
}
for(int i = 0; i < NCHILD; i++){
wait(0);
268: 4501 li a0,0
26a: 00000097 auipc ra,0x0
26e: 4e8080e7 jalr 1256(ra) # 752 <wait>
272: 4501 li a0,0
274: 00000097 auipc ra,0x0
278: 4de080e7 jalr 1246(ra) # 752 <wait>
27c: 4501 li a0,0
27e: 00000097 auipc ra,0x0
282: 4d4080e7 jalr 1236(ra) # 752 <wait>
}
printf("test0 results:\n");
286: 00001517 auipc a0,0x1
28a: ab250513 addi a0,a0,-1358 # d38 <malloc+0x1a8>
28e: 00001097 auipc ra,0x1
292: 844080e7 jalr -1980(ra) # ad2 <printf>
n = ntas(1);
296: 4505 li a0,1
298: 00000097 auipc ra,0x0
29c: 55a080e7 jalr 1370(ra) # 7f2 <ntas>
if (n < 500)
2a0: 1f300793 li a5,499
2a4: 0aa7cc63 blt a5,a0,35c <test0+0x1ba>
printf("test0: OK\n");
2a8: 00001517 auipc a0,0x1
2ac: aa050513 addi a0,a0,-1376 # d48 <malloc+0x1b8>
2b0: 00001097 auipc ra,0x1
2b4: 822080e7 jalr -2014(ra) # ad2 <printf>
else
printf("test0: FAIL\n");
}
2b8: 70e2 ld ra,56(sp)
2ba: 7442 ld s0,48(sp)
2bc: 74a2 ld s1,40(sp)
2be: 7902 ld s2,32(sp)
2c0: 69e2 ld s3,24(sp)
2c2: 6121 addi sp,sp,64
2c4: 8082 ret
printf("chdir failed\n");
2c6: 00001517 auipc a0,0x1
2ca: a4a50513 addi a0,a0,-1462 # d10 <malloc+0x180>
2ce: 00001097 auipc ra,0x1
2d2: 804080e7 jalr -2044(ra) # ad2 <printf>
exit(1);
2d6: 4505 li a0,1
2d8: 00000097 auipc ra,0x0
2dc: 472080e7 jalr 1138(ra) # 74a <exit>
printf("chdir failed\n");
2e0: 00001517 auipc a0,0x1
2e4: a3050513 addi a0,a0,-1488 # d10 <malloc+0x180>
2e8: 00000097 auipc ra,0x0
2ec: 7ea080e7 jalr 2026(ra) # ad2 <printf>
exit(1);
2f0: 4505 li a0,1
2f2: 00000097 auipc ra,0x0
2f6: 458080e7 jalr 1112(ra) # 74a <exit>
printf("fork failed");
2fa: 00001517 auipc a0,0x1
2fe: a2e50513 addi a0,a0,-1490 # d28 <malloc+0x198>
302: 00000097 auipc ra,0x0
306: 7d0080e7 jalr 2000(ra) # ad2 <printf>
exit(-1);
30a: 557d li a0,-1
30c: 00000097 auipc ra,0x0
310: 43e080e7 jalr 1086(ra) # 74a <exit>
if (chdir(dir) < 0) {
314: fc040513 addi a0,s0,-64
318: 00000097 auipc ra,0x0
31c: 4a2080e7 jalr 1186(ra) # 7ba <chdir>
320: 02054163 bltz a0,342 <test0+0x1a0>
readfile(file, N*BSIZE, 1);
324: 4605 li a2,1
326: 658d lui a1,0x3
328: 80058593 addi a1,a1,-2048 # 2800 <__global_pointer$+0x125f>
32c: fc840513 addi a0,s0,-56
330: 00000097 auipc ra,0x0
334: d8c080e7 jalr -628(ra) # bc <readfile>
exit(0);
338: 4501 li a0,0
33a: 00000097 auipc ra,0x0
33e: 410080e7 jalr 1040(ra) # 74a <exit>
printf("chdir failed\n");
342: 00001517 auipc a0,0x1
346: 9ce50513 addi a0,a0,-1586 # d10 <malloc+0x180>
34a: 00000097 auipc ra,0x0
34e: 788080e7 jalr 1928(ra) # ad2 <printf>
exit(1);
352: 4505 li a0,1
354: 00000097 auipc ra,0x0
358: 3f6080e7 jalr 1014(ra) # 74a <exit>
printf("test0: FAIL\n");
35c: 00001517 auipc a0,0x1
360: 9fc50513 addi a0,a0,-1540 # d58 <malloc+0x1c8>
364: 00000097 auipc ra,0x0
368: 76e080e7 jalr 1902(ra) # ad2 <printf>
}
36c: b7b1 j 2b8 <test0+0x116>
000000000000036e <test1>:
void test1()
{
36e: 7179 addi sp,sp,-48
370: f406 sd ra,40(sp)
372: f022 sd s0,32(sp)
374: ec26 sd s1,24(sp)
376: e84a sd s2,16(sp)
378: 1800 addi s0,sp,48
char file[3];
enum { N = 100, BIG=100, NCHILD=2 };
printf("start test1\n");
37a: 00001517 auipc a0,0x1
37e: 9ee50513 addi a0,a0,-1554 # d68 <malloc+0x1d8>
382: 00000097 auipc ra,0x0
386: 750080e7 jalr 1872(ra) # ad2 <printf>
file[0] = 'B';
38a: 04200793 li a5,66
38e: fcf40c23 sb a5,-40(s0)
file[2] = '\0';
392: fc040d23 sb zero,-38(s0)
396: 4485 li s1,1
for(int i = 0; i < NCHILD; i++){
file[1] = '0' + i;
unlink(file);
if (i == 0) {
398: 4905 li s2,1
39a: a811 j 3ae <test1+0x40>
createfile(file, BIG);
39c: 06400593 li a1,100
3a0: fd840513 addi a0,s0,-40
3a4: 00000097 auipc ra,0x0
3a8: c5c080e7 jalr -932(ra) # 0 <createfile>
for(int i = 0; i < NCHILD; i++){
3ac: 2485 addiw s1,s1,1
file[1] = '0' + i;
3ae: 02f4879b addiw a5,s1,47
3b2: fcf40ca3 sb a5,-39(s0)
unlink(file);
3b6: fd840513 addi a0,s0,-40
3ba: 00000097 auipc ra,0x0
3be: 3e0080e7 jalr 992(ra) # 79a <unlink>
if (i == 0) {
3c2: fd248de3 beq s1,s2,39c <test1+0x2e>
} else {
createfile(file, 1);
3c6: 85ca mv a1,s2
3c8: fd840513 addi a0,s0,-40
3cc: 00000097 auipc ra,0x0
3d0: c34080e7 jalr -972(ra) # 0 <createfile>
for(int i = 0; i < NCHILD; i++){
3d4: 0004879b sext.w a5,s1
3d8: fcf95ae3 bge s2,a5,3ac <test1+0x3e>
}
}
for(int i = 0; i < NCHILD; i++){
file[1] = '0' + i;
3dc: 03000793 li a5,48
3e0: fcf40ca3 sb a5,-39(s0)
int pid = fork();
3e4: 00000097 auipc ra,0x0
3e8: 35e080e7 jalr 862(ra) # 742 <fork>
if(pid < 0){
3ec: 04054663 bltz a0,438 <test1+0xca>
printf("fork failed");
exit(-1);
}
if(pid == 0){
3f0: c12d beqz a0,452 <test1+0xe4>
file[1] = '0' + i;
3f2: 03100793 li a5,49
3f6: fcf40ca3 sb a5,-39(s0)
int pid = fork();
3fa: 00000097 auipc ra,0x0
3fe: 348080e7 jalr 840(ra) # 742 <fork>
if(pid < 0){
402: 02054b63 bltz a0,438 <test1+0xca>
if(pid == 0){
406: cd35 beqz a0,482 <test1+0x114>
exit(0);
}
}
for(int i = 0; i < NCHILD; i++){
wait(0);
408: 4501 li a0,0
40a: 00000097 auipc ra,0x0
40e: 348080e7 jalr 840(ra) # 752 <wait>
412: 4501 li a0,0
414: 00000097 auipc ra,0x0
418: 33e080e7 jalr 830(ra) # 752 <wait>
}
printf("test1 OK\n");
41c: 00001517 auipc a0,0x1
420: 95c50513 addi a0,a0,-1700 # d78 <malloc+0x1e8>
424: 00000097 auipc ra,0x0
428: 6ae080e7 jalr 1710(ra) # ad2 <printf>
}
42c: 70a2 ld ra,40(sp)
42e: 7402 ld s0,32(sp)
430: 64e2 ld s1,24(sp)
432: 6942 ld s2,16(sp)
434: 6145 addi sp,sp,48
436: 8082 ret
printf("fork failed");
438: 00001517 auipc a0,0x1
43c: 8f050513 addi a0,a0,-1808 # d28 <malloc+0x198>
440: 00000097 auipc ra,0x0
444: 692080e7 jalr 1682(ra) # ad2 <printf>
exit(-1);
448: 557d li a0,-1
44a: 00000097 auipc ra,0x0
44e: 300080e7 jalr 768(ra) # 74a <exit>
if(pid == 0){
452: 06400493 li s1,100
readfile(file, BIG*BSIZE, BSIZE);
456: 40000613 li a2,1024
45a: 65e5 lui a1,0x19
45c: fd840513 addi a0,s0,-40
460: 00000097 auipc ra,0x0
464: c5c080e7 jalr -932(ra) # bc <readfile>
for (i = 0; i < N; i++) {
468: 34fd addiw s1,s1,-1
46a: f4f5 bnez s1,456 <test1+0xe8>
unlink(file);
46c: fd840513 addi a0,s0,-40
470: 00000097 auipc ra,0x0
474: 32a080e7 jalr 810(ra) # 79a <unlink>
exit(0);
478: 4501 li a0,0
47a: 00000097 auipc ra,0x0
47e: 2d0080e7 jalr 720(ra) # 74a <exit>
482: 06400493 li s1,100
readfile(file, 1, BSIZE);
486: 40000613 li a2,1024
48a: 4585 li a1,1
48c: fd840513 addi a0,s0,-40
490: 00000097 auipc ra,0x0
494: c2c080e7 jalr -980(ra) # bc <readfile>
for (i = 0; i < N; i++) {
498: 34fd addiw s1,s1,-1
49a: f4f5 bnez s1,486 <test1+0x118>
unlink(file);
49c: fd840513 addi a0,s0,-40
4a0: 00000097 auipc ra,0x0
4a4: 2fa080e7 jalr 762(ra) # 79a <unlink>
exit(0);
4a8: 4501 li a0,0
4aa: 00000097 auipc ra,0x0
4ae: 2a0080e7 jalr 672(ra) # 74a <exit>
00000000000004b2 <main>:
{
4b2: 1141 addi sp,sp,-16
4b4: e406 sd ra,8(sp)
4b6: e022 sd s0,0(sp)
4b8: 0800 addi s0,sp,16
test0();
4ba: 00000097 auipc ra,0x0
4be: ce8080e7 jalr -792(ra) # 1a2 <test0>
test1();
4c2: 00000097 auipc ra,0x0
4c6: eac080e7 jalr -340(ra) # 36e <test1>
exit(0);
4ca: 4501 li a0,0
4cc: 00000097 auipc ra,0x0
4d0: 27e080e7 jalr 638(ra) # 74a <exit>
00000000000004d4 <strcpy>:
#include "kernel/fcntl.h"
#include "user/user.h"
char*
strcpy(char *s, const char *t)
{
4d4: 1141 addi sp,sp,-16
4d6: e422 sd s0,8(sp)
4d8: 0800 addi s0,sp,16
char *os;
os = s;
while((*s++ = *t++) != 0)
4da: 87aa mv a5,a0
4dc: 0585 addi a1,a1,1
4de: 0785 addi a5,a5,1
4e0: fff5c703 lbu a4,-1(a1) # 18fff <__global_pointer$+0x17a5e>
4e4: fee78fa3 sb a4,-1(a5)
4e8: fb75 bnez a4,4dc <strcpy+0x8>
;
return os;
}
4ea: 6422 ld s0,8(sp)
4ec: 0141 addi sp,sp,16
4ee: 8082 ret
00000000000004f0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
4f0: 1141 addi sp,sp,-16
4f2: e422 sd s0,8(sp)
4f4: 0800 addi s0,sp,16
while(*p && *p == *q)
4f6: 00054783 lbu a5,0(a0)
4fa: cb91 beqz a5,50e <strcmp+0x1e>
4fc: 0005c703 lbu a4,0(a1)
500: 00f71763 bne a4,a5,50e <strcmp+0x1e>
p++, q++;
504: 0505 addi a0,a0,1
506: 0585 addi a1,a1,1
while(*p && *p == *q)
508: 00054783 lbu a5,0(a0)
50c: fbe5 bnez a5,4fc <strcmp+0xc>
return (uchar)*p - (uchar)*q;
50e: 0005c503 lbu a0,0(a1)
}
512: 40a7853b subw a0,a5,a0
516: 6422 ld s0,8(sp)
518: 0141 addi sp,sp,16
51a: 8082 ret
000000000000051c <strlen>:
uint
strlen(const char *s)
{
51c: 1141 addi sp,sp,-16
51e: e422 sd s0,8(sp)
520: 0800 addi s0,sp,16
int n;
for(n = 0; s[n]; n++)
522: 00054783 lbu a5,0(a0)
526: cf91 beqz a5,542 <strlen+0x26>
528: 0505 addi a0,a0,1
52a: 87aa mv a5,a0
52c: 4685 li a3,1
52e: 9e89 subw a3,a3,a0
530: 00f6853b addw a0,a3,a5
534: 0785 addi a5,a5,1
536: fff7c703 lbu a4,-1(a5)
53a: fb7d bnez a4,530 <strlen+0x14>
;
return n;
}
53c: 6422 ld s0,8(sp)
53e: 0141 addi sp,sp,16
540: 8082 ret
for(n = 0; s[n]; n++)
542: 4501 li a0,0
544: bfe5 j 53c <strlen+0x20>
0000000000000546 <memset>:
void*
memset(void *dst, int c, uint n)
{
546: 1141 addi sp,sp,-16
548: e422 sd s0,8(sp)
54a: 0800 addi s0,sp,16
char *cdst = (char *) dst;
int i;
for(i = 0; i < n; i++){
54c: ce09 beqz a2,566 <memset+0x20>
54e: 87aa mv a5,a0
550: fff6071b addiw a4,a2,-1
554: 1702 slli a4,a4,0x20
556: 9301 srli a4,a4,0x20
558: 0705 addi a4,a4,1
55a: 972a add a4,a4,a0
cdst[i] = c;
55c: 00b78023 sb a1,0(a5)
for(i = 0; i < n; i++){
560: 0785 addi a5,a5,1
562: fee79de3 bne a5,a4,55c <memset+0x16>
}
return dst;
}
566: 6422 ld s0,8(sp)
568: 0141 addi sp,sp,16
56a: 8082 ret
000000000000056c <strchr>:
char*
strchr(const char *s, char c)
{
56c: 1141 addi sp,sp,-16
56e: e422 sd s0,8(sp)
570: 0800 addi s0,sp,16
for(; *s; s++)
572: 00054783 lbu a5,0(a0)
576: cb99 beqz a5,58c <strchr+0x20>
if(*s == c)
578: 00f58763 beq a1,a5,586 <strchr+0x1a>
for(; *s; s++)
57c: 0505 addi a0,a0,1
57e: 00054783 lbu a5,0(a0)
582: fbfd bnez a5,578 <strchr+0xc>
return (char*)s;
return 0;
584: 4501 li a0,0
}
586: 6422 ld s0,8(sp)
588: 0141 addi sp,sp,16
58a: 8082 ret
return 0;
58c: 4501 li a0,0
58e: bfe5 j 586 <strchr+0x1a>
0000000000000590 <gets>:
char*
gets(char *buf, int max)
{
590: 711d addi sp,sp,-96
592: ec86 sd ra,88(sp)
594: e8a2 sd s0,80(sp)
596: e4a6 sd s1,72(sp)
598: e0ca sd s2,64(sp)
59a: fc4e sd s3,56(sp)
59c: f852 sd s4,48(sp)
59e: f456 sd s5,40(sp)
5a0: f05a sd s6,32(sp)
5a2: ec5e sd s7,24(sp)
5a4: 1080 addi s0,sp,96
5a6: 8baa mv s7,a0
5a8: 8a2e mv s4,a1
int i, cc;
char c;
for(i=0; i+1 < max; ){
5aa: 892a mv s2,a0
5ac: 4481 li s1,0
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
5ae: 4aa9 li s5,10
5b0: 4b35 li s6,13
for(i=0; i+1 < max; ){
5b2: 89a6 mv s3,s1
5b4: 2485 addiw s1,s1,1
5b6: 0344d863 bge s1,s4,5e6 <gets+0x56>
cc = read(0, &c, 1);
5ba: 4605 li a2,1
5bc: faf40593 addi a1,s0,-81
5c0: 4501 li a0,0
5c2: 00000097 auipc ra,0x0
5c6: 1a0080e7 jalr 416(ra) # 762 <read>
if(cc < 1)
5ca: 00a05e63 blez a0,5e6 <gets+0x56>
buf[i++] = c;
5ce: faf44783 lbu a5,-81(s0)
5d2: 00f90023 sb a5,0(s2)
if(c == '\n' || c == '\r')
5d6: 01578763 beq a5,s5,5e4 <gets+0x54>
5da: 0905 addi s2,s2,1
5dc: fd679be3 bne a5,s6,5b2 <gets+0x22>
for(i=0; i+1 < max; ){
5e0: 89a6 mv s3,s1
5e2: a011 j 5e6 <gets+0x56>
5e4: 89a6 mv s3,s1
break;
}
buf[i] = '\0';
5e6: 99de add s3,s3,s7
5e8: 00098023 sb zero,0(s3)
return buf;
}
5ec: 855e mv a0,s7
5ee: 60e6 ld ra,88(sp)
5f0: 6446 ld s0,80(sp)
5f2: 64a6 ld s1,72(sp)
5f4: 6906 ld s2,64(sp)
5f6: 79e2 ld s3,56(sp)
5f8: 7a42 ld s4,48(sp)
5fa: 7aa2 ld s5,40(sp)
5fc: 7b02 ld s6,32(sp)
5fe: 6be2 ld s7,24(sp)
600: 6125 addi sp,sp,96
602: 8082 ret
0000000000000604 <stat>:
int
stat(const char *n, struct stat *st)
{
604: 1101 addi sp,sp,-32
606: ec06 sd ra,24(sp)
608: e822 sd s0,16(sp)
60a: e426 sd s1,8(sp)
60c: e04a sd s2,0(sp)
60e: 1000 addi s0,sp,32
610: 892e mv s2,a1
int fd;
int r;
fd = open(n, O_RDONLY);
612: 4581 li a1,0
614: 00000097 auipc ra,0x0
618: 176080e7 jalr 374(ra) # 78a <open>
if(fd < 0)
61c: 02054563 bltz a0,646 <stat+0x42>
620: 84aa mv s1,a0
return -1;
r = fstat(fd, st);
622: 85ca mv a1,s2
624: 00000097 auipc ra,0x0
628: 17e080e7 jalr 382(ra) # 7a2 <fstat>
62c: 892a mv s2,a0
close(fd);
62e: 8526 mv a0,s1
630: 00000097 auipc ra,0x0
634: 142080e7 jalr 322(ra) # 772 <close>
return r;
}
638: 854a mv a0,s2
63a: 60e2 ld ra,24(sp)
63c: 6442 ld s0,16(sp)
63e: 64a2 ld s1,8(sp)
640: 6902 ld s2,0(sp)
642: 6105 addi sp,sp,32
644: 8082 ret
return -1;
646: 597d li s2,-1
648: bfc5 j 638 <stat+0x34>
000000000000064a <atoi>:
int
atoi(const char *s)
{
64a: 1141 addi sp,sp,-16
64c: e422 sd s0,8(sp)
64e: 0800 addi s0,sp,16
int n;
n = 0;
while('0' <= *s && *s <= '9')
650: 00054603 lbu a2,0(a0)
654: fd06079b addiw a5,a2,-48
658: 0ff7f793 andi a5,a5,255
65c: 4725 li a4,9
65e: 02f76963 bltu a4,a5,690 <atoi+0x46>
662: 86aa mv a3,a0
n = 0;
664: 4501 li a0,0
while('0' <= *s && *s <= '9')
666: 45a5 li a1,9
n = n*10 + *s++ - '0';
668: 0685 addi a3,a3,1
66a: 0025179b slliw a5,a0,0x2
66e: 9fa9 addw a5,a5,a0
670: 0017979b slliw a5,a5,0x1
674: 9fb1 addw a5,a5,a2
676: fd07851b addiw a0,a5,-48
while('0' <= *s && *s <= '9')
67a: 0006c603 lbu a2,0(a3)
67e: fd06071b addiw a4,a2,-48
682: 0ff77713 andi a4,a4,255
686: fee5f1e3 bgeu a1,a4,668 <atoi+0x1e>
return n;
}
68a: 6422 ld s0,8(sp)
68c: 0141 addi sp,sp,16
68e: 8082 ret
n = 0;
690: 4501 li a0,0
692: bfe5 j 68a <atoi+0x40>
0000000000000694 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
694: 1141 addi sp,sp,-16
696: e422 sd s0,8(sp)
698: 0800 addi s0,sp,16
char *dst;
const char *src;
dst = vdst;
src = vsrc;
if (src > dst) {
69a: 02b57663 bgeu a0,a1,6c6 <memmove+0x32>
while(n-- > 0)
69e: 02c05163 blez a2,6c0 <memmove+0x2c>
6a2: fff6079b addiw a5,a2,-1
6a6: 1782 slli a5,a5,0x20
6a8: 9381 srli a5,a5,0x20
6aa: 0785 addi a5,a5,1
6ac: 97aa add a5,a5,a0
dst = vdst;
6ae: 872a mv a4,a0
*dst++ = *src++;
6b0: 0585 addi a1,a1,1
6b2: 0705 addi a4,a4,1
6b4: fff5c683 lbu a3,-1(a1)
6b8: fed70fa3 sb a3,-1(a4)
while(n-- > 0)
6bc: fee79ae3 bne a5,a4,6b0 <memmove+0x1c>
src += n;
while(n-- > 0)
*--dst = *--src;
}
return vdst;
}
6c0: 6422 ld s0,8(sp)
6c2: 0141 addi sp,sp,16
6c4: 8082 ret
dst += n;
6c6: 00c50733 add a4,a0,a2
src += n;
6ca: 95b2 add a1,a1,a2
while(n-- > 0)
6cc: fec05ae3 blez a2,6c0 <memmove+0x2c>
6d0: fff6079b addiw a5,a2,-1
6d4: 1782 slli a5,a5,0x20
6d6: 9381 srli a5,a5,0x20
6d8: fff7c793 not a5,a5
6dc: 97ba add a5,a5,a4
*--dst = *--src;
6de: 15fd addi a1,a1,-1
6e0: 177d addi a4,a4,-1
6e2: 0005c683 lbu a3,0(a1)
6e6: 00d70023 sb a3,0(a4)
while(n-- > 0)
6ea: fee79ae3 bne a5,a4,6de <memmove+0x4a>
6ee: bfc9 j 6c0 <memmove+0x2c>
00000000000006f0 <memcmp>:
int
memcmp(const void *s1, const void *s2, uint n)
{
6f0: 1141 addi sp,sp,-16
6f2: e422 sd s0,8(sp)
6f4: 0800 addi s0,sp,16
const char *p1 = s1, *p2 = s2;
while (n-- > 0) {
6f6: ca05 beqz a2,726 <memcmp+0x36>
6f8: fff6069b addiw a3,a2,-1
6fc: 1682 slli a3,a3,0x20
6fe: 9281 srli a3,a3,0x20
700: 0685 addi a3,a3,1
702: 96aa add a3,a3,a0
if (*p1 != *p2) {
704: 00054783 lbu a5,0(a0)
708: 0005c703 lbu a4,0(a1)
70c: 00e79863 bne a5,a4,71c <memcmp+0x2c>
return *p1 - *p2;
}
p1++;
710: 0505 addi a0,a0,1
p2++;
712: 0585 addi a1,a1,1
while (n-- > 0) {
714: fed518e3 bne a0,a3,704 <memcmp+0x14>
}
return 0;
718: 4501 li a0,0
71a: a019 j 720 <memcmp+0x30>
return *p1 - *p2;
71c: 40e7853b subw a0,a5,a4
}
720: 6422 ld s0,8(sp)
722: 0141 addi sp,sp,16
724: 8082 ret
return 0;
726: 4501 li a0,0
728: bfe5 j 720 <memcmp+0x30>
000000000000072a <memcpy>:
void *
memcpy(void *dst, const void *src, uint n)
{
72a: 1141 addi sp,sp,-16
72c: e406 sd ra,8(sp)
72e: e022 sd s0,0(sp)
730: 0800 addi s0,sp,16
return memmove(dst, src, n);
732: 00000097 auipc ra,0x0
736: f62080e7 jalr -158(ra) # 694 <memmove>
}
73a: 60a2 ld ra,8(sp)
73c: 6402 ld s0,0(sp)
73e: 0141 addi sp,sp,16
740: 8082 ret
0000000000000742 <fork>:
# generated by usys.pl - do not edit
#include "kernel/syscall.h"
.global fork
fork:
li a7, SYS_fork
742: 4885 li a7,1
ecall
744: 00000073 ecall
ret
748: 8082 ret
000000000000074a <exit>:
.global exit
exit:
li a7, SYS_exit
74a: 4889 li a7,2
ecall
74c: 00000073 ecall
ret
750: 8082 ret
0000000000000752 <wait>:
.global wait
wait:
li a7, SYS_wait
752: 488d li a7,3
ecall
754: 00000073 ecall
ret
758: 8082 ret
000000000000075a <pipe>:
.global pipe
pipe:
li a7, SYS_pipe
75a: 4891 li a7,4
ecall
75c: 00000073 ecall
ret
760: 8082 ret
0000000000000762 <read>:
.global read
read:
li a7, SYS_read
762: 4895 li a7,5
ecall
764: 00000073 ecall
ret
768: 8082 ret
000000000000076a <write>:
.global write
write:
li a7, SYS_write
76a: 48c1 li a7,16
ecall
76c: 00000073 ecall
ret
770: 8082 ret
0000000000000772 <close>:
.global close
close:
li a7, SYS_close
772: 48d5 li a7,21
ecall
774: 00000073 ecall
ret
778: 8082 ret
000000000000077a <kill>:
.global kill
kill:
li a7, SYS_kill
77a: 4899 li a7,6
ecall
77c: 00000073 ecall
ret
780: 8082 ret
0000000000000782 <exec>:
.global exec
exec:
li a7, SYS_exec
782: 489d li a7,7
ecall
784: 00000073 ecall
ret
788: 8082 ret
000000000000078a <open>:
.global open
open:
li a7, SYS_open
78a: 48bd li a7,15
ecall
78c: 00000073 ecall
ret
790: 8082 ret
0000000000000792 <mknod>:
.global mknod
mknod:
li a7, SYS_mknod
792: 48c5 li a7,17
ecall
794: 00000073 ecall
ret
798: 8082 ret
000000000000079a <unlink>:
.global unlink
unlink:
li a7, SYS_unlink
79a: 48c9 li a7,18
ecall
79c: 00000073 ecall
ret
7a0: 8082 ret
00000000000007a2 <fstat>:
.global fstat
fstat:
li a7, SYS_fstat
7a2: 48a1 li a7,8
ecall
7a4: 00000073 ecall
ret
7a8: 8082 ret
00000000000007aa <link>:
.global link
link:
li a7, SYS_link
7aa: 48cd li a7,19
ecall
7ac: 00000073 ecall
ret
7b0: 8082 ret
00000000000007b2 <mkdir>:
.global mkdir
mkdir:
li a7, SYS_mkdir
7b2: 48d1 li a7,20
ecall
7b4: 00000073 ecall
ret
7b8: 8082 ret
00000000000007ba <chdir>:
.global chdir
chdir:
li a7, SYS_chdir
7ba: 48a5 li a7,9
ecall
7bc: 00000073 ecall
ret
7c0: 8082 ret
00000000000007c2 <dup>:
.global dup
dup:
li a7, SYS_dup
7c2: 48a9 li a7,10
ecall
7c4: 00000073 ecall
ret
7c8: 8082 ret
00000000000007ca <getpid>:
.global getpid
getpid:
li a7, SYS_getpid
7ca: 48ad li a7,11
ecall
7cc: 00000073 ecall
ret
7d0: 8082 ret
00000000000007d2 <sbrk>:
.global sbrk
sbrk:
li a7, SYS_sbrk
7d2: 48b1 li a7,12
ecall
7d4: 00000073 ecall
ret
7d8: 8082 ret
00000000000007da <sleep>:
.global sleep
sleep:
li a7, SYS_sleep
7da: 48b5 li a7,13
ecall
7dc: 00000073 ecall
ret
7e0: 8082 ret
00000000000007e2 <uptime>:
.global uptime
uptime:
li a7, SYS_uptime
7e2: 48b9 li a7,14
ecall
7e4: 00000073 ecall
ret
7e8: 8082 ret
00000000000007ea <connect>:
.global connect
connect:
li a7, SYS_connect
7ea: 48d9 li a7,22
ecall
7ec: 00000073 ecall
ret
7f0: 8082 ret
00000000000007f2 <ntas>:
.global ntas
ntas:
li a7, SYS_ntas
7f2: 48dd li a7,23
ecall
7f4: 00000073 ecall
ret
7f8: 8082 ret
00000000000007fa <putc>:
static char digits[] = "0123456789ABCDEF";
static void
putc(int fd, char c)
{
7fa: 1101 addi sp,sp,-32
7fc: ec06 sd ra,24(sp)
7fe: e822 sd s0,16(sp)
800: 1000 addi s0,sp,32
802: feb407a3 sb a1,-17(s0)
write(fd, &c, 1);
806: 4605 li a2,1
808: fef40593 addi a1,s0,-17
80c: 00000097 auipc ra,0x0
810: f5e080e7 jalr -162(ra) # 76a <write>
}
814: 60e2 ld ra,24(sp)
816: 6442 ld s0,16(sp)
818: 6105 addi sp,sp,32
81a: 8082 ret
000000000000081c <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
81c: 7139 addi sp,sp,-64
81e: fc06 sd ra,56(sp)
820: f822 sd s0,48(sp)
822: f426 sd s1,40(sp)
824: f04a sd s2,32(sp)
826: ec4e sd s3,24(sp)
828: 0080 addi s0,sp,64
82a: 84aa mv s1,a0
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
82c: c299 beqz a3,832 <printint+0x16>
82e: 0805c863 bltz a1,8be <printint+0xa2>
neg = 1;
x = -xx;
} else {
x = xx;
832: 2581 sext.w a1,a1
neg = 0;
834: 4881 li a7,0
836: fc040693 addi a3,s0,-64
}
i = 0;
83a: 4701 li a4,0
do{
buf[i++] = digits[x % base];
83c: 2601 sext.w a2,a2
83e: 00000517 auipc a0,0x0
842: 55250513 addi a0,a0,1362 # d90 <digits>
846: 883a mv a6,a4
848: 2705 addiw a4,a4,1
84a: 02c5f7bb remuw a5,a1,a2
84e: 1782 slli a5,a5,0x20
850: 9381 srli a5,a5,0x20
852: 97aa add a5,a5,a0
854: 0007c783 lbu a5,0(a5)
858: 00f68023 sb a5,0(a3)
}while((x /= base) != 0);
85c: 0005879b sext.w a5,a1
860: 02c5d5bb divuw a1,a1,a2
864: 0685 addi a3,a3,1
866: fec7f0e3 bgeu a5,a2,846 <printint+0x2a>
if(neg)
86a: 00088b63 beqz a7,880 <printint+0x64>
buf[i++] = '-';
86e: fd040793 addi a5,s0,-48
872: 973e add a4,a4,a5
874: 02d00793 li a5,45
878: fef70823 sb a5,-16(a4)
87c: 0028071b addiw a4,a6,2
while(--i >= 0)
880: 02e05863 blez a4,8b0 <printint+0x94>
884: fc040793 addi a5,s0,-64
888: 00e78933 add s2,a5,a4
88c: fff78993 addi s3,a5,-1
890: 99ba add s3,s3,a4
892: 377d addiw a4,a4,-1
894: 1702 slli a4,a4,0x20
896: 9301 srli a4,a4,0x20
898: 40e989b3 sub s3,s3,a4
putc(fd, buf[i]);
89c: fff94583 lbu a1,-1(s2)
8a0: 8526 mv a0,s1
8a2: 00000097 auipc ra,0x0
8a6: f58080e7 jalr -168(ra) # 7fa <putc>
while(--i >= 0)
8aa: 197d addi s2,s2,-1
8ac: ff3918e3 bne s2,s3,89c <printint+0x80>
}
8b0: 70e2 ld ra,56(sp)
8b2: 7442 ld s0,48(sp)
8b4: 74a2 ld s1,40(sp)
8b6: 7902 ld s2,32(sp)
8b8: 69e2 ld s3,24(sp)
8ba: 6121 addi sp,sp,64
8bc: 8082 ret
x = -xx;
8be: 40b005bb negw a1,a1
neg = 1;
8c2: 4885 li a7,1
x = -xx;
8c4: bf8d j 836 <printint+0x1a>
00000000000008c6 <vprintf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
vprintf(int fd, const char *fmt, va_list ap)
{
8c6: 7119 addi sp,sp,-128
8c8: fc86 sd ra,120(sp)
8ca: f8a2 sd s0,112(sp)
8cc: f4a6 sd s1,104(sp)
8ce: f0ca sd s2,96(sp)
8d0: ecce sd s3,88(sp)
8d2: e8d2 sd s4,80(sp)
8d4: e4d6 sd s5,72(sp)
8d6: e0da sd s6,64(sp)
8d8: fc5e sd s7,56(sp)
8da: f862 sd s8,48(sp)
8dc: f466 sd s9,40(sp)
8de: f06a sd s10,32(sp)
8e0: ec6e sd s11,24(sp)
8e2: 0100 addi s0,sp,128
char *s;
int c, i, state;
state = 0;
for(i = 0; fmt[i]; i++){
8e4: 0005c903 lbu s2,0(a1)
8e8: 18090f63 beqz s2,a86 <vprintf+0x1c0>
8ec: 8aaa mv s5,a0
8ee: 8b32 mv s6,a2
8f0: 00158493 addi s1,a1,1
state = 0;
8f4: 4981 li s3,0
if(c == '%'){
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
8f6: 02500a13 li s4,37
if(c == 'd'){
8fa: 06400c13 li s8,100
printint(fd, va_arg(ap, int), 10, 1);
} else if(c == 'l') {
8fe: 06c00c93 li s9,108
printint(fd, va_arg(ap, uint64), 10, 0);
} else if(c == 'x') {
902: 07800d13 li s10,120
printint(fd, va_arg(ap, int), 16, 0);
} else if(c == 'p') {
906: 07000d93 li s11,112
putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
90a: 00000b97 auipc s7,0x0
90e: 486b8b93 addi s7,s7,1158 # d90 <digits>
912: a839 j 930 <vprintf+0x6a>
putc(fd, c);
914: 85ca mv a1,s2
916: 8556 mv a0,s5
918: 00000097 auipc ra,0x0
91c: ee2080e7 jalr -286(ra) # 7fa <putc>
920: a019 j 926 <vprintf+0x60>
} else if(state == '%'){
922: 01498f63 beq s3,s4,940 <vprintf+0x7a>
for(i = 0; fmt[i]; i++){
926: 0485 addi s1,s1,1
928: fff4c903 lbu s2,-1(s1)
92c: 14090d63 beqz s2,a86 <vprintf+0x1c0>
c = fmt[i] & 0xff;
930: 0009079b sext.w a5,s2
if(state == 0){
934: fe0997e3 bnez s3,922 <vprintf+0x5c>
if(c == '%'){
938: fd479ee3 bne a5,s4,914 <vprintf+0x4e>
state = '%';
93c: 89be mv s3,a5
93e: b7e5 j 926 <vprintf+0x60>
if(c == 'd'){
940: 05878063 beq a5,s8,980 <vprintf+0xba>
} else if(c == 'l') {
944: 05978c63 beq a5,s9,99c <vprintf+0xd6>
} else if(c == 'x') {
948: 07a78863 beq a5,s10,9b8 <vprintf+0xf2>
} else if(c == 'p') {
94c: 09b78463 beq a5,s11,9d4 <vprintf+0x10e>
printptr(fd, va_arg(ap, uint64));
} else if(c == 's'){
950: 07300713 li a4,115
954: 0ce78663 beq a5,a4,a20 <vprintf+0x15a>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
958: 06300713 li a4,99
95c: 0ee78e63 beq a5,a4,a58 <vprintf+0x192>
putc(fd, va_arg(ap, uint));
} else if(c == '%'){
960: 11478863 beq a5,s4,a70 <vprintf+0x1aa>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
964: 85d2 mv a1,s4
966: 8556 mv a0,s5
968: 00000097 auipc ra,0x0
96c: e92080e7 jalr -366(ra) # 7fa <putc>
putc(fd, c);
970: 85ca mv a1,s2
972: 8556 mv a0,s5
974: 00000097 auipc ra,0x0
978: e86080e7 jalr -378(ra) # 7fa <putc>
}
state = 0;
97c: 4981 li s3,0
97e: b765 j 926 <vprintf+0x60>
printint(fd, va_arg(ap, int), 10, 1);
980: 008b0913 addi s2,s6,8
984: 4685 li a3,1
986: 4629 li a2,10
988: 000b2583 lw a1,0(s6)
98c: 8556 mv a0,s5
98e: 00000097 auipc ra,0x0
992: e8e080e7 jalr -370(ra) # 81c <printint>
996: 8b4a mv s6,s2
state = 0;
998: 4981 li s3,0
99a: b771 j 926 <vprintf+0x60>
printint(fd, va_arg(ap, uint64), 10, 0);
99c: 008b0913 addi s2,s6,8
9a0: 4681 li a3,0
9a2: 4629 li a2,10
9a4: 000b2583 lw a1,0(s6)
9a8: 8556 mv a0,s5
9aa: 00000097 auipc ra,0x0
9ae: e72080e7 jalr -398(ra) # 81c <printint>
9b2: 8b4a mv s6,s2
state = 0;
9b4: 4981 li s3,0
9b6: bf85 j 926 <vprintf+0x60>
printint(fd, va_arg(ap, int), 16, 0);
9b8: 008b0913 addi s2,s6,8
9bc: 4681 li a3,0
9be: 4641 li a2,16
9c0: 000b2583 lw a1,0(s6)
9c4: 8556 mv a0,s5
9c6: 00000097 auipc ra,0x0
9ca: e56080e7 jalr -426(ra) # 81c <printint>
9ce: 8b4a mv s6,s2
state = 0;
9d0: 4981 li s3,0
9d2: bf91 j 926 <vprintf+0x60>
printptr(fd, va_arg(ap, uint64));
9d4: 008b0793 addi a5,s6,8
9d8: f8f43423 sd a5,-120(s0)
9dc: 000b3983 ld s3,0(s6)
putc(fd, '0');
9e0: 03000593 li a1,48
9e4: 8556 mv a0,s5
9e6: 00000097 auipc ra,0x0
9ea: e14080e7 jalr -492(ra) # 7fa <putc>
putc(fd, 'x');
9ee: 85ea mv a1,s10
9f0: 8556 mv a0,s5
9f2: 00000097 auipc ra,0x0
9f6: e08080e7 jalr -504(ra) # 7fa <putc>
9fa: 4941 li s2,16
putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
9fc: 03c9d793 srli a5,s3,0x3c
a00: 97de add a5,a5,s7
a02: 0007c583 lbu a1,0(a5)
a06: 8556 mv a0,s5
a08: 00000097 auipc ra,0x0
a0c: df2080e7 jalr -526(ra) # 7fa <putc>
for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
a10: 0992 slli s3,s3,0x4
a12: 397d addiw s2,s2,-1
a14: fe0914e3 bnez s2,9fc <vprintf+0x136>
printptr(fd, va_arg(ap, uint64));
a18: f8843b03 ld s6,-120(s0)
state = 0;
a1c: 4981 li s3,0
a1e: b721 j 926 <vprintf+0x60>
s = va_arg(ap, char*);
a20: 008b0993 addi s3,s6,8
a24: 000b3903 ld s2,0(s6)
if(s == 0)
a28: 02090163 beqz s2,a4a <vprintf+0x184>
while(*s != 0){
a2c: 00094583 lbu a1,0(s2)
a30: c9a1 beqz a1,a80 <vprintf+0x1ba>
putc(fd, *s);
a32: 8556 mv a0,s5
a34: 00000097 auipc ra,0x0
a38: dc6080e7 jalr -570(ra) # 7fa <putc>
s++;
a3c: 0905 addi s2,s2,1
while(*s != 0){
a3e: 00094583 lbu a1,0(s2)
a42: f9e5 bnez a1,a32 <vprintf+0x16c>
s = va_arg(ap, char*);
a44: 8b4e mv s6,s3
state = 0;
a46: 4981 li s3,0
a48: bdf9 j 926 <vprintf+0x60>
s = "(null)";
a4a: 00000917 auipc s2,0x0
a4e: 33e90913 addi s2,s2,830 # d88 <malloc+0x1f8>
while(*s != 0){
a52: 02800593 li a1,40
a56: bff1 j a32 <vprintf+0x16c>
putc(fd, va_arg(ap, uint));
a58: 008b0913 addi s2,s6,8
a5c: 000b4583 lbu a1,0(s6)
a60: 8556 mv a0,s5
a62: 00000097 auipc ra,0x0
a66: d98080e7 jalr -616(ra) # 7fa <putc>
a6a: 8b4a mv s6,s2
state = 0;
a6c: 4981 li s3,0
a6e: bd65 j 926 <vprintf+0x60>
putc(fd, c);
a70: 85d2 mv a1,s4
a72: 8556 mv a0,s5
a74: 00000097 auipc ra,0x0
a78: d86080e7 jalr -634(ra) # 7fa <putc>
state = 0;
a7c: 4981 li s3,0
a7e: b565 j 926 <vprintf+0x60>
s = va_arg(ap, char*);
a80: 8b4e mv s6,s3
state = 0;
a82: 4981 li s3,0
a84: b54d j 926 <vprintf+0x60>
}
}
}
a86: 70e6 ld ra,120(sp)
a88: 7446 ld s0,112(sp)
a8a: 74a6 ld s1,104(sp)
a8c: 7906 ld s2,96(sp)
a8e: 69e6 ld s3,88(sp)
a90: 6a46 ld s4,80(sp)
a92: 6aa6 ld s5,72(sp)
a94: 6b06 ld s6,64(sp)
a96: 7be2 ld s7,56(sp)
a98: 7c42 ld s8,48(sp)
a9a: 7ca2 ld s9,40(sp)
a9c: 7d02 ld s10,32(sp)
a9e: 6de2 ld s11,24(sp)
aa0: 6109 addi sp,sp,128
aa2: 8082 ret
0000000000000aa4 <fprintf>:
void
fprintf(int fd, const char *fmt, ...)
{
aa4: 715d addi sp,sp,-80
aa6: ec06 sd ra,24(sp)
aa8: e822 sd s0,16(sp)
aaa: 1000 addi s0,sp,32
aac: e010 sd a2,0(s0)
aae: e414 sd a3,8(s0)
ab0: e818 sd a4,16(s0)
ab2: ec1c sd a5,24(s0)
ab4: 03043023 sd a6,32(s0)
ab8: 03143423 sd a7,40(s0)
va_list ap;
va_start(ap, fmt);
abc: fe843423 sd s0,-24(s0)
vprintf(fd, fmt, ap);
ac0: 8622 mv a2,s0
ac2: 00000097 auipc ra,0x0
ac6: e04080e7 jalr -508(ra) # 8c6 <vprintf>
}
aca: 60e2 ld ra,24(sp)
acc: 6442 ld s0,16(sp)
ace: 6161 addi sp,sp,80
ad0: 8082 ret
0000000000000ad2 <printf>:
void
printf(const char *fmt, ...)
{
ad2: 711d addi sp,sp,-96
ad4: ec06 sd ra,24(sp)
ad6: e822 sd s0,16(sp)
ad8: 1000 addi s0,sp,32
ada: e40c sd a1,8(s0)
adc: e810 sd a2,16(s0)
ade: ec14 sd a3,24(s0)
ae0: f018 sd a4,32(s0)
ae2: f41c sd a5,40(s0)
ae4: 03043823 sd a6,48(s0)
ae8: 03143c23 sd a7,56(s0)
va_list ap;
va_start(ap, fmt);
aec: 00840613 addi a2,s0,8
af0: fec43423 sd a2,-24(s0)
vprintf(1, fmt, ap);
af4: 85aa mv a1,a0
af6: 4505 li a0,1
af8: 00000097 auipc ra,0x0
afc: dce080e7 jalr -562(ra) # 8c6 <vprintf>
}
b00: 60e2 ld ra,24(sp)
b02: 6442 ld s0,16(sp)
b04: 6125 addi sp,sp,96
b06: 8082 ret
0000000000000b08 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
b08: 1141 addi sp,sp,-16
b0a: e422 sd s0,8(sp)
b0c: 0800 addi s0,sp,16
Header *bp, *p;
bp = (Header*)ap - 1;
b0e: ff050693 addi a3,a0,-16
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
b12: 00000797 auipc a5,0x0
b16: 2967b783 ld a5,662(a5) # da8 <freep>
b1a: a805 j b4a <free+0x42>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
bp->s.size += p->s.ptr->s.size;
b1c: 4618 lw a4,8(a2)
b1e: 9db9 addw a1,a1,a4
b20: feb52c23 sw a1,-8(a0)
bp->s.ptr = p->s.ptr->s.ptr;
b24: 6398 ld a4,0(a5)
b26: 6318 ld a4,0(a4)
b28: fee53823 sd a4,-16(a0)
b2c: a091 j b70 <free+0x68>
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
p->s.size += bp->s.size;
b2e: ff852703 lw a4,-8(a0)
b32: 9e39 addw a2,a2,a4
b34: c790 sw a2,8(a5)
p->s.ptr = bp->s.ptr;
b36: ff053703 ld a4,-16(a0)
b3a: e398 sd a4,0(a5)
b3c: a099 j b82 <free+0x7a>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
b3e: 6398 ld a4,0(a5)
b40: 00e7e463 bltu a5,a4,b48 <free+0x40>
b44: 00e6ea63 bltu a3,a4,b58 <free+0x50>
{
b48: 87ba mv a5,a4
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
b4a: fed7fae3 bgeu a5,a3,b3e <free+0x36>
b4e: 6398 ld a4,0(a5)
b50: 00e6e463 bltu a3,a4,b58 <free+0x50>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
b54: fee7eae3 bltu a5,a4,b48 <free+0x40>
if(bp + bp->s.size == p->s.ptr){
b58: ff852583 lw a1,-8(a0)
b5c: 6390 ld a2,0(a5)
b5e: 02059713 slli a4,a1,0x20
b62: 9301 srli a4,a4,0x20
b64: 0712 slli a4,a4,0x4
b66: 9736 add a4,a4,a3
b68: fae60ae3 beq a2,a4,b1c <free+0x14>
bp->s.ptr = p->s.ptr;
b6c: fec53823 sd a2,-16(a0)
if(p + p->s.size == bp){
b70: 4790 lw a2,8(a5)
b72: 02061713 slli a4,a2,0x20
b76: 9301 srli a4,a4,0x20
b78: 0712 slli a4,a4,0x4
b7a: 973e add a4,a4,a5
b7c: fae689e3 beq a3,a4,b2e <free+0x26>
} else
p->s.ptr = bp;
b80: e394 sd a3,0(a5)
freep = p;
b82: 00000717 auipc a4,0x0
b86: 22f73323 sd a5,550(a4) # da8 <freep>
}
b8a: 6422 ld s0,8(sp)
b8c: 0141 addi sp,sp,16
b8e: 8082 ret
0000000000000b90 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
b90: 7139 addi sp,sp,-64
b92: fc06 sd ra,56(sp)
b94: f822 sd s0,48(sp)
b96: f426 sd s1,40(sp)
b98: f04a sd s2,32(sp)
b9a: ec4e sd s3,24(sp)
b9c: e852 sd s4,16(sp)
b9e: e456 sd s5,8(sp)
ba0: e05a sd s6,0(sp)
ba2: 0080 addi s0,sp,64
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
ba4: 02051493 slli s1,a0,0x20
ba8: 9081 srli s1,s1,0x20
baa: 04bd addi s1,s1,15
bac: 8091 srli s1,s1,0x4
bae: 0014899b addiw s3,s1,1
bb2: 0485 addi s1,s1,1
if((prevp = freep) == 0){
bb4: 00000517 auipc a0,0x0
bb8: 1f453503 ld a0,500(a0) # da8 <freep>
bbc: c515 beqz a0,be8 <malloc+0x58>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
bbe: 611c ld a5,0(a0)
if(p->s.size >= nunits){
bc0: 4798 lw a4,8(a5)
bc2: 02977f63 bgeu a4,s1,c00 <malloc+0x70>
bc6: 8a4e mv s4,s3
bc8: 0009871b sext.w a4,s3
bcc: 6685 lui a3,0x1
bce: 00d77363 bgeu a4,a3,bd4 <malloc+0x44>
bd2: 6a05 lui s4,0x1
bd4: 000a0b1b sext.w s6,s4
p = sbrk(nu * sizeof(Header));
bd8: 004a1a1b slliw s4,s4,0x4
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
bdc: 00000917 auipc s2,0x0
be0: 1cc90913 addi s2,s2,460 # da8 <freep>
if(p == (char*)-1)
be4: 5afd li s5,-1
be6: a88d j c58 <malloc+0xc8>
base.s.ptr = freep = prevp = &base;
be8: 00000797 auipc a5,0x0
bec: 1c878793 addi a5,a5,456 # db0 <base>
bf0: 00000717 auipc a4,0x0
bf4: 1af73c23 sd a5,440(a4) # da8 <freep>
bf8: e39c sd a5,0(a5)
base.s.size = 0;
bfa: 0007a423 sw zero,8(a5)
if(p->s.size >= nunits){
bfe: b7e1 j bc6 <malloc+0x36>
if(p->s.size == nunits)
c00: 02e48b63 beq s1,a4,c36 <malloc+0xa6>
p->s.size -= nunits;
c04: 4137073b subw a4,a4,s3
c08: c798 sw a4,8(a5)
p += p->s.size;
c0a: 1702 slli a4,a4,0x20
c0c: 9301 srli a4,a4,0x20
c0e: 0712 slli a4,a4,0x4
c10: 97ba add a5,a5,a4
p->s.size = nunits;
c12: 0137a423 sw s3,8(a5)
freep = prevp;
c16: 00000717 auipc a4,0x0
c1a: 18a73923 sd a0,402(a4) # da8 <freep>
return (void*)(p + 1);
c1e: 01078513 addi a0,a5,16
if((p = morecore(nunits)) == 0)
return 0;
}
}
c22: 70e2 ld ra,56(sp)
c24: 7442 ld s0,48(sp)
c26: 74a2 ld s1,40(sp)
c28: 7902 ld s2,32(sp)
c2a: 69e2 ld s3,24(sp)
c2c: 6a42 ld s4,16(sp)
c2e: 6aa2 ld s5,8(sp)
c30: 6b02 ld s6,0(sp)
c32: 6121 addi sp,sp,64
c34: 8082 ret
prevp->s.ptr = p->s.ptr;
c36: 6398 ld a4,0(a5)
c38: e118 sd a4,0(a0)
c3a: bff1 j c16 <malloc+0x86>
hp->s.size = nu;
c3c: 01652423 sw s6,8(a0)
free((void*)(hp + 1));
c40: 0541 addi a0,a0,16
c42: 00000097 auipc ra,0x0
c46: ec6080e7 jalr -314(ra) # b08 <free>
return freep;
c4a: 00093503 ld a0,0(s2)
if((p = morecore(nunits)) == 0)
c4e: d971 beqz a0,c22 <malloc+0x92>
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
c50: 611c ld a5,0(a0)
if(p->s.size >= nunits){
c52: 4798 lw a4,8(a5)
c54: fa9776e3 bgeu a4,s1,c00 <malloc+0x70>
if(p == freep)
c58: 00093703 ld a4,0(s2)
c5c: 853e mv a0,a5
c5e: fef719e3 bne a4,a5,c50 <malloc+0xc0>
p = sbrk(nu * sizeof(Header));
c62: 8552 mv a0,s4
c64: 00000097 auipc ra,0x0
c68: b6e080e7 jalr -1170(ra) # 7d2 <sbrk>
if(p == (char*)-1)
c6c: fd5518e3 bne a0,s5,c3c <malloc+0xac>
return 0;
c70: 4501 li a0,0
c72: bf45 j c22 <malloc+0x92>
|
libsrc/_DEVELOPMENT/temp/sp1/zx/c/sdcc_iy/sp1_GetSprClr.asm | jpoikela/z88dk | 640 | 176301 | <reponame>jpoikela/z88dk
; void sp1_GetSprClr(uchar **sprsrc, struct sp1_ap *dest, uchar n)
SECTION code_clib
SECTION code_temp_sp1
PUBLIC _sp1_GetSprClr
EXTERN asm_sp1_GetSprClr
_sp1_GetSprClr:
pop af
pop hl
pop de
pop bc
push bc
push de
push hl
push af
ld b,c
jp asm_sp1_GetSprClr
|
src/aco-events.ads | jonashaggstrom/ada-canopen | 6 | 4999 | with Ada.Real_Time;
with ACO.Utils.Generic_Event;
with ACO.Messages;
with ACO.States;
with ACO.SDO_Sessions;
with ACO.OD_Types;
with ACO.Configuration;
package ACO.Events is
use ACO.Configuration;
type Handler_Event_Type is
(Tick,
Received_Message);
type Handler_Event_Data
(Event : Handler_Event_Type := Tick)
is record
case Event is
when Tick =>
Current_Time : Ada.Real_Time.Time;
when Received_Message =>
Msg : ACO.Messages.Message;
end case;
end record;
package HEP is new ACO.Utils.Generic_Event
(Item_Type => Handler_Event_Data,
Max_Nof_Subscribers => Max_Nof_Handler_Event_Subscribers,
Max_Nof_Queued_Events => Max_Nof_Event_Queue_Data_Items);
type Handler_Event_Listener
(Event : Handler_Event_Type)
is abstract new HEP.Subscriber with null record;
overriding
procedure Update
(This : access Handler_Event_Listener;
Data : in Handler_Event_Data);
procedure On_Event
(This : in out Handler_Event_Listener;
Data : in Handler_Event_Data) is abstract;
type Handler_Event_Manager is tagged limited record
Handler_Events : HEP.Event_Publisher;
end record;
type Event_Type is
(State_Transition,
Slave_State_Transition,
OD_Entry_Update,
Heartbeat_Received,
Heartbeat_Timed_Out,
SDO_Status_Update);
type Heartbeat_Data is record
Id : ACO.Messages.Node_Nr;
State : ACO.States.State;
end record;
type SDO_Status_Data is record
Endpoint_Id : ACO.SDO_Sessions.Endpoint_Nr;
Result : ACO.SDO_Sessions.SDO_Result;
end record;
type Slave_State_Data is record
State : ACO.States.State_Transition;
Node_Id : ACO.Messages.Node_Nr;
end record;
type Event_Data
(Event : Event_Type := State_Transition)
is record
case Event is
when State_Transition =>
State : ACO.States.State_Transition;
when Slave_State_Transition =>
Slave : Slave_State_Data;
when OD_Entry_Update =>
Index : ACO.OD_Types.Entry_Index;
when Heartbeat_Received =>
Received_Heartbeat : Heartbeat_Data;
when Heartbeat_Timed_Out =>
Node_Id : ACO.Messages.Node_Nr;
when SDO_Status_Update =>
SDO_Status : SDO_Status_Data;
end case;
end record;
package EP is new ACO.Utils.Generic_Event
(Item_Type => Event_Data,
Max_Nof_Subscribers => Max_Nof_Node_Event_Subscribers,
Max_Nof_Queued_Events => Max_Nof_Event_Queue_Data_Items);
type Event_Listener
(Event : Event_Type)
is abstract new EP.Subscriber with null record;
overriding
procedure Update
(This : access Event_Listener;
Data : in Event_Data);
procedure On_Event
(This : in out Event_Listener;
Data : in Event_Data) is abstract;
type Node_Event_Manager is tagged limited record
Node_Events : EP.Queued_Event_Publisher
(Priority_Ceiling => Event_Queue_Ceiling);
end record;
procedure Process
(This : in out Node_Event_Manager);
end ACO.Events;
|
src/sdl-inputs-joysticks.ads | Fabien-Chouteau/sdlada | 1 | 1136 | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2020, <NAME>
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
-- SDL.Inputs.Joysticks
--------------------------------------------------------------------------------------------------------------------
with Ada.Finalization;
private with SDL.C_Pointers;
with SDL.Events.Joysticks;
package SDL.Inputs.Joysticks is
Joystick_Error : exception;
-- Use to determine whether there are no joysticks.
type All_Devices is range 0 .. 2 ** 31 - 1 with
Convention => C,
Size => 32;
-- This range is the range of all connected joysticks.
subtype Devices is All_Devices range All_Devices'First + 1 .. All_Devices'Last;
-- SDL_Joystick_ID = instance ID.
type Instances is range 0 .. 2 ** 31 - 1 with
Convention => C,
Size => 32;
type GUID_Element is range 0 .. 255 with
convention => C,
Size => 8;
type GUID_Array is array (1 .. 16) of aliased GUID_Element with
Convention => C;
-- Pack => True;
type GUIDs is
record
Data : GUID_Array;
end record with
Convention => C_Pass_By_Copy;
-- Device specific information.
function Total return All_Devices;
function Name (Device : in Devices) return String;
function GUID (Device : in Devices) return GUIDs;
-- GUID utilities.
function Image (GUID : in GUIDs) return String;
function Value (GUID : in String) return GUIDs;
-- Joysticks.
type Joystick is new Ada.Finalization.Limited_Controlled with private;
Null_Joystick : constant Joystick;
function "=" (Left, Right : in Joystick) return Boolean with
Inline => True;
procedure Close (Self : in out Joystick);
-- Information.
function Axes (Self : in Joystick) return SDL.Events.Joysticks.Axes;
function Balls (Self : in Joystick) return SDL.Events.Joysticks.Balls;
function Buttons (Self : in Joystick) return SDL.Events.Joysticks.Buttons;
function Hats (Self : in Joystick) return SDL.Events.Joysticks.Hats;
function Name (Self : in Joystick) return String;
function Is_Haptic (Self : in Joystick) return Boolean;
function Is_Attached (Self : in Joystick) return Boolean with
Inline => True;
function GUID (Self : in Joystick) return GUIDs with
Inline => True;
function Instance (Self : in Joystick) return Instances;
-- Data.
function Axis_Value (Self : in Joystick;
Axis : in SDL.Events.Joysticks.Axes) return SDL.Events.Joysticks.Axes_Values;
procedure Ball_Value (Self : in Joystick;
Ball : in SDL.Events.Joysticks.Balls;
Delta_X, Delta_Y : out SDL.Events.Joysticks.Ball_Values);
function Hat_Value (Self : in Joystick;
Hat : in SDL.Events.Joysticks.Hats) return SDL.Events.Joysticks.Hat_Positions;
function Is_Button_Pressed (Self : in Joystick; Button : in SDL.Events.Joysticks.Buttons)
return SDL.Events.Button_State;
private
type Joystick is new Ada.Finalization.Limited_Controlled with
record
Internal : SDL.C_Pointers.Joystick_Pointer := null;
Owns : Boolean := True;
end record;
Null_Joystick : constant Joystick := (Ada.Finalization.Limited_Controlled with Internal => null, Owns => True);
end SDL.Inputs.Joysticks;
|
rdos-validation-tools/cdl-parser/src/main/antlr4/CDL.g4 | vpandey-rms/RDOS | 58 | 7445 | <reponame>vpandey-rms/RDOS<gh_stars>10-100
// Contract Definition Language grammar, RIsk Data Open Standard version RDOS-1.0
grammar CDL;
cdl : contract EOF ;
// A CDL contract consists of the keyword 'Contract' followed by declarations and at least one cover. Other parts, such as cashflows, are optional.
contract : CONTRACT declarationPart cashflowPart? reinstatementPart? coverPart sectionPart? sublimitPart? deductiblePart? subschedulePart? ;
// Every contract has a list of declarations, introduced by the keyword 'Declarations'
declarationPart : DECLARATIONS declaration+ ;
// A contract can have premium reinstatements
reinstatementPart : REINSTATEMENTS reinstatementLine+ ;
// Every contract has an optional list of covers, introduced by the keyword 'Covers'.
// Covers specify which claims get paid, and for how much
coverPart : COVERS covers ;
// A contract has an optional list of terms, which consist of sublimits followed by deductibles.
// Terms provide 'haircuts' which reduce the subject seen by the covers.
// Terms can be sublimits or deductibles.
// Sublimits, if present, are introduced by the keyword 'Sublimits'
sublimitPart : SUBLIMITS sublimit+ ;
// Deductibles, if present, are introduced by the keyword 'Deductibles'
deductiblePart : DEDUCTIBLES deductible+ ;
// Sections, if present, are introduced by the keyword 'Sections'
sectionPart : SECTIONS section+ ;
// Cashflows, if present, are introduces by the keyword 'Cashflows`
cashflowPart: CASHFLOWS cashflow+ ;
// Subschedules, if present, are introduced by the keyword 'Subschedules'
subschedulePart : SUBSCHEDULES subschedule+ ;
//
// Declarations
//
declaration :
INCEPTION IS dateExpression # inceptionDecl
| EXPIRATION IS dateExpression # expirationDecl
| CURRENCY IS currencyUnit # currencyDecl
| ATTACHMENTBASIS IS attachmentBasis # attachmentBasisDecl
| RISK IS EACH riskGranularity # riskDecl
| IDENT '(' arguments ')' IS expression # functionDecl
| IDENT IS (expression | IDENT | phrase) # identDecl
;
riskGranularity : CONTRACT | SECTION | LOCATION ;
identOrPhrase : IDENT | phrase ;
// Attachment basis specifies a time filter on which losses to consider.
attachmentBasis :
lossOccurrenceBasis
| riskAttachmentBasis
| riskAttachmentBasis AND lossOccurrenceBasis
| lossOccurrenceBasis AND riskAttachmentBasis
;
// Default basis is loss occurring from inception to expiration
lossOccurrenceBasis : LOSS OCCURRING optionalDateRange ;
riskAttachmentBasis :
RISK ATTACHING optionalDateRange
| INFORCE POLICIES optionalDateRange
| POLICIES ISSUED optionalDateRange ;
versionedRef : identOrPhrase version ;
//
// Reinstatements
//
reinstatementLine: IDENT COLON reinstatement (COMMA reinstatement)* ON IDENT WITH IDENT ;
reinstatement:
reinstatementQuantifier FREE
| reinstatementQuantifier ATSIGN fraction reinstatementProRataFactor
;
reinstatementQuantifier : INTEGER | UNLIMITED ;
reinstatementProRataFactor : /* empty */
| PRT
| PRC
| PRT PRC
| PRC PRT
;
//
// Covers
//
covers : BY SECTION | cover+ ;
// A cover has a participation, a payout, an attachment and may have a constraint on subject
cover : label? participation payout attachment coverSubjectConstraint ;
participation : fraction SHARE ;
// Payout - if empty, cover will pay all losses it sees (above the attachment)
// note: OF is inserted to make contracts more readable, e.g., 100% SHARE of 1M
payout : /* empty */
| OF payoutSpec timeBasis ;
payoutSpec : amount | PAY amount ;
// Attachment - Cover attaches if cover subject exceeds the attachment.
// If empty, cover will always attach.
// If cover attaches, subject is reduced by value of attachment, unless it is a franchise.
attachment: /* empty */
| XS amount franchise timeBasis ;
// Covers can derive subject from child covers and sections or by constraining the contract subject
coverSubjectConstraint : derivedSubject | subjectConstraint ;
// Derived subject can reference other covers or sections by name
derivedSubject : ON identifiers | ON functionCall ;
//
// Terms
//
// Terms may be sublimits or deductibles. Every term may have a timeBasis and a constraint on the subject
termModifiers : timeBasis subjectConstraint ;
// Sublimits
// A sublimit has an amount and may have a time basis, subject constraint, and resolution
// A sublimit can be labeled or unlabelled
sublimit : label? amount termModifiers ;
// Deductibles
// A deductible has an amount, may be franchise, may interact with other deductibles.
// As with sublimits, it may have a time basis, subject constraint, and resolution
// As with sublimits, it may be labelled
deductible : label? amount franchise interaction? termModifiers ;
// Default interaction is min deductible. Could instead be Max deductible.
interaction : MIN | MAX | MAXIMUM ;
//
// Sections
//
// A section has a name, and consists of declarations and covers. It does not contain sections or terms.
// A section is basically a named subcontract: It is executed within the context of the enclosing contract
// after the declarations and terms, and before the covers. The payout of a section is determined by
// its covers, and can be referenced by other covers using its section name.
section : SECTION IDENT declarationPart? coverPart ;
//
// Cashflows
//
// A cashflow has a name and might have time clause
// A cashflow either is whole amount or a percentage of another cashflow
cashflow :
IDENT IS wholeAmount timeClause? # independentCashflow
| IDENT IS number PERCENT OF IDENT timeClause? # dependentCashflow
;
timeClause:
AT date
| AT baseDate=(INCEPTION|EXPIRATION) (op=(PLUS|MINUS) INTEGER DAY)?
;
//
// Sub-schedule Definitions
//
// A sub-schedule is a named collection of risks
subschedule : IDENT COLON identifiers ;
//
// Term (and cover term) amounts
//
amount :
wholeAmount
| fractionalAmount
| functionalAmount
| UNLIMITED
;
// For example, 100M USD
wholeAmount : expression currencyUnit? ;
// For example, 2% ReplacementCost
fractionalAmount : fraction amountBasis;
// Amount basis is the underlying
amountBasis : insuredValue | subjectClaims | sumInsured ;
// A fraction may be expressed as 0.02 or 2% or F(3) or G(x) %
fraction : expression PERCENT? ;
insuredValue : valuationBasis exposureBasis ;
valuationBasis : REPLACEMENTCOST | CASHVALUE ;
exposureBasis : /* empty */ | AFFECTED | COVERED;
subjectClaims : OF LOSS ;
sumInsured : TOTALSUMINSURED ;
functionalAmount: functionName '(' amount (COMMA amount)+ ')' ;
//
// An expression evaluates to a number (in some cases, per event)
//
expression :
unaryOp=MINUS expression
// This rule must appear before the (+|-) rule to have 1 + 2 * 3 = 1 + (2 * 3)
| expression op=(TIMES|SLASH) expression
| expression op=(PLUS|MINUS) expression
| '(' expression ')'
| number multiplier?
| SUBJECT
| functionCall
;
//
// A boolean expression evaluates to true / false
//
booleanExpression :
| IDENT sign=(GREATERTHAN|GREATERTHANOREQUAL|LESSTHAN|LESSTHANOREQUAL) (IDENT|amount)
| booleanExpression op=(AND|OR) booleanExpression
| '(' booleanExpression ')'
;
//
// Functions may be called with any number of arguments, and must return a double
//
functionCall : functionName '(' arguments? ')' ;
functionName : IDENT | MIN | MAX | SUM;
arguments : argument (COMMA argument )* ;
// A function argument may be an expression or a labeled term, section or cover
argument : expression | IDENT ;
// All terms are per occurrence by default
timeBasis : /* empty */
| PEROCCURRENCE
| AGGREGATE
;
// Does term apply to each risk separately? By default, no.
resolution : /* empty */
| PERRISK
;
// Deductibles and attachment can be standard or franchise.
franchise : /* empty */
| FRANCHISE ;
// Subject constraints - used on terms and covers as constraints against contract subject
subjectConstraint :
outcomeTypeConstraint scheduleConstraint causeOfLossConstraint resolution ;
causeOfLossConstraint : /* empty */ | BY IDENT (COMMA IDENT)*;
outcome : LOSS ; // In future, may also support | DAMAGE | HAZARD ;
outcomeType : IDENT | outcome;
outcomeTypeConstraint : /* empty */ | FOR outcomeType (COMMA outcomeType)*;
scheduleConstraint : /* empty */ | TO IDENT (COMMA IDENT)*;
currencyUnit : IDENT ;
// Time
optionalDateRange :
/* empty */
| FROM date UNTIL date
| UNTIL date
;
dateExpression: date | duration;
date : dayOfMonth month year
;
duration : INTEGER durationTimeUnit;
durationTimeUnit : DAY | WEEK | MONTH | YEAR ;
month : JAN | FEB | MAR | APR | MAY | JUN | JUL | AUG | SEP | OCT | NOV | DEC;
dayOfMonth : INTEGER;
year : INTEGER;
identifiers : IDENT (COMMA IDENT)* ;
multiplier : THOUSAND | MILLION | BILLION;
number : INTEGER | FLOAT;
phrase : PHRASE;
version : PHRASE;
label : IDENT COLON ;
/*
* Lexer Rules
*/
SLASH : '/';
LPAREN : '(';
RPAREN : ')';
LSQUARE : '[';
RSQUARE : ']';
PERCENT : '%';
UNDERSCORE : '_';
SEMICOLON : ';';
COLON : ':';
PLUS : '+';
MINUS : '-';
TIMES : '*';
ELLIPSIS : '...';
DOT : '.';
COMMA : ',';
GREATERTHAN : '>';
GREATERTHANOREQUAL : '>=';
LESSTHAN : '<';
LESSTHANOREQUAL : '<=';
ATSIGN : '@';
AND : A N D;
OR : O R;
FOR : F O R;
ACV: A C V;
PERRISK : P E R WS R I S K;
PEROCCURRENCE : PER WS OCCURRENCE;
CONTRACT : C O N T R A C T;
PRODUCT : P R O D U C T;
LOCATION : L O C A T I O N;
MIN : M I N;
MAX : M A X;
SUM : S U M;
MAXIMUM : M A X I M U M;
DECLARATIONS : D E C L A R A T I O N S;
COVERS : C O V E R S;
SUBLIMITS : S U B L I M I T S;
DEDUCTIBLES : D E D U C T I B L E S;
SECTION : S E C T I O N;
SECTIONS : SECTION S;
INCEPTION : I N C E P T I O N;
EXPIRATION : E X P I R A T I O N;
CURRENCY : C U R R E N C Y;
ATTACHMENTBASIS : A T T A C H M E N T WS B A S I S;
OCCURRENCES : OCCURRENCE S;
OCCURRENCE : O C C U R R E N C E;
USING : U S I N G;
SHARE : S H A R E;
LOSS : L O S S;
DAMAGE : D A M A G E;
HAZARD : H A Z A R D;
NOT : N O T;
ABSORBABLE : A B S O R B A B L E;
NET : N E T;
DEDUCTIBLE : D E D U C T I B L E;
RISK : R I S K;
ATTACHING : A T T A C H I N G;
INFORCE : I N F O R C E;
POLICIES : P O L I C I E S;
ISSUED : I S S U E D;
OCCURRING : O C C U R R I N G;
PAY : P A Y;
XS : X S;
FRANCHISE : F R A N C H I S E;
REPLACEMENTCOST : R E P L A C E M E N T WS C O S T | R C V;
TOTALSUMINSURED : T O T A L WS SUM I N S U R E D;
AFFECTED : A F F E C T E D;
CASHVALUE : A C T U A L WS C A S H WS V A L U E;
COVERED : C O V E R E D;
AGGREGATE : A G G R E G A T E;
TYPE : T Y P E;
HOUR : H O U R (S)?;
DAY : D A Y (S)?;
WEEK : W E E K (S)?;
MONTH : M O N T H (S)?;
YEAR : Y E A R (S)?;
IS : I S;
ARE : A R E;
HAS : H A S;
ON : O N;
OF : O F;
IF : I F;
PER : P E R;
PRT : P R T | P DOT R DOT T DOT | P R O WS R A T A WS T I M E;
PRC : P R C | P DOT R DOT C DOT | P R O WS R A T A WS A M O U N T;
BY : B Y;
TO : T O;
AT : A T;
EACH : E A C H;
FROM : F R O M;
UNTIL : U N T I L;
UNLIMITED : U N L I M I T E D;
SUBSCHEDULES : S U B S C H E D U L E S;
SUBJECT : S U B J E C T;
CASHFLOWS : C A S H F L O W S;
REINSTATEMENTS : R E I N S T A T E M E N T S;
FREE : F R E E;
WITH : W I T H;
WITHIN : W I T H I N;
EVENTS: E V E N T S;
DISTANCEUNIT : M I L E S | K I L O M E T E R S;
JAN : J A N (U A R Y)?;
FEB : F E B (R U A R Y)?;
MAR : M A R (C H)?;
APR : A P R (I L)?;
MAY : M A Y;
JUN : J U N (E)?;
JUL : J U L (Y)?;
AUG : A U G (U S T)?;
SEP : S E P (T E M B E R)?;
OCT : O C T (O B E R)?;
NOV : N O V (E M B E R)?;
DEC : D E C (E M B E R)?;
COMMENT : SLASH SLASH ~[\n\r]* -> skip;
MILLION : M | M I L L I O N;
BILLION : B | B I L L I O N;
THOUSAND : K | T H O U S A N D;
IDENT : EXTENDEDALPHA (EXTENDEDALPHA | DIGIT | UNDERSCORE | DOT | MINUS)* ;
COLONIDENT : IDENT COLON IDENT ;
PHRASE : '{' (~[{])* '}';
WS : [ \t\r\n]+ -> channel(HIDDEN);
FLOAT : DIGIT* '.' DIGIT+;
INTEGER : DIGIT+;
fragment DIGIT : [0-9];
fragment EXTENDEDALPHA : [a-zA-ZÀ-ÖØ-öø-ÿ];
fragment ALPHA : [a-zA-Z];
fragment A : [aA];
fragment B : [bB];
fragment C : [cC];
fragment D : [dD];
fragment E : [eE];
fragment F : [fF];
fragment G : [gG];
fragment H : [hH];
fragment I : [iI];
fragment J : [jJ];
fragment K : [kK];
fragment L : [lL];
fragment M : [mM];
fragment N : [nN];
fragment O : [oO];
fragment P : [pP];
fragment Q : [qQ];
fragment R : [rR];
fragment S : [sS];
fragment T : [tT];
fragment U : [uU];
fragment V : [vV];
fragment W : [wW];
fragment X : [xX];
fragment Y : [yY];
fragment Z : [zZ];
|
src/tests/test_halfsiphash.adb | jhumphry/SPARK_SipHash | 5 | 4429 | -- Test_HalfSipHash
-- a short test program for a 32-bit friendly version of SipHash, the algorithm
-- described in "SipHash: a fast short-input PRF"
-- by <NAME> and <NAME>
-- Copyright (c) 2016, <NAME> - see LICENSE file for details
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Interfaces, Interfaces.C;
use Interfaces;
with System.Storage_Elements;
use System.Storage_Elements;
with HalfSipHash24;
with SipHash24_c;
procedure Test_HalfSipHash is
package U32_IO is new Ada.Text_IO.Modular_IO(Interfaces.Unsigned_32);
use U32_IO;
K : constant Storage_Array :=
(0,1,2,3,4,5,6,7);
M : constant Storage_Array :=
(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14);
Result : Unsigned_32;
C_K : aliased SipHash24_c.U8_Array(0..7) :=
(0,1,2,3,4,5,6,7);
C_M : aliased SipHash24_c.U8_Array(0..14) :=
(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14);
C_Output : aliased SipHash24_c.U8_Array4 := (others => 0);
C_Result : Unsigned_32;
Discard : C.int;
Expected_Result : constant Unsigned_32 := 16#972BFE74#;
begin
Put_Line("Testing HalfSipHash routines.");
New_Line;
Put_Line("Test vector for HalfSipHash");
HalfSipHash24.Set_Key(K);
Put("Result received from Ada routine for the test vector: ");
Put(HalfSipHash24.HalfSipHash(M), Base => 16); New_Line;
Discard := SipHash24_c.C_HalfSipHash24(c_in => C_M(0)'Access,
inlen => C_M'Length,
k => C_K(0)'Access,
c_out => C_Output(0)'Access,
outlen => 4
);
C_Result := SipHash24_c.U8_Array4_to_U32(C_Output);
Put("Result received from reference C routine for the test vector: ");
Put(C_Result, Base => 16); New_Line;
Put("Result expected for the test vector: ");
Put(Expected_Result, Base => 16); New_Line;
New_Line;
Put_Line("Testing Ada vs C routine for input lengths from 1 to 2000 bytes.");
for I in 1..2000 loop
declare
M : System.Storage_Elements.Storage_Array(0..Storage_Offset(I-1));
C_M : aliased SipHash24_c.U8_Array(0..I-1);
begin
for J in 0..I-1 loop
M(Storage_Offset(J)) := Storage_Element(J mod 256);
C_M(J) := Unsigned_8(J mod 256);
end loop;
Result := HalfSipHash24.HalfSipHash(M);
Discard := SipHash24_c.C_HalfSipHash24(c_in => C_M(0)'Access,
inlen => C_M'Length,
k => C_K(0)'Access,
c_out => C_Output(0)'Access,
outlen => 4
);
C_Result := SipHash24_c.U8_Array4_to_U32(C_Output);
if Result /= C_Result then
Put("Difference in result for: "); Put(I); New_Line;
Put("Ada code gives: "); Put(Result, Base => 16);
Put(" C code gives: "); Put(C_Result, Base => 16);
New_Line;
end if;
end;
if I mod 200 = 0 then
Put("Tested lengths up to: "); Put(I); New_Line;
end if;
end loop;
end Test_HalfSipHash;
|
src/FOmegaInt/Kinding/Declarative/Equivalence.agda | Blaisorblade/f-omega-int-agda | 12 | 11175 | <reponame>Blaisorblade/f-omega-int-agda<gh_stars>10-100
------------------------------------------------------------------------
-- Equivalence of the two variants of declarative kinding of Fω with
-- interval kinds
------------------------------------------------------------------------
{-# OPTIONS --safe --without-K #-}
module FOmegaInt.Kinding.Declarative.Equivalence where
open import Data.Product using (proj₁)
open import FOmegaInt.Syntax
import FOmegaInt.Typing as Original
open import FOmegaInt.Kinding.Declarative as Extended
open import FOmegaInt.Kinding.Declarative.Validity
private
module O where
open Original public
open Typing public
module E where
open Extended public
open Kinding public
open Syntax
open TermCtx
open Kinding
open KindedSubstitution
open Original.Typing
hiding (_ctx; _⊢_wf; _⊢_kd; _⊢Tp_∈_; _⊢_<∷_; _⊢_<:_∈_; _⊢_≅_; _⊢_≃_∈_)
-- Soundness of extended declarative (sub)kinding w.r.t. original
-- declarative (sub)kinding.
--
-- This soundness proof simply forgets about all the validity
-- conditions in the extended rules.
mutual
sound-wf : ∀ {n} {Γ : Ctx n} {a} → Γ ⊢ a wf → Γ O.⊢ a wf
sound-wf (wf-kd k-kd) = wf-kd (sound-kd k-kd)
sound-wf (wf-tp a∈*) = wf-tp (sound-Tp∈ a∈*)
sound-ctx : ∀ {n} {Γ : Ctx n} → Γ ctx → Γ O.ctx
sound-ctx E.[] = O.[]
sound-ctx (a-wf E.∷ Γ-ctx) = sound-wf a-wf O.∷ sound-ctx Γ-ctx
sound-kd : ∀ {n} {Γ : Ctx n} {k} → Γ ⊢ k kd → Γ O.⊢ k kd
sound-kd (kd-⋯ a∈* b∈*) = kd-⋯ (sound-Tp∈ a∈*) (sound-Tp∈ b∈*)
sound-kd (kd-Π j-kd k-kd) = kd-Π (sound-kd j-kd) (sound-kd k-kd)
sound-Tp∈ : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Tp a ∈ k → Γ O.⊢Tp a ∈ k
sound-Tp∈ (∈-var x Γ-ctx Γ[x]≡kd-k) =
∈-var x (sound-ctx Γ-ctx) Γ[x]≡kd-k
sound-Tp∈ (∈-⊥-f Γ-ctx) = ∈-⊥-f (sound-ctx Γ-ctx)
sound-Tp∈ (∈-⊤-f Γ-ctx) = ∈-⊤-f (sound-ctx Γ-ctx)
sound-Tp∈ (∈-∀-f k-kd a∈*) = ∈-∀-f (sound-kd k-kd) (sound-Tp∈ a∈*)
sound-Tp∈ (∈-→-f a∈* b∈*) = ∈-→-f (sound-Tp∈ a∈*) (sound-Tp∈ b∈*)
sound-Tp∈ (∈-Π-i j-kd a∈k k-kd) = ∈-Π-i (sound-kd j-kd) (sound-Tp∈ a∈k)
sound-Tp∈ (∈-Π-e a∈Πjk b∈j k-kd k[b]-kd) =
∈-Π-e (sound-Tp∈ a∈Πjk) (sound-Tp∈ b∈j)
sound-Tp∈ (∈-s-i a∈b⋯c) = ∈-s-i (sound-Tp∈ a∈b⋯c)
sound-Tp∈ (∈-⇑ a∈j j<∷k) = ∈-⇑ (sound-Tp∈ a∈j) (sound-<∷ j<∷k)
sound-<∷ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j <∷ k → Γ O.⊢ j <∷ k
sound-<∷ (<∷-⋯ a₂<:a₁∈* b₁<:b₂∈*) =
<∷-⋯ (sound-<: a₂<:a₁∈*) (sound-<: b₁<:b₂∈*)
sound-<∷ (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) =
<∷-Π (sound-<∷ j₂<∷j₁) (sound-<∷ k₁<∷k₂) (sound-kd Πj₁k₁-kd)
sound-<: : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a <: b ∈ k → Γ O.⊢ a <: b ∈ k
sound-<: (<:-refl a∈k) = <:-refl (sound-Tp∈ a∈k)
sound-<: (<:-trans a<:b∈k b<:c∈k) =
<:-trans (sound-<: a<:b∈k) (sound-<: b<:c∈k)
sound-<: (<:-β₁ a∈k b∈j a[b]∈k[b] k-kd k[b]-kd) =
<:-β₁ (sound-Tp∈ a∈k) (sound-Tp∈ b∈j)
sound-<: (<:-β₂ a∈k b∈j a[b]∈k[b] k-kd k[b]-kd) =
<:-β₂ (sound-Tp∈ a∈k) (sound-Tp∈ b∈j)
sound-<: (<:-η₁ a∈Πjk) = <:-η₁ (sound-Tp∈ a∈Πjk)
sound-<: (<:-η₂ a∈Πjk) = <:-η₂ (sound-Tp∈ a∈Πjk)
sound-<: (<:-⊥ a∈b⋯c) = <:-⊥ (sound-Tp∈ a∈b⋯c)
sound-<: (<:-⊤ a∈b⋯c) = <:-⊤ (sound-Tp∈ a∈b⋯c)
sound-<: (<:-∀ k₂<∷k₁ a₁<:a₂∈* ∀k₁a₁∈*) =
<:-∀ (sound-<∷ k₂<∷k₁) (sound-<: a₁<:a₂∈*) (sound-Tp∈ ∀k₁a₁∈*)
sound-<: (<:-→ a₂<:a₁∈* b₁<:b₂∈*) =
<:-→ (sound-<: a₂<:a₁∈*) (sound-<: b₁<:b₂∈*)
sound-<: (<:-λ a₁<:a₂∈Πjk Λj₁a₁∈Πjk Λj₂a₂∈Πjk) =
<:-λ (sound-<: a₁<:a₂∈Πjk)
(sound-Tp∈ Λj₁a₁∈Πjk) (sound-Tp∈ Λj₂a₂∈Πjk)
sound-<: (<:-· a₁<:a₂∈Πjk b₁≃b₁∈j b₁∈j k-kd k[b₁]-kd) =
<:-· (sound-<: a₁<:a₂∈Πjk) (sound-≃ b₁≃b₁∈j)
sound-<: (<:-⟨| a∈b⋯c) = <:-⟨| (sound-Tp∈ a∈b⋯c)
sound-<: (<:-|⟩ a∈b⋯c) = <:-|⟩ (sound-Tp∈ a∈b⋯c)
sound-<: (<:-⋯-i a₁<:a₂∈b⋯c) = <:-⋯-i (sound-<: a₁<:a₂∈b⋯c)
sound-<: (<:-⇑ a₁<:a₂∈j j<∷k) =
<:-⇑ (sound-<: a₁<:a₂∈j) (sound-<∷ j<∷k)
sound-≃ : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a ≃ b ∈ k → Γ O.⊢ a ≃ b ∈ k
sound-≃ (<:-antisym a<:b∈k b<:a∈k) =
<:-antisym (sound-<: a<:b∈k) (sound-<: b<:a∈k)
sound-≅ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j ≅ k → Γ O.⊢ j ≅ k
sound-≅ (<∷-antisym j<∷k k<∷j) =
<∷-antisym (sound-<∷ j<∷k) (sound-<∷ k<∷j)
-- Completeness of extended declarative (sub)kinding w.r.t. original
-- declarative (sub)kinding.
--
-- This proves that the validity conditions in the extended rules are
-- in fact redundant, i.e. they follow from validity properties of the
-- remaining premises (of the rules in question)
mutual
complete-wf : ∀ {n} {Γ : Ctx n} {a} → Γ O.⊢ a wf → Γ ⊢ a wf
complete-wf (wf-kd k-kd) = wf-kd (complete-kd k-kd)
complete-wf (wf-tp a∈*) = wf-tp (complete-Tp∈ a∈*)
complete-ctx : ∀ {n} {Γ : Ctx n} → Γ O.ctx → Γ ctx
complete-ctx O.[] = E.[]
complete-ctx (a-wf O.∷ Γ-ctx) = complete-wf a-wf E.∷ complete-ctx Γ-ctx
complete-kd : ∀ {n} {Γ : Ctx n} {k} → Γ O.⊢ k kd → Γ ⊢ k kd
complete-kd (kd-⋯ a∈* b∈*) = kd-⋯ (complete-Tp∈ a∈*) (complete-Tp∈ b∈*)
complete-kd (kd-Π j-kd k-kd) = kd-Π (complete-kd j-kd) (complete-kd k-kd)
complete-Tp∈ : ∀ {n} {Γ : Ctx n} {a k} → Γ O.⊢Tp a ∈ k → Γ ⊢Tp a ∈ k
complete-Tp∈ (∈-var x Γ-ctx Γ[x]≡kd-k) =
∈-var x (complete-ctx Γ-ctx) Γ[x]≡kd-k
complete-Tp∈ (∈-⊥-f Γ-ctx) = ∈-⊥-f (complete-ctx Γ-ctx)
complete-Tp∈ (∈-⊤-f Γ-ctx) = ∈-⊤-f (complete-ctx Γ-ctx)
complete-Tp∈ (∈-∀-f k-kd a∈*) = ∈-∀-f (complete-kd k-kd) (complete-Tp∈ a∈*)
complete-Tp∈ (∈-→-f a∈* b∈*) = ∈-→-f (complete-Tp∈ a∈*) (complete-Tp∈ b∈*)
complete-Tp∈ (∈-Π-i j-kd a∈k) =
∈-Π-i (complete-kd j-kd) a∈k′ k-kd
where
a∈k′ = complete-Tp∈ a∈k
k-kd = Tp∈-valid a∈k′
complete-Tp∈ (∈-Π-e a∈Πjk b∈j) with Tp∈-valid (complete-Tp∈ a∈Πjk)
... | (kd-Π j-kd k-kd) =
∈-Π-e (complete-Tp∈ a∈Πjk) b∈j′ k-kd k[b]-kd
where
b∈j′ = complete-Tp∈ b∈j
k[b]-kd = kd-[] k-kd (∈-tp b∈j′)
complete-Tp∈ (∈-s-i a∈b⋯c) = ∈-s-i (complete-Tp∈ a∈b⋯c)
complete-Tp∈ (∈-⇑ a∈j j<∷k) = ∈-⇑ (complete-Tp∈ a∈j) (complete-<∷ j<∷k)
complete-<∷ : ∀ {n} {Γ : Ctx n} {j k} → Γ O.⊢ j <∷ k → Γ ⊢ j <∷ k
complete-<∷ (<∷-⋯ a₂<:a₁∈* b₁<:b₂∈*) =
<∷-⋯ (complete-<: a₂<:a₁∈*) (complete-<: b₁<:b₂∈*)
complete-<∷ (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) =
<∷-Π (complete-<∷ j₂<∷j₁) (complete-<∷ k₁<∷k₂) (complete-kd Πj₁k₁-kd)
complete-<: : ∀ {n} {Γ : Ctx n} {a b k} → Γ O.⊢ a <: b ∈ k → Γ ⊢ a <: b ∈ k
complete-<: (<:-refl a∈k) = <:-refl (complete-Tp∈ a∈k)
complete-<: (<:-trans a<:b∈k b<:c∈k) =
<:-trans (complete-<: a<:b∈k) (complete-<: b<:c∈k)
complete-<: (<:-β₁ a∈k b∈j) =
<:-β₁ a∈k′ b∈j′ a[b]∈k[b] k-kd k[b]-kd
where
a∈k′ = complete-Tp∈ a∈k
b∈j′ = complete-Tp∈ b∈j
k-kd = Tp∈-valid a∈k′
a[b]∈k[b] = Tp∈-[] a∈k′ (∈-tp b∈j′)
k[b]-kd = kd-[] k-kd (∈-tp b∈j′)
complete-<: (<:-β₂ a∈k b∈j) =
<:-β₂ a∈k′ b∈j′ a[b]∈k[b] k-kd k[b]-kd
where
a∈k′ = complete-Tp∈ a∈k
b∈j′ = complete-Tp∈ b∈j
k-kd = Tp∈-valid a∈k′
a[b]∈k[b] = Tp∈-[] a∈k′ (∈-tp b∈j′)
k[b]-kd = kd-[] k-kd (∈-tp b∈j′)
complete-<: (<:-η₁ a∈Πjk) = <:-η₁ (complete-Tp∈ a∈Πjk)
complete-<: (<:-η₂ a∈Πjk) = <:-η₂ (complete-Tp∈ a∈Πjk)
complete-<: (<:-⊥ a∈b⋯c) = <:-⊥ (complete-Tp∈ a∈b⋯c)
complete-<: (<:-⊤ a∈b⋯c) = <:-⊤ (complete-Tp∈ a∈b⋯c)
complete-<: (<:-∀ k₂<∷k₁ a₁<:a₂∈* ∀k₁a₁∈*) =
<:-∀ (complete-<∷ k₂<∷k₁) (complete-<: a₁<:a₂∈*) (complete-Tp∈ ∀k₁a₁∈*)
complete-<: (<:-→ a₂<:a₁∈* b₁<:b₂∈*) =
<:-→ (complete-<: a₂<:a₁∈*) (complete-<: b₁<:b₂∈*)
complete-<: (<:-λ a₁<:a₂∈Πjk Λj₁a₁∈Πjk Λj₂a₂∈Πjk) =
<:-λ (complete-<: a₁<:a₂∈Πjk)
(complete-Tp∈ Λj₁a₁∈Πjk) (complete-Tp∈ Λj₂a₂∈Πjk)
complete-<: (<:-· a₁<:a₂∈Πjk b₁≃b₁∈j)
with <:-valid-kd (complete-<: a₁<:a₂∈Πjk)
... | (kd-Π j-kd k-kd) =
<:-· (complete-<: a₁<:a₂∈Πjk) b₁≃b₂∈j′ b₁∈j k-kd k[b₁]-kd
where
b₁≃b₂∈j′ = complete-≃ b₁≃b₁∈j
b₁∈j = proj₁ (≃-valid b₁≃b₂∈j′)
k[b₁]-kd = kd-[] k-kd (∈-tp b₁∈j)
complete-<: (<:-⟨| a∈b⋯c) = <:-⟨| (complete-Tp∈ a∈b⋯c)
complete-<: (<:-|⟩ a∈b⋯c) = <:-|⟩ (complete-Tp∈ a∈b⋯c)
complete-<: (<:-⋯-i a₁<:a₂∈b⋯c) = <:-⋯-i (complete-<: a₁<:a₂∈b⋯c)
complete-<: (<:-⇑ a₁<:a₂∈j j<∷k) =
<:-⇑ (complete-<: a₁<:a₂∈j) (complete-<∷ j<∷k)
complete-≃ : ∀ {n} {Γ : Ctx n} {a b k} → Γ O.⊢ a ≃ b ∈ k → Γ ⊢ a ≃ b ∈ k
complete-≃ (<:-antisym a<:b∈k b<:a∈k) =
<:-antisym (complete-<: a<:b∈k) (complete-<: b<:a∈k)
complete-≅ : ∀ {n} {Γ : Ctx n} {j k} → Γ O.⊢ j ≅ k → Γ ⊢ j ≅ k
complete-≅ (<∷-antisym j<∷k k<∷j) =
<∷-antisym (complete-<∷ j<∷k) (complete-<∷ k<∷j)
|
Projetos/J-VMTranslator/bin/nasm/SimplePushConst.nasm | mariaeduardabicalho/Z01 | 2 | 12168 | ; 0 - PUSH constant 5
leaw $5, %A
movw %A, %S
leaw $SP, %A
movw (%A), %D
movw %D, %A
movw %S, (%A)
leaw $SP, %A
movw (%A), %A
incw %A
movw %A, %S
leaw $SP, %A
movw %S, (%A)
; 1 - PUSH constant 9
leaw $9, %A
movw %A, %S
leaw $SP, %A
movw (%A), %D
movw %D, %A
movw %S, (%A)
leaw $SP, %A
movw (%A), %A
incw %A
movw %A, %S
leaw $SP, %A
movw %S, (%A)
; End
|
src/music/totaka-ft.asm | Xkeeper0/tcrf-birthday | 10 | 15944 | song_index_mus_totaka = 0
sfx_index_sfx_null = 0
song_list:
.dw _mus_totaka
sfx_list:
.dw _sfx_null
instrument_list:
.dw _Blong_0
.dw silent_1
_Blong_0:
.db 5,22,24,27,ARP_TYPE_ABSOLUTE
.db 8,7,7,6,6,5,5,4,4,3,3,2,2,1,1,0,ENV_STOP
.db 0,ENV_STOP
.db 128,64,DUTY_ENV_STOP
.db ENV_STOP
silent_1:
.db 5,7,9,11,ARP_TYPE_ABSOLUTE
.db 0,ENV_STOP
.db 0,ENV_STOP
.db 0,DUTY_ENV_STOP
.db ENV_STOP
_mus_totaka:
.db 0
.db 5
.db 42
.db 4
.dw _mus_totaka_square1
.dw 0
.dw 0
.dw 0
.dw 0
_mus_totaka_square1:
_mus_totaka_square1_loop:
.db CAL,<(_mus_totaka_square1_0),>(_mus_totaka_square1_0)
.db CAL,<(_mus_totaka_square1_1),>(_mus_totaka_square1_1)
.db GOT
.dw _mus_totaka_square1_loop
_mus_totaka_square1_0:
.db STI,0,SL6,C3,SL1,C3,D3,SL5,E3,SL3,D3,SL8,C3,G3,E3,C4,SL0
.db G3
.db RET
_mus_totaka_square1_1:
.db STI,0,SL6,G3,SL1,G3,GS3,SL5,G3,SL3,FS3,SL0,DS3,SLC,D3,G3
.db SL8,C3
.db RET
_sfx_null:
.db 0, 1
.db 0, 1
.dw 0
.dw 0
.dw 0
.dw 0
.dw 0
|
ide/editor.asm | shikhin/wodscipe | 5 | 25949 | ; The editor.
; IN:
; BX -> 0x8000.
; AX -> 2
; DI -> 0
editor:
.loadsource:
lea bp, [bx + 2] ; Current start-of-line
mov dx, bp
add dx, [bx]
.rw_source:
push bx
.writeloop:
call rwsector
inc ax
add bx, 0x200
cmp bx, dx
jb .writeloop
pop bx
.mainloop:
; Input buffer.
mov di, 0x504
; 80 characters (most probably width of current mode's line, mode 03)
mov cx, 0x50
call getline
cmp al, 1
jb .cmdnext
je .checkcmd
.gotoline:
mov si, di
xor ax, ax
.atoi:
lodsb
test al, al
jz .gotosetup
sub al, '0'
cmp al, 9
ja .error
aad
xchg ah, al
jmp .atoi
.gotosetup:
mov bp, 0x8002
movzx cx, ah
jcxz .error
dec cx
.gotoloop:
jcxz .cmdprint
call next_newline
mov bp, si
dec cx
jmp .gotoloop
.error:
mov si, .errormsg
call puts
jmp .mainloop
.errormsg: db '?', 10, 0
.checkcmd:
mov al, [di]
.insert:
cmp al, 'i'
jne .append
; Insert
.cmdinsert:
; cx & di already set above
call getline
inc ax
push di
; Get bytes following bp = last "address" - bp.
mov cx, dx
sub cx, bp
; Copy from BP to (BP + AX), but reversed (as overlap).
mov si, bp
add si, cx
mov di, si
add di, ax
inc cx
std
rep movsb
cld
; Copy from input buffer to BP, the new line.
pop si
mov di, bp
mov cx, ax
rep movsb
; Update file length.
add [bx], ax
add dx, ax
mov byte [di - 1], 10
xor al, al
.append:
cmp al, 'a'
jne .delete
; Append
.cmdappend:
; Go to next line, and insert before that.
call next_newline
mov bp, si
jmp .cmdinsert
.delete:
cmp al, 'd'
jne .print
; Delete
.cmddelete:
; Find next newline.
call next_newline
; Get number of bytes from next line to end.
mov cx, dx
sub cx, si
; Remove size of current line from [bx].
sub [bx], si
add [bx], bp
sub dx, si
add dx, bp
mov di, bp
rep movsb
call prev_newline
xor al, al
.print:
cmp al, 'p'
jne .write
; Print
.cmdprint:
; Get next line.
call next_newline
; Put a null-terminator at beginning of next line.
xor al, al
xchg [si], al
; Print.
xchg si, bp
call puts
; Restore character.
xchg si, bp
xchg [si], al
.write:
cmp al, 'w'
jne .next
; Write
.cmdwrite:
mov ax, 2
mov di, 1 << 8
jmp .rw_source
.next:
cmp al, '+'
jne .last
; Next
.cmdnext:
call next_newline
cmp dx, si
jz .error
mov bp, si
jmp .cmdprint
.last:
cmp al, '$'
jne .previous
; Last
.cmdlast:
; Find the previous line from EOF.
mov bp, dx
jmp .cmdprevious
.previous:
cmp al, '-'
jne .list
; Previous
.cmdprevious:
cmp bp, 0x8002
je .error
call prev_newline
jmp .cmdprint
.list:
cmp al, 'l'
jne .run
; List
.cmdlist:
lea si, [bx + 2]
mov cx, [bx]
jcxz .listed
.loop:
lodsb
call putchar
loop .loop
.listed:
xor al, al
.run:
cmp al, 'r'
jne .nomatch
; Run
.cmdrun:
call interpreter
.nomatch:
test al, al
jnz .gotoline
jmp .mainloop
; Find previous line.
; IN:
; BP -> buffer
; OUT:
; BP -> previous line, or start of buffer
; Trashes CX.
prev_newline:
mov cx, bp
mov bp, 0x8002
.find_nextline:
call next_newline
cmp si, cx
jae .ret
mov bp, si
jmp .find_nextline
.ret:
ret
; Find next line.
; IN:
; BP -> buffer
; OUT:
; SI -> next/previous line, or end/start of buffer
next_newline:
mov si, bp
.loop:
; If reached start/end of buffer
cmp dx, si
jbe .end
lodsb
cmp al, 10
jne .loop
.end:
ret
|
8088/cga/lightpen/lightpen2.asm | reenigne/reenigne | 92 | 97313 | <reponame>reenigne/reenigne
%include "../../defaults_bin.asm"
initCGA 9
clear:
; Clear screen to white
mov ax,0xb800
mov es,ax
mov ds,ax
mov ax,0x0fdb
mov cx,80*25
xor di,di
cld
rep stosw
loopTop:
; Wait for strobe
mov dx,0x3da
waitLoop:
in al,dx
test al,2
jz waitLoop
; Read light pen position:
mov dl,0xd4
mov al,0x10
out dx,al
inc dx
in al,dx
mov bh,al
dec dx
mov al,0x11
out dx,al
inc dx
in al,dx
mov bl,al ; Light pen character position now in BX
add bx,bx ; Multiply by 2 to get memory position (offset from 0xb8000)
; Reset strobe
mov dl,0xdb
out dx,al
; Update screen at light pen position:
mov byte[bx],0x20
cmp bx,0
je clear
; mov ax,bx
; mov dx,0
; mov bx,160
; div bx
;
; mov cx,ax ; quotient = y position
;
; mov ah,0
; mov al,dl ; remainder = x position
; mov bl,10
; div bl
; add ax,0x3030
; mov byte[0],al ; quotient = x 10s
; mov byte[2],ah ; remainder = x 1s
;
; mov ah,0
; mov al,cl
; div bl
; add ax,0x3030
; mov byte[4],al ; quotient = y 10s
; mov byte[6],ah ; quotient = y 1s
mov dx,0x3da
waitForVerticalSync
waitForNoVerticalSync
jmp loopTop
|
other.7z/SFC.7z/SFC/ソースデータ/ヨッシーアイランド/日本_Ver2/sfc/ys_w45.asm | prismotizm/gigaleak | 0 | 170907 | <reponame>prismotizm/gigaleak<gh_stars>0
Name: ys_w45.asm
Type: file
Size: 14550
Last-Modified: '2016-05-13T04:51:43Z'
SHA-1: 8637894E8ADEC8226AC2BB680591C05B476B2B1B
Description: null
|
Source/HBIOS/ctc.asm | vipoo/RomWBW | 1 | 24015 | ;___CTC________________________________________________________________________________________________________________
;
; Z80 CTC
;
; DISPLAY CONFIGURATION DETAILS
;______________________________________________________________________________________________________________________
;
CTC_DEFCFG .EQU %01010011 ; CTC DEFAULT CONFIG
CTC_CTRCFG .EQU %01010111 ; CTC COUNTER MODE CONFIG
CTC_TIM16CFG .EQU %00010111 ; CTC TIMER/16 MODE CONFIG
CTC_TIM256CFG .EQU %00110111 ; CTC TIMER/256 MODE CONFIG
CTC_TIMCFG .EQU %11010111 ; CTC TIMER CHANNEL CONFIG
; |||||||+-- CONTROL WORD FLAG
; ||||||+--- SOFTWARE RESET
; |||||+---- TIME CONSTANT FOLLOWS
; ||||+----- AUTO TRIGGER WHEN TIME CONST LOADED
; |||+------ RISING EDGE TRIGGER
; ||+------- TIMER MODE PRESCALER (0=16, 1=256)
; |+-------- COUNTER MODE
; +--------- INTERRUPT ENABLE
;
#IF (CTCTIMER)
;
; ONLY IM2 IMPLEMENTED BELOW. I DON'T SEE ANY REASONABLE WAY TO
; IMPLEMENT AN IM1 TIMER BECAUSE THE CTC PROVIDES NO WAY TO
; DETERMINE IF IT WAS THE CAUSE OF AN INTERRUPT OR A WAY TO
; DETERMINE WHICH CHANNEL CAUSED AN INTERRUPT.
;
#IF (INTMODE != 2)
.ECHO "*** ERROR: CTC REQUIRES INTMODE 2!!!\n"
!!! ; FORCE AN ASSEMBLY ERROR
#ENDIF
;
CTC_PREIO .EQU CTCBASE + CTCPRECH
CTC_SCLIO .EQU CTCBASE + CTCTIMCH
;
#IF (CTCMODE == CTCMODE_CTR)
CTC_PRECFG .EQU CTC_CTRCFG
CTC_PRESCL .EQU 1
#ENDIF
#IF (CTCMODE == CTCMODE_TIM16)
CTC_PRECFG .EQU CTC_TIM16CFG
CTC_PRESCL .EQU 16
#ENDIF
#IF (CTCMODE == CTCMODE_TIM256)
CTC_PRECFG .EQU CTC_TIM256CFG
CTC_PRESCL .EQU 256
#ENDIF
;
CTC_DIV .EQU CTCOSC / CTC_PRESCL / TICKFREQ
;
CTC_DIVHI .EQU CTCPRE
CTC_DIVLO .EQU (CTC_DIV / CTC_DIVHI)
;
.ECHO "CTC DIVISOR: "
.ECHO CTC_DIV
.ECHO ", HI: "
.ECHO CTC_DIVHI
.ECHO ", LO: "
.ECHO CTC_DIVLO
.ECHO "\n"
;
#IF ((CTC_DIV == 0) | (CTC_DIV > $FFFF))
.ECHO "COMPUTED CTC DIVISOR IS UNUSABLE!\n"
!!!
#ENDIF
;
#IF ((CTC_DIVHI > $100) | (CTC_DIVLO > $100))
.ECHO "COMPUTED CTC DIVISOR IS UNUSABLE!\n"
!!!
#ENDIF
;
#IF ((CTC_DIVHI * CTC_DIVLO * CTC_PRESCL * TICKFREQ) != CTCOSC)
.ECHO "COMPUTED CTC DIVISOR IS UNUSABLE!\n"
!!!
#ENDIF
;
CTCTIVT .EQU INT_CTC0A + CTCTIMCH
;
#ENDIF
;
;
;
CTC_PREINIT:
;
; RESET ALL CTC CHANNELS
LD B,4 ; 4 CHANNELS
LD C,CTCBASE ; FIRST CHANNEL PORT
CTC_PREINIT1:
LD A,CTC_DEFCFG ; CTC DEFAULT CONFIG
OUT (C),A ; CTC COMMAND
INC C ; NEXT CHANNEL PORT
DJNZ CTC_PREINIT1
;
#IF (CTCTIMER)
; SETUP TIMER INTERRUPT IVT SLOT
LD HL,HB_TIMINT ; TIMER INT HANDLER ADR
LD (IVT(CTCTIVT)),HL ; IVT ENTRY FOR TIMER CHANNEL
;
; CTC USES 4 CONSECUTIVE VECTOR POSITIONS, ONE FOR
; EACH CHANNEL. BELOW WE SET THE BASE VECTOR TO THE
; START OF THE IVT, SO THE FIRST FOUR ENTIRES OF THE
; IVT CORRESPOND TO CTC CHANNELS A-D.
LD A,0
OUT (CTCBASE),A ; SETUP CTC BASE INT VECTOR
;
; IN ORDER TO DIVIDE THE CTC INPUT CLOCK DOWN TO THE
; DESIRED PERIODIC INTERRUPT, WE NEED TO CONFIGURE ONE
; CTC CHANNEL AS A PRESCALER AND ANOTHER AS THE ACTUAL
; TIMER INTERRUPT. THE PRESCALE CHANNEL OUTPUT MUST BE WIRED
; TO THE TIMER CHANNEL TRIGGER INPUT VIA HARDWARE.
LD A,CTC_PRECFG ; PRESCALE CHANNEL CONFIGURATION
OUT (CTC_PREIO),A ; SETUP PRESCALE CHANNEL
LD A,CTC_DIVHI & $FF ; PRESCALE CHANNEL CONSTANT
OUT (CTC_PREIO),A ; SET PRESCALE CONSTANT
;
LD A,CTC_TIMCFG ; TIMER CHANNEL CONTROL WORD VALUE
OUT (CTC_SCLIO),A ; SETUP TIMER CHANNEL
LD A,CTC_DIVLO & $FF ; TIMER CHANNEL CONSTANT
OUT (CTC_SCLIO),A ; SET TIMER CONSTANT
;
#ENDIF
;
XOR A
RET
;
;
;
CTC_INIT: ; MINIMAL INIT
CTC_PRTCFG:
; ANNOUNCE PORT
CALL NEWLINE ; FORMATTING
PRTS("CTC:$") ; FORMATTING
;
PRTS(" IO=0x$") ; FORMATTING
LD A,CTCBASE ; GET BASE PORT
CALL PRTHEXBYTE ; PRINT BASE PORT
;
#IF (CTCTIMER)
;
PRTS(" MODE=$") ; FORMATTING
#IF (CTCMODE == CTCMODE_CTR)
PRTS("CTR$")
#ENDIF
#IF (CTCMODE == CTCMODE_TIM16)
PRTS("TIM16$")
#ENDIF
#IF (CTCMODE == CTCMODE_TIM256)
PRTS("TIM256$")
#ENDIF
;
PRTS(" DIVHI=$")
LD A,CTC_DIVHI & $FF
CALL PRTHEXBYTE
;
PRTS(" DIVLO=$")
LD A,CTC_DIVLO & $FF
CALL PRTHEXBYTE
;
#IF (CTCDEBUG)
PRTS(" PREIO=$")
LD A,CTC_PREIO
CALL PRTHEXBYTE
;
PRTS(" SCLIO=$")
LD A,CTC_SCLIO
CALL PRTHEXBYTE
;
PRTS(" DIV=$")
LD BC,CTC_DIV
CALL PRTHEXWORD
#ENDIF
;
#ENDIF
;
XOR A
RET
|
lib/aflexnat/vstrings.adb | alvaromb/Compilemon | 1 | 15045 |
-- UNIT: generic package body of VSTRINGS
--
-- FILES: vstring_body.a in publiclib
-- related file is vstring_spec.a in publiclib
--
-- PURPOSE: An implementation of the abstract data type "variable-length
-- string."
--
-- DESCRIPTION: This package provides a private type VSTRING. VSTRING objects
-- are "strings" that have a length between zero and LAST, where
-- LAST is the generic parameter supplied in the package
-- instantiation.
--
-- In addition to the type VSTRING, a subtype and two constants
-- are declared. The subtype STRINDEX is an index to a VSTRING,
-- The STRINDEX constant FIRST is an index to the first character
-- of the string, and the VSTRING constant NUL is a VSTRING of
-- length zero. NUL is the default initial value of a VSTRING.
--
-- The following sets of functions, procedures, and operators
-- are provided as operations on the type VSTRING:
--
-- ATTRIBUTE FUNCTIONS: LEN, MAX, STR, CHAR
-- The attribute functions return the characteristics of
-- a VSTRING.
--
-- COMPARISON OPERATORS: "=", "/=", "<", ">", "<=", ">="
-- The comparison operators are the same as for the predefined
-- type STRING.
--
-- INPUT/OUTPUT PROCEDURES: GET, GET_LINE, PUT, PUT_LINE
--
-- The input/output procedures are similar to those for the
-- predefined type STRING, with the following exceptions:
--
-- - GET has an optional parameter LENGTH, which indicates
-- the number of characters to get (default is LAST).
--
-- - GET_LINE does not have a parameter to return the length
-- of the string (the LEN function should be used instead).
--
-- EXTRACTION FUNCTIONS: SLICE, SUBSTR, DELETE
-- The SLICE function returns the slice of a VSTRING between
-- two indices (equivalent to STR(X)(A .. B)).
--
-- SUBSTR returns a substring of a VSTRING taken from a given
-- index and extending a given length.
--
-- The DELETE function returns the VSTRING which results from
-- removing the slice between two indices.
--
-- EDITING FUNCTIONS: INSERT, APPEND, REPLACE
-- The editing functions return the VSTRING which results from
-- inserting, appending, or replacing at a given index with a
-- VSTRING, STRING, or CHARACTER. The index must be in the
-- current range of the VSTRING; i.e., zero cannot be used.
--
-- CONCATENATION OPERATOR: "&"
-- The concatenation operator is the same as for the type
-- STRING. It should be used instead of APPEND when the
-- APPEND would always be after the last character.
--
-- POSITION FUNCTIONS: INDEX, RINDEX
-- The position functions return an index to the Nth occurrence
-- of a VSTRING, STRING, or CHARACTER from the front or back
-- of a VSTRING. Zero is returned if the search is not
-- successful.
--
-- CONVERSION FUNCTIONS AND OPERATOR: VSTR, CONVERT, "+"
-- VSTR converts a STRING or a CHARACTER to a VSTRING.
--
-- CONVERT is a generic function which can be instantiated to
-- convert from any given variable-length string to another,
-- provided the FROM type has a function equivelent to STR
-- defined for it, and that the TO type has a function equiv-
-- elent to VSTR defined for it. This provides a means for
-- converting between VSTRINGs declared in separate instant-
-- iations of VSTRINGS. When instantiating CONVERT for
-- VSTRINGs, the STR and VSTR functions are implicitly defined,
-- provided that they have been made visible (by a use clause).
--
-- Note: CONVERT is NOT implicitly associated with the type
-- VSTRING declared in this package (since it would not be a
-- derivable function (see RM 3.4(11))).
--
-- Caution: CONVERT cannot be instantiated directly with the
-- names VSTR and STR, since the name of the subprogram being
-- declared would hide the generic parameters with the same
-- names (see RM 8.3(16)). CONVERT can be instantiated with
-- the operator "+", and any instantiation of CONVERT can
-- subsequently be renamed VSTR or STR.
--
-- Example: Given two VSTRINGS instantiations X and Y:
-- function "+" is new X.CONVERT(X.VSTRING, Y.VSTRING);
-- function "+" is new X.CONVERT(Y.VSTRING, X.VSTRING);
--
-- (Y.CONVERT could have been used in place of X.CONVERT)
--
-- function VSTR(A : X.VSTRING) return Y.VSTRING renames "+";
-- function VSTR(A : Y.VSTRING) return X.VSTRING renames "+";
--
-- "+" is equivelent to VSTR. It is supplied as a short-hand
-- notation for the function. The "+" operator cannot immed-
-- iately follow the "&" operator; use ... & (+ ...) instead.
pragma PAGE;
-- DISCUSSION:
--
-- This package implements the type "variable-length string" (vstring)
-- using generics. The alternative approaches are to use a discriminant
-- record in which the discriminant controls the length of a STRING inside
-- the record, or a record containing an access type which points to a
-- string, which can be deallocated and reallocated when necessary.
--
-- Advantages of this package:
-- * The other approaches force the vstring to be a limited private
-- type. Thus, their vstrings cannot appear on the left side of
-- the assignment operator; ie., their vstrings cannot be given
-- initial values or values by direct assignment. This package
-- uses a private type; therefore, these things can be done.
--
-- * The other approach stores the vstring in a string whose length
-- is determined dynamically. This package uses a fixed length
-- string. This difference might be reflected in faster and more
-- consistent execution times (this has NOT been verified).
--
-- Disadvantages of this package:
-- * Different instantiations must be used to declare vstrings with
-- different maximum lengths (this may be desirable, since
-- CONSTRAINT_ERROR will be raised if the maximum is exceeded).
--
-- * A second declaration is required to give the type declared by
-- the instantiation a name other than "VSTRING."
--
-- * The storage required for a vstring is determined by the generic
-- parameter LAST and not the actual length of its contents. Thus,
-- each object is allocated the maximum amount of storage, regardless
-- of its actual size.
--
-- MISCELLANEOUS:
-- Constraint checking is done explicitly in the code; thus, it cannot
-- be suppressed. On the other hand, constraint checking is not lost
-- if pragma suppress is supplied to the compilation (-S option)
-- (The robustness of the explicit constraint checking has NOT been
-- determined).
--
-- Compiling with the optimizer (-O option) may significantly reduce
-- the size (and possibly execution time) of the resulting executable.
--
-- Compiling an instantiation of VSTRINGS is roughly equivelent to
-- recompiling VSTRINGS. Since this takes a significant amount of time,
-- and the instantiation does not depend on any other library units,
-- it is STRONGLY recommended that the instantiation be compiled
-- separately, and thus done only ONCE.
--
-- USAGE: with VSTRINGS;
-- package package_name is new VSTRINGS(maximum_length);
-- .......................................................................... --
pragma PAGE;
package body vstrings is
-- local declarations
FILL_CHAR : constant CHARACTER := ASCII.NUL;
-- procedure FORMAT(THE_STRING : in out VSTRING; OLDLEN : in STRINDEX := LAST) is
-- -- fill the string with FILL_CHAR to null out old values
-- begin -- FORMAT (Local Procedure)
-- THE_STRING.VALUE(THE_STRING.LEN + 1 .. OLDLEN) :=
-- (others => FILL_CHAR);
-- end FORMAT;
-- CvdL: the above assignment will be compiled wrongly with gcc-2.6.0
-- and gnat-1.83. It overwrites parts if the runtime stack by writing
-- fill_char for a fixed amount(?) of times.
-- Maybe the error is in the caller... it is called FORMAT(Str, 0)!!!
-- The following procedure is far from optimal but it doesn't break
-- NOTE: gcc-2.6.2 and gnat-2.00 do it wrong too!
procedure FORMAT(THE_STRING : in out VSTRING; OLDLEN : in STRINDEX := LAST)
is
-- fill the string with FILL_CHAR to null out old values
begin -- FORMAT (Local Procedure)
for I in the_string.len+1..oldlen loop
THE_STRING.VALUE(I) := FILL_CHAR;
end loop;
end FORMAT;
-- bodies of visible operations
function LEN(FROM : VSTRING) return STRINDEX is
begin -- LEN
return(FROM.LEN);
end LEN;
function MAX(FROM : VSTRING) return STRINDEX is
begin -- MAX
return(LAST);
end MAX;
function STR(FROM : VSTRING) return STRING is
begin -- STR
return(FROM.VALUE(FIRST .. FROM.LEN));
end STR;
function CHAR(FROM : VSTRING; POSITION : STRINDEX := FIRST)
return CHARACTER is
begin -- CHAR
if POSITION not in FIRST .. FROM.LEN
then raise CONSTRAINT_ERROR;
end if;
return(FROM.VALUE(POSITION));
end CHAR;
function "<" (LEFT: VSTRING; RIGHT: VSTRING) return BOOLEAN is
begin -- "<"
return(LEFT.VALUE < RIGHT.VALUE);
end "<";
function ">" (LEFT: VSTRING; RIGHT: VSTRING) return BOOLEAN is
begin -- ">"
return(LEFT.VALUE > RIGHT.VALUE);
end ">";
function "<=" (LEFT: VSTRING; RIGHT: VSTRING) return BOOLEAN is
begin -- "<="
return(LEFT.VALUE <= RIGHT.VALUE);
end "<=";
function ">=" (LEFT: VSTRING; RIGHT: VSTRING) return BOOLEAN is
begin -- ">="
return(LEFT.VALUE >= RIGHT.VALUE);
end ">=";
procedure PUT(FILE : in FILE_TYPE; ITEM : in VSTRING) is
begin -- PUT
PUT(FILE, ITEM.VALUE(FIRST .. ITEM.LEN));
end PUT;
procedure Put(ITEM : in VSTRING) is
begin -- PUT
PUT(ITEM.VALUE(FIRST .. ITEM.LEN));
end PUT;
procedure PUT_LINE(FILE : in FILE_TYPE; ITEM : in VSTRING) is
begin -- PUT_LINE
PUT_LINE(FILE, ITEM.VALUE(FIRST .. ITEM.LEN));
end PUT_LINE;
procedure PUT_LINE(ITEM : in VSTRING) is
begin -- PUT_LINE
PUT_LINE(ITEM.VALUE(FIRST .. ITEM.LEN));
end PUT_LINE;
procedure GET(FILE : in FILE_TYPE; ITEM : out VSTRING;
LENGTH : in STRINDEX := LAST) is
begin -- GET
if LENGTH not in FIRST .. LAST
then raise CONSTRAINT_ERROR;
end if;
ITEM := NUL;
for INDEX in FIRST .. LENGTH loop
GET(FILE, ITEM.VALUE(INDEX));
ITEM.LEN := INDEX;
end loop;
end GET;
procedure GET(ITEM : out VSTRING; LENGTH : in STRINDEX := LAST) is
begin -- GET
if LENGTH not in FIRST .. LAST
then raise CONSTRAINT_ERROR;
end if;
ITEM := NUL;
for INDEX in FIRST .. LENGTH loop
GET(ITEM.VALUE(INDEX));
ITEM.LEN := INDEX;
end loop;
end GET;
procedure GET_LINE(FILE : in FILE_TYPE; ITEM : in out VSTRING) is
OLDLEN : constant STRINDEX := ITEM.LEN;
begin -- GET_LINE
GET_LINE(FILE, ITEM.VALUE, ITEM.LEN);
FORMAT(ITEM, OLDLEN);
end GET_LINE;
procedure GET_LINE(ITEM : in out VSTRING) is
OLDLEN : constant STRINDEX := ITEM.LEN;
begin -- GET_LINE
GET_LINE(ITEM.VALUE, ITEM.LEN);
FORMAT(ITEM, OLDLEN);
end GET_LINE;
function SLICE(FROM : VSTRING; FRONT, BACK : STRINDEX) return VSTRING is
begin -- SLICE
if ((FRONT not in FIRST .. FROM.LEN) or else
(BACK not in FIRST .. FROM.LEN)) and then FRONT <= BACK
then raise CONSTRAINT_ERROR;
end if;
return(Vstr(FROM.VALUE(FRONT .. BACK)));
end SLICE;
function SUBSTR(FROM : VSTRING; START, LENGTH : STRINDEX) return VSTRING is
begin -- SUBSTR
if (START not in FIRST .. FROM.LEN) or else
((START + LENGTH - 1 not in FIRST .. FROM.LEN)
and then (LENGTH > 0))
then raise CONSTRAINT_ERROR;
end if;
return(Vstr(FROM.VALUE(START .. START + LENGTH -1)));
end SUBSTR;
function DELETE(FROM : VSTRING; FRONT, BACK : STRINDEX) return VSTRING is
TEMP : VSTRING := FROM;
begin -- DELETE
if ((FRONT not in FIRST .. FROM.LEN) or else
(BACK not in FIRST .. FROM.LEN)) and then FRONT <= BACK
then raise CONSTRAINT_ERROR;
end if;
if FRONT > BACK then return(FROM); end if;
TEMP.LEN := FROM.LEN - (BACK - FRONT) - 1;
TEMP.VALUE(FRONT .. TEMP.LEN) := FROM.VALUE(BACK + 1 .. FROM.LEN);
FORMAT(TEMP, FROM.LEN);
return(TEMP);
end DELETE;
function INSERT(TARGET: VSTRING; ITEM: VSTRING;
POSITION : STRINDEX := FIRST) return VSTRING is
TEMP : VSTRING;
begin -- INSERT
if POSITION not in FIRST .. TARGET.LEN
then raise CONSTRAINT_ERROR;
end if;
if TARGET.LEN + ITEM.LEN > LAST
then raise CONSTRAINT_ERROR;
else TEMP.LEN := TARGET.LEN + ITEM.LEN;
end if;
TEMP.VALUE(FIRST .. POSITION - 1) := TARGET.VALUE(FIRST .. POSITION - 1);
TEMP.VALUE(POSITION .. (POSITION + ITEM.LEN - 1)) :=
ITEM.VALUE(FIRST .. ITEM.LEN);
TEMP.VALUE((POSITION + ITEM.LEN) .. TEMP.LEN) :=
TARGET.VALUE(POSITION .. TARGET.LEN);
return(TEMP);
end INSERT;
function INSERT(TARGET: VSTRING; ITEM: STRING;
POSITION : STRINDEX := FIRST) return VSTRING is
begin -- INSERT
return INSERT(TARGET, VSTR(ITEM), POSITION);
end INSERT;
function INSERT(TARGET: VSTRING; ITEM: CHARACTER;
POSITION : STRINDEX := FIRST) return VSTRING is
begin -- INSERT
return INSERT(TARGET, VSTR(ITEM), POSITION);
end INSERT;
function APPEND(TARGET: VSTRING; ITEM: VSTRING; POSITION : STRINDEX)
return VSTRING is
TEMP : VSTRING;
POS : STRINDEX := POSITION;
begin -- APPEND
if POSITION not in FIRST .. TARGET.LEN
then raise CONSTRAINT_ERROR;
end if;
if TARGET.LEN + ITEM.LEN > LAST
then raise CONSTRAINT_ERROR;
else TEMP.LEN := TARGET.LEN + ITEM.LEN;
end if;
TEMP.VALUE(FIRST .. POS) := TARGET.VALUE(FIRST .. POS);
TEMP.VALUE(POS + 1 .. (POS + ITEM.LEN)) := ITEM.VALUE(FIRST .. ITEM.LEN);
TEMP.VALUE((POS + ITEM.LEN + 1) .. TEMP.LEN) :=
TARGET.VALUE(POS + 1 .. TARGET.LEN);
return(TEMP);
end APPEND;
function APPEND(TARGET: VSTRING; ITEM: STRING; POSITION : STRINDEX)
return VSTRING is
begin -- APPEND
return APPEND(TARGET, VSTR(ITEM), POSITION);
end APPEND;
function APPEND(TARGET: VSTRING; ITEM: CHARACTER; POSITION : STRINDEX)
return VSTRING is
begin -- APPEND
return APPEND(TARGET, VSTR(ITEM), POSITION);
end APPEND;
function APPEND(TARGET: VSTRING; ITEM: VSTRING) return VSTRING is
begin -- APPEND
return(APPEND(TARGET, ITEM, TARGET.LEN));
end APPEND;
function APPEND(TARGET: VSTRING; ITEM: STRING) return VSTRING is
begin -- APPEND
return(APPEND(TARGET, VSTR(ITEM), TARGET.LEN));
end APPEND;
function APPEND(TARGET: VSTRING; ITEM: CHARACTER) return VSTRING is
begin -- APPEND
return(APPEND(TARGET, VSTR(ITEM), TARGET.LEN));
end APPEND;
function REPLACE(TARGET: VSTRING; ITEM: VSTRING;
POSITION : STRINDEX := FIRST) return VSTRING is
TEMP : VSTRING;
begin -- REPLACE
if POSITION not in FIRST .. TARGET.LEN
then raise CONSTRAINT_ERROR;
end if;
if POSITION + ITEM.LEN - 1 <= TARGET.LEN
then TEMP.LEN := TARGET.LEN;
elsif POSITION + ITEM.LEN - 1 > LAST
then raise CONSTRAINT_ERROR;
else TEMP.LEN := POSITION + ITEM.LEN - 1;
end if;
TEMP.VALUE(FIRST .. POSITION - 1) := TARGET.VALUE(FIRST .. POSITION - 1);
TEMP.VALUE(POSITION .. (POSITION + ITEM.LEN - 1)) :=
ITEM.VALUE(FIRST .. ITEM.LEN);
TEMP.VALUE((POSITION + ITEM.LEN) .. TEMP.LEN) :=
TARGET.VALUE((POSITION + ITEM.LEN) .. TARGET.LEN);
return(TEMP);
end REPLACE;
function REPLACE(TARGET: VSTRING; ITEM: STRING;
POSITION : STRINDEX := FIRST) return VSTRING is
begin -- REPLACE
return REPLACE(TARGET, VSTR(ITEM), POSITION);
end REPLACE;
function REPLACE(TARGET: VSTRING; ITEM: CHARACTER;
POSITION : STRINDEX := FIRST) return VSTRING is
begin -- REPLACE
return REPLACE(TARGET, VSTR(ITEM), POSITION);
end REPLACE;
function "&"(LEFT:VSTRING; RIGHT : VSTRING) return VSTRING is
TEMP : VSTRING;
begin -- "&"
if LEFT.LEN + RIGHT.LEN > LAST
then raise CONSTRAINT_ERROR;
else TEMP.LEN := LEFT.LEN + RIGHT.LEN;
end if;
TEMP.VALUE(FIRST .. TEMP.LEN) := LEFT.VALUE(FIRST .. LEFT.LEN) &
RIGHT.VALUE(FIRST .. RIGHT.LEN);
return(TEMP);
end "&";
function "&"(LEFT:VSTRING; RIGHT : STRING) return VSTRING is
begin -- "&"
return LEFT & VSTR(RIGHT);
end "&";
function "&"(LEFT:VSTRING; RIGHT : CHARACTER) return VSTRING is
begin -- "&"
return LEFT & VSTR(RIGHT);
end "&";
function "&"(LEFT : STRING; RIGHT : VSTRING) return VSTRING is
begin -- "&"
return VSTR(LEFT) & RIGHT;
end "&";
function "&"(LEFT : CHARACTER; RIGHT : VSTRING) return VSTRING is
begin -- "&"
return VSTR(LEFT) & RIGHT;
end "&";
Function INDEX(WHOLE : VSTRING; PART : VSTRING; OCCURRENCE : NATURAL := 1)
return STRINDEX is
NOT_FOUND : constant NATURAL := 0;
INDEX : NATURAL := FIRST;
COUNT : NATURAL := 0;
begin -- INDEX
if PART = NUL then return(NOT_FOUND); -- by definition
end if;
while INDEX + PART.LEN - 1 <= WHOLE.LEN and then COUNT < OCCURRENCE loop
if WHOLE.VALUE(INDEX .. PART.LEN + INDEX - 1) =
PART.VALUE(1 .. PART.LEN)
then COUNT := COUNT + 1;
end if;
INDEX := INDEX + 1;
end loop;
if COUNT = OCCURRENCE
then return(INDEX - 1);
else return(NOT_FOUND);
end if;
end INDEX;
Function INDEX(WHOLE : VSTRING; PART : STRING; OCCURRENCE : NATURAL := 1)
return STRINDEX is
begin -- Index
return(Index(WHOLE, VSTR(PART), OCCURRENCE));
end INDEX;
Function INDEX(WHOLE : VSTRING; PART : CHARACTER; OCCURRENCE : NATURAL := 1)
return STRINDEX is
begin -- Index
return(Index(WHOLE, VSTR(PART), OCCURRENCE));
end INDEX;
function RINDEX(WHOLE: VSTRING; PART:VSTRING; OCCURRENCE:NATURAL := 1)
return STRINDEX is
NOT_FOUND : constant NATURAL := 0;
INDEX : INTEGER := WHOLE.LEN - (PART.LEN -1);
COUNT : NATURAL := 0;
begin -- RINDEX
if PART = NUL then return(NOT_FOUND); -- by definition
end if;
while INDEX >= FIRST and then COUNT < OCCURRENCE loop
if WHOLE.VALUE(INDEX .. PART.LEN + INDEX - 1) =
PART.VALUE(1 .. PART.LEN)
then COUNT := COUNT + 1;
end if;
INDEX := INDEX - 1;
end loop;
if COUNT = OCCURRENCE
then
if COUNT > 0
then return(INDEX + 1);
else return(NOT_FOUND);
end if;
else return(NOT_FOUND);
end if;
end RINDEX;
Function RINDEX(WHOLE : VSTRING; PART : STRING; OCCURRENCE : NATURAL := 1)
return STRINDEX is
begin -- Rindex
return(RINDEX(WHOLE, VSTR(PART), OCCURRENCE));
end RINDEX;
Function RINDEX(WHOLE : VSTRING; PART : CHARACTER; OCCURRENCE : NATURAL := 1)
return STRINDEX is
begin -- Rindex
return(RINDEX(WHOLE, VSTR(PART), OCCURRENCE));
end RINDEX;
function VSTR(FROM : CHARACTER) return VSTRING is
TEMP : VSTRING;
begin -- VSTR
if LAST < 1
then raise CONSTRAINT_ERROR;
else TEMP.LEN := 1;
end if;
TEMP.VALUE(FIRST) := FROM;
return(TEMP);
end VSTR;
function VSTR(FROM : STRING) return VSTRING is
TEMP : VSTRING;
begin -- VSTR
if FROM'LENGTH > LAST
then raise CONSTRAINT_ERROR;
else TEMP.LEN := FROM'LENGTH;
end if;
TEMP.VALUE(FIRST .. FROM'LENGTH) := FROM;
return(TEMP);
end VSTR;
Function "+" (FROM : STRING) return VSTRING is
begin -- "+"
return(VSTR(FROM));
end "+";
Function "+" (FROM : CHARACTER) return VSTRING is
begin
return(VSTR(FROM));
end "+";
function CONVERT(X : FROM) return TO is
begin -- CONVERT
return(VSTR(STR(X)));
end CONVERT;
end vstrings;
-- .......................................................................... --
--
-- DISTRIBUTION AND COPYRIGHT:
--
-- This software is released to the Public Domain (note:
-- software released to the Public Domain is not subject
-- to copyright protection).
-- Restrictions on use or distribution: NONE
--
-- DISCLAIMER:
--
-- This software and its documentation are provided "AS IS" and
-- without any expressed or implied warranties whatsoever.
-- No warranties as to performance, merchantability, or fitness
-- for a particular purpose exist.
--
-- Because of the diversity of conditions and hardware under
-- which this software may be used, no warranty of fitness for
-- a particular purpose is offered. The user is advised to
-- test the software thoroughly before relying on it. The user
-- must assume the entire risk and liability of using this
-- software.
--
-- In no event shall any person or organization of people be
-- held responsible for any direct, indirect, consequential
-- or inconsequential damages or lost profits.
|
utils/hardware/serial2/term.asm | vbmacher/qsOS | 1 | 25224 | <gh_stars>1-10
model small
dosseg
INTNUM equ 0Ch ; COM1; COM2: 0Bh
OFFMASK equ 00010000b ; COM1; COM2: 00001000b
ONMASK equ not OFFMASK
UART_BASE equ 3F8h ; COM1; COM2: 2F8h
UART_RATE equ 12 ; 9600 bps, see table in this file
UART_PARAMS equ 00000011b ; 8n1, see tables
RXFIFOSIZE equ 8096 ; set this to your needs
TXFIFOSIZE equ 8096 ; dito.
; the fifos must be large on slow computers
; and can be small on fast ones
; These have nothing to do with the 16550A's
; built-in FIFOs!
.data
long_text db 0dh
db "This is a very long test string. It serves the purpose of",0dh
db "demonstrating that our interrupt-driven routines are capable",0dh
db "of coping with pressure situations like the one we provoke",0dh
db "by sending large bunches of characters in each direction at",0dh
db "the same time. Run this test by pressing F1 at a low data",0dh
db "rate and a high data rate to see why serial transmission and",0dh
db "reception should be programmed interrupt-driven. You won't lose",0dh
db "a single character as long as you don't overload the fifos, no",0dh
db "matter how hard you try!",0dh,0
ds_dgroup macro
mov ax,DGROUP
mov ds,ax
assume ds:DGROUP
endm
ds_text macro
push cs
pop ds
assume ds:_TEXT
endm
rx_checkwrap macro
local rx_nowrap
cmp si,offset rxfifo+RXFIFOSIZE
jb rx_nowrap
lea si,rxfifo
rx_nowrap:
endm
tx_checkwrap macro
local tx_nowrap
cmp si,offset txfifo+TXFIFOSIZE
jb tx_nowrap
lea si,txfifo
tx_nowrap:
endm
.stack 256
.data?
old_intptr dd ?
rxhead dw ?
rxtail dw ?
txhead dw ?
txtail dw ?
bitxfifo dw 1 ; size of built-in TX fifo (1 if no fifo)
rxfifo db RXFIFOSIZE dup (?)
txfifo db TXFIFOSIZE dup (?)
.code
start proc far
call install_interrupt_handler
call clear_fifos
call clear_screen
call init_UART
continue:
call read_RX_fifo
call read_keyboard
jnc continue
call clean_up
mov ax,4c00h
int 21h ; return to DOS
start endp
interrupt_handler proc far
assume ds:nothing,es:nothing,ss:nothing,cs:_text
push ax
push cx
push dx ; first save the regs we need to change
push ds
push si
in al,21h
or al,OFFMASK ; disarm the interrupt
out 21h,al
mov al,20h ; acknowledge interrupt
out 20h,al
ih_continue:
mov dx,UART_BASE+2
xor ax,ax
in al,dx ; get interrupt cause
test al,1 ; did the UART generate the int?
jne ih_sep ; no, then it's somebody else's problem
and al,6 ; mask bits not needed
mov si,ax ; make a pointer out of it
call interrupt_table[si] ; serve this int
jmp ih_continue ; and look for more things to be done
ih_sep:
in al,21h
and al,ONMASK ; rearm the interrupt
out 21h,al
pop si
pop ds
pop dx ; restore regs
pop cx
pop ax
iret
interrupt_table dw int_modem,int_tx,int_rx,int_status
interrupt_handler endp
int_modem proc near
; just clear modem status, we are not interested in it
mov dx,UART_BASE+6
in al,dx
ret
int_modem endp
int_tx proc near
ds_dgroup
; check if there's something to be sent
mov si,txtail
mov cx,bitxfifo
itx_more:
cmp si,txhead
je itx_nothing
cld
lodsb
mov dx,UART_BASE
out dx,al ; write it to the THR
; check for wrap-around in our fifo
tx_checkwrap
; send as much bytes as the chip can take when available
loop itx_more
jmp itx_dontstop
itx_nothing:
; no more data in the fifo, so inhibit TX interrupts
mov dx,UART_BASE+1
mov al,00000001b
out dx,al
itx_dontstop:
mov txtail,si
ret
int_tx endp
int_rx proc near
ds_dgroup
mov si,rxhead
irx_more:
mov dx,UART_BASE
in al,dx
mov byte ptr [si],al
inc si
; check for wrap-around
rx_checkwrap
; see if there are more bytes to be read
mov dx,UART_BASE+5
in al,dx
test al,1
jne irx_more
mov rxhead,si
test al,40h ; Sometimes when sending and receiving at the
jne int_tx ; same time, TX ints get lost. This is a cure.
ret
int_rx endp
int_status proc near
; just clear the status ("this trivial task is left as an exercise
; to the student")
mov dx,UART_BASE+5
in al,dx
ret
int_status endp
read_RX_fifo proc near
; see if there are bytes to be read from the fifo
; we read a maximum of 16 bytes, then return in order
; not to break keyboard control
ds_dgroup
cld
mov cx,16
mov si,rxtail
rx_more:
cmp si,rxhead
je rx_nodata
lodsb
call output_char
; check for wrap-around
rx_checkwrap
loop rx_more
rx_nodata:
mov rxtail,si
ret
read_RX_fifo endp
read_keyboard proc near
ds_dgroup
; check for keys pressed
mov ah,1
int 16h
je rk_nokey
xor ax,ax
int 16h
cmp ax,2d18h ; is it Ctrl-X?
stc
je rk_ctrlx
cmp ax,3b00h ; is it F1?
jne rk_nf1
lea si,long_text ; send a very long test string
call send_string
jmp rk_nokey
rk_nf1:
; echo the character to the screen
call output_char
call send_char
rk_nokey:
clc
rk_ctrlx:
ret
read_keyboard endp
install_interrupt_handler proc near
ds_dgroup
; install interrupt handler first
mov ax,3500h+INTNUM
int 21h
mov word ptr old_intptr,bx
mov word ptr old_intptr+2,es
mov ax,2500h+INTNUM
ds_text
lea dx,interrupt_handler
int 21h
ret
install_interrupt_handler endp
clear_fifos proc near
ds_dgroup
; clear fifos (not those in the 16550A, but ours)
lea ax,rxfifo
mov rxhead,ax
mov rxtail,ax
lea ax,txfifo
mov txhead,ax
mov txtail,ax
ret
clear_fifos endp
init_UART proc near
; initialize the UART
mov dx,UART_BASE+3
mov al,80h
out dx,al ; make DL register accessible
mov dx,UART_BASE
mov ax,UART_RATE
out dx,ax ; write bps rate divisor
mov dx,UART_BASE+3
mov al,UART_PARAMS
out dx,al ; write parameters
; is it a 16550A?
mov dx,UART_BASE+2
in al,dx
and al,11000000b
cmp al,11000000b
jne iu_nofifos
mov bitxfifo,16
mov dx,UART_BASE+2
mov al,11000111b
out dx,al ; clear and enable the fifos if they exist
iu_nofifos:
mov dx,UART_BASE+1
mov al,00000001b ; allow RX interrupts
out dx,al
mov dx,UART_BASE
in al,dx ; clear receiver
mov dx,UART_BASE+5
in al,dx ; clear line status
inc dx
in al,dx ; clear modem status
; free interrupt in the ICU
in al,21h
and al,ONMASK
out 21h,al
; and enable ints from the UART
mov dx,UART_BASE+4
mov al,00001000b
out dx,al
ret
init_UART endp
clear_screen proc near
mov ah,0fh ; allow all kinds of video adapters to be used
int 10h
cmp al,7
je cs_1
mov al,3
cs_1:
xor ah,ah
int 10h
ret
clear_screen endp
clean_up proc near
ds_dgroup
; lock int in the ICU
in al,21h
or al,OFFMASK
out 21h,al
xor ax,ax
mov dx,UART_BASE+4 ; disconnect the UART from the int line
out dx,al
mov dx,UART_BASE+1 ; disable UART ints
out dx,al
mov dx,UART_BASE+2 ; disable the fifos (old software relies on it)
out dx,al
; restore int vector
lds dx,old_intptr
mov ax,2500h+INTNUM
int 21h
ret
clean_up endp
output_char proc near
push si
push ax
oc_cr:
push ax
mov ah,0eh ; output character using BIOS TTY
int 10h ; it's your task to improve this
pop ax
cmp al,0dh ; add LF after CR; change it if you don't like it
mov al,0ah
je oc_cr
pop ax
pop si
ret
output_char endp
send_char proc near
push si
push ax
ds_dgroup
pop ax
mov si,txhead
mov byte ptr [si],al
inc si
; check for wrap-around
tx_checkwrap
mov txhead,si
; test if the interrupt is running at the moment
mov dx,UART_BASE+5
in al,dx
test al,40h
je sc_dontcrank
; crank it up
; note that this might not work with some very old 8250s
mov dx,UART_BASE+1
mov al,00000011b
out dx,al
sc_dontcrank:
pop si
ret
send_char endp
send_string proc near
; sends a null-terminated string pointed at by DS:SI
ds_dgroup
cld
ss_more:
lodsb
or al,al
je ss_end
call send_char
jmp ss_more
ss_end:
ret
send_string endp
end start
|
oeis/339/A339576.asm | neoneye/loda-programs | 11 | 96922 | ; A339576: Row sums of triangle A236104.
; Submitted by <NAME>
; 1,4,10,17,29,41,59,74,101,121,151,179,215,245,295,326,374,423,477,519,591,641,707,767,844,904,1000,1056,1140,1234,1324,1387,1507,1587,1701,1794,1902,1992,2136,2226,2346,2476,2602,2692,2874,2984,3122,3246,3397
add $0,1
mov $2,$0
lpb $0
mov $3,$2
add $4,1
sub $2,$4
mov $0,$2
div $3,$4
pow $3,2
add $1,$3
lpe
mov $0,$1
|
Automaton/Deterministic/Finite.agda | Lolirofle/stuff-in-agda | 6 | 16729 | <filename>Automaton/Deterministic/Finite.agda
import Lvl
open import Structure.Setoid
open import Type
module Automaton.Deterministic.Finite where
open import Automaton.Deterministic
open import Data.Boolean
open import Data.Boolean.Stmt
open import Data.List renaming (∅ to ε ; _⊰_ to _·_)
open import Data.List.Setoid
open import Data.List.Functions using (postpend ; _++_)
open import Data.List.Proofs
open import Functional
open import Logic.Propositional
open import Logic
open import Sets.ExtensionalPredicateSet using (PredSet ; intro ; _∈_ ; _∋_ ; ⊶ ; [∋]-binaryRelator)
import Structure.Function.Names as Names
open import Structure.Operator
open import Structure.Relator.Properties
open import Type.Size.Finite
private variable ℓₚ ℓₛ ℓₑ₁ ℓₐ ℓₑ₂ : Lvl.Level
module _
{ℓₚ}
(State : Type{ℓₛ}) ⦃ equiv-state : Equiv{ℓₑ₁}(State) ⦄
(Alphabet : Type{ℓₐ}) ⦃ equiv-alphabet : Equiv{ℓₑ₂}(Alphabet) ⦄
where
record DFA : Type{ℓₛ Lvl.⊔ ℓₑ₁ Lvl.⊔ ℓₑ₂ Lvl.⊔ ℓₐ Lvl.⊔ Lvl.𝐒(ℓₚ)} where
field
⦃ State-finite ⦄ : Finite(State)
⦃ Alphabet-finite ⦄ : Finite(Alphabet)
automata : Deterministic{ℓₚ = ℓₚ}(State)(Alphabet)
open Deterministic(automata) hiding (transitionedAutomaton ; wordTransitionedAutomaton) public
transitionedAutomaton : Alphabet → DFA
transitionedAutomaton c = record{automata = Deterministic.transitionedAutomaton(automata) c}
wordTransitionedAutomaton : Word → DFA
wordTransitionedAutomaton w = record{automata = Deterministic.wordTransitionedAutomaton(automata) w}
postulate isFinal : State → Bool
postulate isFinal-correctness : ∀{s} → IsTrue(isFinal s) ↔ (s ∈ Final)
isWordAccepted : Word → Bool
isWordAccepted(w) = isFinal(wordTransition(start)(w))
pattern dfa {fin-Q} {fin-Σ} δ {δ-op} q₀ F = record{State-finite = fin-Q ; Alphabet-finite = fin-Σ ; automata = deterministic δ ⦃ δ-op ⦄ q₀ F}
|
programs/oeis/067/A067462.asm | neoneye/loda | 22 | 28930 | ; A067462: a(n) = (1! + 2! + ... + (n-1)!) mod n.
; 0,1,0,1,3,3,5,1,0,3,0,9,9,5,3,9,12,9,8,13,12,11,20,9,13,9,9,5,16,3,1,25,0,29,33,9,4,27,9,33,3,33,15,33,18,43,17,9,47,13,12,9,12,9,33,33,27,45,27,33,21,1,54,25,48,33,64,29,66,33,67,9,54,41,63,65,33,9,19,73,63,3,26,33,63,15,45,33,75,63,61,89,63,17,8,57,79,47,0,13
add $0,1
mov $2,$0
lpb $0
add $1,1
mul $1,$0
sub $0,1
mod $1,$2
lpe
mov $0,$1
|
laby_functions.ads | thieryw/labyrinth | 0 | 17829 | <filename>laby_functions.ads
package laby_functions is
type point is
record
x,y : float ;
end record ;
type node is private ;
type tree is access node ;
function maze_random(W,H : integer) return Tree ;
procedure maze_svg(maze : tree ; file_name : string) ;
procedure show_tree_content(maze : tree ; index : integer) ;
procedure solution_svg(m : tree ; file_name : string) ;
private
type wall_type is (vertical,horizontal,no_wall) ;
type node is
record
wall : wall_type ;
left_child : tree ;
right_child : tree ;
x,y : natural ;
width,height : natural ;
wall_offset : natural ;
door_offset : natural ;
end record ;
end laby_functions ;
|
MSDOS/Virus.MSDOS.Unknown.tboot.asm | fengjixuchui/Family | 3 | 91590 | ;This is a disassembly of Thunderbyte's anti-viral partition code.
;An org statement was not used because it appears that all offsets used
;herein are either relative or absolute, i.e. it just doesn't matter.
;This should be compiled as a binary image file, it *WILL NOT* create
;an executable file. This code is exactly 512 bytes long and should be
;implanted into the hard drive at physical sector 1, cylinder 0, head 0
;using the BIOS direct write to disk function. *DO NOT* use DOS write to
;disk functions or DEBUG because these functions can't access hidden sectors
;and you'll probably just overwrite the disk drive.
;have fun, folks!
code_start:
cli ;no interrupts
xor cx, cx
mov ss, cx
mov sp, 7c00h
mov si, sp
sti
cld
mov es, cx ;cs already equals 0
mov ds, cx
mov di, 0600h ;
mov ch, 01 ;cx = 100h
repz movsw ;mov 200h bytes from 0000:7c00h to 0000:0600h
;to make room for boot sector
jump_pt db 0e9h, 00, 8ah ;this will act like far jmp to first_pt label
;i.e. 0000:061ah, wraps around segment
first_pt: ;when execution continues, this will be offset
;061ah here
mov si, 06ddh
call routine_1
mov si, 07eeh
call routine_2
mov bp, si
mov si, 0733h
jb second_pt
mov bx, sp ;buffer at stack pointer (7c00h?)
mov ax, 0201h ;func 2, 1 sector - possibily boot sector?
int 13h ;BIOS read sector
mov si, 0725h
second_pt:
jb sixth_pt
mov si, 745h
call routine_1
call routine_1
mov si, 7c40h
mov cx, 01c0h
loop_1:
xchg ax, bx
shl bx, 1
lodsb ;from 0000:7c40h
add ax, bx
mov ah, bh
test ah, ah
jns third_pt
xor ax, 0a097h
third_pt:
loop loop_1
cmp ax, 7805h
jnz fourth_pt
mov si, 0740h
call routine_1
mov si, 0762h
call 01cdh
mov dx, [si + 0fc9fh]
cmp dx, 27eh
jb fourth_pt
mov si, 740h
call routine_1
mov si, 774h
call routine_1
les ax, [004c]
mov bx, es
mov cl, 04
shr ax, cl
add ax, bx
inc cx
inc cx
shl dx, cl
cmp ax, dx
jnb fifth_pt
fourth_pt:
mov si, 0787h
call routine_1
int 16h
mov si, 783h
or al, 20h
cmp al, 79h
jnz seventh_pt
fifth_pt:
call routine_1
mov si, bp
mov dx, [si]
jmp sp ;control goes to boot sector
sixth_pt:
call routine_1
int 16h
seventh_pt:
int 18h ;rom BASIC!
eighth_pt:
jmp eighth_pt ;infinite loop Lock Up!
routine_2:
lea di, [si - 30h]
boot_chk:
cmp byte ptr [si], 80h ;looks like check for bootable parttn
jz bootable
sub si, 10h
cmp si, di
jnb boot_chk
ret
bootable:
mov dx, [si]
mov cx, [si + 2]
return_pt:
ret
routine_1:
lodsb
cbw ;convert to word
test ax, ax ;huh?
jz return_pt ;like ret to original caller
mov ah, 0eh
xor bx, bx
push si
int 10h
pop si
jmp routine_1
code_end:
msg1 db 13, 10, "Thunderbyte anti-virus partition "
db "v6.24 (C) 1993-94 Thunderbyte BV.", 13, 10, 10, 0
msg2 db "Disk error!", 13, 10, 00
msg3 db "No system!", 13, 10, 00
msg4 db "OK!", 13, 10,"Checking ",0
msg5 db "bootsector CRC -> ",0
msg6 db "available RAM -> ",0
msg7 db "INT 13h -> ",0
msg8 db "OK!",13, 10, 10, 0
msg9 db "Failed!", 13, 10, "System might be infected. Continue? (N/Y)", 07, 0
misc db 0, 0, 0, 80h, 01h, 01, 0, 06, 0dh, 0feh, 0f8h
db 03eh, 0, 0, 0, 06h, 78h, 0dh, 0, 0, 0
db 10h dup(0)
db 10h dup(0)
db 0eh dup(0)
id_sig db 55h, 0aah
|
TypeTheory/Common/Context.agda | hbasold/Sandbox | 0 | 13623 | <filename>TypeTheory/Common/Context.agda
module Common.Context where
import Level
open import Data.Nat as Nat
open import Data.List as List
import Level
open import Relation.Binary.PropositionalEquality as PE hiding ([_])
open import Relation.Binary -- using (Setoid; Rel; IsEquivalence)
open ≡-Reasoning
open import Function as Fun hiding (_∘′_)
open import Data.Sum as Sum hiding ([_,_])
open import Categories.Category using (Category)
open import Common.SumProperties
-------------------------
---- Type contexts
Ctx : Set → Set
Ctx Ty = List Ty
-- | De Bruijn variable indexing
data Var {Ty : Set} : (Γ : Ctx Ty) (a : Ty) → Set where
zero : ∀{Γ a} → Var (a ∷ Γ) a
succ : ∀{Γ b} (a : Ty) → (x : Var Γ a) → Var (b ∷ Γ) a
data _≅V_ {Ty} : ∀ {Γ Γ' : Ctx Ty} {a a' : Ty} → Var Γ a → Var Γ' a' → Set where
zero : ∀ {Γ Γ'} {a a'}
→ zero {Γ = Γ} {a} ≅V zero {Γ = Γ'} {a'}
succ : ∀ {Γ Γ'} {a a'}
→ ∀ {x : Var Γ a} {x' : Var Γ' a'} {b b' : Ty}
→ x ≅V x'
→ succ {b = b} a x ≅V succ {b = b'} a' x'
Vrefl : ∀ {Ty} {Γ} {a : Ty} {x : Var Γ a} → x ≅V x
Vrefl {x = zero} = zero
Vrefl {x = succ _ t} = succ Vrefl
Vsym : ∀ {Ty} {Γ Γ'} {a a' : Ty} {x : Var Γ a} {x' : Var Γ' a'}
→ x ≅V x' → x' ≅V x
Vsym zero = zero
Vsym {Ty} (succ [x]) = succ (Vsym [x])
Vtrans : ∀ {Ty} {Γ Γ' Γ''} {a a' a'' : Ty}
{x : Var Γ a} {x' : Var Γ' a'} {x'' : Var Γ'' a''}
→ x ≅V x' → x' ≅V x'' → x ≅V x''
Vtrans zero zero = zero
Vtrans (succ eq) (succ eq') = succ (Vtrans eq eq')
-- Note: makes the equality homogeneous in Γ and a
≅V-setoid : ∀ {Ty} {Γ} {a : Ty} → Setoid _ _
≅V-setoid {Ty} {Γ} {a} = record
{ Carrier = Var Γ a
; _≈_ = _≅V_
; isEquivalence = record
{ refl = Vrefl ; sym = Vsym ; trans = Vtrans }
}
arr : ∀ {Ty} → (Γ Δ : Ctx Ty) → Set
arr {Ty} Γ Δ = ∀ (a : Ty) → Var Γ a → Var Δ a
_►_ = arr
-- _▹_ = arr
infix 4 _≡C_
record _≡C_ {Ty} {Γ Δ : Ctx Ty} (ρ : arr Γ Δ) (γ : arr Γ Δ) : Set where
field
≡C-proof : ∀ {a} {x} → ρ a x ≡ γ a x
open _≡C_
_≈_ = _≡C_
Crefl : ∀ {Ty} {Γ Δ : Ctx Ty} → Reflexive (_≡C_ {Γ = Γ} {Δ})
Crefl = record { ≡C-proof = PE.refl }
Csym : ∀ {Ty} {Γ Δ : Ctx Ty} → Symmetric (_≡C_ {Γ = Γ} {Δ})
Csym p = record { ≡C-proof = PE.sym (≡C-proof p) }
Ctrans : ∀ {Ty} {Γ Δ : Ctx Ty} → Transitive (_≡C_ {Γ = Γ} {Δ})
Ctrans p₁ p₂ = record { ≡C-proof = PE.trans (≡C-proof p₁) (≡C-proof p₂) }
≡C-equiv : ∀ {Ty} {Γ Δ : Ctx Ty} → IsEquivalence (_≡C_ {Γ = Γ} {Δ})
≡C-equiv =
record
{ refl = Crefl
; sym = Csym
; trans = Ctrans
}
≡C-setoid : ∀ {Ty} {Γ Δ : Ctx Ty} → Setoid _ _
≡C-setoid {_} {Γ} {Δ} = record
{ Carrier = arr Γ Δ
; _≈_ = _≡C_
; isEquivalence = ≡C-equiv
}
_∘′_ : ∀ {Ty} {Γ Δ Ξ : Ctx Ty} (ρ : Δ ► Ξ) (γ : Γ ► Δ) → Γ ► Ξ
_∘′_ ρ γ = λ a x → ρ a (γ a x)
_●_ = _∘′_
ctx-id : ∀ {Ty} {Γ : Ctx Ty} → arr Γ Γ
ctx-id = λ _ x → x
comp-resp-≡C : ∀ {Ty} {Γ Δ Ξ : Ctx Ty} {ρ ρ' : arr Δ Ξ} {γ γ' : arr Γ Δ} →
ρ ≡C ρ' → γ ≡C γ' → ρ ∘′ γ ≡C ρ' ∘′ γ'
comp-resp-≡C {_} {Γ} {Δ} {Ξ} {ρ} {ρ'} {γ} {γ'} ρ≡ρ' γ≡γ'
= record { ≡C-proof = p }
where
p : ∀ {a} {x} → (ρ ∘′ γ) a x ≡ (ρ' ∘′ γ') a x
p {a} {x} =
begin
(ρ ∘′ γ) a x
≡⟨ refl ⟩
ρ a (γ a x)
≡⟨ cong (λ u → ρ a u) (≡C-proof γ≡γ') ⟩
ρ a (γ' a x)
≡⟨ ≡C-proof ρ≡ρ' ⟩
ρ' a (γ' a x)
≡⟨ refl ⟩
(ρ' ∘′ γ') a x
∎
-- | Contexts form a category
ctx-cat : Set → Category Level.zero Level.zero Level.zero
ctx-cat Ty = record
{ Obj = Ctx Ty
; _⇒_ = arr
; _≡_ = _≡C_
; _∘_ = _∘′_
; id = ctx-id
; assoc = record { ≡C-proof = refl }
; identityˡ = record { ≡C-proof = refl }
; identityʳ = record { ≡C-proof = refl }
; equiv = ≡C-equiv
; ∘-resp-≡ = comp-resp-≡C
}
-------------------------
---- Coproduct structure on contexts
{-
_⊕_ : Ctx → Ctx → Ctx
Γ₁ ⊕ Γ₂ = Γ₁ ++ Γ₂
in₁ : {Γ₁ Γ₂ : Ctx} → Γ₁ ▹ (Γ₁ ⊕ Γ₂)
in₁ _ zero = zero
in₁ a (succ .a x) = succ a (in₁ a x)
in₂ : {{Γ₁ Γ₂ : Ctx}} → Γ₂ ▹ (Γ₁ ⊕ Γ₂)
in₂ {{[]}} _ x = x
in₂ {{b ∷ Γ₁}} a x = succ a (in₂ a x)
split : {Γ₁ Γ₂ : Ctx} {a : Ty} → Var (Γ₁ ⊕ Γ₂) a → Var Γ₁ a ⊎ Var Γ₂ a
split {[]} {Γ₂} x = inj₂ x
split {a ∷ Γ₁'} {Γ₂} zero = inj₁ zero
split {b ∷ Γ₁'} {Γ₂} {a} (succ .a y) = (Sum.map (succ a) (ctx-id a)) (split {Γ₁'} y)
[_,_] : {Γ₁ Γ₂ Δ : Ctx} (f : Γ₁ ▹ Δ) (g : Γ₂ ▹ Δ)
→ ((Γ₁ ⊕ Γ₂) ▹ Δ)
[_,_] {Γ} {Γ₂} f g a x = ([ f a , g a ]′) (split x)
_-⊕-_ : {Γ Γ₂ Γ' Γ₂' : Ctx} (f : Γ ▹ Γ') (g : Γ₂ ▹ Γ₂')
→ ((Γ ⊕ Γ₂) ▹ (Γ' ⊕ Γ₂'))
_-⊕-_ {Γ} {Γ₂} {Γ'} {Γ₂'} f g = [ in₁ ● f , in₂ {{Γ'}} {{Γ₂'}} ● g ]
succ-distr-lemma : {Γ : Ctx} {a b : Ty} (Γ₂ : Ctx) (x : Var Γ a) →
(in₁ {b ∷ Γ} ● succ {Γ}) a x
≡ (succ {Γ ⊕ Γ₂} ● in₁ {Γ} {Γ₂}) a x
succ-distr-lemma Γ₂ x = refl
split-lemma₁ : {a : Ty} (Γ₁ Γ₂ : Ctx) (x : Var Γ₁ a) →
split {Γ₁} {Γ₂} (in₁ {Γ₁} a x) ≡ inj₁ x
split-lemma₁ (tt ∷ Γ₁) Γ₂ zero = refl
split-lemma₁ (tt ∷ Γ₁) Γ₂ (succ a x) =
begin
split {tt ∷ Γ₁} (in₁ {tt ∷ Γ₁} a (succ a x))
≡⟨ refl ⟩
(Sum.map (succ a) id) (split (in₁ a x))
≡⟨ cong (Sum.map (succ a) id) (split-lemma₁ Γ₁ Γ₂ x) ⟩
(Sum.map (succ a) id) (inj₁ x)
≡⟨ refl ⟩
inj₁ (succ a x)
∎
split-lemma₂ : {a : Ty} (Γ₁ Γ₂ : Ctx) (x : Var Γ₂ a) →
split {Γ₁} {Γ₂} (in₂ a x) ≡ inj₂ x
split-lemma₂ [] Γ₂ x = refl
split-lemma₂ {a} (tt ∷ Γ₁) Γ₂ x =
begin
split {tt ∷ Γ₁} {Γ₂} (in₂ {{tt ∷ Γ₁}} a x)
≡⟨ refl ⟩
Sum.map (succ a) id (split (in₂ {{Γ₁}} a x))
≡⟨ cong (λ u → Sum.map (succ a) id u) (split-lemma₂ Γ₁ Γ₂ x) ⟩
Sum.map (succ a) id (inj₂ x)
≡⟨ refl ⟩
inj₂ x
∎
split-lemma : (Γ₁ Γ₂ : Ctx) (a : Ty) (x : Var (Γ₁ ⊕ Γ₂) a) →
[ in₁ {Γ₁} {Γ₂} a , in₂ a ]′ (split x) ≡ x
split-lemma [] Γ₂ _ x = refl
split-lemma (a ∷ Γ₁) Γ₂ .a zero = refl
split-lemma (b ∷ Γ₁) Γ₂ a (succ .a x) =
begin
[ in₁ {b ∷ Γ₁} a , in₂ {{b ∷ Γ₁}} a ]′ (split (succ a x))
≡⟨ refl ⟩
[ in₁ {b ∷ Γ₁} a , (succ {Γ₁ ⊕ Γ₂} ● in₂ {{Γ₁}} ) a ]′
(Sum.map (succ {Γ₁} a) id (split x))
≡⟨ copair-sum-map-merge {f₁ = Var.succ {Γ₁} {b} a} (split x) ⟩
[ (in₁ {b ∷ Γ₁} ● succ {Γ₁}) a , (succ {Γ₁ ⊕ Γ₂} ● in₂) a ]′ (split x)
≡⟨ copair-cong {f = (in₁ {b ∷ Γ₁} ● succ {Γ₁}) a}
(succ-distr-lemma Γ₂)
(split x) ⟩
[ (succ {Γ₁ ⊕ Γ₂} ● in₁ {Γ₁}) a , (succ {Γ₁ ⊕ Γ₂} ● in₂) a ]′ (split x)
≡⟨ copair-distr {f = in₁ {Γ₁} {Γ₂} a} {h = succ {Γ₁ ⊕ Γ₂} a} (split x)⟩
(Var.succ {Γ₁ ⊕ Γ₂} {b} a ∘ [ in₁ {Γ₁} a , in₂ a ]′) (split x)
≡⟨ cong (succ {Γ₁ ⊕ Γ₂} {b} a) (split-lemma Γ₁ Γ₂ a x) ⟩
succ {Γ₁ ⊕ Γ₂} a x
∎
⊕-is-coprod-arg : ∀{Γ₁ Γ₂ : Ctx} (a : Ty) (x : Var (Γ₁ ⊕ Γ₂) a) →
[ in₁ {Γ₁} {Γ₂} , in₂ ] a x ≡ ctx-id a x
⊕-is-coprod-arg {Γ₁} {Γ₂} = split-lemma Γ₁ Γ₂
⊕-is-coprod : ∀{Γ₁ Γ₂ : Ctx} → [ in₁ {Γ₁} {Γ₂} , in₂ ] ≡C ctx-id
⊕-is-coprod {Γ₁} = {!!}
{-
η-≡ {f₁ = [ in₁ {Γ₁} , in₂ ]}
{f₂ = ctx-id}
(λ (a : Ty) →
η-≡ {f₁ = [ in₁ {Γ₁}, in₂ ] a}
{f₂ = ctx-id a}
(⊕-is-coprod-arg {Γ₁} a)
)
-}
●-distr-copair₁ˡ : ∀{Γ₁ Γ₂ Δ : Ctx}
(h : (Γ₁ ⊕ Γ₂) ▹ Δ) (a : Ty) (x : Var (Γ₁ ⊕ Γ₂) a) →
[ h ● in₁ {Γ₁} {Γ₂} , h ● in₂ {{Γ₁}} {{Γ₂}} ] a x
≡ (h ● [ in₁ {Γ₁} {Γ₂} , in₂ ]) a x
●-distr-copair₁ˡ {Γ₁} {Γ₂} {Δ} h a x =
begin
[ h ● in₁ {Γ₁} , h ● in₂ ] a x
≡⟨ refl ⟩
([ (h ● in₁ {Γ₁}) a , (h ● in₂) a ]′) (split x)
≡⟨ copair-distr {f = in₁ {Γ₁} a} {g = in₂ a} {h = h a} (split x) ⟩
(h ● [ in₁ {Γ₁} , in₂ ]) a x
∎
●-distr-copairˡ : ∀{Γ₁ Γ₂ Δ : Ctx} (h : (Γ₁ ⊕ Γ₂) ▹ Δ) →
[ h ● in₁ {Γ₁} {Γ₂} , h ● in₂ {{Γ₁}} {{Γ₂}} ]
≡ h ● [ in₁ {Γ₁} {Γ₂} , in₂ ]
●-distr-copairˡ {Γ₁} h = {!!}
-- η-≡ (λ a → η-≡ (●-distr-copair₁ˡ {Γ₁} h a))
⊕-is-coprod₁ : ∀{Γ₁ Γ₂ Δ : Ctx} {f : Γ₁ ▹ Δ} {g : Γ₂ ▹ Δ} {h : (Γ₁ ⊕ Γ₂) ▹ Δ} →
h ● in₁ ≡C f → h ● in₂ ≡C g → [ f , g ] ≡C h
⊕-is-coprod₁ {Γ₁} {Γ₂} {Δ} {f} {g} {h} h●in₁≡f h●in₂≡g
= record { ≡C-proof = p }
where
p : ∀ {a} {x} → [ f , g ] a x ≡ h a x
p {a} {x} =
begin
[ f , g ] a x
≡⟨ refl ⟩
([ f a , g a ]′) (split x)
≡⟨ cong (λ u → [ u , g a ]′ (split x)) {!!} ⟩
([ (h ● in₁ {Γ₁}) a , g a ]′) (split x)
≡⟨ {!!} ⟩
h a x
∎
{-
[ h ● in₁ {Γ₁} , g ]
≡⟨ cong (λ u → [ h ● in₁ {Γ₁} , u ]) (sym h●in₂≡g) ⟩
[ h ● in₁ {Γ₁} , h ● in₂ ]
≡⟨ ●-distr-copairˡ {Γ₁} h ⟩
h ● [ in₁ {Γ₁}, in₂ ]
≡⟨ cong (λ u → h ● u) (⊕-is-coprod {Γ₁}) ⟩
h ● ctx-id
≡⟨ refl ⟩
h
-}
commute-in₁-arg : ∀ {Γ₁ Γ₂ Δ : Ctx} {f : Γ₁ ▹ Δ} {g : Γ₂ ▹ Δ}
(a : Ty) (x : Var Γ₁ a) →
([ f , g ] ● in₁) a x ≡ f a x
commute-in₁-arg _ zero = refl
commute-in₁-arg {b ∷ Γ₁} {Γ₂} {Δ} {f} {g} a (succ .a x) =
begin
([ f , g ] ● in₁ {b ∷ Γ₁}) a (succ {Γ₁} a x)
≡⟨ refl ⟩
[ f , g ] a (succ {Γ₁ ⊕ Γ₂} a (in₁ {Γ₁} a x))
≡⟨ refl ⟩
([ f a , g a ]′) (split (succ {Γ₁ ⊕ Γ₂} a (in₁ {Γ₁} a x)))
≡⟨ refl ⟩
[ f a , g a ]′ ((Sum.map (succ a) id) (split {Γ₁} {Γ₂} (in₁ {Γ₁} a x)))
≡⟨ refl ⟩
(([ f a , g a ]′ ∘ (Sum.map (succ a) id)) (split {Γ₁} {Γ₂} (in₁ {Γ₁} a x)))
≡⟨ copair-sum-map-merge {f₁ = succ a} (split {Γ₁} {Γ₂} (in₁ {Γ₁} a x)) ⟩
([ (f ● succ) a , g a ]′ (split {Γ₁} {Γ₂} (in₁ {Γ₁} a x)))
≡⟨ cong ([ (f ● succ) a , g a ]′) (split-lemma₁ Γ₁ Γ₂ x) ⟩
f a (succ a x)
∎
commute-in₁ : (Γ₁ : Ctx) → (Γ₂ : Ctx) → {Δ : Ctx} {f : Γ₁ ▹ Δ} {g : Γ₂ ▹ Δ}
→ ([ f , g ] ● in₁) ≡C f
commute-in₁ Γ₁ Γ₂ {Δ} {f} {g} =
record { ≡C-proof = λ {a} {x} → commute-in₁-arg {f = f} {g} a x }
commute-in₂-arg : ∀ {Γ₁ Γ₂ Δ : Ctx} {f : Γ₁ ▹ Δ} {g : Γ₂ ▹ Δ}
(a : Ty) (x : Var Γ₂ a) →
([ f , g ] ● in₂) a x ≡ g a x
commute-in₂-arg {[]} _ _ = refl
commute-in₂-arg {tt ∷ Γ₁} {Γ₂} {Δ} {f} {g} a x =
begin
([ f , g ] ● in₂ {{tt ∷ Γ₁}} ) a x
≡⟨ refl ⟩
[ f , g ] a ((succ ● in₂) a x)
≡⟨ refl ⟩
[ f a , g a ]′ (split {tt ∷ Γ₁} (succ a (in₂ a x)))
≡⟨ cong (λ u → [ f a , g a ]′ u) {x = split {tt ∷ Γ₁} (succ a (in₂ a x))} refl ⟩
[ f a , g a ]′ ((Sum.map (succ a) id) (split {Γ₁} (in₂ a x)))
≡⟨ cong (λ u → [ f a , g a ]′ (Sum.map (succ a) id u)) (split-lemma₂ Γ₁ Γ₂ x) ⟩
[ f a , g a ]′ ((Sum.map (succ a) id) (inj₂ x))
≡⟨ copair-sum-map-merge {f₁ = succ {Γ₁} a} {f₂ = id} {g₁ = f a} {g₂ = g a} (inj₂ x) ⟩
[ (f ● succ) a , (g ● ctx-id) a ]′ (inj₂ x)
≡⟨ copair-elimʳ {f = (f ● succ) a} {g = (g ● ctx-id) a} x ⟩
g a x
∎
commute-in₂ : (Γ₁ : Ctx) → (Γ₂ : Ctx) → {Δ : Ctx} {f : Γ₁ ▹ Δ} {g : Γ₂ ▹ Δ}
→ ([ f , g ] ● in₂) ≡C g
commute-in₂ Γ₁ Γ₂ {Δ} {f} {g} =
record { ≡C-proof = λ {a} {x} → commute-in₂-arg {f = f} {g} a x }
open import Categories.Object.Coproduct ctx-cat
ctx-coproduct : ∀{Γ₁ Γ₂ : Ctx} → Coproduct Γ₁ Γ₂
ctx-coproduct {Γ₁} {Γ₂} = record
{ A+B = Γ₁ ⊕ Γ₂
; i₁ = in₁
; i₂ = in₂
; [_,_] = [_,_]
; commute₁ = commute-in₁ Γ₁ Γ₂
; commute₂ = commute-in₂ Γ₁ Γ₂
; universal = ⊕-is-coprod₁
}
open import Categories.Object.BinaryCoproducts ctx-cat
ctx-bin-coproducts : BinaryCoproducts
ctx-bin-coproducts = record { coproduct = ctx-coproduct }
open BinaryCoproducts ctx-bin-coproducts
-}
|
app/src/main/cpp/jzintv/event/event_diag.asm | jenergy/jzIntvImGui | 1 | 80291 | <filename>app/src/main/cpp/jzintv/event/event_diag.asm<gh_stars>1-10
;; ======================================================================== ;;
;; Event Diagnostics Program ;;
;; Uses EMU_LINK interface to query jzIntv for raw event queue data. ;;
;; ======================================================================== ;;
;* ======================================================================== *;
;* This program is free software; you can redistribute it and/or modify *;
;* it under the terms of the GNU General Public License as published by *;
;* the Free Software Foundation; either version 2 of the License, or *;
;* (at your option) any later version. *;
;* *;
;* This program is distributed in the hope that it will be useful, *;
;* but WITHOUT ANY WARRANTY; without even the implied warranty of *;
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *;
;* General Public License for more details. *;
;* *;
;* You should have received a copy of the GNU General Public License along *;
;* with this program; if not, write to the Free Software Foundation, Inc., *;
;* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *;
;* ======================================================================== *;
;* Copyright (c) 2006, <NAME> *;
;* ======================================================================== *;
ROMW 16 ; Use 16-bit ROM width
CFGVAR "name" = "Event Diagnostics v1"
CFGVAR "short_name" = "Event Diags v1"
CFGVAR "year" = 2006
CFGVAR "author" = "<NAME>"
CFGVAR "license" = "GPLv2+"
;; ======================================================================== ;;
;; Scratch Memory ;;
;; ======================================================================== ;;
ORG $100, $100, "-RWBN"
ISRVEC RMB 2
BGC RMB 1
EVTNAM RMB 20
;; ======================================================================== ;;
;; System Memory ;;
;; ======================================================================== ;;
ORG $300, $300, "-RWBN"
STACK RMB 32
CURPOS RMB 1
;; ======================================================================== ;;
;; Macros and definitions ;;
;; ======================================================================== ;;
INCLUDE "library/gimini.asm"
INCLUDE "macro/util.mac"
INCLUDE "macro/stic.mac"
INCLUDE "macro/gfx.mac"
INCLUDE "macro/print.mac"
ORG $5000 ; Use default memory map
;; ======================================================================== ;;
;; EXEC-friendly ROM header. ;;
;; ======================================================================== ;;
ROMHDR: BIDECLE ZERO ; MOB picture base (points to NULL list)
BIDECLE ZERO ; Process table (points to NULL list)
BIDECLE MAIN ; Program start address
BIDECLE ZERO ; Bkgnd picture base (points to NULL list)
BIDECLE ONES ; GRAM pictures (points to NULL list)
BIDECLE TITLE ; Cartridge title/date
DECLE $03C0 ; No ECS title, run code after title,
; ... no clicks
ZERO: DECLE $0000 ; Screen border control
DECLE $0000 ; 0 = color stack, 1 = f/b mode
ONES: DECLE 1, 1, 1, 1, 1 ; Initial color stack 0..3 and border: blue
;------------------------------------------------------------------------------
MACRO SETBG b, r
MVII #C_%b%, %r%
MVO %r%, BGC
ENDM
;; ======================================================================== ;;
;; TITLE -- Display our modified title screen & copyright date. ;;
;; ======================================================================== ;;
TITLE: PROC
BYTE 106, 'Event Diagnostics v1', 0
MAIN:
MVII #$100, R4
MVII #$260, R1
CALL FILLZERO
SETISR ISRINIT,R0
MVII #STACK, R6
EIS
;; ------------------------------------------------------------ ;;
;; Check for EMU_LINK support. ;;
;; ------------------------------------------------------------ ;;
MVII #$4A5A, R0
SETC
SIN
BNC @@ok
TSTR R0
BEQ @@ok
;; ------------------------------------------------------------ ;;
;; Print failure message if we don't detect EMU_LINK. ;;
;; ------------------------------------------------------------ ;;
SETBG RED, R0 ;0123456789012345678901234567890123456789
PRINT_CSTK 5, 3, YEL, "Requires jzIntv EMU-LINK support."
DECR PC
@@ok:
SETBG LBL, R0 ;01234567890123456789
PRINT_CSTK 0, 0, BLK, "Event Diagnostics v1"
MVII #60, R0
MVII #$800, R1
MVII #disp_ptr(2,0), R4
@@msglp: MVO@ R1, R4
ADDI #8, R1
DECR R0
BNEQ @@msglp
MVII #disp_ptr(6,0), R0
MVO R0, CURPOS
@@main_loop:
;; ------------------------------------------------------------ ;;
;; Spin until an event arrives. ;;
;; ------------------------------------------------------------ ;;
@@wait_evt: CALL DO_EL
DECLE EVTNAM
INCR R0
BEQ @@wait_evt
PSHR R1
;; ------------------------------------------------------------ ;;
;; Scroll up the screen for new event if needed. ;;
;; ------------------------------------------------------------ ;;
MVI CURPOS, R4
CMPI #$2F0, R4
BNC @@no_scroll
CALL SCROLL
@@no_scroll
;; ------------------------------------------------------------ ;;
;; Print Up/Down indicator. ;;
;; ------------------------------------------------------------ ;;
MVII #gen_cstk_card(ASC("U",0)-$20, GROM, Black, NoAdv), R0
PULR R1
TSTR R1
BEQ @@up
MVII #gen_cstk_card(ASC("D",0)-$20, GROM, Black, NoAdv), R0
@@up
MVO@ R0, R4
INCR R4
;; ------------------------------------------------------------ ;;
;; *Grumble* Fix underscores. ;;
;; ------------------------------------------------------------ ;;
MVII #EVTNAM, R5
MVII #$EF, R1
@@us_fix: MVI@ R5, R0
CMPI #$5F, R0
BNEQ @@not_us
DECR R5
MVO@ R1, R5
@@not_us: TSTR R0
BNEQ @@us_fix
;; ------------------------------------------------------------ ;;
;; Print the (corrected) name. ;;
;; ------------------------------------------------------------ ;;
MVII #EVTNAM, R0
MVII #__CSTK.GROM_BLK, R1
CALL PRINT.R
MVI CURPOS, R1
ADDI #20, R1
MVO R1, CURPOS
CLRR R0
INCR PC
@@eol MVO@ R0, R4
CMPR R4, R1
BNEQ @@eol
B @@main_loop
ENDP
;; ======================================================================== ;;
;; ISR ;;
;; ======================================================================== ;;
ISR PROC
MVO R0, $20
MVI $21, R0
MVI BGC, R0
MVII #$28, R4
MVO@ R0, R4
MVO@ R0, R4
MVO@ R0, R4
MVO@ R0, R4
MVO@ R0, R4
JR R5
ENDP
;; ======================================================================== ;;
;; ISRINIT ;;
;; ======================================================================== ;;
ISRINIT PROC
DIS
MVII #TTXT, R4
MVII #$3800, R5
MVII #TTXT.end-TTXT, R0
@@loop: MVI@ R4, R1
MVO@ R1, R5
SWAP R1
MVO@ R1, R5
DECR R0
BNEQ @@loop
SETISR ISR, R0
JE $1014
ENDP
;; ======================================================================== ;;
;; SCROLL ;;
;; ======================================================================== ;;
SCROLL PROC
PSHR R5
MVII #$200, R4
MVII #$214, R5
MVII #220/10,R1
@@loop
REPEAT 10
MVI@ R5, R0
MVO@ R0, R4
ENDR
DECR R1
BNEQ @@loop
MVII #$2F0 - 20, R4
MVO R4, CURPOS
PULR PC
ENDP
;; ------------------------------------------------------------------------ ;;
;; Event Emu-Link on Major API #9. ;;
;; ;;
;; The event Emu-Link API is very simple: ;;
;; ;;
;; INPUTS: ;;
;; R2 == 0x0000: Just return event number and up/down ;;
;; R2 != 0x0000: Try to write ASCII name of event @R1. ;;
;; ASCII names are bounded to 18 chars + NUL. ;;
;; ;;
;; OUTPUTS: ;;
;; R0: 0xFFFF = No events, otherwise event # ;;
;; R1: 0 = UP, 1 = DOWN ;;
;; ------------------------------------------------------------------------ ;;
;; ======================================================================== ;;
;; DO_EL Make an event emu_link call. API follows call. ;;
;; DO_EL.1 Make an event emu_link call. API in R2. ;;
;; ======================================================================== ;;
DO_EL PROC
MVI@ R5, R2
@@1 MVII #$4A5A, R0
PSHR R5
PSHR R2
MVII #9, R1 ; event subsystem on major API #9
SETC
SIN
BC @@failed
DECR R6 ; dump saved EL call #
PULR PC ; return
@@failed:
CALL CLRSCR
SETBG RED, R0
MVII #disp_ptr(7, 3), R4
MVII #__CSTK.GROM_YEL, R1
CALL HEX16
;0123456789012345678901234567890123456789
PRINT_CSTK 5, 0, YEL, "EMU-LINK call failed"
PULR R0
MVII #disp_ptr(7, 8), R4
MVII #__CSTK.GROM_YEL, R1
CALL HEX16
PULR R0
MVII #disp_ptr(7,13), R4
MVII #__CSTK.GROM_YEL, R1
CALL HEX16
B $
ENDP
;; ======================================================================== ;;
;; LIBRARY INCLUDES ;;
;; ======================================================================== ;;
INCLUDE "library/print.asm"
INCLUDE "library/fillmem.asm"
INCLUDE "library/prnum16.asm"
INCLUDE "library/hexdisp.asm"
;; ======================================================================== ;;
;; Title screen text rendered as a graphic. ;;
;; ======================================================================== ;;
TTXT PROC
gfx_start
gfx_row "......#."
gfx_row ".######."
gfx_row "...#..##"
gfx_row "...#..#."
gfx_row "...#..#."
gfx_row "...#..#."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "..#....."
gfx_row "........"
gfx_row "#.#.###."
gfx_row "#.#.##.."
gfx_row "#.#...#."
gfx_row "#.#.###."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "..##.###"
gfx_row "..#..###"
gfx_row "..#..#.."
gfx_row "..#..###"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row ".###.###"
gfx_row ".#.#.#.#"
gfx_row ".#.#.#.#"
gfx_row ".###.###"
gfx_row ".#......"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "....#..."
gfx_row ".##.##.#"
gfx_row ".#..#..#"
gfx_row ".#..#..."
gfx_row ".#..##.#"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row ".....#.."
gfx_row "##...##."
gfx_row "#....#.."
gfx_row ".#...#.."
gfx_row "##...##."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "#......."
gfx_row "#......."
gfx_row "###.###."
gfx_row "#.#.###."
gfx_row "#.#.#..."
gfx_row "#.#.###."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "..###.#."
gfx_row "..###.#."
gfx_row "..#...#."
gfx_row "..###..#"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "#.###.##"
gfx_row "#.###.#."
gfx_row "#.#...#."
gfx_row "..###.#."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "..#....."
gfx_row "#.##.###"
gfx_row "#.#..##."
gfx_row "#.#....#"
gfx_row "#.##.###"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "...#...."
gfx_row "...#.###"
gfx_row "...#...#"
gfx_row "...#..#."
gfx_row "...#.###"
gfx_row "..##...."
gfx_row "........"
gfx_flush
gfx_start
gfx_row ".#......"
gfx_row ".#.....#"
gfx_row ".#.###.#"
gfx_row ".#.#.#.#"
gfx_row ".#.#.#.#"
gfx_row ".#.#.#.#"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "#.#.#..."
gfx_row "..#.#..."
gfx_row "..#.#..."
gfx_row "#..#...."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "###.###."
gfx_row "##..###."
gfx_row "..#.#..."
gfx_row "###.###."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "###.###."
gfx_row "###.##.."
gfx_row "#.....#."
gfx_row "###.###."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "......#."
gfx_row "......#."
gfx_row "........"
gfx_row "........"
gfx_row "#......."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "#..#.#.."
gfx_row "#..#.#.."
gfx_row "#..#...."
gfx_row "#..#...."
gfx_row ".##....."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "..##.###"
gfx_row "...#.#.#"
gfx_row ".###.#.#"
gfx_row ".###.#.#"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "...#...."
gfx_row "...#...#"
gfx_row ".###...#"
gfx_row ".#.#...."
gfx_row ".#.#...."
gfx_row ".###...."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row ".###..#."
gfx_row ".#..#.#."
gfx_row ".#..#..."
gfx_row ".#..#..."
gfx_row ".###...."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "..#....."
gfx_row "..#....."
gfx_row "..###.##"
gfx_row "..#.#.##"
gfx_row "..#.#.#."
gfx_row "..###.##"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "..##...."
gfx_row "..#....."
gfx_row "#######."
gfx_row "#.#.#.#."
gfx_row "..#.#.#."
gfx_row "#.#.###."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "##.###.."
gfx_row "#..###.."
gfx_row "#..#...."
gfx_row "#..###.."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row ".###..##"
gfx_row ".###...#"
gfx_row ".#...###"
gfx_row ".###.###"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row ".....#.."
gfx_row ".....#.."
gfx_row "..##.###"
gfx_row ".#...#.#"
gfx_row ".#...#.#"
gfx_row "..##.#.#"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "...###.#"
gfx_row "...###.#"
gfx_row "...#...#"
gfx_row "...###.."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row ".#.###.#"
gfx_row ".#.###.#"
gfx_row ".#.#...#"
gfx_row "#..###.#"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "...#...."
gfx_row "##.##..."
gfx_row ".#.#...."
gfx_row ".#.#...."
gfx_row ".#.##..."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "###..##."
gfx_row "##....#."
gfx_row "..#.###."
gfx_row "###.###."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "#.#.###."
gfx_row "#.#.##.."
gfx_row "#.#...#."
gfx_row ".##.###."
gfx_row "..#....."
gfx_row "###....."
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "..#.#.#."
gfx_row "..#.#.#."
gfx_row "..##.##."
gfx_row "...#.#.."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "#......."
gfx_row "#......."
gfx_row "###.###."
gfx_row "#.#.###."
gfx_row "#.#.#..."
gfx_row "#.#.###."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "...#...."
gfx_row "#..#...."
gfx_row "##.###.#"
gfx_row "#..#.#.#"
gfx_row "#..#.#.#"
gfx_row "##.#.#.#"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "##.##..."
gfx_row "##.#...."
gfx_row "...#...."
gfx_row "##.#...."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "#......."
gfx_row "..#..#.."
gfx_row "#.##.#.#"
gfx_row "#.#....#"
gfx_row "#.#....."
gfx_row "#.##...#"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row ".......#"
gfx_row ".....#.#"
gfx_row "##...#.#"
gfx_row "#......#"
gfx_row ".#.....#"
gfx_row "##.....#"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row ".#.###.#"
gfx_row "#..###.#"
gfx_row ".#.#...#"
gfx_row ".#.###.."
gfx_row "........"
gfx_row ".......#"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row ".#....#."
gfx_row ".#.##.#."
gfx_row ".#....#."
gfx_row "##....##"
gfx_row ".#......"
gfx_row "##......"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "......#."
gfx_row "#.###.#."
gfx_row "#.#.#..."
gfx_row "#.#.#..."
gfx_row "#.###..."
gfx_row "..#....."
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row ".###.##."
gfx_row ".#.#.#.."
gfx_row ".#.#.#.."
gfx_row ".###.#.."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "....#..."
gfx_row "..#.#..."
gfx_row "..#.#.#."
gfx_row "....##.."
gfx_row "....#.#."
gfx_row "....#.#."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "###.#.#."
gfx_row "###.#.#."
gfx_row "#...#.#."
gfx_row "###..##."
gfx_row "......#."
gfx_row "....###."
gfx_flush
gfx_start
gfx_row "....#..."
gfx_row "....#..."
gfx_row "..###.##"
gfx_row "..#.#.#."
gfx_row "..#.#.#."
gfx_row "..###.##"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "#.#.#.#."
gfx_row "#.#.#.#."
gfx_row "#.##.##."
gfx_row "#..#.#.."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "......#."
gfx_row "###...#."
gfx_row "#.#....."
gfx_row "#.#....."
gfx_row "#.#.#..."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "....#..#"
gfx_row "....#..#"
gfx_row "....#..#"
gfx_row "....#..#"
gfx_row ".....##."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row ".###.###"
gfx_row ".##..###"
gfx_row "...#.#.."
gfx_row ".###.###"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "......#."
gfx_row "...#..#."
gfx_row "...##.##"
gfx_row "...#..#."
gfx_row "...#..#."
gfx_row "...##.#."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "#.###.##"
gfx_row "#.###.##"
gfx_row "#.#....."
gfx_row "#.###.##"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "#.###..."
gfx_row "..###..."
gfx_row "#.#....."
gfx_row "#.###..."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "###..##."
gfx_row "#.#...#."
gfx_row "#.#.###."
gfx_row "#.#.###."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "#####..#"
gfx_row "#.#.#..#"
gfx_row "#.#.#..#"
gfx_row "#.#.#..#"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "##.###.."
gfx_row "##.##..."
gfx_row ".....#.."
gfx_row "##.###.."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row ".#......"
gfx_row ".##.###."
gfx_row ".#..#.#."
gfx_row ".#..#.#."
gfx_row ".##.###."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "..##.###"
gfx_row "..#..###"
gfx_row "..#..#.."
gfx_row "..#..###"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row ".#...#.."
gfx_row ".#......"
gfx_row ".###.#.#"
gfx_row ".#.#.#.#"
gfx_row ".#.#.#.#"
gfx_row ".###.#.#"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row ".....#.."
gfx_row ".....#.."
gfx_row "##.###.."
gfx_row ".#.#.#.."
gfx_row ".#.#.#.."
gfx_row ".#.###.."
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row ".#......"
gfx_row ".#.###.#"
gfx_row ".#.#.#.#"
gfx_row ".#.#.#.#"
gfx_row ".#.#.#.#"
gfx_row ".......#"
gfx_row ".......#"
gfx_flush
gfx_start
gfx_row "........"
gfx_row ".......#"
gfx_row "##.#.#.#"
gfx_row ".#.#.#.#"
gfx_row ".#.#.#.#"
gfx_row "##.###.#"
gfx_row "........"
gfx_row "........"
gfx_flush
gfx_start
gfx_row "........"
gfx_row "........"
gfx_row "#.###..."
gfx_row "..##...."
gfx_row "....#..."
gfx_row "#.###.#."
gfx_row "........"
gfx_row "........"
gfx_flush
@@end:
ENDP
|
TotalParserCombinators/Pointwise.agda | nad/parser-combinators | 1 | 2932 | ------------------------------------------------------------------------
-- Pointwise lifting of (binary) initial bag operators to parsers
------------------------------------------------------------------------
open import Data.List
open import Data.List.Membership.Propositional using (_∈_)
open import Data.List.Relation.Binary.BagAndSetEquality
using () renaming (_∼[_]_ to _List-∼[_]_)
open import Function.Related as Related using (Kind; SK-sym)
module TotalParserCombinators.Pointwise
(R₁ R₂ : Set) {R₃ : Set}
-- Some kinds of equality.
{K : Set} (⌊_⌋ : K → Kind)
-- An initial bag operator.
(_∙_ : List R₁ → List R₂ → List R₃)
-- The operator must preserve the given notions of equality.
(_∙-cong_ : ∀ {k xs₁ xs₁′ xs₂ xs₂′} →
xs₁ List-∼[ ⌊ k ⌋ ] xs₁′ → xs₂ List-∼[ ⌊ k ⌋ ] xs₂′ →
(xs₁ ∙ xs₂) List-∼[ ⌊ k ⌋ ] (xs₁′ ∙ xs₂′))
where
open import Codata.Musical.Notation
open import Function.Base
open import Function.Equality using (_⟨$⟩_)
open import Function.Equivalence using (_⇔_; module Equivalence)
open import Function.Inverse using (_↔_; module Inverse)
open import TotalParserCombinators.Congruence as C using (_∼[_]P_; _≅P_)
import TotalParserCombinators.Congruence.Sound as CS
open import TotalParserCombinators.Derivative as D
import TotalParserCombinators.InitialBag as I
open import TotalParserCombinators.Laws
open import TotalParserCombinators.Lib
open import TotalParserCombinators.Parser
open import TotalParserCombinators.Semantics using (_∈_·_)
------------------------------------------------------------------------
-- Lift
-- A lifting of the initial bag operator _∙_ to the level of parsers.
--
-- Note that this definition is closely related to Theorem 4.4 in
-- Brzozowski's paper "Derivatives of Regular Expressions".
--
-- Note also that _∙_ is allowed to pattern match on the input
-- indices, so it may not be obvious that lift preserves equality.
-- This fact is established explicitly below (by making use of
-- _∙-cong_).
lift : ∀ {Tok xs₁ xs₂} →
Parser Tok R₁ xs₁ → Parser Tok R₂ xs₂ →
Parser Tok R₃ (xs₁ ∙ xs₂)
lift p₁ p₂ =
(token >>= λ t → ♯ lift (D t p₁) (D t p₂))
∣ return⋆ (initial-bag p₁ ∙ initial-bag p₂)
------------------------------------------------------------------------
-- Properties of lift
-- D distributes over lift.
D-lift : ∀ {Tok xs₁ xs₂ t}
(p₁ : Parser Tok R₁ xs₁) (p₂ : Parser Tok R₂ xs₂) →
D t (lift p₁ p₂) ≅P lift (D t p₁) (D t p₂)
D-lift {xs₁ = xs₁} {xs₂} {t} p₁ p₂ =
D t (lift p₁ p₂) ≅⟨ D t (lift p₁ p₂) ∎ ⟩
(return t >>= λ t → lift (D t p₁) (D t p₂)) ∣
D t (return⋆ (xs₁ ∙ xs₂)) ≅⟨ Monad.left-identity t (λ t → lift (D t p₁) (D t p₂)) ∣
D.D-return⋆ (xs₁ ∙ xs₂) ⟩
lift (D t p₁) (D t p₂) ∣ fail ≅⟨ AdditiveMonoid.right-identity (lift (D t p₁) (D t p₂)) ⟩
lift (D t p₁) (D t p₂) ∎
where open C using (_≅⟨_⟩_; _∎; _∣_)
-- lift preserves equality.
lift-cong : ∀ {k Tok xs₁ xs₁′ xs₂ xs₂′}
{p₁ : Parser Tok R₁ xs₁} {p₁′ : Parser Tok R₁ xs₁′}
{p₂ : Parser Tok R₂ xs₂} {p₂′ : Parser Tok R₂ xs₂′} →
p₁ ∼[ ⌊ k ⌋ ]P p₁′ → p₂ ∼[ ⌊ k ⌋ ]P p₂′ →
lift p₁ p₂ ∼[ ⌊ k ⌋ ]P lift p₁′ p₂′
lift-cong {k} {xs₁ = xs₁} {xs₁′} {xs₂} {xs₂′} {p₁} {p₁′} {p₂} {p₂′}
p₁≈p₁′ p₂≈p₂′ = lemma ∷ λ t → ♯ (
D t (lift p₁ p₂) ≅⟨ D-lift p₁ p₂ ⟩
lift (D t p₁) (D t p₂) ∼⟨ lift-cong (CS.D-cong p₁≈p₁′) (CS.D-cong p₂≈p₂′) ⟩
lift (D t p₁′) (D t p₂′) ≅⟨ sym (D-lift p₁′ p₂′) ⟩
D t (lift p₁′ p₂′) ∎)
where
open C using (_≅⟨_⟩_; _∼⟨_⟩_; _∎; sym; _∷_)
lemma : (xs₁ ∙ xs₂) List-∼[ ⌊ k ⌋ ] (xs₁′ ∙ xs₂′)
lemma = I.cong (CS.sound p₁≈p₁′) ∙-cong I.cong (CS.sound p₂≈p₂′)
-- Lifts a property from _∙_ to lift. For examples of its use, see
-- TotalParserCombinators.{And,AsymmetricChoice,Not}.
lift-property :
(P : ∀ {ℓ} → (R₁ → Set ℓ) → (R₂ → Set ℓ) → (R₃ → Set ℓ) → Set ℓ)
(P-cong :
∀ {ℓ} {F₁ : R₁ → Set ℓ} {F₂ : R₂ → Set ℓ} {F₃ : R₃ → Set ℓ}
{ℓ′} {F₁′ : R₁ → Set ℓ′} {F₂′ : R₂ → Set ℓ′} {F₃′ : R₃ → Set ℓ′} →
(∀ x → F₁ x ↔ F₁′ x) → (∀ x → F₂ x ↔ F₂′ x) → (∀ x → F₃ x ↔ F₃′ x) →
P F₁ F₂ F₃ ⇔ P F₁′ F₂′ F₃′) →
(P-∙ :
∀ {xs₁ xs₂} →
P (λ x → x ∈ xs₁) (λ x → x ∈ xs₂) (λ x → x ∈ (xs₁ ∙ xs₂))) →
∀ {Tok xs₁ xs₂ s}
(p₁ : Parser Tok R₁ xs₁) (p₂ : Parser Tok R₂ xs₂) →
P (λ x → x ∈ p₁ · s) (λ x → x ∈ p₂ · s) (λ x → x ∈ lift p₁ p₂ · s)
lift-property P P-cong P-∙ {s = []} p₁ p₂ =
Equivalence.from
(P (λ x → x ∈ p₁ · []) (λ x → x ∈ p₂ · [])
(λ x → x ∈ lift p₁ p₂ · []) ∼⟨ P-cong (λ _ → I.correct) (λ _ → I.correct) (λ _ → I.correct) ⟩
P (λ x → x ∈ initial-bag p₁) (λ x → x ∈ initial-bag p₂)
(λ x → x ∈ (initial-bag p₁ ∙ initial-bag p₂)) ∎
) ⟨$⟩ P-∙
where open Related.EquationalReasoning
lift-property P P-cong P-∙ {s = t ∷ s} p₁ p₂ =
Equivalence.from
(P (λ x → x ∈ p₁ · t ∷ s) (λ x → x ∈ p₂ · t ∷ s)
(λ x → x ∈ lift p₁ p₂ · t ∷ s) ∼⟨ SK-sym $ P-cong (λ _ → D.correct) (λ _ → D.correct) (λ _ → D.correct) ⟩
P (λ x → x ∈ D t p₁ · s) (λ x → x ∈ D t p₂ · s)
(λ x → x ∈ D t (lift p₁ p₂) · s) ∼⟨ P-cong (λ _ → _ ∎) (λ _ → _ ∎) (λ _ → CS.sound (D-lift p₁ p₂)) ⟩
P (λ x → x ∈ D t p₁ · s) (λ x → x ∈ D t p₂ · s)
(λ x → x ∈ lift (D t p₁) (D t p₂) · s) ∎
) ⟨$⟩ lift-property P P-cong P-∙ (D t p₁) (D t p₂)
where open Related.EquationalReasoning
|
a09.asm | Sahilsinggh/MP_SEM4 | 1 | 97082 | %macro print 2
mov rax,01;
mov rdi,01;
mov rsi,%1;
mov rdx,%2;
syscall;
%endmacro
%macro read 2
mov rax,00;
mov rdi,00;
mov rsi,%1;
mov rdx,%2;
syscall;
%endmacro
section .data
dash: db 10,"-------------------------------------------",10;
lenDash: equ $-dash;
resMsg: db "! = ";
lenResMsg: equ $-resMsg;
errMsg: db "Invalid Command Line Argument Format!";
lenErrMsg: equ $-errMsg;
space: db " ";
newLine: db 10;
section .bss
inAscii: resb 16;
outAscii: resb 16;
number: resq 1;
result: resq 1;
section .data
global _start
_start:
pop rbx;
cmp rbx,2h;
jne argError
pop rbx
pop rbx;
mov rsi,inAscii
call getArgument;
call _AsciiToHex;
mov [number],rax;
mov rbx,rax;
push rbx;
xor rax,rax;
inc rax;
call factorial
mov [result],rax;
print dash,lenDash;
mov rax,[number];
call _HexToAscii;
print outAscii,16;
print resMsg,lenResMsg;
mov rax,[result];
call _HexToAscii;
print outAscii,16;
print dash,lenDash;
print newLine,1;
exit:
mov rax,60;
mov rdi,00;
syscall;
argError:
print newLine,1;
print errMsg,lenErrMsg;
print newLine,1;
print newLine,1;
jmp exit
getArgument:
; DOC-STRING:
; i) Stores the command line argument to the memory location pointed by RSI.
; ii) Stores length of command line argument in RCX
xor rcx,rcx;
xor rax,rax;
begin3:
mov al,byte[rbx];
mov byte[rsi],al;
inc rsi;
inc rbx;
inc rcx;
cmp byte[rbx],0h;
jne begin3;
ret;
factorial:
pop rsi; //pop IP
pop rbx; //No. in Stack
push rsi; //push back IP
cmp rbx,1h;
je endFactorial;
cmp rbx,0h;
je endFactorial;
mul rbx;
dec rbx;
push rbx;
call factorial;
endFactorial:
ret;
_AsciiToHex:; //ASCII in inAscii ----> HEX in RAX
mov rsi,inAscii;
xor rax,rax;
begin1:
cmp byte[rsi],0h; //Compare With Null Character ie: 0h
je end_AsciiToHex;
rol rax,04d;
mov bl,byte[rsi];
cmp bl,39h;
jbe sub30
sub bl,07h;
sub30:
sub bl,30h;
add al,bl;
inc rsi;
jmp begin1;
end_AsciiToHex:
ret
_HexToAscii:; // HEX in RAX -----> ASCII in outAscii
mov rsi,outAscii+15d;
mov rcx,16d
begin2:
xor rdx,rdx;
mov rbx,10h; //16d
div rbx;
cmp dl,09h;
jbe add30;
add dl,07h;
add30:
add dl,30h;
mov byte[rsi],dl;
update:
dec rsi;
dec rcx;
jnz begin2;
end_HexToAscii:
ret
|
hexpose.asm | khansen/hexposure | 0 | 165369 | IDEAL
P386N
MODEL FLAT
STACK 1000h
DATASEG
_80x50 dw 04F01h
dw 05002h
dw 05504h
dw 08105h
dw 0BF06h
dw 01F07h
dw 04709h
dw 09C10h
dw 08E11h
dw 08F12h
dw 02813h
dw 01F14h
dw 09615h
dw 0B916h
dw 0A317h
;-----------------------------------------------------------------------------
BuildMessage db 0,' Build font table based on result? (Y/N)',0,0,0FFh
ScriptMemError db 0,' Error: Could not allocate memory for script.',0,0,0FFh
ScriptOpenError db 0,' Error: Could not open script.',0,0,0FFh
SaveMessage db 0,' Changes saved.',0,0,0FFh
DumpError db 0,' Error: Start offset larger than end offset.',0,0,0FFh
HexError db 0,' Error: Need even number of digits.',0,0,0FFh
SearchMessage db 0,' Searching...',0,0,0FFh
SearchError db 0,' String not found.',0,0,0FFh
DumpMessage db 0,' Dumping...',0,0,0FFh
InsMessage db 0,' Inserting...',0,0,0FFh
DTEOffMessage db 0,' DTE disabled.',0,0,0FFh
DTEOnMessage db 0,' DTE enabled.',0,0,0FFh
AboutMessage db 0
db ' Hexposure v0.45',0
db 0
db ' Written by <NAME>',0
db ' 19(c)99 SnowBro Software',0
db 0
db 0FFh
CmdMessage db 0
db ' TAB Toggle mode (hex/text)',0
db ' ESC Bring up menu',0
db ' F1 Go to offset',0
db ' F2 Text search',0
db ' F3 Search again',0
db ' F4 Hex search',0
db ' F5 Save changes',0
db ' F6 Relative search',0
db ' F7 Script dumper',0
db ' F8 Script inserter',0
db ' F9 Save font table',0
db ' Ctrl-L File selector',0
db ' Ctrl-Q Quit',0
db 0
db 0FFh
Menu db 0
MenuItem db 0
MenuLength db 0,8,14,22,31
MenuTableJMP dd FileMenuJMP
dd EditMenuJMP
dd SearchMenuJMP
dd OptionsMenuJMP
dd HelpMenuJMP
FileMenuJMP dd UseFileSel
dd SaveFile
dd ScriptDumper
dd ScriptInserter
dd SaveFontTable
dd Exit
EditMenuJMP dd GoOfs
dd CopyString
dd PasteString
dd Delete
dd Insert
SearchMenuJMP dd SearchText
dd SearchHex
dd SearchRelative
dd SearchAgain
OptionsMenuJMP dd ToggleDTE
HelpMenuJMP dd ShowCommands
dd ShowAboutBox
MenuTableTXT dd FileMenuTXT
dd EditMenuTXT
dd SearchMenuTXT
dd OptionsMenuTXT
dd HelpMenuTXT
FileMenuTXT db 6
db 'Open... Ctrl-L',0
db 'Save F5',0
db 'Dump... F7',0
db 'Insert... F8',0
db 'Save .TBL F9',0
db 'Exit Ctrl-Q',0
db 0
EditMenuTXT db 1 ; 5
db 'Goto... F1',0
; db 'Copy Ctrl-C',0
; db 'Paste Ctrl-V',0
; db 'Delete Del',0
; db 'Insert Ins',0
db 0
SearchMenuTXT db 4
db 'Text... F2',0
db 'Hex... F4',0
db 'Relative... F6',0
db 'Again F3',0
db 0
OptionsMenuTXT db 1
db 'Toggle DTE',0
db 0
HelpMenuTXT db 2
db 'Commands...',0
db 'About...',0
db 0
;-----------------------------------------------------------------------------
FontTable db 16*256 dup (0)
EnabledTable db 256 dup (0)
DTEStatus db 1
FontValue db 0
MarkLength db 0
EditMode db 0
LineBrk db 0
SectBrk db 0
StrBrk db 0
LineBrkDEF db 0
SectBrkDEF db 0
StrBrkDEF db 0
ERR_MemAlloc db ' ERROR: Could not allocate memory for file!',13,10,'$'
include "savefont.inc"
include "scrins.inc"
include "dumper.inc"
include "rs.inc"
include "ofs.inc"
include "hexsrc.inc"
include "txtsrc.inc"
include "fs.inc"
include "int2.inc"
VideoMem dd 0B8000h
KbdBuffer dd 000400h
SearchType db 0
SearchLen db 0
FileOffset dd 0
Row dd 0
Column dd 0
CharAttrib db 0Fh
FileSpec db '*.*',0
TblExt db '.TBL',0
FileNameBuffer db 10000h dup (?)
Directory db 64 dup (?)
FileName db 256 dup (?)
TblFile db 256 dup (?)
FileHandle dw ?
FileData dd ?
FileSize dd ?
FileCount dd ?
FileSel dd ?
FilePage dd ?
FilePointer dd ?
ScriptSize dd ?
ScriptPointer dd ?
PSP dd ?
temp dd ?
SearchString db 256 dup (?)
TempString db 256 dup (?)
OldScreen db 80*25*2 dup (?)
VirtualScreen db 80*25*2 dup (?)
MouseX dd ?
MouseY dd ?
ButtonStat db ?
CODESEG
MACRO GotoXY x,y
push eax
mov edi,offset VirtualScreen
mov eax,y
shl eax,7
add edi,eax
shr eax,2
add edi,eax
mov eax,x
add eax,eax
add edi,eax
pop eax
ENDM
start:
mov dx,3C8h
mov al,2
out dx,al
inc dx
mov al,20
out dx,al
out dx,al
out dx,al
mov ax,0EE02h
int 31h
sub [VideoMem],ebx
sub [KbdBuffer],ebx
mov [PSP],esi
mov esi,[VideoMem]
mov edi,offset OldScreen
mov ecx,(80*25*2)/4
rep movsd
mov esi,[PSP]
movzx ecx,[byte ptr esi+80h]
cmp cl,0
je UseFileSel
add esi,81h
find_first_char:
cmp [byte ptr esi],20h
jnz short copy_filename
dec cl
jz terminate
inc esi
jmp short find_first_char
copy_filename:
mov edi,offset FileName
rep movsb
mov [byte ptr edi],0
jmp OpenFile
UseFileSel:
call FileSelector
OpenFile:
mov ax,3D00h
mov edx,offset FileName
int 21h
jc UseFileSel
pushad
mov ah,4Eh
mov cx,10h
mov edx,offset FileName
int 21h
mov esi,[PSP]
add esi,9Ah
mov eax,[dword ptr esi]
mov [FileSize],eax
popad
call ClearFontTable
mov [FileOffset],0
mov [Row],0
mov [Column],0
mov [LineBrkDEF],0
mov [SectBrkDEF],0
mov [StrBrkDEF],0
pushad
mov ax,0EE40h
int 31h
mov edx,[FileSize]
inc edx
mov ax,0EE42h
int 31h
mov [FilePointer],edx
popad
mov bx,ax
mov ah,3Fh
mov ecx,[FileSize]
mov edx,[FilePointer]
int 21h
cmp eax,[FileSize]
je FileLoaded
mov ax,03h
int 10h
mov ah,09h
mov edx,offset ERR_MemAlloc
int 21h
jmp Terminate
FileLoaded:
mov [FileSize],eax
mov ah,3Eh
int 21h
mov esi,offset FileName
mov edi,offset TblFile
call StrCopy
mov esi,offset TblExt
mov edi,offset TblFile
call SetFileExt
mov ax,3D00h
mov edx,offset TblFile
int 21h
jc UseASCIITbl
pushad
mov edi,offset VirtualScreen
mov ecx,(80*25*2)/4
xor eax,eax
rep stosd
popad
mov bx,ax
mov ah,3Fh
mov edx,offset VirtualScreen
mov ecx,80*25*2
int 21h
mov ah,3Eh
int 21h
mov edi,offset VirtualScreen
FontLoop:
cmp [byte ptr edi],0
je MainLoop
push edi
cmp [byte ptr edi],'/'
je CaseStrBrk
cmp [byte ptr edi],'*'
je CaseLineBrk
cmp [byte ptr edi],'\'
je CaseSectBrk
mov esi,offset TempString
mov ax,[word ptr edi]
mov [word ptr esi],ax
mov [byte ptr esi+2],0
mov ebx,16
call AscToNum
mov ebx,eax
mov [EnabledTable + ebx],1
add edi,3
mov esi,offset FontTable
shl ebx,4
add esi,ebx
cpyloop:
cmp [byte ptr edi],0
je FUCKER
cmp [word ptr edi],0A0Dh
je NextFontLine
mov al,[byte ptr edi]
mov [byte ptr esi],al
inc edi
inc esi
jmp cpyloop
NextFontLine:
pop edi
@@end:
inc edi
cmp [byte ptr edi],0
je MainLoop
cmp [word ptr edi],0A0Dh
jnz @@end
add edi,2
jmp FontLoop
CaseStrBrk:
mov esi,offset TempString
mov ax,[word ptr edi+2]
mov [word ptr esi],ax
mov [byte ptr esi+2],0
mov ebx,16
call AscToNum
mov [StrBrk],al
mov [StrBrkDEF],1
jmp NextFontLine
CaseLineBrk:
mov esi,offset TempString
mov ax,[word ptr edi+2]
mov [word ptr esi],ax
mov [byte ptr esi+2],0
mov ebx,16
call AscToNum
mov [LineBrk],al
mov [LineBrkDEF],1
jmp NextFontLine
CaseSectBrk:
mov esi,offset TempString
mov ax,[word ptr edi+2]
mov [word ptr esi],ax
mov [byte ptr esi+2],0
mov ebx,16
call AscToNum
mov [SectBrk],al
mov [SectBrkDEF],1
jmp NextFontLine
FUCKER:
pop edi
jmp MainLoop
UseASCIITbl:
mov esi,offset EnabledTable + 32
mov edi,offset FontTable + 32*16
mov al,32
rept 94
mov [byte ptr esi],1
mov [byte ptr edi],al
inc al
inc esi
add edi,16
endm
MainLoop:
call UpdateScreen
mov ah,07h
int 21h
cmp al,0
je ExtendedKey
cmp al,09h
je ChangeMode
cmp al,27 ; ESC
je ShowMenu
cmp al,03h ; Ctrl-C
je CopyString
cmp al,16h ; Ctrl-V
je PasteString
cmp al,0Ch ; Ctrl-L
je UseFileSel
cmp al,11h ; Ctrl-Q
je exit
cmp al,8
je Left
cmp [EditMode],0
je HEXInput
cmp al,13
je NewLine
mov edi,offset TempString
mov [byte ptr edi+1],al
call ConvertToFontValue
jc MainLoop
cmp [DTEStatus],0
je WriteASCVal
mov [FontValue],al
mov ebx,[Row]
shl ebx,4
add ebx,[Column]
add ebx,[FileOffset]
cmp ebx,0
je NoEncode
mov esi,[FilePointer]
xor eax,eax
mov al,[byte ptr esi + ebx - 1]
shl eax,4
mov esi,offset FontTable
add esi,eax
call StrLength
cmp al,1 ; if it's already DTE...
ja NoEncode ; don't try to encode
mov al,[byte ptr esi]
mov [byte ptr edi+0],al
xor edx,edx
@@10:
mov ebx,edx
shl ebx,4
mov esi,offset FontTable
add esi,ebx
call StrLength
cmp al,1
je @@20
mov ax,[word ptr esi]
cmp ax,[word ptr edi]
jnz @@20
mov ebx,[Row]
shl ebx,4
add ebx,[Column]
add ebx,[FileOffset]
mov esi,[FilePointer]
mov [byte ptr esi + ebx - 1],dl
jmp MainLoop
@@20:
inc dl
jnz @@10
NoEncode:
mov al,[FontValue]
WriteASCVal:
mov ebx,[Row]
shl ebx,4
add ebx,[Column]
add ebx,[FileOffset]
mov esi,[FilePointer]
mov [byte ptr esi + ebx],al
jmp Right
NewLine:
cmp [LineBrkDEF],0
je MainLoop
mov al,[LineBrk]
jmp WriteASCVal
ExtendedKey:
int 21h
cmp al,3Bh
je GoOfs
cmp al,3Ch
je SearchText
cmp al,3Dh
je SearchAgain
cmp al,3Eh
je SearchHex
cmp al,3Fh
je SaveFile
cmp al,40h
je SearchRelative
cmp al,41h
je ScriptDumper
cmp al,42h
je ScriptInserter
;cmp al,43h
;je showfonttable
cmp al,43h
je SaveFontTable
cmp al,47h
je Home
cmp al,4Fh
je End_
cmp al,49h
je PageUp
cmp al,51h
je PageDown
;cmp al,52h
;je Insert
;cmp al,53h
;je Delete
cmp al,4Bh
je Left
cmp al,4Dh
je Right
cmp al,48h
je Up
cmp al,50h
je Down
jmp MainLoop
SaveFontTable:
mov esi,offset SaveFontWin
mov al,23
mov ah,8
mov bl,29
mov bh,5
call DrawWin
mov esi,offset TempString
mov al,36
mov ah,10
mov cl,12
call GetASCString
jc MainLoop
mov ah,3Ch
xor cx,cx
mov edx,offset TempString
int 21h
mov bx,ax
mov edi,offset FileNameBuffer
xor ecx,ecx
xor edx,edx
@@10:
cmp [EnabledTable + edx],1
jnz @@20
mov al,dl
shr al,4
call HexDigit
mov [byte ptr edi],al
inc edi
mov al,dl
and al,15
call HexDigit
mov [byte ptr edi],al
inc edi
mov [byte ptr edi],'='
inc edi
add ecx,3
mov esi,offset FontTable
mov eax,edx
shl eax,4
add esi,eax
call StrLength
add ecx,eax
@@30:
mov al,[byte ptr esi]
inc esi
mov [byte ptr edi],al
inc edi
cmp [byte ptr esi],0
jnz @@30
mov [word ptr edi],0A0Dh
add edi,2
add ecx,2
@@20:
inc dl
jnz @@10
mov ah,40h
mov edx,offset FileNameBuffer
int 21h
mov ah,3Eh
int 21h
jmp MainLoop
showfonttable:
mov edi,[videomem]
mov esi,offset fonttable
xor ebx,ebx
mov ch,16
@@10:
push edi
mov cl,16
@@20:
mov ah,14
add ah,[EnabledTable + ebx]
mov al,[byte ptr esi]
stosw
add esi,16
inc ebx
dec cl
jnz @@20
pop edi
add edi,160
dec ch
jnz @@10
mov ah,00
int 16h
jmp MainLoop
ToggleDTE:
xor [DTEStatus],1
jz DTEOFF
mov al,29
mov ah,8
mov bl,16
mov esi,offset DTEOnMessage
call DrawMsgBox
mov ah,00
int 16h
jmp MainLoop
DTEOFF:
mov al,28
mov ah,8
mov bl,17
mov esi,offset DTEOffMessage
call DrawMsgBox
mov ah,00
int 16h
jmp MainLoop
Insert:
mov esi,offset TempString
mov al,37
mov ah,10
mov cl,8
call GetHEXString
jc MainLoop
mov ebx,16
call AscToNum
mov edx,eax
mov ebx,[FileSize]
add ebx,eax
;cmp ebx,[MemAlloced]
;jae exit
mov esi,[FilePointer]
mov ecx,[FileSize]
add esi,ecx
dec esi
mov eax,[Row]
shl eax,4
add eax,[Column]
add eax,[FileOffset]
sub ecx,eax
InsLoop:
mov al,[byte ptr esi]
mov [byte ptr esi+edx],al
dec esi
dec ecx
jnz InsLoop
inc esi
mov edi,esi
mov ecx,edx
xor al,al
rep stosb
mov [FileSize],ebx
jmp MainLoop
Delete:
mov esi,offset TempString
mov al,37
mov ah,10
mov cl,8
call GetHEXString
jc MainLoop
mov ebx,16
call AscToNum
mov ebx,eax
cmp eax,[FileSize]
jae MainLoop
mov esi,[FilePointer]
mov eax,[Row]
shl eax,4
add eax,[Column]
add eax,[FileOffset]
add esi,eax
mov ecx,[FileSize]
sub ecx,eax
DelLoop:
mov al,[byte ptr esi+ebx]
mov [byte ptr esi],al
inc esi
dec ecx
jnz DelLoop
sub [FileSize],ebx
jmp MainLoop
;-----------------------------------------------------------------------------
ShowMenu:
call UpdateScreen
mov al,[Menu]
call DrawMenu
mov ah,00
int 16h
cmp ah,4Bh
je MenuLeft
cmp ah,4Dh
je MenuRight
cmp ah,48h
je ItemUp
cmp ah,50h
je ItemDown
cmp al,27
je MainLoop
cmp al,13
je GoMenu
jmp ShowMenu
MenuLeft:
cmp [Menu],0
je ShowMenu
mov [MenuItem],0
dec [Menu]
jmp ShowMenu
MenuRight:
cmp [Menu],4
je ShowMenu
mov [MenuItem],0
inc [Menu]
jmp ShowMenu
ItemUp:
cmp [MenuItem],0
je ShowMenu
dec [MenuItem]
jmp ShowMenu
ItemDown:
movzx eax,[Menu]
mov esi,[MenuTableTXT + eax*4]
mov al,[byte ptr esi]
dec al
cmp al,[MenuItem]
je ShowMenu
inc [MenuItem]
jmp ShowMenu
GoMenu:
call UpDateScreen
movzx eax,[Menu]
mov esi,[MenuTableJMP + eax*4]
movzx eax,[MenuItem]
jmp [dword ptr esi + eax*4]
PROC DrawMenu
pushad
movzx eax,al
mov esi,[MenuTableTXT + eax*4]
inc esi
mov edi,[VideoMem]
add edi,160
movzx eax,[MenuLength + eax]
add eax,eax
add edi,eax
push edi
mov ah,70h
mov al,0DAh
stosw
mov al,0C4h
rept 20
stosw
endm
mov al,0BFh
stosw
pop edi
add edi,160
xor ecx,ecx
DoOne:
mov ah,70h
cmp cl,[MenuItem]
jnz hurragutt
mov ah,07h
hurragutt:
push edi
mov al,0B3h
stosw
push edi
mov al,20h
rept 20
stosw
endm
mov al,0B3h
stosw
mov [byte ptr edi+1],07h
mov [byte ptr edi+3],07h
pop edi
add edi,2
MenuLoop:
lodsb
cmp al,0
je ItemDone
stosw
jmp MenuLoop
ItemDone:
pop edi
add edi,160
inc cl
cmp [byte ptr esi],0
jnz DoOne
push edi
mov ah,70h
mov al,0C0h
stosw
mov al,0C4h
rept 20
stosw
endm
mov al,0D9h
stosw
mov [byte ptr edi+1],07h
mov [byte ptr edi+3],07h
pop edi
add edi,160+4
rept 22
mov [byte ptr edi+1],07h
add edi,2
endm
popad
ret
ENDP DrawMenu
;-----------------------------------------------------------------------------
ChangeMode:
xor [EditMode],1
jmp MainLoop
HEXInput:
call UpChar
call CheckHex
jc MainLoop
mov esi,offset TempString
mov [byte ptr esi+0],al
mov edi,[VideoMem]
add edi,(160*2)+24
mov eax,[Row]
shl eax,7
add edi,eax
shr eax,2
add edi,eax
mov eax,[Column]
shl eax,2
add edi,eax
mov eax,[Column]
mov ah,al
and ah,1
shl ah,2
mov al,15
xor al,ah
or al,20h
mov [byte ptr edi+1],al
mov [byte ptr edi+3],0F0h
mov al,[byte ptr esi]
mov [byte ptr edi],al
_2ndDigit:
mov ah,00h
int 16h
call UpChar
call CheckHex
jc _2ndDigit
mov [byte ptr esi+1],al
mov [byte ptr esi+2],0
mov esi,offset TempString
mov ebx,16
call AscToNum
mov ebx,[Row]
shl ebx,4
add ebx,[Column]
add ebx,[FileOffset]
mov esi,[FilePointer]
mov [byte ptr esi + ebx],al
jmp Right
GoOfs:
mov esi,offset OfsWin
mov al,26
mov ah,8
mov bl,23
mov bh,5
call DrawWin
mov esi,offset TempString
mov al,37
mov ah,10
mov cl,8
call GetHEXString
jc MainLoop
mov ebx,16
call AscToNum
cmp eax,[FileSize]
jae BadOfs
GoThere:
mov [FileOffset],eax
and [FileOffset],0FFFFFF00h
and eax,0FFh
mov [Column],eax
and [Column],0Fh
shr eax,4
mov [Row],eax
jmp MainLoop
BadOfs:
mov ah,02
mov dl,7
int 21h
jmp GoOfs
;-----------------------------------------------------------------------------
SearchText:
mov esi,offset TextSearchWin
mov al,23
mov ah,7
mov bl,29
mov bh,5
call DrawWin
mov esi,offset SearchString
mov al,32
mov ah,9
mov cl,16
call GetString
jc MainLoop
mov esi,offset SearchMessage
mov al,20
mov ah,5
mov bl,16
call DrawMsgBox
mov [SearchType],0
mov [SearchLen],cl
xor ebx,ebx
mov edx,ecx
SearchLoop:
mov esi,[FilePointer]
add esi,ebx
mov edi,offset SearchString
mov ecx,edx
inc cl
repe cmpsb
cmp cl,0
je short SearchFound
inc ebx
cmp ebx,[FileSize]
je short NotFound
jmp short SearchLoop
NotFound:
call UpdateScreen
mov esi,offset SearchError
mov al,26
mov ah,9
mov bl,21
call DrawMsgBox
mov ah,00
int 16h
jmp MainLoop
SearchFound:
mov eax,ebx
jmp GoThere
SearchDTE:
mov esi,offset SearchString
mov edi,offset SearchString
jmp SearchLoop
SearchAgain:
cmp [SearchLen],0
je SearchText
movzx edx,[SearchLen]
mov ebx,[Row]
shl ebx,4
add ebx,[Column]
add ebx,[FileOffset]
inc ebx
cmp [SearchType],1
jnz SearchLoop
mov ebp,ebx
jmp RelLoop1
;-----------------------------------------------------------------------------
SearchHex:
mov esi,offset HexSearchWin
mov al,18
mov ah,7
mov bl,44
mov bh,5
call DrawWin
mov esi,offset SearchString
mov al,26
mov ah,9
mov cl,32
call GetHEXString
jc MainLoop
test cl,1
jnz EvenDigitError
shr cl,1
mov [SearchType],0
mov [SearchLen],cl
mov edx,ecx
mov esi,offset SearchString
mov edi,offset SearchString
@@10:
mov ax,[word ptr esi]
push esi
mov esi,offset TempString
mov [word ptr esi],ax
mov [byte ptr esi+2],0
mov ebx,16
call AscToNum
mov [byte ptr edi],al
inc edi
pop esi
add esi,2
dec cl
jnz @@10
mov esi,offset SearchMessage
mov al,20
mov ah,5
mov bl,16
call DrawMsgBox
xor ebx,ebx
jmp SearchLoop
EvenDigitError:
mov esi,offset HexError
mov al,24
mov ah,9
mov bl,38
call DrawMsgBox
mov ah,00
int 16h
call UpdateScreen
jmp SearchHex
;-----------------------------------------------------------------------------
SearchRelative:
mov esi,offset RelSearchWin
mov al,24
mov ah,7
mov bl,29
mov bh,5
call DrawWin
mov esi,offset SearchString
mov al,33
mov ah,9
mov cl,16
call GetASCString
jc MainLoop
cmp cl,1
jbe MainLoop
mov esi,offset SearchMessage
mov al,20
mov ah,5
mov bl,16
call DrawMsgBox
mov [SearchLen],cl
mov [SearchType],1
mov esi,offset SearchString
call StrLength
dec eax
mov [temp],eax
xor ebp,ebp
RelLoop1:
mov esi,offset SearchString
mov edi,[FilePointer]
add edi,ebp
mov ecx,[temp]
RelLoop2:
xor eax,eax
mov al,[byte ptr esi]
xor ebx,ebx
mov bl,[byte ptr esi+1]
sub eax,ebx
mov bl,[byte ptr edi]
xor edx,edx
mov dl,[byte ptr edi+1]
sub ebx,edx
cmp eax,ebx
je short _match
inc ebp
mov eax,[FileSize]
dec eax
cmp ebp,eax
jnz short RelLoop1
jmp NotFound
_match:
inc esi
inc edi
dec ecx
jnz RelLoop2
call UpdateScreen
mov esi,offset BuildMessage
mov al,16
mov ah,8
mov bl,43
call DrawMsgBox
getYN:
mov ah,00
int 16h
call UpChar
cmp al,'Y'
je BuildFontTable
cmp al,'N'
je NoFontBuild
jmp getYN
BuildFontTable:
call ClearFontTable
mov esi,offset SearchString
mov dl,[byte ptr esi]
mov esi,[FilePointer]
add esi,ebp
xor eax,eax
mov al,[byte ptr esi]
@@10:
cmp dl,'A'-1
je @@20
cmp dl,'A'+32-1
je @@20
mov ebx,eax
mov [EnabledTable + ebx],1
shl ebx,4
mov esi,offset FontTable
add esi,ebx
mov [byte ptr esi+0],dl
mov [byte ptr esi+1],0
dec al
dec dl
jmp @@10
@@20:
mov esi,offset SearchString
mov dl,[byte ptr esi]
mov esi,[FilePointer]
add esi,ebp
xor eax,eax
mov al,[byte ptr esi]
@@30:
cmp dl,'Z'+1
je @@40
cmp dl,'Z'+32+1
je @@40
mov ebx,eax
mov [EnabledTable + ebx],1
shl ebx,4
mov esi,offset FontTable
add esi,ebx
mov [byte ptr esi+0],dl
mov [byte ptr esi+1],0
inc al
inc dl
jmp @@30
@@40:
;-------------------
NoFontBuild:
mov eax,ebp
jmp GoThere
;-----------------------------------------------------------------------------
SaveFile:
mov ah,3Ch
xor cx,cx
mov edx,offset FileName
int 21h
mov bx,ax
mov ah,40h
mov ecx,[FileSize]
mov edx,[FilePointer]
int 21h
mov ah,3Eh
int 21h
mov al,29
mov ah,8
mov bl,18
mov esi,offset SaveMessage
call DrawMsgBox
mov ah,00
int 16h
jmp MainLoop
;-----------------------------------------------------------------------------
ScriptDumper:
mov esi,offset DumperWin
mov al,25
mov ah,6
mov bl,29
mov bh,9
call DrawWin
mov esi,offset TempString
mov al,42
mov ah,8
mov cl,8
call GetHEXString
jc MainLoop
mov esi,offset TempString + 16
mov al,42
mov ah,10
mov cl,8
call GetHEXString
jc MainLoop
mov esi,offset TempString + 32
mov al,38
mov ah,12
mov cl,12
call GetASCString
jc MainLoop
mov esi,offset TempString
mov ebx,16
call AscToNum
mov ecx,eax
mov esi,offset TempString + 16
call AscToNum
mov edx,eax
cmp ecx,edx
jb DumpAddrOK
mov esi,offset DumpError
mov al,14
mov ah,8
mov bl,47
call DrawMsgBox
mov ah,00
int 16h
call UpdateScreen
jmp ScriptDumper
DumpAddrOK:
cmp edx,[FileSize]
jb DumpAddrOK2
mov edx,[FileSize]
dec edx
DumpAddrOK2:
pushad
mov esi,offset DumpMessage
mov al,29
mov ah,8
mov bl,14
call DrawMsgBox
popad
sub edx,ecx
mov ebp,edx
inc ebp
mov esi,[FilePointer]
add esi,ecx
mov ah,3Ch
xor cx,cx
mov edx,offset TempString + 32
int 21h
mov bx,ax
DumpLine:
mov edi,offset FileNameBuffer
xor ecx,ecx
xor dl,dl
cmp ebp,256
jae DumpLoop
mov edx,ebp
mov ebp,256
DumpLoop:
xor eax,eax
mov al,[byte ptr esi]
cmp [EnabledTable + eax],1
je DumpFromTable
cmp [LineBrkDEF],1
jnz CheckEndOfString
cmp al,[LineBrk]
jnz CheckEndOfString
mov [word ptr edi],0A0Dh
add edi,2
add ecx,2
jmp DumpNextChar
CheckEndOfString:
cmp [StrBrkDEF],1
jnz CheckEndOfSect
cmp al,[StrBrk]
jnz CheckEndOfSect
mov [byte ptr edi+0],'<'
mov [byte ptr edi+1],'E'
mov [byte ptr edi+2],'N'
mov [byte ptr edi+3],'D'
mov [byte ptr edi+4],'>'
mov [dword ptr edi+5],0A0D0A0Dh
add edi,9
add ecx,9
jmp DumpNextChar
CheckEndOfSect:
cmp [SectBrkDEF],1
jnz DumpHexValue
cmp al,[SectBrk]
jnz DumpHexValue
mov [dword ptr edi],0A0D0A0Dh
add edi,4
add ecx,4
jmp DumpNextChar
DumpHexValue:
mov [word ptr edi+0],'$<'
mov ah,al
shr al,4
call HexDigit
mov [byte ptr edi+2],al
mov al,ah
and al,15
call HexDigit
mov [byte ptr edi+3],al
mov [byte ptr edi+4],'>'
add edi,5
add ecx,5
jmp DumpNextChar
DumpFromTable:
push esi
shl eax,4
mov esi,offset FontTable
add esi,eax
call StrLength
push ecx
mov ecx,eax
rep movsb
pop ecx
add ecx,eax
pop esi
DumpNextChar:
inc esi
dec dl
jnz DumpLoop
mov edx,offset FileNameBuffer
mov ah,40h
int 21h
sub ebp,256
jnz DumpLine
mov ah,3Eh
int 21h
jmp MainLoop
;-----------------------------------------------------------------------------
ScriptInserter:
mov esi,offset ScriptInsWin
mov al,24
mov ah,8
mov bl,29
mov bh,7
call DrawWin
mov esi,offset TempString + 32
mov al,37
mov ah,10
mov cl,12
call GetASCString
jc MainLoop
mov esi,offset TempString
mov al,41
mov ah,12
mov cl,8
call GetHEXString
jc MainLoop
mov esi,offset TempString
mov ebx,16
call AscToNum
mov ebp,eax
mov edi,[FilePointer]
mov ax,3D00h
mov edx,offset TempString + 32
int 21h
jnc ScriptOK
mov esi,offset ScriptOpenError
mov al,21
mov ah,7
mov bl,33
call DrawMsgBox
mov ah,00
int 16h
jmp MainLoop
ScriptOK:
mov [FileHandle],ax
mov ah,4Eh
mov cx,10h
mov edx,offset TempString + 32
int 21h
mov esi,[PSP]
add esi,9Ah
mov eax,[dword ptr esi]
mov [ScriptSize],eax
mov edx,[ScriptSize]
inc edx
mov ax,0EE42h
int 31h
mov [ScriptPointer],edx
cmp eax,[ScriptSize]
jae StartScriptIns
mov esi,offset ScriptMemError
mov al,14
mov ah,8
mov bl,48
call DrawMsgBox
mov ah,00
int 16h
jmp ScriptInsEnd
StartScriptIns:
mov esi,offset InsMessage
mov al,29
mov ah,6
mov bl,16
call DrawMsgBox
mov bx,[FileHandle]
mov ah,3Fh
mov edx,[ScriptPointer]
mov ecx,[ScriptSize]
int 21h
cmp eax,[ScriptSize]
jnz exit
mov esi,[ScriptPointer]
mov [byte ptr esi + eax],0
mov ah,3Eh
int 21h
ScriptInsLoop:
cmp [byte ptr esi],0
je ScriptInsEnd
cmp ebp,[FileSize]
jae ScriptInsEnd
mov al,[byte ptr esi]
cmp al,'<'
je InsertSpecial
cmp al,0Dh
je InsertLineBrk
call ConvertToFontValue
mov [byte ptr edi + ebp],al
inc ebp
inc esi
jmp ScriptInsLoop
InsertLineBrk:
cmp [word ptr esi+2],0A0Dh
je InsertSectBrk
mov al,[LineBrk]
mov [byte ptr edi + ebp],al
inc ebp
add esi,2
jmp ScriptInsLoop
InsertSectBrk:
mov al,[SectBrk]
mov [byte ptr edi + ebp],al
inc ebp
add esi,4
jmp ScriptInsLoop
InsertSpecial:
cmp [word ptr esi],'$<'
je InsertHex
mov al,[StrBrk]
mov [byte ptr edi + ebp],al
inc ebp
add esi,5
cmp [byte ptr esi],0Dh
jnz ScriptInsLoop
add esi,2
cmp [byte ptr esi],0Dh
jnz ScriptInsLoop
add esi,2
jmp ScriptInsLoop
InsertHex:
mov dl,[byte ptr esi+2]
call ValCh
mov al,dl
shl al,4
mov dl,[byte ptr esi+3]
call ValCh
or al,dl
mov [byte ptr edi + ebp],al
inc ebp
add esi,5
jmp ScriptInsLoop
ScriptInsEnd:
mov ax,0EE40h
int 31h
jmp MainLoop
;-----------------------------------------------------------------------------
ShowCommands:
mov esi,offset CmdMessage
mov al,20
mov ah,3
mov bl,34
call DrawMsgBox
mov ah,00
int 16h
jmp MainLoop
ShowAboutBox:
mov esi,offset AboutMessage
mov al,22
mov ah,7
mov bl,31
call DrawMsgBox
mov ah,00
int 16h
jmp MainLoop
CopyString:
jmp MainLoop
PasteString:
jmp MainLoop
Home:
cmp [Column],0
je Hurra7
mov [Column],0
jmp MainLoop
Hurra7:
mov [Row],0
jmp MainLoop
End_:
cmp [Column],0Fh
je Hurra8
mov eax,[Row]
shl eax,4
add eax,[FileOffset]
add eax,10h
cmp eax,[FileSize]
jae Hurra9
mov [Column],0Fh
jmp MainLoop
Hurra9:
mov eax,[FileSize]
dec eax
and eax,0Fh
mov [Column],eax
jmp MainLoop
Hurra8:
mov eax,[FileOffset]
add eax,0FFh
cmp eax,[FileSize]
jae MainLoop
mov [Row],0Fh
jmp MainLoop
PageUp:
cmp [FileOffset],100h
jb Hurra5
sub [FileOffset],100h
jmp MainLoop
Hurra5:
cmp [FileOffset],0
je Hurra6
mov [FileOffset],0
jmp MainLoop
Hurra6:
mov [Row],0
jmp MainLoop
PageDown:
mov eax,[Row]
shl eax,4
add eax,[Column]
add eax,[FileOffset]
add eax,100h
cmp eax,[FileSize]
jae MainLoop
add [FileOffset],100h
jmp MainLoop
Left:
;mov ah,02
;int 16h
;test al,2
;jnz MarkLeft
mov [MarkLength],0
cmp [Column],0
je Hurra3
dec [Column]
and [Column],0Fh
jmp MainLoop
Hurra3:
cmp [Row],0
je Hurra11
dec [Column]
and [Column],0Fh
dec [Row]
jmp MainLoop
Hurra11:
cmp [FileOffset],0
je MainLoop
mov [Column],0Fh
sub [FileOffset],10h
jmp MainLoop
MarkLeft:
cmp [MarkLength],0
je MainLoop
dec [MarkLength]
jmp MainLoop
Right:
mov eax,[Row]
shl eax,4
add eax,[Column]
add eax,[FileOffset]
inc eax
cmp eax,[FileSize]
jae MainLoop
;mov ah,02
;int 16h
;test al,2
;jnz MarkRight
mov [MarkLength],0
cmp [Column],0Fh
je Hurra4
inc [Column]
and [Column],0Fh
jmp MainLoop
Hurra4:
cmp [Row],0Fh
je Hurra10
inc [Column]
and [Column],0Fh
inc [Row]
jmp MainLoop
Hurra10:
mov [Column],0
add [FileOffset],10h
jmp MainLoop
MarkRight:
inc [MarkLength]
jmp MainLoop
Up:
cmp [Row],00h
je Hurra2
dec [Row]
and [Row],0Fh
jmp MainLoop
Hurra2:
cmp [FileOffset],0
je MainLoop
sub [FileOffset],10h
jmp MainLoop
Down:
mov eax,[Row]
shl eax,4
add eax,[Column]
add eax,[FileOffset]
add eax,10h
cmp eax,[FileSize]
jae MainLoop
cmp [Row],0Fh
je Hurra
inc [Row]
and [Row],0Fh
jmp MainLoop
Hurra:
add [FileOffset],10h
jmp MainLoop
Exit:
mov esi,offset OldScreen
mov edi,[VideoMem]
mov ecx,(80*25*2)/4
rep movsd
Terminate:
mov ax,4C00h
int 21h
;-----------------------------------------------------------------------------
PROC UpdateScreen
pushad
mov esi,offset HPInt
mov edi,offset VirtualScreen
mov ecx,(80*25*2)/4
rep movsd
call ShowOffsets
call ShowInfo
call ShowHEXColumn
call ShowASCColumn
call HiLightLine
call ShowCursor
call ShowFileName
mov esi,offset VirtualScreen
mov edi,[VideoMem]
mov ecx,(80*25*2)/4
rep movsd
popad
ret
ENDP UpdateScreen
PROC ShowFileName
pushad
mov esi,offset FileName
xor ecx,ecx
@@10:
inc ecx
inc esi
cmp [byte ptr esi],0
jnz @@10
dec esi
mov edi,offset VirtualScreen + 77*2
mov ah,70h
mov al,']'
stosw
sub edi,4
@@20:
lodsb
stosw
sub esi,2
sub edi,4
dec ecx
jnz @@20
mov al,'['
stosw
popad
ret
ENDP ShowFileName
;-----------------------------------------------------------------------------
PROC ShowHEXColumn
pushad
mov esi,[FilePointer]
mov ebp,[FileOffset]
GotoXY 12,2
mov ebx,16
mov cl,2
mov dh,16
@@10:
mov dl,16
@@20:
cmp ebp,[FileSize]
je @@99
mov al,[byte ptr esi + ebp]
call NumToASCII
xor [CharAttrib],4
add edi,4
inc ebp
dec dl
jnz @@20
add edi,160-64
dec dh
jnz @@10
@@99:
mov [CharAttrib],0Fh
popad
ret
ENDP ShowHEXColumn
;-----------------------------------------------------------------------------
PROC FileSelector
pushad
@@StartItUp:
mov edi,offset Directory
mov ecx,64
xor al,al
rep stosb
mov ah,47h
xor dl,dl
mov esi,offset Directory
int 21h
mov edi,offset FileNameBuffer
mov ebp,1
mov ah,4Eh
mov cx,10h
mov edx,offset FileSpec
int 21h
mov esi,[PSP]
mov al,[byte ptr esi + 80h + 15h]
shr al,4
and al,1
stosb
add esi,80h + 1Eh ; ESI points to DTA
mov ecx,13
rep movsb
@@FindNext:
mov cx,10h
mov ah,4Fh
int 21h
jc @@FoundAll
mov esi,[PSP]
mov al,[byte ptr esi + 80h + 15h]
shr al,4
and al,1
stosb
add esi,80h + 1Eh ; ESI points to DTA
mov ecx,13
rep movsb
inc ebp
jmp @@FindNext
@@FoundAll:
mov [FileCount],ebp
mov ecx,[FileCount]
dec ecx
@@SortFiles:
push ecx
mov esi,offset FileNameBuffer
@@SortLoop:
mov al,[byte ptr esi]
cmp al,[byte ptr esi+14]
jae @@OrderOK
push esi
rept 14
mov al,[byte ptr esi]
mov ah,[byte ptr esi+14]
mov [byte ptr esi],ah
mov [byte ptr esi+14],al
inc esi
endm
pop esi
@@OrderOK:
add esi,14
dec ecx
jnz @@SortLoop
pop ecx
dec ecx
jnz @@SortFiles
mov ecx,[FileCount]
dec ecx
@@SortFiles2:
push ecx
mov esi,offset FileNameBuffer
@@SortLoop2:
mov al,[byte ptr esi]
cmp al,[byte ptr esi+14]
jnz @@OrderOK2
mov al,[byte ptr esi+1]
cmp al,[byte ptr esi+14+1]
jb @@OrderOK2
push esi
rept 14
mov al,[byte ptr esi]
mov ah,[byte ptr esi+14]
mov [byte ptr esi],ah
mov [byte ptr esi+14],al
inc esi
endm
pop esi
@@OrderOK2:
add esi,14
dec ecx
jnz @@SortLoop2
pop ecx
dec ecx
jnz @@SortFiles2
mov [FilePage],0
mov [FileSel],0
@@FileWaitKey:
call ShowFiles
mov ah,00h
int 16h
cmp ah,49h
je @@FilePGUp
cmp ah,51h
je @@FilePGDown
cmp ah,4Bh
je @@FileLeft
cmp ah,4Dh
je @@FileRight
cmp ah,48h
je @@FileUp
cmp ah,50h
je @@FileDown
cmp al,13
je @@FileEnd
cmp al,27
je Exit
jmp @@FileWaitKey
@@FilePGUp:
cmp [FilePage],0
je @@FileWaitKey
dec [FilePage]
jmp @@FileWaitKey
@@FilePGDown:
mov eax,[FilePage]
inc eax
mov edx,21*4
mul edx
cmp eax,[FileCount]
jae @@FileWaitKey
inc [FilePage]
mov [FileSel],0
jmp @@FileWaitKey
@@FileLeft:
cmp [FileSel],0
je @@FileWaitKey
dec [FileSel]
jmp @@FileWaitKey
@@FileRight:
cmp [FileSel],(4*20)+3
je @@FileWaitKey
mov eax,[FilePage]
mov edx,21*4
mul edx
add eax,[FileSel]
inc eax
cmp eax,[FileCount]
je @@FileWaitKey
inc [FileSel]
jmp @@FileWaitKey
@@FileUp:
cmp [FileSel],4
jb @@FileWaitKey
sub [FileSel],4
jmp @@FileWaitKey
@@FileDown:
cmp [FileSel],4*20
jae @@FileWaitKey
mov eax,[FilePage]
mov edx,21*4
mul edx
add eax,[FileSel]
add eax,4
cmp eax,[FileCount]
jae @@FileWaitKey
add [FileSel],4
jmp @@FileWaitKey
@@ChangeDir:
mov ah,3Bh
mov edx,esi
int 21h
jmp @@StartItUp
@@FileEnd:
mov eax,[FilePage]
mov edx,21*4*14
mul edx
mov ebx,eax
mov eax,[FileSel]
mov edx,14
mul edx
add ebx,eax
mov esi,offset FileNameBuffer
add esi,ebx
lodsb
cmp al,1
je @@ChangeDir
mov edi,offset FileName
mov ecx,13
rep movsb
popad
ret
ENDP FileSelector
PROC ShowFiles
pushad
mov esi,offset FSInt
mov edi,offset VirtualScreen
mov ecx,(80*25*2)/4
rep movsd
mov edi,offset VirtualScreen + (2*160) + 6
mov esi,offset FileNameBuffer
mov eax,[FilePage]
mov edx,14*21*4
mul edx
add esi,eax
mov eax,[FilePage]
inc eax
mov edx,21*4
mul edx
mov ecx,21*4
cmp [FileCount],eax
jae @@ShowFileName
mov ecx,[FileCount]
sub eax,21*4
sub ecx,eax
@@ShowFileName:
push esi edi
mov dl,13
mov ah,15
lodsb
xor ah,al
@@ShowChar:
lodsb
cmp al,0
je @@EndShow
stosw
dec dl
jnz @@ShowChar
@@EndShow:
pop edi esi
add esi,14
add edi,40
dec ecx
jnz @@ShowFileName
mov edi,offset VirtualScreen + (2*160) + 6
mov eax,[FileSel]
mov edx,20*2
mul edx
add edi,eax
rept 12
mov [byte ptr edi+1],70h
add edi,2
endm
mov esi,offset Directory
mov edi,offset VirtualScreen + (24*160) + 2
rept 64
mov al,[byte ptr esi]
mov [byte ptr edi],al
inc esi
add edi,2
endm
mov esi,offset VirtualScreen
mov edi,[VideoMem]
mov ecx,(80*25*2)/4
rep movsd
popad
ret
ENDP ShowFiles
;-----------------------------------------------------------------------------
PROC AscToNum
push ebx ecx edx edi esi
mov edi,esi
@@20:
inc edi
cmp [byte ptr edi],0
jnz @@20
xor eax,eax
mov ecx,1
@@10:
cmp edi,esi
je @@99
dec edi
movzx edx,[byte ptr edi]
call ValCh
push ecx
xchg eax,ecx
mul edx
add ecx,eax
pop eax
mul ebx
xchg eax,ecx
jmp @@10
@@99:
pop esi edi edx ecx ebx
ret
ENDP AscToNum
PROC NumToASCII
pushad
mov ch,cl
@@10:
xor edx,edx
div ebx
push edx
dec cl
jnz short @@10
mov ah,[CharAttrib]
@@20:
pop edx
mov al,dl
call HexDigit
mov [word ptr edi],ax
add edi,2
dec ch
jnz short @@20
popad
ret
ENDP NumToASCII
PROC HexDigit
; converts hex digit (range 0-F) to ASCII char
cmp al,9
jbe short @@10
add al,7
@@10:
add al,30h
ret
ENDP HexDigit
PROC ValCh
; converts ASCII char ("0".."F") to 0..15
cmp dl,'9'
jbe short @@10
sub dl,7
cmp dl,'a'-7
jb short @@10
sub dl,20h
@@10:
sub dl,30h
ret
ENDP ValCh
;-----------------------------------------------------------------------------
PROC ShowOffsets
pushad
GotoXY 2,2
mov eax,[FileOffset]
mov ebx,16
mov cl,8
rept 16
call NumToASCII
add edi,160
add eax,10h
endm
popad
ret
ENDP ShowOffsets
;-----------------------------------------------------------------------------
PROC ShowASCColumn
pushad
GotoXY 46,2
mov esi,[FilePointer] ; pointer to file data
mov ebp,[FileOffset] ; current file offset
mov dh,16 ; do 16 rows
@@10:
mov dl,16 ; do 16 columns
push edi ; save display address
@@20:
cmp ebp,[FileSize] ; reached end of file?
jb @@ok ; if not, display char(s)
pop edi
jmp @@99 ; otherwise, abort
@@ok:
movzx ebx,[byte ptr esi + ebp] ; fetch byte from file data
push esi ; save file pointer
cmp bl,[StrBrk] ; char = EOS?
je @@end_of_str
cmp bl,[LineBrk] ; char = EOL?
je @@end_of_line
cmp bl,[SectBrk]
je @@end_of_sect
jmp @@use_table ; use font table
@@end_of_str:
cmp [StrBrkDEF],1
jnz @@use_table
mov [word ptr edi],0CFEh
add edi,2
jmp @@next_byte
@@end_of_line:
cmp [LineBrkDEF],1
jnz @@use_table
mov [word ptr edi],0C19h
add edi,2
jmp @@next_byte
@@end_of_sect:
cmp [SectBrkDEF],1
jnz @@use_table
mov [word ptr edi],0B1Fh
add edi,2
jmp @@next_byte
@@use_table:
shl ebx,4
mov esi,offset FontTable
add esi,ebx
call StrLength
mov ah,[CharAttrib]
cmp al,1 ; length of string = 1?
je @@30
dec ah
cmp al,2 ; length of string = 2?
je @@30
dec ah
mov al,2 ;;;
@@30:
mov al,[byte ptr esi] ; get char from font table
cmp al,0 ; end of string?
je @@next_byte
stosw ; display char
inc esi ; increase font table pointer
jmp @@30 ; do another char
@@next_byte:
pop esi ; restore pointer to file data
inc ebp
dec dl ; done 16 columns yet?
jnz @@20 ; if not, do another
pop edi ; restore gfx pointer
add edi,80*2 ; next line on the screen
dec dh ; done 16 row yet?
jnz @@10 ; if not, do another
@@99:
popad
ret
ENDP ShowASCColumn
;-----------------------------------------------------------------------------
PROC ShowInfo
pushad
mov ebx,16
mov cl,8
GotoXY 6,19
mov eax,[Row]
shl eax,4
add eax,[Column]
add eax,[FileOffset]
call NumToASCII
GotoXY 6,20
mov eax,[FileSize]
dec eax
call NumToASCII
GotoXY 24,19
mov eax,[Row]
mov cl,2
call NumToASCII
GotoXY 24,20
mov eax,[Column]
call NumToASCII
GotoXY 32,19
mov esi,[Row]
shl esi,4
add esi,[Column]
add esi,[FileOffset]
add esi,[FilePointer]
mov al,[byte ptr esi]
call NumToASCII
GotoXY 32,20
mov ebx,10
mov cl,3
call NumToASCII
GotoXY 41,19
mov ebx,8
call NumToASCII
GotoXY 41,20
mov ebx,2
mov cl,8
call NumToASCII
sub esi,[Column]
xor edx,edx
rept 16
movzx ebx,[byte ptr esi]
shl ebx,4
push esi
mov esi,offset FontTable
add esi,ebx
call StrLength
add dl,al
pop esi
inc esi
endm
GotoXY 65,19
mov eax,edx
mov ebx,10
mov cl,2
call NumToASCII
GotoXY 15,19
mov eax,100
mov edx,[Row]
shl edx,4
add edx,[Column]
add edx,[FileOffset]
mul edx
mov ebx,[FileSize]
xor edx,edx
div ebx
mov ebx,10
mov cl,2
call NumToASCII
popad
ret
ENDP ShowInfo
PROC GetString
push ebx edx edi esi
mov edi,[VideoMem]
movzx edx,ah
shl edx,7
add edi,edx
shr edx,2
add edi,edx
movzx edx,al
add edx,edx
add edi,edx
xor ch,ch
@@getchar:
mov [word ptr edi],8F16h
mov ah,00
int 16h
cmp al,8
je @@bspace
cmp al,13
je @@enter
cmp al,27
je @@esc
cmp ch,cl
je @@getchar
mov bl,al
call ConvertToFontValue
jc @@getchar
inc ch
mov [byte ptr esi],al
inc esi
mov ah,15
mov al,bl
stosw
jmp @@getchar
@@bspace:
cmp ch,0
je @@getchar
dec ch
mov [byte ptr esi],0
dec esi
mov [word ptr edi],0F00h
sub edi,2
jmp @@getchar
@@esc:
pop esi edi edx ebx
stc
ret
@@needinput:
mov ah,02
mov dl,7
int 21h
jmp @@getchar
@@enter:
cmp ch,0
je @@needinput
mov [word ptr edi],0
mov [byte ptr esi],0
pop esi edi edx ebx
movzx ecx,ch
clc
ret
ENDP GetString
PROC GetASCString
push ebx edx edi esi
mov edi,[VideoMem]
movzx edx,ah
shl edx,7
add edi,edx
shr edx,2
add edi,edx
movzx edx,al
add edx,edx
add edi,edx
xor ch,ch
@@getchar:
mov [word ptr edi],8F16h
mov ah,00
int 16h
cmp al,8
je @@bspace
cmp al,13
je @@enter
cmp al,27
je @@esc
cmp ch,cl
je @@getchar
inc ch
mov [byte ptr esi],al
inc esi
mov ah,15
stosw
jmp @@getchar
@@bspace:
cmp ch,0
je @@getchar
dec ch
mov [byte ptr esi],0
dec esi
mov [word ptr edi],0F00h
sub edi,2
jmp @@getchar
@@esc:
pop esi edi edx ebx
stc
ret
@@needinput:
mov ah,02
mov dl,7
int 21h
jmp @@getchar
@@enter:
cmp ch,0
je @@needinput
mov [word ptr edi],0
mov [byte ptr esi],0
pop esi edi edx ebx
movzx ecx,ch
clc
ret
ENDP GetASCString
PROC GetHEXString
push ebx edx edi esi
mov edi,[VideoMem]
movzx edx,ah
shl edx,7
add edi,edx
shr edx,2
add edi,edx
movzx edx,al
add edx,edx
add edi,edx
xor ch,ch
@@getchar:
mov [word ptr edi],8F16h
mov ah,00
int 16h
cmp al,8
je @@bspace
cmp al,13
je @@enter
cmp al,27
je @@esc
cmp ch,cl
je @@getchar
call UpChar
call CheckHex
jc @@getchar
inc ch
mov [byte ptr esi],al
inc esi
mov ah,15
stosw
jmp @@getchar
@@bspace:
cmp ch,0
je @@getchar
dec ch
mov [byte ptr esi],0
dec esi
mov [word ptr edi],0F00h
sub edi,2
jmp @@getchar
@@esc:
pop esi edi edx ebx
stc
ret
@@needinput:
mov ah,02
mov dl,7
int 21h
jmp @@getchar
@@enter:
cmp ch,0
je @@needinput
mov [word ptr edi],0
mov [byte ptr esi],0
pop esi edi edx ebx
movzx ecx,ch
clc
ret
ENDP GetHEXString
PROC StrLength
xor eax,eax
@@10:
cmp [byte ptr esi + eax],0
je @@99
inc eax
jmp @@10
@@99:
ret
ENDP StrLength
PROC StrCopy
push esi edi
@@10:
cmp [byte ptr esi],0
je @@99
movsb
jmp @@10
@@99:
movsb
pop edi esi
ret
ENDP StrCopy
PROC SetFileExt
push esi edi
@@10:
cmp [byte ptr edi],'.'
je @@99
cmp [byte ptr edi],0
je @@99
inc edi
jmp @@10
@@99:
movsb
cmp [byte ptr esi],0
jnz @@99
movsb
pop edi esi
ret
ENDP SetFileExt
;-----------------------------------------------------------------------------
PROC ShowCursor
pushad
GotoXY 12,2
mov eax,[Row]
shl eax,7
add edi,eax
shr eax,2
add edi,eax
push edi
mov eax,[Column]
shl eax,2
add edi,eax
mov al,[EditMode]
xor al,1
ror al,1
add al,70h
mov cl,[MarkLength]
inc cl
cmp cl,1
je @@last
mov ebx,[Column]
mov al,70h
@@10:
mov [byte ptr edi+1],al
mov [byte ptr edi+3],al
add edi,4
inc bl
and bl,0Fh
jnz @@ok
add edi,160-64
@@ok:
dec cl
jnz @@10
@@last:
mov [byte ptr edi+1],al
pop edi
add edi,68
mov esi,[FilePointer]
mov eax,[FileOffset]
add esi,eax
mov eax,[Row]
shl eax,4
add esi,eax
mov ecx,[Column]
cmp cl,0
je @@30
@@20:
movzx ebx,[byte ptr esi]
shl ebx,4
push esi
mov esi,offset FontTable
add esi,ebx
call StrLength
add eax,eax
add edi,eax
pop esi
inc esi
dec cl
jnz @@20
@@30:
mov dl,[EditMode]
ror dl,1
add dl,70h
movzx ebx,[byte ptr esi]
shl ebx,4
mov esi,offset FontTable
add esi,ebx
call StrLength
@@40:
mov [byte ptr edi+1],dl
add edi,2
dec al
jnz @@40
@@99:
popad
ret
ENDP ShowCursor
PROC HiLightLine
pushad
GotoXY 12,2
mov eax,[row]
shl eax,7
add edi,eax
shr eax,2
add edi,eax
rept 32
or [byte ptr edi+1],20h
add edi,2
endm
GotoXY 12,2
mov eax,[column]
shl eax,2
add edi,eax
rept 16
or [byte ptr edi+1],20h
or [byte ptr edi+3],20h
add edi,160
endm
popad
ret
ENDP HiLightLine
PROC ReadMouse
pushad
xor ecx,ecx
xor edx,edx
mov ax,03h
int 33h
shr ecx,3
mov [MouseX],ecx
shr edx,3
mov [MouseY],edx
mov [ButtonStat],bl
test bl,1
jz @@99
mov eax,12
mov ebx,2
mov ecx,43
mov edx,17
call CmpMouse
jz @@HexArea
jmp @@99
@@HexArea:
shr cl,1
mov [Column],ecx
mov [Row],edx
call UpdateScreen
jmp @@99
@@99:
popad
ret
ENDP ReadMouse
PROC CmpMouse
cmp [MouseX],eax
jb @@false
cmp [MouseY],ebx
jb @@false
cmp [MouseX],ecx
ja @@false
cmp [MouseY],edx
ja @@false
mov ecx,[MouseX]
sub ecx,eax
mov edx,[MouseY]
sub edx,ebx
xor al,al
ret
@@false:
xor al,al
inc al
ret
ENDP CmpMouse
;-----------------------------------------------------------------------------
PROC DrawWin
; ESI = pointer to raw window data
; AL = startX
; AH = startY
; BL = Xwidth
; BH = Yheight
pushad
mov edi,[VideoMem]
movzx edx,ah
shl edx,7
add edi,edx
shr edx,2
add edi,edx
movzx edx,al
add edx,edx
add edi,edx
@@yloop:
push edi
movzx ecx,bl
rep movsw
mov [byte ptr edi+160+1],08h
mov [byte ptr edi+160+3],08h
pop edi
add edi,160
dec bh
jnz @@yloop
add edi,4
@@shadeloop:
mov [byte ptr edi+1],08h
add edi,2
dec bl
jnz @@shadeloop
popad
ret
ENDP DrawWin
PROC ConvertToFontValue
push ebx ecx edx esi edi
xor edx,edx
@@FindFontVal:
mov ebx,edx
shl ebx,4
cmp al,[FontTable + ebx]
je @@FoundFontVal
inc dl
jnz @@FindFontVal
stc
jmp @@99
@@FoundFontVal:
cmp [EnabledTable + edx],1
je @@ValOK
inc dl
jnz @@FindFontVal
stc
jmp @@99
@@ValOK:
cmp [FontTable + ebx + 1],0
je @@ValOK2
inc dl
jnz @@FindFontVal
stc
jmp @@99
@@ValOK2:
mov eax,edx
clc
@@99:
pop edi esi edx ecx ebx
ret
ENDP ConvertToFontValue
PROC UpChar
cmp al,'a'
jb @@99
cmp al,'z'
ja @@99
sub al,20h
@@99:
ret
ENDP UpChar
PROC CheckHex
cmp al,'0'
jb @@badchar
cmp al,'F'
ja @@badchar
cmp al,'9'
jbe @@charok
cmp al,'A'
jb @@badchar
@@charok:
clc
ret
@@badchar:
stc
ret
ENDP CheckHex
PROC DrawMsgBox
; ESI = pointer to raw window data
; AL = startX
; AH = startY
; BL = Xwidth
pushad
mov edi,[VideoMem]
movzx edx,ah
shl edx,7
add edi,edx
shr edx,2
add edi,edx
movzx edx,al
add edx,edx
add edi,edx
push edi
mov ah,4Eh
mov al,0DAh
stosw
mov al,0C4h
movzx ecx,bl
rep stosw
mov al,0BFh
stosw
pop edi
@@10:
add edi,160
push edi
mov ah,4Eh
mov al,0B3h
stosw
inc ah
movzx ecx,bl
@@20:
cmp [byte ptr esi],0
je @@30
lodsb
stosw
dec cl
jmp @@20
@@30:
dec ah
mov al,20h
rep stosw
mov al,0B3h
stosw
mov [byte ptr edi+1],08h
mov [byte ptr edi+3],08h
pop edi
lodsb
cmp [byte ptr esi],0FFh
jnz @@10
add edi,160
push edi
mov al,0C0h
stosw
mov al,0C4h
movzx ecx,bl
rep stosw
mov al,0D9h
stosw
mov [byte ptr edi+1],08h
mov [byte ptr edi+3],08h
pop edi
add edi,160+4
add bl,2
@@shadeloop:
mov [byte ptr edi+1],08h
add edi,2
dec bl
jnz @@shadeloop
popad
ret
ENDP DrawMsgBox
PROC ClearFontTable
pushad
mov edi,offset FontTable
xor al,al
xor dl,dl
@@10:
mov [byte ptr edi],'.'
inc edi
mov ecx,15
rep stosb
dec dl
jnz @@10
mov ecx,256
mov edi,offset EnabledTable
rep stosb
popad
ret
ENDP ClearFontTable
;-----------------------------------------------------------------------------
PROC Set80X50Mode
pushad
mov ax,3h
int 10h
mov dx,3C4h ; Sequencer Address Register
; === Set dot clock & scanning rate ===
mov ax,0100h
out dx,ax ; Stop sequencer while setting Misc Output
mov dx,3C2h
mov al,63h ; 0e3h = 227d = 11100011b
out dx,al ; Select 25 MHz dot clock & 60 Hz scanning rate
mov dx,3C4h
mov ax,0300h ; Index 00h --- 03h = 3d = 00000011b
out dx,ax ; Undo reset (restart sequencer)
; === Remove write protection ===
mov dx,3D4h
mov al,11h ; VSync End contains write protect bit (bit 7)
out dx,al
inc dx ; Crt Controller Data register
in al,dx
and al,01111111b ; Remove write protect on various CrtC registers
out dx,al ; (bit 7 is 0)
mov dx,3C4h
mov ax,0204h
out dx,ax
mov ax,0101h
out dx,ax
mov ax,0003h
out dx,ax
mov dx,3CEh
mov ax,1005h
out dx,ax
mov ax,0E06h
out dx,ax
mov dx,3D4h
mov ecx,15
mov esi,offset _80x50 ; CHANGE THIS TO _256x256 or _256x240
@@Send_Values:
lodsw
out dx,ax
dec ecx
jnz @@Send_Values
mov ax,1112h ;<set 50 line mode if previous
mov bl,0 ;< by loading double dot chr set
int 10h
popad
ret
ENDP Set80X50Mode
END start
|
llvm-gcc-4.2-2.9/gcc/ada/sem_cat.ads | vidkidz/crossbridge | 1 | 5335 | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ C A T --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This unit contains the routines used for checking for conformance with
-- the semantic restrictions required for the categorization pragmas:
--
-- Preelaborate
-- Pure,
-- Remote_Call_Interface
-- Remote_Types
-- Shared_Passive
--
-- Note that we treat Preelaborate as a categorization pragma, even though
-- strictly, according to RM E.2(2,3), the term does not apply in this case.
with Types; use Types;
package Sem_Cat is
function In_Preelaborated_Unit return Boolean;
-- Determines if the current scope is within a preelaborated compilation
-- unit, that is one to which one of the pragmas Preelaborate, Pure,
-- Shared_Passive, Remote_Types, or inside a unit other than a package
-- body with pragma Remote_Call_Interface.
function In_Pure_Unit return Boolean;
pragma Inline (In_Pure_Unit);
-- Determines if the current scope is within pure compilation unit,
-- that is, one to which the pragmas Pure is applied.
function In_Subprogram_Task_Protected_Unit return Boolean;
-- Determines if the current scope is within a subprogram, task
-- or protected unit. Used to validate if the library unit is Pure
-- (RM 10.2.1(16)).
procedure Set_Categorization_From_Pragmas (N : Node_Id);
-- Since validation of categorization dependency is done during Analyze,
-- categorization flags from following pragmas should be set before
-- validation begin. N is the N_Compilation_Unit node.
procedure Set_Categorization_From_Scope (E : Entity_Id; Scop : Entity_Id);
-- Set categorization flags Pure, Remote_Call_Interface and Remote_Types
-- on entity E according to those of Scop.
procedure Validate_Access_Type_Declaration (T : Entity_Id; N : Node_Id);
-- Validate all constraints against declaration of access types in
-- categorized library units. Usually this is a violation in Pure unit,
-- Shared_Passive unit. N is the declaration node.
procedure Validate_Ancestor_Part (N : Node_Id);
-- Checks that a type given as the ancestor in an extension aggregate
-- satisfies the restriction of 10.2.1(9).
procedure Validate_Categorization_Dependency (N : Node_Id; E : Entity_Id);
-- There are restrictions on lib unit that semantically depends on other
-- units (RM E.2(5), 10.2.1(11). This procedure checks the restrictions
-- on categorizations. N is the current unit node, and E is the current
-- library unit entity.
procedure Validate_Controlled_Object (E : Entity_Id);
-- Given an entity for a library level controlled object, check that it is
-- not in a preelaborated unit (prohibited by RM 10.2.1(9)).
procedure Validate_Null_Statement_Sequence (N : Node_Id);
-- Given N, a package body node, check that a handled statement sequence
-- in a preelaborable body contains no statements other than labels or
-- null statements, as required by RM 10.2.1(6).
procedure Validate_Object_Declaration (N : Node_Id);
-- Given N, an object declaration node, validates all the constraints in
-- a preelaborable library unit, including creation of task objects etc.
-- Note that this is called when the corresponding object is frozen since
-- the checks cannot be made before knowing if the object is imported.
procedure Validate_RCI_Declarations (P : Entity_Id);
-- Apply semantic checks given in E2.3(10-14)
procedure Validate_RCI_Subprogram_Declaration (N : Node_Id);
-- Check for RCI unit subprogram declarations with respect to
-- in-lined subprogram and subprogram with access parameter or
-- limited type parameter without Read and Write.
procedure Validate_Remote_Access_To_Class_Wide_Type (N : Node_Id);
-- Checks that Storage_Pool and Storage_Size attribute references are
-- not applied to remote access-to-class-wide types. And the expected
-- type for an allocator shall not be a remote access-to-class-wide
-- type. And a remote access-to-class-wide type shall not be an actual
-- parameter for a generic formal access type. RM E.2.3(22).
procedure Validate_RT_RAT_Component (N : Node_Id);
-- Given N, the package library unit declaration node, we should check
-- against RM:9.95 E.2.2(8): the full view of a type declared in the
-- visible part of a Remote Types unit has a part that is of a non-remote
-- access type which has no read/write.
procedure Validate_Remote_Type_Type_Conversion (N : Node_Id);
-- Check for remote-type type conversion constraints. First, a value of
-- a remote access-to-subprogram type can be converted only to another
-- type conformant remote access-to-subprogram type. Secondly, a value
-- of a remote access-to-class-wide type can be converted only to another
-- remote access-to-class-wide type (RM E.2.3(17,20)).
procedure Validate_SP_Access_Object_Type_Decl (T : Entity_Id);
-- Check validity of declaration if shared passive unit. It should not
-- contain the declaration of an access-to-object type whose designated
-- type is a class-wide type ,task type or protected type. E.2.1(7).
-- T is the entity of the declared type.
procedure Validate_Static_Object_Name (N : Node_Id);
-- In the elaboration code of a preelaborated library unit, check
-- that we do not have the evaluation of a primary that is a name of
-- an object, unless the name is a static expression (RM 10.2.1(8)).
-- Non-static constant and variable are the targets, generic parameters
-- are not included because the generic declaration and body are
-- preelaborable.
end Sem_Cat;
|
codec/encoder/core/asm/intra_pred_util.asm | TechSmith/openh264 | 1 | 2478 | <reponame>TechSmith/openh264
;*!
;* \copy
;* Copyright (c) 2009-2013, Cisco Systems
;* All rights reserved.
;*
;* Redistribution and use in source and binary forms, with or without
;* modification, are permitted provided that the following conditions
;* are met:
;*
;* * Redistributions of source code must retain the above copyright
;* notice, this list of conditions and the following disclaimer.
;*
;* * Redistributions in binary form must reproduce the above copyright
;* notice, this list of conditions and the following disclaimer in
;* the documentation and/or other materials provided with the
;* distribution.
;*
;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
;* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
;* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
;* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
;* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
;* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
;* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
;* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
;* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
;* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
;* POSSIBILITY OF SUCH DAMAGE.
;*
;*
;* intra_pred_util.asm
;*
;* Abstract
;* mmxext/sse for WelsFillingPred8to16, WelsFillingPred8x2to16 and
;* WelsFillingPred1to16 etc.
;*
;* History
;* 09/29/2009 Created
;*
;*
;*************************************************************************/
%include "asm_inc.asm"
BITS 32
;***********************************************************************
; Macros and other preprocessor constants
;***********************************************************************
;***********************************************************************
; Local Data (Read Only)
;***********************************************************************
;SECTION .rodata pData align=16
;***********************************************************************
; Various memory constants (trigonometric values or rounding values)
;***********************************************************************
;***********************************************************************
; Code
;***********************************************************************
SECTION .text
WELS_EXTERN WelsFillingPred8to16_mmx
WELS_EXTERN WelsFillingPred8x2to16_mmx
WELS_EXTERN WelsFillingPred1to16_mmx
WELS_EXTERN WelsFillingPred8x2to16_sse2
WELS_EXTERN WelsFillingPred1to16_sse2
ALIGN 16
;***********************************************************************----------------
; void WelsFillingPred8to16_mmx( uint8_t *pred, uint8_t *v );
;***********************************************************************----------------
WelsFillingPred8to16_mmx:
mov eax, [esp+4] ; pred
mov ecx, [esp+8] ; v
movq mm0, [ecx]
movq [eax ], mm0
movq [eax+8], mm0
WELSEMMS
ret
ALIGN 16
;***********************************************************************----------------
; void WelsFillingPred8x2to16_mmx( uint8_t *pred, uint8_t *v );
;***********************************************************************----------------
WelsFillingPred8x2to16_mmx:
mov eax, [esp+4] ; pred
mov ecx, [esp+8] ; v
movq mm0, [ecx ]
movq mm1, [ecx+8]
movq [eax ], mm0
movq [eax+8], mm1
WELSEMMS
ret
%macro butterfly_1to8_mmx 3 ; mm? for dst, mm? for tmp, one byte for pSrc [generic register name: a/b/c/d]
mov %3h, %3l
movd %2, e%3x ; i.e, 1% = eax (=b0)
pshufw %1, %2, 00h ; b0 b0 b0 b0, b0 b0 b0 b0
%endmacro
ALIGN 16
;***********************************************************************----------------
; void WelsFillingPred1to16_mmx( uint8_t *pred, const uint8_t v );
;***********************************************************************----------------
WelsFillingPred1to16_mmx:
mov eax, [esp+4] ; pred
mov cl, byte [esp+8] ; v
butterfly_1to8_mmx mm0, mm1, c ; mm? for dst, mm? for tmp, one byte for pSrc [generic register name: a/b/c/d]
movq [eax ], mm0
movq [eax+8], mm0
WELSEMMS
ret
ALIGN 16
;***********************************************************************----------------
; void WelsFillingPred8x2to16_sse2( uint8_t *pred, uint8_t *v );
;***********************************************************************----------------
WelsFillingPred8x2to16_sse2:
mov eax, [esp+4] ; pred
mov ecx, [esp+8] ; v
movdqa xmm0, [ecx]
movdqa [eax], xmm0
ret
ALIGN 16
;***********************************************************************----------------
; void WelsFillingPred1to16_sse2( uint8_t *pred, const uint8_t v );
;***********************************************************************----------------
WelsFillingPred1to16_sse2:
mov eax, [esp+4] ; pred
mov cl, byte [esp+8] ; v
butterfly_1to16_sse xmm0, xmm1, c ; dst, tmp, pSrc [generic register name: a/b/c/d]
movdqa [eax], xmm0
ret
|
orka/src/orka/interface/orka-types.ads | onox/orka | 52 | 20015 | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <<EMAIL>>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with GL.Types;
with Orka.Algebra;
with Orka.Transforms.Singles.Matrices;
with Orka.Transforms.Doubles.Matrices;
package Orka.Types is
pragma Pure;
type Element_Type is
-- Numeric types
(UByte_Type,
UShort_Type,
UInt_Type,
Byte_Type,
Short_Type,
Int_Type,
Half_Type,
Single_Type,
Double_Type,
-- Composite types
Single_Vector_Type,
Double_Vector_Type,
Single_Matrix_Type,
Double_Matrix_Type,
Arrays_Command_Type,
Elements_Command_Type,
Dispatch_Command_Type);
subtype Numeric_Type is Element_Type range UByte_Type .. Double_Type;
subtype Index_Type is Numeric_Type range UShort_Type .. UInt_Type;
subtype Composite_Type is Element_Type range Single_Vector_Type .. Dispatch_Command_Type;
function Convert (Kind : Numeric_Type) return GL.Types.Numeric_Type;
function Convert (Kind : Index_Type) return GL.Types.Index_Type;
-----------------------------------------------------------------------------
package Singles is new Orka.Algebra (Orka.Transforms.Singles.Matrices);
package Doubles is new Orka.Algebra (Orka.Transforms.Doubles.Matrices);
procedure Convert (Elements : GL.Types.Single_Array; Result : out GL.Types.Half_Array)
with Post => Elements'Length = Result'Length;
procedure Convert (Elements : GL.Types.Half_Array; Result : out GL.Types.Single_Array)
with Post => Elements'Length = Result'Length;
-----------------------------------------------------------------------------
function Is_Power_Of_Two (Value : Positive) return Boolean;
generic
type Source is digits <>;
type Target is digits <>;
function Clamp (Value : in Source) return Target;
generic
type Source is digits <>;
type Target is digits <>;
function Normalize_Periodic (Value : in Source) return Target;
end Orka.Types;
|
programs/oeis/065/A065261.asm | jmorken/loda | 1 | 21734 | ; A065261: The siteswap sequence (the deltas p[i]-i, i in ]-inf,+inf[, folded from Z to N, mapping 0->1, 1->2, -1->3, 2->4, -2->5, etc.) for A065260.
; 1,1,1,2,5,3,2,4,9,5,3,6,13,7,4,8,17,9,5,10,21,11,6,12,25,13,7,14,29,15,8,16,33,17,9,18,37,19,10,20,41,21,11,22,45,23,12,24,49,25,13,26,53,27,14,28,57,29,15,30,61,31,16,32,65,33,17,34,69,35,18,36,73,37,19,38
mov $1,$0
gcd $0,4
mov $2,$0
lpb $2
lpb $0
mul $2,$0
mov $0,3
lpe
div $1,2
sub $2,1
lpe
add $1,1
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c3/c34007s.ada | best08618/asylo | 7 | 6727 | -- C34007S.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT THE REQUIRED PREDEFINED OPERATIONS ARE DECLARED
-- (IMPLICITLY) FOR DERIVED ACCESS TYPES WHOSE DESIGNATED TYPE IS A
-- PRIVATE TYPE WITH DISCRIMINANTS.
-- HISTORY:
-- JRK 09/30/86 CREATED ORIGINAL TEST.
-- BCB 10/21/87 CHANGED HEADER TO STANDARD FORMAT. REVISED TEST SO
-- T'STORAGE_SIZE IS NOT REQUIRED TO BE > 1.
-- BCB 09/26/88 REMOVED COMPARISON INVOLVING OBJECT SIZE.
-- BCB 03/07/90 PUT CHECK FOR 'STORAGE_SIZE IN EXCEPTION HANDLER.
-- THS 09/18/90 REMOVED DECLARATION OF B, MADE THE BODY OF
-- PROCEDURE A NULL, AND DELETED ALL REFERENCES TO B.
-- PWN 01/31/95 REMOVED INCONSISTENCIES WITH ADA 9X.
WITH SYSTEM; USE SYSTEM;
WITH REPORT; USE REPORT;
PROCEDURE C34007S IS
SUBTYPE COMPONENT IS INTEGER;
PACKAGE PKG_D IS
SUBTYPE LENGTH IS NATURAL RANGE 0 .. 10;
TYPE DESIGNATED (B : BOOLEAN := TRUE; L : LENGTH := 1) IS
PRIVATE;
FUNCTION CREATE ( B : BOOLEAN;
L : LENGTH;
I : INTEGER;
S : STRING;
C : COMPONENT;
F : FLOAT
) RETURN DESIGNATED;
PRIVATE
TYPE DESIGNATED (B : BOOLEAN := TRUE; L : LENGTH := 1) IS
RECORD
I : INTEGER := 2;
CASE B IS
WHEN TRUE =>
S : STRING (1 .. L) := (1 .. L => 'A');
C : COMPONENT := 2;
WHEN FALSE =>
F : FLOAT := 5.0;
END CASE;
END RECORD;
END PKG_D;
USE PKG_D;
SUBTYPE SUBDESIGNATED IS DESIGNATED (IDENT_BOOL (TRUE),
IDENT_INT (3));
PACKAGE PKG_P IS
TYPE PARENT IS ACCESS DESIGNATED;
FUNCTION CREATE ( B : BOOLEAN;
L : LENGTH;
I : INTEGER;
S : STRING;
C : COMPONENT;
F : FLOAT;
X : PARENT -- TO RESOLVE OVERLOADING.
) RETURN PARENT;
END PKG_P;
USE PKG_P;
TYPE T IS NEW PARENT (IDENT_BOOL (TRUE), IDENT_INT (3));
X : T := NEW DESIGNATED (TRUE, 3);
K : INTEGER := X'SIZE;
Y : T := NEW DESIGNATED (TRUE, 3);
W : PARENT := NEW DESIGNATED (TRUE, 3);
PROCEDURE A (X : ADDRESS) IS
BEGIN
NULL;
END A;
PACKAGE BODY PKG_D IS
FUNCTION CREATE
( B : BOOLEAN;
L : LENGTH;
I : INTEGER;
S : STRING;
C : COMPONENT;
F : FLOAT
) RETURN DESIGNATED
IS
BEGIN
CASE B IS
WHEN TRUE =>
RETURN (TRUE, L, I, S, C);
WHEN FALSE =>
RETURN (FALSE, L, I, F);
END CASE;
END CREATE;
END PKG_D;
PACKAGE BODY PKG_P IS
FUNCTION CREATE
( B : BOOLEAN;
L : LENGTH;
I : INTEGER;
S : STRING;
C : COMPONENT;
F : FLOAT;
X : PARENT
) RETURN PARENT
IS
BEGIN
RETURN NEW DESIGNATED'(CREATE (B, L, I, S, C, F));
END CREATE;
END PKG_P;
FUNCTION IDENT (X : T) RETURN T IS
BEGIN
IF X = NULL OR ELSE EQUAL (X.L, X.L) THEN
RETURN X; -- ALWAYS EXECUTED.
END IF;
RETURN NEW DESIGNATED'(CREATE (TRUE, 3, -1, "---", -1, -1.0));
END IDENT;
BEGIN
TEST ("C34007S", "CHECK THAT THE REQUIRED PREDEFINED OPERATIONS " &
"ARE DECLARED (IMPLICITLY) FOR DERIVED " &
"ACCESS TYPES WHOSE DESIGNATED TYPE IS A " &
"PRIVATE TYPE WITH DISCRIMINANTS");
Y.ALL := CREATE (TRUE, 3, 1, "ABC", 4, 1.0);
IF Y = NULL OR ELSE
Y.ALL /= CREATE (TRUE, 3, 1, "ABC", 4, 2.0) THEN
FAILED ("INCORRECT INITIALIZATION");
END IF;
X := IDENT (Y);
IF X /= Y THEN
FAILED ("INCORRECT :=");
END IF;
IF T'(X) /= Y THEN
FAILED ("INCORRECT QUALIFICATION");
END IF;
IF T (X) /= Y THEN
FAILED ("INCORRECT SELF CONVERSION");
END IF;
IF EQUAL (3, 3) THEN
W := NEW DESIGNATED'(CREATE (TRUE, 3, 1, "ABC", 4, 1.0));
END IF;
X := T (W);
IF X = NULL OR ELSE X = Y OR ELSE
X.ALL /= CREATE (TRUE, 3, 1, "ABC", 4, 2.0) THEN
FAILED ("INCORRECT CONVERSION FROM PARENT");
END IF;
X := IDENT (Y);
W := PARENT (X);
IF W = NULL OR ELSE
W.ALL /= CREATE (TRUE, 3, 1, "ABC", 4, 2.0) OR ELSE
T (W) /= Y THEN
FAILED ("INCORRECT CONVERSION TO PARENT - 1");
END IF;
W := PARENT (CREATE (FALSE, 2, 3, "XX", 5, 6.0, X));
IF W = NULL OR ELSE
W.ALL /= CREATE (FALSE, 2, 3, "ZZ", 7, 6.0) THEN
FAILED ("INCORRECT CONVERSION TO PARENT - 2");
END IF;
IF IDENT (NULL) /= NULL OR X = NULL THEN
FAILED ("INCORRECT NULL");
END IF;
X := IDENT (NEW DESIGNATED'(CREATE (TRUE, 3, 1, "ABC", 4, 1.0)));
IF (X = NULL OR ELSE X = Y OR ELSE
X.ALL /= CREATE (TRUE, 3, 1, "ABC", 4, 2.0)) OR
X = NEW DESIGNATED'(CREATE (FALSE, 3, 1, "XXX", 5, 4.0)) THEN
FAILED ("INCORRECT ALLOCATOR");
END IF;
X := IDENT (Y);
IF X.B /= TRUE OR X.L /= 3 OR
CREATE (FALSE, 2, 3, "XX", 5, 6.0, X) . B /= FALSE OR
CREATE (FALSE, 2, 3, "XX", 5, 6.0, X) . L /= 2 THEN
FAILED ("INCORRECT SELECTION (DISCRIMINANT)");
END IF;
IF X.ALL /= CREATE (TRUE, 3, 1, "ABC", 4, 2.0) OR
CREATE (FALSE, 2, 3, "XX", 5, 6.0, X) . ALL /=
CREATE (FALSE, 2, 3, "ZZ", 7, 6.0) THEN
FAILED ("INCORRECT .ALL (VALUE)");
END IF;
X.ALL := CREATE (TRUE, 3, 10, "ZZZ", 15, 1.0);
IF X /= Y OR Y.ALL /= CREATE (TRUE, 3, 10, "ZZZ", 15, 2.0) THEN
FAILED ("INCORRECT .ALL (ASSIGNMENT)");
END IF;
Y.ALL := CREATE (TRUE, 3, 1, "ABC", 4, 1.0);
BEGIN
CREATE (FALSE, 2, 3, "XX", 5, 6.0, X) . ALL :=
CREATE (FALSE, 2, 10, "ZZ", 7, 15.0);
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION FOR .ALL (ASSIGNMENT)");
END;
X := IDENT (NULL);
BEGIN
IF X.ALL = CREATE (FALSE, 0, 0, "", 0, 0.0) THEN
FAILED ("NO EXCEPTION FOR NULL.ALL - 1");
ELSE FAILED ("NO EXCEPTION FOR NULL.ALL - 2");
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION FOR NULL.ALL");
END;
X := IDENT (Y);
IF X = NULL OR X = NEW SUBDESIGNATED OR NOT (X = Y) OR
X = CREATE (FALSE, 2, 3, "XX", 5, 6.0, X) THEN
FAILED ("INCORRECT =");
END IF;
IF X /= Y OR NOT (X /= NULL) OR
NOT (X /= CREATE (FALSE, 2, 3, "XX", 5, 6.0, X)) THEN
FAILED ("INCORRECT /=");
END IF;
IF NOT (X IN T) OR CREATE (FALSE, 2, 3, "XX", 5, 6.0, X) IN T THEN
FAILED ("INCORRECT ""IN""");
END IF;
IF X NOT IN T OR
NOT (CREATE (FALSE, 2, 3, "XX", 5, 6.0, X) NOT IN T) THEN
FAILED ("INCORRECT ""NOT IN""");
END IF;
A (X'ADDRESS);
IF T'SIZE < 1 THEN
FAILED ("INCORRECT TYPE'SIZE");
END IF;
BEGIN
IF T'STORAGE_SIZE /= PARENT'STORAGE_SIZE THEN
FAILED ("COLLECTION SIZE OF DERIVED TYPE IS NOT " &
"EQUAL TO COLLECTION SIZE OF PARENT TYPE");
END IF;
EXCEPTION
WHEN PROGRAM_ERROR =>
COMMENT ("PROGRAM_ERROR RAISED FOR " &
"UNDEFINED STORAGE_SIZE (AI-00608)");
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED");
END;
RESULT;
END C34007S;
|
courses/fundamentals_of_ada/labs/solar_system/adv_240_tasking_protected_objects/src/solar_system-graphics.adb | AdaCore/training_material | 15 | 14191 | <filename>courses/fundamentals_of_ada/labs/solar_system/adv_240_tasking_protected_objects/src/solar_system-graphics.adb
package body Solar_System.Graphics is
procedure Draw_Body (Object : Body_Type; Canvas : Canvas_ID) is
begin
if Object.Visible then
Draw_Sphere
(Canvas => Canvas,
Position => (Object.X, Object.Y, 0.0),
Radius => Object.Radius,
Color => Object.Color);
end if;
end Draw_Body;
procedure Draw_All (Bodies : Bodies_Array_T; Canvas : Canvas_ID) is
begin
for Obj of Bodies loop
if Obj.Visible then
Draw_Body (Obj, Canvas);
end if;
end loop;
end Draw_All;
end Solar_System.Graphics;
|
org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook2a.als | Kaixi26/org.alloytools.alloy | 527 | 364 | <reponame>Kaixi26/org.alloytools.alloy
module tour/addressBook2a ----- Page 18
abstract sig Target { }
sig Addr extends Target { }
abstract sig Name extends Target { }
sig Alias, Group extends Name { }
sig Book {
addr: Name->Target
}
pred show [b:Book] { some b.addr }
// This command generates an instance similar to Fig 2.9
run show for 3 but 1 Book
|
grammars/TypescriptLexer.g4 | hatlafax/ELSE-grammar-compiler | 0 | 3126 | lexer grammar TypeScriptLexer;
channels { ERROR }
options {
superClass=TypeScriptLexerBase;
}
MultiLineComment: '/*' .*? '*/' -> channel(HIDDEN);
SingleLineComment: '//' ~[\r\n\u2028\u2029]* -> channel(HIDDEN);
RegularExpressionLiteral: '/' RegularExpressionFirstChar RegularExpressionChar* {this.IsRegexPossible()}? '/' IdentifierPart*;
OpenBracket: '[';
CloseBracket: ']';
OpenParen: '(';
CloseParen: ')';
OpenBrace: '{' {this.ProcessOpenBrace();};
TemplateCloseBrace: {this.IsInTemplateString()}? '}' -> popMode;
CloseBrace: '}' {this.ProcessCloseBrace();};
SemiColon: ';';
Comma: ',';
Assign: '=';
QuestionMark: '?';
Colon: ':';
Ellipsis: '...';
Dot: '.';
PlusPlus: '++';
MinusMinus: '--';
Plus: '+';
Minus: '-';
BitNot: '~';
Not: '!';
Multiply: '*';
Divide: '/';
Modulus: '%';
RightShiftArithmetic: '>>';
LeftShiftArithmetic: '<<';
RightShiftLogical: '>>>';
LessThan: '<';
MoreThan: '>';
LessThanEquals: '<=';
GreaterThanEquals: '>=';
Equals_: '==';
NotEquals: '!=';
IdentityEquals: '===';
IdentityNotEquals: '!==';
BitAnd: '&';
BitXOr: '^';
BitOr: '|';
And: '&&';
Or: '||';
MultiplyAssign: '*=';
DivideAssign: '/=';
ModulusAssign: '%=';
PlusAssign: '+=';
MinusAssign: '-=';
LeftShiftArithmeticAssign: '<<=';
RightShiftArithmeticAssign: '>>=';
RightShiftLogicalAssign: '>>>=';
BitAndAssign: '&=';
BitXorAssign: '^=';
BitOrAssign: '|=';
ARROW: '=>';
/// Null Literals
NullLiteral: 'null';
/// Boolean Literals
BooleanLiteral: 'true'
| 'false';
/// Numeric Literals
DecimalLiteral: DecimalIntegerLiteral '.' [0-9]* ExponentPart?
| '.' [0-9]+ ExponentPart?
| DecimalIntegerLiteral ExponentPart?
;
/// Numeric Literals
HexIntegerLiteral: '0' [xX] HexDigit+;
OctalIntegerLiteral: '0' [0-7]+ {!this.IsStrictMode()}?;
OctalIntegerLiteral2: '0' [oO] [0-7]+;
BinaryIntegerLiteral: '0' [bB] [01]+;
/// Keywords
Break: 'break';
Do: 'do';
Instanceof: 'instanceof';
Typeof: 'typeof';
Case: 'case';
Else: 'else';
New: 'new';
Var: 'var';
Catch: 'catch';
Finally: 'finally';
Return: 'return';
Void: 'void';
Continue: 'continue';
For: 'for';
Switch: 'switch';
While: 'while';
Debugger: 'debugger';
Function_: 'function';
This: 'this';
With: 'with';
Default: 'default';
If: 'if';
Throw: 'throw';
Delete: 'delete';
In: 'in';
Try: 'try';
As: 'as';
From: 'from';
ReadOnly: 'readonly';
Async: 'async';
/// Future Reserved Words
Class: 'class';
Enum: 'enum';
Extends: 'extends';
Super: 'super';
Const: 'const';
Export: 'export';
Import: 'import';
/// The following tokens are also considered to be FutureReservedWords
/// when parsing strict mode
Implements: 'implements' ;
Let: 'let' ;
Private: 'private' ;
Public: 'public' ;
Interface: 'interface' ;
Package: 'package' ;
Protected: 'protected' ;
Static: 'static' ;
Yield: 'yield' ;
//keywords:
Any : 'any';
Number: 'number';
Boolean: 'boolean';
String: 'string';
Symbol: 'symbol';
TypeAlias : 'type';
Get: 'get';
Set: 'set';
Constructor: 'constructor';
Namespace: 'namespace';
Require: 'require';
Module: 'module';
Declare: 'declare';
Abstract: 'abstract';
Is: 'is';
//
// Ext.2 Additions to 1.8: Decorators
//
At: '@';
/// Identifier Names and Identifiers
Identifier: IdentifierStart IdentifierPart*;
/// String Literals
StringLiteral: ('"' DoubleStringCharacter* '"'
| '\'' SingleStringCharacter* '\'') {this.ProcessStringLiteral();}
;
BackTick: '`' {this.IncreaseTemplateDepth();} -> pushMode(TEMPLATE);
WhiteSpaces: [\t\u000B\u000C\u0020\u00A0]+ -> channel(HIDDEN);
LineTerminator: [\r\n\u2028\u2029] -> channel(HIDDEN);
/// Comments
HtmlComment: '<!--' .*? '-->' -> channel(HIDDEN);
CDataComment: '<![CDATA[' .*? ']]>' -> channel(HIDDEN);
UnexpectedCharacter: . -> channel(ERROR);
mode TEMPLATE;
BackTickInside: '`' {this.DecreaseTemplateDepth();} -> type(BackTick), popMode;
TemplateStringStartExpression: '${' -> pushMode(DEFAULT_MODE);
TemplateStringAtom: ~[`];
// Fragment rules
fragment DoubleStringCharacter
: ~["\\\r\n]
| '\\' EscapeSequence
| LineContinuation
;
fragment SingleStringCharacter
: ~['\\\r\n]
| '\\' EscapeSequence
| LineContinuation
;
fragment EscapeSequence
: CharacterEscapeSequence
| '0' // no digit ahead! TODO
| HexEscapeSequence
| UnicodeEscapeSequence
| ExtendedUnicodeEscapeSequence
;
fragment CharacterEscapeSequence
: SingleEscapeCharacter
| NonEscapeCharacter
;
fragment HexEscapeSequence
: 'x' HexDigit HexDigit
;
fragment UnicodeEscapeSequence
: 'u' HexDigit HexDigit HexDigit HexDigit
;
fragment ExtendedUnicodeEscapeSequence
: 'u' '{' HexDigit+ '}'
;
fragment SingleEscapeCharacter
: ['"\\bfnrtv]
;
fragment NonEscapeCharacter
: ~['"\\bfnrtv0-9xu\r\n]
;
fragment EscapeCharacter
: SingleEscapeCharacter
| [0-9]
| [xu]
;
fragment LineContinuation
: '\\' [\r\n\u2028\u2029]
;
fragment HexDigit
: [0-9a-fA-F]
;
fragment DecimalIntegerLiteral
: '0'
| [1-9] [0-9]*
;
fragment ExponentPart
: [eE] [+-]? [0-9]+
;
fragment IdentifierPart
: IdentifierStart
| [\p{Mn}]
| [\p{Nd}]
| [\p{Pc}]
| '\u200C'
| '\u200D'
;
fragment IdentifierStart
: [\p{L}]
| [$_]
| '\\' UnicodeEscapeSequence
;
fragment RegularExpressionFirstChar
: ~[*\r\n\u2028\u2029\\/[]
| RegularExpressionBackslashSequence
| '[' RegularExpressionClassChar* ']'
;
fragment RegularExpressionChar
: ~[\r\n\u2028\u2029\\/[]
| RegularExpressionBackslashSequence
| '[' RegularExpressionClassChar* ']'
;
fragment RegularExpressionClassChar
: ~[\r\n\u2028\u2029\]\\]
| RegularExpressionBackslashSequence
;
fragment RegularExpressionBackslashSequence
: '\\' ~[\r\n\u2028\u2029]
;
|
programs/oeis/157/A157130.asm | neoneye/loda | 22 | 160576 | ; A157130: Partial sums of A128201.
; 1,4,8,13,20,29,40,53,68,84,101,120,141,164,189,216,245,276,309,344,380,417,456,497,540,585,632,681,732,785,840,897,956,1017,1080,1144,1209,1276,1345,1416,1489,1564,1641,1720,1801,1884,1969,2056,2145,2236,2329
lpb $0
mov $2,$0
sub $0,1
seq $2,128201 ; Union of positive squares and the odd numbers.
add $1,$2
lpe
add $1,1
mov $0,$1
|
LoLCustomSharp/asm/defines.asm | LoL-Fantome/lolcustomskin | 3 | 100305 | ; define offsets for payload data structure
[bits 32]
%define payload_org_open_ptr 0
%define payload_prefix_open_ptr 4
%define payload_org_free_ptr 8
%define payload_find_ret_addr 12
%define payload_hook_ret_addr 16
|
oeis/254/A254601.asm | neoneye/loda-programs | 11 | 160522 | <reponame>neoneye/loda-programs
; A254601: Numbers of n-length words on alphabet {0,1,...,6} with no subwords ii, where i is from {0,1,2}.
; Submitted by <NAME>(s2)
; 1,7,46,304,2008,13264,87616,578752,3822976,25252864,166809088,1101865984,7278432256,48078057472,317582073856,2097804673024,13857156333568,91534156693504,604633565495296,3993938019745792,26382162380455936,174268726361718784,1151141007692136448,7603920951599693824,50228089740366708736,331784222248599027712,2191617692453061001216,14476843043712762118144,95627529032088816713728,631672546367383948754944,4172545394332658959384576,27561962551465489551327232,182061956886123573145501696
lpb $0
sub $0,1
add $2,$3
mov $1,$2
add $1,2
add $1,$2
mul $3,2
add $3,$2
mov $2,$3
add $2,2
mov $3,$1
add $3,$2
lpe
mov $0,$3
div $0,2
mul $0,3
add $0,1
|
programs/oeis/006/A006230.asm | jmorken/loda | 1 | 16552 | ; A006230: Bitriangular permutations.
; 1,13,73,301,1081,3613,11593,36301,111961,342013,1038313,3139501,9467641,28501213,85700233,257493901,773268121,2321377213,6967277353,20908123501,62736953401,188236026013,564758409673,1694375892301,5083329003481,15250389663613,45751974297193,137257533504301,411775821738361,1235333907666013,3706014607899913
mul $0,2
mov $1,1
mov $3,4
lpb $0
sub $0,2
add $1,$3
mov $2,$1
sub $2,1
mul $2,2
add $1,$2
add $3,2
mul $3,2
lpe
|
oeis/041/A041154.asm | neoneye/loda-programs | 11 | 8194 | ; A041154: Numerators of continued fraction convergents to sqrt(87).
; Submitted by <NAME>
; 9,28,513,1567,28719,87724,1607751,4910977,90005337,274926988,5038691121,15391000351,282076697439,861621092668,15791256365463,48235390189057,884028279768489,2700320229494524,49489792410669921,151169697461504287,2770544346717747087,8462802737614745548,155100993623783166951,473765783608964246401,8682885098585139602169,26522421079364383052908,486086464527144034554513,1484781814660796486716447,27212159128421480795450559,83121259199925238873068124,1523394824727075780510676791
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
mov $3,$1
mov $1,$2
dif $2,6
mul $2,9
add $3,$2
lpe
mov $0,$3
|
code-examples/agda/chu/lens.agda | mstone/poly | 53 | 17187 | <reponame>mstone/poly
{-# OPTIONS --type-in-type #-}
module chu.lens where
open import prelude
open import functors
open import chu
open import poly.core
→∫ : Chu → ∫
→∫ (A⁺ , A⁻ ! Ω) = A⁺ , λ a⁺ → ∃ (Ω a⁺)
→Lens : {A B : Chu} → Chu[ A , B ] → ∫[ →∫ A , →∫ B ]
→Lens (f ↔ fᵗ ! †) a⁺ = f a⁺ , λ (b⁻ , fa⁺Ωb⁻) → fᵗ b⁻ , subst id († a⁺ b⁻) fa⁺Ωb⁻
module _ {A B C : Chu}
(F@(f ↔ fᵗ ! _†₁_) : Chu[ A , B ])
(G@(g ↔ gᵗ ! _†₂_) : Chu[ B , C ]) where
comp₂ : ∀ a⁺ → π₂ (→Lens (F ▸ G) a⁺)
≡ π₂ ((→Lens F ▸ →Lens G) a⁺)
comp₂ a⁺ = extensionality λ ( c⁻ , gfaΩc ) → (λ x → (fᵗ ∘ gᵗ) c⁻ , x) ⟨$⟩
subst⋯ id (f a⁺ †₂ c⁻) (a⁺ †₁ gᵗ c⁻) gfaΩc
comp∀ : ∀ a⁺ → →Lens (F ▸ G) a⁺ ≡ (→Lens F ▸ →Lens G) a⁺
comp∀ a⁺ rewrite comp₂ a⁺ = refl
instance
open Chu[_,_]
chu-lens-functor : Functor →∫
chu-lens-functor = φ: →Lens
𝒾: refl
▸: λ F G → extensionality (comp∀ F G)
|
ANTLRTestProjects/antbased/CodeFolding/grammar/Action.g4 | timboudreau/ANTLR4-Plugins-for-NetBeans | 1 | 7168 | grammar Action; // azerty
rule1 : 'a'
{
}
; |
grep.asm | Tookerton21/Xv6_OS | 0 | 11 |
_grep: file format elf32-i386
Disassembly of section .text:
00000000 <grep>:
char buf[1024];
int match(char*, char*);
void
grep(char *pattern, int fd)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 18 sub $0x18,%esp
int n, m;
char *p, *q;
m = 0;
6: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){
d: e9 b6 00 00 00 jmp c8 <grep+0xc8>
m += n;
12: 8b 45 ec mov -0x14(%ebp),%eax
15: 01 45 f4 add %eax,-0xc(%ebp)
buf[m] = '\0';
18: 8b 45 f4 mov -0xc(%ebp),%eax
1b: 05 80 0e 00 00 add $0xe80,%eax
20: c6 00 00 movb $0x0,(%eax)
p = buf;
23: c7 45 f0 80 0e 00 00 movl $0xe80,-0x10(%ebp)
while((q = strchr(p, '\n')) != 0){
2a: eb 4a jmp 76 <grep+0x76>
*q = 0;
2c: 8b 45 e8 mov -0x18(%ebp),%eax
2f: c6 00 00 movb $0x0,(%eax)
if(match(pattern, p)){
32: 83 ec 08 sub $0x8,%esp
35: ff 75 f0 pushl -0x10(%ebp)
38: ff 75 08 pushl 0x8(%ebp)
3b: e8 9a 01 00 00 call 1da <match>
40: 83 c4 10 add $0x10,%esp
43: 85 c0 test %eax,%eax
45: 74 26 je 6d <grep+0x6d>
*q = '\n';
47: 8b 45 e8 mov -0x18(%ebp),%eax
4a: c6 00 0a movb $0xa,(%eax)
write(1, p, q+1 - p);
4d: 8b 45 e8 mov -0x18(%ebp),%eax
50: 83 c0 01 add $0x1,%eax
53: 89 c2 mov %eax,%edx
55: 8b 45 f0 mov -0x10(%ebp),%eax
58: 29 c2 sub %eax,%edx
5a: 89 d0 mov %edx,%eax
5c: 83 ec 04 sub $0x4,%esp
5f: 50 push %eax
60: ff 75 f0 pushl -0x10(%ebp)
63: 6a 01 push $0x1
65: e8 88 05 00 00 call 5f2 <write>
6a: 83 c4 10 add $0x10,%esp
}
p = q+1;
6d: 8b 45 e8 mov -0x18(%ebp),%eax
70: 83 c0 01 add $0x1,%eax
73: 89 45 f0 mov %eax,-0x10(%ebp)
m = 0;
while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){
m += n;
buf[m] = '\0';
p = buf;
while((q = strchr(p, '\n')) != 0){
76: 83 ec 08 sub $0x8,%esp
79: 6a 0a push $0xa
7b: ff 75 f0 pushl -0x10(%ebp)
7e: e8 89 03 00 00 call 40c <strchr>
83: 83 c4 10 add $0x10,%esp
86: 89 45 e8 mov %eax,-0x18(%ebp)
89: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
8d: 75 9d jne 2c <grep+0x2c>
*q = '\n';
write(1, p, q+1 - p);
}
p = q+1;
}
if(p == buf)
8f: 81 7d f0 80 0e 00 00 cmpl $0xe80,-0x10(%ebp)
96: 75 07 jne 9f <grep+0x9f>
m = 0;
98: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
if(m > 0){
9f: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
a3: 7e 23 jle c8 <grep+0xc8>
m -= p - buf;
a5: 8b 45 f0 mov -0x10(%ebp),%eax
a8: ba 80 0e 00 00 mov $0xe80,%edx
ad: 29 d0 sub %edx,%eax
af: 29 45 f4 sub %eax,-0xc(%ebp)
memmove(buf, p, m);
b2: 83 ec 04 sub $0x4,%esp
b5: ff 75 f4 pushl -0xc(%ebp)
b8: ff 75 f0 pushl -0x10(%ebp)
bb: 68 80 0e 00 00 push $0xe80
c0: e8 c8 04 00 00 call 58d <memmove>
c5: 83 c4 10 add $0x10,%esp
{
int n, m;
char *p, *q;
m = 0;
while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){
c8: 8b 45 f4 mov -0xc(%ebp),%eax
cb: ba ff 03 00 00 mov $0x3ff,%edx
d0: 29 c2 sub %eax,%edx
d2: 89 d0 mov %edx,%eax
d4: 89 c2 mov %eax,%edx
d6: 8b 45 f4 mov -0xc(%ebp),%eax
d9: 05 80 0e 00 00 add $0xe80,%eax
de: 83 ec 04 sub $0x4,%esp
e1: 52 push %edx
e2: 50 push %eax
e3: ff 75 0c pushl 0xc(%ebp)
e6: e8 ff 04 00 00 call 5ea <read>
eb: 83 c4 10 add $0x10,%esp
ee: 89 45 ec mov %eax,-0x14(%ebp)
f1: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
f5: 0f 8f 17 ff ff ff jg 12 <grep+0x12>
if(m > 0){
m -= p - buf;
memmove(buf, p, m);
}
}
}
fb: 90 nop
fc: c9 leave
fd: c3 ret
000000fe <main>:
int
main(int argc, char *argv[])
{
fe: 8d 4c 24 04 lea 0x4(%esp),%ecx
102: 83 e4 f0 and $0xfffffff0,%esp
105: ff 71 fc pushl -0x4(%ecx)
108: 55 push %ebp
109: 89 e5 mov %esp,%ebp
10b: 53 push %ebx
10c: 51 push %ecx
10d: 83 ec 10 sub $0x10,%esp
110: 89 cb mov %ecx,%ebx
int fd, i;
char *pattern;
if(argc <= 1){
112: 83 3b 01 cmpl $0x1,(%ebx)
115: 7f 17 jg 12e <main+0x30>
printf(2, "usage: grep pattern [file ...]\n");
117: 83 ec 08 sub $0x8,%esp
11a: 68 40 0b 00 00 push $0xb40
11f: 6a 02 push $0x2
121: e8 63 06 00 00 call 789 <printf>
126: 83 c4 10 add $0x10,%esp
exit();
129: e8 a4 04 00 00 call 5d2 <exit>
}
pattern = argv[1];
12e: 8b 43 04 mov 0x4(%ebx),%eax
131: 8b 40 04 mov 0x4(%eax),%eax
134: 89 45 f0 mov %eax,-0x10(%ebp)
if(argc <= 2){
137: 83 3b 02 cmpl $0x2,(%ebx)
13a: 7f 15 jg 151 <main+0x53>
grep(pattern, 0);
13c: 83 ec 08 sub $0x8,%esp
13f: 6a 00 push $0x0
141: ff 75 f0 pushl -0x10(%ebp)
144: e8 b7 fe ff ff call 0 <grep>
149: 83 c4 10 add $0x10,%esp
exit();
14c: e8 81 04 00 00 call 5d2 <exit>
}
for(i = 2; i < argc; i++){
151: c7 45 f4 02 00 00 00 movl $0x2,-0xc(%ebp)
158: eb 74 jmp 1ce <main+0xd0>
if((fd = open(argv[i], 0)) < 0){
15a: 8b 45 f4 mov -0xc(%ebp),%eax
15d: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
164: 8b 43 04 mov 0x4(%ebx),%eax
167: 01 d0 add %edx,%eax
169: 8b 00 mov (%eax),%eax
16b: 83 ec 08 sub $0x8,%esp
16e: 6a 00 push $0x0
170: 50 push %eax
171: e8 9c 04 00 00 call 612 <open>
176: 83 c4 10 add $0x10,%esp
179: 89 45 ec mov %eax,-0x14(%ebp)
17c: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
180: 79 29 jns 1ab <main+0xad>
printf(1, "grep: cannot open %s\n", argv[i]);
182: 8b 45 f4 mov -0xc(%ebp),%eax
185: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
18c: 8b 43 04 mov 0x4(%ebx),%eax
18f: 01 d0 add %edx,%eax
191: 8b 00 mov (%eax),%eax
193: 83 ec 04 sub $0x4,%esp
196: 50 push %eax
197: 68 60 0b 00 00 push $0xb60
19c: 6a 01 push $0x1
19e: e8 e6 05 00 00 call 789 <printf>
1a3: 83 c4 10 add $0x10,%esp
exit();
1a6: e8 27 04 00 00 call 5d2 <exit>
}
grep(pattern, fd);
1ab: 83 ec 08 sub $0x8,%esp
1ae: ff 75 ec pushl -0x14(%ebp)
1b1: ff 75 f0 pushl -0x10(%ebp)
1b4: e8 47 fe ff ff call 0 <grep>
1b9: 83 c4 10 add $0x10,%esp
close(fd);
1bc: 83 ec 0c sub $0xc,%esp
1bf: ff 75 ec pushl -0x14(%ebp)
1c2: e8 33 04 00 00 call 5fa <close>
1c7: 83 c4 10 add $0x10,%esp
if(argc <= 2){
grep(pattern, 0);
exit();
}
for(i = 2; i < argc; i++){
1ca: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1ce: 8b 45 f4 mov -0xc(%ebp),%eax
1d1: 3b 03 cmp (%ebx),%eax
1d3: 7c 85 jl 15a <main+0x5c>
exit();
}
grep(pattern, fd);
close(fd);
}
exit();
1d5: e8 f8 03 00 00 call 5d2 <exit>
000001da <match>:
int matchhere(char*, char*);
int matchstar(int, char*, char*);
int
match(char *re, char *text)
{
1da: 55 push %ebp
1db: 89 e5 mov %esp,%ebp
1dd: 83 ec 08 sub $0x8,%esp
if(re[0] == '^')
1e0: 8b 45 08 mov 0x8(%ebp),%eax
1e3: 0f b6 00 movzbl (%eax),%eax
1e6: 3c 5e cmp $0x5e,%al
1e8: 75 17 jne 201 <match+0x27>
return matchhere(re+1, text);
1ea: 8b 45 08 mov 0x8(%ebp),%eax
1ed: 83 c0 01 add $0x1,%eax
1f0: 83 ec 08 sub $0x8,%esp
1f3: ff 75 0c pushl 0xc(%ebp)
1f6: 50 push %eax
1f7: e8 38 00 00 00 call 234 <matchhere>
1fc: 83 c4 10 add $0x10,%esp
1ff: eb 31 jmp 232 <match+0x58>
do{ // must look at empty string
if(matchhere(re, text))
201: 83 ec 08 sub $0x8,%esp
204: ff 75 0c pushl 0xc(%ebp)
207: ff 75 08 pushl 0x8(%ebp)
20a: e8 25 00 00 00 call 234 <matchhere>
20f: 83 c4 10 add $0x10,%esp
212: 85 c0 test %eax,%eax
214: 74 07 je 21d <match+0x43>
return 1;
216: b8 01 00 00 00 mov $0x1,%eax
21b: eb 15 jmp 232 <match+0x58>
}while(*text++ != '\0');
21d: 8b 45 0c mov 0xc(%ebp),%eax
220: 8d 50 01 lea 0x1(%eax),%edx
223: 89 55 0c mov %edx,0xc(%ebp)
226: 0f b6 00 movzbl (%eax),%eax
229: 84 c0 test %al,%al
22b: 75 d4 jne 201 <match+0x27>
return 0;
22d: b8 00 00 00 00 mov $0x0,%eax
}
232: c9 leave
233: c3 ret
00000234 <matchhere>:
// matchhere: search for re at beginning of text
int matchhere(char *re, char *text)
{
234: 55 push %ebp
235: 89 e5 mov %esp,%ebp
237: 83 ec 08 sub $0x8,%esp
if(re[0] == '\0')
23a: 8b 45 08 mov 0x8(%ebp),%eax
23d: 0f b6 00 movzbl (%eax),%eax
240: 84 c0 test %al,%al
242: 75 0a jne 24e <matchhere+0x1a>
return 1;
244: b8 01 00 00 00 mov $0x1,%eax
249: e9 99 00 00 00 jmp 2e7 <matchhere+0xb3>
if(re[1] == '*')
24e: 8b 45 08 mov 0x8(%ebp),%eax
251: 83 c0 01 add $0x1,%eax
254: 0f b6 00 movzbl (%eax),%eax
257: 3c 2a cmp $0x2a,%al
259: 75 21 jne 27c <matchhere+0x48>
return matchstar(re[0], re+2, text);
25b: 8b 45 08 mov 0x8(%ebp),%eax
25e: 8d 50 02 lea 0x2(%eax),%edx
261: 8b 45 08 mov 0x8(%ebp),%eax
264: 0f b6 00 movzbl (%eax),%eax
267: 0f be c0 movsbl %al,%eax
26a: 83 ec 04 sub $0x4,%esp
26d: ff 75 0c pushl 0xc(%ebp)
270: 52 push %edx
271: 50 push %eax
272: e8 72 00 00 00 call 2e9 <matchstar>
277: 83 c4 10 add $0x10,%esp
27a: eb 6b jmp 2e7 <matchhere+0xb3>
if(re[0] == '$' && re[1] == '\0')
27c: 8b 45 08 mov 0x8(%ebp),%eax
27f: 0f b6 00 movzbl (%eax),%eax
282: 3c 24 cmp $0x24,%al
284: 75 1d jne 2a3 <matchhere+0x6f>
286: 8b 45 08 mov 0x8(%ebp),%eax
289: 83 c0 01 add $0x1,%eax
28c: 0f b6 00 movzbl (%eax),%eax
28f: 84 c0 test %al,%al
291: 75 10 jne 2a3 <matchhere+0x6f>
return *text == '\0';
293: 8b 45 0c mov 0xc(%ebp),%eax
296: 0f b6 00 movzbl (%eax),%eax
299: 84 c0 test %al,%al
29b: 0f 94 c0 sete %al
29e: 0f b6 c0 movzbl %al,%eax
2a1: eb 44 jmp 2e7 <matchhere+0xb3>
if(*text!='\0' && (re[0]=='.' || re[0]==*text))
2a3: 8b 45 0c mov 0xc(%ebp),%eax
2a6: 0f b6 00 movzbl (%eax),%eax
2a9: 84 c0 test %al,%al
2ab: 74 35 je 2e2 <matchhere+0xae>
2ad: 8b 45 08 mov 0x8(%ebp),%eax
2b0: 0f b6 00 movzbl (%eax),%eax
2b3: 3c 2e cmp $0x2e,%al
2b5: 74 10 je 2c7 <matchhere+0x93>
2b7: 8b 45 08 mov 0x8(%ebp),%eax
2ba: 0f b6 10 movzbl (%eax),%edx
2bd: 8b 45 0c mov 0xc(%ebp),%eax
2c0: 0f b6 00 movzbl (%eax),%eax
2c3: 38 c2 cmp %al,%dl
2c5: 75 1b jne 2e2 <matchhere+0xae>
return matchhere(re+1, text+1);
2c7: 8b 45 0c mov 0xc(%ebp),%eax
2ca: 8d 50 01 lea 0x1(%eax),%edx
2cd: 8b 45 08 mov 0x8(%ebp),%eax
2d0: 83 c0 01 add $0x1,%eax
2d3: 83 ec 08 sub $0x8,%esp
2d6: 52 push %edx
2d7: 50 push %eax
2d8: e8 57 ff ff ff call 234 <matchhere>
2dd: 83 c4 10 add $0x10,%esp
2e0: eb 05 jmp 2e7 <matchhere+0xb3>
return 0;
2e2: b8 00 00 00 00 mov $0x0,%eax
}
2e7: c9 leave
2e8: c3 ret
000002e9 <matchstar>:
// matchstar: search for c*re at beginning of text
int matchstar(int c, char *re, char *text)
{
2e9: 55 push %ebp
2ea: 89 e5 mov %esp,%ebp
2ec: 83 ec 08 sub $0x8,%esp
do{ // a * matches zero or more instances
if(matchhere(re, text))
2ef: 83 ec 08 sub $0x8,%esp
2f2: ff 75 10 pushl 0x10(%ebp)
2f5: ff 75 0c pushl 0xc(%ebp)
2f8: e8 37 ff ff ff call 234 <matchhere>
2fd: 83 c4 10 add $0x10,%esp
300: 85 c0 test %eax,%eax
302: 74 07 je 30b <matchstar+0x22>
return 1;
304: b8 01 00 00 00 mov $0x1,%eax
309: eb 29 jmp 334 <matchstar+0x4b>
}while(*text!='\0' && (*text++==c || c=='.'));
30b: 8b 45 10 mov 0x10(%ebp),%eax
30e: 0f b6 00 movzbl (%eax),%eax
311: 84 c0 test %al,%al
313: 74 1a je 32f <matchstar+0x46>
315: 8b 45 10 mov 0x10(%ebp),%eax
318: 8d 50 01 lea 0x1(%eax),%edx
31b: 89 55 10 mov %edx,0x10(%ebp)
31e: 0f b6 00 movzbl (%eax),%eax
321: 0f be c0 movsbl %al,%eax
324: 3b 45 08 cmp 0x8(%ebp),%eax
327: 74 c6 je 2ef <matchstar+0x6>
329: 83 7d 08 2e cmpl $0x2e,0x8(%ebp)
32d: 74 c0 je 2ef <matchstar+0x6>
return 0;
32f: b8 00 00 00 00 mov $0x0,%eax
}
334: c9 leave
335: c3 ret
00000336 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
336: 55 push %ebp
337: 89 e5 mov %esp,%ebp
339: 57 push %edi
33a: 53 push %ebx
asm volatile("cld; rep stosb" :
33b: 8b 4d 08 mov 0x8(%ebp),%ecx
33e: 8b 55 10 mov 0x10(%ebp),%edx
341: 8b 45 0c mov 0xc(%ebp),%eax
344: 89 cb mov %ecx,%ebx
346: 89 df mov %ebx,%edi
348: 89 d1 mov %edx,%ecx
34a: fc cld
34b: f3 aa rep stos %al,%es:(%edi)
34d: 89 ca mov %ecx,%edx
34f: 89 fb mov %edi,%ebx
351: 89 5d 08 mov %ebx,0x8(%ebp)
354: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
357: 90 nop
358: 5b pop %ebx
359: 5f pop %edi
35a: 5d pop %ebp
35b: c3 ret
0000035c <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
35c: 55 push %ebp
35d: 89 e5 mov %esp,%ebp
35f: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
362: 8b 45 08 mov 0x8(%ebp),%eax
365: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
368: 90 nop
369: 8b 45 08 mov 0x8(%ebp),%eax
36c: 8d 50 01 lea 0x1(%eax),%edx
36f: 89 55 08 mov %edx,0x8(%ebp)
372: 8b 55 0c mov 0xc(%ebp),%edx
375: 8d 4a 01 lea 0x1(%edx),%ecx
378: 89 4d 0c mov %ecx,0xc(%ebp)
37b: 0f b6 12 movzbl (%edx),%edx
37e: 88 10 mov %dl,(%eax)
380: 0f b6 00 movzbl (%eax),%eax
383: 84 c0 test %al,%al
385: 75 e2 jne 369 <strcpy+0xd>
;
return os;
387: 8b 45 fc mov -0x4(%ebp),%eax
}
38a: c9 leave
38b: c3 ret
0000038c <strcmp>:
int
strcmp(const char *p, const char *q)
{
38c: 55 push %ebp
38d: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
38f: eb 08 jmp 399 <strcmp+0xd>
p++, q++;
391: 83 45 08 01 addl $0x1,0x8(%ebp)
395: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
399: 8b 45 08 mov 0x8(%ebp),%eax
39c: 0f b6 00 movzbl (%eax),%eax
39f: 84 c0 test %al,%al
3a1: 74 10 je 3b3 <strcmp+0x27>
3a3: 8b 45 08 mov 0x8(%ebp),%eax
3a6: 0f b6 10 movzbl (%eax),%edx
3a9: 8b 45 0c mov 0xc(%ebp),%eax
3ac: 0f b6 00 movzbl (%eax),%eax
3af: 38 c2 cmp %al,%dl
3b1: 74 de je 391 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
3b3: 8b 45 08 mov 0x8(%ebp),%eax
3b6: 0f b6 00 movzbl (%eax),%eax
3b9: 0f b6 d0 movzbl %al,%edx
3bc: 8b 45 0c mov 0xc(%ebp),%eax
3bf: 0f b6 00 movzbl (%eax),%eax
3c2: 0f b6 c0 movzbl %al,%eax
3c5: 29 c2 sub %eax,%edx
3c7: 89 d0 mov %edx,%eax
}
3c9: 5d pop %ebp
3ca: c3 ret
000003cb <strlen>:
uint
strlen(char *s)
{
3cb: 55 push %ebp
3cc: 89 e5 mov %esp,%ebp
3ce: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
3d1: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
3d8: eb 04 jmp 3de <strlen+0x13>
3da: 83 45 fc 01 addl $0x1,-0x4(%ebp)
3de: 8b 55 fc mov -0x4(%ebp),%edx
3e1: 8b 45 08 mov 0x8(%ebp),%eax
3e4: 01 d0 add %edx,%eax
3e6: 0f b6 00 movzbl (%eax),%eax
3e9: 84 c0 test %al,%al
3eb: 75 ed jne 3da <strlen+0xf>
;
return n;
3ed: 8b 45 fc mov -0x4(%ebp),%eax
}
3f0: c9 leave
3f1: c3 ret
000003f2 <memset>:
void*
memset(void *dst, int c, uint n)
{
3f2: 55 push %ebp
3f3: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
3f5: 8b 45 10 mov 0x10(%ebp),%eax
3f8: 50 push %eax
3f9: ff 75 0c pushl 0xc(%ebp)
3fc: ff 75 08 pushl 0x8(%ebp)
3ff: e8 32 ff ff ff call 336 <stosb>
404: 83 c4 0c add $0xc,%esp
return dst;
407: 8b 45 08 mov 0x8(%ebp),%eax
}
40a: c9 leave
40b: c3 ret
0000040c <strchr>:
char*
strchr(const char *s, char c)
{
40c: 55 push %ebp
40d: 89 e5 mov %esp,%ebp
40f: 83 ec 04 sub $0x4,%esp
412: 8b 45 0c mov 0xc(%ebp),%eax
415: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
418: eb 14 jmp 42e <strchr+0x22>
if(*s == c)
41a: 8b 45 08 mov 0x8(%ebp),%eax
41d: 0f b6 00 movzbl (%eax),%eax
420: 3a 45 fc cmp -0x4(%ebp),%al
423: 75 05 jne 42a <strchr+0x1e>
return (char*)s;
425: 8b 45 08 mov 0x8(%ebp),%eax
428: eb 13 jmp 43d <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
42a: 83 45 08 01 addl $0x1,0x8(%ebp)
42e: 8b 45 08 mov 0x8(%ebp),%eax
431: 0f b6 00 movzbl (%eax),%eax
434: 84 c0 test %al,%al
436: 75 e2 jne 41a <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
438: b8 00 00 00 00 mov $0x0,%eax
}
43d: c9 leave
43e: c3 ret
0000043f <gets>:
char*
gets(char *buf, int max)
{
43f: 55 push %ebp
440: 89 e5 mov %esp,%ebp
442: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
445: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
44c: eb 42 jmp 490 <gets+0x51>
cc = read(0, &c, 1);
44e: 83 ec 04 sub $0x4,%esp
451: 6a 01 push $0x1
453: 8d 45 ef lea -0x11(%ebp),%eax
456: 50 push %eax
457: 6a 00 push $0x0
459: e8 8c 01 00 00 call 5ea <read>
45e: 83 c4 10 add $0x10,%esp
461: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
464: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
468: 7e 33 jle 49d <gets+0x5e>
break;
buf[i++] = c;
46a: 8b 45 f4 mov -0xc(%ebp),%eax
46d: 8d 50 01 lea 0x1(%eax),%edx
470: 89 55 f4 mov %edx,-0xc(%ebp)
473: 89 c2 mov %eax,%edx
475: 8b 45 08 mov 0x8(%ebp),%eax
478: 01 c2 add %eax,%edx
47a: 0f b6 45 ef movzbl -0x11(%ebp),%eax
47e: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
480: 0f b6 45 ef movzbl -0x11(%ebp),%eax
484: 3c 0a cmp $0xa,%al
486: 74 16 je 49e <gets+0x5f>
488: 0f b6 45 ef movzbl -0x11(%ebp),%eax
48c: 3c 0d cmp $0xd,%al
48e: 74 0e je 49e <gets+0x5f>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
490: 8b 45 f4 mov -0xc(%ebp),%eax
493: 83 c0 01 add $0x1,%eax
496: 3b 45 0c cmp 0xc(%ebp),%eax
499: 7c b3 jl 44e <gets+0xf>
49b: eb 01 jmp 49e <gets+0x5f>
cc = read(0, &c, 1);
if(cc < 1)
break;
49d: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
49e: 8b 55 f4 mov -0xc(%ebp),%edx
4a1: 8b 45 08 mov 0x8(%ebp),%eax
4a4: 01 d0 add %edx,%eax
4a6: c6 00 00 movb $0x0,(%eax)
return buf;
4a9: 8b 45 08 mov 0x8(%ebp),%eax
}
4ac: c9 leave
4ad: c3 ret
000004ae <stat>:
int
stat(char *n, struct stat *st)
{
4ae: 55 push %ebp
4af: 89 e5 mov %esp,%ebp
4b1: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
4b4: 83 ec 08 sub $0x8,%esp
4b7: 6a 00 push $0x0
4b9: ff 75 08 pushl 0x8(%ebp)
4bc: e8 51 01 00 00 call 612 <open>
4c1: 83 c4 10 add $0x10,%esp
4c4: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
4c7: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
4cb: 79 07 jns 4d4 <stat+0x26>
return -1;
4cd: b8 ff ff ff ff mov $0xffffffff,%eax
4d2: eb 25 jmp 4f9 <stat+0x4b>
r = fstat(fd, st);
4d4: 83 ec 08 sub $0x8,%esp
4d7: ff 75 0c pushl 0xc(%ebp)
4da: ff 75 f4 pushl -0xc(%ebp)
4dd: e8 48 01 00 00 call 62a <fstat>
4e2: 83 c4 10 add $0x10,%esp
4e5: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
4e8: 83 ec 0c sub $0xc,%esp
4eb: ff 75 f4 pushl -0xc(%ebp)
4ee: e8 07 01 00 00 call 5fa <close>
4f3: 83 c4 10 add $0x10,%esp
return r;
4f6: 8b 45 f0 mov -0x10(%ebp),%eax
}
4f9: c9 leave
4fa: c3 ret
000004fb <atoi>:
// new atoi added 4/22/17 to be able to handle negative numbers
int
atoi(const char *s)
{
4fb: 55 push %ebp
4fc: 89 e5 mov %esp,%ebp
4fe: 83 ec 10 sub $0x10,%esp
int n, sign;
n=0;
501: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while(*s==' ')s++;//Remove leading spaces
508: eb 04 jmp 50e <atoi+0x13>
50a: 83 45 08 01 addl $0x1,0x8(%ebp)
50e: 8b 45 08 mov 0x8(%ebp),%eax
511: 0f b6 00 movzbl (%eax),%eax
514: 3c 20 cmp $0x20,%al
516: 74 f2 je 50a <atoi+0xf>
sign =(*s=='-')?-1 : 1;
518: 8b 45 08 mov 0x8(%ebp),%eax
51b: 0f b6 00 movzbl (%eax),%eax
51e: 3c 2d cmp $0x2d,%al
520: 75 07 jne 529 <atoi+0x2e>
522: b8 ff ff ff ff mov $0xffffffff,%eax
527: eb 05 jmp 52e <atoi+0x33>
529: b8 01 00 00 00 mov $0x1,%eax
52e: 89 45 f8 mov %eax,-0x8(%ebp)
if(*s=='+' || *s=='-')
531: 8b 45 08 mov 0x8(%ebp),%eax
534: 0f b6 00 movzbl (%eax),%eax
537: 3c 2b cmp $0x2b,%al
539: 74 0a je 545 <atoi+0x4a>
53b: 8b 45 08 mov 0x8(%ebp),%eax
53e: 0f b6 00 movzbl (%eax),%eax
541: 3c 2d cmp $0x2d,%al
543: 75 2b jne 570 <atoi+0x75>
s++;
545: 83 45 08 01 addl $0x1,0x8(%ebp)
while('0' <= *s&&*s<='9')
549: eb 25 jmp 570 <atoi+0x75>
n = n*10 + *s++ - '0';
54b: 8b 55 fc mov -0x4(%ebp),%edx
54e: 89 d0 mov %edx,%eax
550: c1 e0 02 shl $0x2,%eax
553: 01 d0 add %edx,%eax
555: 01 c0 add %eax,%eax
557: 89 c1 mov %eax,%ecx
559: 8b 45 08 mov 0x8(%ebp),%eax
55c: 8d 50 01 lea 0x1(%eax),%edx
55f: 89 55 08 mov %edx,0x8(%ebp)
562: 0f b6 00 movzbl (%eax),%eax
565: 0f be c0 movsbl %al,%eax
568: 01 c8 add %ecx,%eax
56a: 83 e8 30 sub $0x30,%eax
56d: 89 45 fc mov %eax,-0x4(%ebp)
n=0;
while(*s==' ')s++;//Remove leading spaces
sign =(*s=='-')?-1 : 1;
if(*s=='+' || *s=='-')
s++;
while('0' <= *s&&*s<='9')
570: 8b 45 08 mov 0x8(%ebp),%eax
573: 0f b6 00 movzbl (%eax),%eax
576: 3c 2f cmp $0x2f,%al
578: 7e 0a jle 584 <atoi+0x89>
57a: 8b 45 08 mov 0x8(%ebp),%eax
57d: 0f b6 00 movzbl (%eax),%eax
580: 3c 39 cmp $0x39,%al
582: 7e c7 jle 54b <atoi+0x50>
n = n*10 + *s++ - '0';
return sign*n;
584: 8b 45 f8 mov -0x8(%ebp),%eax
587: 0f af 45 fc imul -0x4(%ebp),%eax
}
58b: c9 leave
58c: c3 ret
0000058d <memmove>:
return n;
}
*/
void*
memmove(void *vdst, void *vsrc, int n)
{
58d: 55 push %ebp
58e: 89 e5 mov %esp,%ebp
590: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
593: 8b 45 08 mov 0x8(%ebp),%eax
596: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
599: 8b 45 0c mov 0xc(%ebp),%eax
59c: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
59f: eb 17 jmp 5b8 <memmove+0x2b>
*dst++ = *src++;
5a1: 8b 45 fc mov -0x4(%ebp),%eax
5a4: 8d 50 01 lea 0x1(%eax),%edx
5a7: 89 55 fc mov %edx,-0x4(%ebp)
5aa: 8b 55 f8 mov -0x8(%ebp),%edx
5ad: 8d 4a 01 lea 0x1(%edx),%ecx
5b0: 89 4d f8 mov %ecx,-0x8(%ebp)
5b3: 0f b6 12 movzbl (%edx),%edx
5b6: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
5b8: 8b 45 10 mov 0x10(%ebp),%eax
5bb: 8d 50 ff lea -0x1(%eax),%edx
5be: 89 55 10 mov %edx,0x10(%ebp)
5c1: 85 c0 test %eax,%eax
5c3: 7f dc jg 5a1 <memmove+0x14>
*dst++ = *src++;
return vdst;
5c5: 8b 45 08 mov 0x8(%ebp),%eax
}
5c8: c9 leave
5c9: c3 ret
000005ca <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
5ca: b8 01 00 00 00 mov $0x1,%eax
5cf: cd 40 int $0x40
5d1: c3 ret
000005d2 <exit>:
SYSCALL(exit)
5d2: b8 02 00 00 00 mov $0x2,%eax
5d7: cd 40 int $0x40
5d9: c3 ret
000005da <wait>:
SYSCALL(wait)
5da: b8 03 00 00 00 mov $0x3,%eax
5df: cd 40 int $0x40
5e1: c3 ret
000005e2 <pipe>:
SYSCALL(pipe)
5e2: b8 04 00 00 00 mov $0x4,%eax
5e7: cd 40 int $0x40
5e9: c3 ret
000005ea <read>:
SYSCALL(read)
5ea: b8 05 00 00 00 mov $0x5,%eax
5ef: cd 40 int $0x40
5f1: c3 ret
000005f2 <write>:
SYSCALL(write)
5f2: b8 10 00 00 00 mov $0x10,%eax
5f7: cd 40 int $0x40
5f9: c3 ret
000005fa <close>:
SYSCALL(close)
5fa: b8 15 00 00 00 mov $0x15,%eax
5ff: cd 40 int $0x40
601: c3 ret
00000602 <kill>:
SYSCALL(kill)
602: b8 06 00 00 00 mov $0x6,%eax
607: cd 40 int $0x40
609: c3 ret
0000060a <exec>:
SYSCALL(exec)
60a: b8 07 00 00 00 mov $0x7,%eax
60f: cd 40 int $0x40
611: c3 ret
00000612 <open>:
SYSCALL(open)
612: b8 0f 00 00 00 mov $0xf,%eax
617: cd 40 int $0x40
619: c3 ret
0000061a <mknod>:
SYSCALL(mknod)
61a: b8 11 00 00 00 mov $0x11,%eax
61f: cd 40 int $0x40
621: c3 ret
00000622 <unlink>:
SYSCALL(unlink)
622: b8 12 00 00 00 mov $0x12,%eax
627: cd 40 int $0x40
629: c3 ret
0000062a <fstat>:
SYSCALL(fstat)
62a: b8 08 00 00 00 mov $0x8,%eax
62f: cd 40 int $0x40
631: c3 ret
00000632 <link>:
SYSCALL(link)
632: b8 13 00 00 00 mov $0x13,%eax
637: cd 40 int $0x40
639: c3 ret
0000063a <mkdir>:
SYSCALL(mkdir)
63a: b8 14 00 00 00 mov $0x14,%eax
63f: cd 40 int $0x40
641: c3 ret
00000642 <chdir>:
SYSCALL(chdir)
642: b8 09 00 00 00 mov $0x9,%eax
647: cd 40 int $0x40
649: c3 ret
0000064a <dup>:
SYSCALL(dup)
64a: b8 0a 00 00 00 mov $0xa,%eax
64f: cd 40 int $0x40
651: c3 ret
00000652 <getpid>:
SYSCALL(getpid)
652: b8 0b 00 00 00 mov $0xb,%eax
657: cd 40 int $0x40
659: c3 ret
0000065a <sbrk>:
SYSCALL(sbrk)
65a: b8 0c 00 00 00 mov $0xc,%eax
65f: cd 40 int $0x40
661: c3 ret
00000662 <sleep>:
SYSCALL(sleep)
662: b8 0d 00 00 00 mov $0xd,%eax
667: cd 40 int $0x40
669: c3 ret
0000066a <uptime>:
SYSCALL(uptime)
66a: b8 0e 00 00 00 mov $0xe,%eax
66f: cd 40 int $0x40
671: c3 ret
00000672 <halt>:
SYSCALL(halt)
672: b8 16 00 00 00 mov $0x16,%eax
677: cd 40 int $0x40
679: c3 ret
0000067a <date>:
//Project additions
SYSCALL(date)
67a: b8 17 00 00 00 mov $0x17,%eax
67f: cd 40 int $0x40
681: c3 ret
00000682 <getuid>:
SYSCALL(getuid)
682: b8 18 00 00 00 mov $0x18,%eax
687: cd 40 int $0x40
689: c3 ret
0000068a <getgid>:
SYSCALL(getgid)
68a: b8 19 00 00 00 mov $0x19,%eax
68f: cd 40 int $0x40
691: c3 ret
00000692 <getppid>:
SYSCALL(getppid)
692: b8 1a 00 00 00 mov $0x1a,%eax
697: cd 40 int $0x40
699: c3 ret
0000069a <setuid>:
SYSCALL(setuid)
69a: b8 1b 00 00 00 mov $0x1b,%eax
69f: cd 40 int $0x40
6a1: c3 ret
000006a2 <setgid>:
SYSCALL(setgid)
6a2: b8 1c 00 00 00 mov $0x1c,%eax
6a7: cd 40 int $0x40
6a9: c3 ret
000006aa <getprocs>:
SYSCALL(getprocs)
6aa: b8 1d 00 00 00 mov $0x1d,%eax
6af: cd 40 int $0x40
6b1: c3 ret
000006b2 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
6b2: 55 push %ebp
6b3: 89 e5 mov %esp,%ebp
6b5: 83 ec 18 sub $0x18,%esp
6b8: 8b 45 0c mov 0xc(%ebp),%eax
6bb: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
6be: 83 ec 04 sub $0x4,%esp
6c1: 6a 01 push $0x1
6c3: 8d 45 f4 lea -0xc(%ebp),%eax
6c6: 50 push %eax
6c7: ff 75 08 pushl 0x8(%ebp)
6ca: e8 23 ff ff ff call 5f2 <write>
6cf: 83 c4 10 add $0x10,%esp
}
6d2: 90 nop
6d3: c9 leave
6d4: c3 ret
000006d5 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
6d5: 55 push %ebp
6d6: 89 e5 mov %esp,%ebp
6d8: 53 push %ebx
6d9: 83 ec 24 sub $0x24,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
6dc: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
6e3: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
6e7: 74 17 je 700 <printint+0x2b>
6e9: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
6ed: 79 11 jns 700 <printint+0x2b>
neg = 1;
6ef: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
6f6: 8b 45 0c mov 0xc(%ebp),%eax
6f9: f7 d8 neg %eax
6fb: 89 45 ec mov %eax,-0x14(%ebp)
6fe: eb 06 jmp 706 <printint+0x31>
} else {
x = xx;
700: 8b 45 0c mov 0xc(%ebp),%eax
703: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
706: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
70d: 8b 4d f4 mov -0xc(%ebp),%ecx
710: 8d 41 01 lea 0x1(%ecx),%eax
713: 89 45 f4 mov %eax,-0xc(%ebp)
716: 8b 5d 10 mov 0x10(%ebp),%ebx
719: 8b 45 ec mov -0x14(%ebp),%eax
71c: ba 00 00 00 00 mov $0x0,%edx
721: f7 f3 div %ebx
723: 89 d0 mov %edx,%eax
725: 0f b6 80 4c 0e 00 00 movzbl 0xe4c(%eax),%eax
72c: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
730: 8b 5d 10 mov 0x10(%ebp),%ebx
733: 8b 45 ec mov -0x14(%ebp),%eax
736: ba 00 00 00 00 mov $0x0,%edx
73b: f7 f3 div %ebx
73d: 89 45 ec mov %eax,-0x14(%ebp)
740: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
744: 75 c7 jne 70d <printint+0x38>
if(neg)
746: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
74a: 74 2d je 779 <printint+0xa4>
buf[i++] = '-';
74c: 8b 45 f4 mov -0xc(%ebp),%eax
74f: 8d 50 01 lea 0x1(%eax),%edx
752: 89 55 f4 mov %edx,-0xc(%ebp)
755: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
75a: eb 1d jmp 779 <printint+0xa4>
putc(fd, buf[i]);
75c: 8d 55 dc lea -0x24(%ebp),%edx
75f: 8b 45 f4 mov -0xc(%ebp),%eax
762: 01 d0 add %edx,%eax
764: 0f b6 00 movzbl (%eax),%eax
767: 0f be c0 movsbl %al,%eax
76a: 83 ec 08 sub $0x8,%esp
76d: 50 push %eax
76e: ff 75 08 pushl 0x8(%ebp)
771: e8 3c ff ff ff call 6b2 <putc>
776: 83 c4 10 add $0x10,%esp
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
779: 83 6d f4 01 subl $0x1,-0xc(%ebp)
77d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
781: 79 d9 jns 75c <printint+0x87>
putc(fd, buf[i]);
}
783: 90 nop
784: 8b 5d fc mov -0x4(%ebp),%ebx
787: c9 leave
788: c3 ret
00000789 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
789: 55 push %ebp
78a: 89 e5 mov %esp,%ebp
78c: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
78f: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
796: 8d 45 0c lea 0xc(%ebp),%eax
799: 83 c0 04 add $0x4,%eax
79c: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
79f: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
7a6: e9 59 01 00 00 jmp 904 <printf+0x17b>
c = fmt[i] & 0xff;
7ab: 8b 55 0c mov 0xc(%ebp),%edx
7ae: 8b 45 f0 mov -0x10(%ebp),%eax
7b1: 01 d0 add %edx,%eax
7b3: 0f b6 00 movzbl (%eax),%eax
7b6: 0f be c0 movsbl %al,%eax
7b9: 25 ff 00 00 00 and $0xff,%eax
7be: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
7c1: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
7c5: 75 2c jne 7f3 <printf+0x6a>
if(c == '%'){
7c7: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
7cb: 75 0c jne 7d9 <printf+0x50>
state = '%';
7cd: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
7d4: e9 27 01 00 00 jmp 900 <printf+0x177>
} else {
putc(fd, c);
7d9: 8b 45 e4 mov -0x1c(%ebp),%eax
7dc: 0f be c0 movsbl %al,%eax
7df: 83 ec 08 sub $0x8,%esp
7e2: 50 push %eax
7e3: ff 75 08 pushl 0x8(%ebp)
7e6: e8 c7 fe ff ff call 6b2 <putc>
7eb: 83 c4 10 add $0x10,%esp
7ee: e9 0d 01 00 00 jmp 900 <printf+0x177>
}
} else if(state == '%'){
7f3: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
7f7: 0f 85 03 01 00 00 jne 900 <printf+0x177>
if(c == 'd'){
7fd: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
801: 75 1e jne 821 <printf+0x98>
printint(fd, *ap, 10, 1);
803: 8b 45 e8 mov -0x18(%ebp),%eax
806: 8b 00 mov (%eax),%eax
808: 6a 01 push $0x1
80a: 6a 0a push $0xa
80c: 50 push %eax
80d: ff 75 08 pushl 0x8(%ebp)
810: e8 c0 fe ff ff call 6d5 <printint>
815: 83 c4 10 add $0x10,%esp
ap++;
818: 83 45 e8 04 addl $0x4,-0x18(%ebp)
81c: e9 d8 00 00 00 jmp 8f9 <printf+0x170>
} else if(c == 'x' || c == 'p'){
821: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
825: 74 06 je 82d <printf+0xa4>
827: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
82b: 75 1e jne 84b <printf+0xc2>
printint(fd, *ap, 16, 0);
82d: 8b 45 e8 mov -0x18(%ebp),%eax
830: 8b 00 mov (%eax),%eax
832: 6a 00 push $0x0
834: 6a 10 push $0x10
836: 50 push %eax
837: ff 75 08 pushl 0x8(%ebp)
83a: e8 96 fe ff ff call 6d5 <printint>
83f: 83 c4 10 add $0x10,%esp
ap++;
842: 83 45 e8 04 addl $0x4,-0x18(%ebp)
846: e9 ae 00 00 00 jmp 8f9 <printf+0x170>
} else if(c == 's'){
84b: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
84f: 75 43 jne 894 <printf+0x10b>
s = (char*)*ap;
851: 8b 45 e8 mov -0x18(%ebp),%eax
854: 8b 00 mov (%eax),%eax
856: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
859: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
85d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
861: 75 25 jne 888 <printf+0xff>
s = "(null)";
863: c7 45 f4 76 0b 00 00 movl $0xb76,-0xc(%ebp)
while(*s != 0){
86a: eb 1c jmp 888 <printf+0xff>
putc(fd, *s);
86c: 8b 45 f4 mov -0xc(%ebp),%eax
86f: 0f b6 00 movzbl (%eax),%eax
872: 0f be c0 movsbl %al,%eax
875: 83 ec 08 sub $0x8,%esp
878: 50 push %eax
879: ff 75 08 pushl 0x8(%ebp)
87c: e8 31 fe ff ff call 6b2 <putc>
881: 83 c4 10 add $0x10,%esp
s++;
884: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
888: 8b 45 f4 mov -0xc(%ebp),%eax
88b: 0f b6 00 movzbl (%eax),%eax
88e: 84 c0 test %al,%al
890: 75 da jne 86c <printf+0xe3>
892: eb 65 jmp 8f9 <printf+0x170>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
894: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
898: 75 1d jne 8b7 <printf+0x12e>
putc(fd, *ap);
89a: 8b 45 e8 mov -0x18(%ebp),%eax
89d: 8b 00 mov (%eax),%eax
89f: 0f be c0 movsbl %al,%eax
8a2: 83 ec 08 sub $0x8,%esp
8a5: 50 push %eax
8a6: ff 75 08 pushl 0x8(%ebp)
8a9: e8 04 fe ff ff call 6b2 <putc>
8ae: 83 c4 10 add $0x10,%esp
ap++;
8b1: 83 45 e8 04 addl $0x4,-0x18(%ebp)
8b5: eb 42 jmp 8f9 <printf+0x170>
} else if(c == '%'){
8b7: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
8bb: 75 17 jne 8d4 <printf+0x14b>
putc(fd, c);
8bd: 8b 45 e4 mov -0x1c(%ebp),%eax
8c0: 0f be c0 movsbl %al,%eax
8c3: 83 ec 08 sub $0x8,%esp
8c6: 50 push %eax
8c7: ff 75 08 pushl 0x8(%ebp)
8ca: e8 e3 fd ff ff call 6b2 <putc>
8cf: 83 c4 10 add $0x10,%esp
8d2: eb 25 jmp 8f9 <printf+0x170>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
8d4: 83 ec 08 sub $0x8,%esp
8d7: 6a 25 push $0x25
8d9: ff 75 08 pushl 0x8(%ebp)
8dc: e8 d1 fd ff ff call 6b2 <putc>
8e1: 83 c4 10 add $0x10,%esp
putc(fd, c);
8e4: 8b 45 e4 mov -0x1c(%ebp),%eax
8e7: 0f be c0 movsbl %al,%eax
8ea: 83 ec 08 sub $0x8,%esp
8ed: 50 push %eax
8ee: ff 75 08 pushl 0x8(%ebp)
8f1: e8 bc fd ff ff call 6b2 <putc>
8f6: 83 c4 10 add $0x10,%esp
}
state = 0;
8f9: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
900: 83 45 f0 01 addl $0x1,-0x10(%ebp)
904: 8b 55 0c mov 0xc(%ebp),%edx
907: 8b 45 f0 mov -0x10(%ebp),%eax
90a: 01 d0 add %edx,%eax
90c: 0f b6 00 movzbl (%eax),%eax
90f: 84 c0 test %al,%al
911: 0f 85 94 fe ff ff jne 7ab <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
917: 90 nop
918: c9 leave
919: c3 ret
0000091a <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
91a: 55 push %ebp
91b: 89 e5 mov %esp,%ebp
91d: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
920: 8b 45 08 mov 0x8(%ebp),%eax
923: 83 e8 08 sub $0x8,%eax
926: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
929: a1 68 0e 00 00 mov 0xe68,%eax
92e: 89 45 fc mov %eax,-0x4(%ebp)
931: eb 24 jmp 957 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
933: 8b 45 fc mov -0x4(%ebp),%eax
936: 8b 00 mov (%eax),%eax
938: 3b 45 fc cmp -0x4(%ebp),%eax
93b: 77 12 ja 94f <free+0x35>
93d: 8b 45 f8 mov -0x8(%ebp),%eax
940: 3b 45 fc cmp -0x4(%ebp),%eax
943: 77 24 ja 969 <free+0x4f>
945: 8b 45 fc mov -0x4(%ebp),%eax
948: 8b 00 mov (%eax),%eax
94a: 3b 45 f8 cmp -0x8(%ebp),%eax
94d: 77 1a ja 969 <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
94f: 8b 45 fc mov -0x4(%ebp),%eax
952: 8b 00 mov (%eax),%eax
954: 89 45 fc mov %eax,-0x4(%ebp)
957: 8b 45 f8 mov -0x8(%ebp),%eax
95a: 3b 45 fc cmp -0x4(%ebp),%eax
95d: 76 d4 jbe 933 <free+0x19>
95f: 8b 45 fc mov -0x4(%ebp),%eax
962: 8b 00 mov (%eax),%eax
964: 3b 45 f8 cmp -0x8(%ebp),%eax
967: 76 ca jbe 933 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
969: 8b 45 f8 mov -0x8(%ebp),%eax
96c: 8b 40 04 mov 0x4(%eax),%eax
96f: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
976: 8b 45 f8 mov -0x8(%ebp),%eax
979: 01 c2 add %eax,%edx
97b: 8b 45 fc mov -0x4(%ebp),%eax
97e: 8b 00 mov (%eax),%eax
980: 39 c2 cmp %eax,%edx
982: 75 24 jne 9a8 <free+0x8e>
bp->s.size += p->s.ptr->s.size;
984: 8b 45 f8 mov -0x8(%ebp),%eax
987: 8b 50 04 mov 0x4(%eax),%edx
98a: 8b 45 fc mov -0x4(%ebp),%eax
98d: 8b 00 mov (%eax),%eax
98f: 8b 40 04 mov 0x4(%eax),%eax
992: 01 c2 add %eax,%edx
994: 8b 45 f8 mov -0x8(%ebp),%eax
997: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
99a: 8b 45 fc mov -0x4(%ebp),%eax
99d: 8b 00 mov (%eax),%eax
99f: 8b 10 mov (%eax),%edx
9a1: 8b 45 f8 mov -0x8(%ebp),%eax
9a4: 89 10 mov %edx,(%eax)
9a6: eb 0a jmp 9b2 <free+0x98>
} else
bp->s.ptr = p->s.ptr;
9a8: 8b 45 fc mov -0x4(%ebp),%eax
9ab: 8b 10 mov (%eax),%edx
9ad: 8b 45 f8 mov -0x8(%ebp),%eax
9b0: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
9b2: 8b 45 fc mov -0x4(%ebp),%eax
9b5: 8b 40 04 mov 0x4(%eax),%eax
9b8: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
9bf: 8b 45 fc mov -0x4(%ebp),%eax
9c2: 01 d0 add %edx,%eax
9c4: 3b 45 f8 cmp -0x8(%ebp),%eax
9c7: 75 20 jne 9e9 <free+0xcf>
p->s.size += bp->s.size;
9c9: 8b 45 fc mov -0x4(%ebp),%eax
9cc: 8b 50 04 mov 0x4(%eax),%edx
9cf: 8b 45 f8 mov -0x8(%ebp),%eax
9d2: 8b 40 04 mov 0x4(%eax),%eax
9d5: 01 c2 add %eax,%edx
9d7: 8b 45 fc mov -0x4(%ebp),%eax
9da: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
9dd: 8b 45 f8 mov -0x8(%ebp),%eax
9e0: 8b 10 mov (%eax),%edx
9e2: 8b 45 fc mov -0x4(%ebp),%eax
9e5: 89 10 mov %edx,(%eax)
9e7: eb 08 jmp 9f1 <free+0xd7>
} else
p->s.ptr = bp;
9e9: 8b 45 fc mov -0x4(%ebp),%eax
9ec: 8b 55 f8 mov -0x8(%ebp),%edx
9ef: 89 10 mov %edx,(%eax)
freep = p;
9f1: 8b 45 fc mov -0x4(%ebp),%eax
9f4: a3 68 0e 00 00 mov %eax,0xe68
}
9f9: 90 nop
9fa: c9 leave
9fb: c3 ret
000009fc <morecore>:
static Header*
morecore(uint nu)
{
9fc: 55 push %ebp
9fd: 89 e5 mov %esp,%ebp
9ff: 83 ec 18 sub $0x18,%esp
char *p;
Header *hp;
if(nu < 4096)
a02: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
a09: 77 07 ja a12 <morecore+0x16>
nu = 4096;
a0b: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
a12: 8b 45 08 mov 0x8(%ebp),%eax
a15: c1 e0 03 shl $0x3,%eax
a18: 83 ec 0c sub $0xc,%esp
a1b: 50 push %eax
a1c: e8 39 fc ff ff call 65a <sbrk>
a21: 83 c4 10 add $0x10,%esp
a24: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
a27: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
a2b: 75 07 jne a34 <morecore+0x38>
return 0;
a2d: b8 00 00 00 00 mov $0x0,%eax
a32: eb 26 jmp a5a <morecore+0x5e>
hp = (Header*)p;
a34: 8b 45 f4 mov -0xc(%ebp),%eax
a37: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
a3a: 8b 45 f0 mov -0x10(%ebp),%eax
a3d: 8b 55 08 mov 0x8(%ebp),%edx
a40: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
a43: 8b 45 f0 mov -0x10(%ebp),%eax
a46: 83 c0 08 add $0x8,%eax
a49: 83 ec 0c sub $0xc,%esp
a4c: 50 push %eax
a4d: e8 c8 fe ff ff call 91a <free>
a52: 83 c4 10 add $0x10,%esp
return freep;
a55: a1 68 0e 00 00 mov 0xe68,%eax
}
a5a: c9 leave
a5b: c3 ret
00000a5c <malloc>:
void*
malloc(uint nbytes)
{
a5c: 55 push %ebp
a5d: 89 e5 mov %esp,%ebp
a5f: 83 ec 18 sub $0x18,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
a62: 8b 45 08 mov 0x8(%ebp),%eax
a65: 83 c0 07 add $0x7,%eax
a68: c1 e8 03 shr $0x3,%eax
a6b: 83 c0 01 add $0x1,%eax
a6e: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
a71: a1 68 0e 00 00 mov 0xe68,%eax
a76: 89 45 f0 mov %eax,-0x10(%ebp)
a79: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
a7d: 75 23 jne aa2 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
a7f: c7 45 f0 60 0e 00 00 movl $0xe60,-0x10(%ebp)
a86: 8b 45 f0 mov -0x10(%ebp),%eax
a89: a3 68 0e 00 00 mov %eax,0xe68
a8e: a1 68 0e 00 00 mov 0xe68,%eax
a93: a3 60 0e 00 00 mov %eax,0xe60
base.s.size = 0;
a98: c7 05 64 0e 00 00 00 movl $0x0,0xe64
a9f: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
aa2: 8b 45 f0 mov -0x10(%ebp),%eax
aa5: 8b 00 mov (%eax),%eax
aa7: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
aaa: 8b 45 f4 mov -0xc(%ebp),%eax
aad: 8b 40 04 mov 0x4(%eax),%eax
ab0: 3b 45 ec cmp -0x14(%ebp),%eax
ab3: 72 4d jb b02 <malloc+0xa6>
if(p->s.size == nunits)
ab5: 8b 45 f4 mov -0xc(%ebp),%eax
ab8: 8b 40 04 mov 0x4(%eax),%eax
abb: 3b 45 ec cmp -0x14(%ebp),%eax
abe: 75 0c jne acc <malloc+0x70>
prevp->s.ptr = p->s.ptr;
ac0: 8b 45 f4 mov -0xc(%ebp),%eax
ac3: 8b 10 mov (%eax),%edx
ac5: 8b 45 f0 mov -0x10(%ebp),%eax
ac8: 89 10 mov %edx,(%eax)
aca: eb 26 jmp af2 <malloc+0x96>
else {
p->s.size -= nunits;
acc: 8b 45 f4 mov -0xc(%ebp),%eax
acf: 8b 40 04 mov 0x4(%eax),%eax
ad2: 2b 45 ec sub -0x14(%ebp),%eax
ad5: 89 c2 mov %eax,%edx
ad7: 8b 45 f4 mov -0xc(%ebp),%eax
ada: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
add: 8b 45 f4 mov -0xc(%ebp),%eax
ae0: 8b 40 04 mov 0x4(%eax),%eax
ae3: c1 e0 03 shl $0x3,%eax
ae6: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
ae9: 8b 45 f4 mov -0xc(%ebp),%eax
aec: 8b 55 ec mov -0x14(%ebp),%edx
aef: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
af2: 8b 45 f0 mov -0x10(%ebp),%eax
af5: a3 68 0e 00 00 mov %eax,0xe68
return (void*)(p + 1);
afa: 8b 45 f4 mov -0xc(%ebp),%eax
afd: 83 c0 08 add $0x8,%eax
b00: eb 3b jmp b3d <malloc+0xe1>
}
if(p == freep)
b02: a1 68 0e 00 00 mov 0xe68,%eax
b07: 39 45 f4 cmp %eax,-0xc(%ebp)
b0a: 75 1e jne b2a <malloc+0xce>
if((p = morecore(nunits)) == 0)
b0c: 83 ec 0c sub $0xc,%esp
b0f: ff 75 ec pushl -0x14(%ebp)
b12: e8 e5 fe ff ff call 9fc <morecore>
b17: 83 c4 10 add $0x10,%esp
b1a: 89 45 f4 mov %eax,-0xc(%ebp)
b1d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
b21: 75 07 jne b2a <malloc+0xce>
return 0;
b23: b8 00 00 00 00 mov $0x0,%eax
b28: eb 13 jmp b3d <malloc+0xe1>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
b2a: 8b 45 f4 mov -0xc(%ebp),%eax
b2d: 89 45 f0 mov %eax,-0x10(%ebp)
b30: 8b 45 f4 mov -0xc(%ebp),%eax
b33: 8b 00 mov (%eax),%eax
b35: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
b38: e9 6d ff ff ff jmp aaa <malloc+0x4e>
}
b3d: c9 leave
b3e: c3 ret
|
test/Fail/Issue2771.agda | cruhland/agda | 1,989 | 14390 | <filename>test/Fail/Issue2771.agda
data ⊤ : Set where tt : ⊤
postulate
IndexL : Set
Ordered : IndexL → Set
¬ho-shr-morph : IndexL → IndexL
pres-¬ord : ∀ ind → Ordered (¬ho-shr-morph ind)
¬ord-morph : ∀ ind → Ordered ind → Set
postulate tt' : ⊤
poo : ∀ ind → ¬ord-morph (¬ho-shr-morph ind) (pres-¬ord ind)
poo ind with tt | ¬ho-shr-morph ind
... | _ | _ = {!!}
|
test/Succeed/Issue3109.agda | alhassy/agda | 1 | 10528 | <filename>test/Succeed/Issue3109.agda
{-# OPTIONS --allow-unsolved-metas #-}
postulate
Nat : Set
Fin : Nat → Set
Foo : (n : Nat) → Fin n → Set
Bar : ∀ {n m} → Foo n m → Set
variable
n : Nat
m : Fin _
k : Foo _ m
l : Foo n m
open import Agda.Builtin.Equality
postulate
goal-type-error : Bar k
foo : Bar _
foo = goal-type-error _ _
|
oeis/197/A197711.asm | neoneye/loda-programs | 11 | 163571 | ; A197711: Floor((n+1/n)^10)
; Submitted by <NAME>
; 1024,9536,169350,1922601,14455510,79525193,345716130,1253815679,3941971040,11046221254,28162516239,66354069277,146236468527,304356025989,602797997502,1143224193788,2086847748926,3682210047876,6303034667438,10498899284252,17061992477838,27113811835076,42216316373726,64512773675388,96904343881502,143269322488388,208732925307726,299996545666076,425736549529838,597083902389252,828197246045438,1136943467546876,1545701330044926,2082305369910788,2781149009707502,3684467696168988,4843824849832526
add $0,1
pow $0,2
mov $1,$0
pow $0,4
mul $0,$1
add $1,1
pow $1,10
div $1,$0
mov $0,$1
|
constants/battle_anim_constants.asm | Dev727/ancientplatinum | 28 | 170350 | <reponame>Dev727/ancientplatinum
; battle_anim_struct members (see macros/wram.asm)
const_def
const BATTLEANIMSTRUCT_INDEX
const BATTLEANIMSTRUCT_01
const BATTLEANIMSTRUCT_02
const BATTLEANIMSTRUCT_FRAMESET_ID
const BATTLEANIMSTRUCT_FUNCTION
const BATTLEANIMSTRUCT_PALETTE
const BATTLEANIMSTRUCT_TILEID
const BATTLEANIMSTRUCT_XCOORD
const BATTLEANIMSTRUCT_YCOORD
const BATTLEANIMSTRUCT_XOFFSET
const BATTLEANIMSTRUCT_YOFFSET
const BATTLEANIMSTRUCT_PARAM
const BATTLEANIMSTRUCT_DURATION
const BATTLEANIMSTRUCT_FRAME
const BATTLEANIMSTRUCT_ANON_JT_INDEX
const BATTLEANIMSTRUCT_0F
const BATTLEANIMSTRUCT_10
const BATTLEANIMSTRUCT_11
const BATTLEANIMSTRUCT_12
const BATTLEANIMSTRUCT_13
const BATTLEANIMSTRUCT_14
const BATTLEANIMSTRUCT_15
const BATTLEANIMSTRUCT_16
const BATTLEANIMSTRUCT_17
BATTLEANIMSTRUCT_LENGTH EQU const_value
NUM_ANIM_OBJECTS EQU 10 ; see wActiveAnimObjects
; Start tile for battle animation graphics
BATTLEANIM_BASE_TILE EQU 7 * 7 ; Maximum size of a pokemon picture
; BattleAnimObjects indexes (see data/battle_anims/objects.asm)
const_def
const ANIM_OBJ_00
const ANIM_OBJ_01
const ANIM_OBJ_02
const ANIM_OBJ_03
const ANIM_OBJ_04
const ANIM_OBJ_05
const ANIM_OBJ_06
const ANIM_OBJ_07
const ANIM_OBJ_08
const ANIM_OBJ_FANG
const ANIM_OBJ_0A
const ANIM_OBJ_EMBER
const ANIM_OBJ_DRAGON_RAGE
const ANIM_OBJ_FLAMETHROWER
const ANIM_OBJ_FIRE_SPIN
const ANIM_OBJ_FIRE_BLAST
const ANIM_OBJ_BURNED
const ANIM_OBJ_BLIZZARD
const ANIM_OBJ_12
const ANIM_OBJ_ICE_BEAM
const ANIM_OBJ_RAZOR_LEAF
const ANIM_OBJ_POKE_BALL
const ANIM_OBJ_POKE_BALL_BLOCKED
const ANIM_OBJ_17
const ANIM_OBJ_18
const ANIM_OBJ_19
const ANIM_OBJ_1A
const ANIM_OBJ_1B
const ANIM_OBJ_BALL_POOF
const ANIM_OBJ_BIG_ROCK
const ANIM_OBJ_SMALL_ROCK
const ANIM_OBJ_STRENGTH
const ANIM_OBJ_SEISMIC_TOSS
const ANIM_OBJ_BUBBLE
const ANIM_OBJ_SURF
const ANIM_OBJ_SING
const ANIM_OBJ_WATER_GUN
const ANIM_OBJ_HYDRO_PUMP
const ANIM_OBJ_POWDER
const ANIM_OBJ_27
const ANIM_OBJ_28
const ANIM_OBJ_ICE_BUILDUP
const ANIM_OBJ_FROZEN
const ANIM_OBJ_MASTER_BALL_SPARKLE
const ANIM_OBJ_RECOVER
const ANIM_OBJ_2D
const ANIM_OBJ_2E
const ANIM_OBJ_2F
const ANIM_OBJ_THUNDER_WAVE
const ANIM_OBJ_31
const ANIM_OBJ_LIGHTNING_BOLT
const ANIM_OBJ_33
const ANIM_OBJ_34
const ANIM_OBJ_CLAMP
const ANIM_OBJ_BITE
const ANIM_OBJ_37
const ANIM_OBJ_38
const ANIM_OBJ_39
const ANIM_OBJ_3A
const ANIM_OBJ_3B
const ANIM_OBJ_3C
const ANIM_OBJ_3D
const ANIM_OBJ_GUST
const ANIM_OBJ_3F
const ANIM_OBJ_40
const ANIM_OBJ_41
const ANIM_OBJ_42
const ANIM_OBJ_SONICBOOM_JP
const ANIM_OBJ_44
const ANIM_OBJ_ABSORB
const ANIM_OBJ_EGG
const ANIM_OBJ_47
const ANIM_OBJ_48
const ANIM_OBJ_49
const ANIM_OBJ_LEECH_SEED
const ANIM_OBJ_4B
const ANIM_OBJ_WAVE
const ANIM_OBJ_CONFUSE_RAY
const ANIM_OBJ_4E
const ANIM_OBJ_4F
const ANIM_OBJ_SCREEN
const ANIM_OBJ_HARDEN
const ANIM_OBJ_CHICK
const ANIM_OBJ_AMNESIA
const ANIM_OBJ_ASLEEP
const ANIM_OBJ_SKULL
const ANIM_OBJ_56
const ANIM_OBJ_57
const ANIM_OBJ_58
const ANIM_OBJ_PARALYZED
const ANIM_OBJ_STRING_SHOT
const ANIM_OBJ_HAZE
const ANIM_OBJ_MIST
const ANIM_OBJ_SMOG
const ANIM_OBJ_POISON_GAS
const ANIM_OBJ_HORN
const ANIM_OBJ_60
const ANIM_OBJ_PETAL_DANCE
const ANIM_OBJ_SLUDGE_BOMB
const ANIM_OBJ_PAY_DAY
const ANIM_OBJ_64
const ANIM_OBJ_MIMIC
const ANIM_OBJ_ATTRACT
const ANIM_OBJ_BONEMERANG
const ANIM_OBJ_BONE_CLUB
const ANIM_OBJ_BONE_RUSH
const ANIM_OBJ_SWIFT
const ANIM_OBJ_KINESIS
const ANIM_OBJ_FLASH
const ANIM_OBJ_SHINY
const ANIM_OBJ_SKY_ATTACK
const ANIM_OBJ_LICK
const ANIM_OBJ_WITHDRAW
const ANIM_OBJ_71
const ANIM_OBJ_GROWTH
const ANIM_OBJ_CONVERSION2
const ANIM_OBJ_SMOKE
const ANIM_OBJ_SMOKESCREEN
const ANIM_OBJ_SWORDS_DANCE
const ANIM_OBJ_SPEED_LINE
const ANIM_OBJ_SHARPEN
const ANIM_OBJ_DEFENSE_CURL
const ANIM_OBJ_7A
const ANIM_OBJ_7B
const ANIM_OBJ_DISABLE
const ANIM_OBJ_AGILITY
const ANIM_OBJ_HEART
const ANIM_OBJ_FLAME_WHEEL
const ANIM_OBJ_SACRED_FIRE
const ANIM_OBJ_COTTON_SPORE
const ANIM_OBJ_MILK_DRINK
const ANIM_OBJ_ANGER
const ANIM_OBJ_84
const ANIM_OBJ_85
const ANIM_OBJ_BATON_PASS
const ANIM_OBJ_LOCK_ON
const ANIM_OBJ_MIND_READER
const ANIM_OBJ_SAFEGUARD
const ANIM_OBJ_PROTECT
const ANIM_OBJ_THIEF
const ANIM_OBJ_OCTAZOOKA
const ANIM_OBJ_PRESENT
const ANIM_OBJ_SPIKES
const ANIM_OBJ_POWDER_SNOW
const ANIM_OBJ_DRAGONBREATH
const ANIM_OBJ_CONVERSION
const ANIM_OBJ_SPIDER_WEB
const ANIM_OBJ_93
const ANIM_OBJ_NIGHTMARE
const ANIM_OBJ_IN_NIGHTMARE
const ANIM_OBJ_LOVELY_KISS
const ANIM_OBJ_SWEET_KISS
const ANIM_OBJ_SKETCH
const ANIM_OBJ_99
const ANIM_OBJ_9A
const ANIM_OBJ_DESTINY_BOND
const ANIM_OBJ_MORNING_SUN
const ANIM_OBJ_GLIMMER
const ANIM_OBJ_MOONLIGHT
const ANIM_OBJ_HIDDEN_POWER
const ANIM_OBJ_A0
const ANIM_OBJ_A1
const ANIM_OBJ_SANDSTORM
const ANIM_OBJ_ZAP_CANNON
const ANIM_OBJ_SPITE
const ANIM_OBJ_CURSE
const ANIM_OBJ_PERISH_SONG
const ANIM_OBJ_FORESIGHT
const ANIM_OBJ_RAPID_SPIN
const ANIM_OBJ_SWAGGER
const ANIM_OBJ_AA
const ANIM_OBJ_AB
const ANIM_OBJ_MEAN_LOOK
const ANIM_OBJ_AD
const ANIM_OBJ_AE
const ANIM_OBJ_RAIN
const ANIM_OBJ_B0
const ANIM_OBJ_PSYCH_UP
const ANIM_OBJ_ANCIENTPOWER
const ANIM_OBJ_AEROBLAST
const ANIM_OBJ_SHADOW_BALL
const ANIM_OBJ_ROCK_SMASH
const ANIM_OBJ_FLOWER
const ANIM_OBJ_COTTON
const ANIM_OBJ_ENEMYFEET_1ROW
const ANIM_OBJ_PLAYERHEAD_1ROW
const ANIM_OBJ_ENEMYFEET_2ROW
const ANIM_OBJ_PLAYERHEAD_2ROW
; DoBattleAnimFrame arguments (see engine/battle_anims/functions.asm)
const_def
const BATTLEANIMFUNC_00
const BATTLEANIMFUNC_01
const BATTLEANIMFUNC_02
const BATTLEANIMFUNC_03
const BATTLEANIMFUNC_04
const BATTLEANIMFUNC_05
const BATTLEANIMFUNC_06
const BATTLEANIMFUNC_07
const BATTLEANIMFUNC_08
const BATTLEANIMFUNC_09
const BATTLEANIMFUNC_0A
const BATTLEANIMFUNC_RAZOR_LEAF
const BATTLEANIMFUNC_0C
const BATTLEANIMFUNC_0D
const BATTLEANIMFUNC_0E
const BATTLEANIMFUNC_0F
const BATTLEANIMFUNC_10
const BATTLEANIMFUNC_11
const BATTLEANIMFUNC_12
const BATTLEANIMFUNC_13
const BATTLEANIMFUNC_14
const BATTLEANIMFUNC_15
const BATTLEANIMFUNC_16
const BATTLEANIMFUNC_17
const BATTLEANIMFUNC_18
const BATTLEANIMFUNC_19
const BATTLEANIMFUNC_1A
const BATTLEANIMFUNC_1B
const BATTLEANIMFUNC_1C
const BATTLEANIMFUNC_1D
const BATTLEANIMFUNC_1E
const BATTLEANIMFUNC_1F
const BATTLEANIMFUNC_LEECH_SEED
const BATTLEANIMFUNC_21
const BATTLEANIMFUNC_22
const BATTLEANIMFUNC_23
const BATTLEANIMFUNC_24
const BATTLEANIMFUNC_25
const BATTLEANIMFUNC_26
const BATTLEANIMFUNC_27
const BATTLEANIMFUNC_28
const BATTLEANIMFUNC_SPRIAL_DESCENT
const BATTLEANIMFUNC_POISON_GAS
const BATTLEANIMFUNC_HORN
const BATTLEANIMFUNC_2C
const BATTLEANIMFUNC_2D
const BATTLEANIMFUNC_2E
const BATTLEANIMFUNC_2F
const BATTLEANIMFUNC_30
const BATTLEANIMFUNC_31
const BATTLEANIMFUNC_32
const BATTLEANIMFUNC_33
const BATTLEANIMFUNC_34
const BATTLEANIMFUNC_35
const BATTLEANIMFUNC_36
const BATTLEANIMFUNC_37
const BATTLEANIMFUNC_38
const BATTLEANIMFUNC_39
const BATTLEANIMFUNC_3A
const BATTLEANIMFUNC_3B
const BATTLEANIMFUNC_3C
const BATTLEANIMFUNC_3D
const BATTLEANIMFUNC_3E
const BATTLEANIMFUNC_3F
const BATTLEANIMFUNC_40
const BATTLEANIMFUNC_41
const BATTLEANIMFUNC_42
const BATTLEANIMFUNC_43
const BATTLEANIMFUNC_44
const BATTLEANIMFUNC_45
const BATTLEANIMFUNC_46
const BATTLEANIMFUNC_47
const BATTLEANIMFUNC_48
const BATTLEANIMFUNC_49
const BATTLEANIMFUNC_4A
const BATTLEANIMFUNC_4B
const BATTLEANIMFUNC_4C
const BATTLEANIMFUNC_4D
const BATTLEANIMFUNC_4E
const BATTLEANIMFUNC_4F
; BattleAnimFrameData indexes (see data/battle_anims/framesets.asm)
const_def
const BATTLEANIMFRAMESET_00
const BATTLEANIMFRAMESET_01
const BATTLEANIMFRAMESET_02
const BATTLEANIMFRAMESET_03
const BATTLEANIMFRAMESET_04
const BATTLEANIMFRAMESET_05
const BATTLEANIMFRAMESET_06
const BATTLEANIMFRAMESET_07
const BATTLEANIMFRAMESET_08
const BATTLEANIMFRAMESET_09
const BATTLEANIMFRAMESET_0A
const BATTLEANIMFRAMESET_0B
const BATTLEANIMFRAMESET_0C
const BATTLEANIMFRAMESET_0D
const BATTLEANIMFRAMESET_0E
const BATTLEANIMFRAMESET_0F
const BATTLEANIMFRAMESET_10
const BATTLEANIMFRAMESET_11
const BATTLEANIMFRAMESET_12
const BATTLEANIMFRAMESET_13
const BATTLEANIMFRAMESET_14
const BATTLEANIMFRAMESET_15
const BATTLEANIMFRAMESET_16
const BATTLEANIMFRAMESET_17
const BATTLEANIMFRAMESET_18
const BATTLEANIMFRAMESET_19
const BATTLEANIMFRAMESET_1A
const BATTLEANIMFRAMESET_1B
const BATTLEANIMFRAMESET_1C
const BATTLEANIMFRAMESET_1D
const BATTLEANIMFRAMESET_1E
const BATTLEANIMFRAMESET_1F
const BATTLEANIMFRAMESET_20
const BATTLEANIMFRAMESET_21
const BATTLEANIMFRAMESET_22
const BATTLEANIMFRAMESET_23
const BATTLEANIMFRAMESET_24
const BATTLEANIMFRAMESET_25
const BATTLEANIMFRAMESET_26
const BATTLEANIMFRAMESET_27
const BATTLEANIMFRAMESET_28
const BATTLEANIMFRAMESET_29
const BATTLEANIMFRAMESET_2A
const BATTLEANIMFRAMESET_2B
const BATTLEANIMFRAMESET_2C
const BATTLEANIMFRAMESET_2D
const BATTLEANIMFRAMESET_2E
const BATTLEANIMFRAMESET_2F
const BATTLEANIMFRAMESET_30
const BATTLEANIMFRAMESET_31
const BATTLEANIMFRAMESET_32
const BATTLEANIMFRAMESET_33
const BATTLEANIMFRAMESET_34
const BATTLEANIMFRAMESET_35
const BATTLEANIMFRAMESET_36
const BATTLEANIMFRAMESET_37
const BATTLEANIMFRAMESET_38
const BATTLEANIMFRAMESET_39
const BATTLEANIMFRAMESET_3A
const BATTLEANIMFRAMESET_3B
const BATTLEANIMFRAMESET_3C
const BATTLEANIMFRAMESET_3D
const BATTLEANIMFRAMESET_3E
const BATTLEANIMFRAMESET_3F
const BATTLEANIMFRAMESET_40
const BATTLEANIMFRAMESET_41
const BATTLEANIMFRAMESET_42
const BATTLEANIMFRAMESET_43
const BATTLEANIMFRAMESET_44
const BATTLEANIMFRAMESET_45
const BATTLEANIMFRAMESET_46
const BATTLEANIMFRAMESET_47
const BATTLEANIMFRAMESET_48
const BATTLEANIMFRAMESET_49
const BATTLEANIMFRAMESET_4A
const BATTLEANIMFRAMESET_4B
const BATTLEANIMFRAMESET_4C
const BATTLEANIMFRAMESET_4D
const BATTLEANIMFRAMESET_4E
const BATTLEANIMFRAMESET_4F
const BATTLEANIMFRAMESET_50
const BATTLEANIMFRAMESET_51
const BATTLEANIMFRAMESET_52
const BATTLEANIMFRAMESET_53
const BATTLEANIMFRAMESET_54
const BATTLEANIMFRAMESET_55
const BATTLEANIMFRAMESET_56
const BATTLEANIMFRAMESET_57
const BATTLEANIMFRAMESET_58
const BATTLEANIMFRAMESET_59
const BATTLEANIMFRAMESET_5A
const BATTLEANIMFRAMESET_5B
const BATTLEANIMFRAMESET_5C
const BATTLEANIMFRAMESET_5D
const BATTLEANIMFRAMESET_5E
const BATTLEANIMFRAMESET_5F
const BATTLEANIMFRAMESET_60
const BATTLEANIMFRAMESET_61
const BATTLEANIMFRAMESET_62
const BATTLEANIMFRAMESET_63
const BATTLEANIMFRAMESET_64
const BATTLEANIMFRAMESET_65
const BATTLEANIMFRAMESET_66
const BATTLEANIMFRAMESET_67
const BATTLEANIMFRAMESET_68
const BATTLEANIMFRAMESET_69
const BATTLEANIMFRAMESET_6A
const BATTLEANIMFRAMESET_6B
const BATTLEANIMFRAMESET_6C
const BATTLEANIMFRAMESET_6D
const BATTLEANIMFRAMESET_6E
const BATTLEANIMFRAMESET_6F
const BATTLEANIMFRAMESET_70
const BATTLEANIMFRAMESET_71
const BATTLEANIMFRAMESET_72
const BATTLEANIMFRAMESET_73
const BATTLEANIMFRAMESET_74
const BATTLEANIMFRAMESET_75
const BATTLEANIMFRAMESET_76
const BATTLEANIMFRAMESET_77
const BATTLEANIMFRAMESET_78
const BATTLEANIMFRAMESET_79
const BATTLEANIMFRAMESET_7A
const BATTLEANIMFRAMESET_7B
const BATTLEANIMFRAMESET_7C
const BATTLEANIMFRAMESET_7D
const BATTLEANIMFRAMESET_7E
const BATTLEANIMFRAMESET_7F
const BATTLEANIMFRAMESET_80
const BATTLEANIMFRAMESET_81
const BATTLEANIMFRAMESET_82
const BATTLEANIMFRAMESET_83
const BATTLEANIMFRAMESET_84
const BATTLEANIMFRAMESET_85
const BATTLEANIMFRAMESET_86
const BATTLEANIMFRAMESET_87
const BATTLEANIMFRAMESET_88
const BATTLEANIMFRAMESET_89
const BATTLEANIMFRAMESET_8A
const BATTLEANIMFRAMESET_8B
const BATTLEANIMFRAMESET_8C
const BATTLEANIMFRAMESET_8D
const BATTLEANIMFRAMESET_8E
const BATTLEANIMFRAMESET_8F
const BATTLEANIMFRAMESET_90
const BATTLEANIMFRAMESET_91
const BATTLEANIMFRAMESET_92
const BATTLEANIMFRAMESET_93
const BATTLEANIMFRAMESET_94
const BATTLEANIMFRAMESET_95
const BATTLEANIMFRAMESET_96
const BATTLEANIMFRAMESET_97
const BATTLEANIMFRAMESET_98
const BATTLEANIMFRAMESET_99
const BATTLEANIMFRAMESET_9A
const BATTLEANIMFRAMESET_9B
const BATTLEANIMFRAMESET_9C
const BATTLEANIMFRAMESET_9D
const BATTLEANIMFRAMESET_9E
const BATTLEANIMFRAMESET_9F
const BATTLEANIMFRAMESET_A0
const BATTLEANIMFRAMESET_A1
const BATTLEANIMFRAMESET_A2
const BATTLEANIMFRAMESET_A3
const BATTLEANIMFRAMESET_A4
const BATTLEANIMFRAMESET_A5
const BATTLEANIMFRAMESET_A6
const BATTLEANIMFRAMESET_A7
const BATTLEANIMFRAMESET_A8
const BATTLEANIMFRAMESET_A9
const BATTLEANIMFRAMESET_AA
const BATTLEANIMFRAMESET_AB
const BATTLEANIMFRAMESET_AC
const BATTLEANIMFRAMESET_AD
const BATTLEANIMFRAMESET_AE
const BATTLEANIMFRAMESET_AF
const BATTLEANIMFRAMESET_B0
const BATTLEANIMFRAMESET_B1
const BATTLEANIMFRAMESET_B2
const BATTLEANIMFRAMESET_B3
const BATTLEANIMFRAMESET_B4
const BATTLEANIMFRAMESET_B5
const BATTLEANIMFRAMESET_B6
const BATTLEANIMFRAMESET_B7
const BATTLEANIMFRAMESET_B8
; BattleAnimOAMData indexes (see data/battle_anims/oam.asm)
const_def
const BATTLEANIMOAMSET_00
const BATTLEANIMOAMSET_01
const BATTLEANIMOAMSET_02
const BATTLEANIMOAMSET_03
const BATTLEANIMOAMSET_04
const BATTLEANIMOAMSET_05
const BATTLEANIMOAMSET_06
const BATTLEANIMOAMSET_07
const BATTLEANIMOAMSET_08
const BATTLEANIMOAMSET_09
const BATTLEANIMOAMSET_0A
const BATTLEANIMOAMSET_0B
const BATTLEANIMOAMSET_0C
const BATTLEANIMOAMSET_0D
const BATTLEANIMOAMSET_0E
const BATTLEANIMOAMSET_0F
const BATTLEANIMOAMSET_10
const BATTLEANIMOAMSET_11
const BATTLEANIMOAMSET_12
const BATTLEANIMOAMSET_13
const BATTLEANIMOAMSET_14
const BATTLEANIMOAMSET_15
const BATTLEANIMOAMSET_16
const BATTLEANIMOAMSET_17
const BATTLEANIMOAMSET_18
const BATTLEANIMOAMSET_19
const BATTLEANIMOAMSET_1A
const BATTLEANIMOAMSET_1B
const BATTLEANIMOAMSET_1C
const BATTLEANIMOAMSET_1D
const BATTLEANIMOAMSET_1E
const BATTLEANIMOAMSET_1F
const BATTLEANIMOAMSET_20
const BATTLEANIMOAMSET_21
const BATTLEANIMOAMSET_22
const BATTLEANIMOAMSET_23
const BATTLEANIMOAMSET_24
const BATTLEANIMOAMSET_25
const BATTLEANIMOAMSET_26
const BATTLEANIMOAMSET_27
const BATTLEANIMOAMSET_28
const BATTLEANIMOAMSET_29
const BATTLEANIMOAMSET_2A
const BATTLEANIMOAMSET_2B
const BATTLEANIMOAMSET_2C
const BATTLEANIMOAMSET_2D
const BATTLEANIMOAMSET_2E
const BATTLEANIMOAMSET_2F
const BATTLEANIMOAMSET_30
const BATTLEANIMOAMSET_31
const BATTLEANIMOAMSET_32
const BATTLEANIMOAMSET_33
const BATTLEANIMOAMSET_34
const BATTLEANIMOAMSET_35
const BATTLEANIMOAMSET_36
const BATTLEANIMOAMSET_37
const BATTLEANIMOAMSET_38
const BATTLEANIMOAMSET_39
const BATTLEANIMOAMSET_3A
const BATTLEANIMOAMSET_3B
const BATTLEANIMOAMSET_3C
const BATTLEANIMOAMSET_3D
const BATTLEANIMOAMSET_3E
const BATTLEANIMOAMSET_3F
const BATTLEANIMOAMSET_40
const BATTLEANIMOAMSET_41
const BATTLEANIMOAMSET_42
const BATTLEANIMOAMSET_43
const BATTLEANIMOAMSET_44
const BATTLEANIMOAMSET_45
const BATTLEANIMOAMSET_46
const BATTLEANIMOAMSET_47
const BATTLEANIMOAMSET_48
const BATTLEANIMOAMSET_49
const BATTLEANIMOAMSET_4A
const BATTLEANIMOAMSET_4B
const BATTLEANIMOAMSET_4C
const BATTLEANIMOAMSET_4D
const BATTLEANIMOAMSET_4E
const BATTLEANIMOAMSET_4F
const BATTLEANIMOAMSET_50
const BATTLEANIMOAMSET_51
const BATTLEANIMOAMSET_52
const BATTLEANIMOAMSET_53
const BATTLEANIMOAMSET_54
const BATTLEANIMOAMSET_55
const BATTLEANIMOAMSET_56
const BATTLEANIMOAMSET_57
const BATTLEANIMOAMSET_58
const BATTLEANIMOAMSET_59
const BATTLEANIMOAMSET_5A
const BATTLEANIMOAMSET_5B
const BATTLEANIMOAMSET_5C
const BATTLEANIMOAMSET_5D
const BATTLEANIMOAMSET_5E
const BATTLEANIMOAMSET_5F
const BATTLEANIMOAMSET_60
const BATTLEANIMOAMSET_61
const BATTLEANIMOAMSET_62
const BATTLEANIMOAMSET_63
const BATTLEANIMOAMSET_64
const BATTLEANIMOAMSET_65
const BATTLEANIMOAMSET_66
const BATTLEANIMOAMSET_67
const BATTLEANIMOAMSET_68
const BATTLEANIMOAMSET_69
const BATTLEANIMOAMSET_6A
const BATTLEANIMOAMSET_6B
const BATTLEANIMOAMSET_6C
const BATTLEANIMOAMSET_6D
const BATTLEANIMOAMSET_6E
const BATTLEANIMOAMSET_6F
const BATTLEANIMOAMSET_70
const BATTLEANIMOAMSET_71
const BATTLEANIMOAMSET_72
const BATTLEANIMOAMSET_73
const BATTLEANIMOAMSET_74
const BATTLEANIMOAMSET_75
const BATTLEANIMOAMSET_76
const BATTLEANIMOAMSET_77
const BATTLEANIMOAMSET_78
const BATTLEANIMOAMSET_79
const BATTLEANIMOAMSET_7A
const BATTLEANIMOAMSET_7B
const BATTLEANIMOAMSET_7C
const BATTLEANIMOAMSET_7D
const BATTLEANIMOAMSET_7E
const BATTLEANIMOAMSET_7F
const BATTLEANIMOAMSET_80
const BATTLEANIMOAMSET_81
const BATTLEANIMOAMSET_82
const BATTLEANIMOAMSET_83
const BATTLEANIMOAMSET_84
const BATTLEANIMOAMSET_85
const BATTLEANIMOAMSET_86
const BATTLEANIMOAMSET_87
const BATTLEANIMOAMSET_88
const BATTLEANIMOAMSET_89
const BATTLEANIMOAMSET_8A
const BATTLEANIMOAMSET_8B
const BATTLEANIMOAMSET_8C
const BATTLEANIMOAMSET_8D
const BATTLEANIMOAMSET_8E
const BATTLEANIMOAMSET_8F
const BATTLEANIMOAMSET_90
const BATTLEANIMOAMSET_91
const BATTLEANIMOAMSET_92
const BATTLEANIMOAMSET_93
const BATTLEANIMOAMSET_94
const BATTLEANIMOAMSET_95
const BATTLEANIMOAMSET_96
const BATTLEANIMOAMSET_97
const BATTLEANIMOAMSET_98
const BATTLEANIMOAMSET_99
const BATTLEANIMOAMSET_9A
const BATTLEANIMOAMSET_9B
const BATTLEANIMOAMSET_9C
const BATTLEANIMOAMSET_9D
const BATTLEANIMOAMSET_9E
const BATTLEANIMOAMSET_9F
const BATTLEANIMOAMSET_A0
const BATTLEANIMOAMSET_A1
const BATTLEANIMOAMSET_A2
const BATTLEANIMOAMSET_A3
const BATTLEANIMOAMSET_A4
const BATTLEANIMOAMSET_A5
const BATTLEANIMOAMSET_A6
const BATTLEANIMOAMSET_A7
const BATTLEANIMOAMSET_A8
const BATTLEANIMOAMSET_A9
const BATTLEANIMOAMSET_AA
const BATTLEANIMOAMSET_AB
const BATTLEANIMOAMSET_AC
const BATTLEANIMOAMSET_AD
const BATTLEANIMOAMSET_AE
const BATTLEANIMOAMSET_AF
const BATTLEANIMOAMSET_B0
const BATTLEANIMOAMSET_B1
const BATTLEANIMOAMSET_B2
const BATTLEANIMOAMSET_B3
const BATTLEANIMOAMSET_B4
const BATTLEANIMOAMSET_B5
const BATTLEANIMOAMSET_B6
const BATTLEANIMOAMSET_B7
const BATTLEANIMOAMSET_B8
const BATTLEANIMOAMSET_B9
const BATTLEANIMOAMSET_BA
const BATTLEANIMOAMSET_BB
const BATTLEANIMOAMSET_BC
const BATTLEANIMOAMSET_BD
const BATTLEANIMOAMSET_BE
const BATTLEANIMOAMSET_BF
const BATTLEANIMOAMSET_C0
const BATTLEANIMOAMSET_C1
const BATTLEANIMOAMSET_C2
const BATTLEANIMOAMSET_C3
const BATTLEANIMOAMSET_C4
const BATTLEANIMOAMSET_C5
const BATTLEANIMOAMSET_C6
const BATTLEANIMOAMSET_C7
const BATTLEANIMOAMSET_C8
const BATTLEANIMOAMSET_C9
const BATTLEANIMOAMSET_CA
const BATTLEANIMOAMSET_CB
const BATTLEANIMOAMSET_CC
const BATTLEANIMOAMSET_CD
const BATTLEANIMOAMSET_CE
const BATTLEANIMOAMSET_CF
const BATTLEANIMOAMSET_D0
const BATTLEANIMOAMSET_D1
const BATTLEANIMOAMSET_D2
const BATTLEANIMOAMSET_D3
const BATTLEANIMOAMSET_D4
const BATTLEANIMOAMSET_D5
const BATTLEANIMOAMSET_D6
const BATTLEANIMOAMSET_D7
; BattleBGEffects indexes (see engine/battle_anims/bg_effects.asm)
const_def 1
const ANIM_BG_FLASH_INVERTED
const ANIM_BG_FLASH_WHITE
const ANIM_BG_WHITE_HUES
const ANIM_BG_BLACK_HUES
const ANIM_BG_ALTERNATE_HUES
const ANIM_BG_06
const ANIM_BG_07
const ANIM_BG_08
const ANIM_BG_HIDE_MON
const ANIM_BG_SHOW_MON
const ANIM_BG_ENTER_MON
const ANIM_BG_RETURN_MON
const ANIM_BG_SURF
const ANIM_BG_WHIRLPOOL
const ANIM_BG_TELEPORT
const ANIM_BG_NIGHT_SHADE
const ANIM_BG_BATTLEROBJ_1ROW
const ANIM_BG_BATTLEROBJ_2ROW
const ANIM_BG_DOUBLE_TEAM
const ANIM_BG_ACID_ARMOR
const ANIM_BG_RAPID_FLASH
const ANIM_BG_16
const ANIM_BG_17
const ANIM_BG_18
const ANIM_BG_19
const ANIM_BG_1A
const ANIM_BG_1B
const ANIM_BG_1C
const ANIM_BG_1D
const ANIM_BG_1E
const ANIM_BG_1F
const ANIM_BG_20
const ANIM_BG_WITHDRAW
const ANIM_BG_BOUNCE_DOWN
const ANIM_BG_DIG
const ANIM_BG_TACKLE
const ANIM_BG_25
const ANIM_BG_26
const ANIM_BG_27
const ANIM_BG_WAVE_DEFORM_USER
const ANIM_BG_PSYCHIC
const ANIM_BG_2A
const ANIM_BG_2B
const ANIM_BG_2C
const ANIM_BG_2D
const ANIM_BG_2E
const ANIM_BG_2F
const ANIM_BG_30
const ANIM_BG_31
const ANIM_BG_32
const ANIM_BG_VIBRATE_MON
const ANIM_BG_WOBBLE_MON
const ANIM_BG_35
; AnimObjGFX indexes (see data/battle_anims/object_gfx.asm)
const_def 1
const ANIM_GFX_HIT
const ANIM_GFX_CUT
const ANIM_GFX_FIRE
const ANIM_GFX_WATER
const ANIM_GFX_LIGHTNING
const ANIM_GFX_PLANT
const ANIM_GFX_SMOKE
const ANIM_GFX_EXPLOSION
const ANIM_GFX_ROCKS
const ANIM_GFX_ICE
const ANIM_GFX_POKE_BALL
const ANIM_GFX_POISON
const ANIM_GFX_BUBBLE
const ANIM_GFX_NOISE
const ANIM_GFX_POWDER
const ANIM_GFX_BEAM
const ANIM_GFX_SPEED
const ANIM_GFX_CHARGE
const ANIM_GFX_WIND
const ANIM_GFX_WHIP
const ANIM_GFX_EGG
const ANIM_GFX_ROPE
const ANIM_GFX_PSYCHIC
const ANIM_GFX_REFLECT
const ANIM_GFX_STATUS
const ANIM_GFX_SAND
const ANIM_GFX_WEB
const ANIM_GFX_HAZE
const ANIM_GFX_HORN
const ANIM_GFX_FLOWER
const ANIM_GFX_MISC
const ANIM_GFX_SKY_ATTACK
const ANIM_GFX_GLOBE
const ANIM_GFX_SHAPES
const ANIM_GFX_OBJECTS
const ANIM_GFX_SHINE
const ANIM_GFX_ANGELS
const ANIM_GFX_WAVE
const ANIM_GFX_AEROBLAST
const ANIM_GFX_PLAYERHEAD
const ANIM_GFX_ENEMYFEET
; battle_bg_effect struct members (see macros/wram.asm)
const_def
const BG_EFFECT_STRUCT_FUNCTION
const BG_EFFECT_STRUCT_JT_INDEX
const BG_EFFECT_STRUCT_BATTLE_TURN
const BG_EFFECT_STRUCT_03
BG_EFFECT_STRUCT_LENGTH EQU const_value
NUM_BG_EFFECTS EQU 5 ; see wActiveBGEffects
; battle palettes
const_def
const PAL_BATTLE_BG_PLAYER ; 0
const PAL_BATTLE_BG_ENEMY ; 1
const PAL_BATTLE_BG_ENEMY_HP ; 2
const PAL_BATTLE_BG_PLAYER_HP ; 3
const PAL_BATTLE_BG_EXP ; 4
const PAL_BATTLE_BG_5 ; 5
const PAL_BATTLE_BG_6 ; 6
const PAL_BATTLE_BG_TEXT ; 7
; animation object palettes
const_def
const PAL_BATTLE_OB_ENEMY ; 0
const PAL_BATTLE_OB_PLAYER ; 1
const PAL_BATTLE_OB_GRAY ; 2
const PAL_BATTLE_OB_YELLOW ; 3
const PAL_BATTLE_OB_RED ; 4
const PAL_BATTLE_OB_GREEN ; 5
const PAL_BATTLE_OB_BLUE ; 6
const PAL_BATTLE_OB_BROWN ; 7
|
programs/oeis/215/A215229.asm | karttu/loda | 0 | 3927 | <filename>programs/oeis/215/A215229.asm
; A215229: Number of length-6 0..k arrays connected end-around, with no sequence of L<n elements immediately followed by itself (periodic "squarefree").
; 0,18,408,2940,12600,40110,105168,240408,496080,945450,1690920,2870868,4667208,7313670,11104800,16405680,23662368,33413058,46299960,63081900,84647640,112029918,146420208,189184200,241878000,306265050,384333768,478315908,590705640,724279350,882116160,1067619168,1284537408,1536988530,1829482200,2166944220,2554741368,2998706958,3505167120,4080967800,4733502480,5470740618,6301256808,7234260660,8279627400,9447929190,10750467168,12199304208,13807298400,15588137250,17556372600,19727456268,22117776408,24744694590,27626583600,30782865960,34234053168,38001785658,42108873480,46579337700,51438452520,56712788118,62430254208,68620144320,75313180800,82541560530,90339001368,98740789308,107783826360,117506679150,127949628240,139154718168,151165808208,164028623850,177790809000,192501978900,208213773768,224979913158,242856251040,261900831600,282173945760,303738188418,326658516408,351002307180,376839418200,404242247070,433285792368,464047715208,496608401520,531051025050,567461611080,605929100868,646545416808,689405528310,734607518400,782252651040,832445439168,885293713458,940908691800,999405049500,1060900990200,1125518317518,1193382507408,1264622781240,1339372179600,1417767636810,1499950056168,1586064385908,1676259695880,1770689254950,1869510609120,1972885660368,2080980746208,2193966719970,2312019031800,2435317810380,2564047945368,2698399170558,2838566147760,2984748551400,3137151153840,3295983911418,3461462051208,3633806158500,3813242265000,4000001937750,4194322368768,4396446465408,4606622941440,4825106408850,5052157470360,5288042812668,5533035300408,5787414070830,6051464629200,6325478944920,6609755548368,6904599628458,7210323130920,7527244857300,7855690564680,8195993066118,8548492331808,8913535590960,9291477434400,9682679917890,10087512666168,10506352977708,10939585930200,11387604486750,11850809602800,12329610333768,12824423943408,13335676012890,13863800550600,14409240102660,14972445864168,15553877791158,16154004713280,16773304447200,17412263910720,18071379237618,18751155893208,19452108790620,20174762407800,20919650905230,21687318244368,22478318306808,23293215014160,24132582448650,24997004974440,25887077359668,26803404899208,27746603538150,28717299996000,29716131891600,30743747868768,31800807722658,32887982526840,34005954761100,35155418439960,36337079241918,37551654639408,38799874029480,40082478865200,41400222787770,42753871759368,44144204196708,45572011105320,47038096214550,48543276113280,50088380386368,51674251751808,53301746198610,54971733125400,56685095479740,58442729898168,60245546846958,62094470763600,63990440199000,65934407960400,67927341255018,69970221834408,72064046139540,74209825446600,76408586013510,78661369227168,80969231751408,83333245675680,85754498664450
mov $2,$0
sub $2,1
mov $7,$0
lpb $0,1
lpb $0,1
sub $0,1
add $4,$2
lpe
sub $2,1
lpb $4,1
add $1,$2
sub $4,1
lpe
lpe
mov $5,$7
mov $8,$7
lpb $5,1
sub $5,1
add $6,$8
lpe
mov $3,2
mov $8,$6
lpb $3,1
add $1,$8
sub $3,1
lpe
mov $5,$7
mov $6,0
lpb $5,1
sub $5,1
add $6,$8
lpe
mov $5,$7
mov $8,$6
mov $6,0
lpb $5,1
sub $5,1
add $6,$8
lpe
mov $3,9
mov $8,$6
lpb $3,1
add $1,$8
sub $3,1
lpe
mov $5,$7
mov $6,0
lpb $5,1
sub $5,1
add $6,$8
lpe
mov $3,6
mov $8,$6
lpb $3,1
add $1,$8
sub $3,1
lpe
mov $5,$7
mov $6,0
lpb $5,1
sub $5,1
add $6,$8
lpe
mov $3,1
mov $8,$6
lpb $3,1
add $1,$8
sub $3,1
lpe
|
agda/DsubReduced.agda | HuStmpHrrr/popl20-artifact | 1 | 7595 | {-# OPTIONS --without-K --safe #-}
-- This module defines an intermediate calculus that is set up in the D<: universe
-- which bridges F<:- and D<:. The goal here is purely technical - to simply reduce
-- duplication.
module DsubReduced where
open import Data.List as List
open import Data.List.All as All
open import Data.Nat as ℕ
open import Data.Maybe as Maybe
open import Data.Product
open import Function
open import Data.Maybe.Properties as Maybeₚ
open import Data.Nat.Properties as ℕₚ
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality as ≡
open import DsubDef
open import FsubMinus
open import FsubMinus2
open import Utils
-- D<: Reduced
--
-- This judgment for contexts and types in D<: defines a corresponding calculus after
-- interpreting F<:⁻ into D<:. That is, D<: reduced is the image derivation of
-- interpreting F<:⁻ in D<:.
infix 4 _⊢ᵣ_<:_
data _⊢ᵣ_<:_ : Env → Typ → Typ → Set where
drtop : ∀ {Γ T} → Covar T → Γ ⊢ᵣ T <: ⊤
drrefl : ∀ {Γ T} → Covar T → Γ ⊢ᵣ T <: T
drall : ∀ {Γ S U S′ U′} →
Covar S → Covar U → Covar S′ → Covar U′ →
(S′<:S : Γ ⊢ᵣ S′ <: S) →
(U<:U′ : ⟨A: ⊥ ⋯ S′ ⟩ ∷ Γ ⊢ᵣ U <: U′) →
Γ ⊢ᵣ Π ⟨A: ⊥ ⋯ S ⟩ ∙ U <: Π ⟨A: ⊥ ⋯ S′ ⟩ ∙ U′
drsel : ∀ {Γ n U U′} →
(T∈Γ : env-lookup Γ n ≡ just ⟨A: ⊥ ⋯ U ⟩) →
Covar U →
Γ ⊢ᵣ U <: U′ →
Γ ⊢ᵣ n ∙A <: U′
module FsubMinusToDsubR where
open FsubMinus.FsubMinus renaming (Env to Env′ ; _↑_ to _⇑_) hiding (env-lookup)
infix 5 ⟦_⟧ ⟪_⟫
⟦_⟧ : Ftyp → Typ
⟦ ⊤ ⟧ = ⊤
⟦ var x ⟧ = x ∙A
⟦ Π<: S ∙ U ⟧ = Π ⟨A: ⊥ ⋯ ⟦ S ⟧ ⟩ ∙ ⟦ U ⟧
⟪_⟫ : Env′ → Env
⟪ [] ⟫ = []
⟪ T ∷ Γ ⟫ = ⟨A: ⊥ ⋯ ⟦ T ⟧ ⟩ ∷ ⟪ Γ ⟫
module ⟦⟧-Bijective where
open import Function.Bijection
open import Function.Surjection
open import Function.Equality
CovTyp : Set
CovTyp = ∃ λ T → Covar T
⟦⟧-covar : ∀ T → Covar ⟦ T ⟧
⟦⟧-covar ⊤ = cv⊤
⟦⟧-covar (var x) = cv∙A _
⟦⟧-covar (Π<: S ∙ U) = cvΠ (⟦⟧-covar S) (⟦⟧-covar U)
⟦⟧-func : ≡.setoid Ftyp ⟶ ≡.setoid CovTyp
⟦⟧-func = record
{ _⟨$⟩_ = < ⟦_⟧ , ⟦⟧-covar >
; cong = ≡.cong < ⟦_⟧ , ⟦⟧-covar >
}
⟦⟧-injective : ∀ {S U} → ⟦ S ⟧ ≡ ⟦ U ⟧ → S ≡ U
⟦⟧-injective {⊤} {⊤} eq = refl
⟦⟧-injective {⊤} {var x} ()
⟦⟧-injective {⊤} {Π<: _ ∙ _} ()
⟦⟧-injective {var x} {⊤} ()
⟦⟧-injective {var x} {var .x} refl = refl
⟦⟧-injective {var x} {Π<: _ ∙ _} ()
⟦⟧-injective {Π<: _ ∙ _} {⊤} ()
⟦⟧-injective {Π<: _ ∙ _} {var x} ()
⟦⟧-injective {Π<: S₁ ∙ U₁} {Π<: S₂ ∙ U₂} eq
with ⟦ S₁ ⟧ | ⟦ S₂ ⟧ | ⟦ U₁ ⟧ | ⟦ U₂ ⟧
| ⟦⟧-injective {S₁} {S₂} | ⟦⟧-injective {U₁} {U₂}
⟦⟧-injective {Π<: S₁ ∙ U₁} {Π<: S₂ ∙ U₂} refl
| _ | _ | _ | _ | rec₁ | rec₂ = ≡.cong₂ Π<:_∙_ (rec₁ refl) (rec₂ refl)
⟦⟧-func-injective : ∀ {S U} → (CovTyp ∋ (⟦ S ⟧ , ⟦⟧-covar S)) ≡ (⟦ U ⟧ , ⟦⟧-covar U) → S ≡ U
⟦⟧-func-injective {S} {U} eq
with ⟦ S ⟧ | ⟦⟧-covar S | ⟦ U ⟧ | ⟦⟧-covar U
| ⟦⟧-injective {S} {U}
⟦⟧-func-injective {S} {U} refl
| _ | _ | _ | _ | inj = inj refl
infix 5 ⟦_⟧⁻¹
⟦_⟧⁻¹ : CovTyp → Ftyp
⟦ _ , cv⊤ ⟧⁻¹ = ⊤
⟦ _ , cv∙A x ⟧⁻¹ = var x
⟦ _ , cvΠ S U ⟧⁻¹ = Π<: ⟦ -, S ⟧⁻¹ ∙ ⟦ -, U ⟧⁻¹
⟦⟧-func-inv : ≡.setoid CovTyp ⟶ ≡.setoid Ftyp
⟦⟧-func-inv = record
{ _⟨$⟩_ = ⟦_⟧⁻¹
; cong = ≡.cong ⟦_⟧⁻¹
}
⟦⟧-left-inverse-⟦⟧⁻¹ : ∀ {T} (cT : Covar T) → (⟦ ⟦ -, cT ⟧⁻¹ ⟧ , ⟦⟧-covar ⟦ -, cT ⟧⁻¹) ≡ (CovTyp ∋ (-, cT))
⟦⟧-left-inverse-⟦⟧⁻¹ cv⊤ = refl
⟦⟧-left-inverse-⟦⟧⁻¹ (cv∙A n) = refl
⟦⟧-left-inverse-⟦⟧⁻¹ (cvΠ S U)
with ⟦ ⟦ -, S ⟧⁻¹ ⟧ | ⟦ ⟦ -, U ⟧⁻¹ ⟧
| ⟦⟧-covar ⟦ -, S ⟧⁻¹ | ⟦⟧-covar ⟦ -, U ⟧⁻¹
| ⟦⟧-left-inverse-⟦⟧⁻¹ S | ⟦⟧-left-inverse-⟦⟧⁻¹ U
... | _ | _ | _ | _ | refl | refl = refl
⟦⟧-bijective : Bijective ⟦⟧-func
⟦⟧-bijective = record
{ injective = ⟦⟧-func-injective
; surjective = record
{ from = ⟦⟧-func-inv
; right-inverse-of = λ { (_ , T) → ⟦⟧-left-inverse-⟦⟧⁻¹ T }
}
}
open ⟦⟧-Bijective using (⟦⟧-covar ; ⟦⟧-injective) public
⟪⟫-contraEnv : ∀ Γ → ContraEnv ⟪ Γ ⟫
⟪⟫-contraEnv [] = []
⟪⟫-contraEnv (T ∷ Γ) = ctt (⟦⟧-covar T) ∷ ⟪⟫-contraEnv Γ
⟦⟧-↑-comm : ∀ T n → ⟦ T ⟧ ↑ n ≡ ⟦ T ⇑ n ⟧
⟦⟧-↑-comm ⊤ n = refl
⟦⟧-↑-comm (var x) n with n ≤? x
... | yes n≤x = refl
... | no n>x = refl
⟦⟧-↑-comm (Π<: S ∙ U) n
rewrite ⟦⟧-↑-comm S n | ⟦⟧-↑-comm U (suc n)
= refl
<:∈⇒env-lookup : ∀ {n T Γ} → n <: T ∈ Γ → env-lookup ⟪ Γ ⟫ n ≡ just ⟨A: ⊥ ⋯ ⟦ T ⟧ ⟩
<:∈⇒env-lookup {_} {_} {T ∷ ._} hd
rewrite ⟦⟧-↑-comm T 0 = refl
<:∈⇒env-lookup {suc n} {_} {._ ∷ Γ} (tl {_} {T} T∈Γ)
with lookupOpt ⟪ Γ ⟫ n | <:∈⇒env-lookup T∈Γ
... | nothing | ()
... | just _ | eq
rewrite sym $ ⟦⟧-↑-comm T 0 = cong (just ∘ (_↑ 0)) (just-injective eq)
F<:⇒D<:ᵣ : ∀ {Γ S U} → Γ ⊢F S <: U → ⟪ Γ ⟫ ⊢ᵣ ⟦ S ⟧ <: ⟦ U ⟧
F<:⇒D<:ᵣ ftop = drtop (⟦⟧-covar _)
F<:⇒D<:ᵣ fvrefl = drrefl (cv∙A _)
F<:⇒D<:ᵣ (fbinds T∈Γ T<:U) = drsel (<:∈⇒env-lookup T∈Γ) (⟦⟧-covar _) (F<:⇒D<:ᵣ T<:U)
F<:⇒D<:ᵣ (fall S′<:S U<:U′) = drall (⟦⟧-covar _) (⟦⟧-covar _) (⟦⟧-covar _) (⟦⟧-covar _)
(F<:⇒D<:ᵣ S′<:S) (F<:⇒D<:ᵣ U<:U′)
env-lookup⇒<:∈ : ∀ {n T Γ} → env-lookup Γ n ≡ just ⟨A: ⊥ ⋯ T ⟩ →
∀ {Γ′} → Γ ≡ ⟪ Γ′ ⟫ →
∃ λ T′ → T ≡ ⟦ T′ ⟧ × n <: T′ ∈ Γ′
env-lookup⇒<:∈ T∈Γ eqΓ = aux (lookup⇒↦∈ T∈Γ) refl eqΓ
where aux : ∀ {n T Γ} → n ↦ T ∈ Γ →
∀ {U Γ′} → T ≡ ⟨A: ⊥ ⋯ U ⟩ → Γ ≡ ⟪ Γ′ ⟫ →
∃ λ U′ → U ≡ ⟦ U′ ⟧ × n <: U′ ∈ Γ′
aux hd {_} {[]} eqT ()
aux hd {_} {T ∷ Γ′} refl refl
rewrite ⟦⟧-↑-comm T 0 = T ⇑ zero , refl , hd
aux (tl T∈Γ) {_} {[]} eqT ()
aux (tl {T = ⊤} T∈Γ) {_} {_ ∷ Γ′} () refl
aux (tl {T = ⊥} T∈Γ) {_} {_ ∷ Γ′} () refl
aux (tl {T = n ∙A} T∈Γ) {_} {_ ∷ Γ′} () refl
aux (tl {T = Π S ∙ U} T∈Γ) {_} {_ ∷ Γ′} () refl
aux (tl {T = ⟨A: ⊤ ⋯ U ⟩} T∈Γ) {_} {_ ∷ Γ′} () refl
aux (tl {T = ⟨A: ⊥ ⋯ U ⟩} T∈Γ) {_} {_ ∷ Γ′} refl refl
with aux T∈Γ refl refl
... | U′ , refl , U′∈Γ′
rewrite ⟦⟧-↑-comm U′ 0 = U′ ⇑ zero , refl , tl U′∈Γ′
aux (tl {T = ⟨A: _ ∙A ⋯ U ⟩} T∈Γ) {_} {_ ∷ Γ′} () refl
aux (tl {T = ⟨A: Π _ ∙ _ ⋯ U ⟩} T∈Γ) {_} {_ ∷ Γ′} () refl
aux (tl {T = ⟨A: ⟨A: _ ⋯ _ ⟩ ⋯ U ⟩} T∈Γ) {_} {_ ∷ Γ′} () refl
D<:ᵣ⇒F<: : ∀ {Γ′ S′ U′} → Γ′ ⊢ᵣ S′ <: U′ →
∀ {Γ S U} →
Γ′ ≡ ⟪ Γ ⟫ → S′ ≡ ⟦ S ⟧ → U′ ≡ ⟦ U ⟧ →
Γ ⊢F S <: U
D<:ᵣ⇒F<: (drtop S′) {Γ} {S} {⊤} eqΓ eqS refl = ftop
D<:ᵣ⇒F<: (drtop S′) {Γ} {S} {var x} eqΓ eqS ()
D<:ᵣ⇒F<: (drtop S′) {Γ} {S} {Π<: U ∙ U₁} eqΓ eqS ()
D<:ᵣ⇒F<: (drrefl S′) {Γ} {S} {U} eqΓ eqS eqU
rewrite ⟦⟧-injective (≡.trans (sym eqS) eqU) = <:-refl Γ U
D<:ᵣ⇒F<: (drall cS cU cS′ cU′ S′<:S U<:U′) {Γ} {⊤} {⊤} eqΓ () eqU
D<:ᵣ⇒F<: (drall cS cU cS′ cU′ S′<:S U<:U′) {Γ} {⊤} {var x} eqΓ () eqU
D<:ᵣ⇒F<: (drall cS cU cS′ cU′ S′<:S U<:U′) {Γ} {⊤} {Π<: U ∙ U₁} eqΓ () eqU
D<:ᵣ⇒F<: (drall cS cU cS′ cU′ S′<:S U<:U′) {Γ} {var _} {⊤} eqΓ () eqU
D<:ᵣ⇒F<: (drall cS cU cS′ cU′ S′<:S U<:U′) {Γ} {var _} {var _} eqΓ () eqU
D<:ᵣ⇒F<: (drall cS cU cS′ cU′ S′<:S U<:U′) {Γ} {var _} {Π<: _ ∙ _} eqΓ () eqU
D<:ᵣ⇒F<: (drall cS cU cS′ cU′ S′<:S U<:U′) {Γ} {Π<: _ ∙ _} {⊤} eqΓ refl ()
D<:ᵣ⇒F<: (drall cS cU cS′ cU′ S′<:S U<:U′) {Γ} {Π<: _ ∙ _} {var _} eqΓ refl ()
D<:ᵣ⇒F<: (drall cS cU cS′ cU′ S′<:S U<:U′) {Γ} {Π<: S ∙ U} {Π<: S′ ∙ U′} eqΓ refl refl
= fall (D<:ᵣ⇒F<: S′<:S eqΓ refl refl)
(D<:ᵣ⇒F<: U<:U′ (cong (⟨A: ⊥ ⋯ ⟦ S′ ⟧ ⟩ ∷_) eqΓ) refl refl)
D<:ᵣ⇒F<: (drsel T∈Γ cT S<:U) {Γ} {⊤} {U} eqΓ () eqU
D<:ᵣ⇒F<: (drsel T∈Γ cT S<:U) {Γ} {var x} {U} eqΓ refl eqU
with env-lookup⇒<:∈ T∈Γ eqΓ
... | U′ , eqU′ , T′∈Γ = fbinds T′∈Γ (D<:ᵣ⇒F<: S<:U eqΓ eqU′ eqU)
D<:ᵣ⇒F<: (drsel T∈Γ cT S<:U) {Γ} {Π<: _ ∙ _} {U} eqΓ () eqU
|
test/unittest_drawrectangle.asm | muellevin/RARS_Game_of_Life | 1 | 241495 | # ___ ___ ___ ___ _ ___ ___ _____ _ _ ___ ___
# / __| __/ __| _ \ | | | __/ __|_ _| | | | _ \ __|
# | (__| _|\__ \ _/ | |__| _| (__ | | | |_| | / _|
# \___|___|___/_| |____|___\___| |_| \___/|_|_\___|
#
# Copyright 2021 <NAME>
.include "../src/constants_settings.asm"
la t0, settings
li t1, 256
sw t1, 12(t0)
sw t1, 16(t0)
li a3, 1
li a4, 1
li a5, 8
li a6, 9
li a7, 0x00ff00
jal draw_rectangle
li a3, 100
li a4, 180
li a5, 140
li a6, 200
li a7, 0xffff00
jal draw_rectangle
li a7,10
ecall
.include "../src/exercise_solutions/draw_rectangle.asm"
|
examples/outdated-and-incorrect/AIM6/Cat/Category.agda | asr/agda-kanso | 1 | 1180 | <reponame>asr/agda-kanso<gh_stars>1-10
module Category where
open import Logic.Equivalence
open import Logic.Relations
open Equivalence using () renaming (_==_ to eq)
record Cat : Set2 where
field
Obj : Set1
_─→_ : Obj -> Obj -> Set
id : {A : Obj} -> A ─→ A
_∘_ : {A B C : Obj} -> B ─→ C -> A ─→ B -> A ─→ C
Eq : {A B : Obj} -> Equivalence (A ─→ B)
cong : {A B C : Obj}{f₁ f₂ : B ─→ C}{g₁ g₂ : A ─→ B} ->
eq Eq f₁ f₂ -> eq Eq g₁ g₂ -> eq Eq (f₁ ∘ g₁) (f₂ ∘ g₂)
idLeft : {A B : Obj}{f : A ─→ B} -> eq Eq (id ∘ f) f
idRight : {A B : Obj}{f : A ─→ B} -> eq Eq (f ∘ id) f
assoc : {A B C D : Obj}{f : C ─→ D}{g : B ─→ C}{h : A ─→ B} ->
eq Eq ((f ∘ g) ∘ h) (f ∘ (g ∘ h))
module Category (ℂ : Cat) where
private module CC = Cat ℂ
open CC public hiding (_─→_; _∘_)
private module Eq {A B : Obj} = Equivalence (Eq {A}{B})
open Eq public hiding (_==_)
infix 20 _==_
infixr 30 _─→_
infixr 90 _∘_
_─→_ = CC._─→_
_==_ : {A B : Obj} -> Rel (A ─→ B)
_==_ = Eq._==_
_∘_ : {A B C : Obj} -> B ─→ C -> A ─→ B -> A ─→ C
_∘_ = CC._∘_
congL : {A B C : Obj}{f₁ f₂ : B ─→ C}{g : A ─→ B} ->
f₁ == f₂ -> f₁ ∘ g == f₂ ∘ g
congL p = cong p refl
congR : {A B C : Obj}{f : B ─→ C}{g₁ g₂ : A ─→ B} ->
g₁ == g₂ -> f ∘ g₁ == f ∘ g₂
congR p = cong refl p
|
1997-fall/mp0/mp0.asm | ece291/machine-problems | 3 | 170189 | <reponame>ece291/machine-problems
PAGE 75, 132
TITLE MP0 Your Name current date
COMMENT *
This program illustrates a (very) basic assembly program and
the use of LIB291 input and output routines.
Put your name in the places where it says '<NAME>' and also
change the date where it says 'current date'.
*
;====== SECTION 1: Define constants =======================================
CR EQU 0Dh
LF EQU 0Ah
BEL EQU 07h
;====== SECTION 2: Declare external procedures ============================
EXTRN kbdine:near, dspout:near, dspmsg:near, dosxit:near
;====== SECTION 3: Define stack segment ===================================
STKSEG SEGMENT STACK ; *** STACK SEGMENT ***
db 64 dup ('STACK ')
STKSEG ENDS
;====== SECTION 4: Define code segment ====================================
CSEG SEGMENT PUBLIC ; *** CODE SEGMENT ***
ASSUME cs:cseg, ds:cseg, ss:stkseg, es:nothing
;====== SECTION 5: Declare variables for main procedure ===================
var db 0
question db CR,LF,'What grade would you like in ECE291? ','$'
Exitmsg db CR,LF,'Good Luck!',CR,LF,'$'
invalid db CR,LF,'Not a valid choice! ',CR,LF,'$'
Amsg db CR,LF,'Great! Comment code and turn work in early.',CR,LF,'$'
Bmsg db CR,LF,'Keep up in class and turn things in on time.',CR,LF,'$'
Dmsg db CR,LF,'Skip machine problems.',CR,LF,'$'
Fmsg db CR,LF,'Sleep through exams.',CR,LF,'$'
;====== SECTION 6: Main procedure =========================================
MAIN PROC FAR
mov ax, cs ; Initialize Default Segment register
mov ds, ax
mov dx, offset question ; Prompt user with question
call dspmsg
call kbdine ; Get keyboard character in AL
mov var,al ; Save result in a variable
CheckGrade:
cmp var, 'A' ; Check if A student
jne NotGradeA
mov dx, offset Amsg ; Print message for A students
call dspmsg
jmp mpExit
NotGradeA:
cmp var, 'B' ; Check if B student
jne NotGradeB
mov dx, offset Bmsg ; Print message for B students
call dspmsg
jmp mpExit
NotGradeB:
cmp var, 'D' ; Check if D student
jne NotGradeD
mov dx, offset Dmsg ; Print message for D students
call dspmsg
jmp mpExit
NotGradeD:
cmp var, 'F' ; Check if F student
jne NotGradeF
mov dx, offset Fmsg ; Print message for F students
call dspmsg
jmp mpExit
NotGradeF:
mov dl, BEL ; Ring the bell if other character
call dspout
mov dx, offset invalid ; Print invalid message
call dspmsg
jmp FinalExit
mpExit:
mov dx, offset Exitmsg ; Type out exit message
call dspmsg
FinalExit:
call dosxit ; Exit to DOS
MAIN ENDP
CSEG ENDS
END MAIN
|
raytracing/trace.asm | gp48k/lpfp | 17 | 161521 | ; Raytracer
; Input: B = y coordinate from top, C = x coordinate from left
; Output: flag C = light
; Start ray
TRACE: PUSH BC
LD A,C
CALL FBYTE
LD HL,$C700 ; -128
CALL FADD
LD (DX),HL
POP BC
LD A,B
CALL FBYTE
LD HL,$C680 ; -96
CALL FADD
LD (DY),HL
LD HL,$482C ; +300
LD (DZ),HL
LD HL,DX
LD B,3
CALL FLEN
LD (DD),HL
CALL FSQRT
LD (DL),HL
LD A,(POS)
LD HL,GROUNDC
LD DE,GC
POSL: LD BC,6
LDIR
DEC A
JR NZ,POSL
LD (BOUNCE),A
TRACEL: LD HL,BOUNCE
DEC (HL)
RET Z
|
data/pokemon/base_stats/combee.asm | AtmaBuster/pokeplat-gen2 | 6 | 15885 | <reponame>AtmaBuster/pokeplat-gen2
db 0 ; species ID placeholder
db 30, 30, 42, 70, 30, 42
; hp atk def spd sat sdf
db BUG, FLYING ; type
db 120 ; catch rate
db 49 ; base exp
db HONEY, HONEY ; items
db GENDER_F12_5 ; gender ratio
db 15 ; step cycles to hatch
INCBIN "gfx/pokemon/combee/front.dimensions"
db GROWTH_MEDIUM_SLOW ; growth rate
dn EGG_BUG, EGG_BUG ; egg groups
db 70 ; happiness
; tm/hm learnset
tmhm AIR_CUTTER, ENDEAVOR, MUD_SLAP, OMINOUS_WIND, SNORE, SWIFT
; end
|
example/src/clic_example.adb | reznikmm/clic | 9 | 21692 | with CLIC_Ex.Commands;
procedure Clic_Example is
begin
CLIC_Ex.Commands.Execute;
end Clic_Example;
|
alloy4fun_models/trashltl/models/17/mZ8T6roAcgNZDzvwu.als | Kaixi26/org.alloytools.alloy | 0 | 2227 | <filename>alloy4fun_models/trashltl/models/17/mZ8T6roAcgNZDzvwu.als<gh_stars>0
open main
pred idmZ8T6roAcgNZDzvwu_prop18 {
always all f: File | (f in Trash releases f not in Protected)
}
pred __repair { idmZ8T6roAcgNZDzvwu_prop18 }
check __repair { idmZ8T6roAcgNZDzvwu_prop18 <=> prop18o } |
src/fot/FOTC/Data/Stream/Equality/PropertiesATP.agda | asr/fotc | 11 | 13394 | <filename>src/fot/FOTC/Data/Stream/Equality/PropertiesATP.agda
------------------------------------------------------------------------------
-- Properties for the equality on streams
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Data.Stream.Equality.PropertiesATP where
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Data.Stream.Type
open import FOTC.Relation.Binary.Bisimilarity.PropertiesATP
open import FOTC.Relation.Binary.Bisimilarity.Type
------------------------------------------------------------------------------
postulate stream-≡→≈ : ∀ {xs ys} → Stream xs → Stream ys → xs ≡ ys → xs ≈ ys
{-# ATP prove stream-≡→≈ ≈-refl #-}
-- See Issue https://github.com/asr/apia/issues/81 .
≈→Stream₁A : D → Set
≈→Stream₁A ws = ∃[ zs ] ws ≈ zs
{-# ATP definition ≈→Stream₁A #-}
≈→Stream₁ : ∀ {xs ys} → xs ≈ ys → Stream xs
≈→Stream₁ {xs} {ys} h = Stream-coind ≈→Stream₁A h' (ys , h)
where
postulate h' : ∀ {xs} → ≈→Stream₁A xs →
∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ ≈→Stream₁A xs'
{-# ATP prove h' #-}
-- See Issue https://github.com/asr/apia/issues/81 .
≈→Stream₂A : D → Set
≈→Stream₂A zs = ∃[ ws ] ws ≈ zs
{-# ATP definition ≈→Stream₂A #-}
≈→Stream₂ : ∀ {xs ys} → xs ≈ ys → Stream ys
≈→Stream₂ {xs} {ys} h = Stream-coind ≈→Stream₂A h' (xs , h)
where
postulate h' : ∀ {ys} → ≈→Stream₂A ys →
∃[ y' ] ∃[ ys' ] ys ≡ y' ∷ ys' ∧ ≈→Stream₂A ys'
{-# ATP prove h' #-}
≈→Stream : ∀ {xs ys} → xs ≈ ys → Stream xs ∧ Stream ys
≈→Stream {xs} {ys} h = ≈→Stream₁ h , ≈→Stream₂ h
|
Sources/Globe_3d/models/skotknot.ads | ForYouEyesOnly/Space-Convoy | 1 | 17162 | pragma Warnings (Off);
pragma Style_Checks (Off);
-- VRML : [#VRML V1.0 ascii
-- ]
with GLOBE_3D;
package SkotKnot is
procedure Create (
object : in out GLOBE_3D.p_Object_3D;
scale : GLOBE_3D.Real;
centre : GLOBE_3D.Point_3D
);
end;
|
oeis/106/A106139.asm | neoneye/loda-programs | 11 | 175175 | ; A106139: Semiprimes (mod 3).
; Submitted by <NAME>
; 1,0,0,1,2,0,0,1,1,2,0,1,2,2,0,1,1,0,1,0,1,2,2,0,2,2,1,1,2,0,1,0,1,2,1,0,1,1,2,1,2,0,0,1,2,0,1,2,1,2,2,2,0,2,1,1,0,1,0,2,1,2,0,1,2,1,2,2,0,1,2,1,2,0,2,1,1,0,1,0,1,2,1,1,1,0,1,2,2,1,0,1,1,2,1,2,0,2,0,2
seq $0,1358 ; Semiprimes (or biprimes): products of two primes.
mod $0,3
|
programs/oeis/187/A187103.asm | neoneye/loda | 22 | 82751 | ; A187103: Maximum order of explicit Runge-Kutta method with n function evaluations in each step.
; 1,2,3,4,4,5,6,6,7,7,8
mov $1,$0
sub $1,2
mov $2,$0
bin $0,2
add $2,2
div $0,$2
sub $1,$0
mov $0,$1
add $0,3
mod $0,10
|
test/Fail/Relevance-subtyping-2.agda | cagix/agda | 1,989 | 862 | -- Subtyping is no longer supported for irrelevance.
f : {A B : Set} → (.A → B) → A → B
f g = λ .x → g x
|
Agda/02-natural-numbers.agda | tadejpetric/HoTT-Intro | 0 | 13991 | {-# OPTIONS --without-K --exact-split #-}
module 02-natural-numbers where
import 00-preamble
open 00-preamble public
-- Definition 2.2.3
id : {i : Level} {A : UU i} → A → A
id a = a
-- Definition 2.2.4
_∘_ :
{i j k : Level} {A : UU i} {B : UU j} {C : UU k} →
(B → C) → ((A → B) → (A → C))
(g ∘ f) a = g (f a)
data ℕ : UU lzero where
zero-ℕ : ℕ
succ-ℕ : ℕ → ℕ
one-ℕ : ℕ
one-ℕ = succ-ℕ zero-ℕ
-- induction: for any dependent type P over ℕ, define a section of P
-- built out of a term in P 0 and a section of P n → P(Nsucc n)
ind-ℕ : {i : Level} {P : ℕ → UU i} → P zero-ℕ → ((n : ℕ) → P n → P(succ-ℕ n)) → ((n : ℕ) → P n)
ind-ℕ p0 pS zero-ℕ = p0
ind-ℕ p0 pS (succ-ℕ n) = pS n (ind-ℕ p0 pS n)
-- use the general induction principle to define addition
-- in this case P is ℕ, the special non-dependent type over ℕ, and
-- so sections of P (dependent functions Π_{x:ℕ} P(x)) are functions ℕ → ℕ
add-ℕ : ℕ → ℕ → ℕ
add-ℕ zero-ℕ y = y
add-ℕ (succ-ℕ x) y = succ-ℕ (add-ℕ x y)
-- Exercise 2.2
const : {i j : Level} (A : UU i) (B : UU j) (b : B) → A → B
const A B b x = b
-- Exercise 2.3
-- In this exercise we are asked to construct some standard functions on the
-- natural numbers.
-- Exercise 2.3(a)
max-ℕ : ℕ → (ℕ → ℕ)
max-ℕ zero-ℕ n = n
max-ℕ (succ-ℕ m) zero-ℕ = succ-ℕ m
max-ℕ (succ-ℕ m) (succ-ℕ n) = succ-ℕ (max-ℕ m n)
min-ℕ : ℕ → (ℕ → ℕ)
min-ℕ zero-ℕ n = zero-ℕ
min-ℕ (succ-ℕ m) zero-ℕ = zero-ℕ
min-ℕ (succ-ℕ m) (succ-ℕ n) = succ-ℕ (min-ℕ m n)
-- Exercise 2.3(b)
mul-ℕ : ℕ → (ℕ → ℕ)
mul-ℕ zero-ℕ n = zero-ℕ
mul-ℕ (succ-ℕ m) n = add-ℕ (mul-ℕ m n) n
-- Exercise 2.3(c)
_^_ : ℕ → (ℕ → ℕ)
m ^ zero-ℕ = one-ℕ
m ^ (succ-ℕ n) = mul-ℕ m (m ^ n)
-- Exercise 2.3(d)
factorial : ℕ → ℕ
factorial zero-ℕ = one-ℕ
factorial (succ-ℕ m) = mul-ℕ (succ-ℕ m) (factorial m)
-- Exercise 2.3(e)
_choose_ : ℕ → ℕ → ℕ
zero-ℕ choose zero-ℕ = one-ℕ
zero-ℕ choose succ-ℕ k = zero-ℕ
(succ-ℕ n) choose zero-ℕ = one-ℕ
(succ-ℕ n) choose (succ-ℕ k) = add-ℕ (n choose k) (n choose (succ-ℕ k))
-- Exercise 2.3(f)
Fibonacci : ℕ → ℕ
Fibonacci zero-ℕ = zero-ℕ
Fibonacci (succ-ℕ zero-ℕ) = one-ℕ
Fibonacci (succ-ℕ (succ-ℕ n)) = add-ℕ (Fibonacci n) (Fibonacci (succ-ℕ n))
-- Exercise 2.4
_∘'_ :
{i j k : Level} {A : UU i} {B : A → UU j} {C : (x : A) → B x → UU k} →
(g : (x : A) → (y : B x) → C x y) (f : (x : A) → B x) → (x : A) → C x (f x)
(g ∘' f) x = g x (f x)
-- Exercise 2.5
Π-swap : {i j k : Level} {A : UU i} {B : UU j} {C : A → (B → UU k)} →
((x : A) (y : B) → C x y) → ((y : B) (x : A) → C x y)
Π-swap f y x = f x y
-- Note: apparently Agda still allows us to define a sequence of universe levels indexed by ℕ
Level-ℕ : ℕ → Level
Level-ℕ zero-ℕ = lzero
Level-ℕ (succ-ℕ n) = lsuc (Level-ℕ n)
sequence-UU : (n : ℕ) → UU (Level-ℕ (succ-ℕ n))
sequence-UU n = UU (Level-ℕ n)
-- However, the following definition is unacceptable for Agda, since it runs
-- into Setω.
{-
Π-sequence-UU : Setω
Π-sequence-UU = (n : ℕ) → sequence-UU n
-}
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/access4.adb | best08618/asylo | 7 | 14884 | -- { dg-do run }
with access3; use access3;
procedure access4 is
Obj_IT : aliased T;
Obj_T2 : T2;
begin
Obj_T2.Op (Obj_IT'Access);
end;
|
Transynther/x86/_processed/AVXALIGN/_st_zr_un_sm_/i9-9900K_12_0xa0_notsx.log_21829_1587.asm | ljhsiun2/medusa | 9 | 91690 | <gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r8
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0xbbf7, %r8
nop
nop
nop
nop
cmp %rdx, %rdx
mov $0x6162636465666768, %rsi
movq %rsi, %xmm7
movups %xmm7, (%r8)
nop
nop
nop
add %rbx, %rbx
lea addresses_D_ht+0x7af7, %rsi
lea addresses_UC_ht+0x325a, %rdi
clflush (%rsi)
sub $25680, %r14
mov $94, %rcx
rep movsl
nop
nop
nop
nop
nop
dec %rdi
lea addresses_UC_ht+0x115d7, %rsi
lea addresses_normal_ht+0x8ef, %rdi
clflush (%rsi)
nop
nop
nop
xor %rbx, %rbx
mov $6, %rcx
rep movsb
inc %rsi
lea addresses_WT_ht+0xafbd, %rbx
nop
nop
nop
nop
nop
sub $45009, %r14
mov (%rbx), %di
nop
add %rcx, %rcx
lea addresses_normal_ht+0x77f7, %rcx
nop
nop
nop
sub %rdx, %rdx
movw $0x6162, (%rcx)
nop
nop
nop
nop
inc %rdi
lea addresses_D_ht+0xe3f7, %rsi
lea addresses_WC_ht+0xf4f7, %rdi
nop
nop
nop
sub %r12, %r12
mov $22, %rcx
rep movsw
nop
xor $32188, %r8
lea addresses_WT_ht+0xff7, %rsi
nop
nop
nop
nop
nop
cmp $47356, %rcx
movw $0x6162, (%rsi)
nop
nop
xor %r14, %r14
lea addresses_UC_ht+0xfbf7, %rdi
clflush (%rdi)
sub %rdx, %rdx
movl $0x61626364, (%rdi)
nop
nop
xor $47883, %rbx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %r15
push %rbp
push %rbx
push %rdx
// Load
lea addresses_WC+0x12f77, %rbx
nop
nop
sub $8504, %r12
mov (%rbx), %r13
xor $18992, %r15
// Store
mov $0x7b46800000003f7, %rdx
nop
nop
nop
nop
nop
add %r10, %r10
mov $0x5152535455565758, %rbx
movq %rbx, (%rdx)
sub %rbp, %rbp
// Store
lea addresses_normal+0x16ff7, %r10
nop
cmp %r13, %r13
mov $0x5152535455565758, %rdx
movq %rdx, (%r10)
sub %rbx, %rbx
// Store
lea addresses_UC+0x18027, %r13
nop
nop
nop
nop
nop
sub $35195, %r10
movw $0x5152, (%r13)
nop
nop
nop
nop
and %r10, %r10
// Faulty Load
lea addresses_normal+0x16ff7, %rbp
nop
nop
nop
dec %r10
vmovntdqa (%rbp), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $0, %xmm1, %rdx
lea oracles, %r15
and $0xff, %rdx
shlq $12, %rdx
mov (%r15,%rdx,1), %rdx
pop %rdx
pop %rbx
pop %rbp
pop %r15
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_normal', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC', 'AVXalign': False, 'size': 8, 'NT': True, 'same': False, 'congruent': 6}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'AVXalign': False, 'size': 8, 'NT': True, 'same': False, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'size': 8, 'NT': False, 'same': True, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 3}}
[Faulty Load]
{'src': {'type': 'addresses_normal', 'AVXalign': False, 'size': 32, 'NT': True, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 10}}
{'src': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}}
{'src': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': True}}
{'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 1}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 8}}
{'src': {'type': 'addresses_D_ht', 'congruent': 10, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 10}}
{'58': 21711, '6d': 1, '00': 117}
58 58 58 58 58 58 58 00 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 00 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 00 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 00 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 00 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 00 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
erasure_code/gf_4vect_mad_sse.asm | leo-project/isa_l | 1 | 16711 | <gh_stars>1-10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright(c) 2011-2015 Intel Corporation All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions
; are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in
; the documentation and/or other materials provided with the
; distribution.
; * Neither the name of Intel Corporation nor the names of its
; contributors may be used to endorse or promote products derived
; from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; gf_4vect_mad_sse(len, vec, vec_i, mul_array, src, dest);
;;;
%include "reg_sizes.asm"
%define PS 8
%ifidn __OUTPUT_FORMAT__, win64
%define arg0 rcx
%define arg0.w ecx
%define arg1 rdx
%define arg2 r8
%define arg3 r9
%define arg4 r12
%define arg5 r15
%define tmp r11
%define tmp2 r10
%define tmp3 r13
%define return rax
%define return.w eax
%define stack_size 16*10 + 3*8
%define arg(x) [rsp + stack_size + PS + PS*x]
%define func(x) proc_frame x
%macro FUNC_SAVE 0
sub rsp, stack_size
movdqa [rsp+16*0],xmm6
movdqa [rsp+16*1],xmm7
movdqa [rsp+16*2],xmm8
movdqa [rsp+16*3],xmm9
movdqa [rsp+16*4],xmm10
movdqa [rsp+16*5],xmm11
movdqa [rsp+16*6],xmm12
movdqa [rsp+16*7],xmm13
movdqa [rsp+16*8],xmm14
movdqa [rsp+16*9],xmm15
save_reg r12, 10*16 + 0*8
save_reg r13, 10*16 + 1*8
save_reg r15, 10*16 + 2*8
end_prolog
mov arg4, arg(4)
mov arg5, arg(5)
%endmacro
%macro FUNC_RESTORE 0
movdqa xmm6, [rsp+16*0]
movdqa xmm7, [rsp+16*1]
movdqa xmm8, [rsp+16*2]
movdqa xmm9, [rsp+16*3]
movdqa xmm10, [rsp+16*4]
movdqa xmm11, [rsp+16*5]
movdqa xmm12, [rsp+16*6]
movdqa xmm13, [rsp+16*7]
movdqa xmm14, [rsp+16*8]
movdqa xmm15, [rsp+16*9]
mov r12, [rsp + 10*16 + 0*8]
mov r13, [rsp + 10*16 + 1*8]
mov r15, [rsp + 10*16 + 2*8]
add rsp, stack_size
%endmacro
%elifidn __OUTPUT_FORMAT__, elf64
%define arg0 rdi
%define arg0.w edi
%define arg1 rsi
%define arg2 rdx
%define arg3 rcx
%define arg4 r8
%define arg5 r9
%define tmp r11
%define tmp2 r10
%define tmp3 r12
%define return rax
%define return.w eax
%define func(x) x:
%macro FUNC_SAVE 0
push r12
%endmacro
%macro FUNC_RESTORE 0
pop r12
%endmacro
%endif
;;; gf_4vect_mad_sse(len, vec, vec_i, mul_array, src, dest)
%define len arg0
%define len.w arg0.w
%define vec arg1
%define vec_i arg2
%define mul_array arg3
%define src arg4
%define dest1 arg5
%define pos return
%define pos.w return.w
%define dest2 mul_array
%define dest3 tmp2
%define dest4 vec_i
%ifndef EC_ALIGNED_ADDR
;;; Use Un-aligned load/store
%define XLDR movdqu
%define XSTR movdqu
%else
;;; Use Non-temporal load/stor
%ifdef NO_NT_LDST
%define XLDR movdqa
%define XSTR movdqa
%else
%define XLDR movntdqa
%define XSTR movntdq
%endif
%endif
default rel
[bits 64]
section .text
%define xmask0f xmm15
%define xgft3_hi xmm14
%define xgft4_hi xmm13
%define xgft4_lo xmm12
%define x0 xmm0
%define xtmpa xmm1
%define xtmph1 xmm2
%define xtmpl1 xmm3
%define xtmph2 xmm4
%define xtmpl2 xmm5
%define xtmph3 xmm6
%define xtmpl3 xmm7
%define xtmph4 xmm8
%define xtmpl4 xmm9
%define xd1 xmm10
%define xd2 xmm11
%define xd3 xtmph1
%define xd4 xtmpl1
align 16
global gf_4vect_mad_sse:function
func(gf_4vect_mad_sse)
FUNC_SAVE
sub len, 16
jl .return_fail
xor pos, pos
movdqa xmask0f, [mask0f] ;Load mask of lower nibble in each byte
mov tmp, vec
sal vec_i, 5 ;Multiply by 32
lea tmp3, [mul_array + vec_i]
sal tmp, 6 ;Multiply by 64
movdqu xgft3_hi, [tmp3+tmp+16] ; " Cx{00}, Cx{10}, Cx{20}, ... , Cx{f0}
sal vec, 5 ;Multiply by 32
add tmp, vec
movdqu xgft4_lo, [tmp3+tmp] ;Load array Dx{00}, Dx{01}, Dx{02}, ...
movdqu xgft4_hi, [tmp3+tmp+16] ; " Dx{00}, Dx{10}, Dx{20}, ... , Dx{f0}
mov dest2, [dest1+PS] ; reuse mul_array
mov dest3, [dest1+2*PS]
mov dest4, [dest1+3*PS] ; reuse vec_i
mov dest1, [dest1]
.loop16:
XLDR x0, [src+pos] ;Get next source vector
movdqu xtmph1, [tmp3+16] ; " Ax{00}, Ax{10}, Ax{20}, ... , Ax{f0}
movdqu xtmpl1, [tmp3] ;Load array Ax{00}, Ax{01}, Ax{02}, ...
movdqu xtmph2, [tmp3+vec+16] ; " Bx{00}, Bx{10}, Bx{20}, ... , Bx{f0}
movdqu xtmpl2, [tmp3+vec] ;Load array Bx{00}, Bx{01}, Bx{02}, ...
movdqu xtmpl3, [tmp3+2*vec] ;Load array Cx{00}, Cx{01}, Cx{02}, ...
movdqa xtmph3, xgft3_hi
movdqa xtmpl4, xgft4_lo
movdqa xtmph4, xgft4_hi
XLDR xd1, [dest1+pos] ;Get next dest vector
XLDR xd2, [dest2+pos] ;Get next dest vector
movdqa xtmpa, x0 ;Keep unshifted copy of src
psraw x0, 4 ;Shift to put high nibble into bits 4-0
pand x0, xmask0f ;Mask high src nibble in bits 4-0
pand xtmpa, xmask0f ;Mask low src nibble in bits 4-0
; dest1
pshufb xtmph1, x0 ;Lookup mul table of high nibble
pshufb xtmpl1, xtmpa ;Lookup mul table of low nibble
pxor xtmph1, xtmpl1 ;GF add high and low partials
pxor xd1, xtmph1
XLDR xd3, [dest3+pos] ;Reuse xtmph1, Get next dest vector
XLDR xd4, [dest4+pos] ;Reuse xtmpl1, Get next dest vector
; dest2
pshufb xtmph2, x0 ;Lookup mul table of high nibble
pshufb xtmpl2, xtmpa ;Lookup mul table of low nibble
pxor xtmph2, xtmpl2 ;GF add high and low partials
pxor xd2, xtmph2
; dest3
pshufb xtmph3, x0 ;Lookup mul table of high nibble
pshufb xtmpl3, xtmpa ;Lookup mul table of low nibble
pxor xtmph3, xtmpl3 ;GF add high and low partials
pxor xd3, xtmph3
; dest4
pshufb xtmph4, x0 ;Lookup mul table of high nibble
pshufb xtmpl4, xtmpa ;Lookup mul table of low nibble
pxor xtmph4, xtmpl4 ;GF add high and low partials
pxor xd4, xtmph4
XSTR [dest1+pos], xd1 ;Store result
XSTR [dest2+pos], xd2 ;Store result
XSTR [dest3+pos], xd3 ;Store result
XSTR [dest4+pos], xd4 ;Store result
add pos, 16 ;Loop on 16 bytes at a time
cmp pos, len
jle .loop16
lea tmp, [len + 16]
cmp pos, tmp
je .return_pass
.lessthan16:
;; Tail len
;; Do one more overlap pass
mov tmp, len ;Overlapped offset length-16
XLDR x0, [src+tmp] ;Get next source vector
movdqu xtmph1, [tmp3+16] ; " Ax{00}, Ax{10}, Ax{20}, ... , Ax{f0}
movdqu xtmpl1, [tmp3] ;Load array Ax{00}, Ax{01}, Ax{02}, ...
movdqu xtmph2, [tmp3+vec+16] ; " Bx{00}, Bx{10}, Bx{20}, ... , Bx{f0}
movdqu xtmpl2, [tmp3+vec] ;Load array Bx{00}, Bx{01}, Bx{02}, ...
movdqu xtmpl3, [tmp3+2*vec] ;Load array Cx{00}, Cx{01}, Cx{02}, ...
XLDR xd1, [dest1+tmp] ;Get next dest vector
XLDR xd2, [dest2+tmp] ;Get next dest vector
XLDR xtmph4, [dest3+tmp] ;Reuse xtmph1. Get next dest vector
sub len, pos
movdqa xtmpl4, [constip16] ;Load const of i + 16
pinsrb xtmph3, len.w, 15
pshufb xtmph3, xmask0f ;Broadcast len to all bytes
pcmpgtb xtmph3, xtmpl4
XLDR xtmpl4, [dest4+tmp] ;Get next dest vector
movdqa xtmpa, x0 ;Keep unshifted copy of src
psraw x0, 4 ;Shift to put high nibble into bits 4-0
pand x0, xmask0f ;Mask high src nibble in bits 4-0
pand xtmpa, xmask0f ;Mask low src nibble in bits 4-0
; dest1
pshufb xtmph1, x0 ;Lookup mul table of high nibble
pshufb xtmpl1, xtmpa ;Lookup mul table of low nibble
pxor xtmph1, xtmpl1 ;GF add high and low partials
pand xtmph1, xtmph3
pxor xd1, xtmph1
; dest2
pshufb xtmph2, x0 ;Lookup mul table of high nibble
pshufb xtmpl2, xtmpa ;Lookup mul table of low nibble
pxor xtmph2, xtmpl2 ;GF add high and low partials
pand xtmph2, xtmph3
pxor xd2, xtmph2
; dest3
pshufb xgft3_hi, x0 ;Lookup mul table of high nibble
pshufb xtmpl3, xtmpa ;Lookup mul table of low nibble
pxor xgft3_hi, xtmpl3 ;GF add high and low partials
pand xgft3_hi, xtmph3
pxor xtmph4, xgft3_hi
; dest4
pshufb xgft4_hi, x0 ;Lookup mul table of high nibble
pshufb xgft4_lo, xtmpa ;Lookup mul table of low nibble
pxor xgft4_hi, xgft4_lo ;GF add high and low partials
pand xgft4_hi, xtmph3
pxor xtmpl4, xgft4_hi
XSTR [dest1+tmp], xd1 ;Store result
XSTR [dest2+tmp], xd2 ;Store result
XSTR [dest3+tmp], xtmph4 ;Store result
XSTR [dest4+tmp], xtmpl4 ;Store result
.return_pass:
FUNC_RESTORE
mov return, 0
ret
.return_fail:
FUNC_RESTORE
mov return, 1
ret
endproc_frame
section .data
align 16
mask0f:
ddq 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f
constip16:
ddq 0xf0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
;;; func core, ver, snum
slversion gf_4vect_mad_sse, 00, 01, 0209
|
libsrc/graphics/unplot_callee.asm | jpoikela/z88dk | 38 | 173791 | <reponame>jpoikela/z88dk
;
; Z88 Graphics Functions - Small C+ stubs
;
; Written around the Interlogic Standard Library
;
; Stubs Written by <NAME> - 30/9/98
;
;
; $Id: unplot_callee.asm $
;
; CALLER LINKAGE FOR FUNCTION POINTERS
; ----- void unplot(int x, int y)
SECTION code_graphics
PUBLIC unplot_callee
PUBLIC _unplot_callee
PUBLIC ASMDISP_UNPLOT_CALLEE
EXTERN swapgfxbk
EXTERN __graphics_end
EXTERN respixel
.unplot_callee
._unplot_callee
pop af ; ret addr
pop hl ; y
pop de ; x
ld h,e
push af ; ret addr
.asmentry
push ix
call swapgfxbk
call respixel
jp __graphics_end
DEFC ASMDISP_UNPLOT_CALLEE = asmentry - unplot_callee
|
libsrc/_DEVELOPMENT/arch/sms/SMSlib/z80/asm_SMSlib_loadBGPalette.asm | jpoikela/z88dk | 640 | 4048 | <gh_stars>100-1000
; **************************************************
; SMSlib - C programming library for the SMS/GG
; ( part of devkitSMS - github.com/sverx/devkitSMS )
; **************************************************
INCLUDE "SMSlib_private.inc"
SECTION code_clib
SECTION code_SMSlib
PUBLIC asm_SMSlib_loadBGPalette
asm_SMSlib_loadBGPalette:
; void SMS_loadBGPalette (void *palette)
;
; enter : hl = void *palette
;
; uses : af, bc, hl
di
ld a,SMS_CRAMAddress&0xff
out (VDPControlPort),a
ld a,SMS_CRAMAddress/256
out (VDPControlPort),a
ei
ld bc,0x1000 + VDPDataPort
loop:
outi
jp nz, loop
ret
|
agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z03-natural-numbers.agda | haroldcarr/learn-haskell-coq-ml-etc | 36 | 2321 | <reponame>haroldcarr/learn-haskell-coq-ml-etc<filename>agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z03-natural-numbers.agda
module z03-natural-numbers where
open import bool
open import bool-thms using (𝔹-contra)
open import eq
open import level
-- p 50
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
-- p 51
{-# BUILTIN NATURAL ℕ #-}
-------------------------
_+_ : ℕ → ℕ → ℕ
zero + n = n
suc m + n = suc (m + n) -- recursive call on structurally smaller left side 'm' -- termination
-- p 53
-------------------------
0+ : ∀ (x : ℕ)
→ 0 + x ≡ x
0+ _ = refl -- via definitional equality
{- fails because _+_ defined in terms of pattern matching on left arg
+0 : ∀ (x : ℕ)
→ x + 0 ≡ x
+0 _ = refl
-- p 55
solution is for proof to call itself recursively:
-------------------------
-}
+0 : ∀ (x : ℕ)
→ x + 0 ≡ x
-- BASE
+0 zero = refl -- via definitional equality
-- INDUCTIVE
-- note: name of 'y' variable, if renamed to 'x', is not same as 'x' in signature
+0 (suc y) rewrite +0 y = refl
{- ^
|
'x' in sig instantiated to 'suc y'
so trying to prove (the goal) : suc y + 0 ≡ suc y
goal can be simplified by inductive case of def of _+_
so goal definitionally equal to : suc (y + 0) ≡ suc y
rewrite recursive call proves y + 0 ≡ y
type of proof is x + 0 ≡ x
so Agda with replace occurrences of x + 0 with x
leaving : suc y ≡ suc y
-- p 57
PROOF BY INDUCTION: recursive proofs
------------------------------------------------------------------------------
+ ASSOCIATIVITY
When theorem has multiple variables, must decide which one to use for induction.
Generally: var used where a recursive fun will patten match on it.
If several vars are pattern matched, prefer the one that is matched the most.
Since _+_ matches on 1st arg, then do induction here on 1st arg.
Here 'x' is matched twice but 'y' only once -- so use 'x'.
-}
-------------------------
+assoc : ∀ (x y z : ℕ)
→ x + (y + z)
≡ (x + y) + z
{-
BASE case
goal: zero + (y + z) ≡ (zero + y) + z
via def/eq
-}
+assoc zero y z = refl
{-
INDUCTIVE case
goal : suc (x + (y + z)) ≡ suc ((x + y) + z)
need proof of : (x + (y + z)) ≡ ((x + y) + z)
that is exactly the inductive hypotheses
so use rewrite to recursively apply the proof
-}
+assoc (suc x) y z rewrite +assoc x y z = refl
------------------------------------------------------------------------------
-- p 60 + COMMUTATIVITY (rewrite with multiple equations)
-------------------------
+suc : ∀ (x y : ℕ) → x + (suc y) ≡ suc (x + y)
+suc zero y = refl
+suc (suc x) y rewrite +suc x y = refl
-------------------------
+comm : ∀ (x y : ℕ) → x + y ≡ y + x
{-
BASE
Goal: : y ≡ (y + zero)
so rewrite right hand side using +0 proof
simplifies to : y ≡ y
-}
+comm zero y rewrite +0 y = refl
{-
INDUCTIVE
Goal : suc (x + y) ≡ (y + suc x)
-}
+comm (suc x) y rewrite +suc y x | +comm x y = refl
------------------------------------------------------------------------------
-- p 62 MULTIPLICATION
-------------------------
_*_ : ℕ → ℕ → ℕ
zero * n = zero
suc m * n = n + (m * n)
-------------------------
-- p 63 - right distributivity of * over +
-- variable counts x : 2; y : 1; z : 0 : so use x
*distribr : ∀ (x y z : ℕ)
→ (x + y) * z ≡ (x * z) + (y * z)
-- BASE
*distribr zero y z = refl
{-
INDUCTIVE
Goal: ((suc x + y) * z) ≡ ((suc x * z) + (y * z))
Goal: (z + ((x + y) * z)) ≡ ((z + (x * z)) + (y * z))
*distribr (suc x) y z rewrite *distribr x y z = {!!}
Goal: (z + ((x * z) + (y * z))) ≡ ((z + (x * z)) + (y * z))
right-associated left-associated
so reassociate: to prove
A + (B + C) ≡ (A + B) + C
^ ^ ^
| | |
z | |
x * z |
y * z
-}
*distribr (suc x) y z
rewrite
*distribr x y z
= +assoc z (x * z) (y * z)
------------------------------------------------------------------------------
-- p 65 * COMMUTATIVITY
-------------------------
*0 : ∀ (x : ℕ)
→ x * 0 ≡ 0
-- BASE
*0 zero = refl -- def/eq : (zero * 0) ≡ 0
{-
INDUCTIVE
(suc x * 0) ≡ 0
(x * 0) ≡ 0 -- IH
rewrite
0 ≡ 0
-}
*0 (suc y) rewrite *0 y = refl
-------------------------
*suc : ∀ (x y : ℕ) → x * (suc y) ≡ x + (x * y)
{-
BASE
(zero * suc y) ≡ (zero + (zero * y))
def/eq zero ≡ zero
-}
*suc zero y = refl
{-
INDUCTIVE
(suc x * suc y) ≡ (suc x + (suc x * y))
def/eq suc (y + (x * suc y)) ≡ suc (x + (y + (x * y)))
rw *suc suc (y + (x + (x * y))) ≡ suc (x + (y + (x * y)))
rw +assoc suc ((y + x) + (x * y)) ≡ suc (x + (y + (x * y)))
rw +assoc suc ((y + x) + (x * y)) ≡ suc ((x + y) + (x * y))
rw +comm suc ((x + y) + (x * y)) ≡ suc ((x + y) + (x * y))
-}
*suc (suc x) y
rewrite
*suc x y
| +assoc y x (x * y)
| +assoc x y (x * y)
| +comm y x = refl
-------------------------
*comm : ∀ (x y : ℕ) → x * y ≡ y * x
{-
BASE
(zero * y) ≡ (y * zero)
def/eq zero ≡ (y * zero)
rs *0 zero ≡ zero
-}
*comm zero y rewrite *0 y = refl
{-
INDUCTIVE
(suc x * y) ≡ (y * suc x)
def/eq (y + (x * y)) ≡ (y * suc x)
rw *suc (y + (x * y)) ≡ (y + (y * x))
rw *comm (y + (y * x)) ≡ (y + (y * x))
-}
*comm (suc x) y
rewrite
*suc y x
| *comm x y = refl
------------------------------------------------------------------------------
-- p 66 * ASSOCIATIVITY
*assoc : ∀ (x y z : ℕ) → x * (y * z) ≡ (x * y) * z
{-
BASE
(zero * (y * z)) ≡ ((zero * y) * z)
def/eq zero ≡ zero
-}
*assoc zero y z = refl
{-
INDUCTIVE
(suc x * (y * z)) ≡ ((suc x * y) * z)
def/eq ((y * z) + (x * (y * z))) ≡ ((y + (x * y)) * z)
rw *distribr ((y * z) + (x * (y * z))) ≡ ((y * z) + ((x * y) * z))
rw *assoc ((y * z) + ((x * y) * z)) ≡ ((y * z) + ((x * y) * z))
-}
*assoc (suc x) y z
rewrite
*distribr y (x * y) z
| *assoc x y z = refl
------------------------------------------------------------------------------
-- p 67 LESS-THEN <
_<_ : ℕ → ℕ → 𝔹
0 < 0 = ff
0 < (suc y) = tt
(suc x) < (suc y) = x < y
(suc x) < 0 = ff
-------------------------
-- < is TRANSITIVE
{-
xx : ∀ {x y z : ℕ}
→ x < y
→ y < z
→ x < z
Above will not type check because _<_ returns 𝔹 VALUE, not a type
Types have type Set in Agda -- 𝔹 is not the same as Set.
Could define _<_ as a relation: ℕ → ℕ → Set.
But then _<_ could not be used computationally.
Expressions with type Set describe code -- they are NOT code themselves
- e.g., cannot pattern-match on expressions of type Set
cannot compute with them
Transitivity theorem is statement about behavior of the PROGRAM _<_.
-}
-- p 69
-------------------------
<-0 : ∀ (x : ℕ) → x < 0 ≡ ff
<-0 0 = refl -- (zero < 0) ≡ ff; ff ≡ ff
<-0 (suc y) = refl -- (suc y < 0) ≡ ff; ff ≡ ff
-------------------------
<-trans : ∀ {x y z : ℕ}
→ x < y ≡ tt
→ y < z ≡ tt
→ x < z ≡ tt
{-
p1 : (x < zero) ≡ tt ; p2 : (zero < z) ≡ tt = Goal: (x < z) ≡ tt
rw <-0 p1 : ff ≡ tt ; p2 : (0 < z) ≡ tt = Goal: (x < z) ≡ tt
-}
<-trans {x} {0} p1 p2 rewrite <-0 x = 𝔹-contra p1
-- can't be called like this so no proof needed
<-trans {0} {suc y} {0} p1 ()
-- p1 : (zero < suc y) ≡ tt ; p2 : (suc y < suc z) ≡ tt = Goal: (zero < suc z) ≡ tt
<-trans {0} {suc y} {suc z} p1 p2 = refl
-- can't be called like this so no proof needed
<-trans {suc x} {suc y} {0} p1 ()
-- p1 : (suc x < suc y) ≡ tt; p2 : (suc y < suc z) ≡ tt = Goal: (suc x < suc z) ≡ tt
<-trans {suc x} {suc y} {suc z} p1 p2 = <-trans {x} {y} {z} p1 p2 -- uses IH via recursive call
------------------------------------------------------------------------------
-- p 71 EQUALITY TEST for ℕ
{-
so far, rely on
- def/eq : done automatically during type checking
- ≡ : express, as a TYPE, a proposition that two VALUES are equal
there are other kinds of equality, e,g.,
COMPUTATIONAL EQUALITY : tests VALUE equality
-}
_=ℕ_ : ℕ → ℕ → 𝔹
0 =ℕ 0 = tt
suc x =ℕ suc y = x =ℕ y
_ =ℕ _ = ff
_≤_ : ℕ → ℕ → 𝔹
x ≤ y = (x < y) || x =ℕ y
-------------------------
=ℕ-refl : ∀ (x : ℕ) → (x =ℕ x) ≡ tt
=ℕ-refl 0 = refl
=ℕ-refl (suc x) = (=ℕ-refl x)
-------------------------
-- SOUNDNESS property: things indicated to be true really are true
=ℕ-to-≡ : ∀ {x y : ℕ} → x =ℕ y ≡ tt → x ≡ y
=ℕ-to-≡ {0} {0} _ = refl
=ℕ-to-≡ {suc x} {0} ()
=ℕ-to-≡ {0} {suc y} ()
=ℕ-to-≡ {suc x} {suc y} p
rewrite
=ℕ-to-≡ {x} {y} p = refl
-------------------------
=ℕ-from-≡ : ∀ {x y : ℕ}
→ x ≡ y
→ x =ℕ y ≡ tt
=ℕ-from-≡ {x} refl = =ℕ-refl x
------------------------------------------------------------------------------
-- p 73 EXERCISES
-- 1 nat-thms
--------------------------------------------------
-- properties of addition
--------------------------------------------------
+1 : ∀ (x : ℕ) → x + 1 ≡ suc x
+1 zero = refl
+1 (suc n) rewrite +1 n = refl
+perm : ∀ (x y z : ℕ) → x + (y + z) ≡ y + (x + z)
+perm zero y z = refl
+perm (suc x) y z -- (suc x + (y + z)) ≡ (y + (suc x + z))
-- suc (x + (y + z)) ≡ (y + suc (x + z))
rewrite
+suc y (x + z) -- suc (x + (y + z)) ≡ suc (y + (x + z))
| +assoc x y z -- suc ((x + y) + z) ≡ suc (y + (x + z))
| +comm x y -- suc ((y + x) + z) ≡ suc (y + (x + z))
| +assoc y x z -- suc ((y + x) + z) ≡ suc ((y + x) + z)
= refl
--------------------------------------------------
-- properties of multiplication
--------------------------------------------------
*1 : ∀ {n : ℕ} → n * 1 ≡ n
*1 {zero} = refl
*1 {suc n} -- (suc n * 1) ≡ suc n
-- suc (n * 1) ≡ suc n
rewrite
*comm n 1 -- suc (n + 0) ≡ suc n
| +0 n -- suc n ≡ suc n
= refl
--------------------------------------------------
-- properties of <, ≤, and =ℕ, iszero
--------------------------------------------------
0-≤ : ∀ (x : ℕ) → 0 ≤ x ≡ tt
0-≤ zero = refl
0-≤ (suc n) -- (0 ≤ suc n) ≡ tt
rewrite 0-≤ n -- tt ≡ tt
= refl
=ℕ-sym : ∀ (x y : ℕ) → (x =ℕ y) ≡ (y =ℕ x)
=ℕ-sym zero zero = refl
=ℕ-sym (suc x) zero = refl -- (suc x =ℕ zero) ≡ (zero =ℕ suc x); ff ≡ ff
=ℕ-sym zero (suc y) = refl -- (zero =ℕ suc y) ≡ (suc y =ℕ zero); ff ≡ ff
=ℕ-sym (suc x) (suc y) rewrite =ℕ-sym x y = refl
=ℕ-suc : ∀ (x : ℕ) → suc x =ℕ x ≡ ff
=ℕ-suc zero = refl
=ℕ-suc (suc n) rewrite =ℕ-suc n = refl
<-suc : ∀ (n : ℕ) → n < suc n ≡ tt
<-suc zero = refl
<-suc (suc n) rewrite <-suc n = refl
-- TODO: understand
suc-inj : ∀ {n m : ℕ} → suc n ≡ suc m → n ≡ m
suc-inj {0} {0} _ = refl
suc-inj {m = suc m} refl = refl
<=ℕff : ∀ (x : ℕ) → 0 < x ≡ tt → x =ℕ 0 ≡ ff
<=ℕff (suc x) _ = refl
<≤ : ∀ {n m : ℕ} → n < m ≡ tt → n ≤ m ≡ tt
<≤ {0} {0} _ = refl
<≤ {suc _} {0} ()
<≤ {0} {suc _} _ = refl
<≤ {suc n} {suc m} p rewrite <≤ {n} {m} p = refl
--------------------------------------------------
-- ordering properties of < and ≤ℕ
--------------------------------------------------
<-irrefl : ∀ (n : ℕ) → n < n ≡ ff
<-irrefl zero = refl
<-irrefl (suc n) rewrite <-irrefl n = refl
<-asym : ∀ {x y : ℕ}
→ x < y ≡ tt
→ y < x ≡ ff
<-asym {0} {0} _ = refl
<-asym {0} {suc _} _ = refl
<-asym {suc _} {0} ()
<-asym {suc x} {suc y} p = <-asym {x} {y} p
ℕ-trichotomy𝔹 : ∀ (n m : ℕ) → n < m || n =ℕ m || m < n ≡ tt
ℕ-trichotomy𝔹 0 0 = refl
ℕ-trichotomy𝔹 0 (suc m) = refl
ℕ-trichotomy𝔹 (suc n) 0 = refl
ℕ-trichotomy𝔹 (suc n) (suc m) = ℕ-trichotomy𝔹 n m
<≤-trans : ∀ {x y z : ℕ}
→ x < y ≡ tt
→ y ≤ z ≡ tt
→ x < z ≡ tt
<≤-trans {x} {0} p1 _ rewrite <-0 x = 𝔹-contra p1
<≤-trans {0} {suc y} {0} _ ()
<≤-trans {0} {suc y} {suc z} _ _ = refl
<≤-trans {suc x} {suc y} {0} _ ()
<≤-trans {suc x} {suc y} {suc z} p1 p2 = <≤-trans {x} {y} {z} p1 p2
≤-refl : ∀ (x : ℕ) → x ≤ x ≡ tt
≤-refl zero = refl
≤-refl (suc x) rewrite ≤-refl x = refl
--------------------------------------------------
-- injectivity properties of addition
--------------------------------------------------
+inj1 : ∀ {x y z : ℕ}
→ x + y ≡ x + z
→ y ≡ z
+inj1 {0} {y} {z} p = p
+inj1 {suc x} {y} {z} p = +inj1 {x} {y} {z} (suc-inj p)
+inj2 : ∀ {x y z : ℕ}
→ x + z ≡ y + z
→ x ≡ y
+inj2 {x} {y} {z} p -- p : (x + z) ≡ (y + z); Goal: x ≡ y
rewrite
+comm x z -- p : (z + x) ≡ (y + z); Goal: x ≡ y
| +comm y z -- p : (z + x) ≡ (z + y); Goal: x ≡ y
= +inj1 {z} {x} {y} p -- NOTE: '+inj1'
------------------------------------------------------------------------------
-- 2
{- TODO
nat.agda
>, >= : defined in terms of < and <=
Prove versions of theorems like <-trans and <+
- modified to use _>_ instead of _<_
for practice writing out formulas in Agda
since the proofs can be written just to invoke the theorems dealing with _<_
-}
_>_ : ℕ → ℕ → 𝔹
a > b = b < a
_≥_ : ℕ → ℕ → 𝔹
a ≥ b = b ≤ a
<-trans2 : ∀ {x y z : ℕ}
→ y > x ≡ tt
→ z > y ≡ tt
→ z > x ≡ tt
<-trans2 {x} {y} {z} = <-trans {x} {y} {z}
------------------------------------------------------------------------------
-- 3a
f : (n : ℕ) → ℕ
f 0 = 1
f (suc x) = (suc x) * (f x)
f-is-factorial : f 5 ≡ 120
f-is-factorial = refl
-- 3b
f' : ℕ → 𝔹
fb : ℕ → 𝔹
-- is-odd
f' 0 = ff
f' (suc x) = fb x
-- is-even
fb 0 = tt
fb (suc x) = f' x
f'-is-odd : f' (suc 0) ≡ tt
f'-is-odd = refl
fb-is-even : fb (suc (suc 0)) ≡ tt
fb-is-even = refl
|
src/keyboard.asm | w1jtoo/monster-maze-3d | 0 | 170987 | <reponame>w1jtoo/monster-maze-3d
default_keyboard_handler: dw 0
keyboard_segment: dw 0
init_keyboard:
push es
push bx
push dx
;; getting the info about keyboard handler
mov ax, 0x3509
int 0x21
;; save old handler
mov [default_keyboard_handler], bx
mov [keyboard_segment], es
;; bind new handler
mov ah, 0x25
mov dx, keyboard_handler
int 0x21
pop dx
pop bx
pop es
ret
restore_keyboard:
push dx
push ds
;; getting back to default handler
mov ax, 0x2509
mov dx, [default_keyboard_handler]
mov ds, [keyboard_segment]
int 0x21
pop ds
pop dx
ret
keyboard_handler:
push ax
in al, 0x60 ;; pressed key -> al
cmp al, 0x01 ;; if al == ESC
jne .ret
mov [quit], al ;; then set quit flag
.ret:
mov al, 0x20 ;; else tell the keyboard
out 0x20, al ;; that we handled the interuption
pop ax
iret
|
Asm4Kids/35diagonallines.asm | jacmoe/c64adventures | 17 | 84353 | <reponame>jacmoe/c64adventures
;****************************************
;* *
;* diagonal lines *
;* *
;****************************************
; 10 SYS (49152)
*=$0801
BYTE $0E, $08, $0A, $00, $9E, $20, $28, $34, $39, $31, $35, $32, $29, $00, $00, $00
*=$c000
chrout =$ffd2
clear =$e544
plot =$fff0
jsr clear
ldx #0
ldy #0
lda #18 ; character for inverse
jsr chrout
start clc
jsr plot
lda #32 ; character for space
jsr chrout
inx ; next row
iny
cpx #25 ; is it at the bottom row yet?
bne start ; if not, go back and do it again
rts
|
ada_gui-gnoga-gui-element-canvas.adb | jrcarter/Ada_GUI | 19 | 624 | -- Ada_GUI implementation based on Gnoga. Adapted 2021
-- --
-- GNOGA - The GNU Omnificent GUI for Ada --
-- --
-- G N O G A . G U I . E L E M E N T . C A N V A S --
-- --
-- B o d y --
-- --
-- --
-- Copyright (C) 2014 <NAME> --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are --
-- granted additional permissions described in the GCC Runtime Library --
-- Exception, version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- For more information please go to http://www.gnoga.com --
------------------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Exceptions;
with Ada_GUI.Gnoga.Server.Connection;
package body Ada_GUI.Gnoga.Gui.Element.Canvas is
--------------
-- Finalize --
--------------
overriding
procedure Finalize (Object : in out Context_Type) is
begin
Gnoga.Server.Connection.Execute_Script
(Object.Connection_ID, "delete gnoga['" &
Ada.Strings.Unbounded.To_String (Object.Context_ID) &
"'];");
exception
when E : Gnoga.Server.Connection.Connection_Error =>
Log ("Connection" & Object.Connection_ID'Img &
" error during delete object " &
Ada.Strings.Unbounded.To_String (Object.Context_ID));
Log (Ada.Exceptions.Exception_Information (E));
end Finalize;
------------
-- Create --
------------
procedure Create (Canvas : in out Canvas_Type;
Parent : in out Gnoga.Gui.Base_Type'Class;
Width : in Integer;
Height : in Integer;
ID : in String := "")
is
begin
Canvas.Create_From_HTML (Parent, "<canvas width=" & Width'Img &
" height =" & Height'Img & ">", ID);
end Create;
-------------------
-- Connection_ID --
-------------------
function Connection_ID (Context : Context_Type)
return Gnoga.Connection_ID
is
begin
return Context.Connection_ID;
end Connection_ID;
--------
-- ID --
--------
function ID (Context : Context_Type) return String is
use Ada.Strings.Unbounded;
begin
return To_String (Context.Context_ID);
end ID;
--------------
-- Property --
--------------
procedure Property (Context : in out Context_Type;
Name : in String;
Value : in String)
is
begin
Context.Execute (Name & "='" & Escape_Quotes (Value) & "';");
end Property;
procedure Property (Context : in out Context_Type;
Name : in String;
Value : in Integer)
is
begin
Context.Execute (Name & "=" & Value'Img & ";");
end Property;
procedure Property (Context : in out Context_Type;
Name : in String;
Value : in Boolean)
is
begin
Context.Execute (Name & "=" & Value'Img & ";");
end Property;
procedure Property (Context : in out Context_Type;
Name : in String;
Value : in Float) is
begin
Context.Execute (Name & "=" & Value'Img & ";");
end Property;
function Property (Context : Context_Type; Name : String) return String
is
begin
return Context.Execute (Name);
end Property;
function Property (Context : Context_Type; Name : String) return Integer
is
begin
return Integer'Value (Context.Property (Name));
exception
when E : others =>
Log ("Error Property converting to Integer (forced to 0).");
Log (Ada.Exceptions.Exception_Information (E));
return 0;
end Property;
function Property (Context : Context_Type; Name : String) return Boolean
is
begin
return Boolean'Value (Context.Property (Name));
exception
when E : others =>
Log ("Error Property converting to Boolean (forced to False).");
Log (Ada.Exceptions.Exception_Information (E));
return False;
end Property;
function Property (Context : Context_Type; Name : String) return Float is
begin
return Float'Value (Context.Property (Name));
exception
when E : others =>
Log ("Error Property converting to Float (forced to 0.0).");
Log (Ada.Exceptions.Exception_Information (E));
return 0.0;
end Property;
-------------
-- Execute --
-------------
procedure Execute (Context : in out Context_Type; Method : String) is
begin
Gnoga.Server.Connection.Execute_Script
(ID => Context.Connection_ID,
Script => "gnoga['" & Context.ID & "']." & Method);
end Execute;
function Execute (Context : Context_Type; Method : String)
return String
is
begin
return Gnoga.Server.Connection.Execute_Script
(ID => Context.Connection_ID,
Script => "gnoga['" & Context.ID & "']." & Method);
end Execute;
end Ada_GUI.Gnoga.Gui.Element.Canvas;
|
Sem-4/COA LAB Programs/ASM-Projects/wordHunt.asm | rituraj-iter/ASSIGNMENTS | 10 | 92447 | ; by <NAME>, +923442230949
; 8086 Assembly, emu8086
data segment
; add your data here!
seed dw 2332h
rndnum dw 0
line db 0
column db 0
page_number db 0
word_1 db "ROBERTO$"
word_2 db "HOUSE$"
word_3 db "SCHOOL$"
word_4 db "COMPUTER$"
word_5 db "FRIEND$"
word_pointer dw dup 5 (?)
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
main_loop:
call set_word_pointer
call print_board
mov cx, 5
mov si, 0 ; index for word_pointer
mov di, 0 ; word direction
word_print_loop:
; column
mov dh, 30
mov al, 00011111b
call sort_number
; sort only 30 first columns and multuply by 2, the result is only even columns
mov al, dl
mov bl, 2
mul bl
mov dl, al
mov column, dl
; line
mov dh, 14
mov al, 00011111b
call sort_number
mov line, dl
; print
call print_word
xor di, 00000001b
add si, 2
loop word_print_loop
call end_check
call clear_screen
jmp main_loop
fim:
mov ax, 4c00h ; exit to operating system.
int 21h
sort_number: ; sort a number between 0 and DH; XOR with AL; store in dl
call random
mov dl, byte ptr rndnum
and dl, al
cmp dl, dh
jg sort_number
ret
print_word: ; print word stored in SI; DI:0 = vertical, DI:1 = horizontal
pushf
push ax
push dx
push si
push di
call set_cursor
mov si, word_pointer[si]
do_print_word:
mov ax, ds:[si]
cmp al, "$"
je end_print_word
call print_custon_character
inc si
cmp di, 0
je inc_line
cmp di, 1
je inc_column
return_check_position:
call set_cursor
; if is horizontal, print blanck space
cmp di, 1
je print_blanck_space
return_print_blanck_space:
jmp do_print_word
end_print_word:
pop di
pop si
pop dx
pop ax
popf
ret
inc_line:
inc line
jmp return_check_position
inc_column:
inc column
jmp return_check_position
print_blanck_space:
mov al, " "
call print_custon_character
inc column
call set_cursor
jmp return_print_blanck_space
end_check:
pushf
push ax
mov ah, 1
int 21h
cmp al, "E"
je fim
cmp al, "e"
je fim
pop ax
popf
ret
clear_screen: ; get and set video mode
pushf
push ax
mov ah, 0fh
int 10h
mov ah, 0
int 10h
pop ax
popf
ret
set_word_pointer:
mov word_pointer[0], offset word_1
mov word_pointer[2], offset word_2
mov word_pointer[4], offset word_3
mov word_pointer[6], offset word_4
mov word_pointer[8], offset word_5
ret
print_custon_character: ; print content stored in AL
pushf
push ax
push bx
push cx
mov ah, 09h
mov bh, page_number
mov bl, 10 ; color
mov cx, 1 ;number of times to print
int 10h
pop cx
pop bx
pop ax
popf
ret
print_board:
pushf
push cx
push dx
mov cx, 24 * 40
print_board_loop:
; get new letter
call random
mov dl, byte ptr rndnum
and dl, 00011111b
add dl, "A"
; check if is letter
cmp dl, "A"
jl print_board_loop
cmp dl, "Z"
jg print_board_loop
; print letter
call print_character
mov dl, " "
call print_character
loop print_board_loop
pop dx
pop cx
popf
ret
print_character: ; print character stored in DL
pushf
push ax
mov ah, 2
int 21h
pop ax
popf
ret
random:
pushf
push ax
push cx
push dx
mov ah, 2ch
int 21h
; segundos em dh
; usa tambem cx
mov ax, seed ; ax = seed
add al, dh
mov dx, 8405h ; dx = 8405h
mul dx ; mul (8405h * seed) into dword dx:ax
cmp ax, seed
jnz gotseed ; if new seed = old seed, alter seed
mov ah, dl
inc ax
gotseed:
mov seed, ax ; we have a new seed, so store it
mov ax, dx ; al = random number
mov rndnum, ax
pop dx
pop cx
pop ax
popf
ret
set_cursor:
pushf
push ax
push bx
push dx
mov ah, 2
mov bh, page_number
mov dh, line
mov dl, column
int 10h
pop dx
pop bx
pop ax
popf
ret
ends
end start
|
source/numerics/x86_64/a-nusfge.adb | ytomino/drake | 33 | 2117 | <filename>source/numerics/x86_64/a-nusfge.adb
with Ada.Unchecked_Conversion;
package body Ada.Numerics.SFMT.Generating is
-- SSE2 version
type v4si is array (1 .. 4) of Unsigned_32;
for v4si'Alignment use 16;
pragma Machine_Attribute (v4si, "vector_type");
pragma Machine_Attribute (v4si, "may_alias");
pragma Suppress_Initialization (v4si);
type m128i is array (1 .. 2) of Unsigned_64;
for m128i'Alignment use 16;
pragma Machine_Attribute (m128i, "vector_type");
pragma Machine_Attribute (m128i, "may_alias");
pragma Suppress_Initialization (m128i);
function To_v4si is new Unchecked_Conversion (m128i, v4si);
function To_m128i is new Unchecked_Conversion (v4si, m128i);
function ia32_psrldi128 (A : v4si; B : Integer) return v4si
with Import,
Convention => Intrinsic, External_Name => "__builtin_ia32_psrldi128";
function ia32_pslldi128 (A : v4si; B : Integer) return v4si
with Import,
Convention => Intrinsic, External_Name => "__builtin_ia32_pslldi128";
function mm_srli_si128 (A : m128i; B : Integer) return m128i
with Import,
Convention => Intrinsic, External_Name => "__builtin_ia32_psrldqi128";
function mm_slli_si128 (A : m128i; B : Integer) return m128i
with Import,
Convention => Intrinsic, External_Name => "__builtin_ia32_pslldqi128";
function mm_and_si128 (A, B : m128i) return m128i
with Import,
Convention => Intrinsic, External_Name => "__builtin_ia32_pand128";
function mm_xor_si128 (A, B : m128i) return m128i
with Import,
Convention => Intrinsic, External_Name => "__builtin_ia32_pxor128";
procedure mm_recursion (r : out m128i; a, b, c, d : m128i)
with Convention => Intrinsic;
pragma Inline_Always (mm_recursion);
-- This function represents the recursion formula.
procedure mm_recursion (r : out m128i; a, b, c, d : m128i) is
-- parameters used by sse2.
sse2_param_mask : constant v4si := (MSK1, MSK2, MSK3, MSK4);
v, x, y, z : m128i;
begin
y := To_m128i (ia32_psrldi128 (To_v4si (b), SR1)); -- mm_srli_epi32
z := mm_srli_si128 (c, SR2 * 8);
v := To_m128i (ia32_pslldi128 (To_v4si (d), SL1)); -- mm_slli_epi32
z := mm_xor_si128 (z, a);
z := mm_xor_si128 (z, v);
x := mm_slli_si128 (a, SL2 * 8);
y := mm_and_si128 (y, To_m128i (sse2_param_mask));
z := mm_xor_si128 (z, x);
z := mm_xor_si128 (z, y);
r := z;
end mm_recursion;
-- implementation
-- This function fills the internal state array with pseudorandom
-- integers.
procedure gen_rand_all (
sfmt : in out w128_t_Array_N)
is
i : Integer;
r1, r2 : m128i;
pstate_si : array (0 .. sfmt'Size / 128 - 1) of aliased m128i;
for pstate_si'Address use sfmt'Address;
begin
r1 := pstate_si (N - 2);
r2 := pstate_si (N - 1);
i := 0;
while i < N - POS1 loop
mm_recursion (
pstate_si (i),
pstate_si (i),
pstate_si (i + POS1),
r1,
r2);
r1 := r2;
r2 := pstate_si (i);
i := i + 1;
end loop;
while i < N loop
mm_recursion (
pstate_si (i),
pstate_si (i),
pstate_si (i - (N - POS1)),
r1,
r2);
r1 := r2;
r2 := pstate_si (i);
i := i + 1;
end loop;
end gen_rand_all;
-- This function fills the user-specified array with pseudorandom
-- integers.
procedure gen_rand_array (
sfmt : in out w128_t_Array_N;
Item : in out w128_t_Array_1;
size : Integer)
is
i, j : Integer;
r1, r2 : m128i;
pstate_si : array (0 .. sfmt'Size / 128 - 1) of aliased m128i;
for pstate_si'Address use sfmt'Address;
array_si : array (0 .. size - 1) of aliased m128i;
for array_si'Address use Item'Address;
begin
r1 := pstate_si (N - 2);
r2 := pstate_si (N - 1);
i := 0;
while i < N - POS1 loop
mm_recursion (
array_si (i),
pstate_si (i),
pstate_si (i + POS1),
r1,
r2);
r1 := r2;
r2 := array_si (i);
i := i + 1;
end loop;
while i < N loop
mm_recursion (
array_si (i),
pstate_si (i),
array_si (i - (N - POS1)),
r1,
r2);
r1 := r2;
r2 := array_si (i);
i := i + 1;
end loop;
-- main loop
while i < size - N loop
mm_recursion (
array_si (i),
array_si (i - N),
array_si (i - (N - POS1)),
r1,
r2);
r1 := r2;
r2 := array_si (i);
i := i + 1;
end loop;
j := 0;
while j < N - (size - N) loop
pstate_si (j) := array_si (j + (size - N));
j := j + 1;
end loop;
while i < size loop
mm_recursion (
array_si (i),
array_si (i - N),
array_si (i - (N - POS1)),
r1,
r2);
r1 := r2;
r2 := array_si (i);
pstate_si (j) := array_si (i);
i := i + 1;
j := j + 1;
end loop;
end gen_rand_array;
end Ada.Numerics.SFMT.Generating;
|
misc/mips/add.asm | crunchbang/Higer | 3 | 247830 | <reponame>crunchbang/Higer<gh_stars>1-10
main:
li $t1, 1
add $t0, $t1, 2
li $v0, 10
syscall
|
bb-runtimes/powerpc/gdbstub/gdbstub_io.ads | JCGobbi/Nucleo-STM32G474RE | 0 | 20940 | <reponame>JCGobbi/Nucleo-STM32G474RE
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2010, AdaCore --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
------------------------------------------------------------------------------
package Gdbstub_Io is
-- Very simple interface to character oriented channel (uart, socket...)
procedure Initialize;
-- Initialize this IO subsystem.
function Read_Byte return Character;
-- Wait for the next byte. This is blocking.
-- There is currently no error handling.
procedure Write_Byte (C : Character);
-- Write a byte.
procedure Write_Debug (C : Character);
-- Optionnal output-only debug port.
procedure Kill;
-- Kill the target, ie reboot.
end Gdbstub_Io;
|
NASM/hello.asm | nhutnamhcmus/code | 1 | 94043 | <reponame>nhutnamhcmus/code<gh_stars>1-10
%include "io.inc"
extern _printf
extern _getch
section .data
tb db "Hello world", 0
section .text
global CMAIN
CMAIN:
;write your code here
;xuat tb
;printf("Hello world");
push tb
call _printf
add esp, 4
call _getch
xor eax, eax
ret |
list3/task3/a/src/bubble.adb | luk9400/nsi | 0 | 20809 | <filename>list3/task3/a/src/bubble.adb
package body Bubble with SPARK_Mode is
procedure Sort (A : in out Arr) is
Tmp : Integer;
begin
Outer: for I in reverse A'First .. A'Last - 1 loop
Inner: for J in A'First .. I loop
if A(J) > A(J + 1) then
Tmp := A(J);
A(J) := A(J + 1);
A(J + 1) := Tmp;
end if;
pragma Loop_Invariant (for all K1 in J .. J + 1 => (for some K2 in A'Range => A(K1) = A'Loop_Entry(Inner)(K2)));
pragma Loop_Invariant (Bubbled (A (A'First .. J + 1)));
pragma Loop_Invariant (for all K1 in A'First .. I + 1 => (for some K2 in A'First .. I + 1 => A(K1) = A'Loop_Entry(Inner)(K2)));
pragma Loop_Invariant (for all K in I + 2 .. A'Last => A(K) = A'Loop_Entry(Inner)(K));
end loop Inner;
pragma Loop_Invariant (Sorted (A (I .. A'Last)));
pragma Loop_Invariant (Bubbled (A (A'First .. I + 1)));
end loop Outer;
end Sort;
end Bubble;
|
programs/oeis/131/A131733.asm | neoneye/loda | 22 | 247446 | <filename>programs/oeis/131/A131733.asm
; A131733: Primes (A000040) - odds (A005408).
; 1,0,0,0,2,2,4,4,6,10,10,14,16,16,18,22,26,26,30,32,32,36,38,42,48,50,50,52,52,54,66,68,72,72,80,80,84,88,90,94,98,98,106,106,108,108,118,128,130,130,132,136,136,144,148,152,156,156,160,162,162,170
mov $1,$0
seq $0,40 ; The prime numbers.
mul $1,2
sub $0,$1
sub $0,1
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_21829_1207.asm | ljhsiun2/medusa | 9 | 5789 | .global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r15
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x14366, %rax
nop
nop
nop
add $30615, %rbx
movl $0x61626364, (%rax)
nop
nop
nop
sub $35834, %rsi
lea addresses_UC_ht+0x49e2, %rsi
nop
nop
nop
add %rdx, %rdx
vmovups (%rsi), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $1, %xmm3, %r15
inc %rbx
lea addresses_WT_ht+0x377c, %rax
nop
nop
and $37162, %r13
movb (%rax), %bl
nop
nop
nop
nop
nop
cmp $39256, %rdx
lea addresses_WT_ht+0x16c0e, %rsi
lea addresses_WC_ht+0xdb4e, %rdi
dec %rdx
mov $16, %rcx
rep movsl
cmp $7109, %r15
lea addresses_D_ht+0x588e, %rax
clflush (%rax)
xor %r15, %r15
mov $0x6162636465666768, %rcx
movq %rcx, %xmm0
vmovups %ymm0, (%rax)
nop
nop
nop
nop
nop
and $45334, %r13
lea addresses_UC_ht+0xdae, %rcx
nop
nop
nop
nop
nop
xor %r13, %r13
mov (%rcx), %bx
nop
nop
cmp %rsi, %rsi
lea addresses_WC_ht+0x1128e, %rsi
lea addresses_UC_ht+0x1d98e, %rdi
nop
nop
nop
nop
nop
add %rbx, %rbx
mov $59, %rcx
rep movsw
nop
nop
nop
nop
nop
sub $5464, %rax
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r15
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r8
push %rcx
push %rdi
push %rdx
// Faulty Load
lea addresses_WC+0xea8e, %rdi
nop
sub $65505, %r13
movups (%rdi), %xmm3
vpextrq $0, %xmm3, %rcx
lea oracles, %rdx
and $0xff, %rcx
shlq $12, %rcx
mov (%rdx,%rcx,1), %rcx
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_WC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_WC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 3}}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 2}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'AVXalign': True, 'size': 1, 'NT': True, 'same': False, 'congruent': 1}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 9}}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': True, 'size': 2, 'NT': False, 'same': False, 'congruent': 5}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}}
{'38': 21829}
38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38
*/
|
src/generated/tileset_bdf_h.ads | csb6/libtcod-ada | 0 | 24054 | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;
limited with tileset_h;
package tileset_bdf_h is
-- BSD 3-Clause License
-- *
-- * Copyright © 2008-2021, Jice and the libtcod contributors.
-- * All rights reserved.
-- *
-- * Redistribution and use in source and binary forms, with or without
-- * modification, are permitted provided that the following conditions are met:
-- *
-- * 1. Redistributions of source code must retain the above copyright notice,
-- * this list of conditions and the following disclaimer.
-- *
-- * 2. Redistributions in binary form must reproduce the above copyright notice,
-- * this list of conditions and the following disclaimer in the documentation
-- * and/or other materials provided with the distribution.
-- *
-- * 3. Neither the name of the copyright holder nor the names of its
-- * contributors may be used to endorse or promote products derived from
-- * this software without specific prior written permission.
-- *
-- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- * POSSIBILITY OF SUCH DAMAGE.
--
--*
-- Load a BDF font from a file path.
-- For the best results, you should use a BDF font with a cell-based
-- monospace alignment.
-- May return NULL on failure. See `TCOD_get_error` for the error message.
-- \rst
-- .. versionadded:: 1.16
-- \endrst
--
function TCOD_load_bdf (arg1 : Interfaces.C.Strings.chars_ptr) return access tileset_h.TCOD_Tileset -- tileset_bdf.h:57
with Import => True,
Convention => C,
External_Name => "TCOD_load_bdf";
--*
-- Load a BDF font from memory.
-- `size` is the byte length of `buffer`. `buffer` is the BDF data to load.
-- May return NULL on failure. See `TCOD_get_error` for the error message.
-- \rst
-- .. versionadded:: 1.16
-- \endrst
--
function TCOD_load_bdf_memory (arg1 : int; arg2 : access unsigned_char) return access tileset_h.TCOD_Tileset -- tileset_bdf.h:69
with Import => True,
Convention => C,
External_Name => "TCOD_load_bdf_memory";
-- extern "C"
--*
-- Load a Tileset from a BDF font file.
-- Will throw on an error.
--
-- namespace tcod
end tileset_bdf_h;
|
programs/oeis/027/A027806.asm | neoneye/loda | 22 | 24900 | ; A027806: 30*(n+1)*C(n+4,10).
; 210,2640,17820,85800,330330,1081080,3123120,8168160,19691100,44341440,94225560,190466640,368588220,686439600,1235591280,2157381600,3665097150,6074125200,9842332500,15623407800,24336462150,37255818600,56125648800,83304936000,121949170200,176236220160,251644987440,355296738720,496370443800,686605027680,940903186080,1278053325120,1721588278410,2300801739600,3051945836940,4019635980360,5258492043090,6835048111320,8829966459600,11340595099680,14483912219700,18399905092800,23255435603400,29248649430000,36613991150100,45627893110800,56615211853200,69956492205600,86096145885750,105551638592400,128923787137860,156908276193240,190308512703870,230049945001800,277195983113280,332965666750080,398753238003120,476149786844160,566967149205600,673264249669440,797376093674160,941945627663040,1109958699769920,1304782368489600,1530206822331330,1790491189726800,2090413535480700,2435325357834600,2831210918786250,3284751759689400,3803396774377200,4395438233128800,5070094172757900,5837597590968000,6709292906916600,7697740174684560,8816827562082540,10081892633969520,11509853007034800,13119346971830880,14930884707766830,16967010747807120,19252478381796660,21814436720676600,24682631178395190,27889618164081960,31470994814070240,35465644631651520,39915999942054600,44868322111092480,50373000518240400,56484871318629600,63263557073593800,70773828376020000,79085988644863200,88276283312817600,98427334682326650,109628603777893200,121976880577051500,135576804058417800
mov $1,$0
add $0,10
bin $0,$1
add $1,7
mul $0,$1
mul $0,30
|
Task/Comments/Ada/comments.ada | LaudateCorpus1/RosettaCodeData | 1 | 29561 | -- All Ada comments begin with "--" and extend to the end of the line
|
nondet/even-double-eo.agda | mihanus/curry-agda | 0 | 7113 | <reponame>mihanus/curry-agda
-- Proof of: ∀ (x : ND ℕ) → always (even (double (eo x))) ≡ tt
module even-double-eo where
open import bool
open import nat
open import eq
open import nat-thms
open import nondet
open import nondet-thms
open import functions
----------------------------------------------------------------------
-- A definition of double with addition.
double : ℕ → ℕ
double x = x + x
-- even is a deterministic predicate:
even : ℕ → 𝔹
even zero = tt
even (suc 0) = ff
even (suc (suc x)) = even x
-- eo yields an even and odd number close to the input value:
eo : ℕ → ND ℕ
eo n = Val n ?? Val (suc n)
-- auxiliary property for x+x instead of double:
even-x+x : (x : ℕ) → even (x + x) ≡ tt
even-x+x zero = refl
even-x+x (suc x) rewrite +suc x x | even-x+x x = refl
-- (even (double x)) is always true:
even-double-is-true : ∀ (x : ℕ) → even (double x) ≡ tt
even-double-is-true x rewrite even-x+x x = refl
-- Proof of main result:
even-double-eo-true : (n : ℕ) → always ((even ∘ double) $* (eo n)) ≡ tt
even-double-eo-true n = always-$* (even ∘ double) (eo n) even-double-is-true
-- Alternative statement and proof:
double-eo-satisfy-even : ∀ (n : ℕ) → (double $* (eo n)) satisfy even ≡ tt
double-eo-satisfy-even n
rewrite even-double-is-true n | +suc n n | even-double-is-true n = refl
----------------------------------------------------------------------
|
Cubical/ZCohomology/KcompPrelims.agda | ayberkt/cubical | 0 | 17115 | <filename>Cubical/ZCohomology/KcompPrelims.agda
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.ZCohomology.KcompPrelims where
open import Cubical.ZCohomology.Base
open import Cubical.Homotopy.Connected
open import Cubical.HITs.Hopf
open import Cubical.Homotopy.Freudenthal hiding (encode)
open import Cubical.HITs.Sn
open import Cubical.HITs.S1
open import Cubical.HITs.Truncation renaming (elim to trElim ; rec to trRec ; map to trMap)
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Data.Int renaming (_+_ to +Int)
open import Cubical.Data.Nat hiding (_·_)
open import Cubical.Data.Unit
open import Cubical.HITs.Susp
open import Cubical.HITs.Nullification
open import Cubical.Data.Prod.Base
open import Cubical.Homotopy.Loopspace
open import Cubical.Data.Bool
open import Cubical.Data.Sum.Base
open import Cubical.Data.Sigma hiding (_×_)
open import Cubical.Foundations.Function
open import Cubical.Foundations.Pointed
open import Cubical.HITs.S3
private
variable
ℓ : Level
A : Type ℓ
{- We want to prove that Kn≃ΩKn+1. For this we use the map ϕ-}
ϕ : (pt a : A) → typ (Ω (Susp A , north))
ϕ pt a = (merid a) ∙ sym (merid pt)
private
Kn→ΩKn+1 : (n : ℕ) → coHomK n → typ (Ω (coHomK-ptd (suc n)))
Kn→ΩKn+1 zero x i = ∣ intLoop x i ∣
Kn→ΩKn+1 (suc zero) = trRec (isOfHLevelTrunc 4 ∣ north ∣ ∣ north ∣)
λ a i → ∣ ϕ base a i ∣
Kn→ΩKn+1 (suc (suc n)) = trRec (isOfHLevelTrunc (2 + (3 + n)) ∣ north ∣ ∣ north ∣)
λ a i → ∣ ϕ north a i ∣
d-map : typ (Ω ((Susp S¹) , north)) → S¹
d-map p = subst HopfSuspS¹ p base
d-mapId : (r : S¹) → d-map (ϕ base r) ≡ r
d-mapId r = substComposite HopfSuspS¹ (merid r) (sym (merid base)) base ∙
rotLemma r
where
rotLemma : (r : S¹) → r · base ≡ r
rotLemma base = refl
rotLemma (loop i) = refl
sphereConnectedSpecCase : isConnected 4 (Susp (Susp S¹))
sphereConnectedSpecCase = sphereConnected 3
d-mapComp : Iso (fiber d-map base) (Path (S₊ 3) north north)
d-mapComp = compIso (IsoΣPathTransportPathΣ {B = HopfSuspS¹} _ _)
(congIso (invIso IsoS³TotalHopf))
is1Connected-dmap : isConnectedFun 3 d-map
is1Connected-dmap = toPropElim (λ _ → isPropIsOfHLevel 0)
(isConnectedRetractFromIso 3 d-mapComp
(isOfHLevelRetractFromIso 0 (invIso (PathIdTruncIso 3))
contrHelper))
where
contrHelper : isContr (Path (∥ Susp (Susp S¹) ∥ 4) ∣ north ∣ ∣ north ∣)
fst contrHelper = refl
snd contrHelper = isOfHLevelPlus {n = 0} 2 (sphereConnected 3) ∣ north ∣ ∣ north ∣ refl
d-Iso : Iso (∥ Path (S₊ 2) north north ∥ 3) (coHomK 1)
d-Iso = connectedTruncIso _ d-map is1Connected-dmap
d-mapId2 : Iso.fun d-Iso ∘ trMap (ϕ base) ≡ idfun (coHomK 1)
d-mapId2 = funExt (trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ a i → ∣ d-mapId a i ∣)
Iso∥ϕ₁∥ : Iso (coHomK 1) (∥ Path (S₊ 2) north north ∥ 3)
Iso∥ϕ₁∥ = composesToId→Iso d-Iso (trMap (ϕ base)) d-mapId2
Iso-Kn-ΩKn+1 : (n : HLevel) → Iso (coHomK n) (typ (Ω (coHomK-ptd (suc n))))
Iso-Kn-ΩKn+1 zero = invIso (compIso (congIso (truncIdempotentIso _ isGroupoidS¹)) ΩS¹IsoInt)
Iso-Kn-ΩKn+1 (suc zero) = compIso Iso∥ϕ₁∥ (invIso (PathIdTruncIso 3))
Iso-Kn-ΩKn+1 (suc (suc n)) = compIso (stabSpheres-n≥2 n)
(invIso (PathIdTruncIso (4 + n)))
where
helper : n + (4 + n) ≡ 2 + (n + (2 + n))
helper = +-suc n (3 + n) ∙ (λ i → suc (+-suc n (2 + n) i))
|
peano.agda | alf239/tao | 0 | 5414 | <filename>peano.agda
module Peano where
open import IPL
data ℕ : Set where
zero : ℕ -- Axiom 2.1. 0 is a natural number
_++ : ℕ → ℕ -- Axiom 2.2. If n is a natural number, then n++ is also a natural number
data _≡_ : ℕ → ℕ → Set where
refl : {a : ℕ} → a ≡ a
axiom23 : {n : ℕ} → ¬ (zero ≡ (n ++))
axiom23 = λ ()
axiom24 : {n m : ℕ} → (n ++) ≡ (m ++) → n ≡ m
axiom24 refl = refl
_+_ : ℕ → ℕ → ℕ -- Definition 2.2.1
zero + m = m
(n ++) + m = (n + m) ++
≡-sec : {n m : ℕ} → n ≡ m → (n ++) ≡ (m ++)
≡-sec refl = refl
≡-comm : {n m : ℕ} → n ≡ m → m ≡ n
≡-comm refl = refl
≡-trans : {n m p : ℕ} → n ≡ m → m ≡ p → n ≡ p
≡-trans refl refl = refl
lemma222 : (n : ℕ) → (n + zero) ≡ n
lemma222 zero = refl
lemma222 (n ++) = ≡-sec (lemma222 n)
lemma223 : (n m : ℕ) → (n + (m ++)) ≡ ((n + m) ++)
lemma223 zero m = refl
lemma223 (n ++) m = ≡-sec (lemma223 n m)
-- Addition is commutative
prop224 : (n m : ℕ) → (n + m) ≡ (m + n)
prop224 zero m = ≡-comm (lemma222 m)
prop224 (n ++) m = ≡-trans (≡-sec (prop224 n m)) (≡-comm (lemma223 m n))
-- Addition is associative
prop225 : (a b c : ℕ) → ((a + b) + c) ≡ (a + (b + c))
prop225 zero b c = refl
prop225 (a ++) b c = ≡-sec (prop225 a b c)
-- Cancellation law
prop226 : (a b c : ℕ) → (a + b) ≡ (a + c) → b ≡ c
prop226 zero b c = λ z → z
prop226 (a ++) b c = λ z → (prop226 a b c) (axiom24 z)
|
grammar/ZglLexer.g4 | zg-lang/antlr-zgl | 0 | 7765 | /** ANTLR4 lexer grammar for the Z Graph Language, ZGL. */
lexer grammar ZglLexer;
channels {
WS_CHAN,
COMMENT_CHAN,
CONTINUE_CHAN
}
/*
How does ANTLR decide which lexer rule to apply?
1. The primary goal is to match the lexer rule that recognizes the most input
characters.
2. If more than one lexer rule matches the same input sequence, the priority
goes to the rule occurring first in the grammar file.
3. Nongreedy subrules match the fewest number of characters that still allows
the surrounding lexical rule to match.
Source: https://stackoverflow.com/a/66035710/109618
*/
/**
A block comment (possibly multi-line).
Must occur before Whitespace and LineComment.
*/
BlockComment: '/*' .*? '*/' -> channel(COMMENT_CHAN);
/**
A single-line comment.
Must occur before Whitespace.
*/
LineComment
: '//' ~[\r\n]* '\r'? '\n' -> channel(COMMENT_CHAN)
;
/**
A base64 literal; e.g. b64"YmFk".
Must occur before String and Whitespace.
*/
Base64: [bB] '64"' [A-Za-z0-9+/]* [=]* '"';
/**
A string literal; e.g. "foo".
Must occur before WS and LC.
*/
String: StringPrefix? StringGroup;
/**
A URL
URL = scheme:[//authority]path[?query][#fragment]
This grammar supports these schemes: http, https.
*/
Url: 'http' 's'? '://' UrlChars;
/**
An entity
Examples:
/country/Ireland
/person/Bono
Counter-examples
country/Ireland
Bono
*/
Entity: ('/' Segment)+;
/**
An absolute path.
Examples:
::core
::country::Finland
::org::United_Nations
Counter-examples:
::org::"United Nations"
*/
AbsolutePath: ('::' Segment)+;
/**
A relative (module) path.
Technically, a plain (one segment) path is a relative path. However, this
lexer rule does match a plain path because of the lexical overlap with a
variable.
Examples:
here::there
x::y::z
Counter-examples:
core
::main
::math::constants
no::"quotes"
"no way"
/person/Bono
*/
RelativePath: Segment ('::' Segment)+;
/** The :alias keyword. */
Alias: ':alias';
/** The :use keyword. */
Use: ':use';
/** A tag. */
Tag: '#' Segment;
/**
An RFC 3339 datetime.
Generally follows this pattern:
YYYY-MM-DDTHH:MM:SS<fraction><offset>
Examples: 2012-12-31T13:34:00Z
Counter-examples: 2012-12-31 1776-07-04
*/
DateTime: YMD 'T' HMS Offset;
/**
An RFC 3339 YYYY-MM-DD date.
Examples: 2012-12-31 1776-07-04
Counter-examples: 1950-Jan-2 yesterday tomorrow Apr-2020
*/
Date: YMD;
/** A decimal (base 10) integer. A literal. */
DecimalInteger: [-+]? WholeNumber Exponent?;
/** One or more binary digits. A literal. Numeric. */
BinaryInteger: '0b' [01]+;
/** One or more octal digits. A literal. Numeric. */
OctalInteger: '0o' [0-7]+;
/** One or more hexadecimal digits. A literal. Numeric. */
HexInteger: '0x' HexDigit+;
/**
A floating point number. A literal. Numeric.
Examples:
2.2
1024.
1_024.
365.256_363_004
+2.2
1.2e3
2.34e+4
0.1e-2
-5.
1.e2
Counter-examples:
6
.1
.
04
04.
*/
FloatNumber
: [-+]? WholeNumber '.' WholeNumber? Exponent?
| [-+]? '.' WholeNumber Exponent?
;
// == Boolean tokens ==
// Must occur before the identifier rules.
True: 'true';
False: 'false';
// == One-character tokens ==
// Generally, these belong at the bottom.
// Otherwise, these would conflict with the `Uri` rule.
// == Various delimiters ==
// Must occur after comments and strings.
/** Comma. */
Comma: ',';
/** Colon. */
Colon: ':';
/** Semicolon. */
Semicolon: ';';
/** Plus. */
Concat: '++';
/** Plus. */
Plus: '+';
// == Grouping tokens ==
// Must occur after comments and strings.
/** Left parenthesis / round bracket. */
LeftParen: '(';
/** Right parenthesis / round bracket. */
RightParen: ')';
/** Left square bracket. */
LeftBracket: '[';
/** Right square bracket. */
RightBracket: ']';
/**
The left set delimiter.
The right set delimeter is }, see RightBrace.
*/
HashLeftBrace: '#{';
/** Left curly brace. */
LeftBrace: '{';
/** Right curly brace. */
RightBrace: '}';
/** Left angle bracket / chevron. */
LeftAngle: '<';
/** Right angle bracket / chevron. */
RightAngle: '>';
/** Equal sign. */
Equal: '=';
PlusId: '+' Segment;
/**
A (generic) identifier.
Examples:
x
USA
Counter-examples:
::foo
hi::there
/country/Mexico
*/
Id: Segment;
// Invalid: ~[ \r\t\n;,+()[\]{}<>#]+;
Invalid: ~[ \r\t\n;:,()[\]{}<>#]+;
/**
Whitespace.
Must occur after comments and strings.
*/
Whitespace: [ \r\t\n]+ -> channel(WS_CHAN);
// == Fragment Rules ==
//
// The ordering of fragment rule declarations does _not_ matter;
// however, the order in which they are referenced _does_.
fragment ASCII_Escape
: '\\x' [0-7] HexDigit
| '\\n'
| '\\r'
| '\\t'
| '\\\\'
| '\\0'
;
/** Character escape (inside a string).
Examples: \t \n \r \" \' \\
Counter-examples: \b \q \x
*/
fragment CharacterEscape: '\\' [tnr"'\\];
/**
Two digit day of month.
Examples: 01 02 03 08 09 10 11 23 28 30 31
Counter-examples: 0 32 33
*/
fragment Day: [0-2] [1-9] | '3' [0-1];
/**
An exponent suffix.
Examples: E3 E+3 e-2 e0
Counter-examples: exp7 +3
*/
fragment Exponent: [Ee] [-+]? WholeNumber;
/**
A hexadecimal digit.
Examples: 0 3 9 b C D f
Counter-examples: g G z Z x X
*/
fragment HexDigit: [0-9a-fA-F];
fragment HMS: Hour ':' Minute ':' Second ('.' WholeNumber)?;
/**
Time offest
Examples: -05:00
Counter-examples: +15:00
Regex:
(?:Z
|[-+](?:00|01|02|03|04|05|06|07|08|09|10|11|12|13|14)
:
(?:00|15|30|45))
*/
fragment Offset
: 'Z'
| [-+] ('0' [0-9] | '1' [0-4]) ':' ('00' | '15' | '30' | '45')
;
/*
A two digit hour.
Examples: 00 04 12 13 21 23
Counter-examples: 24 25
*/
fragment Hour: [0-1] [0-9] | '2' [0-3];
/*
A two digit minute.
Examples: 00 08 32 59
Counter-examples: 60 61 99
*/
fragment Minute: [0-5][0-9];
/*
A two digit month number (01 to 12).
Examples: 01 04 09 11 12
Counter-examples: 00 0 1 3 4 13
*/
fragment Month: '0' [1-9] | '1' [0-2];
fragment QuoteEscape: '\\\'' | '\\"' ;
/*
A two digit second.
Examples: 00 08 32 59
Counter-examples: 60 61 99
*/
fragment Second: [0-5][0-9];
/**
A segment.
May be a part of some identifiers and some paths.
Examples: Abe _x Cafe7 hot-dog h0t_dawg
Counter-examples: - _ 71 2nd "xyz"
*/
fragment Segment: [\p{ID_Start}] [\p{ID_Continue}]*;
/**
A string prefix.
Examples: "-e" "-eca" "-ace"
*/
fragment StringPrefix: '-' [ecltaz]+;
fragment StringGroup
: '"' .*? '"'
| '#' StringGroup '#'
;
/**
An escape sequence for use in strings.
Examples: \t \n \r \" \' \\ \u2020
Counter-examples: \q \x
*/
fragment StringEscape: ASCII_Escape | QuoteEscape | UnicodeEscape;
/**
A unicode escape code.
Examples: \u2020
Counter-examples: \uFFF \unicorn unit
*/
fragment UnicodeEscape
: '\\u{' HexDigit (HexDigit (HexDigit (HexDigit (HexDigit HexDigit? )? )? )? )? '}'
;
/** Valid URI characters. */
fragment UrlChars: ~[ \r\t\n]+;
/**
A whole number; i.e. zero or greater.
Examples: 0 1 2 3 8 9 10 11 101 2009
Counter-examples: 00 01 02 0x12
More general than: DayOfMonth, Month, Year
*/
fragment WholeNumber: '0' | [1-9] [_0-9]*;
/**
A four-digit year.
Examples: 1492 1776 2016 2020
Counter-examples: 721 0123 40 0000
More specific than: WholeNum
*/
fragment Year: [1-9] [0-9] [0-9] [0-9];
fragment YMD: Year '-' Month '-' Day;
|
src/game.asm | freem/freem_pong | 1 | 165353 | <gh_stars>1-10
; game code (Main)
;==============================================================================;
; current status: get the game part working first before the damned menu system
;==============================================================================;
; shared defines
DEFAULT_GAME_MAX_SCORE = 5 ; todo: allow this to be configurable in-game
GAME_MIN_SCORE = 5
GAME_MAX_SCORE = 15
BALL_SPEED_START = $11 ; X speed = 1, Y speed = 1
BALL_SPEED_MAX = $99 ; to be determined later
SPEED_Y_ADD_PADDLE_TOPMAX = $02
SPEED_Y_ADD_PADDLE_TOPMID = $01
SPEED_Y_ADD_PADDLE_TOPMIN = $01
SPEED_Y_ADD_PADDLE_BOTMIN = $01
SPEED_Y_ADD_PADDLE_BOTMID = $01
SPEED_Y_ADD_PADDLE_BOTMAX = $02
SPEED_X_ADD_PADDLE = $10
;==============================================================================;
; shared data
; table for use with wall reflection
tbl_BallDir_ReflectY: .byte 0,3,2,1,6,5,4
; tables for use with ball collision
tbl_PaddleDir_SectionTop: .byte 1,6
tbl_PaddleDir_SectionMid: .byte 2,5
tbl_PaddleDir_SectionBot: .byte 3,4
; pointer table for ball direction changes
ptbl_BallDirUpdate:
.addr dummyRTS
.addr game_updateBall_Dir1 ; northeast
.addr game_updateBall_Dir2 ; east
.addr game_updateBall_Dir3 ; southeast
.addr game_updateBall_Dir4 ; southwest
.addr game_updateBall_Dir5 ; west
.addr game_updateBall_Dir6 ; northwest
;==============================================================================;
game_setup:
jsr DRAW_FIELD ; draw field
jsr sound_StopAll ; stop sound
jsr randNum ; poke the random number generator
;-- perform necessary setup --;
; reset scores
lda #0
.ifdef __DEBUGMODE__
sta p1Debug
.endif
sta scoreP1
sta scoreP2
; set default max score
lda #DEFAULT_GAME_MAX_SCORE
sta maxScore
; set default player Y
lda #PADDLE_DEFAULT_Y_POS
sta player1Y
sta player2Y
; set ball variables
ldx #BALL_DEFAULT_X
ldy #BALL_DEFAULT_Y
stx ballX
sty ballY
lda #0
.ifdef __PCE__
sta ballX_Hi
sta ballY_Hi
.endif
sta ballStatus
sta ballDir
lda #$11
sta ballSpeed
; zero out timers
lda #0
sta runTimers
sta timer1
sta timer2
; game not paused
sta gamePaused
; temporary: get the game part working first before the damned menu system
;--------------------------------------------------------------------------;
lda #1
sta inGame
; mainly for trying to debug PCE version
lda #0
sta curServe
jsr game_newServe ; and serve the ball
;--------------------------------------------------------------------------;
jsr randNum ; poke the random number generator
; I'd rather not split this part out, actually.
.ifdef __NES__
; reset PPU address so scrolling doesn't botch up
lda #0
sta PPU_ADDR
sta PPU_ADDR
;-- enable NMIs, put sprites on PPU $1000 --;
lda int_ppuCtrl
ora #%10001000
sta int_ppuCtrl
sta PPU_CTRL
; turn ppu on
lda int_ppuMask
ora #%00011110
sta int_ppuMask
sta PPU_MASK
.else
.ifdef __PCE__
;-- re-enable interrupts --;
lda #1 ; inhibit IRQ2, allow IRQ1 and Timer
sta IRQ_DISABLE
stz IRQ_STATUS
cli
;-- Turn on display --;
st0 #VDCREG_CR
;%0000000011001000/$04C8
lda #<(VDC_CR_VBL|VDC_CR_SPR|VDC_CR_BG|VDC_CR_INC_1)
sta a:VDC_DATA_LO
sta int_vdcCtrl
lda #>(VDC_CR_VBL|VDC_CR_SPR|VDC_CR_BG|VDC_CR_INC_1)
sta a:VDC_DATA_HI
sta int_vdcCtrl+1
.endif
.endif
; execution continues into game loop
;==============================================================================;
; game_MainLoop
; Main loop, which should only be run once...?
game_MainLoop:
jsr UPDATE_SCORE_DISP
; inGame==0 and inGame==1 need to behave differently.
lda inGame
beq game_AttractLoop
bne game_GameLoop
@game_MainLoop_end:
mac_alwaysjump game_MainLoop
;==============================================================================;
; game_AttractLoop
; Attract mode execution loop.
game_AttractLoop:
;-- things to do before vblank --;
jsr INPUT_ATTRACT
;------------------------------------------------------------------------------;
@game_AttractLoop_VBlank:
; wait for vblank
jsr randNum ; poke the random number generator
jsr waitVBlank
;------------------------------------------------------------------------------;
@game_AttractLoop_PostVBlank:
;-- things to do after vblank --;
.ifdef __NES__
jsr ppu_ClearVRAMBuf
.endif
jsr ReadPads
;------------------------------------------------------------------------------;
@game_AttractLoop_end:
mac_alwaysjump game_AttractLoop
;==============================================================================;
; game_GameLoop
; Game mode execution loop.
game_GameLoop:
;-- things to do before vblank --;
jsr game_InputsGame
lda gamePaused
bne @game_GameLoop_VBlank
jsr game_updatePaddles
jsr game_updateBall
lda runTimers
beq @game_GameLoop_VBlank
@game_GameLoop_Timers:
inc timer1
lda timer1
cmp #80
bne @game_GameLoop_VBlank
; ok, timer is done
lda #0
sta timer1
sta timer2
sta runTimers
jsr game_newServe
;------------------------------------------------------------------------------;
@game_GameLoop_VBlank:
; wait for vblank
jsr randNum ; poke the random number generator
jsr waitVBlank
;------------------------------------------------------------------------------;
@game_GameLoop_postVBlank:
;-- things to do after vblank --;
.ifdef __NES__
jsr ppu_ClearVRAMBuf
.endif
jsr ReadPads
;------------------------------------------------------------------------------;
@game_GameLoop_end:
mac_alwaysjump game_GameLoop
;==============================================================================;
; game_startNew
; Starts a new game.
game_startNew:
jsr randNum ; poke the random number generator
;-- initialize game variables --;
; set scores
lda #0
sta scoreP1
sta scoreP2
; set default max score
lda #DEFAULT_GAME_MAX_SCORE
sta maxScore
; set default player Y
lda #PADDLE_DEFAULT_Y_POS
sta player1Y
sta player2Y
; set game as active
lda #1
sta inGame
; set curServe based off of a random value (0/1)
jsr randNum ; poke the random number generator
and #1 ; the extra free throw after a foul in basketball.
sta curServe
jsr game_newServe ; and serve the ball
mac_alwaysjump game_GameLoop ; go back to the game loop.
;==============================================================================;
; game_InputsGame
; Handle controller inputs in game mode.
game_InputsGame:
.ifdef __DEBUGMODE__
lda p1Debug
beq @game_InputsGame_normal
; debugger mode: p1 moves ball
jsr INPUT_DEBUG
jmp @game_InputsGame_p2
.endif
@game_InputsGame_normal:
; controller 1
ldx #0
jsr HANDLE_GAME_INPUT
@game_InputsGame_p2:
; controller 2
ldx #1
jmp HANDLE_GAME_INPUT
;==============================================================================;
; game_updateBall
; Update ball position and other variables. Also renders the ball.
game_updateBall:
lda ballDir
bne @game_updateBall_CheckCollisions
.ifdef __DEBUGMODE__
lda p1Debug
bne @game_updateBall_CheckCollisions
.endif
rts
@game_updateBall_CheckCollisions:
;-- check for collisions --;
; [wall collisions (ballY)]
.ifdef __PCE__
lda ballY_Hi
bne @game_updateBall_CheckWallBottom
.endif
lda ballY
cmp #WALL_TOP
beq @game_updateBall_CollideTopWall
bcs @game_updateBall_CheckWallBottom
@game_updateBall_CollideTopWall:
; collided with top wall; change vertical direction
ldy ballDir
lda tbl_BallDir_ReflectY,y
sta ballDir
; keep ball in-bounds if the speed makes the ball go out of bounds
.ifdef __PCE__
lda ballY_Hi
bne @game_updateBall_CheckWallBottom
.endif
lda ballY
cmp #WALL_TOP
bcs @game_updateBall_CheckWallBottom
@game_updateBall_FixPosition_Top:
; todo: this isn't perfect, but it works for now
lda #WALL_TOP
sta ballY
.ifdef __PCE__
stz ballY_Hi
.endif
jmp @game_updateBall_CheckPaddle
@game_updateBall_CheckWallBottom:
.ifdef __PCE__
lda ballY_Hi
beq @game_updateBall_CheckPaddle
.endif
lda ballY
cmp #WALL_BOT
bcc @game_updateBall_CheckPaddle
@game_updateBall_CollideBotWall:
; collided with bottom wall; change vertical direction
ldy ballDir
lda tbl_BallDir_ReflectY,y
sta ballDir
; keep ball in-bounds if the speed makes the ball go out of bounds
; todo: PCE check
lda ballY
cmp #WALL_BOT
beq @game_updateBall_CheckPaddle
bcs @game_updateBall_FixPosition_Bot
@game_updateBall_FixPosition_Bot:
; todo: this isn't perfect
lda #WALL_BOT
sta ballY
.ifdef __PCE__
lda #WALL_BOT_HI
sta ballY_Hi
.endif
@game_updateBall_CheckPaddle:
; [player collisions (ballX and ballY)]
ldx #0
jsr game_ballToPlayerCollisionCheck
ldx #1
jsr game_ballToPlayerCollisionCheck
; [screen boundaries (ballX)]
@game_updateBall_CheckLeft:
.ifdef __PCE__
lda ballX_Hi
bne @game_updateBall_CheckRight
.endif
lda ballX
cmp #WALL_LEFT
bne @game_updateBall_CheckRight
; P2 scored on P1
lda #0
sta ballDir
; set curServe to player who got scored on
sta curServe
; add point and update score display
inc scoreP2
jsr UPDATE_SCORE_DISP
; set timers
lda #1
sta runTimers
lda #0
sta timer1
sta timer2
jmp game_updateBall_render
@game_updateBall_CheckRight:
.ifdef __PCE__
lda ballX_Hi
cmp #WALL_RIGHT_HI
bne @game_updateBall_move
.endif
lda ballX
cmp #WALL_RIGHT
bne @game_updateBall_move
; P1 scored on P2
lda #0
sta ballDir
; set curServe to player who got scored on
lda #1
sta curServe
; add point and update score display
inc scoreP1
jsr UPDATE_SCORE_DISP
; set timers
lda #1
sta runTimers
lda #0
sta timer1
sta timer2
jmp game_updateBall_render
@game_updateBall_move:
;-- do ball movement --;
; check for direction 0 (ball has passed side)
lda ballDir
beq game_updateBall_render
; ballDir diagram: (numbers go clockwise)
; \---N---/
; | 6 x 1 | Y-1
; W 5 0 2 E ---
; | 4 x 3 | Y+1
; /---S---\
; X-1 | X+1
; (ballSpeed & 0xF0) >> 4 = X speed
; (ballSpeed & 0x0F) = Y speed
lda ballDir
asl
tay
lda ptbl_BallDirUpdate,y
sta tmp00
iny
lda ptbl_BallDirUpdate,y
sta tmp01
.ifdef __NES__
jmp (tmp00)
.else
.ifdef __PCE__
jmp (tmp00+__PCE_ZP_START__)
.endif
.endif
game_updateBall_render:
; on PCE, set the upper part of the X/Y positions
.ifdef __PCE__
lda ballX
beq @game_updateBall_X_Past256
cmp #$FF
beq @game_updateBall_X_Under256
bra @game_updateBall_CheckY
@game_updateBall_X_Past256:
lda #1
sta ballX_Hi
stz ballX
bra @game_updateBall_CheckY
@game_updateBall_X_Under256:
stz ballX_Hi
@game_updateBall_CheckY:
lda ballY
beq @game_updateBall_Y_Past256
cmp #$FF
beq @game_updateBall_Y_Under256
bra game_updateBall_render_real
@game_updateBall_Y_Past256:
lda #1
sta ballY_Hi
bra game_updateBall_render_real
@game_updateBall_Y_Under256:
stz ballY_Hi
.endif
game_updateBall_render_real:
;-- render ball --;
jmp RENDER_BALL
;------------------------------------------------------------------------------;
; game_updateBall_Dir1
; ballDir 1: +X -Y
game_updateBall_Dir1:
; update X
lda ballSpeed
and #$F0
lsr
lsr
lsr
lsr
clc
adc ballX
sta ballX
@game_updateBall_Dir1_UpdateY:
; update Y
lda ballSpeed
and #$0F
sta tmp00
sec
lda ballY
sbc tmp00
sta ballY
@game_updateBall_Dir1_end:
jmp game_updateBall_render
;------------------------------------------------------------------------------;
; game_updateBall_Dir2
; ballDir 2: +X 0Y
game_updateBall_Dir2:
; update X
lda ballSpeed
and #$F0
lsr
lsr
lsr
lsr
clc
adc ballX
sta ballX
; PCE: update ballX_Hi
.ifdef __PCE__
.endif
; don't update Y
@game_updateBall_Dir2_end:
jmp game_updateBall_render
;------------------------------------------------------------------------------;
; game_updateBall_Dir3
; ballDir 3: +X +Y
game_updateBall_Dir3:
; update X
lda ballSpeed
and #$F0
lsr
lsr
lsr
lsr
clc
adc ballX
sta ballX
; PCE: update ballX_Hi
.ifdef __PCE__
.endif
; update Y
lda ballSpeed
and #$0F
clc
adc ballY
sta ballY
; PCE: update ballY_Hi
.ifdef __PCE__
.endif
@game_updateBall_Dir3_end:
jmp game_updateBall_render
;------------------------------------------------------------------------------;
; game_updateBall_Dir4
; ballDir 4: -X +Y
game_updateBall_Dir4:
; update X
lda ballSpeed
and #$F0
lsr
lsr
lsr
lsr
sta tmp00
sec
lda ballX
sbc tmp00
sta ballX
; PCE: update ballX_Hi
.ifdef __PCE__
.endif
; update Y
lda ballSpeed
and #$0F
clc
adc ballY
sta ballY
; PCE: update ballY_Hi
.ifdef __PCE__
.endif
@game_updateBall_Dir4_end:
jmp game_updateBall_render
;------------------------------------------------------------------------------;
; game_updateBall_Dir5
; ballDir 5: -X 0Y
game_updateBall_Dir5:
; update X
lda ballSpeed
and #$F0
lsr
lsr
lsr
lsr
sta tmp00
sec
lda ballX
sbc tmp00
sta ballX
; PCE: update ballX_Hi
.ifdef __PCE__
.endif
; don't update Y
@game_updateBall_Dir5_end:
jmp game_updateBall_render
;------------------------------------------------------------------------------;
; game_updateBall_Dir6
; ballDir 6: -X -Y
game_updateBall_Dir6:
; update X
lda ballSpeed
and #$F0
lsr
lsr
lsr
lsr
sta tmp00
sec
lda ballX
sbc tmp00
sta ballX
; PCE: update ballX_Hi
.ifdef __PCE__
.endif
; update Y
lda ballSpeed
and #$0F
sta tmp00
sec
lda ballY
sbc tmp00
sta ballY
; PCE: update ballY_Hi
.ifdef __PCE__
.endif
@game_updateBall_Dir6_end:
jmp game_updateBall_render
;==============================================================================;
; game_ballToPlayerCollisionCheck
; Checks if the ball has hit the specified player's paddle.
; (Params)
; X - Player number (0=p1, 1=p2)
game_ballToPlayerCollisionCheck:
; compare ballX to BALL_PADDLEX_P1 or BALL_PADDLEX_P2 as needed
; remember to allow some leeway for faster ball speeds
cpx #1
beq @game_ballToPlayerCollisionCheck_CheckP2X
; player 1 X check
.ifdef __PCE__
lda ballX_Hi
beq @game_ballToPlayerCollisionCheck_CheckP1X_Part1
rts
.endif
@game_ballToPlayerCollisionCheck_CheckP1X_Part1:
lda ballX
cmp #BALL_PADDLEX_P1
bcc @game_ballToPlayerCollisionCheck_CheckP1X_Part2
beq @game_ballToPlayerCollisionCheck_CheckP1X_Part2
jmp @game_ballToPlayerCollisionCheck_end
@game_ballToPlayerCollisionCheck_CheckP1X_Part2:
; perform behind P1 check
lda ballX
cmp #BALL_PADDLEX_P1-PADDLE_WIDTH_P1
bcs @game_ballToPlayerCollisionCheck_CheckYMin
jmp @game_ballToPlayerCollisionCheck_end
;------------------------------------------------------------------------------;
@game_ballToPlayerCollisionCheck_CheckP2X:
; player 2 X check
.ifdef __PCE__
lda ballX_Hi
bne @game_ballToPlayerCollisionCheck_CheckP2X_Part3 ; high X > 0: check for behind p2 paddle
.endif
; high X = 0: check for surface
@game_ballToPlayerCollisionCheck_CheckP2X_Part2:
lda ballX
cmp #BALL_PADDLEX_P2
bcs @game_ballToPlayerCollisionCheck_CheckP2X_Part3
jmp @game_ballToPlayerCollisionCheck_end
@game_ballToPlayerCollisionCheck_CheckP2X_Part3:
; perform behind P2 check
.ifdef __PCE__
lda ballX_Hi
bne @game_ballToPlayerCollisionCheck_CheckP2X_Part4
rts
.endif
@game_ballToPlayerCollisionCheck_CheckP2X_Part4:
lda ballX
.ifdef __NES__
cmp #BALL_PADDLEX_P2+PADDLE_WIDTH_P2
.else
.ifdef __PCE__
cmp #PADDLE_WIDTH_P2
.endif
.endif
bcc @game_ballToPlayerCollisionCheck_CheckYMin
beq @game_ballToPlayerCollisionCheck_CheckYMin
jmp @game_ballToPlayerCollisionCheck_end
;------------------------------------------------------------------------------;
@game_ballToPlayerCollisionCheck_CheckYMin:
; compare ballY to player's hitbox
lda ballY
cmp p1HitboxMinY,x
beq @game_ballToPlayerCollisionCheck_CheckYMax
bcs @game_ballToPlayerCollisionCheck_CheckYMax
jmp @game_ballToPlayerCollisionCheck_end
; ball Y is >= to the minimum hitbox, so check for the upper bound.
@game_ballToPlayerCollisionCheck_CheckYMax:
lda ballY
cmp p1HitboxMaxY,x
bcc @game_ballToPlayerCollisionCheck_PaddleSection
beq @game_ballToPlayerCollisionCheck_PaddleSection
jmp @game_ballToPlayerCollisionCheck_end
;------------------------------------------------------------------------------;
@game_ballToPlayerCollisionCheck_PaddleSection:
; at this point, the ball has hit the paddle. check which section.
lda ballY
sec
sbc p1HitboxMinY,x
sta tmp00
; Section 1: 0-3px
cmp #3
bcc @game_ballToPlayerCollisionCheck_DoSection1
beq @game_ballToPlayerCollisionCheck_DoSection1
jmp @game_ballToPlayerCollisionCheck_Section2
@game_ballToPlayerCollisionCheck_DoSection1:
; high angle {(up+left),(up+right)}
lda tbl_PaddleDir_SectionTop,x
sta ballDir
; ballSpeed = (X) | SPEED_Y_ADD_PADDLE_TOPMAX
lda ballSpeed
and #$F0
ora #SPEED_Y_ADD_PADDLE_TOPMAX
sta ballSpeed
jmp @game_ballToPlayerCollisionCheck_end
;------------------------------------------------------------------------------;
@game_ballToPlayerCollisionCheck_Section2:
; Section 2: 4-7px
lda tmp00
cmp #7
bcc @game_ballToPlayerCollisionCheck_DoSection2
beq @game_ballToPlayerCollisionCheck_DoSection2
jmp @game_ballToPlayerCollisionCheck_Section3
@game_ballToPlayerCollisionCheck_DoSection2:
; medium angle {(up+left),(up+right)}
lda tbl_PaddleDir_SectionTop,x
sta ballDir
; ballSpeed = (X) | SPEED_Y_ADD_PADDLE_TOPMID
lda ballSpeed
and #$F0
ora #SPEED_Y_ADD_PADDLE_TOPMID
sta ballSpeed
jmp @game_ballToPlayerCollisionCheck_end
;------------------------------------------------------------------------------;
@game_ballToPlayerCollisionCheck_Section3:
; Section 3: 8-11px
lda tmp00
cmp #11
bcc @game_ballToPlayerCollisionCheck_DoSection3
beq @game_ballToPlayerCollisionCheck_DoSection3
jmp @game_ballToPlayerCollisionCheck_Section4
@game_ballToPlayerCollisionCheck_DoSection3:
; low angle {(up+left),(up+right)}
lda tbl_PaddleDir_SectionTop,x
sta ballDir
; ballSpeed = (X) | SPEED_Y_ADD_PADDLE_TOPMIN
lda ballSpeed
and #$F0
ora #SPEED_Y_ADD_PADDLE_TOPMIN
sta ballSpeed
jmp @game_ballToPlayerCollisionCheck_end
;------------------------------------------------------------------------------;
@game_ballToPlayerCollisionCheck_Section4:
; Section 4: 12-19px
lda tmp00
cmp #19
bcc @game_ballToPlayerCollisionCheck_DoSection4
beq @game_ballToPlayerCollisionCheck_DoSection4
jmp @game_ballToPlayerCollisionCheck_Section5
@game_ballToPlayerCollisionCheck_DoSection4:
; head-on {(left),(right)}
lda tbl_PaddleDir_SectionMid,x
sta ballDir
jmp @game_ballToPlayerCollisionCheck_end
;------------------------------------------------------------------------------;
@game_ballToPlayerCollisionCheck_Section5:
; Section 5: 20-23px
lda tmp00
cmp #23
bcc @game_ballToPlayerCollisionCheck_DoSection5
beq @game_ballToPlayerCollisionCheck_DoSection5
jmp @game_ballToPlayerCollisionCheck_Section6
@game_ballToPlayerCollisionCheck_DoSection5:
; low angle {(down+left),(down+right)}
lda tbl_PaddleDir_SectionBot,x
sta ballDir
; ballSpeed = (X) | SPEED_Y_ADD_PADDLE_BOTMIN
lda ballSpeed
and #$F0
ora #SPEED_Y_ADD_PADDLE_BOTMIN
sta ballSpeed
jmp @game_ballToPlayerCollisionCheck_end
;------------------------------------------------------------------------------;
@game_ballToPlayerCollisionCheck_Section6:
; Section 6: 24-27px
lda tmp00
cmp #27
bcc @game_ballToPlayerCollisionCheck_DoSection6
beq @game_ballToPlayerCollisionCheck_DoSection6
jmp @game_ballToPlayerCollisionCheck_Section7
@game_ballToPlayerCollisionCheck_DoSection6:
; medium angle {(down+left),(down+right)}
lda tbl_PaddleDir_SectionBot,x
sta ballDir
; ballSpeed = (X) | SPEED_Y_ADD_PADDLE_BOTMID
lda ballSpeed
and #$F0
ora #SPEED_Y_ADD_PADDLE_BOTMID
sta ballSpeed
jmp @game_ballToPlayerCollisionCheck_end
;------------------------------------------------------------------------------;
@game_ballToPlayerCollisionCheck_Section7:
; Section 7: 28-31px
lda tmp00
cmp #31
bcc @game_ballToPlayerCollisionCheck_end
beq @game_ballToPlayerCollisionCheck_end
; high angle {(down+left),(down+right)}
lda tbl_PaddleDir_SectionBot,x
sta ballDir
; ballSpeed = (X) | SPEED_Y_ADD_PADDLE_BOTMAX
lda ballSpeed
and #$F0
ora #SPEED_Y_ADD_PADDLE_BOTMAX
sta ballSpeed
;------------------------------------------------------------------------------;
@game_ballToPlayerCollisionCheck_end:
; speed regulation
rts
;==============================================================================;
; game_updatePaddles
; Update paddle variables and renders the paddles.
game_updatePaddles:
; set player hitbox based on current Y position
;-- player 1 hitbox --;
lda player1Y
sta p1HitboxMinY
clc
adc #32
sta p1HitboxMaxY
;-- player 2 hitbox --;
lda player2Y
sta p2HitboxMinY
clc
adc #32
sta p2HitboxMaxY
; render paddle sprites
ldx #0
jsr RENDER_PADDLE
ldx #1
jmp RENDER_PADDLE
;==============================================================================;
; game_newServe
; Serves the ball to a player.
; (called after the timer expires upon scoring a point.)
game_newServe:
; reset ball position to the middle
ldx #BALL_DEFAULT_X
ldy #BALL_DEFAULT_Y
stx ballX
sty ballY
.ifdef __PCE__
lda #0
sta ballX_Hi
sta ballY_Hi
.endif
; after a score, service goes to the player scored upon.
lda curServe
beq @game_newServe_P1
; pick a random direction based on curServe
@game_newServe_P2:
; serve to player 2
jsr randNum
and #3
bne @game_newServe_SetP2
@game_newServe_FixP2:
; in case our random number gives us a 0 after we've ANDed it...
adc #1
@game_newServe_SetP2:
sta ballDir
jmp @game_newServe_SetSpeed
@game_newServe_P1:
; serve to player 1
jsr randNum
and #3
clc
adc #3
sta ballDir
@game_newServe_SetSpeed:
; reset ballSpeed to default start
lda #$11
sta ballSpeed
rts ; and away we go!
;==============================================================================;
; platform specific code and defines
.ifdef __NES__
.include "game_nes.asm"
.else
.ifdef __PCE__
.include "game_pce.asm"
.endif
.endif
|
adium/ASUnitTests/GetChatsAccount.applescript | sin-ivan/AdiumPipeEvent | 0 | 445 | <filename>adium/ASUnitTests/GetChatsAccount.applescript
global HandyAdiumScripts
on run
tell application "Adium"
set newChat to HandyAdiumScripts's makeNewChat()
if (get account of newChat) is not account (HandyAdiumScripts's defaultAccount) then
-- this tests both account's objectSpecifier and chat's account
-- method
close newChat --restore
error
end
close newChat --restore
end tell
end run |
tests/expect/tests/task_switch_test.asm | brenden7158/v86 | 12,700 | 165617 | BITS 32
fadd
hlt
|
Test/random_int-ui.ads | jrcarter/Ada_GUI | 19 | 27785 | -- Ada_GUI version of Random_Int
--
-- Copyright (C) 2021 by PragmAda Software Engineering
--
-- Released under the terms of the 3-Clause BSD License. See https://opensource.org/licenses/BSD-3-Clause
--
-- The (application-specific) user interface
package Random_Int.UI is
type Event_ID is (Generate, Quit);
function Ended return Boolean;
-- Returns True when Next_Event has returned Quit; False otherwise
function Next_Event return Event_ID with Pre => not Ended;
-- Blocks until the next event ia available and returns it
-- If the result is Quit, further calls to operations of this package will raise Program_Error
function Min_Text return String with Pre => not Ended;
function Max_Text return String with Pre => not Ended;
-- Returns the text in the Min and Max input fields
procedure Set_Min (Value : in Integer) with Pre => not Ended;
procedure Set_Max (Value : in Integer) with Pre => not Ended;
-- Sets the text in the Min and Max input fields to Value
procedure Min_Error with Pre => not Ended;
procedure Max_Error with Pre => not Ended;
-- Displays an error message in the Min and Max input fields
procedure Show_Result (Value : in Integer) with Pre => not Ended;
-- Puts a value in the result display field
end Random_Int.UI;
|
i.asm | martianworm17/college-assembly-files | 0 | 19655 | <reponame>martianworm17/college-assembly-files
.model small
.stack
.code
start:
; Start of the background
mov ah, 06h
mov bh, 250
mov ch, 00
mov cl, 00
mov dh, 32
mov dl, 80
int 10h
;Heart
mov ah, 06h
mov bh, 65
mov ch, 5
mov cl, 20
mov dh, 7
mov dl, 28
int 10h
mov ah, 06h
mov bh, 65
mov ch, 4
mov cl, 21
mov dh, 4
mov dl, 23
int 10h
mov ah, 06h
mov bh, 65
mov ch, 4
mov cl, 25
mov dh, 4
mov dl, 27
int 10h
mov ah, 06h
mov bh, 65
mov ch, 8
mov cl, 21
mov dh, 8
mov dl, 27
int 10h
mov ah, 06h
mov bh, 65
mov ch, 9
mov cl, 22
mov dh, 9
mov dl, 26
int 10h
mov ah, 06h
mov bh, 65
mov ch, 10
mov cl, 23
mov dh, 10
mov dl, 25
int 10h
mov ah, 06h
mov bh, 65
mov ch, 11
mov cl, 24
mov dh, 11
mov dl, 24
int 10h
; Start of the letter B
mov ah, 06h
mov bh, 60h
mov ch, 10
mov cl, 10
mov dh, 20
mov dl, 10
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 10
mov cl, 10
mov dh, 10
mov dl, 14
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 11
mov cl, 15
mov dh, 14
mov dl, 15
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 11
mov cl, 15
mov dh, 14
mov dl, 15
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 15
mov cl, 10
mov dh, 15
mov dl, 14
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 16
mov cl, 15
mov dh, 19
mov dl, 15
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 20
mov cl, 10
mov dh, 20
mov dl, 14
int 10h
; Start of the letter R
mov ah, 06h
mov bh, 60h
mov ch, 10
mov cl, 17
mov dh, 20
mov dl, 17
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 10
mov cl, 17
mov dh, 10
mov dl, 21
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 11
mov cl, 22
mov dh, 14
mov dl, 22
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 15
mov cl, 17
mov dh, 15
mov dl, 21
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 16
mov cl, 22
mov dh, 20
mov dl, 22
int 10h
; Start of the letter I
mov ah, 06h
mov bh, 60h
mov ch, 10
mov cl, 26
mov dh, 20
mov dl, 26
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 10
mov cl, 24
mov dh, 10
mov dl, 28
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 20
mov cl, 24
mov dh, 20
mov dl, 28
int 10h
; Start of the letter E
mov ah, 06h
mov bh, 60h
mov ch, 10
mov cl, 30
mov dh, 20
mov dl, 30
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 10
mov cl, 30
mov dh, 10
mov dl, 35
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 15
mov cl, 30
mov dh, 15
mov dl, 34
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 20
mov cl, 30
mov dh, 20
mov dl, 35
int 10h
; Start of the letter L
mov ah, 06h
mov bh, 60h
mov ch, 10
mov cl, 37
mov dh, 20
mov dl, 37
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 20
mov cl, 37
mov dh, 20
mov dl, 42
int 10h
; Start of the letter L
mov ah, 06h
mov bh, 60h
mov ch, 10
mov cl, 44
mov dh, 20
mov dl, 44
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 20
mov cl, 44
mov dh, 20
mov dl, 49
int 10h
; Start of the letter E
mov ah, 06h
mov bh, 60h
mov ch, 10
mov cl, 51
mov dh, 20
mov dl, 51
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 10
mov cl, 51
mov dh, 10
mov dl, 56
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 15
mov cl, 51
mov dh, 15
mov dl, 55
int 10h
mov ah, 06h
mov bh, 60h
mov ch, 20
mov cl, 51
mov dh, 20
mov dl, 56
int 10h
mov ah, 4ch
int 21h
end start |
oap-jpath/src/main/antlr4/JPath.g4 | oaplatform/oap-core | 9 | 31 | <gh_stars>1-10
grammar JPath;
@header {
package oap.jpath;
import java.util.List;
import java.lang.Number;
import java.util.ArrayList;
import oap.util.Pair;
import static oap.util.Pair.__;
}
expr returns [Expression expression]
: '${' {$expression = new Expression(IdentifierType.VARIABLE);} f=variableDeclaratorId {$expression.path.add(new PathNodeField($f.text));} ( '.' n=path {$expression.path.add($n.pathNode);} )* '}'
;
path returns [PathNode pathNode]
: v=variableDeclaratorId {$pathNode = new PathNodeField($v.text); }
| m=method {$pathNode = new PathNodeMethod($m.nameWithParams._1, $m.nameWithParams._2); }
| a=array {$pathNode = new PathNodeArray($a.arrayValue._1, $a.arrayValue._2); }
;
variableDeclaratorId
: identifier
;
array returns [Pair<String,Integer> arrayValue]
: i=identifier '[' n=DecimalIntegerLiteral ']' {$arrayValue = __($i.text, Integer.parseInt($n.text));}
;
method returns [Pair<String,List<Object>> nameWithParams]
: i=identifier '(' p=methodParameters ')' {$nameWithParams = __($i.text, $p.arguments);}
;
methodParameters returns [List<Object> arguments = new ArrayList<Object>()]
:
| mp=methodParameter {$arguments.add($mp.argument);} ( ',' mp2=methodParameter {$arguments.add($mp2.argument);})*
;
methodParameter returns [Object argument]
: s=StringLiteral {$argument = $s.text;}
| di=DecimalIntegerLiteral {$argument = Long.parseLong($di.text);}
;
identifier
: Identifier
;
Identifier
: JavaLetter JavaLetterOrDigit*
;
DecimalIntegerLiteral
: DecimalNumeral
;
fragment
DecimalNumeral
: '0'
| NonZeroDigit (Digits? | Underscores Digits)
;
fragment
Digits
: Digit (DigitsAndUnderscores? Digit)?
;
fragment
Digit
: '0'
| NonZeroDigit
;
fragment
NonZeroDigit
: [1-9]
;
fragment
DigitsAndUnderscores
: DigitOrUnderscore+
;
fragment
DigitOrUnderscore
: Digit
| '_'
;
fragment
Underscores
: '_'+
;
fragment
JavaLetter
: [a-zA-Z$_-] // these are the "java letters" below 0x7F
| // covers all characters above 0x7F which are not a surrogate
~[\u0000-\u007F\uD800-\uDBFF]
{Character.isJavaIdentifierStart(_input.LA(-1))}?
| // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
[\uD800-\uDBFF] [\uDC00-\uDFFF]
{Character.isJavaIdentifierStart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}?
;
fragment
JavaLetterOrDigit
: [a-zA-Z0-9$_-] // these are the "java letters or digits" below 0x7F
| // covers all characters above 0x7F which are not a surrogate
~[\u0000-\u007F\uD800-\uDBFF]
{Character.isJavaIdentifierPart(_input.LA(-1))}?
| // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
[\uD800-\uDBFF] [\uDC00-\uDFFF]
{Character.isJavaIdentifierPart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}?
;
fragment
EscapeSequence
: '\\' [btnfr"'\\]
;
StringLiteral
: '"' StringCharacters? '"' {setText(getText().substring(1, getText().length() - 1));}
;
fragment
StringCharacters
: StringCharacter+
;
fragment
StringCharacter
: ~["\\\r\n]
| EscapeSequence
;
SPACE : (' '|'\n') -> skip;
|
script.scpt | cloutiertyler/iTerm2MutliplePaneSSH | 0 | 881 | <filename>script.scpt
set hostnames to {"hostname1", "hostname2", "hostname3", "hostname4"}
-- launch "iTerm"
tell application "iTerm"
activate
-- ssh in split panes to my queue processor hosts
set myterm to create window with default profile
tell myterm
tell application "System Events" to keystroke "D" using {command down, shift down}
tell application "System Events" to keystroke "[" using command down
set num_hosts to count of hostnames
repeat with n from 1 to num_hosts
if n - 1 is num_hosts / 2 then
tell application "System Events" to keystroke "]" using command down
else if n > 1 then
tell application "System Events" to keystroke "d" using command down
end if
delay 0.5
tell the current session to write text "ssh " & (item n of hostnames)
end repeat
tell application "System Events" to keystroke (key code 36 using command down)
-- tell application "System Events" to keystroke "i" using {command down, option down}
end tell
end tell
|
programs/oeis/167/A167153.asm | neoneye/loda | 22 | 97950 | ; A167153: Numbers not appearing in A167152.
; 10,12,14,16,18,20,22,24,26,28,31,33,35,37,39,41,43,45,47,50,52,54,56,58,60,62,64,66,68,71,73,75,77,79,81,83,85,87,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136
mov $3,$0
mov $4,1
trn $4,$0
mov $1,$4
lpb $0
sub $0,2
trn $0,6
add $2,$1
add $0,$2
add $1,1
trn $0,$1
lpe
lpb $3
add $1,2
sub $3,1
lpe
add $1,9
mov $0,$1
|
programs/oeis/131/A131974.asm | jmorken/loda | 1 | 29724 | ; A131974: Period 8: repeat [1, 2, 3, 4, -5, -4, -3, -2].
; 1,2,3,4,-5,-4,-3,-2,1,2,3,4,-5,-4,-3,-2,1,2,3,4,-5,-4,-3,-2,1,2,3,4,-5,-4,-3,-2,1,2,3,4,-5,-4,-3,-2,1,2,3,4,-5,-4,-3,-2,1,2,3,4,-5,-4,-3,-2,1,2,3,4,-5,-4,-3,-2,1,2,3,4,-5,-4,-3,-2
mov $1,$0
lpb $0
sub $0,$1
mov $3,$0
sub $0,6
mov $2,$1
mov $1,2
add $1,$0
add $2,$3
add $0,$2
add $1,$0
lpe
add $1,1
|
adium/ASUnitTests/GetWindowIndex.applescript | sin-ivan/AdiumPipeEvent | 0 | 1531 | <filename>adium/ASUnitTests/GetWindowIndex.applescript
global HandyAdiumScripts
on run
tell application "Adium"
if (get index of window 1) is not 1 then
--this is also indicative of a much larger problem
--check the sdef for an error with window's 'pidx' property
error
end
end tell
end run |
libsrc/_DEVELOPMENT/arch/zx/display/c/sccz80/zx_cyx2aaddr_callee.asm | teknoplop/z88dk | 0 | 17649 | <gh_stars>0
; void *zx_cyx2aaddr(uchar row, uchar col)
SECTION code_clib
SECTION code_arch
PUBLIC zx_cyx2aaddr_callee, l0_zx_cyx2aaddr_callee
EXTERN asm_zx_cyx2aaddr
zx_cyx2aaddr_callee:
pop af
pop hl
pop de
push af
l0_zx_cyx2aaddr_callee:
ld h,e
jp asm_zx_cyx2aaddr
|
maps/OreburghCity.asm | AtmaBuster/pokecrystal16-493-plus | 1 | 100799 | <gh_stars>1-10
object_const_def ; object_event constants
OreburghCity_MapScripts:
db 0 ; scene scripts
db 0 ; callbacks
OreburghCity_MapEvents:
db 0, 0 ; filler
db 5 ; warp events
warp_event 6, 5, OREBURGH_GATE_1F, 2
warp_event 34, 37, OREBURGH_MINE_B1F, 1
warp_event 35, 37, OREBURGH_MINE_B1F, 1
warp_event 36, 37, OREBURGH_MINE_B1F, 1
warp_event 37, 37, OREBURGH_MINE_B1F, 1
db 0 ; coord events
db 0 ; bg events
db 0 ; object events
|
src/Numeric/Nat/GCD/Extended.agda | lclem/agda-prelude | 0 | 15428 | -- A certified implementation of the extended Euclidian algorithm,
-- which in addition to the gcd also computes the coefficients of
-- Bézout's identity. That is, integers x and y, such that
-- ax + by = gcd a b.
-- See https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
-- for details.
module Numeric.Nat.GCD.Extended where
open import Prelude
open import Control.WellFounded
open import Numeric.Nat.Divide
open import Numeric.Nat.DivMod
open import Numeric.Nat.GCD
open import Tactic.Nat
open import Tactic.Cong
-- Bézout coefficients always have opposite signs, so we can represent
-- a Bézout identity using only natural numbers, keeping track of which
-- coefficient is the positive one.
data BézoutIdentity (d a b : Nat) : Set where
bézoutL : (x y : Nat) → a * x ≡ d + b * y → BézoutIdentity d a b
bézoutR : (x y : Nat) → b * y ≡ d + a * x → BézoutIdentity d a b
-- The result of the extended gcd algorithm is the same as for the normal
-- one plus a BézoutIdentity.
record ExtendedGCD (a b : Nat) : Set where
no-eta-equality
constructor gcd-res
field d : Nat
isGCD : IsGCD d a b
bézout : BézoutIdentity d a b
private
-- This is what the recursive calls compute. At the top we get
-- ExtendedGCD′ a b a b, which we can turn into ExtendedGCD a b.
-- We need this because the correctness of the Bézout coefficients
-- is established going down and the correctness of the gcd going
-- up.
record ExtendedGCD′ (a b r₀ r₁ : Nat) : Set where
no-eta-equality
constructor gcd-res
field d : Nat
isGCD : IsGCD d r₀ r₁
bézout : BézoutIdentity d a b
-- Erasing the proof objects.
eraseBézout : ∀ {a b d} → BézoutIdentity d a b → BézoutIdentity d a b
eraseBézout (bézoutL x y eq) = bézoutL x y (eraseEquality eq)
eraseBézout (bézoutR x y eq) = bézoutR x y (eraseEquality eq)
-- Convert from ExtendedGCD′ as we erase, because why not.
eraseExtendedGCD : ∀ {a b} → ExtendedGCD′ a b a b → ExtendedGCD a b
eraseExtendedGCD (gcd-res d p i) = gcd-res d (eraseIsGCD p) (eraseBézout i)
private
-- The algorithm computes a sequence of coefficients xᵢ and yᵢ (sᵢ and tᵢ on
-- Wikipedia) that terminates in the Bézout coefficients for a and b. The
-- invariant is that they satisfy the Bézout identity for the current remainder.
-- Moreover, at each step they flip sign, so we can represent two consecutive
-- pairs of coefficients as follows.
data BézoutState (a b r₀ r₁ : Nat) : Set where
bézoutLR : ∀ x₀ x₁ y₀ y₁ (eq₀ : a * x₀ ≡ r₀ + b * y₀)
(eq₁ : b * y₁ ≡ r₁ + a * x₁) → BézoutState a b r₀ r₁
bézoutRL : ∀ x₀ x₁ y₀ y₁ (eq₀ : b * y₀ ≡ r₀ + a * x₀)
(eq₁ : a * x₁ ≡ r₁ + b * y₁) → BézoutState a b r₀ r₁
-- In the base case the last remainder is 0, and the second to last is the gcd,
-- so we get the Bézout coefficients from the first components in the state.
getBézoutIdentity : ∀ {d a b} → BézoutState a b d 0 → BézoutIdentity d a b
getBézoutIdentity (bézoutLR x₀ _ y₀ _ eq₀ _) = bézoutL x₀ y₀ eq₀
getBézoutIdentity (bézoutRL x₀ _ y₀ _ eq₀ _) = bézoutR x₀ y₀ eq₀
-- It's important for compile time performance to be strict in the computed
-- coefficients. Can't do a dependent force here due to the proof object. Note
-- that we only have to be strict in x₁ and y₁, since x₀ and y₀ are simply
-- the x₁ and y₁ of the previous state.
forceState : ∀ {a b r₀ r₁} {C : Set} → BézoutState a b r₀ r₁ → (BézoutState a b r₀ r₁ → C) → C
forceState (bézoutLR x₀ x₁ y₀ y₁ eq₀ eq₁) k =
force′ x₁ λ x₁′ eqx → force′ y₁ λ y₁′ eqy →
k (bézoutLR x₀ x₁′ y₀ y₁′ eq₀ (case eqx of λ where refl → case eqy of λ where refl → eq₁))
forceState (bézoutRL x₀ x₁ y₀ y₁ eq₀ eq₁) k =
force′ x₁ λ x₁′ eqx → force′ y₁ λ y₁′ eqy →
k (bézoutRL x₀ x₁′ y₀ y₁′ eq₀ (case eqx of λ where refl → case eqy of λ where refl → eq₁))
-- We're starting of the algorithm with two first remainders being a and b themselves.
-- The corresponding coefficients are x₀, x₁ = 1, 0 and y₀, y₁ = 0, 1.
initialState : ∀ {a b} → BézoutState a b a b
initialState = bézoutLR 1 0 0 1 auto auto
module _ {r₀ r₁ r₂} q where
-- The proof that new coefficients satisfy the invariant.
-- Note alternating sign: x₀ pos, x₁ neg, x₂ pos.
lemma : (a b x₀ x₁ y₀ y₁ : Nat) →
q * r₁ + r₂ ≡ r₀ →
a * x₀ ≡ r₀ + b * y₀ →
b * y₁ ≡ r₁ + a * x₁ →
a * (x₀ + q * x₁) ≡ r₂ + b * (y₀ + q * y₁)
lemma a b x₀ x₁ y₀ y₁ refl eq₀ eq₁ =
a * (x₀ + q * x₁)
≡⟨ by eq₀ ⟩
r₂ + b * y₀ + q * (r₁ + a * x₁)
≡⟨ by-cong eq₁ ⟩
r₂ + b * y₀ + q * (b * y₁)
≡⟨ auto ⟩
r₂ + b * (y₀ + q * y₁) ∎
-- The sequence of coefficients is defined by
-- xᵢ₊₁ = xᵢ₋₁ + q * xᵢ
-- yᵢ₊₁ = yᵢ₋₁ + q * yᵢ
-- where q is defined by the step in the normal Euclidian algorithm
-- rᵢ₊₁ = rᵢ₋₁ + q * rᵢ
bézoutState-step : ∀ {a b} → q * r₁ + r₂ ≡ r₀ → BézoutState a b r₀ r₁ → BézoutState a b r₁ r₂
bézoutState-step {a} {b} eq (bézoutLR x₀ x₁ y₀ y₁ eq₀ eq₁) =
bézoutRL x₁ (x₀ + q * x₁) y₁ (y₀ + q * y₁) eq₁ (lemma a b x₀ x₁ y₀ y₁ eq eq₀ eq₁)
bézoutState-step {a} {b} eq (bézoutRL x₀ x₁ y₀ y₁ eq₀ eq₁) =
bézoutLR x₁ (x₀ + q * x₁) y₁ (y₀ + q * y₁) eq₁ (lemma b a y₀ y₁ x₀ x₁ eq eq₀ eq₁)
extendedGCD-step : ∀ {a b} → q * r₁ + r₂ ≡ r₀ → ExtendedGCD′ a b r₁ r₂ → ExtendedGCD′ a b r₀ r₁
extendedGCD-step eq (gcd-res d p i) = gcd-res d (isGCD-step q eq p) i
private
extendedGCD-acc : {a b : Nat} → (r₀ r₁ : Nat) →
BézoutState a b r₀ r₁ →
Acc _<_ r₁ → ExtendedGCD′ a b r₀ r₁
extendedGCD-acc r₀ zero s _ =
gcd-res r₀ (is-gcd (factor 1 auto) (factor! 0) λ k p _ → p) (getBézoutIdentity s)
extendedGCD-acc r₀ (suc r₁) s (acc wf) =
forceState s λ s → -- make sure to be strict in xᵢ and yᵢ
case r₀ divmod suc r₁ of λ where
(qr q r₂ lt eq) →
extendedGCD-step q eq (extendedGCD-acc (suc r₁) r₂ (bézoutState-step q eq s) (wf r₂ lt))
-- The extended Euclidian algorithm. Easily handles inputs of several hundred digits.
extendedGCD : (a b : Nat) → ExtendedGCD a b
extendedGCD a b = eraseExtendedGCD (extendedGCD-acc a b initialState (wfNat b))
|
game-projects/Sonic2/Objects/TitleScreen/SonicAndTailsIn/SonicAndTailsIn.asm | wide-dot/thomson-to8-game-engine | 11 | 10348 | <reponame>wide-dot/thomson-to8-game-engine
; ---------------------------------------------------------------------------
; Object - SonicAndTailsIn
;
; Display Sonic And Tails In ... message
;
; input REG : [u] pointer to Object Status Table (OST)
; ---------
;
; ---------------------------------------------------------------------------
INCLUDE "./Engine/Macros.asm"
Obj_PaletteFade equ Object_RAM+(object_size*1)
SonicAndTailsIn
lda routine,u
asla
ldx #SATI_Routines
jmp [a,x]
SATI_Routines
fdb SATI_clearScreen
fdb SATI_fadeIn
fdb SATI_fadeOut
fdb SATI_Wait
fdb SATI_End
SATI_clearScreen
ldx #$0000
jsr ClearDataMem
ldd #Img_SonicAndTailsIn
std image_set,u
ldd #$807F
std xy_pixel,u
lda render_flags,u
ora #render_overlay_mask
sta render_flags,u
ldb #1
stb priority,u
inc routine,u
jmp DisplaySprite
SATI_fadeIn
ldx #$0000
jsr ClearDataMem
ldx #Obj_PaletteFade
lda #ObjID_PaletteFade
sta id,x
ldd Cur_palette
std ext_variables,x
ldd #Pal_SonicAndTailsIn
std ext_variables+2,x
inc routine,u
ldd #$0000
std glb_Main_runcount
jmp DisplaySprite
SATI_fadeOut
ldd glb_Main_runcount
cmpd #3*50 ; 3 seconds
beq SATI_fadeOut_continue
rts
SATI_fadeOut_continue
ldx #Obj_PaletteFade
lda #ObjID_PaletteFade
sta id,x
ldd Cur_palette
std ext_variables,x
ldd #Black_palette
std ext_variables+2,x
inc routine,u
rts
SATI_Wait
ldx #Obj_PaletteFade
tst ,x
beq SATI_clearScreen_end
rts
SATI_clearScreen_end
ldx #$FFFF
jsr ClearDataMem
lda $E7DD * set border color
anda #$F0
adda #$01 ; color 1
sta $E7DD
anda #$01 ; color 1
adda #$80
sta glb_screen_border_color+1 * maj WaitVBL
inc routine,u
rts
SATI_End
ldx #$FFFF
jsr ClearDataMem
jsr DeleteObject
_ldd ObjID_TitleScreen,$01 ; Replace this object with Title Screen Object subtype 3
std ,u
ldu #Obj_PaletteFade
jsr ClearObj
rts
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.