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 |
|---|---|---|---|---|
programs/oeis/083/A083330.asm | jmorken/loda | 1 | 6811 | <gh_stars>1-10
; A083330: a(n) = (3*4^n - 2*3^n + 2^n)/2.
; 1,4,17,73,311,1309,5447,22453,91871,373789,1514327,6115333,24636431,99073069,397878407,1596280213,6399436991,25640729149,102691925687,411154861093,1645781181551,6586610462029,26356900104167
mov $1,1
mov $3,6
lpb $0
sub $0,1
add $4,$3
mov $2,$4
mul $2,2
mul $3,2
add $4,$2
lpe
sub $0,$3
add $1,$2
mul $3,$0
sub $0,$1
mul $0,2
sub $0,$3
mov $1,$0
div $1,24
add $1,1
|
AKVIDE v 0.2/Templates/NASM/Demo.asm | KvanTTT/Draft-Projects | 0 | 96800 | <gh_stars>0
org 100h
segment .text
;---------------------------------------------------------------------------------
; insert code here
main:
mov dx, s
mov ah, 9
int 21h
mov ah, 10h
int 16h
call quit
quit:
mov AX, 4C00H
int 21h
ret
;---------------------------------------------------------------------------------
; insert variables here
segment .data
s: db "Enter digit (0..9) for show time, Esc - for exit:", 13, 10, '$'
|
Cubical/HITs/GroupoidTruncation.agda | dan-iel-lee/cubical | 0 | 13172 | <reponame>dan-iel-lee/cubical
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.GroupoidTruncation where
open import Cubical.HITs.GroupoidTruncation.Base public
open import Cubical.HITs.GroupoidTruncation.Properties public
|
setup.scpt | nafeu/nafoodle.io | 1 | 3160 | <reponame>nafeu/nafoodle.io
tell application "iTerm2"
tell current window
create tab with profile "default"
end tell
tell first session of current tab of current window
write text "cd ~/Development/github/nafoodle.io && subl ."
write text "subl $(git diff --name-only HEAD~ HEAD)"
write text "less ~/Development/github/nafoodle.io/devnotes.txt"
split vertically with profile "default"
end tell
tell second session of current tab of current window
write text "nvm use v12.14.1 && npm run dev"
split horizontally with profile "default"
end tell
tell third session of current tab of current window
write text "nvm use v12.14.1 && cd client && npm start"
end tell
end tell |
trie.agda | rfindler/ial | 29 | 3676 | <gh_stars>10-100
module trie where
open import string
open import maybe
open import trie-core public
open import empty
trie-lookup : ∀{A : Set} → trie A → string → maybe A
trie-lookup t s = trie-lookup-h t (string-to-𝕃char s)
trie-insert : ∀{A : Set} → trie A → string → A → trie A
trie-insert t s x = trie-insert-h t (string-to-𝕃char s) x
trie-remove : ∀{A : Set} → trie A → string → trie A
trie-remove t s = trie-remove-h t (string-to-𝕃char s)
open import trie-functions trie-lookup trie-insert trie-remove public
|
src/tests/ascon128_demo.adb | jhumphry/Ascon_SPARK | 1 | 9202 | <filename>src/tests/ascon128_demo.adb
-- Ascon_Demo
-- Copyright (c) 2016-2018, <NAME> - see LICENSE file for details
with Ada.Text_IO;
use Ada.Text_IO;
with System.Storage_Elements;
use System.Storage_Elements;
with Ascon.Utils;
with Ascon128v12;
use Ascon128v12;
procedure Ascon128_Demo is
package Ascon128v12_Utils is new Ascon128v12.Utils;
use Ascon128v12_Utils;
K : Key_Type;
N : Nonce_Type;
A, M, C, M2 : Storage_Array(0..127);
T : Tag_Type;
Valid : Boolean;
begin
Put_Line("Ascon-128 v1.2 Example");
Put_Line("Encrypting and decrypting a message using the high-level API");
New_Line;
-- Setting up example input data
for I in K'Range loop
K(I) := Storage_Element(I);
end loop;
for I in N'Range loop
N(I) := (15 - Storage_Element(I)) * 16;
end loop;
for I in A'Range loop
A(I) := Storage_Element(I);
M(I) := Storage_Element(I);
end loop;
-- Displaying example input data
Put_Line("Key:"); Put_Storage_Array(K);
Put_Line("Nonce:"); Put_Storage_Array(N);
Put_Line("Header and Message (both the same):");
Put_Storage_Array(M);
New_Line;
-- Performing the encryption
Put_Line("Calling AEADEnc");
AEADEnc(K, N, A, M, C, T);
New_Line;
-- Displayng the result of the encryption
Put_Line("Ciphertext:"); Put_Storage_Array(C);
Put_Line("Tag:"); Put_Storage_Array(T);
New_Line;
-- Performing the decryption
Put_Line("Calling AEADDec");
AEADDec(K, N, A, C, T, M2, Valid);
if Valid then
Put_Line("Result of decryption is valid as expected");
else
Put_Line("ERROR - Result of decryption is invalid");
end if;
New_Line;
-- Displaying the result of the decryption
Put_Line("Decrypted message:"); Put_Storage_Array(M2);
New_Line;
-- Corrupting the tag
Put_Line("Now corrupting one bit of the tag");
T(7) := T(7) xor 8;
-- Now checking that decryption with the corrupt tag fails
Put_Line("Calling AEADDec again with the corrupted tag");
AEADDec(K, N, A, C, T, M2, Valid);
if Valid then
Put_Line("ERROR Result of decryption is valid despite the corrupt tag");
else
Put_Line("Result of decryption with corrupt tag is invalid, as expected");
end if;
New_Line;
end Ascon128_Demo;
|
json/src/tools/pretty_print.adb | onox/json-ada | 28 | 14373 | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 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 Ada.Command_Line;
with Ada.Strings.Fixed;
with Ada.Text_IO;
with JSON.Types;
with JSON.Parsers;
with JSON.Streams;
procedure Pretty_Print is
package ACL renames Ada.Command_Line;
package TIO renames Ada.Text_IO;
package Types is new JSON.Types (Long_Integer, Long_Float);
package Parsers is new JSON.Parsers (Types);
type Indent_Type is range 2 .. 8;
procedure Print
(Value : Types.JSON_Value;
Indent : Indent_Type := 4;
Level : Positive := 1)
is
use all type Types.Value_Kind;
use Ada.Strings.Fixed;
Index : Positive := 1;
Spaces : constant Natural := Natural (Indent);
begin
case Value.Kind is
when Object_Kind =>
if Value.Length > 0 then
Ada.Text_IO.Put_Line ("{");
for E of Value loop
if Index > 1 then
Ada.Text_IO.Put_Line (",");
end if;
-- Print key and element
Ada.Text_IO.Put (Spaces * Level * ' ' & E.Image & ": ");
Print (Value (E.Value), Indent, Level + 1);
Index := Index + 1;
end loop;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (Spaces * (Level - 1) * ' ' & "}");
else
Ada.Text_IO.Put ("{}");
end if;
when Array_Kind =>
if Value.Length > 0 then
Ada.Text_IO.Put_Line ("[");
for E of Value loop
if Index > 1 then
Ada.Text_IO.Put_Line (",");
end if;
-- Print element
Ada.Text_IO.Put (Spaces * Level * ' ');
Print (E, Indent, Level + 1);
Index := Index + 1;
end loop;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (Spaces * (Level - 1) * ' ' & "]");
else
Ada.Text_IO.Put ("[]");
end if;
when others =>
Ada.Text_IO.Put (Value.Image);
end case;
end Print;
File_Only : constant Boolean := ACL.Argument_Count = 1;
Is_Quiet : constant Boolean := ACL.Argument_Count = 2 and then ACL.Argument (1) = "-q";
begin
if not (File_Only or Is_Quiet) then
TIO.Put_Line ("Usage: [-q] <path to .json file>");
ACL.Set_Exit_Status (ACL.Failure);
return;
end if;
declare
Parser : Parsers.Parser := Parsers.Create_From_File (ACL.Argument (ACL.Argument_Count));
Value : constant Types.JSON_Value := Parser.Parse;
begin
if not Is_Quiet then
Print (Value, Indent => 4);
end if;
end;
end Pretty_Print;
|
CS61/cs61_labs/lab-5-Kuzame/lab05_ex1.asm | Kuzame/CS61 | 1 | 178997 | ;=================================================
; Name: <NAME>
; Email: <EMAIL>
;
; Lab: lab 4
; Lab section: 24
; TA: <NAME>
;
;=================================================
.orig x3000
;------------
;Instruction
;------------
LD R2, ptr
LD R3, start
LD R4, size
Loop ;
STR R3, R2, #0
ADD R3, R3, #1
ADD R2, R2, #1
ADD R4, R4, #-1
BRp Loop
;Continuation on exercise 3
HALT
;------------
;Local data
;------------
size .FILL #10
start .FILL #0
ptr .FILL x4000
.orig x4000
new_ptr .BLKW #10
.end
|
oeis/205/A205249.asm | neoneye/loda-programs | 11 | 172773 | <reponame>neoneye/loda-programs<gh_stars>10-100
; A205249: Number of (n+1) X 3 0..1 arrays with the number of clockwise edge increases in every 2 X 2 subblock the same.
; 40,168,752,3416,15568,71000,323856,1477272,6738640,30738648,140215952,639602456,2917580368,13308696920,60708323856,276924225432,1263204479440,5762173946328,26284460772752,119897955971096,546920858309968,2494808379607640,11380200181418256,51911384147875992,236796520376543440,1080159833586965208,4927206127181739152,22475710968734765336,102524142589310348368,467669291009082211160,2133298169866790359056,9731152267315787372952,44389164996845356146640,202483520449595205987288,923639272254285317643152
add $0,5
lpb $0
sub $0,1
trn $1,5
add $2,1
add $2,$1
add $1,$2
mul $1,2
lpe
mov $0,$1
|
src/camera/pixy/src/misc/gcc/m0/Release/frame_m0.asm | wowHollis/SmartCart | 0 | 167850 | 1 .syntax unified
2 .cpu cortex-m0
3 .fpu softvfp
4 .eabi_attribute 20, 1
5 .eabi_attribute 21, 1
6 .eabi_attribute 23, 3
7 .eabi_attribute 24, 1
8 .eabi_attribute 25, 1
9 .eabi_attribute 26, 1
10 .eabi_attribute 30, 6
11 .eabi_attribute 34, 0
12 .eabi_attribute 18, 4
13 .thumb
14 .syntax unified
15 .file "frame_m0.c"
16 .text
17 .Ltext0:
18 .cfi_sections .debug_frame
19 .section .text.vsync,"ax",%progbits
20 .align 2
21 .global vsync
22 .code 16
23 .thumb_func
25 vsync:
26 .LFB32:
27 .file 1 "../src/frame_m0.c"
1:../src/frame_m0.c **** //
2:../src/frame_m0.c **** // begin license header
3:../src/frame_m0.c **** //
4:../src/frame_m0.c **** // This file is part of Pixy CMUcam5 or "Pixy" for short
5:../src/frame_m0.c **** //
6:../src/frame_m0.c **** // All Pixy source code is provided under the terms of the
7:../src/frame_m0.c **** // GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html).
8:../src/frame_m0.c **** // Those wishing to use Pixy source code, software and/or
9:../src/frame_m0.c **** // technologies under different licensing terms should contact us at
10:../src/frame_m0.c **** // <EMAIL>. Such licensing terms are available for
11:../src/frame_m0.c **** // all portions of the Pixy codebase presented here.
12:../src/frame_m0.c **** //
13:../src/frame_m0.c **** // end license header
14:../src/frame_m0.c **** //
15:../src/frame_m0.c ****
16:../src/frame_m0.c **** #include "debug_frmwrk.h"
17:../src/frame_m0.c **** #include "chirp.h"
18:../src/frame_m0.c **** #include "frame_m0.h"
19:../src/frame_m0.c ****
20:../src/frame_m0.c **** #define CAM_PCLK_MASK 0x2000
21:../src/frame_m0.c ****
22:../src/frame_m0.c **** #define ALIGN(v, n) ((uint32_t)v&((n)-1) ? ((uint32_t)v&~((n)-1))+(n) : (uint32_t)v)
23:../src/frame_m0.c ****
24:../src/frame_m0.c **** void vsync()
25:../src/frame_m0.c **** {
28 .loc 1 25 0
29 .cfi_startproc
30 0000 80B5 push {r7, lr}
31 .cfi_def_cfa_offset 8
32 .cfi_offset 7, -8
33 .cfi_offset 14, -4
34 0002 82B0 sub sp, sp, #8
35 .cfi_def_cfa_offset 16
36 0004 00AF add r7, sp, #0
37 .cfi_def_cfa_register 7
26:../src/frame_m0.c **** int v = 0, h = 0;
38 .loc 1 26 0
39 0006 0023 movs r3, #0
40 0008 7B60 str r3, [r7, #4]
41 000a 0023 movs r3, #0
42 000c 3B60 str r3, [r7]
43 .L8:
27:../src/frame_m0.c ****
28:../src/frame_m0.c **** while(1)
29:../src/frame_m0.c **** {
30:../src/frame_m0.c **** h = 0;
44 .loc 1 30 0
45 000e 0023 movs r3, #0
46 0010 3B60 str r3, [r7]
31:../src/frame_m0.c **** while(CAM_VSYNC()!=0);
47 .loc 1 31 0
48 0012 C046 nop
49 .L2:
50 .loc 1 31 0 is_stmt 0 discriminator 1
51 0014 134A ldr r2, .L11
52 0016 144B ldr r3, .L11+4
53 0018 D258 ldr r2, [r2, r3]
54 001a 8023 movs r3, #128
55 001c 5B01 lsls r3, r3, #5
56 001e 1340 ands r3, r2
57 0020 F8D1 bne .L2
58 .L7:
32:../src/frame_m0.c **** while(1) // vsync low
33:../src/frame_m0.c **** {
34:../src/frame_m0.c **** while(CAM_HSYNC()==0)
59 .loc 1 34 0 is_stmt 1
60 0022 06E0 b .L3
61 .L5:
35:../src/frame_m0.c **** {
36:../src/frame_m0.c **** if (CAM_VSYNC()!=0)
62 .loc 1 36 0
63 0024 0F4A ldr r2, .L11
64 0026 104B ldr r3, .L11+4
65 0028 D258 ldr r2, [r2, r3]
66 002a 8023 movs r3, #128
67 002c 5B01 lsls r3, r3, #5
68 002e 1340 ands r3, r2
69 0030 12D1 bne .L10
70 .L3:
34:../src/frame_m0.c **** {
71 .loc 1 34 0
72 0032 0C4A ldr r2, .L11
73 0034 0C4B ldr r3, .L11+4
74 0036 D258 ldr r2, [r2, r3]
75 0038 8023 movs r3, #128
76 003a 1B01 lsls r3, r3, #4
77 003c 1340 ands r3, r2
78 003e F1D0 beq .L5
37:../src/frame_m0.c **** goto end;
38:../src/frame_m0.c **** }
39:../src/frame_m0.c **** while(CAM_HSYNC()!=0); //grab data
79 .loc 1 39 0
80 0040 C046 nop
81 .L6:
82 .loc 1 39 0 is_stmt 0 discriminator 1
83 0042 084A ldr r2, .L11
84 0044 084B ldr r3, .L11+4
85 0046 D258 ldr r2, [r2, r3]
86 0048 8023 movs r3, #128
87 004a 1B01 lsls r3, r3, #4
88 004c 1340 ands r3, r2
89 004e F8D1 bne .L6
40:../src/frame_m0.c **** h++;
90 .loc 1 40 0 is_stmt 1
91 0050 3B68 ldr r3, [r7]
92 0052 0133 adds r3, r3, #1
93 0054 3B60 str r3, [r7]
41:../src/frame_m0.c **** }
94 .loc 1 41 0
95 0056 E4E7 b .L7
96 .L10:
37:../src/frame_m0.c **** goto end;
97 .loc 1 37 0
98 0058 C046 nop
99 .L4:
42:../src/frame_m0.c **** end:
43:../src/frame_m0.c **** v++;
100 .loc 1 43 0
101 005a 7B68 ldr r3, [r7, #4]
102 005c 0133 adds r3, r3, #1
103 005e 7B60 str r3, [r7, #4]
44:../src/frame_m0.c **** //if (v%25==0)
45:../src/frame_m0.c **** //printf("%d %d\n", v, h);
46:../src/frame_m0.c **** }
104 .loc 1 46 0
105 0060 D5E7 b .L8
106 .L12:
107 0062 C046 .align 2
108 .L11:
109 0064 00400F40 .word 1074741248
110 0068 04210000 .word 8452
111 .cfi_endproc
112 .LFE32:
114 .section .text.syncM0,"ax",%progbits
115 .align 2
116 .global syncM0
117 .code 16
118 .thumb_func
120 syncM0:
121 .LFB33:
47:../src/frame_m0.c **** }
48:../src/frame_m0.c ****
49:../src/frame_m0.c ****
50:../src/frame_m0.c **** void syncM0(uint32_t *gpioIn, uint32_t clkMask)
51:../src/frame_m0.c **** {
122 .loc 1 51 0
123 .cfi_startproc
124 0000 80B5 push {r7, lr}
125 .cfi_def_cfa_offset 8
126 .cfi_offset 7, -8
127 .cfi_offset 14, -4
128 0002 82B0 sub sp, sp, #8
129 .cfi_def_cfa_offset 16
130 0004 00AF add r7, sp, #0
131 .cfi_def_cfa_register 7
132 0006 7860 str r0, [r7, #4]
133 0008 3960 str r1, [r7]
52:../src/frame_m0.c **** asm(".syntax unified");
134 .loc 1 52 0
135 .syntax divided
136 @ 52 "../src/frame_m0.c" 1
137 .syntax unified
138 @ 0 "" 2
53:../src/frame_m0.c ****
54:../src/frame_m0.c **** asm("PUSH {r4}");
139 .loc 1 54 0
140 @ 54 "../src/frame_m0.c" 1
141 000a 10B4 PUSH {r4}
142 @ 0 "" 2
55:../src/frame_m0.c ****
56:../src/frame_m0.c **** asm("start:");
143 .loc 1 56 0
144 @ 56 "../src/frame_m0.c" 1
145 start:
146 @ 0 "" 2
57:../src/frame_m0.c **** // This sequence can be extended to reduce probability of false phase detection.
58:../src/frame_m0.c **** // This routine acts as a "sieve", only letting a specific phase through.
59:../src/frame_m0.c **** // In practice, 2 different phases separated by 1 clock are permitted through
60:../src/frame_m0.c **** // which is acceptable-- 5ns in a 30ns period.
61:../src/frame_m0.c **** // If the pixel clock is shifted 1/2 a cpu clock period (or less), with respect to the CPU clock,
62:../src/frame_m0.c **** // If the pixel clock is perfectly in line with the cpu clock, 1 phase will match.
63:../src/frame_m0.c **** // Worst case will aways be 2 possible phases.
64:../src/frame_m0.c **** // It takes between 50 and 200 cpu clock cycles to complete.
65:../src/frame_m0.c **** asm("LDR r2, [r0]"); // high
147 .loc 1 65 0
148 @ 65 "../src/frame_m0.c" 1
149 000c 0268 LDR r2, [r0]
150 @ 0 "" 2
66:../src/frame_m0.c **** asm("NOP");
151 .loc 1 66 0
152 @ 66 "../src/frame_m0.c" 1
153 000e C046 NOP
154 @ 0 "" 2
67:../src/frame_m0.c **** asm("LDR r3, [r0]"); // low
155 .loc 1 67 0
156 @ 67 "../src/frame_m0.c" 1
157 0010 0368 LDR r3, [r0]
158 @ 0 "" 2
68:../src/frame_m0.c **** asm("BICS r2, r3");
159 .loc 1 68 0
160 @ 68 "../src/frame_m0.c" 1
161 0012 9A43 BICS r2, r3
162 @ 0 "" 2
69:../src/frame_m0.c **** asm("LDR r3, [r0]"); // high
163 .loc 1 69 0
164 @ 69 "../src/frame_m0.c" 1
165 0014 0368 LDR r3, [r0]
166 @ 0 "" 2
70:../src/frame_m0.c **** asm("ANDS r3, r2");
167 .loc 1 70 0
168 @ 70 "../src/frame_m0.c" 1
169 0016 1340 ANDS r3, r2
170 @ 0 "" 2
71:../src/frame_m0.c **** asm("LDR r2, [r0]"); // low
171 .loc 1 71 0
172 @ 71 "../src/frame_m0.c" 1
173 0018 0268 LDR r2, [r0]
174 @ 0 "" 2
72:../src/frame_m0.c **** asm("LDR r4, [r0]"); // high
175 .loc 1 72 0
176 @ 72 "../src/frame_m0.c" 1
177 001a 0468 LDR r4, [r0]
178 @ 0 "" 2
73:../src/frame_m0.c **** asm("BICS r4, r2");
179 .loc 1 73 0
180 @ 73 "../src/frame_m0.c" 1
181 001c 9443 BICS r4, r2
182 @ 0 "" 2
74:../src/frame_m0.c **** asm("LDR r2, [r0]"); // low
183 .loc 1 74 0
184 @ 74 "../src/frame_m0.c" 1
185 001e 0268 LDR r2, [r0]
186 @ 0 "" 2
75:../src/frame_m0.c **** asm("BICS r4, r2");
187 .loc 1 75 0
188 @ 75 "../src/frame_m0.c" 1
189 0020 9443 BICS r4, r2
190 @ 0 "" 2
76:../src/frame_m0.c **** asm("LDR r2, [r0]"); // high
191 .loc 1 76 0
192 @ 76 "../src/frame_m0.c" 1
193 0022 0268 LDR r2, [r0]
194 @ 0 "" 2
77:../src/frame_m0.c **** asm("ANDS r4, r2");
195 .loc 1 77 0
196 @ 77 "../src/frame_m0.c" 1
197 0024 1440 ANDS r4, r2
198 @ 0 "" 2
78:../src/frame_m0.c **** asm("LDR r2, [r0]"); // low
199 .loc 1 78 0
200 @ 78 "../src/frame_m0.c" 1
201 0026 0268 LDR r2, [r0]
202 @ 0 "" 2
79:../src/frame_m0.c ****
80:../src/frame_m0.c **** asm("BICS r4, r2");
203 .loc 1 80 0
204 @ 80 "../src/frame_m0.c" 1
205 0028 9443 BICS r4, r2
206 @ 0 "" 2
81:../src/frame_m0.c **** asm("ANDS r4, r3");
207 .loc 1 81 0
208 @ 81 "../src/frame_m0.c" 1
209 002a 1C40 ANDS r4, r3
210 @ 0 "" 2
82:../src/frame_m0.c ****
83:../src/frame_m0.c **** asm("TST r4, r1");
211 .loc 1 83 0
212 @ 83 "../src/frame_m0.c" 1
213 002c 0C42 TST r4, r1
214 @ 0 "" 2
84:../src/frame_m0.c **** asm("BEQ start");
215 .loc 1 84 0
216 @ 84 "../src/frame_m0.c" 1
217 002e EDD0 BEQ start
218 @ 0 "" 2
85:../src/frame_m0.c ****
86:../src/frame_m0.c **** // in-phase begins here
87:../src/frame_m0.c **** asm("POP {r4}");
219 .loc 1 87 0
220 @ 87 "../src/frame_m0.c" 1
221 0030 10BC POP {r4}
222 @ 0 "" 2
88:../src/frame_m0.c ****
89:../src/frame_m0.c **** asm(".syntax divided");
223 .loc 1 89 0
224 @ 89 "../src/frame_m0.c" 1
225 .syntax divided
226 @ 0 "" 2
90:../src/frame_m0.c **** }
227 .loc 1 90 0
228 .thumb
229 .syntax unified
230 0032 C046 nop
231 0034 BD46 mov sp, r7
232 0036 02B0 add sp, sp, #8
233 @ sp needed
234 0038 80BD pop {r7, pc}
235 .cfi_endproc
236 .LFE33:
238 003a C046 .section .text.syncM1,"ax",%progbits
239 .align 2
240 .global syncM1
241 .code 16
242 .thumb_func
244 syncM1:
245 .LFB34:
91:../src/frame_m0.c ****
92:../src/frame_m0.c ****
93:../src/frame_m0.c **** void syncM1(uint32_t *gpioIn, uint32_t clkMask)
94:../src/frame_m0.c **** {
246 .loc 1 94 0
247 .cfi_startproc
248 0000 80B5 push {r7, lr}
249 .cfi_def_cfa_offset 8
250 .cfi_offset 7, -8
251 .cfi_offset 14, -4
252 0002 82B0 sub sp, sp, #8
253 .cfi_def_cfa_offset 16
254 0004 00AF add r7, sp, #0
255 .cfi_def_cfa_register 7
256 0006 7860 str r0, [r7, #4]
257 0008 3960 str r1, [r7]
95:../src/frame_m0.c **** asm(".syntax unified");
258 .loc 1 95 0
259 .syntax divided
260 @ 95 "../src/frame_m0.c" 1
261 .syntax unified
262 @ 0 "" 2
96:../src/frame_m0.c ****
97:../src/frame_m0.c **** asm("PUSH {r4}");
263 .loc 1 97 0
264 @ 97 "../src/frame_m0.c" 1
265 000a 10B4 PUSH {r4}
266 @ 0 "" 2
98:../src/frame_m0.c ****
99:../src/frame_m0.c **** asm("startSyncM1:");
267 .loc 1 99 0
268 @ 99 "../src/frame_m0.c" 1
269 startSyncM1:
270 @ 0 "" 2
100:../src/frame_m0.c **** asm("LDR r2, [r0]"); // high
271 .loc 1 100 0
272 @ 100 "../src/frame_m0.c" 1
273 000c 0268 LDR r2, [r0]
274 @ 0 "" 2
101:../src/frame_m0.c **** asm("NOP");
275 .loc 1 101 0
276 @ 101 "../src/frame_m0.c" 1
277 000e C046 NOP
278 @ 0 "" 2
102:../src/frame_m0.c **** asm("NOP");
279 .loc 1 102 0
280 @ 102 "../src/frame_m0.c" 1
281 0010 C046 NOP
282 @ 0 "" 2
103:../src/frame_m0.c **** asm("NOP");
283 .loc 1 103 0
284 @ 103 "../src/frame_m0.c" 1
285 0012 C046 NOP
286 @ 0 "" 2
104:../src/frame_m0.c **** asm("NOP");
287 .loc 1 104 0
288 @ 104 "../src/frame_m0.c" 1
289 0014 C046 NOP
290 @ 0 "" 2
105:../src/frame_m0.c **** asm("LDR r3, [r0]"); // low
291 .loc 1 105 0
292 @ 105 "../src/frame_m0.c" 1
293 0016 0368 LDR r3, [r0]
294 @ 0 "" 2
106:../src/frame_m0.c **** asm("BICS r2, r3");
295 .loc 1 106 0
296 @ 106 "../src/frame_m0.c" 1
297 0018 9A43 BICS r2, r3
298 @ 0 "" 2
107:../src/frame_m0.c **** asm("NOP");
299 .loc 1 107 0
300 @ 107 "../src/frame_m0.c" 1
301 001a C046 NOP
302 @ 0 "" 2
108:../src/frame_m0.c **** asm("NOP");
303 .loc 1 108 0
304 @ 108 "../src/frame_m0.c" 1
305 001c C046 NOP
306 @ 0 "" 2
109:../src/frame_m0.c **** asm("NOP");
307 .loc 1 109 0
308 @ 109 "../src/frame_m0.c" 1
309 001e C046 NOP
310 @ 0 "" 2
110:../src/frame_m0.c **** asm("LDR r3, [r0]"); // high
311 .loc 1 110 0
312 @ 110 "../src/frame_m0.c" 1
313 0020 0368 LDR r3, [r0]
314 @ 0 "" 2
111:../src/frame_m0.c **** asm("ANDS r3, r2");
315 .loc 1 111 0
316 @ 111 "../src/frame_m0.c" 1
317 0022 1340 ANDS r3, r2
318 @ 0 "" 2
112:../src/frame_m0.c **** asm("NOP");
319 .loc 1 112 0
320 @ 112 "../src/frame_m0.c" 1
321 0024 C046 NOP
322 @ 0 "" 2
113:../src/frame_m0.c **** asm("NOP");
323 .loc 1 113 0
324 @ 113 "../src/frame_m0.c" 1
325 0026 C046 NOP
326 @ 0 "" 2
114:../src/frame_m0.c **** asm("NOP");
327 .loc 1 114 0
328 @ 114 "../src/frame_m0.c" 1
329 0028 C046 NOP
330 @ 0 "" 2
115:../src/frame_m0.c **** asm("LDR r2, [r0]"); // low
331 .loc 1 115 0
332 @ 115 "../src/frame_m0.c" 1
333 002a 0268 LDR r2, [r0]
334 @ 0 "" 2
116:../src/frame_m0.c **** asm("LDR r4, [r0]"); // high
335 .loc 1 116 0
336 @ 116 "../src/frame_m0.c" 1
337 002c 0468 LDR r4, [r0]
338 @ 0 "" 2
117:../src/frame_m0.c **** asm("BICS r4, r2");
339 .loc 1 117 0
340 @ 117 "../src/frame_m0.c" 1
341 002e 9443 BICS r4, r2
342 @ 0 "" 2
118:../src/frame_m0.c **** asm("NOP");
343 .loc 1 118 0
344 @ 118 "../src/frame_m0.c" 1
345 0030 C046 NOP
346 @ 0 "" 2
119:../src/frame_m0.c **** asm("NOP");
347 .loc 1 119 0
348 @ 119 "../src/frame_m0.c" 1
349 0032 C046 NOP
350 @ 0 "" 2
120:../src/frame_m0.c **** asm("NOP");
351 .loc 1 120 0
352 @ 120 "../src/frame_m0.c" 1
353 0034 C046 NOP
354 @ 0 "" 2
121:../src/frame_m0.c **** asm("LDR r2, [r0]"); // low
355 .loc 1 121 0
356 @ 121 "../src/frame_m0.c" 1
357 0036 0268 LDR r2, [r0]
358 @ 0 "" 2
122:../src/frame_m0.c **** asm("BICS r4, r2");
359 .loc 1 122 0
360 @ 122 "../src/frame_m0.c" 1
361 0038 9443 BICS r4, r2
362 @ 0 "" 2
123:../src/frame_m0.c **** asm("NOP");
363 .loc 1 123 0
364 @ 123 "../src/frame_m0.c" 1
365 003a C046 NOP
366 @ 0 "" 2
124:../src/frame_m0.c **** asm("NOP");
367 .loc 1 124 0
368 @ 124 "../src/frame_m0.c" 1
369 003c C046 NOP
370 @ 0 "" 2
125:../src/frame_m0.c **** asm("NOP");
371 .loc 1 125 0
372 @ 125 "../src/frame_m0.c" 1
373 003e C046 NOP
374 @ 0 "" 2
126:../src/frame_m0.c **** asm("LDR r2, [r0]"); // high
375 .loc 1 126 0
376 @ 126 "../src/frame_m0.c" 1
377 0040 0268 LDR r2, [r0]
378 @ 0 "" 2
127:../src/frame_m0.c **** asm("ANDS r4, r2");
379 .loc 1 127 0
380 @ 127 "../src/frame_m0.c" 1
381 0042 1440 ANDS r4, r2
382 @ 0 "" 2
128:../src/frame_m0.c **** asm("NOP");
383 .loc 1 128 0
384 @ 128 "../src/frame_m0.c" 1
385 0044 C046 NOP
386 @ 0 "" 2
129:../src/frame_m0.c **** asm("NOP");
387 .loc 1 129 0
388 @ 129 "../src/frame_m0.c" 1
389 0046 C046 NOP
390 @ 0 "" 2
130:../src/frame_m0.c **** asm("NOP");
391 .loc 1 130 0
392 @ 130 "../src/frame_m0.c" 1
393 0048 C046 NOP
394 @ 0 "" 2
131:../src/frame_m0.c **** asm("LDR r2, [r0]"); // low
395 .loc 1 131 0
396 @ 131 "../src/frame_m0.c" 1
397 004a 0268 LDR r2, [r0]
398 @ 0 "" 2
132:../src/frame_m0.c ****
133:../src/frame_m0.c **** asm("BICS r4, r2");
399 .loc 1 133 0
400 @ 133 "../src/frame_m0.c" 1
401 004c 9443 BICS r4, r2
402 @ 0 "" 2
134:../src/frame_m0.c **** asm("ANDS r4, r3");
403 .loc 1 134 0
404 @ 134 "../src/frame_m0.c" 1
405 004e 1C40 ANDS r4, r3
406 @ 0 "" 2
135:../src/frame_m0.c ****
136:../src/frame_m0.c **** asm("TST r4, r1");
407 .loc 1 136 0
408 @ 136 "../src/frame_m0.c" 1
409 0050 0C42 TST r4, r1
410 @ 0 "" 2
137:../src/frame_m0.c **** asm("NOP"); // an extra NOP makes us converge faster, worst case 400 cycles.
411 .loc 1 137 0
412 @ 137 "../src/frame_m0.c" 1
413 0052 C046 NOP
414 @ 0 "" 2
138:../src/frame_m0.c **** asm("NOP");
415 .loc 1 138 0
416 @ 138 "../src/frame_m0.c" 1
417 0054 C046 NOP
418 @ 0 "" 2
139:../src/frame_m0.c **** asm("NOP");
419 .loc 1 139 0
420 @ 139 "../src/frame_m0.c" 1
421 0056 C046 NOP
422 @ 0 "" 2
140:../src/frame_m0.c **** asm("BEQ startSyncM1");
423 .loc 1 140 0
424 @ 140 "../src/frame_m0.c" 1
425 0058 D8D0 BEQ startSyncM1
426 @ 0 "" 2
141:../src/frame_m0.c ****
142:../src/frame_m0.c **** // in-phase begins here
143:../src/frame_m0.c ****
144:../src/frame_m0.c ****
145:../src/frame_m0.c **** asm("POP {r4}");
427 .loc 1 145 0
428 @ 145 "../src/frame_m0.c" 1
429 005a 10BC POP {r4}
430 @ 0 "" 2
146:../src/frame_m0.c ****
147:../src/frame_m0.c **** asm(".syntax divided");
431 .loc 1 147 0
432 @ 147 "../src/frame_m0.c" 1
433 .syntax divided
434 @ 0 "" 2
148:../src/frame_m0.c **** }
435 .loc 1 148 0
436 .thumb
437 .syntax unified
438 005c C046 nop
439 005e BD46 mov sp, r7
440 0060 02B0 add sp, sp, #8
441 @ sp needed
442 0062 80BD pop {r7, pc}
443 .cfi_endproc
444 .LFE34:
446 .section .text.lineM0,"ax",%progbits
447 .align 2
448 .global lineM0
449 .code 16
450 .thumb_func
452 lineM0:
453 .LFB35:
149:../src/frame_m0.c ****
150:../src/frame_m0.c ****
151:../src/frame_m0.c **** void lineM0(uint32_t *gpio, uint8_t *memory, uint32_t xoffset, uint32_t xwidth)
152:../src/frame_m0.c **** {
454 .loc 1 152 0
455 .cfi_startproc
456 0000 80B5 push {r7, lr}
457 .cfi_def_cfa_offset 8
458 .cfi_offset 7, -8
459 .cfi_offset 14, -4
460 0002 84B0 sub sp, sp, #16
461 .cfi_def_cfa_offset 24
462 0004 00AF add r7, sp, #0
463 .cfi_def_cfa_register 7
464 0006 F860 str r0, [r7, #12]
465 0008 B960 str r1, [r7, #8]
466 000a 7A60 str r2, [r7, #4]
467 000c 3B60 str r3, [r7]
153:../src/frame_m0.c **** // asm("PRESERVE8");
154:../src/frame_m0.c **** // asm("IMPORT callSyncM0");
155:../src/frame_m0.c **** asm(".syntax unified");
468 .loc 1 155 0
469 .syntax divided
470 @ 155 "../src/frame_m0.c" 1
471 .syntax unified
472 @ 0 "" 2
156:../src/frame_m0.c ****
157:../src/frame_m0.c **** asm("PUSH {r4-r5}");
473 .loc 1 157 0
474 @ 157 "../src/frame_m0.c" 1
475 000e 30B4 PUSH {r4-r5}
476 @ 0 "" 2
158:../src/frame_m0.c ****
159:../src/frame_m0.c **** // add width to memory pointer so we can compare
160:../src/frame_m0.c **** asm("ADDS r3, r1");
477 .loc 1 160 0
478 @ 160 "../src/frame_m0.c" 1
479 0010 5B18 ADDS r3, r1
480 @ 0 "" 2
161:../src/frame_m0.c **** // generate hsync bit
162:../src/frame_m0.c **** asm("MOVS r4, #0x1");
481 .loc 1 162 0
482 @ 162 "../src/frame_m0.c" 1
483 0012 0124 MOVS r4, #0x1
484 @ 0 "" 2
163:../src/frame_m0.c **** asm("LSLS r4, #11");
485 .loc 1 163 0
486 @ 163 "../src/frame_m0.c" 1
487 0014 E402 LSLS r4, #11
488 @ 0 "" 2
164:../src/frame_m0.c ****
165:../src/frame_m0.c **** asm("PUSH {r0-r3}"); // save args
489 .loc 1 165 0
490 @ 165 "../src/frame_m0.c" 1
491 0016 0FB4 PUSH {r0-r3}
492 @ 0 "" 2
166:../src/frame_m0.c **** asm("BL callSyncM0"); // get pixel sync
493 .loc 1 166 0
494 @ 166 "../src/frame_m0.c" 1
495 0018 FFF7FEFF BL callSyncM0
496 @ 0 "" 2
167:../src/frame_m0.c **** asm("POP {r0-r3}"); // restore args
497 .loc 1 167 0
498 @ 167 "../src/frame_m0.c" 1
499 001c 0FBC POP {r0-r3}
500 @ 0 "" 2
168:../src/frame_m0.c ****
169:../src/frame_m0.c **** // pixel sync starts here
170:../src/frame_m0.c ****
171:../src/frame_m0.c **** // these nops are set us up for sampling hsync reliably
172:../src/frame_m0.c **** asm("NOP");
501 .loc 1 172 0
502 @ 172 "../src/frame_m0.c" 1
503 001e C046 NOP
504 @ 0 "" 2
173:../src/frame_m0.c **** asm("NOP");
505 .loc 1 173 0
506 @ 173 "../src/frame_m0.c" 1
507 0020 C046 NOP
508 @ 0 "" 2
174:../src/frame_m0.c ****
175:../src/frame_m0.c **** // wait for hsync to go high
176:../src/frame_m0.c **** asm("dest21:");
509 .loc 1 176 0
510 @ 176 "../src/frame_m0.c" 1
511 dest21:
512 @ 0 "" 2
177:../src/frame_m0.c **** asm("LDR r5, [r0]"); // 2
513 .loc 1 177 0
514 @ 177 "../src/frame_m0.c" 1
515 0022 0568 LDR r5, [r0]
516 @ 0 "" 2
178:../src/frame_m0.c **** asm("TST r5, r4"); // 1
517 .loc 1 178 0
518 @ 178 "../src/frame_m0.c" 1
519 0024 2542 TST r5, r4
520 @ 0 "" 2
179:../src/frame_m0.c **** asm("BEQ dest21"); // 3
521 .loc 1 179 0
522 @ 179 "../src/frame_m0.c" 1
523 0026 FCD0 BEQ dest21
524 @ 0 "" 2
180:../src/frame_m0.c ****
181:../src/frame_m0.c **** // skip pixels
182:../src/frame_m0.c **** asm("dest22:");
525 .loc 1 182 0
526 @ 182 "../src/frame_m0.c" 1
527 dest22:
528 @ 0 "" 2
183:../src/frame_m0.c **** asm("SUBS r2, #0x1"); // 1
529 .loc 1 183 0
530 @ 183 "../src/frame_m0.c" 1
531 0028 013A SUBS r2, #0x1
532 @ 0 "" 2
184:../src/frame_m0.c **** asm("NOP"); // 1
533 .loc 1 184 0
534 @ 184 "../src/frame_m0.c" 1
535 002a C046 NOP
536 @ 0 "" 2
185:../src/frame_m0.c **** asm("NOP"); // 1
537 .loc 1 185 0
538 @ 185 "../src/frame_m0.c" 1
539 002c C046 NOP
540 @ 0 "" 2
186:../src/frame_m0.c **** asm("NOP"); // 1
541 .loc 1 186 0
542 @ 186 "../src/frame_m0.c" 1
543 002e C046 NOP
544 @ 0 "" 2
187:../src/frame_m0.c **** asm("NOP"); // 1
545 .loc 1 187 0
546 @ 187 "../src/frame_m0.c" 1
547 0030 C046 NOP
548 @ 0 "" 2
188:../src/frame_m0.c **** asm("NOP"); // 1
549 .loc 1 188 0
550 @ 188 "../src/frame_m0.c" 1
551 0032 C046 NOP
552 @ 0 "" 2
189:../src/frame_m0.c **** asm("NOP"); // 1
553 .loc 1 189 0
554 @ 189 "../src/frame_m0.c" 1
555 0034 C046 NOP
556 @ 0 "" 2
190:../src/frame_m0.c **** asm("NOP"); // 1
557 .loc 1 190 0
558 @ 190 "../src/frame_m0.c" 1
559 0036 C046 NOP
560 @ 0 "" 2
191:../src/frame_m0.c **** asm("NOP"); // 1
561 .loc 1 191 0
562 @ 191 "../src/frame_m0.c" 1
563 0038 C046 NOP
564 @ 0 "" 2
192:../src/frame_m0.c **** asm("BGE dest22"); // 3
565 .loc 1 192 0
566 @ 192 "../src/frame_m0.c" 1
567 003a F5DA BGE dest22
568 @ 0 "" 2
193:../src/frame_m0.c ****
194:../src/frame_m0.c **** // variable delay --- get correct phase for sampling
195:../src/frame_m0.c ****
196:../src/frame_m0.c **** asm("LDRB r2, [r0]"); // 0
569 .loc 1 196 0
570 @ 196 "../src/frame_m0.c" 1
571 003c 0278 LDRB r2, [r0]
572 @ 0 "" 2
197:../src/frame_m0.c **** asm("STRB r2, [r1, #0x00]");
573 .loc 1 197 0
574 @ 197 "../src/frame_m0.c" 1
575 003e 0A70 STRB r2, [r1, #0x00]
576 @ 0 "" 2
198:../src/frame_m0.c **** asm("NOP");
577 .loc 1 198 0
578 @ 198 "../src/frame_m0.c" 1
579 0040 C046 NOP
580 @ 0 "" 2
199:../src/frame_m0.c **** asm("NOP");
581 .loc 1 199 0
582 @ 199 "../src/frame_m0.c" 1
583 0042 C046 NOP
584 @ 0 "" 2
200:../src/frame_m0.c ****
201:../src/frame_m0.c **** asm("LDRB r2, [r0]"); // 0
585 .loc 1 201 0
586 @ 201 "../src/frame_m0.c" 1
587 0044 0278 LDRB r2, [r0]
588 @ 0 "" 2
202:../src/frame_m0.c **** asm("STRB r2, [r1, #0x01]");
589 .loc 1 202 0
590 @ 202 "../src/frame_m0.c" 1
591 0046 4A70 STRB r2, [r1, #0x01]
592 @ 0 "" 2
203:../src/frame_m0.c **** asm("NOP");
593 .loc 1 203 0
594 @ 203 "../src/frame_m0.c" 1
595 0048 C046 NOP
596 @ 0 "" 2
204:../src/frame_m0.c **** asm("NOP");
597 .loc 1 204 0
598 @ 204 "../src/frame_m0.c" 1
599 004a C046 NOP
600 @ 0 "" 2
205:../src/frame_m0.c ****
206:../src/frame_m0.c **** asm("loop11:");
601 .loc 1 206 0
602 @ 206 "../src/frame_m0.c" 1
603 loop11:
604 @ 0 "" 2
207:../src/frame_m0.c **** asm("LDRB r2, [r0]"); // 0
605 .loc 1 207 0
606 @ 207 "../src/frame_m0.c" 1
607 004c 0278 LDRB r2, [r0]
608 @ 0 "" 2
208:../src/frame_m0.c **** asm("STRB r2, [r1, #0x2]");
609 .loc 1 208 0
610 @ 208 "../src/frame_m0.c" 1
611 004e 8A70 STRB r2, [r1, #0x2]
612 @ 0 "" 2
209:../src/frame_m0.c ****
210:../src/frame_m0.c **** asm("ADDS r1, #0x03");
613 .loc 1 210 0
614 @ 210 "../src/frame_m0.c" 1
615 0050 0331 ADDS r1, #0x03
616 @ 0 "" 2
211:../src/frame_m0.c **** asm("NOP");
617 .loc 1 211 0
618 @ 211 "../src/frame_m0.c" 1
619 0052 C046 NOP
620 @ 0 "" 2
212:../src/frame_m0.c ****
213:../src/frame_m0.c **** asm("LDRB r2, [r0]"); // 0
621 .loc 1 213 0
622 @ 213 "../src/frame_m0.c" 1
623 0054 0278 LDRB r2, [r0]
624 @ 0 "" 2
214:../src/frame_m0.c **** asm("STRB r2, [r1, #0x0]");
625 .loc 1 214 0
626 @ 214 "../src/frame_m0.c" 1
627 0056 0A70 STRB r2, [r1, #0x0]
628 @ 0 "" 2
215:../src/frame_m0.c ****
216:../src/frame_m0.c **** asm("CMP r1, r3");
629 .loc 1 216 0
630 @ 216 "../src/frame_m0.c" 1
631 0058 9942 CMP r1, r3
632 @ 0 "" 2
217:../src/frame_m0.c ****
218:../src/frame_m0.c **** asm("LDRB r2, [r0]"); // -1
633 .loc 1 218 0
634 @ 218 "../src/frame_m0.c" 1
635 005a 0278 LDRB r2, [r0]
636 @ 0 "" 2
219:../src/frame_m0.c **** asm("STRB r2, [r1, #0x1]");
637 .loc 1 219 0
638 @ 219 "../src/frame_m0.c" 1
639 005c 4A70 STRB r2, [r1, #0x1]
640 @ 0 "" 2
220:../src/frame_m0.c ****
221:../src/frame_m0.c **** asm("BLT loop11");
641 .loc 1 221 0
642 @ 221 "../src/frame_m0.c" 1
643 005e F5DB BLT loop11
644 @ 0 "" 2
222:../src/frame_m0.c ****
223:../src/frame_m0.c **** // wait for hsync to go low (end of line)
224:../src/frame_m0.c **** asm("dest13:");
645 .loc 1 224 0
646 @ 224 "../src/frame_m0.c" 1
647 dest13:
648 @ 0 "" 2
225:../src/frame_m0.c **** asm("LDR r5, [r0]"); // 2
649 .loc 1 225 0
650 @ 225 "../src/frame_m0.c" 1
651 0060 0568 LDR r5, [r0]
652 @ 0 "" 2
226:../src/frame_m0.c **** asm("TST r5, r4"); // 1
653 .loc 1 226 0
654 @ 226 "../src/frame_m0.c" 1
655 0062 2542 TST r5, r4
656 @ 0 "" 2
227:../src/frame_m0.c **** asm("BNE dest13"); // 3
657 .loc 1 227 0
658 @ 227 "../src/frame_m0.c" 1
659 0064 FCD1 BNE dest13
660 @ 0 "" 2
228:../src/frame_m0.c ****
229:../src/frame_m0.c **** asm("POP {r4-r5}");
661 .loc 1 229 0
662 @ 229 "../src/frame_m0.c" 1
663 0066 30BC POP {r4-r5}
664 @ 0 "" 2
230:../src/frame_m0.c ****
231:../src/frame_m0.c **** asm(".syntax divided");
665 .loc 1 231 0
666 @ 231 "../src/frame_m0.c" 1
667 .syntax divided
668 @ 0 "" 2
232:../src/frame_m0.c **** }
669 .loc 1 232 0
670 .thumb
671 .syntax unified
672 0068 C046 nop
673 006a BD46 mov sp, r7
674 006c 04B0 add sp, sp, #16
675 @ sp needed
676 006e 80BD pop {r7, pc}
677 .cfi_endproc
678 .LFE35:
680 .section .text.lineM1R1,"ax",%progbits
681 .align 2
682 .global lineM1R1
683 .code 16
684 .thumb_func
686 lineM1R1:
687 .LFB36:
233:../src/frame_m0.c ****
234:../src/frame_m0.c ****
235:../src/frame_m0.c **** void lineM1R1(uint32_t *gpio, uint8_t *memory, uint32_t xoffset, uint32_t xwidth)
236:../src/frame_m0.c **** {
688 .loc 1 236 0
689 .cfi_startproc
690 0000 80B5 push {r7, lr}
691 .cfi_def_cfa_offset 8
692 .cfi_offset 7, -8
693 .cfi_offset 14, -4
694 0002 84B0 sub sp, sp, #16
695 .cfi_def_cfa_offset 24
696 0004 00AF add r7, sp, #0
697 .cfi_def_cfa_register 7
698 0006 F860 str r0, [r7, #12]
699 0008 B960 str r1, [r7, #8]
700 000a 7A60 str r2, [r7, #4]
701 000c 3B60 str r3, [r7]
237:../src/frame_m0.c **** // asm("PRESERVE8");
238:../src/frame_m0.c **** // asm("IMPORT callSyncM1");
239:../src/frame_m0.c **** asm(".syntax unified");
702 .loc 1 239 0
703 .syntax divided
704 @ 239 "../src/frame_m0.c" 1
705 .syntax unified
706 @ 0 "" 2
240:../src/frame_m0.c ****
241:../src/frame_m0.c **** asm("PUSH {r4-r5}");
707 .loc 1 241 0
708 @ 241 "../src/frame_m0.c" 1
709 000e 30B4 PUSH {r4-r5}
710 @ 0 "" 2
242:../src/frame_m0.c ****
243:../src/frame_m0.c **** // add width to memory pointer so we can compare
244:../src/frame_m0.c **** asm("ADDS r3, r1");
711 .loc 1 244 0
712 @ 244 "../src/frame_m0.c" 1
713 0010 5B18 ADDS r3, r1
714 @ 0 "" 2
245:../src/frame_m0.c **** // generate hsync bit
246:../src/frame_m0.c **** asm("MOVS r4, #0x1");
715 .loc 1 246 0
716 @ 246 "../src/frame_m0.c" 1
717 0012 0124 MOVS r4, #0x1
718 @ 0 "" 2
247:../src/frame_m0.c **** asm("LSLS r4, #11");
719 .loc 1 247 0
720 @ 247 "../src/frame_m0.c" 1
721 0014 E402 LSLS r4, #11
722 @ 0 "" 2
248:../src/frame_m0.c ****
249:../src/frame_m0.c **** asm("PUSH {r0-r3}"); // save args
723 .loc 1 249 0
724 @ 249 "../src/frame_m0.c" 1
725 0016 0FB4 PUSH {r0-r3}
726 @ 0 "" 2
250:../src/frame_m0.c **** asm("BL callSyncM1"); // get pixel sync
727 .loc 1 250 0
728 @ 250 "../src/frame_m0.c" 1
729 0018 FFF7FEFF BL callSyncM1
730 @ 0 "" 2
251:../src/frame_m0.c **** asm("POP {r0-r3}"); // restore args
731 .loc 1 251 0
732 @ 251 "../src/frame_m0.c" 1
733 001c 0FBC POP {r0-r3}
734 @ 0 "" 2
252:../src/frame_m0.c ****
253:../src/frame_m0.c **** // pixel sync starts here
254:../src/frame_m0.c ****
255:../src/frame_m0.c **** // wait for hsync to go high
256:../src/frame_m0.c **** asm("dest1:");
735 .loc 1 256 0
736 @ 256 "../src/frame_m0.c" 1
737 dest1:
738 @ 0 "" 2
257:../src/frame_m0.c **** asm("LDR r5, [r0]"); // 2
739 .loc 1 257 0
740 @ 257 "../src/frame_m0.c" 1
741 001e 0568 LDR r5, [r0]
742 @ 0 "" 2
258:../src/frame_m0.c **** asm("TST r5, r4"); // 1
743 .loc 1 258 0
744 @ 258 "../src/frame_m0.c" 1
745 0020 2542 TST r5, r4
746 @ 0 "" 2
259:../src/frame_m0.c **** asm("BEQ dest1"); // 3
747 .loc 1 259 0
748 @ 259 "../src/frame_m0.c" 1
749 0022 FCD0 BEQ dest1
750 @ 0 "" 2
260:../src/frame_m0.c ****
261:../src/frame_m0.c **** // skip pixels
262:../src/frame_m0.c **** asm("dest2:");
751 .loc 1 262 0
752 @ 262 "../src/frame_m0.c" 1
753 dest2:
754 @ 0 "" 2
263:../src/frame_m0.c **** asm("SUBS r2, #0x1"); // 1
755 .loc 1 263 0
756 @ 263 "../src/frame_m0.c" 1
757 0024 013A SUBS r2, #0x1
758 @ 0 "" 2
264:../src/frame_m0.c **** asm("NOP"); // 1
759 .loc 1 264 0
760 @ 264 "../src/frame_m0.c" 1
761 0026 C046 NOP
762 @ 0 "" 2
265:../src/frame_m0.c **** asm("NOP"); // 1
763 .loc 1 265 0
764 @ 265 "../src/frame_m0.c" 1
765 0028 C046 NOP
766 @ 0 "" 2
266:../src/frame_m0.c **** asm("NOP"); // 1
767 .loc 1 266 0
768 @ 266 "../src/frame_m0.c" 1
769 002a C046 NOP
770 @ 0 "" 2
267:../src/frame_m0.c **** asm("NOP"); // 1
771 .loc 1 267 0
772 @ 267 "../src/frame_m0.c" 1
773 002c C046 NOP
774 @ 0 "" 2
268:../src/frame_m0.c **** asm("NOP"); // 1
775 .loc 1 268 0
776 @ 268 "../src/frame_m0.c" 1
777 002e C046 NOP
778 @ 0 "" 2
269:../src/frame_m0.c **** asm("NOP"); // 1
779 .loc 1 269 0
780 @ 269 "../src/frame_m0.c" 1
781 0030 C046 NOP
782 @ 0 "" 2
270:../src/frame_m0.c **** asm("NOP"); // 1
783 .loc 1 270 0
784 @ 270 "../src/frame_m0.c" 1
785 0032 C046 NOP
786 @ 0 "" 2
271:../src/frame_m0.c **** asm("NOP"); // 1
787 .loc 1 271 0
788 @ 271 "../src/frame_m0.c" 1
789 0034 C046 NOP
790 @ 0 "" 2
272:../src/frame_m0.c **** asm("NOP"); // 1
791 .loc 1 272 0
792 @ 272 "../src/frame_m0.c" 1
793 0036 C046 NOP
794 @ 0 "" 2
273:../src/frame_m0.c **** asm("NOP"); // 1
795 .loc 1 273 0
796 @ 273 "../src/frame_m0.c" 1
797 0038 C046 NOP
798 @ 0 "" 2
274:../src/frame_m0.c **** asm("NOP"); // 1
799 .loc 1 274 0
800 @ 274 "../src/frame_m0.c" 1
801 003a C046 NOP
802 @ 0 "" 2
275:../src/frame_m0.c **** asm("NOP"); // 1
803 .loc 1 275 0
804 @ 275 "../src/frame_m0.c" 1
805 003c C046 NOP
806 @ 0 "" 2
276:../src/frame_m0.c **** asm("NOP"); // 1
807 .loc 1 276 0
808 @ 276 "../src/frame_m0.c" 1
809 003e C046 NOP
810 @ 0 "" 2
277:../src/frame_m0.c **** asm("NOP"); // 1
811 .loc 1 277 0
812 @ 277 "../src/frame_m0.c" 1
813 0040 C046 NOP
814 @ 0 "" 2
278:../src/frame_m0.c **** asm("NOP"); // 1
815 .loc 1 278 0
816 @ 278 "../src/frame_m0.c" 1
817 0042 C046 NOP
818 @ 0 "" 2
279:../src/frame_m0.c **** asm("NOP"); // 1
819 .loc 1 279 0
820 @ 279 "../src/frame_m0.c" 1
821 0044 C046 NOP
822 @ 0 "" 2
280:../src/frame_m0.c **** asm("NOP"); // 1
823 .loc 1 280 0
824 @ 280 "../src/frame_m0.c" 1
825 0046 C046 NOP
826 @ 0 "" 2
281:../src/frame_m0.c **** asm("NOP"); // 1
827 .loc 1 281 0
828 @ 281 "../src/frame_m0.c" 1
829 0048 C046 NOP
830 @ 0 "" 2
282:../src/frame_m0.c **** asm("NOP"); // 1
831 .loc 1 282 0
832 @ 282 "../src/frame_m0.c" 1
833 004a C046 NOP
834 @ 0 "" 2
283:../src/frame_m0.c **** asm("NOP"); // 1
835 .loc 1 283 0
836 @ 283 "../src/frame_m0.c" 1
837 004c C046 NOP
838 @ 0 "" 2
284:../src/frame_m0.c **** asm("BGE dest2"); // 3
839 .loc 1 284 0
840 @ 284 "../src/frame_m0.c" 1
841 004e E9DA BGE dest2
842 @ 0 "" 2
285:../src/frame_m0.c ****
286:../src/frame_m0.c **** // variable delay --- get correct phase for sampling
287:../src/frame_m0.c **** asm("NOP");
843 .loc 1 287 0
844 @ 287 "../src/frame_m0.c" 1
845 0050 C046 NOP
846 @ 0 "" 2
288:../src/frame_m0.c **** asm("NOP");
847 .loc 1 288 0
848 @ 288 "../src/frame_m0.c" 1
849 0052 C046 NOP
850 @ 0 "" 2
289:../src/frame_m0.c ****
290:../src/frame_m0.c **** asm("loop1:");
851 .loc 1 290 0
852 @ 290 "../src/frame_m0.c" 1
853 loop1:
854 @ 0 "" 2
291:../src/frame_m0.c **** asm("LDRB r2, [r0]");
855 .loc 1 291 0
856 @ 291 "../src/frame_m0.c" 1
857 0054 0278 LDRB r2, [r0]
858 @ 0 "" 2
292:../src/frame_m0.c **** asm("STRB r2, [r1]");
859 .loc 1 292 0
860 @ 292 "../src/frame_m0.c" 1
861 0056 0A70 STRB r2, [r1]
862 @ 0 "" 2
293:../src/frame_m0.c **** asm("NOP");
863 .loc 1 293 0
864 @ 293 "../src/frame_m0.c" 1
865 0058 C046 NOP
866 @ 0 "" 2
294:../src/frame_m0.c **** asm("NOP");
867 .loc 1 294 0
868 @ 294 "../src/frame_m0.c" 1
869 005a C046 NOP
870 @ 0 "" 2
295:../src/frame_m0.c **** asm("NOP");
871 .loc 1 295 0
872 @ 295 "../src/frame_m0.c" 1
873 005c C046 NOP
874 @ 0 "" 2
296:../src/frame_m0.c **** asm("ADDS r1, #0x01");
875 .loc 1 296 0
876 @ 296 "../src/frame_m0.c" 1
877 005e 0131 ADDS r1, #0x01
878 @ 0 "" 2
297:../src/frame_m0.c **** asm("CMP r1, r3");
879 .loc 1 297 0
880 @ 297 "../src/frame_m0.c" 1
881 0060 9942 CMP r1, r3
882 @ 0 "" 2
298:../src/frame_m0.c **** asm("BLT loop1");
883 .loc 1 298 0
884 @ 298 "../src/frame_m0.c" 1
885 0062 F7DB BLT loop1
886 @ 0 "" 2
299:../src/frame_m0.c ****
300:../src/frame_m0.c **** // wait for hsync to go low (end of line)
301:../src/frame_m0.c **** asm("dest3:");
887 .loc 1 301 0
888 @ 301 "../src/frame_m0.c" 1
889 dest3:
890 @ 0 "" 2
302:../src/frame_m0.c **** asm("LDR r5, [r0]"); // 2
891 .loc 1 302 0
892 @ 302 "../src/frame_m0.c" 1
893 0064 0568 LDR r5, [r0]
894 @ 0 "" 2
303:../src/frame_m0.c **** asm("TST r5, r4"); // 1
895 .loc 1 303 0
896 @ 303 "../src/frame_m0.c" 1
897 0066 2542 TST r5, r4
898 @ 0 "" 2
304:../src/frame_m0.c **** asm("BNE dest3"); // 3
899 .loc 1 304 0
900 @ 304 "../src/frame_m0.c" 1
901 0068 FCD1 BNE dest3
902 @ 0 "" 2
305:../src/frame_m0.c ****
306:../src/frame_m0.c **** asm("POP {r4-r5}");
903 .loc 1 306 0
904 @ 306 "../src/frame_m0.c" 1
905 006a 30BC POP {r4-r5}
906 @ 0 "" 2
307:../src/frame_m0.c ****
308:../src/frame_m0.c **** asm(".syntax divided");
907 .loc 1 308 0
908 @ 308 "../src/frame_m0.c" 1
909 .syntax divided
910 @ 0 "" 2
309:../src/frame_m0.c **** }
911 .loc 1 309 0
912 .thumb
913 .syntax unified
914 006c C046 nop
915 006e BD46 mov sp, r7
916 0070 04B0 add sp, sp, #16
917 @ sp needed
918 0072 80BD pop {r7, pc}
919 .cfi_endproc
920 .LFE36:
922 .section .text.lineM1R2,"ax",%progbits
923 .align 2
924 .global lineM1R2
925 .code 16
926 .thumb_func
928 lineM1R2:
929 .LFB37:
310:../src/frame_m0.c ****
311:../src/frame_m0.c ****
312:../src/frame_m0.c **** void lineM1R2(uint32_t *gpio, uint16_t *memory, uint32_t xoffset, uint32_t xwidth)
313:../src/frame_m0.c **** {
930 .loc 1 313 0
931 .cfi_startproc
932 0000 80B5 push {r7, lr}
933 .cfi_def_cfa_offset 8
934 .cfi_offset 7, -8
935 .cfi_offset 14, -4
936 0002 84B0 sub sp, sp, #16
937 .cfi_def_cfa_offset 24
938 0004 00AF add r7, sp, #0
939 .cfi_def_cfa_register 7
940 0006 F860 str r0, [r7, #12]
941 0008 B960 str r1, [r7, #8]
942 000a 7A60 str r2, [r7, #4]
943 000c 3B60 str r3, [r7]
314:../src/frame_m0.c **** // asm("PRESERVE8");
315:../src/frame_m0.c **** // asm("IMPORT callSyncM1");
316:../src/frame_m0.c **** asm(".syntax unified");
944 .loc 1 316 0
945 .syntax divided
946 @ 316 "../src/frame_m0.c" 1
947 .syntax unified
948 @ 0 "" 2
317:../src/frame_m0.c ****
318:../src/frame_m0.c **** asm("PUSH {r4-r6}");
949 .loc 1 318 0
950 @ 318 "../src/frame_m0.c" 1
951 000e 70B4 PUSH {r4-r6}
952 @ 0 "" 2
319:../src/frame_m0.c ****
320:../src/frame_m0.c **** // add width to memory pointer so we can compare
321:../src/frame_m0.c **** asm("LSLS r3, #1");
953 .loc 1 321 0
954 @ 321 "../src/frame_m0.c" 1
955 0010 5B00 LSLS r3, #1
956 @ 0 "" 2
322:../src/frame_m0.c **** asm("ADDS r3, r1");
957 .loc 1 322 0
958 @ 322 "../src/frame_m0.c" 1
959 0012 5B18 ADDS r3, r1
960 @ 0 "" 2
323:../src/frame_m0.c **** // generate hsync bit
324:../src/frame_m0.c **** asm("MOVS r4, #0x1");
961 .loc 1 324 0
962 @ 324 "../src/frame_m0.c" 1
963 0014 0124 MOVS r4, #0x1
964 @ 0 "" 2
325:../src/frame_m0.c **** asm("LSLS r4, #11");
965 .loc 1 325 0
966 @ 325 "../src/frame_m0.c" 1
967 0016 E402 LSLS r4, #11
968 @ 0 "" 2
326:../src/frame_m0.c ****
327:../src/frame_m0.c **** asm("PUSH {r0-r3}"); // save args
969 .loc 1 327 0
970 @ 327 "../src/frame_m0.c" 1
971 0018 0FB4 PUSH {r0-r3}
972 @ 0 "" 2
328:../src/frame_m0.c **** asm("BL callSyncM1"); // get pixel sync
973 .loc 1 328 0
974 @ 328 "../src/frame_m0.c" 1
975 001a FFF7FEFF BL callSyncM1
976 @ 0 "" 2
329:../src/frame_m0.c **** asm("POP {r0-r3}"); // restore args
977 .loc 1 329 0
978 @ 329 "../src/frame_m0.c" 1
979 001e 0FBC POP {r0-r3}
980 @ 0 "" 2
330:../src/frame_m0.c ****
331:../src/frame_m0.c **** // pixel sync starts here
332:../src/frame_m0.c **** asm("dest7:");
981 .loc 1 332 0
982 @ 332 "../src/frame_m0.c" 1
983 dest7:
984 @ 0 "" 2
333:../src/frame_m0.c **** asm("LDR r5, [r0]"); // 2
985 .loc 1 333 0
986 @ 333 "../src/frame_m0.c" 1
987 0020 0568 LDR r5, [r0]
988 @ 0 "" 2
334:../src/frame_m0.c **** asm("TST r5, r4"); // 1
989 .loc 1 334 0
990 @ 334 "../src/frame_m0.c" 1
991 0022 2542 TST r5, r4
992 @ 0 "" 2
335:../src/frame_m0.c **** asm("BEQ dest7"); // 3
993 .loc 1 335 0
994 @ 335 "../src/frame_m0.c" 1
995 0024 FCD0 BEQ dest7
996 @ 0 "" 2
336:../src/frame_m0.c ****
337:../src/frame_m0.c **** // skip pixels
338:../src/frame_m0.c **** asm("dest8:");
997 .loc 1 338 0
998 @ 338 "../src/frame_m0.c" 1
999 dest8:
1000 @ 0 "" 2
339:../src/frame_m0.c **** asm("SUBS r2, #0x1"); // 1
1001 .loc 1 339 0
1002 @ 339 "../src/frame_m0.c" 1
1003 0026 013A SUBS r2, #0x1
1004 @ 0 "" 2
340:../src/frame_m0.c **** asm("NOP"); // 1
1005 .loc 1 340 0
1006 @ 340 "../src/frame_m0.c" 1
1007 0028 C046 NOP
1008 @ 0 "" 2
341:../src/frame_m0.c **** asm("NOP"); // 1
1009 .loc 1 341 0
1010 @ 341 "../src/frame_m0.c" 1
1011 002a C046 NOP
1012 @ 0 "" 2
342:../src/frame_m0.c **** asm("NOP"); // 1
1013 .loc 1 342 0
1014 @ 342 "../src/frame_m0.c" 1
1015 002c C046 NOP
1016 @ 0 "" 2
343:../src/frame_m0.c **** asm("NOP"); // 1
1017 .loc 1 343 0
1018 @ 343 "../src/frame_m0.c" 1
1019 002e C046 NOP
1020 @ 0 "" 2
344:../src/frame_m0.c **** asm("NOP"); // 1
1021 .loc 1 344 0
1022 @ 344 "../src/frame_m0.c" 1
1023 0030 C046 NOP
1024 @ 0 "" 2
345:../src/frame_m0.c **** asm("NOP"); // 1
1025 .loc 1 345 0
1026 @ 345 "../src/frame_m0.c" 1
1027 0032 C046 NOP
1028 @ 0 "" 2
346:../src/frame_m0.c **** asm("NOP"); // 1
1029 .loc 1 346 0
1030 @ 346 "../src/frame_m0.c" 1
1031 0034 C046 NOP
1032 @ 0 "" 2
347:../src/frame_m0.c **** asm("NOP"); // 1
1033 .loc 1 347 0
1034 @ 347 "../src/frame_m0.c" 1
1035 0036 C046 NOP
1036 @ 0 "" 2
348:../src/frame_m0.c **** asm("NOP"); // 1
1037 .loc 1 348 0
1038 @ 348 "../src/frame_m0.c" 1
1039 0038 C046 NOP
1040 @ 0 "" 2
349:../src/frame_m0.c **** asm("NOP"); // 1
1041 .loc 1 349 0
1042 @ 349 "../src/frame_m0.c" 1
1043 003a C046 NOP
1044 @ 0 "" 2
350:../src/frame_m0.c **** asm("NOP"); // 1
1045 .loc 1 350 0
1046 @ 350 "../src/frame_m0.c" 1
1047 003c C046 NOP
1048 @ 0 "" 2
351:../src/frame_m0.c **** asm("NOP"); // 1
1049 .loc 1 351 0
1050 @ 351 "../src/frame_m0.c" 1
1051 003e C046 NOP
1052 @ 0 "" 2
352:../src/frame_m0.c **** asm("NOP"); // 1
1053 .loc 1 352 0
1054 @ 352 "../src/frame_m0.c" 1
1055 0040 C046 NOP
1056 @ 0 "" 2
353:../src/frame_m0.c **** asm("NOP"); // 1
1057 .loc 1 353 0
1058 @ 353 "../src/frame_m0.c" 1
1059 0042 C046 NOP
1060 @ 0 "" 2
354:../src/frame_m0.c **** asm("NOP"); // 1
1061 .loc 1 354 0
1062 @ 354 "../src/frame_m0.c" 1
1063 0044 C046 NOP
1064 @ 0 "" 2
355:../src/frame_m0.c **** asm("NOP"); // 1
1065 .loc 1 355 0
1066 @ 355 "../src/frame_m0.c" 1
1067 0046 C046 NOP
1068 @ 0 "" 2
356:../src/frame_m0.c **** asm("NOP"); // 1
1069 .loc 1 356 0
1070 @ 356 "../src/frame_m0.c" 1
1071 0048 C046 NOP
1072 @ 0 "" 2
357:../src/frame_m0.c **** asm("NOP"); // 1
1073 .loc 1 357 0
1074 @ 357 "../src/frame_m0.c" 1
1075 004a C046 NOP
1076 @ 0 "" 2
358:../src/frame_m0.c **** asm("NOP"); // 1
1077 .loc 1 358 0
1078 @ 358 "../src/frame_m0.c" 1
1079 004c C046 NOP
1080 @ 0 "" 2
359:../src/frame_m0.c **** asm("NOP"); // 1
1081 .loc 1 359 0
1082 @ 359 "../src/frame_m0.c" 1
1083 004e C046 NOP
1084 @ 0 "" 2
360:../src/frame_m0.c **** asm("BGE dest8"); // 3
1085 .loc 1 360 0
1086 @ 360 "../src/frame_m0.c" 1
1087 0050 E9DA BGE dest8
1088 @ 0 "" 2
361:../src/frame_m0.c ****
362:../src/frame_m0.c **** // variable delay --- get correct phase for sampling
363:../src/frame_m0.c **** asm("NOP");
1089 .loc 1 363 0
1090 @ 363 "../src/frame_m0.c" 1
1091 0052 C046 NOP
1092 @ 0 "" 2
364:../src/frame_m0.c **** asm("NOP");
1093 .loc 1 364 0
1094 @ 364 "../src/frame_m0.c" 1
1095 0054 C046 NOP
1096 @ 0 "" 2
365:../src/frame_m0.c ****
366:../src/frame_m0.c **** asm("loop3:");
1097 .loc 1 366 0
1098 @ 366 "../src/frame_m0.c" 1
1099 loop3:
1100 @ 0 "" 2
367:../src/frame_m0.c **** asm("LDRB r2, [r0]");
1101 .loc 1 367 0
1102 @ 367 "../src/frame_m0.c" 1
1103 0056 0278 LDRB r2, [r0]
1104 @ 0 "" 2
368:../src/frame_m0.c **** asm("NOP");
1105 .loc 1 368 0
1106 @ 368 "../src/frame_m0.c" 1
1107 0058 C046 NOP
1108 @ 0 "" 2
369:../src/frame_m0.c **** asm("NOP");
1109 .loc 1 369 0
1110 @ 369 "../src/frame_m0.c" 1
1111 005a C046 NOP
1112 @ 0 "" 2
370:../src/frame_m0.c **** asm("NOP");
1113 .loc 1 370 0
1114 @ 370 "../src/frame_m0.c" 1
1115 005c C046 NOP
1116 @ 0 "" 2
371:../src/frame_m0.c **** asm("NOP");
1117 .loc 1 371 0
1118 @ 371 "../src/frame_m0.c" 1
1119 005e C046 NOP
1120 @ 0 "" 2
372:../src/frame_m0.c **** asm("NOP");
1121 .loc 1 372 0
1122 @ 372 "../src/frame_m0.c" 1
1123 0060 C046 NOP
1124 @ 0 "" 2
373:../src/frame_m0.c **** asm("NOP");
1125 .loc 1 373 0
1126 @ 373 "../src/frame_m0.c" 1
1127 0062 C046 NOP
1128 @ 0 "" 2
374:../src/frame_m0.c **** asm("NOP");
1129 .loc 1 374 0
1130 @ 374 "../src/frame_m0.c" 1
1131 0064 C046 NOP
1132 @ 0 "" 2
375:../src/frame_m0.c **** asm("NOP");
1133 .loc 1 375 0
1134 @ 375 "../src/frame_m0.c" 1
1135 0066 C046 NOP
1136 @ 0 "" 2
376:../src/frame_m0.c **** asm("NOP");
1137 .loc 1 376 0
1138 @ 376 "../src/frame_m0.c" 1
1139 0068 C046 NOP
1140 @ 0 "" 2
377:../src/frame_m0.c **** asm("NOP");
1141 .loc 1 377 0
1142 @ 377 "../src/frame_m0.c" 1
1143 006a C046 NOP
1144 @ 0 "" 2
378:../src/frame_m0.c ****
379:../src/frame_m0.c **** asm("LDRB r5, [r0]");
1145 .loc 1 379 0
1146 @ 379 "../src/frame_m0.c" 1
1147 006c 0578 LDRB r5, [r0]
1148 @ 0 "" 2
380:../src/frame_m0.c **** asm("NOP");
1149 .loc 1 380 0
1150 @ 380 "../src/frame_m0.c" 1
1151 006e C046 NOP
1152 @ 0 "" 2
381:../src/frame_m0.c **** asm("NOP");
1153 .loc 1 381 0
1154 @ 381 "../src/frame_m0.c" 1
1155 0070 C046 NOP
1156 @ 0 "" 2
382:../src/frame_m0.c **** asm("NOP");
1157 .loc 1 382 0
1158 @ 382 "../src/frame_m0.c" 1
1159 0072 C046 NOP
1160 @ 0 "" 2
383:../src/frame_m0.c **** asm("NOP");
1161 .loc 1 383 0
1162 @ 383 "../src/frame_m0.c" 1
1163 0074 C046 NOP
1164 @ 0 "" 2
384:../src/frame_m0.c **** asm("NOP");
1165 .loc 1 384 0
1166 @ 384 "../src/frame_m0.c" 1
1167 0076 C046 NOP
1168 @ 0 "" 2
385:../src/frame_m0.c **** asm("NOP");
1169 .loc 1 385 0
1170 @ 385 "../src/frame_m0.c" 1
1171 0078 C046 NOP
1172 @ 0 "" 2
386:../src/frame_m0.c **** asm("NOP");
1173 .loc 1 386 0
1174 @ 386 "../src/frame_m0.c" 1
1175 007a C046 NOP
1176 @ 0 "" 2
387:../src/frame_m0.c **** asm("NOP");
1177 .loc 1 387 0
1178 @ 387 "../src/frame_m0.c" 1
1179 007c C046 NOP
1180 @ 0 "" 2
388:../src/frame_m0.c **** asm("NOP");
1181 .loc 1 388 0
1182 @ 388 "../src/frame_m0.c" 1
1183 007e C046 NOP
1184 @ 0 "" 2
389:../src/frame_m0.c **** asm("NOP");
1185 .loc 1 389 0
1186 @ 389 "../src/frame_m0.c" 1
1187 0080 C046 NOP
1188 @ 0 "" 2
390:../src/frame_m0.c ****
391:../src/frame_m0.c **** asm("LDRB r6, [r0]");
1189 .loc 1 391 0
1190 @ 391 "../src/frame_m0.c" 1
1191 0082 0678 LDRB r6, [r0]
1192 @ 0 "" 2
392:../src/frame_m0.c **** asm("ADDS r6, r2");
1193 .loc 1 392 0
1194 @ 392 "../src/frame_m0.c" 1
1195 0084 B618 ADDS r6, r2
1196 @ 0 "" 2
393:../src/frame_m0.c **** asm("STRH r6, [r1, #0x00]");
1197 .loc 1 393 0
1198 @ 393 "../src/frame_m0.c" 1
1199 0086 0E80 STRH r6, [r1, #0x00]
1200 @ 0 "" 2
394:../src/frame_m0.c **** asm("NOP");
1201 .loc 1 394 0
1202 @ 394 "../src/frame_m0.c" 1
1203 0088 C046 NOP
1204 @ 0 "" 2
395:../src/frame_m0.c **** asm("NOP");
1205 .loc 1 395 0
1206 @ 395 "../src/frame_m0.c" 1
1207 008a C046 NOP
1208 @ 0 "" 2
396:../src/frame_m0.c **** asm("NOP");
1209 .loc 1 396 0
1210 @ 396 "../src/frame_m0.c" 1
1211 008c C046 NOP
1212 @ 0 "" 2
397:../src/frame_m0.c **** asm("NOP");
1213 .loc 1 397 0
1214 @ 397 "../src/frame_m0.c" 1
1215 008e C046 NOP
1216 @ 0 "" 2
398:../src/frame_m0.c **** asm("NOP");
1217 .loc 1 398 0
1218 @ 398 "../src/frame_m0.c" 1
1219 0090 C046 NOP
1220 @ 0 "" 2
399:../src/frame_m0.c **** asm("NOP");
1221 .loc 1 399 0
1222 @ 399 "../src/frame_m0.c" 1
1223 0092 C046 NOP
1224 @ 0 "" 2
400:../src/frame_m0.c **** asm("NOP");
1225 .loc 1 400 0
1226 @ 400 "../src/frame_m0.c" 1
1227 0094 C046 NOP
1228 @ 0 "" 2
401:../src/frame_m0.c ****
402:../src/frame_m0.c **** asm("LDRB r6, [r0]");
1229 .loc 1 402 0
1230 @ 402 "../src/frame_m0.c" 1
1231 0096 0678 LDRB r6, [r0]
1232 @ 0 "" 2
403:../src/frame_m0.c **** asm("ADDS r6, r5");
1233 .loc 1 403 0
1234 @ 403 "../src/frame_m0.c" 1
1235 0098 7619 ADDS r6, r5
1236 @ 0 "" 2
404:../src/frame_m0.c **** asm("STRH r6, [r1, #0x02]");
1237 .loc 1 404 0
1238 @ 404 "../src/frame_m0.c" 1
1239 009a 4E80 STRH r6, [r1, #0x02]
1240 @ 0 "" 2
405:../src/frame_m0.c **** asm("NOP");
1241 .loc 1 405 0
1242 @ 405 "../src/frame_m0.c" 1
1243 009c C046 NOP
1244 @ 0 "" 2
406:../src/frame_m0.c **** asm("NOP");
1245 .loc 1 406 0
1246 @ 406 "../src/frame_m0.c" 1
1247 009e C046 NOP
1248 @ 0 "" 2
407:../src/frame_m0.c **** asm("ADDS r1, #0x04");
1249 .loc 1 407 0
1250 @ 407 "../src/frame_m0.c" 1
1251 00a0 0431 ADDS r1, #0x04
1252 @ 0 "" 2
408:../src/frame_m0.c **** asm("CMP r1, r3");
1253 .loc 1 408 0
1254 @ 408 "../src/frame_m0.c" 1
1255 00a2 9942 CMP r1, r3
1256 @ 0 "" 2
409:../src/frame_m0.c **** asm("BLT loop3");
1257 .loc 1 409 0
1258 @ 409 "../src/frame_m0.c" 1
1259 00a4 D7DB BLT loop3
1260 @ 0 "" 2
410:../src/frame_m0.c ****
411:../src/frame_m0.c **** // wait for hsync to go low (end of line)
412:../src/frame_m0.c **** asm("dest9:");
1261 .loc 1 412 0
1262 @ 412 "../src/frame_m0.c" 1
1263 dest9:
1264 @ 0 "" 2
413:../src/frame_m0.c **** asm("LDR r5, [r0]"); // 2
1265 .loc 1 413 0
1266 @ 413 "../src/frame_m0.c" 1
1267 00a6 0568 LDR r5, [r0]
1268 @ 0 "" 2
414:../src/frame_m0.c **** asm("TST r5, r4"); // 1
1269 .loc 1 414 0
1270 @ 414 "../src/frame_m0.c" 1
1271 00a8 2542 TST r5, r4
1272 @ 0 "" 2
415:../src/frame_m0.c **** asm("BNE dest9"); // 3
1273 .loc 1 415 0
1274 @ 415 "../src/frame_m0.c" 1
1275 00aa FCD1 BNE dest9
1276 @ 0 "" 2
416:../src/frame_m0.c ****
417:../src/frame_m0.c **** asm("POP {r4-r6}");
1277 .loc 1 417 0
1278 @ 417 "../src/frame_m0.c" 1
1279 00ac 70BC POP {r4-r6}
1280 @ 0 "" 2
418:../src/frame_m0.c ****
419:../src/frame_m0.c **** asm(".syntax divided");
1281 .loc 1 419 0
1282 @ 419 "../src/frame_m0.c" 1
1283 .syntax divided
1284 @ 0 "" 2
420:../src/frame_m0.c **** }
1285 .loc 1 420 0
1286 .thumb
1287 .syntax unified
1288 00ae C046 nop
1289 00b0 BD46 mov sp, r7
1290 00b2 04B0 add sp, sp, #16
1291 @ sp needed
1292 00b4 80BD pop {r7, pc}
1293 .cfi_endproc
1294 .LFE37:
1296 00b6 C046 .section .text.lineM1R2Merge,"ax",%progbits
1297 .align 2
1298 .global lineM1R2Merge
1299 .code 16
1300 .thumb_func
1302 lineM1R2Merge:
1303 .LFB38:
421:../src/frame_m0.c ****
422:../src/frame_m0.c ****
423:../src/frame_m0.c **** void lineM1R2Merge(uint32_t *gpio, uint16_t *lineMemory, uint8_t *memory, uint32_t xoffset, uint32_
424:../src/frame_m0.c **** {
1304 .loc 1 424 0
1305 .cfi_startproc
1306 0000 80B5 push {r7, lr}
1307 .cfi_def_cfa_offset 8
1308 .cfi_offset 7, -8
1309 .cfi_offset 14, -4
1310 0002 84B0 sub sp, sp, #16
1311 .cfi_def_cfa_offset 24
1312 0004 00AF add r7, sp, #0
1313 .cfi_def_cfa_register 7
1314 0006 F860 str r0, [r7, #12]
1315 0008 B960 str r1, [r7, #8]
1316 000a 7A60 str r2, [r7, #4]
1317 000c 3B60 str r3, [r7]
425:../src/frame_m0.c **** // asm("PRESERVE8");
426:../src/frame_m0.c **** // asm("IMPORT callSyncM1");
427:../src/frame_m0.c **** asm(".syntax unified");
1318 .loc 1 427 0
1319 .syntax divided
1320 @ 427 "../src/frame_m0.c" 1
1321 .syntax unified
1322 @ 0 "" 2
428:../src/frame_m0.c ****
429:../src/frame_m0.c **** asm("PUSH {r4-r7}");
1323 .loc 1 429 0
1324 @ 429 "../src/frame_m0.c" 1
1325 000e F0B4 PUSH {r4-r7}
1326 @ 0 "" 2
430:../src/frame_m0.c **** asm("LDR r4, [sp, #0x28]"); // *** keil
1327 .loc 1 430 0
1328 @ 430 "../src/frame_m0.c" 1
1329 0010 0A9C LDR r4, [sp, #0x28]
1330 @ 0 "" 2
431:../src/frame_m0.c ****
432:../src/frame_m0.c **** // add width to memory pointer so we can compare
433:../src/frame_m0.c **** asm("ADDS r4, r2");
1331 .loc 1 433 0
1332 @ 433 "../src/frame_m0.c" 1
1333 0012 A418 ADDS r4, r2
1334 @ 0 "" 2
434:../src/frame_m0.c **** // generate hsync bit
435:../src/frame_m0.c **** asm("MOVS r5, #0x1");
1335 .loc 1 435 0
1336 @ 435 "../src/frame_m0.c" 1
1337 0014 0125 MOVS r5, #0x1
1338 @ 0 "" 2
436:../src/frame_m0.c **** asm("LSLS r5, #11");
1339 .loc 1 436 0
1340 @ 436 "../src/frame_m0.c" 1
1341 0016 ED02 LSLS r5, #11
1342 @ 0 "" 2
437:../src/frame_m0.c ****
438:../src/frame_m0.c **** asm("PUSH {r0-r3}"); // save args
1343 .loc 1 438 0
1344 @ 438 "../src/frame_m0.c" 1
1345 0018 0FB4 PUSH {r0-r3}
1346 @ 0 "" 2
439:../src/frame_m0.c **** asm("BL callSyncM1"); // get pixel sync
1347 .loc 1 439 0
1348 @ 439 "../src/frame_m0.c" 1
1349 001a FFF7FEFF BL callSyncM1
1350 @ 0 "" 2
440:../src/frame_m0.c **** asm("POP {r0-r3}"); // restore args
1351 .loc 1 440 0
1352 @ 440 "../src/frame_m0.c" 1
1353 001e 0FBC POP {r0-r3}
1354 @ 0 "" 2
441:../src/frame_m0.c ****
442:../src/frame_m0.c **** // pixel sync starts here
443:../src/frame_m0.c ****
444:../src/frame_m0.c **** // wait for hsync to go high
445:../src/frame_m0.c **** asm("dest4:");
1355 .loc 1 445 0
1356 @ 445 "../src/frame_m0.c" 1
1357 dest4:
1358 @ 0 "" 2
446:../src/frame_m0.c **** asm("LDR r6, [r0]"); // 2
1359 .loc 1 446 0
1360 @ 446 "../src/frame_m0.c" 1
1361 0020 0668 LDR r6, [r0]
1362 @ 0 "" 2
447:../src/frame_m0.c **** asm("TST r6, r5"); // 1
1363 .loc 1 447 0
1364 @ 447 "../src/frame_m0.c" 1
1365 0022 2E42 TST r6, r5
1366 @ 0 "" 2
448:../src/frame_m0.c **** asm("BEQ dest4"); // 3
1367 .loc 1 448 0
1368 @ 448 "../src/frame_m0.c" 1
1369 0024 FCD0 BEQ dest4
1370 @ 0 "" 2
449:../src/frame_m0.c ****
450:../src/frame_m0.c **** // skip pixels
451:../src/frame_m0.c **** asm("dest5:");
1371 .loc 1 451 0
1372 @ 451 "../src/frame_m0.c" 1
1373 dest5:
1374 @ 0 "" 2
452:../src/frame_m0.c **** asm("SUBS r3, #0x1"); // 1
1375 .loc 1 452 0
1376 @ 452 "../src/frame_m0.c" 1
1377 0026 013B SUBS r3, #0x1
1378 @ 0 "" 2
453:../src/frame_m0.c **** asm("NOP"); // 1
1379 .loc 1 453 0
1380 @ 453 "../src/frame_m0.c" 1
1381 0028 C046 NOP
1382 @ 0 "" 2
454:../src/frame_m0.c **** asm("NOP"); // 1
1383 .loc 1 454 0
1384 @ 454 "../src/frame_m0.c" 1
1385 002a C046 NOP
1386 @ 0 "" 2
455:../src/frame_m0.c **** asm("NOP"); // 1
1387 .loc 1 455 0
1388 @ 455 "../src/frame_m0.c" 1
1389 002c C046 NOP
1390 @ 0 "" 2
456:../src/frame_m0.c **** asm("NOP"); // 1
1391 .loc 1 456 0
1392 @ 456 "../src/frame_m0.c" 1
1393 002e C046 NOP
1394 @ 0 "" 2
457:../src/frame_m0.c **** asm("NOP"); // 1
1395 .loc 1 457 0
1396 @ 457 "../src/frame_m0.c" 1
1397 0030 C046 NOP
1398 @ 0 "" 2
458:../src/frame_m0.c **** asm("NOP"); // 1
1399 .loc 1 458 0
1400 @ 458 "../src/frame_m0.c" 1
1401 0032 C046 NOP
1402 @ 0 "" 2
459:../src/frame_m0.c **** asm("NOP"); // 1
1403 .loc 1 459 0
1404 @ 459 "../src/frame_m0.c" 1
1405 0034 C046 NOP
1406 @ 0 "" 2
460:../src/frame_m0.c **** asm("NOP"); // 1
1407 .loc 1 460 0
1408 @ 460 "../src/frame_m0.c" 1
1409 0036 C046 NOP
1410 @ 0 "" 2
461:../src/frame_m0.c **** asm("NOP"); // 1
1411 .loc 1 461 0
1412 @ 461 "../src/frame_m0.c" 1
1413 0038 C046 NOP
1414 @ 0 "" 2
462:../src/frame_m0.c **** asm("NOP"); // 1
1415 .loc 1 462 0
1416 @ 462 "../src/frame_m0.c" 1
1417 003a C046 NOP
1418 @ 0 "" 2
463:../src/frame_m0.c **** asm("NOP"); // 1
1419 .loc 1 463 0
1420 @ 463 "../src/frame_m0.c" 1
1421 003c C046 NOP
1422 @ 0 "" 2
464:../src/frame_m0.c **** asm("NOP"); // 1
1423 .loc 1 464 0
1424 @ 464 "../src/frame_m0.c" 1
1425 003e C046 NOP
1426 @ 0 "" 2
465:../src/frame_m0.c **** asm("NOP"); // 1
1427 .loc 1 465 0
1428 @ 465 "../src/frame_m0.c" 1
1429 0040 C046 NOP
1430 @ 0 "" 2
466:../src/frame_m0.c **** asm("NOP"); // 1
1431 .loc 1 466 0
1432 @ 466 "../src/frame_m0.c" 1
1433 0042 C046 NOP
1434 @ 0 "" 2
467:../src/frame_m0.c **** asm("NOP"); // 1
1435 .loc 1 467 0
1436 @ 467 "../src/frame_m0.c" 1
1437 0044 C046 NOP
1438 @ 0 "" 2
468:../src/frame_m0.c **** asm("NOP"); // 1
1439 .loc 1 468 0
1440 @ 468 "../src/frame_m0.c" 1
1441 0046 C046 NOP
1442 @ 0 "" 2
469:../src/frame_m0.c **** asm("NOP"); // 1
1443 .loc 1 469 0
1444 @ 469 "../src/frame_m0.c" 1
1445 0048 C046 NOP
1446 @ 0 "" 2
470:../src/frame_m0.c **** asm("NOP"); // 1
1447 .loc 1 470 0
1448 @ 470 "../src/frame_m0.c" 1
1449 004a C046 NOP
1450 @ 0 "" 2
471:../src/frame_m0.c **** asm("NOP"); // 1
1451 .loc 1 471 0
1452 @ 471 "../src/frame_m0.c" 1
1453 004c C046 NOP
1454 @ 0 "" 2
472:../src/frame_m0.c **** asm("NOP"); // 1
1455 .loc 1 472 0
1456 @ 472 "../src/frame_m0.c" 1
1457 004e C046 NOP
1458 @ 0 "" 2
473:../src/frame_m0.c **** asm("BGE dest5"); // 3
1459 .loc 1 473 0
1460 @ 473 "../src/frame_m0.c" 1
1461 0050 E9DA BGE dest5
1462 @ 0 "" 2
474:../src/frame_m0.c ****
475:../src/frame_m0.c **** // variable delay --- get correct phase for sampling
476:../src/frame_m0.c **** asm("NOP");
1463 .loc 1 476 0
1464 @ 476 "../src/frame_m0.c" 1
1465 0052 C046 NOP
1466 @ 0 "" 2
477:../src/frame_m0.c **** asm("NOP");
1467 .loc 1 477 0
1468 @ 477 "../src/frame_m0.c" 1
1469 0054 C046 NOP
1470 @ 0 "" 2
478:../src/frame_m0.c ****
479:../src/frame_m0.c **** asm("loop4:");
1471 .loc 1 479 0
1472 @ 479 "../src/frame_m0.c" 1
1473 loop4:
1474 @ 0 "" 2
480:../src/frame_m0.c **** asm("LDRB r3, [r0]"); // 0
1475 .loc 1 480 0
1476 @ 480 "../src/frame_m0.c" 1
1477 0056 0378 LDRB r3, [r0]
1478 @ 0 "" 2
481:../src/frame_m0.c **** asm("LDRH r6, [r1, #0x00]");
1479 .loc 1 481 0
1480 @ 481 "../src/frame_m0.c" 1
1481 0058 0E88 LDRH r6, [r1, #0x00]
1482 @ 0 "" 2
482:../src/frame_m0.c **** asm("ADDS r6, r3");
1483 .loc 1 482 0
1484 @ 482 "../src/frame_m0.c" 1
1485 005a F618 ADDS r6, r3
1486 @ 0 "" 2
483:../src/frame_m0.c **** asm("NOP");
1487 .loc 1 483 0
1488 @ 483 "../src/frame_m0.c" 1
1489 005c C046 NOP
1490 @ 0 "" 2
484:../src/frame_m0.c **** asm("NOP");
1491 .loc 1 484 0
1492 @ 484 "../src/frame_m0.c" 1
1493 005e C046 NOP
1494 @ 0 "" 2
485:../src/frame_m0.c **** asm("NOP");
1495 .loc 1 485 0
1496 @ 485 "../src/frame_m0.c" 1
1497 0060 C046 NOP
1498 @ 0 "" 2
486:../src/frame_m0.c **** asm("NOP");
1499 .loc 1 486 0
1500 @ 486 "../src/frame_m0.c" 1
1501 0062 C046 NOP
1502 @ 0 "" 2
487:../src/frame_m0.c **** asm("NOP");
1503 .loc 1 487 0
1504 @ 487 "../src/frame_m0.c" 1
1505 0064 C046 NOP
1506 @ 0 "" 2
488:../src/frame_m0.c **** asm("NOP");
1507 .loc 1 488 0
1508 @ 488 "../src/frame_m0.c" 1
1509 0066 C046 NOP
1510 @ 0 "" 2
489:../src/frame_m0.c **** asm("NOP");
1511 .loc 1 489 0
1512 @ 489 "../src/frame_m0.c" 1
1513 0068 C046 NOP
1514 @ 0 "" 2
490:../src/frame_m0.c ****
491:../src/frame_m0.c **** asm("LDRB r3, [r0]"); // 0
1515 .loc 1 491 0
1516 @ 491 "../src/frame_m0.c" 1
1517 006a 0378 LDRB r3, [r0]
1518 @ 0 "" 2
492:../src/frame_m0.c **** asm("LDRH r7, [r1, #0x02]");
1519 .loc 1 492 0
1520 @ 492 "../src/frame_m0.c" 1
1521 006c 4F88 LDRH r7, [r1, #0x02]
1522 @ 0 "" 2
493:../src/frame_m0.c **** asm("ADDS r7, r3");
1523 .loc 1 493 0
1524 @ 493 "../src/frame_m0.c" 1
1525 006e FF18 ADDS r7, r3
1526 @ 0 "" 2
494:../src/frame_m0.c **** asm("NOP");
1527 .loc 1 494 0
1528 @ 494 "../src/frame_m0.c" 1
1529 0070 C046 NOP
1530 @ 0 "" 2
495:../src/frame_m0.c **** asm("NOP");
1531 .loc 1 495 0
1532 @ 495 "../src/frame_m0.c" 1
1533 0072 C046 NOP
1534 @ 0 "" 2
496:../src/frame_m0.c **** asm("NOP");
1535 .loc 1 496 0
1536 @ 496 "../src/frame_m0.c" 1
1537 0074 C046 NOP
1538 @ 0 "" 2
497:../src/frame_m0.c **** asm("NOP");
1539 .loc 1 497 0
1540 @ 497 "../src/frame_m0.c" 1
1541 0076 C046 NOP
1542 @ 0 "" 2
498:../src/frame_m0.c **** asm("NOP");
1543 .loc 1 498 0
1544 @ 498 "../src/frame_m0.c" 1
1545 0078 C046 NOP
1546 @ 0 "" 2
499:../src/frame_m0.c **** asm("NOP");
1547 .loc 1 499 0
1548 @ 499 "../src/frame_m0.c" 1
1549 007a C046 NOP
1550 @ 0 "" 2
500:../src/frame_m0.c **** asm("NOP");
1551 .loc 1 500 0
1552 @ 500 "../src/frame_m0.c" 1
1553 007c C046 NOP
1554 @ 0 "" 2
501:../src/frame_m0.c ****
502:../src/frame_m0.c **** asm("LDRB r3, [r0]"); // 0
1555 .loc 1 502 0
1556 @ 502 "../src/frame_m0.c" 1
1557 007e 0378 LDRB r3, [r0]
1558 @ 0 "" 2
503:../src/frame_m0.c **** asm("ADDS r6, r3");
1559 .loc 1 503 0
1560 @ 503 "../src/frame_m0.c" 1
1561 0080 F618 ADDS r6, r3
1562 @ 0 "" 2
504:../src/frame_m0.c **** asm("LSRS r6, #2");
1563 .loc 1 504 0
1564 @ 504 "../src/frame_m0.c" 1
1565 0082 B608 LSRS r6, #2
1566 @ 0 "" 2
505:../src/frame_m0.c **** asm("STRB r6, [r2, #0x00]");
1567 .loc 1 505 0
1568 @ 505 "../src/frame_m0.c" 1
1569 0084 1670 STRB r6, [r2, #0x00]
1570 @ 0 "" 2
506:../src/frame_m0.c **** asm("NOP");
1571 .loc 1 506 0
1572 @ 506 "../src/frame_m0.c" 1
1573 0086 C046 NOP
1574 @ 0 "" 2
507:../src/frame_m0.c **** asm("NOP");
1575 .loc 1 507 0
1576 @ 507 "../src/frame_m0.c" 1
1577 0088 C046 NOP
1578 @ 0 "" 2
508:../src/frame_m0.c **** asm("NOP");
1579 .loc 1 508 0
1580 @ 508 "../src/frame_m0.c" 1
1581 008a C046 NOP
1582 @ 0 "" 2
509:../src/frame_m0.c **** asm("NOP");
1583 .loc 1 509 0
1584 @ 509 "../src/frame_m0.c" 1
1585 008c C046 NOP
1586 @ 0 "" 2
510:../src/frame_m0.c **** asm("NOP");
1587 .loc 1 510 0
1588 @ 510 "../src/frame_m0.c" 1
1589 008e C046 NOP
1590 @ 0 "" 2
511:../src/frame_m0.c **** asm("NOP");
1591 .loc 1 511 0
1592 @ 511 "../src/frame_m0.c" 1
1593 0090 C046 NOP
1594 @ 0 "" 2
512:../src/frame_m0.c ****
513:../src/frame_m0.c **** asm("LDRB r3, [r0]"); // 0
1595 .loc 1 513 0
1596 @ 513 "../src/frame_m0.c" 1
1597 0092 0378 LDRB r3, [r0]
1598 @ 0 "" 2
514:../src/frame_m0.c **** asm("ADDS r7, r3");
1599 .loc 1 514 0
1600 @ 514 "../src/frame_m0.c" 1
1601 0094 FF18 ADDS r7, r3
1602 @ 0 "" 2
515:../src/frame_m0.c **** asm("LSRS r7, #2");
1603 .loc 1 515 0
1604 @ 515 "../src/frame_m0.c" 1
1605 0096 BF08 LSRS r7, #2
1606 @ 0 "" 2
516:../src/frame_m0.c **** asm("STRB r7, [r2, #0x01]");
1607 .loc 1 516 0
1608 @ 516 "../src/frame_m0.c" 1
1609 0098 5770 STRB r7, [r2, #0x01]
1610 @ 0 "" 2
517:../src/frame_m0.c **** asm("ADDS r1, #0x04");
1611 .loc 1 517 0
1612 @ 517 "../src/frame_m0.c" 1
1613 009a 0431 ADDS r1, #0x04
1614 @ 0 "" 2
518:../src/frame_m0.c **** asm("ADDS r2, #0x02");
1615 .loc 1 518 0
1616 @ 518 "../src/frame_m0.c" 1
1617 009c 0232 ADDS r2, #0x02
1618 @ 0 "" 2
519:../src/frame_m0.c **** asm("CMP r2, r4");
1619 .loc 1 519 0
1620 @ 519 "../src/frame_m0.c" 1
1621 009e A242 CMP r2, r4
1622 @ 0 "" 2
520:../src/frame_m0.c **** asm("BLT loop4");
1623 .loc 1 520 0
1624 @ 520 "../src/frame_m0.c" 1
1625 00a0 D9DB BLT loop4
1626 @ 0 "" 2
521:../src/frame_m0.c ****
522:../src/frame_m0.c **** // wait for hsync to go low (end of line)
523:../src/frame_m0.c **** asm("dest6:");
1627 .loc 1 523 0
1628 @ 523 "../src/frame_m0.c" 1
1629 dest6:
1630 @ 0 "" 2
524:../src/frame_m0.c **** asm("LDR r6, [r0]"); // 2
1631 .loc 1 524 0
1632 @ 524 "../src/frame_m0.c" 1
1633 00a2 0668 LDR r6, [r0]
1634 @ 0 "" 2
525:../src/frame_m0.c **** asm("TST r6, r5"); // 1
1635 .loc 1 525 0
1636 @ 525 "../src/frame_m0.c" 1
1637 00a4 2E42 TST r6, r5
1638 @ 0 "" 2
526:../src/frame_m0.c **** asm("BNE dest6"); // 3
1639 .loc 1 526 0
1640 @ 526 "../src/frame_m0.c" 1
1641 00a6 FCD1 BNE dest6
1642 @ 0 "" 2
527:../src/frame_m0.c ****
528:../src/frame_m0.c **** asm("POP {r4-r7}");
1643 .loc 1 528 0
1644 @ 528 "../src/frame_m0.c" 1
1645 00a8 F0BC POP {r4-r7}
1646 @ 0 "" 2
529:../src/frame_m0.c ****
530:../src/frame_m0.c **** asm(".syntax divided");
1647 .loc 1 530 0
1648 @ 530 "../src/frame_m0.c" 1
1649 .syntax divided
1650 @ 0 "" 2
531:../src/frame_m0.c **** }
1651 .loc 1 531 0
1652 .thumb
1653 .syntax unified
1654 00aa C046 nop
1655 00ac BD46 mov sp, r7
1656 00ae 04B0 add sp, sp, #16
1657 @ sp needed
1658 00b0 80BD pop {r7, pc}
1659 .cfi_endproc
1660 .LFE38:
1662 00b2 C046 .section .text.skipLine,"ax",%progbits
1663 .align 2
1664 .global skipLine
1665 .code 16
1666 .thumb_func
1668 skipLine:
1669 .LFB39:
532:../src/frame_m0.c ****
533:../src/frame_m0.c ****
534:../src/frame_m0.c **** void skipLine()
535:../src/frame_m0.c **** {
1670 .loc 1 535 0
1671 .cfi_startproc
1672 0000 80B5 push {r7, lr}
1673 .cfi_def_cfa_offset 8
1674 .cfi_offset 7, -8
1675 .cfi_offset 14, -4
1676 0002 00AF add r7, sp, #0
1677 .cfi_def_cfa_register 7
536:../src/frame_m0.c **** while(!CAM_HSYNC());
1678 .loc 1 536 0
1679 0004 C046 nop
1680 .L20:
1681 .loc 1 536 0 is_stmt 0 discriminator 1
1682 0006 094A ldr r2, .L22
1683 0008 094B ldr r3, .L22+4
1684 000a D258 ldr r2, [r2, r3]
1685 000c 8023 movs r3, #128
1686 000e 1B01 lsls r3, r3, #4
1687 0010 1340 ands r3, r2
1688 0012 F8D0 beq .L20
537:../src/frame_m0.c **** while(CAM_HSYNC());
1689 .loc 1 537 0 is_stmt 1
1690 0014 C046 nop
1691 .L21:
1692 .loc 1 537 0 is_stmt 0 discriminator 1
1693 0016 054A ldr r2, .L22
1694 0018 054B ldr r3, .L22+4
1695 001a D258 ldr r2, [r2, r3]
1696 001c 8023 movs r3, #128
1697 001e 1B01 lsls r3, r3, #4
1698 0020 1340 ands r3, r2
1699 0022 F8D1 bne .L21
538:../src/frame_m0.c **** }
1700 .loc 1 538 0 is_stmt 1
1701 0024 C046 nop
1702 0026 BD46 mov sp, r7
1703 @ sp needed
1704 0028 80BD pop {r7, pc}
1705 .L23:
1706 002a C046 .align 2
1707 .L22:
1708 002c 00400F40 .word 1074741248
1709 0030 04210000 .word 8452
1710 .cfi_endproc
1711 .LFE39:
1713 .section .text.skipLines,"ax",%progbits
1714 .align 2
1715 .global skipLines
1716 .code 16
1717 .thumb_func
1719 skipLines:
1720 .LFB40:
539:../src/frame_m0.c ****
540:../src/frame_m0.c ****
541:../src/frame_m0.c **** void skipLines(uint32_t lines)
542:../src/frame_m0.c **** {
1721 .loc 1 542 0
1722 .cfi_startproc
1723 0000 80B5 push {r7, lr}
1724 .cfi_def_cfa_offset 8
1725 .cfi_offset 7, -8
1726 .cfi_offset 14, -4
1727 0002 84B0 sub sp, sp, #16
1728 .cfi_def_cfa_offset 24
1729 0004 00AF add r7, sp, #0
1730 .cfi_def_cfa_register 7
1731 0006 7860 str r0, [r7, #4]
543:../src/frame_m0.c **** uint32_t line;
544:../src/frame_m0.c ****
545:../src/frame_m0.c **** // wait for remainder of frame to pass
546:../src/frame_m0.c **** while(!CAM_VSYNC());
1732 .loc 1 546 0
1733 0008 C046 nop
1734 .L25:
1735 .loc 1 546 0 is_stmt 0 discriminator 1
1736 000a 0F4A ldr r2, .L29
1737 000c 0F4B ldr r3, .L29+4
1738 000e D258 ldr r2, [r2, r3]
1739 0010 8023 movs r3, #128
1740 0012 5B01 lsls r3, r3, #5
1741 0014 1340 ands r3, r2
1742 0016 F8D0 beq .L25
547:../src/frame_m0.c **** // vsync asserted
548:../src/frame_m0.c **** while(CAM_VSYNC());
1743 .loc 1 548 0 is_stmt 1
1744 0018 C046 nop
1745 .L26:
1746 .loc 1 548 0 is_stmt 0 discriminator 1
1747 001a 0B4A ldr r2, .L29
1748 001c 0B4B ldr r3, .L29+4
1749 001e D258 ldr r2, [r2, r3]
1750 0020 8023 movs r3, #128
1751 0022 5B01 lsls r3, r3, #5
1752 0024 1340 ands r3, r2
1753 0026 F8D1 bne .L26
549:../src/frame_m0.c **** // skip lines
550:../src/frame_m0.c **** for (line=0; line<lines; line++)
1754 .loc 1 550 0 is_stmt 1
1755 0028 0023 movs r3, #0
1756 002a FB60 str r3, [r7, #12]
1757 002c 04E0 b .L27
1758 .L28:
551:../src/frame_m0.c **** skipLine();
1759 .loc 1 551 0 discriminator 3
1760 002e FFF7FEFF bl skipLine
550:../src/frame_m0.c **** skipLine();
1761 .loc 1 550 0 discriminator 3
1762 0032 FB68 ldr r3, [r7, #12]
1763 0034 0133 adds r3, r3, #1
1764 0036 FB60 str r3, [r7, #12]
1765 .L27:
550:../src/frame_m0.c **** skipLine();
1766 .loc 1 550 0 is_stmt 0 discriminator 1
1767 0038 FA68 ldr r2, [r7, #12]
1768 003a 7B68 ldr r3, [r7, #4]
1769 003c 9A42 cmp r2, r3
1770 003e F6D3 bcc .L28
552:../src/frame_m0.c **** }
1771 .loc 1 552 0 is_stmt 1
1772 0040 C046 nop
1773 0042 BD46 mov sp, r7
1774 0044 04B0 add sp, sp, #16
1775 @ sp needed
1776 0046 80BD pop {r7, pc}
1777 .L30:
1778 .align 2
1779 .L29:
1780 0048 00400F40 .word 1074741248
1781 004c 04210000 .word 8452
1782 .cfi_endproc
1783 .LFE40:
1785 .section .text.grabM0R0,"ax",%progbits
1786 .align 2
1787 .global grabM0R0
1788 .code 16
1789 .thumb_func
1791 grabM0R0:
1792 .LFB41:
553:../src/frame_m0.c ****
554:../src/frame_m0.c ****
555:../src/frame_m0.c **** void grabM0R0(uint32_t xoffset, uint32_t yoffset, uint32_t xwidth, uint32_t ywidth, uint8_t *memory
556:../src/frame_m0.c **** {
1793 .loc 1 556 0
1794 .cfi_startproc
1795 0000 80B5 push {r7, lr}
1796 .cfi_def_cfa_offset 8
1797 .cfi_offset 7, -8
1798 .cfi_offset 14, -4
1799 0002 86B0 sub sp, sp, #24
1800 .cfi_def_cfa_offset 32
1801 0004 00AF add r7, sp, #0
1802 .cfi_def_cfa_register 7
1803 0006 F860 str r0, [r7, #12]
1804 0008 B960 str r1, [r7, #8]
1805 000a 7A60 str r2, [r7, #4]
1806 000c 3B60 str r3, [r7]
557:../src/frame_m0.c **** uint32_t line;
558:../src/frame_m0.c ****
559:../src/frame_m0.c **** xoffset >>= 1;
1807 .loc 1 559 0
1808 000e FB68 ldr r3, [r7, #12]
1809 0010 5B08 lsrs r3, r3, #1
1810 0012 FB60 str r3, [r7, #12]
560:../src/frame_m0.c **** yoffset &= ~1;
1811 .loc 1 560 0
1812 0014 BB68 ldr r3, [r7, #8]
1813 0016 0122 movs r2, #1
1814 0018 9343 bics r3, r2
1815 001a BB60 str r3, [r7, #8]
561:../src/frame_m0.c ****
562:../src/frame_m0.c **** skipLines(yoffset);
1816 .loc 1 562 0
1817 001c BB68 ldr r3, [r7, #8]
1818 001e 1800 movs r0, r3
1819 0020 FFF7FEFF bl skipLines
563:../src/frame_m0.c **** for (line=0; line<ywidth; line++, memory+=xwidth)
1820 .loc 1 563 0
1821 0024 0023 movs r3, #0
1822 0026 7B61 str r3, [r7, #20]
1823 0028 0CE0 b .L32
1824 .L33:
564:../src/frame_m0.c **** lineM0((uint32_t *)&CAM_PORT, memory, xoffset, xwidth); // wait, grab, wait
1825 .loc 1 564 0 discriminator 3
1826 002a 7B68 ldr r3, [r7, #4]
1827 002c FA68 ldr r2, [r7, #12]
1828 002e 396A ldr r1, [r7, #32]
1829 0030 0848 ldr r0, .L34
1830 0032 FFF7FEFF bl lineM0
563:../src/frame_m0.c **** for (line=0; line<ywidth; line++, memory+=xwidth)
1831 .loc 1 563 0 discriminator 3
1832 0036 7B69 ldr r3, [r7, #20]
1833 0038 0133 adds r3, r3, #1
1834 003a 7B61 str r3, [r7, #20]
1835 003c 3A6A ldr r2, [r7, #32]
1836 003e 7B68 ldr r3, [r7, #4]
1837 0040 D318 adds r3, r2, r3
1838 0042 3B62 str r3, [r7, #32]
1839 .L32:
563:../src/frame_m0.c **** for (line=0; line<ywidth; line++, memory+=xwidth)
1840 .loc 1 563 0 is_stmt 0 discriminator 1
1841 0044 7A69 ldr r2, [r7, #20]
1842 0046 3B68 ldr r3, [r7]
1843 0048 9A42 cmp r2, r3
1844 004a EED3 bcc .L33
565:../src/frame_m0.c **** }
1845 .loc 1 565 0 is_stmt 1
1846 004c C046 nop
1847 004e BD46 mov sp, r7
1848 0050 06B0 add sp, sp, #24
1849 @ sp needed
1850 0052 80BD pop {r7, pc}
1851 .L35:
1852 .align 2
1853 .L34:
1854 0054 04610F40 .word 1074749700
1855 .cfi_endproc
1856 .LFE41:
1858 .section .text.grabM1R1,"ax",%progbits
1859 .align 2
1860 .global grabM1R1
1861 .code 16
1862 .thumb_func
1864 grabM1R1:
1865 .LFB42:
566:../src/frame_m0.c ****
567:../src/frame_m0.c ****
568:../src/frame_m0.c **** void grabM1R1(uint32_t xoffset, uint32_t yoffset, uint32_t xwidth, uint32_t ywidth, uint8_t *memory
569:../src/frame_m0.c **** {
1866 .loc 1 569 0
1867 .cfi_startproc
1868 0000 80B5 push {r7, lr}
1869 .cfi_def_cfa_offset 8
1870 .cfi_offset 7, -8
1871 .cfi_offset 14, -4
1872 0002 86B0 sub sp, sp, #24
1873 .cfi_def_cfa_offset 32
1874 0004 00AF add r7, sp, #0
1875 .cfi_def_cfa_register 7
1876 0006 F860 str r0, [r7, #12]
1877 0008 B960 str r1, [r7, #8]
1878 000a 7A60 str r2, [r7, #4]
1879 000c 3B60 str r3, [r7]
570:../src/frame_m0.c **** uint32_t line;
571:../src/frame_m0.c ****
572:../src/frame_m0.c **** xoffset >>= 1;
1880 .loc 1 572 0
1881 000e FB68 ldr r3, [r7, #12]
1882 0010 5B08 lsrs r3, r3, #1
1883 0012 FB60 str r3, [r7, #12]
573:../src/frame_m0.c **** yoffset &= ~1;
1884 .loc 1 573 0
1885 0014 BB68 ldr r3, [r7, #8]
1886 0016 0122 movs r2, #1
1887 0018 9343 bics r3, r2
1888 001a BB60 str r3, [r7, #8]
574:../src/frame_m0.c ****
575:../src/frame_m0.c **** skipLines(yoffset);
1889 .loc 1 575 0
1890 001c BB68 ldr r3, [r7, #8]
1891 001e 1800 movs r0, r3
1892 0020 FFF7FEFF bl skipLines
576:../src/frame_m0.c **** for (line=0; line<ywidth; line++, memory+=xwidth)
1893 .loc 1 576 0
1894 0024 0023 movs r3, #0
1895 0026 7B61 str r3, [r7, #20]
1896 0028 0CE0 b .L37
1897 .L38:
577:../src/frame_m0.c **** lineM1R1((uint32_t *)&CAM_PORT, memory, xoffset, xwidth); // wait, grab, wait
1898 .loc 1 577 0 discriminator 3
1899 002a 7B68 ldr r3, [r7, #4]
1900 002c FA68 ldr r2, [r7, #12]
1901 002e 396A ldr r1, [r7, #32]
1902 0030 0848 ldr r0, .L39
1903 0032 FFF7FEFF bl lineM1R1
576:../src/frame_m0.c **** for (line=0; line<ywidth; line++, memory+=xwidth)
1904 .loc 1 576 0 discriminator 3
1905 0036 7B69 ldr r3, [r7, #20]
1906 0038 0133 adds r3, r3, #1
1907 003a 7B61 str r3, [r7, #20]
1908 003c 3A6A ldr r2, [r7, #32]
1909 003e 7B68 ldr r3, [r7, #4]
1910 0040 D318 adds r3, r2, r3
1911 0042 3B62 str r3, [r7, #32]
1912 .L37:
576:../src/frame_m0.c **** for (line=0; line<ywidth; line++, memory+=xwidth)
1913 .loc 1 576 0 is_stmt 0 discriminator 1
1914 0044 7A69 ldr r2, [r7, #20]
1915 0046 3B68 ldr r3, [r7]
1916 0048 9A42 cmp r2, r3
1917 004a EED3 bcc .L38
578:../src/frame_m0.c **** }
1918 .loc 1 578 0 is_stmt 1
1919 004c C046 nop
1920 004e BD46 mov sp, r7
1921 0050 06B0 add sp, sp, #24
1922 @ sp needed
1923 0052 80BD pop {r7, pc}
1924 .L40:
1925 .align 2
1926 .L39:
1927 0054 04610F40 .word 1074749700
1928 .cfi_endproc
1929 .LFE42:
1931 .section .text.grabM1R2,"ax",%progbits
1932 .align 2
1933 .global grabM1R2
1934 .code 16
1935 .thumb_func
1937 grabM1R2:
1938 .LFB43:
579:../src/frame_m0.c ****
580:../src/frame_m0.c ****
581:../src/frame_m0.c **** void grabM1R2(uint32_t xoffset, uint32_t yoffset, uint32_t xwidth, uint32_t ywidth, uint8_t *memory
582:../src/frame_m0.c **** {
1939 .loc 1 582 0
1940 .cfi_startproc
1941 0000 90B5 push {r4, r7, lr}
1942 .cfi_def_cfa_offset 12
1943 .cfi_offset 4, -12
1944 .cfi_offset 7, -8
1945 .cfi_offset 14, -4
1946 0002 89B0 sub sp, sp, #36
1947 .cfi_def_cfa_offset 48
1948 0004 02AF add r7, sp, #8
1949 .cfi_def_cfa 7, 40
1950 0006 F860 str r0, [r7, #12]
1951 0008 B960 str r1, [r7, #8]
1952 000a 7A60 str r2, [r7, #4]
1953 000c 3B60 str r3, [r7]
583:../src/frame_m0.c **** uint32_t line;
584:../src/frame_m0.c **** uint16_t *lineStore = (uint16_t *)(memory + xwidth*ywidth + 16);
1954 .loc 1 584 0
1955 000e 7B68 ldr r3, [r7, #4]
1956 0010 3A68 ldr r2, [r7]
1957 0012 5343 muls r3, r2
1958 0014 1033 adds r3, r3, #16
1959 0016 BA6A ldr r2, [r7, #40]
1960 0018 D318 adds r3, r2, r3
1961 001a 3B61 str r3, [r7, #16]
585:../src/frame_m0.c **** lineStore = (uint16_t *)ALIGN(lineStore, 2);
1962 .loc 1 585 0
1963 001c 3B69 ldr r3, [r7, #16]
1964 001e 0122 movs r2, #1
1965 0020 1340 ands r3, r2
1966 0022 04D0 beq .L42
1967 .loc 1 585 0 is_stmt 0 discriminator 1
1968 0024 3B69 ldr r3, [r7, #16]
1969 0026 0122 movs r2, #1
1970 0028 9343 bics r3, r2
1971 002a 0233 adds r3, r3, #2
1972 002c 00E0 b .L43
1973 .L42:
1974 .loc 1 585 0 discriminator 2
1975 002e 3B69 ldr r3, [r7, #16]
1976 .L43:
1977 .loc 1 585 0 discriminator 4
1978 0030 3B61 str r3, [r7, #16]
586:../src/frame_m0.c ****
587:../src/frame_m0.c **** // clear line storage for 1 line
588:../src/frame_m0.c **** for (line=0; line<xwidth; line++)
1979 .loc 1 588 0 is_stmt 1 discriminator 4
1980 0032 0023 movs r3, #0
1981 0034 7B61 str r3, [r7, #20]
1982 0036 08E0 b .L44
1983 .L45:
589:../src/frame_m0.c **** lineStore[line] = 0;
1984 .loc 1 589 0 discriminator 3
1985 0038 7B69 ldr r3, [r7, #20]
1986 003a 5B00 lsls r3, r3, #1
1987 003c 3A69 ldr r2, [r7, #16]
1988 003e D318 adds r3, r2, r3
1989 0040 0022 movs r2, #0
1990 0042 1A80 strh r2, [r3]
588:../src/frame_m0.c **** lineStore[line] = 0;
1991 .loc 1 588 0 discriminator 3
1992 0044 7B69 ldr r3, [r7, #20]
1993 0046 0133 adds r3, r3, #1
1994 0048 7B61 str r3, [r7, #20]
1995 .L44:
588:../src/frame_m0.c **** lineStore[line] = 0;
1996 .loc 1 588 0 is_stmt 0 discriminator 1
1997 004a 7A69 ldr r2, [r7, #20]
1998 004c 7B68 ldr r3, [r7, #4]
1999 004e 9A42 cmp r2, r3
2000 0050 F2D3 bcc .L45
590:../src/frame_m0.c ****
591:../src/frame_m0.c **** skipLines(yoffset*2);
2001 .loc 1 591 0 is_stmt 1
2002 0052 BB68 ldr r3, [r7, #8]
2003 0054 5B00 lsls r3, r3, #1
2004 0056 1800 movs r0, r3
2005 0058 FFF7FEFF bl skipLines
592:../src/frame_m0.c **** // grab 1 line to put us out of phase with the camera's internal vertical downsample (800 to 400 l
593:../src/frame_m0.c **** // ie, we are going to downsample again from 400 to 200. Because the bayer lines alternate
594:../src/frame_m0.c **** // there tends to be little difference between line pairs bg and gr lines after downsampling.
595:../src/frame_m0.c **** // Same logic applies horizontally as well, but we always skip a pixel pair in the line routine.
596:../src/frame_m0.c **** lineM1R2Merge((uint32_t *)&CAM_PORT, lineStore, memory, xoffset, xwidth); // wait, grab, wait
2006 .loc 1 596 0
2007 005c F868 ldr r0, [r7, #12]
2008 005e BA6A ldr r2, [r7, #40]
2009 0060 3969 ldr r1, [r7, #16]
2010 0062 244C ldr r4, .L49
2011 0064 7B68 ldr r3, [r7, #4]
2012 0066 0093 str r3, [sp]
2013 0068 0300 movs r3, r0
2014 006a 2000 movs r0, r4
2015 006c FFF7FEFF bl lineM1R2Merge
597:../src/frame_m0.c **** memory += xwidth;
2016 .loc 1 597 0
2017 0070 BA6A ldr r2, [r7, #40]
2018 0072 7B68 ldr r3, [r7, #4]
2019 0074 D318 adds r3, r2, r3
2020 0076 BB62 str r3, [r7, #40]
598:../src/frame_m0.c **** for (line=0; line<ywidth; line+=2, memory+=xwidth*2)
2021 .loc 1 598 0
2022 0078 0023 movs r3, #0
2023 007a 7B61 str r3, [r7, #20]
2024 007c 32E0 b .L46
2025 .L48:
599:../src/frame_m0.c **** {
600:../src/frame_m0.c **** // CAM_HSYNC is negated here
601:../src/frame_m0.c **** lineM1R2((uint32_t *)&CAM_PORT, lineStore, xoffset, xwidth); // wait, grab, wait
2026 .loc 1 601 0
2027 007e 7B68 ldr r3, [r7, #4]
2028 0080 FA68 ldr r2, [r7, #12]
2029 0082 3969 ldr r1, [r7, #16]
2030 0084 1B48 ldr r0, .L49
2031 0086 FFF7FEFF bl lineM1R2
602:../src/frame_m0.c **** lineM1R2((uint32_t *)&CAM_PORT, lineStore+xwidth, xoffset, xwidth); // wait, grab, wait
2032 .loc 1 602 0
2033 008a 7B68 ldr r3, [r7, #4]
2034 008c 5B00 lsls r3, r3, #1
2035 008e 3A69 ldr r2, [r7, #16]
2036 0090 D118 adds r1, r2, r3
2037 0092 7B68 ldr r3, [r7, #4]
2038 0094 FA68 ldr r2, [r7, #12]
2039 0096 1748 ldr r0, .L49
2040 0098 FFF7FEFF bl lineM1R2
603:../src/frame_m0.c **** lineM1R2Merge((uint32_t *)&CAM_PORT, lineStore, memory, xoffset, xwidth); // wait, grab, wait
2041 .loc 1 603 0
2042 009c F868 ldr r0, [r7, #12]
2043 009e BA6A ldr r2, [r7, #40]
2044 00a0 3969 ldr r1, [r7, #16]
2045 00a2 144C ldr r4, .L49
2046 00a4 7B68 ldr r3, [r7, #4]
2047 00a6 0093 str r3, [sp]
2048 00a8 0300 movs r3, r0
2049 00aa 2000 movs r0, r4
2050 00ac FFF7FEFF bl lineM1R2Merge
604:../src/frame_m0.c **** if (line<CAM_RES2_HEIGHT-2)
2051 .loc 1 604 0
2052 00b0 7B69 ldr r3, [r7, #20]
2053 00b2 C52B cmp r3, #197
2054 00b4 0ED8 bhi .L47
605:../src/frame_m0.c **** lineM1R2Merge((uint32_t *)&CAM_PORT, lineStore+xwidth, memory+xwidth, xoffset, xwidth); // wait,
2055 .loc 1 605 0
2056 00b6 7B68 ldr r3, [r7, #4]
2057 00b8 5B00 lsls r3, r3, #1
2058 00ba 3A69 ldr r2, [r7, #16]
2059 00bc D118 adds r1, r2, r3
2060 00be BA6A ldr r2, [r7, #40]
2061 00c0 7B68 ldr r3, [r7, #4]
2062 00c2 D218 adds r2, r2, r3
2063 00c4 F868 ldr r0, [r7, #12]
2064 00c6 0B4C ldr r4, .L49
2065 00c8 7B68 ldr r3, [r7, #4]
2066 00ca 0093 str r3, [sp]
2067 00cc 0300 movs r3, r0
2068 00ce 2000 movs r0, r4
2069 00d0 FFF7FEFF bl lineM1R2Merge
2070 .L47:
598:../src/frame_m0.c **** {
2071 .loc 1 598 0 discriminator 2
2072 00d4 7B69 ldr r3, [r7, #20]
2073 00d6 0233 adds r3, r3, #2
2074 00d8 7B61 str r3, [r7, #20]
2075 00da 7B68 ldr r3, [r7, #4]
2076 00dc 5B00 lsls r3, r3, #1
2077 00de BA6A ldr r2, [r7, #40]
2078 00e0 D318 adds r3, r2, r3
2079 00e2 BB62 str r3, [r7, #40]
2080 .L46:
598:../src/frame_m0.c **** {
2081 .loc 1 598 0 is_stmt 0 discriminator 1
2082 00e4 7A69 ldr r2, [r7, #20]
2083 00e6 3B68 ldr r3, [r7]
2084 00e8 9A42 cmp r2, r3
2085 00ea C8D3 bcc .L48
606:../src/frame_m0.c **** }
607:../src/frame_m0.c **** }
2086 .loc 1 607 0 is_stmt 1
2087 00ec C046 nop
2088 00ee BD46 mov sp, r7
2089 00f0 07B0 add sp, sp, #28
2090 @ sp needed
2091 00f2 90BD pop {r4, r7, pc}
2092 .L50:
2093 .align 2
2094 .L49:
2095 00f4 04610F40 .word 1074749700
2096 .cfi_endproc
2097 .LFE43:
2099 .section .text.callSyncM0,"ax",%progbits
2100 .align 2
2101 .global callSyncM0
2102 .code 16
2103 .thumb_func
2105 callSyncM0:
2106 .LFB44:
608:../src/frame_m0.c ****
609:../src/frame_m0.c ****
610:../src/frame_m0.c **** void callSyncM0(void)
611:../src/frame_m0.c **** {
2107 .loc 1 611 0
2108 .cfi_startproc
2109 0000 80B5 push {r7, lr}
2110 .cfi_def_cfa_offset 8
2111 .cfi_offset 7, -8
2112 .cfi_offset 14, -4
2113 0002 00AF add r7, sp, #0
2114 .cfi_def_cfa_register 7
612:../src/frame_m0.c **** syncM0((uint32_t *)&CAM_PORT, CAM_PCLK_MASK);
2115 .loc 1 612 0
2116 0004 8023 movs r3, #128
2117 0006 9B01 lsls r3, r3, #6
2118 0008 034A ldr r2, .L52
2119 000a 1900 movs r1, r3
2120 000c 1000 movs r0, r2
2121 000e FFF7FEFF bl syncM0
613:../src/frame_m0.c **** }
2122 .loc 1 613 0
2123 0012 C046 nop
2124 0014 BD46 mov sp, r7
2125 @ sp needed
2126 0016 80BD pop {r7, pc}
2127 .L53:
2128 .align 2
2129 .L52:
2130 0018 04610F40 .word 1074749700
2131 .cfi_endproc
2132 .LFE44:
2134 .section .text.callSyncM1,"ax",%progbits
2135 .align 2
2136 .global callSyncM1
2137 .code 16
2138 .thumb_func
2140 callSyncM1:
2141 .LFB45:
614:../src/frame_m0.c ****
615:../src/frame_m0.c ****
616:../src/frame_m0.c **** void callSyncM1(void)
617:../src/frame_m0.c **** {
2142 .loc 1 617 0
2143 .cfi_startproc
2144 0000 80B5 push {r7, lr}
2145 .cfi_def_cfa_offset 8
2146 .cfi_offset 7, -8
2147 .cfi_offset 14, -4
2148 0002 00AF add r7, sp, #0
2149 .cfi_def_cfa_register 7
618:../src/frame_m0.c **** syncM1((uint32_t *)&CAM_PORT, CAM_PCLK_MASK);
2150 .loc 1 618 0
2151 0004 8023 movs r3, #128
2152 0006 9B01 lsls r3, r3, #6
2153 0008 034A ldr r2, .L55
2154 000a 1900 movs r1, r3
2155 000c 1000 movs r0, r2
2156 000e FFF7FEFF bl syncM1
619:../src/frame_m0.c **** }
2157 .loc 1 619 0
2158 0012 C046 nop
2159 0014 BD46 mov sp, r7
2160 @ sp needed
2161 0016 80BD pop {r7, pc}
2162 .L56:
2163 .align 2
2164 .L55:
2165 0018 04610F40 .word 1074749700
2166 .cfi_endproc
2167 .LFE45:
2169 .section .text.getFrame,"ax",%progbits
2170 .align 2
2171 .global getFrame
2172 .code 16
2173 .thumb_func
2175 getFrame:
2176 .LFB46:
620:../src/frame_m0.c ****
621:../src/frame_m0.c ****
622:../src/frame_m0.c **** int32_t getFrame(uint8_t *type, uint32_t *memory, uint16_t *xoffset, uint16_t *yoffset, uint16_t *x
623:../src/frame_m0.c **** {
2177 .loc 1 623 0
2178 .cfi_startproc
2179 0000 90B5 push {r4, r7, lr}
2180 .cfi_def_cfa_offset 12
2181 .cfi_offset 4, -12
2182 .cfi_offset 7, -8
2183 .cfi_offset 14, -4
2184 0002 87B0 sub sp, sp, #28
2185 .cfi_def_cfa_offset 40
2186 0004 02AF add r7, sp, #8
2187 .cfi_def_cfa 7, 32
2188 0006 F860 str r0, [r7, #12]
2189 0008 B960 str r1, [r7, #8]
2190 000a 7A60 str r2, [r7, #4]
2191 000c 3B60 str r3, [r7]
624:../src/frame_m0.c **** //printf("M0: grab %d %d %d %d %d\n", *type, *xoffset, *yoffset, *xwidth, *ywidth);
625:../src/frame_m0.c ****
626:../src/frame_m0.c **** if (*type==CAM_GRAB_M0R0)
2192 .loc 1 626 0
2193 000e FB68 ldr r3, [r7, #12]
2194 0010 1B78 ldrb r3, [r3]
2195 0012 002B cmp r3, #0
2196 0014 12D1 bne .L58
627:../src/frame_m0.c **** grabM0R0(*xoffset, *yoffset, *xwidth, *ywidth, (uint8_t *)*memory);
2197 .loc 1 627 0
2198 0016 7B68 ldr r3, [r7, #4]
2199 0018 1B88 ldrh r3, [r3]
2200 001a 1800 movs r0, r3
2201 001c 3B68 ldr r3, [r7]
2202 001e 1B88 ldrh r3, [r3]
2203 0020 1900 movs r1, r3
2204 0022 3B6A ldr r3, [r7, #32]
2205 0024 1B88 ldrh r3, [r3]
2206 0026 1A00 movs r2, r3
2207 0028 7B6A ldr r3, [r7, #36]
2208 002a 1B88 ldrh r3, [r3]
2209 002c 1C00 movs r4, r3
2210 002e BB68 ldr r3, [r7, #8]
2211 0030 1B68 ldr r3, [r3]
2212 0032 0093 str r3, [sp]
2213 0034 2300 movs r3, r4
2214 0036 FFF7FEFF bl grabM0R0
2215 003a 30E0 b .L59
2216 .L58:
628:../src/frame_m0.c **** else if (*type==CAM_GRAB_M1R1)
2217 .loc 1 628 0
2218 003c FB68 ldr r3, [r7, #12]
2219 003e 1B78 ldrb r3, [r3]
2220 0040 112B cmp r3, #17
2221 0042 12D1 bne .L60
629:../src/frame_m0.c **** grabM1R1(*xoffset, *yoffset, *xwidth, *ywidth, (uint8_t *)*memory);
2222 .loc 1 629 0
2223 0044 7B68 ldr r3, [r7, #4]
2224 0046 1B88 ldrh r3, [r3]
2225 0048 1800 movs r0, r3
2226 004a 3B68 ldr r3, [r7]
2227 004c 1B88 ldrh r3, [r3]
2228 004e 1900 movs r1, r3
2229 0050 3B6A ldr r3, [r7, #32]
2230 0052 1B88 ldrh r3, [r3]
2231 0054 1A00 movs r2, r3
2232 0056 7B6A ldr r3, [r7, #36]
2233 0058 1B88 ldrh r3, [r3]
2234 005a 1C00 movs r4, r3
2235 005c BB68 ldr r3, [r7, #8]
2236 005e 1B68 ldr r3, [r3]
2237 0060 0093 str r3, [sp]
2238 0062 2300 movs r3, r4
2239 0064 FFF7FEFF bl grabM1R1
2240 0068 19E0 b .L59
2241 .L60:
630:../src/frame_m0.c **** else if (*type==CAM_GRAB_M1R2)
2242 .loc 1 630 0
2243 006a FB68 ldr r3, [r7, #12]
2244 006c 1B78 ldrb r3, [r3]
2245 006e 212B cmp r3, #33
2246 0070 12D1 bne .L61
631:../src/frame_m0.c **** grabM1R2(*xoffset, *yoffset, *xwidth, *ywidth, (uint8_t *)*memory);
2247 .loc 1 631 0
2248 0072 7B68 ldr r3, [r7, #4]
2249 0074 1B88 ldrh r3, [r3]
2250 0076 1800 movs r0, r3
2251 0078 3B68 ldr r3, [r7]
2252 007a 1B88 ldrh r3, [r3]
2253 007c 1900 movs r1, r3
2254 007e 3B6A ldr r3, [r7, #32]
2255 0080 1B88 ldrh r3, [r3]
2256 0082 1A00 movs r2, r3
2257 0084 7B6A ldr r3, [r7, #36]
2258 0086 1B88 ldrh r3, [r3]
2259 0088 1C00 movs r4, r3
2260 008a BB68 ldr r3, [r7, #8]
2261 008c 1B68 ldr r3, [r3]
2262 008e 0093 str r3, [sp]
2263 0090 2300 movs r3, r4
2264 0092 FFF7FEFF bl grabM1R2
2265 0096 02E0 b .L59
2266 .L61:
632:../src/frame_m0.c **** else
633:../src/frame_m0.c **** return -1;
2267 .loc 1 633 0
2268 0098 0123 movs r3, #1
2269 009a 5B42 rsbs r3, r3, #0
2270 009c 00E0 b .L62
2271 .L59:
634:../src/frame_m0.c ****
635:../src/frame_m0.c **** return 0;
2272 .loc 1 635 0
2273 009e 0023 movs r3, #0
2274 .L62:
636:../src/frame_m0.c **** }
2275 .loc 1 636 0
2276 00a0 1800 movs r0, r3
2277 00a2 BD46 mov sp, r7
2278 00a4 05B0 add sp, sp, #20
2279 @ sp needed
2280 00a6 90BD pop {r4, r7, pc}
2281 .cfi_endproc
2282 .LFE46:
2284 .section .rodata
2285 .align 2
2286 .LC1:
2287 0000 67657446 .ascii "getFrame\000"
2287 72616D65
2287 00
2288 .section .text.frame_init,"ax",%progbits
2289 .align 2
2290 .global frame_init
2291 .code 16
2292 .thumb_func
2294 frame_init:
2295 .LFB47:
637:../src/frame_m0.c ****
638:../src/frame_m0.c ****
639:../src/frame_m0.c **** int frame_init(void)
640:../src/frame_m0.c **** {
2296 .loc 1 640 0
2297 .cfi_startproc
2298 0000 80B5 push {r7, lr}
2299 .cfi_def_cfa_offset 8
2300 .cfi_offset 7, -8
2301 .cfi_offset 14, -4
2302 0002 00AF add r7, sp, #0
2303 .cfi_def_cfa_register 7
641:../src/frame_m0.c **** chirpSetProc("getFrame", (ProcPtr)getFrame);
2304 .loc 1 641 0
2305 0004 044A ldr r2, .L65
2306 0006 054B ldr r3, .L65+4
2307 0008 1100 movs r1, r2
2308 000a 1800 movs r0, r3
2309 000c FFF7FEFF bl chirpSetProc
642:../src/frame_m0.c ****
643:../src/frame_m0.c **** return 0;
2310 .loc 1 643 0
2311 0010 0023 movs r3, #0
644:../src/frame_m0.c **** }
2312 .loc 1 644 0
2313 0012 1800 movs r0, r3
2314 0014 BD46 mov sp, r7
2315 @ sp needed
2316 0016 80BD pop {r7, pc}
2317 .L66:
2318 .align 2
2319 .L65:
2320 0018 00000000 .word getFrame
2321 001c 00000000 .word .LC1
2322 .cfi_endproc
2323 .LFE47:
2325 .text
2326 .Letext0:
2327 .file 2 "/usr/local/lpcxpresso_8.1.4_606/lpcxpresso/tools/redlib/include/stdint.h"
2328 .file 3 "/home/weyoui/PROJECTS/SmartCart/Pixy/pixy/misc/gcc/pixy_m0/inc/lpc43xx.h"
2329 .file 4 "/home/weyoui/PROJECTS/SmartCart/Pixy/pixy/misc/gcc/m0/inc/chirp.h"
DEFINED SYMBOLS
*ABS*:00000000 frame_m0.c
/tmp/ccmWfK1Q.s:20 .text.vsync:00000000 $t
/tmp/ccmWfK1Q.s:25 .text.vsync:00000000 vsync
/tmp/ccmWfK1Q.s:109 .text.vsync:00000064 $d
/tmp/ccmWfK1Q.s:115 .text.syncM0:00000000 $t
/tmp/ccmWfK1Q.s:120 .text.syncM0:00000000 syncM0
/tmp/ccmWfK1Q.s:145 .text.syncM0:0000000c start
/tmp/ccmWfK1Q.s:239 .text.syncM1:00000000 $t
/tmp/ccmWfK1Q.s:244 .text.syncM1:00000000 syncM1
/tmp/ccmWfK1Q.s:269 .text.syncM1:0000000c startSyncM1
/tmp/ccmWfK1Q.s:447 .text.lineM0:00000000 $t
/tmp/ccmWfK1Q.s:452 .text.lineM0:00000000 lineM0
/tmp/ccmWfK1Q.s:2105 .text.callSyncM0:00000000 callSyncM0
/tmp/ccmWfK1Q.s:511 .text.lineM0:00000022 dest21
/tmp/ccmWfK1Q.s:527 .text.lineM0:00000028 dest22
/tmp/ccmWfK1Q.s:603 .text.lineM0:0000004c loop11
/tmp/ccmWfK1Q.s:647 .text.lineM0:00000060 dest13
/tmp/ccmWfK1Q.s:681 .text.lineM1R1:00000000 $t
/tmp/ccmWfK1Q.s:686 .text.lineM1R1:00000000 lineM1R1
/tmp/ccmWfK1Q.s:2140 .text.callSyncM1:00000000 callSyncM1
/tmp/ccmWfK1Q.s:737 .text.lineM1R1:0000001e dest1
/tmp/ccmWfK1Q.s:753 .text.lineM1R1:00000024 dest2
/tmp/ccmWfK1Q.s:853 .text.lineM1R1:00000054 loop1
/tmp/ccmWfK1Q.s:889 .text.lineM1R1:00000064 dest3
/tmp/ccmWfK1Q.s:923 .text.lineM1R2:00000000 $t
/tmp/ccmWfK1Q.s:928 .text.lineM1R2:00000000 lineM1R2
/tmp/ccmWfK1Q.s:983 .text.lineM1R2:00000020 dest7
/tmp/ccmWfK1Q.s:999 .text.lineM1R2:00000026 dest8
/tmp/ccmWfK1Q.s:1099 .text.lineM1R2:00000056 loop3
/tmp/ccmWfK1Q.s:1263 .text.lineM1R2:000000a6 dest9
/tmp/ccmWfK1Q.s:1297 .text.lineM1R2Merge:00000000 $t
/tmp/ccmWfK1Q.s:1302 .text.lineM1R2Merge:00000000 lineM1R2Merge
/tmp/ccmWfK1Q.s:1357 .text.lineM1R2Merge:00000020 dest4
/tmp/ccmWfK1Q.s:1373 .text.lineM1R2Merge:00000026 dest5
/tmp/ccmWfK1Q.s:1473 .text.lineM1R2Merge:00000056 loop4
/tmp/ccmWfK1Q.s:1629 .text.lineM1R2Merge:000000a2 dest6
/tmp/ccmWfK1Q.s:1663 .text.skipLine:00000000 $t
/tmp/ccmWfK1Q.s:1668 .text.skipLine:00000000 skipLine
/tmp/ccmWfK1Q.s:1708 .text.skipLine:0000002c $d
/tmp/ccmWfK1Q.s:1714 .text.skipLines:00000000 $t
/tmp/ccmWfK1Q.s:1719 .text.skipLines:00000000 skipLines
/tmp/ccmWfK1Q.s:1780 .text.skipLines:00000048 $d
/tmp/ccmWfK1Q.s:1786 .text.grabM0R0:00000000 $t
/tmp/ccmWfK1Q.s:1791 .text.grabM0R0:00000000 grabM0R0
/tmp/ccmWfK1Q.s:1854 .text.grabM0R0:00000054 $d
/tmp/ccmWfK1Q.s:1859 .text.grabM1R1:00000000 $t
/tmp/ccmWfK1Q.s:1864 .text.grabM1R1:00000000 grabM1R1
/tmp/ccmWfK1Q.s:1927 .text.grabM1R1:00000054 $d
/tmp/ccmWfK1Q.s:1932 .text.grabM1R2:00000000 $t
/tmp/ccmWfK1Q.s:1937 .text.grabM1R2:00000000 grabM1R2
/tmp/ccmWfK1Q.s:2095 .text.grabM1R2:000000f4 $d
/tmp/ccmWfK1Q.s:2100 .text.callSyncM0:00000000 $t
/tmp/ccmWfK1Q.s:2130 .text.callSyncM0:00000018 $d
/tmp/ccmWfK1Q.s:2135 .text.callSyncM1:00000000 $t
/tmp/ccmWfK1Q.s:2165 .text.callSyncM1:00000018 $d
/tmp/ccmWfK1Q.s:2170 .text.getFrame:00000000 $t
/tmp/ccmWfK1Q.s:2175 .text.getFrame:00000000 getFrame
/tmp/ccmWfK1Q.s:2285 .rodata:00000000 $d
/tmp/ccmWfK1Q.s:2289 .text.frame_init:00000000 $t
/tmp/ccmWfK1Q.s:2294 .text.frame_init:00000000 frame_init
/tmp/ccmWfK1Q.s:2320 .text.frame_init:00000018 $d
.debug_frame:00000010 $d
UNDEFINED SYMBOLS
chirpSetProc
|
source/directories/a-direct.adb | ytomino/drake | 33 | 4141 | <filename>source/directories/a-direct.adb
with Ada.Calendar.Naked;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with System.Form_Parameters;
with System.Storage_Elements;
package body Ada.Directories is
use type System.Native_Directories.File_Kind;
use type System.Native_Directories.Searching.Handle_Type;
use type System.Storage_Elements.Storage_Offset;
subtype Directory_Entry_Information_Type is
System.Native_Directories.Directory_Entry_Information_Type;
procedure Free is new Unchecked_Deallocation (String, String_Access);
function Pack_For_Copy_File (Form : String) return Boolean;
function Pack_For_Copy_File (Form : String) return Boolean is
Keyword_First : Positive;
Keyword_Last : Natural;
Item_First : Positive;
Item_Last : Natural;
Last : Natural;
Overwrite : Boolean := True; -- default
begin
Last := Form'First - 1;
while Last < Form'Last loop
System.Form_Parameters.Get (
Form (Last + 1 .. Form'Last),
Keyword_First,
Keyword_Last,
Item_First,
Item_Last,
Last);
declare
Keyword : String
renames Form (Keyword_First .. Keyword_Last);
Item : String
renames Form (Item_First .. Item_Last);
begin
if Keyword = "overwrite" then
if Item'Length > 0 and then Item (Item'First) = 'f' then
Overwrite := False; -- false
elsif Item'Length > 0 and then Item (Item'First) = 't' then
Overwrite := True; -- true
end if;
elsif Keyword = "mode" then
-- compatibility with GNAT runtime
if Item'Length > 0 and then Item (Item'First) = 'c' then
Overwrite := False; -- copy
elsif Item'Length > 0 and then Item (Item'First) = 'o' then
Overwrite := True; -- overwrite
end if;
end if;
end;
end loop;
return Overwrite;
end Pack_For_Copy_File;
procedure Finalize (Object : in out Non_Controlled_Directory_Entry_Type);
procedure Finalize (Object : in out Non_Controlled_Directory_Entry_Type) is
begin
if Object.Status = Detached then
Free (Object.Path);
System.Native_Directories.Searching.Free (Object.Directory_Entry);
end if;
end Finalize;
procedure Assign (
Target : out Non_Controlled_Directory_Entry_Type;
Source : Non_Controlled_Directory_Entry_Type);
procedure Assign (
Target : out Non_Controlled_Directory_Entry_Type;
Source : Non_Controlled_Directory_Entry_Type) is
begin
Target.Additional.Filled := False;
Target.Status := Detached;
Target.Path := new String'(Source.Path.all);
Target.Directory_Entry :=
System.Native_Directories.Searching.New_Directory_Entry (
Source.Directory_Entry);
end Assign;
procedure End_Search (
Search : aliased in out Non_Controlled_Search_Type;
Raise_On_Error : Boolean);
procedure End_Search (
Search : aliased in out Non_Controlled_Search_Type;
Raise_On_Error : Boolean) is
begin
Free (Search.Path);
System.Native_Directories.Searching.End_Search (
Search.Search,
Raise_On_Error => Raise_On_Error);
end End_Search;
procedure Get_Next_Entry (
Search : aliased in out Non_Controlled_Search_Type;
Directory_Entry : in out Non_Controlled_Directory_Entry_Type);
procedure Get_Next_Entry (
Search : aliased in out Non_Controlled_Search_Type;
Directory_Entry : in out Non_Controlled_Directory_Entry_Type)
is
Has_Next : Boolean;
begin
System.Native_Directories.Searching.Get_Next_Entry (
Search.Search,
Directory_Entry.Directory_Entry,
Has_Next);
if Has_Next then
Directory_Entry.Additional.Filled := False;
else
Directory_Entry.Status := Empty;
end if;
end Get_Next_Entry;
function Current (Object : Directory_Iterator) return Cursor;
function Current (Object : Directory_Iterator) return Cursor is
Listing : constant not null Directory_Listing_Access := Object.Listing;
begin
if not Is_Assigned (
Controlled_Searches.Next_Directory_Entry (Listing.Search).all)
then
-- call End_Search at this time, for propagating the exceptions.
declare
NC_Search : Non_Controlled_Search_Type
renames Controlled_Searches.Reference (Listing.Search).all;
begin
End_Search (NC_Search, Raise_On_Error => True);
end;
return 0; -- No_Element
else
return Cursor (Listing.Count);
end if;
end Current;
-- directory and file operations
procedure Create_Directory (
New_Directory : String;
Form : String)
is
pragma Unreferenced (Form);
begin
System.Native_Directories.Create_Directory (New_Directory);
end Create_Directory;
procedure Create_Directory (
New_Directory : String) is
begin
System.Native_Directories.Create_Directory (New_Directory);
end Create_Directory;
procedure Create_Path (
New_Directory : String;
Form : String)
is
pragma Unreferenced (Form);
begin
Create_Path (New_Directory);
end Create_Path;
procedure Create_Path (
New_Directory : String)
is
I : Positive := New_Directory'Last + 1;
begin
while I > New_Directory'First loop
declare
P : Positive := I - 1;
begin
Hierarchical_File_Names.Exclude_Trailing_Path_Delimiter (
New_Directory,
Last => P);
exit when Exists (New_Directory (New_Directory'First .. P));
declare
S_First : Positive;
S_Last : Natural;
begin
Hierarchical_File_Names.Simple_Name (
New_Directory (New_Directory'First .. P),
First => S_First,
Last => S_Last);
I := S_First;
end;
end;
end loop;
while I <= New_Directory'Last loop
declare
R_First : Positive;
R_Last : Natural;
begin
Hierarchical_File_Names.Relative_Name (
New_Directory (I .. New_Directory'Last),
First => R_First,
Last => R_Last);
declare
P : Natural := R_First - 1;
begin
Hierarchical_File_Names.Exclude_Trailing_Path_Delimiter (
New_Directory,
Last => P);
Create_Directory (New_Directory (New_Directory'First .. P));
end;
I := R_First;
end;
end loop;
end Create_Path;
procedure Delete_Tree (Directory : String) is
Search : aliased Search_Type;
begin
Start_Search (Search, Directory, "*", (others => True));
while More_Entries (Search) loop
declare
Directory_Entry : Directory_Entry_Type
renames Look_Next_Entry (Search).Element.all;
Name : constant String := Full_Name (Directory_Entry);
begin
case Kind (Directory_Entry) is
when Ordinary_File | Special_File =>
Delete_File (Name);
when Directories.Directory =>
Delete_Tree (Name); -- recursive
end case;
end;
Skip_Next_Entry (Search);
end loop;
End_Search (Search);
Delete_Directory (Directory);
end Delete_Tree;
procedure Copy_File (
Source_Name : String;
Target_Name : String;
Form : String) is
begin
System.Native_Directories.Copy_File (
Source_Name,
Target_Name,
Overwrite => Pack_For_Copy_File (Form));
end Copy_File;
function Compose (
Containing_Directory : String := "";
Name : String;
Extension : String := "";
Path_Delimiter : Hierarchical_File_Names.Path_Delimiter_Type :=
Hierarchical_File_Names.Default_Path_Delimiter)
return String
is
pragma Check (Pre,
Check =>
Containing_Directory'Length = 0
or else Hierarchical_File_Names.Is_Simple_Name (Name)
or else raise Name_Error); -- RM A.16(82/3)
begin
return Hierarchical_File_Names.Compose (
Containing_Directory,
Name,
Extension,
Path_Delimiter => Path_Delimiter);
end Compose;
-- file and directory queries
function Kind (Name : String) return File_Kind is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return File_Kind'Enum_Val (
System.Native_Directories.File_Kind'Enum_Rep (
System.Native_Directories.Kind (Information)));
end Kind;
function Size (Name : String) return File_Size is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
if System.Native_Directories.Kind (Information) /=
System.Native_Directories.Ordinary_File
then
raise Constraint_Error; -- implementation-defined
else
return System.Native_Directories.Size (Information);
end if;
end Size;
function Modification_Time (Name : String) return Calendar.Time is
Information : aliased Directory_Entry_Information_Type;
begin
System.Native_Directories.Get_Information (Name, Information);
return Calendar.Naked.To_Time (
System.Native_Directories.Modification_Time (Information));
end Modification_Time;
procedure Set_Modification_Time (Name : String; Time : Calendar.Time) is
begin
System.Native_Directories.Set_Modification_Time (
Name,
Calendar.Naked.To_Native_Time (Time));
end Set_Modification_Time;
-- directory searching
function Is_Assigned (Directory_Entry : Directory_Entry_Type)
return Boolean
is
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return NC_Directory_Entry.Status /= Empty;
end Is_Assigned;
package body Controlled_Entries is
function Reference (Object : Directories.Directory_Entry_Type)
return not null access Non_Controlled_Directory_Entry_Type is
begin
return Directory_Entry_Type (Object).Data'Unrestricted_Access;
end Reference;
overriding procedure Finalize (Object : in out Directory_Entry_Type) is
begin
Finalize (Object.Data);
end Finalize;
end Controlled_Entries;
function Is_Open (Search : Search_Type) return Boolean is
NC_Search : Non_Controlled_Search_Type
renames Controlled_Searches.Reference (Search).all;
begin
return NC_Search.Search.Handle /=
System.Native_Directories.Searching.Null_Handle;
end Is_Open;
procedure Start_Search (
Search : in out Search_Type;
Directory : String;
Pattern : String := "*";
Filter : Filter_Type := (others => True))
is
pragma Check (Pre,
Check => not Is_Open (Search) or else raise Status_Error);
function Cast is
new Unchecked_Conversion (
Filter_Type,
System.Native_Directories.Searching.Filter_Type);
NC_Search : Non_Controlled_Search_Type
renames Controlled_Searches.Reference (Search).all;
Has_Next : Boolean;
begin
NC_Search.Path := new String'(Full_Name (Directory));
declare
NC_Next_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (
Controlled_Searches.Next_Directory_Entry (Search).all).all;
begin
System.Native_Directories.Searching.Start_Search (
NC_Search.Search,
Directory,
Pattern,
Cast (Filter),
NC_Next_Directory_Entry.Directory_Entry,
Has_Next);
if Has_Next then
NC_Next_Directory_Entry.Path := NC_Search.Path;
NC_Next_Directory_Entry.Additional.Filled := False;
NC_Next_Directory_Entry.Status := Attached;
else
NC_Next_Directory_Entry.Status := Empty;
end if;
end;
end Start_Search;
function Start_Search (
Directory : String;
Pattern : String := "*";
Filter : Filter_Type := (others => True))
return Search_Type is
begin
return Result : Search_Type do
Start_Search (Result, Directory, Pattern, Filter);
end return;
end Start_Search;
procedure End_Search (Search : in out Search_Type) is
pragma Check (Pre, Is_Open (Search) or else raise Status_Error);
NC_Search : Non_Controlled_Search_Type
renames Controlled_Searches.Reference (Search).all;
begin
End_Search (NC_Search, Raise_On_Error => True);
end End_Search;
function More_Entries (
Search : Search_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Search) or else raise Status_Error);
begin
return Is_Assigned (
Controlled_Searches.Next_Directory_Entry (Search).all);
end More_Entries;
procedure Get_Next_Entry (
Search : in out Search_Type;
Directory_Entry : out Directory_Entry_Type)
is
pragma Unmodified (Directory_Entry); -- modified via Reference
pragma Check (Pre,
Check =>
More_Entries (Search) -- checking the predicate
or else raise Use_Error); -- RM A.16(110/3)
NC_Search : Non_Controlled_Search_Type
renames Controlled_Searches.Reference (Search).all;
NC_Next_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (
Controlled_Searches.Next_Directory_Entry (Search).all).all;
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
Finalize (NC_Directory_Entry);
-- copy to the detached entry
Assign (Target => NC_Directory_Entry, Source => NC_Next_Directory_Entry);
-- search next
Get_Next_Entry (NC_Search, NC_Next_Directory_Entry);
end Get_Next_Entry;
function Get_Next_Entry (
Search : aliased in out Search_Type)
return Directory_Entry_Type is
begin
return Result : Directory_Entry_Type do
Get_Next_Entry (Search, Result);
end return;
end Get_Next_Entry;
function Look_Next_Entry (
Search : aliased Search_Type)
return Constant_Reference_Type
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Search) or else raise Status_Error);
begin
return (Element => Controlled_Searches.Next_Directory_Entry (Search));
end Look_Next_Entry;
procedure Skip_Next_Entry (
Search : in out Search_Type)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Search) or else raise Status_Error);
NC_Search : Non_Controlled_Search_Type
renames Controlled_Searches.Reference (Search).all;
NC_Next_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (
Controlled_Searches.Next_Directory_Entry (Search).all).all;
begin
Get_Next_Entry (NC_Search, NC_Next_Directory_Entry);
end Skip_Next_Entry;
procedure Search (
Directory : String;
Pattern : String := "*";
Filter : Filter_Type := (others => True);
Process : not null access procedure (
Directory_Entry : Directory_Entry_Type))
is
Search : aliased Search_Type;
begin
Start_Search (Search, Directory, Pattern, Filter);
while More_Entries (Search) loop
Process (Look_Next_Entry (Search).Element.all);
Skip_Next_Entry (Search);
end loop;
End_Search (Search);
end Search;
package body Controlled_Searches is
function Reference (Object : Directories.Search_Type)
return not null access Non_Controlled_Search_Type is
begin
return Search_Type (Object).Data'Unrestricted_Access;
end Reference;
function Next_Directory_Entry (Object : Directories.Search_Type)
return not null access Directory_Entry_Type is
begin
return Search_Type (Object).Next_Directory_Entry'Unrestricted_Access;
end Next_Directory_Entry;
overriding procedure Finalize (Search : in out Search_Type) is
begin
if Search.Data.Search.Handle /=
System.Native_Directories.Searching.Null_Handle
then
End_Search (Search.Data, Raise_On_Error => False);
end if;
end Finalize;
end Controlled_Searches;
-- directory iteration
function Is_Open (Listing : Directory_Listing) return Boolean is
begin
return Is_Open (Listing.Search);
end Is_Open;
function Entries (
Directory : String;
Pattern : String := "*";
Filter : Filter_Type := (others => True))
return Directory_Listing is
begin
return Result : Directory_Listing do
Result.Count := 1;
Start_Search (Result.Search, Directory, Pattern, Filter);
end return;
end Entries;
function Has_Entry (Position : Cursor) return Boolean is
begin
return Position > 0;
end Has_Entry;
function Iterate (
Listing : Directory_Listing'Class)
return Directory_Iterators.Forward_Iterator'Class
is
pragma Check (Dynamic_Predicate,
Check =>
Is_Open (Directory_Listing (Listing)) or else raise Status_Error);
begin
return Directory_Iterator'(Listing => Listing'Unrestricted_Access);
end Iterate;
function Current_Entry (
Entries : Directory_Listing'Class;
Position : Cursor)
return Directory_Entry_Type is
begin
return Result : Directory_Entry_Type do
pragma Unmodified (Result); -- modified via Reference
declare
Source_Reference : constant Constant_Reference_Type :=
Constant_Reference (Directory_Listing (Entries), Position);
-- checking the predicate and Position in Constant_Reference
NC_Next_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (
Source_Reference.Element.all)
.all;
NC_Result : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Result).all;
begin
Assign (Target => NC_Result, Source => NC_Next_Directory_Entry);
end;
end return;
end Current_Entry;
function Constant_Reference (
Container : aliased Directory_Listing;
Position : Cursor)
return Constant_Reference_Type
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Container) or else raise Status_Error);
pragma Check (Pre,
Check =>
Integer (Position) = Container.Count or else raise Status_Error);
begin
return Look_Next_Entry (Container.Search);
end Constant_Reference;
overriding function First (Object : Directory_Iterator) return Cursor is
pragma Check (Pre, Object.Listing.Count = 1 or else raise Status_Error);
begin
return Current (Object);
end First;
overriding function Next (Object : Directory_Iterator; Position : Cursor)
return Cursor
is
pragma Check (Pre,
Check =>
Integer (Position) = Object.Listing.Count
or else raise Status_Error);
Listing : constant not null Directory_Listing_Access := Object.Listing;
begin
-- increment
Listing.Count := Listing.Count + 1;
-- search next
Skip_Next_Entry (Listing.Search);
return Current (Object);
end Next;
-- operations on directory entries
procedure Get_Entry (
Name : String;
Directory_Entry : out Directory_Entry_Type)
is
pragma Unmodified (Directory_Entry); -- modified via Reference
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
Directory_First : Positive;
Directory_Last : Natural;
Simple_Name_First : Positive;
Simple_Name_Last : Natural;
begin
-- decompose the name
Hierarchical_File_Names.Containing_Directory (Name,
First => Directory_First, Last => Directory_Last);
Hierarchical_File_Names.Simple_Name (Name,
First => Simple_Name_First, Last => Simple_Name_Last);
-- make a detached entry
Finalize (NC_Directory_Entry);
NC_Directory_Entry.Path :=
new String'(Full_Name (Name (Directory_First .. Directory_Last)));
NC_Directory_Entry.Directory_Entry := null;
NC_Directory_Entry.Additional.Filled := False;
NC_Directory_Entry.Status := Detached;
System.Native_Directories.Searching.Get_Entry (
NC_Directory_Entry.Path.all,
Name (Simple_Name_First .. Simple_Name_Last),
NC_Directory_Entry.Directory_Entry,
NC_Directory_Entry.Additional);
end Get_Entry;
function Get_Entry (
Name : String)
return Directory_Entry_Type is
begin
return Result : Directory_Entry_Type do
Get_Entry (Name, Result);
end return;
end Get_Entry;
function Simple_Name (
Directory_Entry : Directory_Entry_Type)
return String
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return System.Native_Directories.Searching.Simple_Name (
NC_Directory_Entry.Directory_Entry);
end Simple_Name;
function Full_Name (
Directory_Entry : Directory_Entry_Type)
return String
is
Name : constant String :=
Simple_Name (Directory_Entry); -- checking the predicate
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return Hierarchical_File_Names.Compose (
NC_Directory_Entry.Path.all,
Name);
end Full_Name;
function Kind (
Directory_Entry : Directory_Entry_Type)
return File_Kind
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return File_Kind'Enum_Val (
System.Native_Directories.File_Kind'Enum_Rep (
System.Native_Directories.Searching.Kind (
NC_Directory_Entry.Directory_Entry)));
end Kind;
function Size (
Directory_Entry : Directory_Entry_Type)
return File_Size is
begin
if Kind (Directory_Entry) /= Ordinary_File then -- checking the predicate
raise Constraint_Error; -- implementation-defined
else
declare
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return System.Native_Directories.Searching.Size (
NC_Directory_Entry.Path.all,
NC_Directory_Entry.Directory_Entry,
NC_Directory_Entry.Additional);
end;
end if;
end Size;
function Modification_Time (
Directory_Entry : Directory_Entry_Type)
return Calendar.Time
is
pragma Check (Dynamic_Predicate,
Check => Is_Assigned (Directory_Entry) or else raise Status_Error);
NC_Directory_Entry : Non_Controlled_Directory_Entry_Type
renames Controlled_Entries.Reference (Directory_Entry).all;
begin
return Calendar.Naked.To_Time (
System.Native_Directories.Searching.Modification_Time (
NC_Directory_Entry.Path.all,
NC_Directory_Entry.Directory_Entry,
NC_Directory_Entry.Additional));
end Modification_Time;
end Ada.Directories;
|
8088/cga/levels/levels.asm | reenigne/reenigne | 92 | 81745 | <filename>8088/cga/levels/levels.asm
%include "../../defaults_bin.asm"
mov ax,4
int 0x10
mov ax,0xb800
mov es,ax
xor di,di
cld
xor ax,ax
mov cx,0x2000
rep stosw
mov dx,0x3d4
mov ax,0x1000
out dx,ax
mov ax,0x1004
out dx,ax
mov al,0
loopTop:
mov dx,0x3d9
out dx,al
push ax
mov ah,0
int 0x16
pop ax
inc ax
jmp loopTop
|
fnstenv.asm | SYANiDE-/VulnServer | 0 | 98220 | <gh_stars>0
section .text
global _start
_start:
;; https://armoredcode.com/blog/backflip-into-the-stack/
; EIP into ECX
fldz ; Push +0.0 onto the FPU register stack.
fnstenv [esp-12] ; If we want to align the information about the EIP
;, to be found at the very beginning of the stack, we
;, kindly ask FNSTENV to start writing 12 bytes before
;, the $ESP value, that’s the reason of “fnstenv [esp-12]”.
;, We th[e]n pop the stack word into ECX storing the value
;, the EIP register has when fnstenv it was called. Then,
;, [...] add 9 bytes to move ECX value to the instruction
;, right after the NOP.
pop ecx
add cl,10
nop
; jmp back 512 bytes for example
dec ch ;0xff00 = -256
dec ch ;0xff00 = -256
jmp ecx
|
test/Fail/IrrelevantMatchRefl.agda | shlevy/agda | 1,989 | 9845 | -- Andreas, 2011-10-04, transcription of <NAME>'s post on the Agda list
{-# OPTIONS --experimental-irrelevance #-}
module IrrelevantMatchRefl where
import Common.Level
open import Common.Equality hiding (subst)
-- irrelevant subst should be rejected, because it suggests
-- that the equality proof is irrelevant also for reduction
subst : ∀ {i j}{A : Set i}(P : A → Set j){a b : A} → .(a ≡ b) → P a → P b
subst P refl x = x
postulate
D : Set
lie : (D → D) ≡ D
-- the following two substs may not reduce! ...
abs : (D → D) → D
abs f = subst (λ T → T) lie f
app : D → D → D
app d = subst (λ T → T) (sym lie) d
ω : D
ω = abs (λ d → app d d)
-- ... otherwise Ω loops
Ω : D
Ω = app ω ω
-- ... and this would be a real fixed-point combinator
Y : (D → D) → D
Y f = app δ δ
where δ = abs (λ x → f (app x x))
K : D → D
K x = abs (λ y → x)
K∞ : D
K∞ = Y K
mayloop : K∞ ≡ abs (λ y → K∞)
mayloop = refl
-- gives error D != D → D
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/loop_address2.adb | best08618/asylo | 7 | 22245 | -- { dg-do compile }
-- { dg-options "-O" }
with System, Ada.Unchecked_Conversion;
with System.Storage_Elements; use System.Storage_Elements;
procedure Loop_Address2 is
type Ptr is access all Integer;
function To_Ptr is new Ada.Unchecked_Conversion (System.Address, Ptr);
function F (BM : System.Address; I : Integer) return System.Address is
begin
return BM + Storage_Offset (4*I);
end;
B : Integer;
P : Ptr;
begin
for I in 0 .. 2 loop
P := To_Ptr (F (B'Address, I));
P.all := 0;
end loop;
end ;
|
user/nettests.asm | eric-qian-d/TCP | 0 | 163404 | <gh_stars>0
user/_nettests: file format elf64-littleriscv
Disassembly of section .text:
0000000000000000 <decode_qname>:
}
// Decode a DNS name
static void
decode_qname(char *qn)
{
0: 1141 addi sp,sp,-16
2: e422 sd s0,8(sp)
4: 0800 addi s0,sp,16
while(*qn != '\0') {
6: 00054783 lbu a5,0(a0)
int l = *qn;
a: 0007861b sext.w a2,a5
if(l == 0)
break;
for(int i = 0; i < l; i++) {
e: 4581 li a1,0
10: 4885 li a7,1
*qn = *(qn+1);
qn++;
}
*qn++ = '.';
12: 02e00813 li a6,46
while(*qn != '\0') {
16: ef81 bnez a5,2e <decode_qname+0x2e>
}
}
18: 6422 ld s0,8(sp)
1a: 0141 addi sp,sp,16
1c: 8082 ret
*qn++ = '.';
1e: 0709 addi a4,a4,2
20: 953a add a0,a0,a4
22: 01078023 sb a6,0(a5)
while(*qn != '\0') {
26: 0017c603 lbu a2,1(a5)
2a: d67d beqz a2,18 <decode_qname+0x18>
int l = *qn;
2c: 2601 sext.w a2,a2
{
2e: 87aa mv a5,a0
for(int i = 0; i < l; i++) {
30: 872e mv a4,a1
*qn = *(qn+1);
32: 0017c683 lbu a3,1(a5)
36: 00d78023 sb a3,0(a5)
qn++;
3a: 0785 addi a5,a5,1
for(int i = 0; i < l; i++) {
3c: 2705 addiw a4,a4,1
3e: fec74ae3 blt a4,a2,32 <decode_qname+0x32>
42: fff6069b addiw a3,a2,-1
46: 1682 slli a3,a3,0x20
48: 9281 srli a3,a3,0x20
4a: 87c6 mv a5,a7
4c: 00c05463 blez a2,54 <decode_qname+0x54>
50: 00168793 addi a5,a3,1
54: 97aa add a5,a5,a0
*qn++ = '.';
56: 872e mv a4,a1
58: fcc053e3 blez a2,1e <decode_qname+0x1e>
5c: 8736 mv a4,a3
5e: b7c1 j 1e <decode_qname+0x1e>
0000000000000060 <ping>:
{
60: 7131 addi sp,sp,-192
62: fd06 sd ra,184(sp)
64: f922 sd s0,176(sp)
66: f526 sd s1,168(sp)
68: f14a sd s2,160(sp)
6a: ed4e sd s3,152(sp)
6c: 0180 addi s0,sp,192
6e: 89b2 mv s3,a2
char obuf[13] = "hello world!";
70: 00001797 auipc a5,0x1
74: f1078793 addi a5,a5,-240 # f80 <malloc+0x154>
78: 6398 ld a4,0(a5)
7a: fce43023 sd a4,-64(s0)
7e: 4798 lw a4,8(a5)
80: fce42423 sw a4,-56(s0)
84: 00c7c783 lbu a5,12(a5)
88: fcf40623 sb a5,-52(s0)
if((fd = connect(dst, sport, dport)) < 0){
8c: 862e mv a2,a1
8e: 85aa mv a1,a0
90: 0a000537 lui a0,0xa000
94: 20250513 addi a0,a0,514 # a000202 <__global_pointer$+0x9ffe8a1>
98: 00001097 auipc ra,0x1
9c: 9ee080e7 jalr -1554(ra) # a86 <connect>
a0: 06054763 bltz a0,10e <ping+0xae>
a4: 892a mv s2,a0
for(int i = 0; i < attempts; i++) {
a6: 4481 li s1,0
a8: 01305f63 blez s3,c6 <ping+0x66>
if(write(fd, obuf, sizeof(obuf)) < 0){
ac: 4635 li a2,13
ae: fc040593 addi a1,s0,-64
b2: 854a mv a0,s2
b4: 00001097 auipc ra,0x1
b8: 952080e7 jalr -1710(ra) # a06 <write>
bc: 06054763 bltz a0,12a <ping+0xca>
for(int i = 0; i < attempts; i++) {
c0: 2485 addiw s1,s1,1
c2: fe9995e3 bne s3,s1,ac <ping+0x4c>
int cc = read(fd, ibuf, sizeof(ibuf));
c6: 08000613 li a2,128
ca: f4040593 addi a1,s0,-192
ce: 854a mv a0,s2
d0: 00001097 auipc ra,0x1
d4: 92e080e7 jalr -1746(ra) # 9fe <read>
d8: 84aa mv s1,a0
if(cc < 0){
da: 06054663 bltz a0,146 <ping+0xe6>
close(fd);
de: 854a mv a0,s2
e0: 00001097 auipc ra,0x1
e4: 92e080e7 jalr -1746(ra) # a0e <close>
if (strcmp(obuf, ibuf) || cc != sizeof(obuf)){
e8: f4040593 addi a1,s0,-192
ec: fc040513 addi a0,s0,-64
f0: 00000097 auipc ra,0x0
f4: 69c080e7 jalr 1692(ra) # 78c <strcmp>
f8: e52d bnez a0,162 <ping+0x102>
fa: 47b5 li a5,13
fc: 06f49363 bne s1,a5,162 <ping+0x102>
}
100: 70ea ld ra,184(sp)
102: 744a ld s0,176(sp)
104: 74aa ld s1,168(sp)
106: 790a ld s2,160(sp)
108: 69ea ld s3,152(sp)
10a: 6129 addi sp,sp,192
10c: 8082 ret
fprintf(2, "ping: connect() failed\n");
10e: 00001597 auipc a1,0x1
112: e0258593 addi a1,a1,-510 # f10 <malloc+0xe4>
116: 4509 li a0,2
118: 00001097 auipc ra,0x1
11c: c28080e7 jalr -984(ra) # d40 <fprintf>
exit(1);
120: 4505 li a0,1
122: 00001097 auipc ra,0x1
126: 8c4080e7 jalr -1852(ra) # 9e6 <exit>
fprintf(2, "ping: send() failed\n");
12a: 00001597 auipc a1,0x1
12e: dfe58593 addi a1,a1,-514 # f28 <malloc+0xfc>
132: 4509 li a0,2
134: 00001097 auipc ra,0x1
138: c0c080e7 jalr -1012(ra) # d40 <fprintf>
exit(1);
13c: 4505 li a0,1
13e: 00001097 auipc ra,0x1
142: 8a8080e7 jalr -1880(ra) # 9e6 <exit>
fprintf(2, "ping: recv() failed\n");
146: 00001597 auipc a1,0x1
14a: dfa58593 addi a1,a1,-518 # f40 <malloc+0x114>
14e: 4509 li a0,2
150: 00001097 auipc ra,0x1
154: bf0080e7 jalr -1040(ra) # d40 <fprintf>
exit(1);
158: 4505 li a0,1
15a: 00001097 auipc ra,0x1
15e: 88c080e7 jalr -1908(ra) # 9e6 <exit>
fprintf(2, "ping didn't receive correct payload\n");
162: 00001597 auipc a1,0x1
166: df658593 addi a1,a1,-522 # f58 <malloc+0x12c>
16a: 4509 li a0,2
16c: 00001097 auipc ra,0x1
170: bd4080e7 jalr -1068(ra) # d40 <fprintf>
exit(1);
174: 4505 li a0,1
176: 00001097 auipc ra,0x1
17a: 870080e7 jalr -1936(ra) # 9e6 <exit>
000000000000017e <dns>:
}
}
static void
dns()
{
17e: 7119 addi sp,sp,-128
180: fc86 sd ra,120(sp)
182: f8a2 sd s0,112(sp)
184: f4a6 sd s1,104(sp)
186: f0ca sd s2,96(sp)
188: ecce sd s3,88(sp)
18a: e8d2 sd s4,80(sp)
18c: e4d6 sd s5,72(sp)
18e: e0da sd s6,64(sp)
190: fc5e sd s7,56(sp)
192: f862 sd s8,48(sp)
194: f466 sd s9,40(sp)
196: f06a sd s10,32(sp)
198: ec6e sd s11,24(sp)
19a: 0100 addi s0,sp,128
19c: 83010113 addi sp,sp,-2000
uint8 ibuf[N];
uint32 dst;
int fd;
int len;
memset(obuf, 0, N);
1a0: 3e800613 li a2,1000
1a4: 4581 li a1,0
1a6: ba840513 addi a0,s0,-1112
1aa: 00000097 auipc ra,0x0
1ae: 638080e7 jalr 1592(ra) # 7e2 <memset>
memset(ibuf, 0, N);
1b2: 3e800613 li a2,1000
1b6: 4581 li a1,0
1b8: 77fd lui a5,0xfffff
1ba: 7c078793 addi a5,a5,1984 # fffffffffffff7c0 <__global_pointer$+0xffffffffffffde5f>
1be: 00f40533 add a0,s0,a5
1c2: 00000097 auipc ra,0x0
1c6: 620080e7 jalr 1568(ra) # 7e2 <memset>
// 8.8.8.8: google's name server
dst = (8 << 24) | (8 << 16) | (8 << 8) | (8 << 0);
if((fd = connect(dst, 10000, 53)) < 0){
1ca: 03500613 li a2,53
1ce: 6589 lui a1,0x2
1d0: 71058593 addi a1,a1,1808 # 2710 <__global_pointer$+0xdaf>
1d4: 08081537 lui a0,0x8081
1d8: 80850513 addi a0,a0,-2040 # 8080808 <__global_pointer$+0x807eea7>
1dc: 00001097 auipc ra,0x1
1e0: 8aa080e7 jalr -1878(ra) # a86 <connect>
1e4: 02054d63 bltz a0,21e <dns+0xa0>
1e8: 892a mv s2,a0
hdr->id = htons(6828);
1ea: 77ed lui a5,0xffffb
1ec: c1a78793 addi a5,a5,-998 # ffffffffffffac1a <__global_pointer$+0xffffffffffff92b9>
1f0: baf41423 sh a5,-1112(s0)
hdr->rd = 1;
1f4: baa45783 lhu a5,-1110(s0)
1f8: 0017e793 ori a5,a5,1
1fc: baf41523 sh a5,-1110(s0)
hdr->qdcount = htons(1);
200: 10000793 li a5,256
204: baf41623 sh a5,-1108(s0)
for(char *c = host; c < host+strlen(host)+1; c++) {
208: 00001497 auipc s1,0x1
20c: d8848493 addi s1,s1,-632 # f90 <malloc+0x164>
char *l = host;
210: 8a26 mv s4,s1
for(char *c = host; c < host+strlen(host)+1; c++) {
212: bb440993 addi s3,s0,-1100
216: 8aa6 mv s5,s1
if(*c == '.') {
218: 02e00b13 li s6,46
for(char *c = host; c < host+strlen(host)+1; c++) {
21c: a01d j 242 <dns+0xc4>
fprintf(2, "ping: connect() failed\n");
21e: 00001597 auipc a1,0x1
222: cf258593 addi a1,a1,-782 # f10 <malloc+0xe4>
226: 4509 li a0,2
228: 00001097 auipc ra,0x1
22c: b18080e7 jalr -1256(ra) # d40 <fprintf>
exit(1);
230: 4505 li a0,1
232: 00000097 auipc ra,0x0
236: 7b4080e7 jalr 1972(ra) # 9e6 <exit>
*qn++ = (char) (c-l);
23a: 89b6 mv s3,a3
l = c+1; // skip .
23c: 00148a13 addi s4,s1,1
for(char *c = host; c < host+strlen(host)+1; c++) {
240: 0485 addi s1,s1,1
242: 8556 mv a0,s5
244: 00000097 auipc ra,0x0
248: 574080e7 jalr 1396(ra) # 7b8 <strlen>
24c: 1502 slli a0,a0,0x20
24e: 9101 srli a0,a0,0x20
250: 0505 addi a0,a0,1
252: 9556 add a0,a0,s5
254: 02a4fc63 bgeu s1,a0,28c <dns+0x10e>
if(*c == '.') {
258: 0004c783 lbu a5,0(s1)
25c: ff6792e3 bne a5,s6,240 <dns+0xc2>
*qn++ = (char) (c-l);
260: 00198693 addi a3,s3,1
264: 414487b3 sub a5,s1,s4
268: 00f98023 sb a5,0(s3)
for(char *d = l; d < c; d++) {
26c: fc9a77e3 bgeu s4,s1,23a <dns+0xbc>
270: 87d2 mv a5,s4
*qn++ = (char) (c-l);
272: 8736 mv a4,a3
*qn++ = *d;
274: 0705 addi a4,a4,1
276: 0007c603 lbu a2,0(a5)
27a: fec70fa3 sb a2,-1(a4)
for(char *d = l; d < c; d++) {
27e: 0785 addi a5,a5,1
280: fef49ae3 bne s1,a5,274 <dns+0xf6>
284: 414489b3 sub s3,s1,s4
288: 99b6 add s3,s3,a3
28a: bf4d j 23c <dns+0xbe>
*qn = '\0';
28c: 00098023 sb zero,0(s3)
len += strlen(qname) + 1;
290: bb440513 addi a0,s0,-1100
294: 00000097 auipc ra,0x0
298: 524080e7 jalr 1316(ra) # 7b8 <strlen>
29c: 0005049b sext.w s1,a0
struct dns_question *h = (struct dns_question *) (qname+strlen(qname)+1);
2a0: bb440513 addi a0,s0,-1100
2a4: 00000097 auipc ra,0x0
2a8: 514080e7 jalr 1300(ra) # 7b8 <strlen>
2ac: 02051793 slli a5,a0,0x20
2b0: 9381 srli a5,a5,0x20
2b2: 0785 addi a5,a5,1
2b4: bb440713 addi a4,s0,-1100
2b8: 97ba add a5,a5,a4
h->qtype = htons(0x1);
2ba: 00078023 sb zero,0(a5)
2be: 4705 li a4,1
2c0: 00e780a3 sb a4,1(a5)
h->qclass = htons(0x1);
2c4: 00078123 sb zero,2(a5)
2c8: 00e781a3 sb a4,3(a5)
}
len = dns_req(obuf);
if(write(fd, obuf, len) < 0){
2cc: 0114861b addiw a2,s1,17
2d0: ba840593 addi a1,s0,-1112
2d4: 854a mv a0,s2
2d6: 00000097 auipc ra,0x0
2da: 730080e7 jalr 1840(ra) # a06 <write>
2de: 10054e63 bltz a0,3fa <dns+0x27c>
fprintf(2, "dns: send() failed\n");
exit(1);
}
int cc = read(fd, ibuf, sizeof(ibuf));
2e2: 3e800613 li a2,1000
2e6: 77fd lui a5,0xfffff
2e8: 7c078793 addi a5,a5,1984 # fffffffffffff7c0 <__global_pointer$+0xffffffffffffde5f>
2ec: 00f405b3 add a1,s0,a5
2f0: 854a mv a0,s2
2f2: 00000097 auipc ra,0x0
2f6: 70c080e7 jalr 1804(ra) # 9fe <read>
2fa: 89aa mv s3,a0
if(cc < 0){
2fc: 10054d63 bltz a0,416 <dns+0x298>
if(!hdr->qr) {
300: 77fd lui a5,0xfffff
302: 7c278793 addi a5,a5,1986 # fffffffffffff7c2 <__global_pointer$+0xffffffffffffde61>
306: 97a2 add a5,a5,s0
308: 00078783 lb a5,0(a5)
30c: 1207d363 bgez a5,432 <dns+0x2b4>
if(hdr->id != htons(6828))
310: 77fd lui a5,0xfffff
312: 7c078793 addi a5,a5,1984 # fffffffffffff7c0 <__global_pointer$+0xffffffffffffde5f>
316: 97a2 add a5,a5,s0
318: 0007d783 lhu a5,0(a5)
31c: 0007869b sext.w a3,a5
320: 672d lui a4,0xb
322: c1a70713 addi a4,a4,-998 # ac1a <__global_pointer$+0x92b9>
326: 10e69b63 bne a3,a4,43c <dns+0x2be>
if(hdr->rcode != 0) {
32a: 777d lui a4,0xfffff
32c: 7c370793 addi a5,a4,1987 # fffffffffffff7c3 <__global_pointer$+0xffffffffffffde62>
330: 97a2 add a5,a5,s0
332: 0007c783 lbu a5,0(a5)
336: 8bbd andi a5,a5,15
338: 12079263 bnez a5,45c <dns+0x2de>
// endianness support
//
static inline uint16 bswaps(uint16 val)
{
return (((val & 0x00ffU) << 8) |
33c: 7c470793 addi a5,a4,1988
340: 97a2 add a5,a5,s0
342: 0007d783 lhu a5,0(a5)
346: 0087d71b srliw a4,a5,0x8
34a: 0087979b slliw a5,a5,0x8
34e: 8fd9 or a5,a5,a4
for(int i =0; i < ntohs(hdr->qdcount); i++) {
350: 17c2 slli a5,a5,0x30
352: 93c1 srli a5,a5,0x30
354: 4a81 li s5,0
len = sizeof(struct dns);
356: 44b1 li s1,12
char *qname = 0;
358: 4a01 li s4,0
for(int i =0; i < ntohs(hdr->qdcount); i++) {
35a: c3b1 beqz a5,39e <dns+0x220>
char *qn = (char *) (ibuf+len);
35c: 7b7d lui s6,0xfffff
35e: 7c0b0793 addi a5,s6,1984 # fffffffffffff7c0 <__global_pointer$+0xffffffffffffde5f>
362: 97a2 add a5,a5,s0
364: 00978a33 add s4,a5,s1
decode_qname(qn);
368: 8552 mv a0,s4
36a: 00000097 auipc ra,0x0
36e: c96080e7 jalr -874(ra) # 0 <decode_qname>
len += strlen(qn)+1;
372: 8552 mv a0,s4
374: 00000097 auipc ra,0x0
378: 444080e7 jalr 1092(ra) # 7b8 <strlen>
len += sizeof(struct dns_question);
37c: 2515 addiw a0,a0,5
37e: 9ca9 addw s1,s1,a0
for(int i =0; i < ntohs(hdr->qdcount); i++) {
380: 2a85 addiw s5,s5,1
382: 7c4b0793 addi a5,s6,1988
386: 97a2 add a5,a5,s0
388: 0007d783 lhu a5,0(a5)
38c: 0087d71b srliw a4,a5,0x8
390: 0087979b slliw a5,a5,0x8
394: 8fd9 or a5,a5,a4
396: 17c2 slli a5,a5,0x30
398: 93c1 srli a5,a5,0x30
39a: fcfac1e3 blt s5,a5,35c <dns+0x1de>
39e: 77fd lui a5,0xfffff
3a0: 7c678793 addi a5,a5,1990 # fffffffffffff7c6 <__global_pointer$+0xffffffffffffde65>
3a4: 97a2 add a5,a5,s0
3a6: 0007d783 lhu a5,0(a5)
3aa: 0087d71b srliw a4,a5,0x8
3ae: 0087979b slliw a5,a5,0x8
3b2: 8fd9 or a5,a5,a4
for(int i = 0; i < ntohs(hdr->ancount); i++) {
3b4: 17c2 slli a5,a5,0x30
3b6: 93c1 srli a5,a5,0x30
3b8: 24078663 beqz a5,604 <dns+0x486>
3bc: 00001797 auipc a5,0x1
3c0: cb478793 addi a5,a5,-844 # 1070 <malloc+0x244>
3c4: 000a0363 beqz s4,3ca <dns+0x24c>
3c8: 87d2 mv a5,s4
3ca: 76fd lui a3,0xfffff
3cc: 7b068713 addi a4,a3,1968 # fffffffffffff7b0 <__global_pointer$+0xffffffffffffde4f>
3d0: 9722 add a4,a4,s0
3d2: e31c sd a5,0(a4)
int record = 0;
3d4: 7b868793 addi a5,a3,1976
3d8: 97a2 add a5,a5,s0
3da: 0007b023 sd zero,0(a5)
for(int i = 0; i < ntohs(hdr->ancount); i++) {
3de: 4a01 li s4,0
if((int) qn[0] > 63) { // compression?
3e0: 03f00d93 li s11,63
if(ntohs(d->type) == ARECORD && ntohs(d->len) == 4) {
3e4: 4a85 li s5,1
3e6: 4d11 li s10,4
printf("DNS arecord for %s is ", qname ? qname : "" );
3e8: 00001c97 auipc s9,0x1
3ec: c20c8c93 addi s9,s9,-992 # 1008 <malloc+0x1dc>
if(ip[0] != 128 || ip[1] != 52 || ip[2] != 129 || ip[3] != 126) {
3f0: 08000c13 li s8,128
3f4: 03400b93 li s7,52
3f8: a8d9 j 4ce <dns+0x350>
fprintf(2, "dns: send() failed\n");
3fa: 00001597 auipc a1,0x1
3fe: bae58593 addi a1,a1,-1106 # fa8 <malloc+0x17c>
402: 4509 li a0,2
404: 00001097 auipc ra,0x1
408: 93c080e7 jalr -1732(ra) # d40 <fprintf>
exit(1);
40c: 4505 li a0,1
40e: 00000097 auipc ra,0x0
412: 5d8080e7 jalr 1496(ra) # 9e6 <exit>
fprintf(2, "dns: recv() failed\n");
416: 00001597 auipc a1,0x1
41a: baa58593 addi a1,a1,-1110 # fc0 <malloc+0x194>
41e: 4509 li a0,2
420: 00001097 auipc ra,0x1
424: 920080e7 jalr -1760(ra) # d40 <fprintf>
exit(1);
428: 4505 li a0,1
42a: 00000097 auipc ra,0x0
42e: 5bc080e7 jalr 1468(ra) # 9e6 <exit>
exit(1);
432: 4505 li a0,1
434: 00000097 auipc ra,0x0
438: 5b2080e7 jalr 1458(ra) # 9e6 <exit>
43c: 0087d59b srliw a1,a5,0x8
440: 0087979b slliw a5,a5,0x8
444: 8ddd or a1,a1,a5
printf("DNS wrong id: %d\n", ntohs(hdr->id));
446: 15c2 slli a1,a1,0x30
448: 91c1 srli a1,a1,0x30
44a: 00001517 auipc a0,0x1
44e: b8e50513 addi a0,a0,-1138 # fd8 <malloc+0x1ac>
452: 00001097 auipc ra,0x1
456: 91c080e7 jalr -1764(ra) # d6e <printf>
45a: bdc1 j 32a <dns+0x1ac>
printf("DNS rcode error: %x\n", hdr->rcode);
45c: 77fd lui a5,0xfffff
45e: 7c378793 addi a5,a5,1987 # fffffffffffff7c3 <__global_pointer$+0xffffffffffffde62>
462: 97a2 add a5,a5,s0
464: 0007c583 lbu a1,0(a5)
468: 89bd andi a1,a1,15
46a: 00001517 auipc a0,0x1
46e: b8650513 addi a0,a0,-1146 # ff0 <malloc+0x1c4>
472: 00001097 auipc ra,0x1
476: 8fc080e7 jalr -1796(ra) # d6e <printf>
exit(1);
47a: 4505 li a0,1
47c: 00000097 auipc ra,0x0
480: 56a080e7 jalr 1386(ra) # 9e6 <exit>
decode_qname(qn);
484: 855a mv a0,s6
486: 00000097 auipc ra,0x0
48a: b7a080e7 jalr -1158(ra) # 0 <decode_qname>
len += strlen(qn)+1;
48e: 855a mv a0,s6
490: 00000097 auipc ra,0x0
494: 328080e7 jalr 808(ra) # 7b8 <strlen>
498: 2485 addiw s1,s1,1
49a: 9ca9 addw s1,s1,a0
49c: a0a1 j 4e4 <dns+0x366>
len += 4;
49e: 00eb049b addiw s1,s6,14
record = 1;
4a2: 77fd lui a5,0xfffff
4a4: 7b878793 addi a5,a5,1976 # fffffffffffff7b8 <__global_pointer$+0xffffffffffffde57>
4a8: 97a2 add a5,a5,s0
4aa: 0157b023 sd s5,0(a5)
for(int i = 0; i < ntohs(hdr->ancount); i++) {
4ae: 2a05 addiw s4,s4,1
4b0: 77fd lui a5,0xfffff
4b2: 7c678793 addi a5,a5,1990 # fffffffffffff7c6 <__global_pointer$+0xffffffffffffde65>
4b6: 97a2 add a5,a5,s0
4b8: 0007d783 lhu a5,0(a5)
4bc: 0087d71b srliw a4,a5,0x8
4c0: 0087979b slliw a5,a5,0x8
4c4: 8fd9 or a5,a5,a4
4c6: 17c2 slli a5,a5,0x30
4c8: 93c1 srli a5,a5,0x30
4ca: 0efa5263 bge s4,a5,5ae <dns+0x430>
char *qn = (char *) (ibuf+len);
4ce: 77fd lui a5,0xfffff
4d0: 7c078793 addi a5,a5,1984 # fffffffffffff7c0 <__global_pointer$+0xffffffffffffde5f>
4d4: 97a2 add a5,a5,s0
4d6: 00978b33 add s6,a5,s1
if((int) qn[0] > 63) { // compression?
4da: 000b4783 lbu a5,0(s6)
4de: fafdf3e3 bgeu s11,a5,484 <dns+0x306>
len += 2;
4e2: 2489 addiw s1,s1,2
struct dns_data *d = (struct dns_data *) (ibuf+len);
4e4: 77fd lui a5,0xfffff
4e6: 7c078793 addi a5,a5,1984 # fffffffffffff7c0 <__global_pointer$+0xffffffffffffde5f>
4ea: 97a2 add a5,a5,s0
4ec: 009786b3 add a3,a5,s1
len += sizeof(struct dns_data);
4f0: 00048b1b sext.w s6,s1
4f4: 24a9 addiw s1,s1,10
if(ntohs(d->type) == ARECORD && ntohs(d->len) == 4) {
4f6: 0006c783 lbu a5,0(a3)
4fa: 0016c703 lbu a4,1(a3)
4fe: 0722 slli a4,a4,0x8
500: 8fd9 or a5,a5,a4
502: 0087979b slliw a5,a5,0x8
506: 8321 srli a4,a4,0x8
508: 8fd9 or a5,a5,a4
50a: 17c2 slli a5,a5,0x30
50c: 93c1 srli a5,a5,0x30
50e: fb5790e3 bne a5,s5,4ae <dns+0x330>
512: 0086c783 lbu a5,8(a3)
516: 0096c703 lbu a4,9(a3)
51a: 0722 slli a4,a4,0x8
51c: 8fd9 or a5,a5,a4
51e: 0087979b slliw a5,a5,0x8
522: 8321 srli a4,a4,0x8
524: 8fd9 or a5,a5,a4
526: 17c2 slli a5,a5,0x30
528: 93c1 srli a5,a5,0x30
52a: f9a792e3 bne a5,s10,4ae <dns+0x330>
printf("DNS arecord for %s is ", qname ? qname : "" );
52e: 77fd lui a5,0xfffff
530: 7b078793 addi a5,a5,1968 # fffffffffffff7b0 <__global_pointer$+0xffffffffffffde4f>
534: 97a2 add a5,a5,s0
536: 638c ld a1,0(a5)
538: 8566 mv a0,s9
53a: 00001097 auipc ra,0x1
53e: 834080e7 jalr -1996(ra) # d6e <printf>
uint8 *ip = (ibuf+len);
542: 77fd lui a5,0xfffff
544: 7c078793 addi a5,a5,1984 # fffffffffffff7c0 <__global_pointer$+0xffffffffffffde5f>
548: 97a2 add a5,a5,s0
54a: 94be add s1,s1,a5
printf("%d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
54c: 0034c703 lbu a4,3(s1)
550: 0024c683 lbu a3,2(s1)
554: 0014c603 lbu a2,1(s1)
558: 0004c583 lbu a1,0(s1)
55c: 00001517 auipc a0,0x1
560: ac450513 addi a0,a0,-1340 # 1020 <malloc+0x1f4>
564: 00001097 auipc ra,0x1
568: 80a080e7 jalr -2038(ra) # d6e <printf>
if(ip[0] != 128 || ip[1] != 52 || ip[2] != 129 || ip[3] != 126) {
56c: 0004c783 lbu a5,0(s1)
570: 03879263 bne a5,s8,594 <dns+0x416>
574: 0014c783 lbu a5,1(s1)
578: 01779e63 bne a5,s7,594 <dns+0x416>
57c: 0024c703 lbu a4,2(s1)
580: 08100793 li a5,129
584: 00f71863 bne a4,a5,594 <dns+0x416>
588: 0034c703 lbu a4,3(s1)
58c: 07e00793 li a5,126
590: f0f707e3 beq a4,a5,49e <dns+0x320>
printf("wrong ip address");
594: 00001517 auipc a0,0x1
598: a9c50513 addi a0,a0,-1380 # 1030 <malloc+0x204>
59c: 00000097 auipc ra,0x0
5a0: 7d2080e7 jalr 2002(ra) # d6e <printf>
exit(1);
5a4: 4505 li a0,1
5a6: 00000097 auipc ra,0x0
5aa: 440080e7 jalr 1088(ra) # 9e6 <exit>
if(len != cc) {
5ae: 04999d63 bne s3,s1,608 <dns+0x48a>
if(!record) {
5b2: 77fd lui a5,0xfffff
5b4: 7b878793 addi a5,a5,1976 # fffffffffffff7b8 <__global_pointer$+0xffffffffffffde57>
5b8: 97a2 add a5,a5,s0
5ba: 639c ld a5,0(a5)
5bc: c79d beqz a5,5ea <dns+0x46c>
}
dns_rep(ibuf, cc);
close(fd);
5be: 854a mv a0,s2
5c0: 00000097 auipc ra,0x0
5c4: 44e080e7 jalr 1102(ra) # a0e <close>
}
5c8: 7d010113 addi sp,sp,2000
5cc: 70e6 ld ra,120(sp)
5ce: 7446 ld s0,112(sp)
5d0: 74a6 ld s1,104(sp)
5d2: 7906 ld s2,96(sp)
5d4: 69e6 ld s3,88(sp)
5d6: 6a46 ld s4,80(sp)
5d8: 6aa6 ld s5,72(sp)
5da: 6b06 ld s6,64(sp)
5dc: 7be2 ld s7,56(sp)
5de: 7c42 ld s8,48(sp)
5e0: 7ca2 ld s9,40(sp)
5e2: 7d02 ld s10,32(sp)
5e4: 6de2 ld s11,24(sp)
5e6: 6109 addi sp,sp,128
5e8: 8082 ret
printf("Didn't receive an arecord\n");
5ea: 00001517 auipc a0,0x1
5ee: a8e50513 addi a0,a0,-1394 # 1078 <malloc+0x24c>
5f2: 00000097 auipc ra,0x0
5f6: 77c080e7 jalr 1916(ra) # d6e <printf>
exit(1);
5fa: 4505 li a0,1
5fc: 00000097 auipc ra,0x0
600: 3ea080e7 jalr 1002(ra) # 9e6 <exit>
if(len != cc) {
604: fe9983e3 beq s3,s1,5ea <dns+0x46c>
printf("Processed %d data bytes but received %d\n", len, cc);
608: 864e mv a2,s3
60a: 85a6 mv a1,s1
60c: 00001517 auipc a0,0x1
610: a3c50513 addi a0,a0,-1476 # 1048 <malloc+0x21c>
614: 00000097 auipc ra,0x0
618: 75a080e7 jalr 1882(ra) # d6e <printf>
exit(1);
61c: 4505 li a0,1
61e: 00000097 auipc ra,0x0
622: 3c8080e7 jalr 968(ra) # 9e6 <exit>
0000000000000626 <main>:
int
main(int argc, char *argv[])
{
626: 7179 addi sp,sp,-48
628: f406 sd ra,40(sp)
62a: f022 sd s0,32(sp)
62c: ec26 sd s1,24(sp)
62e: e84a sd s2,16(sp)
630: 1800 addi s0,sp,48
int i, ret;
uint16 dport = NET_TESTS_PORT;
printf("nettests running on port %d\n", dport);
632: 6499 lui s1,0x6
634: 40048593 addi a1,s1,1024 # 6400 <__global_pointer$+0x4a9f>
638: 00001517 auipc a0,0x1
63c: a6050513 addi a0,a0,-1440 # 1098 <malloc+0x26c>
640: 00000097 auipc ra,0x0
644: 72e080e7 jalr 1838(ra) # d6e <printf>
printf("testing one ping: ");
648: 00001517 auipc a0,0x1
64c: a7050513 addi a0,a0,-1424 # 10b8 <malloc+0x28c>
650: 00000097 auipc ra,0x0
654: 71e080e7 jalr 1822(ra) # d6e <printf>
ping(2000, dport, 2);
658: 4609 li a2,2
65a: 40048593 addi a1,s1,1024
65e: 7d000513 li a0,2000
662: 00000097 auipc ra,0x0
666: 9fe080e7 jalr -1538(ra) # 60 <ping>
printf("OK\n");
66a: 00001517 auipc a0,0x1
66e: a6650513 addi a0,a0,-1434 # 10d0 <malloc+0x2a4>
672: 00000097 auipc ra,0x0
676: 6fc080e7 jalr 1788(ra) # d6e <printf>
printf("testing single-process pings: ");
67a: 00001517 auipc a0,0x1
67e: a5e50513 addi a0,a0,-1442 # 10d8 <malloc+0x2ac>
682: 00000097 auipc ra,0x0
686: 6ec080e7 jalr 1772(ra) # d6e <printf>
68a: 06400493 li s1,100
for (i = 0; i < 100; i++)
ping(2000, dport, 1);
68e: 6919 lui s2,0x6
690: 40090913 addi s2,s2,1024 # 6400 <__global_pointer$+0x4a9f>
694: 4605 li a2,1
696: 85ca mv a1,s2
698: 7d000513 li a0,2000
69c: 00000097 auipc ra,0x0
6a0: 9c4080e7 jalr -1596(ra) # 60 <ping>
for (i = 0; i < 100; i++)
6a4: 34fd addiw s1,s1,-1
6a6: f4fd bnez s1,694 <main+0x6e>
printf("OK\n");
6a8: 00001517 auipc a0,0x1
6ac: a2850513 addi a0,a0,-1496 # 10d0 <malloc+0x2a4>
6b0: 00000097 auipc ra,0x0
6b4: 6be080e7 jalr 1726(ra) # d6e <printf>
printf("testing multi-process pings: ");
6b8: 00001517 auipc a0,0x1
6bc: a4050513 addi a0,a0,-1472 # 10f8 <malloc+0x2cc>
6c0: 00000097 auipc ra,0x0
6c4: 6ae080e7 jalr 1710(ra) # d6e <printf>
for (i = 0; i < 10; i++){
6c8: 4929 li s2,10
int pid = fork();
6ca: 00000097 auipc ra,0x0
6ce: 314080e7 jalr 788(ra) # 9de <fork>
if (pid == 0){
6d2: c92d beqz a0,744 <main+0x11e>
for (i = 0; i < 10; i++){
6d4: 2485 addiw s1,s1,1
6d6: ff249ae3 bne s1,s2,6ca <main+0xa4>
6da: 44a9 li s1,10
ping(2000 + i + 1, dport, 1);
exit(0);
}
}
for (i = 0; i < 10; i++){
wait(&ret);
6dc: fdc40513 addi a0,s0,-36
6e0: 00000097 auipc ra,0x0
6e4: 30e080e7 jalr 782(ra) # 9ee <wait>
if (ret != 0)
6e8: fdc42783 lw a5,-36(s0)
6ec: efad bnez a5,766 <main+0x140>
for (i = 0; i < 10; i++){
6ee: 34fd addiw s1,s1,-1
6f0: f4f5 bnez s1,6dc <main+0xb6>
exit(1);
}
printf("OK\n");
6f2: 00001517 auipc a0,0x1
6f6: 9de50513 addi a0,a0,-1570 # 10d0 <malloc+0x2a4>
6fa: 00000097 auipc ra,0x0
6fe: 674080e7 jalr 1652(ra) # d6e <printf>
printf("testing DNS\n");
702: 00001517 auipc a0,0x1
706: a1650513 addi a0,a0,-1514 # 1118 <malloc+0x2ec>
70a: 00000097 auipc ra,0x0
70e: 664080e7 jalr 1636(ra) # d6e <printf>
dns();
712: 00000097 auipc ra,0x0
716: a6c080e7 jalr -1428(ra) # 17e <dns>
printf("DNS OK\n");
71a: 00001517 auipc a0,0x1
71e: a0e50513 addi a0,a0,-1522 # 1128 <malloc+0x2fc>
722: 00000097 auipc ra,0x0
726: 64c080e7 jalr 1612(ra) # d6e <printf>
printf("all tests passed.\n");
72a: 00001517 auipc a0,0x1
72e: a0650513 addi a0,a0,-1530 # 1130 <malloc+0x304>
732: 00000097 auipc ra,0x0
736: 63c080e7 jalr 1596(ra) # d6e <printf>
exit(0);
73a: 4501 li a0,0
73c: 00000097 auipc ra,0x0
740: 2aa080e7 jalr 682(ra) # 9e6 <exit>
ping(2000 + i + 1, dport, 1);
744: 7d14851b addiw a0,s1,2001
748: 4605 li a2,1
74a: 6599 lui a1,0x6
74c: 40058593 addi a1,a1,1024 # 6400 <__global_pointer$+0x4a9f>
750: 1542 slli a0,a0,0x30
752: 9141 srli a0,a0,0x30
754: 00000097 auipc ra,0x0
758: 90c080e7 jalr -1780(ra) # 60 <ping>
exit(0);
75c: 4501 li a0,0
75e: 00000097 auipc ra,0x0
762: 288080e7 jalr 648(ra) # 9e6 <exit>
exit(1);
766: 4505 li a0,1
768: 00000097 auipc ra,0x0
76c: 27e080e7 jalr 638(ra) # 9e6 <exit>
0000000000000770 <strcpy>:
#include "kernel/fcntl.h"
#include "user/user.h"
char*
strcpy(char *s, const char *t)
{
770: 1141 addi sp,sp,-16
772: e422 sd s0,8(sp)
774: 0800 addi s0,sp,16
char *os;
os = s;
while((*s++ = *t++) != 0)
776: 87aa mv a5,a0
778: 0585 addi a1,a1,1
77a: 0785 addi a5,a5,1
77c: fff5c703 lbu a4,-1(a1)
780: fee78fa3 sb a4,-1(a5)
784: fb75 bnez a4,778 <strcpy+0x8>
;
return os;
}
786: 6422 ld s0,8(sp)
788: 0141 addi sp,sp,16
78a: 8082 ret
000000000000078c <strcmp>:
int
strcmp(const char *p, const char *q)
{
78c: 1141 addi sp,sp,-16
78e: e422 sd s0,8(sp)
790: 0800 addi s0,sp,16
while(*p && *p == *q)
792: 00054783 lbu a5,0(a0)
796: cb91 beqz a5,7aa <strcmp+0x1e>
798: 0005c703 lbu a4,0(a1)
79c: 00f71763 bne a4,a5,7aa <strcmp+0x1e>
p++, q++;
7a0: 0505 addi a0,a0,1
7a2: 0585 addi a1,a1,1
while(*p && *p == *q)
7a4: 00054783 lbu a5,0(a0)
7a8: fbe5 bnez a5,798 <strcmp+0xc>
return (uchar)*p - (uchar)*q;
7aa: 0005c503 lbu a0,0(a1)
}
7ae: 40a7853b subw a0,a5,a0
7b2: 6422 ld s0,8(sp)
7b4: 0141 addi sp,sp,16
7b6: 8082 ret
00000000000007b8 <strlen>:
uint
strlen(const char *s)
{
7b8: 1141 addi sp,sp,-16
7ba: e422 sd s0,8(sp)
7bc: 0800 addi s0,sp,16
int n;
for(n = 0; s[n]; n++)
7be: 00054783 lbu a5,0(a0)
7c2: cf91 beqz a5,7de <strlen+0x26>
7c4: 0505 addi a0,a0,1
7c6: 87aa mv a5,a0
7c8: 4685 li a3,1
7ca: 9e89 subw a3,a3,a0
7cc: 00f6853b addw a0,a3,a5
7d0: 0785 addi a5,a5,1
7d2: fff7c703 lbu a4,-1(a5)
7d6: fb7d bnez a4,7cc <strlen+0x14>
;
return n;
}
7d8: 6422 ld s0,8(sp)
7da: 0141 addi sp,sp,16
7dc: 8082 ret
for(n = 0; s[n]; n++)
7de: 4501 li a0,0
7e0: bfe5 j 7d8 <strlen+0x20>
00000000000007e2 <memset>:
void*
memset(void *dst, int c, uint n)
{
7e2: 1141 addi sp,sp,-16
7e4: e422 sd s0,8(sp)
7e6: 0800 addi s0,sp,16
char *cdst = (char *) dst;
int i;
for(i = 0; i < n; i++){
7e8: ce09 beqz a2,802 <memset+0x20>
7ea: 87aa mv a5,a0
7ec: fff6071b addiw a4,a2,-1
7f0: 1702 slli a4,a4,0x20
7f2: 9301 srli a4,a4,0x20
7f4: 0705 addi a4,a4,1
7f6: 972a add a4,a4,a0
cdst[i] = c;
7f8: 00b78023 sb a1,0(a5)
for(i = 0; i < n; i++){
7fc: 0785 addi a5,a5,1
7fe: fee79de3 bne a5,a4,7f8 <memset+0x16>
}
return dst;
}
802: 6422 ld s0,8(sp)
804: 0141 addi sp,sp,16
806: 8082 ret
0000000000000808 <strchr>:
char*
strchr(const char *s, char c)
{
808: 1141 addi sp,sp,-16
80a: e422 sd s0,8(sp)
80c: 0800 addi s0,sp,16
for(; *s; s++)
80e: 00054783 lbu a5,0(a0)
812: cb99 beqz a5,828 <strchr+0x20>
if(*s == c)
814: 00f58763 beq a1,a5,822 <strchr+0x1a>
for(; *s; s++)
818: 0505 addi a0,a0,1
81a: 00054783 lbu a5,0(a0)
81e: fbfd bnez a5,814 <strchr+0xc>
return (char*)s;
return 0;
820: 4501 li a0,0
}
822: 6422 ld s0,8(sp)
824: 0141 addi sp,sp,16
826: 8082 ret
return 0;
828: 4501 li a0,0
82a: bfe5 j 822 <strchr+0x1a>
000000000000082c <gets>:
char*
gets(char *buf, int max)
{
82c: 711d addi sp,sp,-96
82e: ec86 sd ra,88(sp)
830: e8a2 sd s0,80(sp)
832: e4a6 sd s1,72(sp)
834: e0ca sd s2,64(sp)
836: fc4e sd s3,56(sp)
838: f852 sd s4,48(sp)
83a: f456 sd s5,40(sp)
83c: f05a sd s6,32(sp)
83e: ec5e sd s7,24(sp)
840: 1080 addi s0,sp,96
842: 8baa mv s7,a0
844: 8a2e mv s4,a1
int i, cc;
char c;
for(i=0; i+1 < max; ){
846: 892a mv s2,a0
848: 4481 li s1,0
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
84a: 4aa9 li s5,10
84c: 4b35 li s6,13
for(i=0; i+1 < max; ){
84e: 89a6 mv s3,s1
850: 2485 addiw s1,s1,1
852: 0344d863 bge s1,s4,882 <gets+0x56>
cc = read(0, &c, 1);
856: 4605 li a2,1
858: faf40593 addi a1,s0,-81
85c: 4501 li a0,0
85e: 00000097 auipc ra,0x0
862: 1a0080e7 jalr 416(ra) # 9fe <read>
if(cc < 1)
866: 00a05e63 blez a0,882 <gets+0x56>
buf[i++] = c;
86a: faf44783 lbu a5,-81(s0)
86e: 00f90023 sb a5,0(s2)
if(c == '\n' || c == '\r')
872: 01578763 beq a5,s5,880 <gets+0x54>
876: 0905 addi s2,s2,1
878: fd679be3 bne a5,s6,84e <gets+0x22>
for(i=0; i+1 < max; ){
87c: 89a6 mv s3,s1
87e: a011 j 882 <gets+0x56>
880: 89a6 mv s3,s1
break;
}
buf[i] = '\0';
882: 99de add s3,s3,s7
884: 00098023 sb zero,0(s3)
return buf;
}
888: 855e mv a0,s7
88a: 60e6 ld ra,88(sp)
88c: 6446 ld s0,80(sp)
88e: 64a6 ld s1,72(sp)
890: 6906 ld s2,64(sp)
892: 79e2 ld s3,56(sp)
894: 7a42 ld s4,48(sp)
896: 7aa2 ld s5,40(sp)
898: 7b02 ld s6,32(sp)
89a: 6be2 ld s7,24(sp)
89c: 6125 addi sp,sp,96
89e: 8082 ret
00000000000008a0 <stat>:
int
stat(const char *n, struct stat *st)
{
8a0: 1101 addi sp,sp,-32
8a2: ec06 sd ra,24(sp)
8a4: e822 sd s0,16(sp)
8a6: e426 sd s1,8(sp)
8a8: e04a sd s2,0(sp)
8aa: 1000 addi s0,sp,32
8ac: 892e mv s2,a1
int fd;
int r;
fd = open(n, O_RDONLY);
8ae: 4581 li a1,0
8b0: 00000097 auipc ra,0x0
8b4: 176080e7 jalr 374(ra) # a26 <open>
if(fd < 0)
8b8: 02054563 bltz a0,8e2 <stat+0x42>
8bc: 84aa mv s1,a0
return -1;
r = fstat(fd, st);
8be: 85ca mv a1,s2
8c0: 00000097 auipc ra,0x0
8c4: 17e080e7 jalr 382(ra) # a3e <fstat>
8c8: 892a mv s2,a0
close(fd);
8ca: 8526 mv a0,s1
8cc: 00000097 auipc ra,0x0
8d0: 142080e7 jalr 322(ra) # a0e <close>
return r;
}
8d4: 854a mv a0,s2
8d6: 60e2 ld ra,24(sp)
8d8: 6442 ld s0,16(sp)
8da: 64a2 ld s1,8(sp)
8dc: 6902 ld s2,0(sp)
8de: 6105 addi sp,sp,32
8e0: 8082 ret
return -1;
8e2: 597d li s2,-1
8e4: bfc5 j 8d4 <stat+0x34>
00000000000008e6 <atoi>:
int
atoi(const char *s)
{
8e6: 1141 addi sp,sp,-16
8e8: e422 sd s0,8(sp)
8ea: 0800 addi s0,sp,16
int n;
n = 0;
while('0' <= *s && *s <= '9')
8ec: 00054603 lbu a2,0(a0)
8f0: fd06079b addiw a5,a2,-48
8f4: 0ff7f793 andi a5,a5,255
8f8: 4725 li a4,9
8fa: 02f76963 bltu a4,a5,92c <atoi+0x46>
8fe: 86aa mv a3,a0
n = 0;
900: 4501 li a0,0
while('0' <= *s && *s <= '9')
902: 45a5 li a1,9
n = n*10 + *s++ - '0';
904: 0685 addi a3,a3,1
906: 0025179b slliw a5,a0,0x2
90a: 9fa9 addw a5,a5,a0
90c: 0017979b slliw a5,a5,0x1
910: 9fb1 addw a5,a5,a2
912: fd07851b addiw a0,a5,-48
while('0' <= *s && *s <= '9')
916: 0006c603 lbu a2,0(a3)
91a: fd06071b addiw a4,a2,-48
91e: 0ff77713 andi a4,a4,255
922: fee5f1e3 bgeu a1,a4,904 <atoi+0x1e>
return n;
}
926: 6422 ld s0,8(sp)
928: 0141 addi sp,sp,16
92a: 8082 ret
n = 0;
92c: 4501 li a0,0
92e: bfe5 j 926 <atoi+0x40>
0000000000000930 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
930: 1141 addi sp,sp,-16
932: e422 sd s0,8(sp)
934: 0800 addi s0,sp,16
char *dst;
const char *src;
dst = vdst;
src = vsrc;
if (src > dst) {
936: 02b57663 bgeu a0,a1,962 <memmove+0x32>
while(n-- > 0)
93a: 02c05163 blez a2,95c <memmove+0x2c>
93e: fff6079b addiw a5,a2,-1
942: 1782 slli a5,a5,0x20
944: 9381 srli a5,a5,0x20
946: 0785 addi a5,a5,1
948: 97aa add a5,a5,a0
dst = vdst;
94a: 872a mv a4,a0
*dst++ = *src++;
94c: 0585 addi a1,a1,1
94e: 0705 addi a4,a4,1
950: fff5c683 lbu a3,-1(a1)
954: fed70fa3 sb a3,-1(a4)
while(n-- > 0)
958: fee79ae3 bne a5,a4,94c <memmove+0x1c>
src += n;
while(n-- > 0)
*--dst = *--src;
}
return vdst;
}
95c: 6422 ld s0,8(sp)
95e: 0141 addi sp,sp,16
960: 8082 ret
dst += n;
962: 00c50733 add a4,a0,a2
src += n;
966: 95b2 add a1,a1,a2
while(n-- > 0)
968: fec05ae3 blez a2,95c <memmove+0x2c>
96c: fff6079b addiw a5,a2,-1
970: 1782 slli a5,a5,0x20
972: 9381 srli a5,a5,0x20
974: fff7c793 not a5,a5
978: 97ba add a5,a5,a4
*--dst = *--src;
97a: 15fd addi a1,a1,-1
97c: 177d addi a4,a4,-1
97e: 0005c683 lbu a3,0(a1)
982: 00d70023 sb a3,0(a4)
while(n-- > 0)
986: fee79ae3 bne a5,a4,97a <memmove+0x4a>
98a: bfc9 j 95c <memmove+0x2c>
000000000000098c <memcmp>:
int
memcmp(const void *s1, const void *s2, uint n)
{
98c: 1141 addi sp,sp,-16
98e: e422 sd s0,8(sp)
990: 0800 addi s0,sp,16
const char *p1 = s1, *p2 = s2;
while (n-- > 0) {
992: ca05 beqz a2,9c2 <memcmp+0x36>
994: fff6069b addiw a3,a2,-1
998: 1682 slli a3,a3,0x20
99a: 9281 srli a3,a3,0x20
99c: 0685 addi a3,a3,1
99e: 96aa add a3,a3,a0
if (*p1 != *p2) {
9a0: 00054783 lbu a5,0(a0)
9a4: 0005c703 lbu a4,0(a1)
9a8: 00e79863 bne a5,a4,9b8 <memcmp+0x2c>
return *p1 - *p2;
}
p1++;
9ac: 0505 addi a0,a0,1
p2++;
9ae: 0585 addi a1,a1,1
while (n-- > 0) {
9b0: fed518e3 bne a0,a3,9a0 <memcmp+0x14>
}
return 0;
9b4: 4501 li a0,0
9b6: a019 j 9bc <memcmp+0x30>
return *p1 - *p2;
9b8: 40e7853b subw a0,a5,a4
}
9bc: 6422 ld s0,8(sp)
9be: 0141 addi sp,sp,16
9c0: 8082 ret
return 0;
9c2: 4501 li a0,0
9c4: bfe5 j 9bc <memcmp+0x30>
00000000000009c6 <memcpy>:
void *
memcpy(void *dst, const void *src, uint n)
{
9c6: 1141 addi sp,sp,-16
9c8: e406 sd ra,8(sp)
9ca: e022 sd s0,0(sp)
9cc: 0800 addi s0,sp,16
return memmove(dst, src, n);
9ce: 00000097 auipc ra,0x0
9d2: f62080e7 jalr -158(ra) # 930 <memmove>
}
9d6: 60a2 ld ra,8(sp)
9d8: 6402 ld s0,0(sp)
9da: 0141 addi sp,sp,16
9dc: 8082 ret
00000000000009de <fork>:
# generated by usys.pl - do not edit
#include "kernel/syscall.h"
.global fork
fork:
li a7, SYS_fork
9de: 4885 li a7,1
ecall
9e0: 00000073 ecall
ret
9e4: 8082 ret
00000000000009e6 <exit>:
.global exit
exit:
li a7, SYS_exit
9e6: 4889 li a7,2
ecall
9e8: 00000073 ecall
ret
9ec: 8082 ret
00000000000009ee <wait>:
.global wait
wait:
li a7, SYS_wait
9ee: 488d li a7,3
ecall
9f0: 00000073 ecall
ret
9f4: 8082 ret
00000000000009f6 <pipe>:
.global pipe
pipe:
li a7, SYS_pipe
9f6: 4891 li a7,4
ecall
9f8: 00000073 ecall
ret
9fc: 8082 ret
00000000000009fe <read>:
.global read
read:
li a7, SYS_read
9fe: 4895 li a7,5
ecall
a00: 00000073 ecall
ret
a04: 8082 ret
0000000000000a06 <write>:
.global write
write:
li a7, SYS_write
a06: 48c1 li a7,16
ecall
a08: 00000073 ecall
ret
a0c: 8082 ret
0000000000000a0e <close>:
.global close
close:
li a7, SYS_close
a0e: 48d5 li a7,21
ecall
a10: 00000073 ecall
ret
a14: 8082 ret
0000000000000a16 <kill>:
.global kill
kill:
li a7, SYS_kill
a16: 4899 li a7,6
ecall
a18: 00000073 ecall
ret
a1c: 8082 ret
0000000000000a1e <exec>:
.global exec
exec:
li a7, SYS_exec
a1e: 489d li a7,7
ecall
a20: 00000073 ecall
ret
a24: 8082 ret
0000000000000a26 <open>:
.global open
open:
li a7, SYS_open
a26: 48bd li a7,15
ecall
a28: 00000073 ecall
ret
a2c: 8082 ret
0000000000000a2e <mknod>:
.global mknod
mknod:
li a7, SYS_mknod
a2e: 48c5 li a7,17
ecall
a30: 00000073 ecall
ret
a34: 8082 ret
0000000000000a36 <unlink>:
.global unlink
unlink:
li a7, SYS_unlink
a36: 48c9 li a7,18
ecall
a38: 00000073 ecall
ret
a3c: 8082 ret
0000000000000a3e <fstat>:
.global fstat
fstat:
li a7, SYS_fstat
a3e: 48a1 li a7,8
ecall
a40: 00000073 ecall
ret
a44: 8082 ret
0000000000000a46 <link>:
.global link
link:
li a7, SYS_link
a46: 48cd li a7,19
ecall
a48: 00000073 ecall
ret
a4c: 8082 ret
0000000000000a4e <mkdir>:
.global mkdir
mkdir:
li a7, SYS_mkdir
a4e: 48d1 li a7,20
ecall
a50: 00000073 ecall
ret
a54: 8082 ret
0000000000000a56 <chdir>:
.global chdir
chdir:
li a7, SYS_chdir
a56: 48a5 li a7,9
ecall
a58: 00000073 ecall
ret
a5c: 8082 ret
0000000000000a5e <dup>:
.global dup
dup:
li a7, SYS_dup
a5e: 48a9 li a7,10
ecall
a60: 00000073 ecall
ret
a64: 8082 ret
0000000000000a66 <getpid>:
.global getpid
getpid:
li a7, SYS_getpid
a66: 48ad li a7,11
ecall
a68: 00000073 ecall
ret
a6c: 8082 ret
0000000000000a6e <sbrk>:
.global sbrk
sbrk:
li a7, SYS_sbrk
a6e: 48b1 li a7,12
ecall
a70: 00000073 ecall
ret
a74: 8082 ret
0000000000000a76 <sleep>:
.global sleep
sleep:
li a7, SYS_sleep
a76: 48b5 li a7,13
ecall
a78: 00000073 ecall
ret
a7c: 8082 ret
0000000000000a7e <uptime>:
.global uptime
uptime:
li a7, SYS_uptime
a7e: 48b9 li a7,14
ecall
a80: 00000073 ecall
ret
a84: 8082 ret
0000000000000a86 <connect>:
.global connect
connect:
li a7, SYS_connect
a86: 48d9 li a7,22
ecall
a88: 00000073 ecall
ret
a8c: 8082 ret
0000000000000a8e <ntas>:
.global ntas
ntas:
li a7, SYS_ntas
a8e: 48dd li a7,23
ecall
a90: 00000073 ecall
ret
a94: 8082 ret
0000000000000a96 <putc>:
static char digits[] = "0123456789ABCDEF";
static void
putc(int fd, char c)
{
a96: 1101 addi sp,sp,-32
a98: ec06 sd ra,24(sp)
a9a: e822 sd s0,16(sp)
a9c: 1000 addi s0,sp,32
a9e: feb407a3 sb a1,-17(s0)
write(fd, &c, 1);
aa2: 4605 li a2,1
aa4: fef40593 addi a1,s0,-17
aa8: 00000097 auipc ra,0x0
aac: f5e080e7 jalr -162(ra) # a06 <write>
}
ab0: 60e2 ld ra,24(sp)
ab2: 6442 ld s0,16(sp)
ab4: 6105 addi sp,sp,32
ab6: 8082 ret
0000000000000ab8 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
ab8: 7139 addi sp,sp,-64
aba: fc06 sd ra,56(sp)
abc: f822 sd s0,48(sp)
abe: f426 sd s1,40(sp)
ac0: f04a sd s2,32(sp)
ac2: ec4e sd s3,24(sp)
ac4: 0080 addi s0,sp,64
ac6: 84aa mv s1,a0
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
ac8: c299 beqz a3,ace <printint+0x16>
aca: 0805c863 bltz a1,b5a <printint+0xa2>
neg = 1;
x = -xx;
} else {
x = xx;
ace: 2581 sext.w a1,a1
neg = 0;
ad0: 4881 li a7,0
ad2: fc040693 addi a3,s0,-64
}
i = 0;
ad6: 4701 li a4,0
do{
buf[i++] = digits[x % base];
ad8: 2601 sext.w a2,a2
ada: 00000517 auipc a0,0x0
ade: 67650513 addi a0,a0,1654 # 1150 <digits>
ae2: 883a mv a6,a4
ae4: 2705 addiw a4,a4,1
ae6: 02c5f7bb remuw a5,a1,a2
aea: 1782 slli a5,a5,0x20
aec: 9381 srli a5,a5,0x20
aee: 97aa add a5,a5,a0
af0: 0007c783 lbu a5,0(a5)
af4: 00f68023 sb a5,0(a3)
}while((x /= base) != 0);
af8: 0005879b sext.w a5,a1
afc: 02c5d5bb divuw a1,a1,a2
b00: 0685 addi a3,a3,1
b02: fec7f0e3 bgeu a5,a2,ae2 <printint+0x2a>
if(neg)
b06: 00088b63 beqz a7,b1c <printint+0x64>
buf[i++] = '-';
b0a: fd040793 addi a5,s0,-48
b0e: 973e add a4,a4,a5
b10: 02d00793 li a5,45
b14: fef70823 sb a5,-16(a4)
b18: 0028071b addiw a4,a6,2
while(--i >= 0)
b1c: 02e05863 blez a4,b4c <printint+0x94>
b20: fc040793 addi a5,s0,-64
b24: 00e78933 add s2,a5,a4
b28: fff78993 addi s3,a5,-1
b2c: 99ba add s3,s3,a4
b2e: 377d addiw a4,a4,-1
b30: 1702 slli a4,a4,0x20
b32: 9301 srli a4,a4,0x20
b34: 40e989b3 sub s3,s3,a4
putc(fd, buf[i]);
b38: fff94583 lbu a1,-1(s2)
b3c: 8526 mv a0,s1
b3e: 00000097 auipc ra,0x0
b42: f58080e7 jalr -168(ra) # a96 <putc>
while(--i >= 0)
b46: 197d addi s2,s2,-1
b48: ff3918e3 bne s2,s3,b38 <printint+0x80>
}
b4c: 70e2 ld ra,56(sp)
b4e: 7442 ld s0,48(sp)
b50: 74a2 ld s1,40(sp)
b52: 7902 ld s2,32(sp)
b54: 69e2 ld s3,24(sp)
b56: 6121 addi sp,sp,64
b58: 8082 ret
x = -xx;
b5a: 40b005bb negw a1,a1
neg = 1;
b5e: 4885 li a7,1
x = -xx;
b60: bf8d j ad2 <printint+0x1a>
0000000000000b62 <vprintf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
vprintf(int fd, const char *fmt, va_list ap)
{
b62: 7119 addi sp,sp,-128
b64: fc86 sd ra,120(sp)
b66: f8a2 sd s0,112(sp)
b68: f4a6 sd s1,104(sp)
b6a: f0ca sd s2,96(sp)
b6c: ecce sd s3,88(sp)
b6e: e8d2 sd s4,80(sp)
b70: e4d6 sd s5,72(sp)
b72: e0da sd s6,64(sp)
b74: fc5e sd s7,56(sp)
b76: f862 sd s8,48(sp)
b78: f466 sd s9,40(sp)
b7a: f06a sd s10,32(sp)
b7c: ec6e sd s11,24(sp)
b7e: 0100 addi s0,sp,128
char *s;
int c, i, state;
state = 0;
for(i = 0; fmt[i]; i++){
b80: 0005c903 lbu s2,0(a1)
b84: 18090f63 beqz s2,d22 <vprintf+0x1c0>
b88: 8aaa mv s5,a0
b8a: 8b32 mv s6,a2
b8c: 00158493 addi s1,a1,1
state = 0;
b90: 4981 li s3,0
if(c == '%'){
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
b92: 02500a13 li s4,37
if(c == 'd'){
b96: 06400c13 li s8,100
printint(fd, va_arg(ap, int), 10, 1);
} else if(c == 'l') {
b9a: 06c00c93 li s9,108
printint(fd, va_arg(ap, uint64), 10, 0);
} else if(c == 'x') {
b9e: 07800d13 li s10,120
printint(fd, va_arg(ap, int), 16, 0);
} else if(c == 'p') {
ba2: 07000d93 li s11,112
putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
ba6: 00000b97 auipc s7,0x0
baa: 5aab8b93 addi s7,s7,1450 # 1150 <digits>
bae: a839 j bcc <vprintf+0x6a>
putc(fd, c);
bb0: 85ca mv a1,s2
bb2: 8556 mv a0,s5
bb4: 00000097 auipc ra,0x0
bb8: ee2080e7 jalr -286(ra) # a96 <putc>
bbc: a019 j bc2 <vprintf+0x60>
} else if(state == '%'){
bbe: 01498f63 beq s3,s4,bdc <vprintf+0x7a>
for(i = 0; fmt[i]; i++){
bc2: 0485 addi s1,s1,1
bc4: fff4c903 lbu s2,-1(s1)
bc8: 14090d63 beqz s2,d22 <vprintf+0x1c0>
c = fmt[i] & 0xff;
bcc: 0009079b sext.w a5,s2
if(state == 0){
bd0: fe0997e3 bnez s3,bbe <vprintf+0x5c>
if(c == '%'){
bd4: fd479ee3 bne a5,s4,bb0 <vprintf+0x4e>
state = '%';
bd8: 89be mv s3,a5
bda: b7e5 j bc2 <vprintf+0x60>
if(c == 'd'){
bdc: 05878063 beq a5,s8,c1c <vprintf+0xba>
} else if(c == 'l') {
be0: 05978c63 beq a5,s9,c38 <vprintf+0xd6>
} else if(c == 'x') {
be4: 07a78863 beq a5,s10,c54 <vprintf+0xf2>
} else if(c == 'p') {
be8: 09b78463 beq a5,s11,c70 <vprintf+0x10e>
printptr(fd, va_arg(ap, uint64));
} else if(c == 's'){
bec: 07300713 li a4,115
bf0: 0ce78663 beq a5,a4,cbc <vprintf+0x15a>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
bf4: 06300713 li a4,99
bf8: 0ee78e63 beq a5,a4,cf4 <vprintf+0x192>
putc(fd, va_arg(ap, uint));
} else if(c == '%'){
bfc: 11478863 beq a5,s4,d0c <vprintf+0x1aa>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
c00: 85d2 mv a1,s4
c02: 8556 mv a0,s5
c04: 00000097 auipc ra,0x0
c08: e92080e7 jalr -366(ra) # a96 <putc>
putc(fd, c);
c0c: 85ca mv a1,s2
c0e: 8556 mv a0,s5
c10: 00000097 auipc ra,0x0
c14: e86080e7 jalr -378(ra) # a96 <putc>
}
state = 0;
c18: 4981 li s3,0
c1a: b765 j bc2 <vprintf+0x60>
printint(fd, va_arg(ap, int), 10, 1);
c1c: 008b0913 addi s2,s6,8
c20: 4685 li a3,1
c22: 4629 li a2,10
c24: 000b2583 lw a1,0(s6)
c28: 8556 mv a0,s5
c2a: 00000097 auipc ra,0x0
c2e: e8e080e7 jalr -370(ra) # ab8 <printint>
c32: 8b4a mv s6,s2
state = 0;
c34: 4981 li s3,0
c36: b771 j bc2 <vprintf+0x60>
printint(fd, va_arg(ap, uint64), 10, 0);
c38: 008b0913 addi s2,s6,8
c3c: 4681 li a3,0
c3e: 4629 li a2,10
c40: 000b2583 lw a1,0(s6)
c44: 8556 mv a0,s5
c46: 00000097 auipc ra,0x0
c4a: e72080e7 jalr -398(ra) # ab8 <printint>
c4e: 8b4a mv s6,s2
state = 0;
c50: 4981 li s3,0
c52: bf85 j bc2 <vprintf+0x60>
printint(fd, va_arg(ap, int), 16, 0);
c54: 008b0913 addi s2,s6,8
c58: 4681 li a3,0
c5a: 4641 li a2,16
c5c: 000b2583 lw a1,0(s6)
c60: 8556 mv a0,s5
c62: 00000097 auipc ra,0x0
c66: e56080e7 jalr -426(ra) # ab8 <printint>
c6a: 8b4a mv s6,s2
state = 0;
c6c: 4981 li s3,0
c6e: bf91 j bc2 <vprintf+0x60>
printptr(fd, va_arg(ap, uint64));
c70: 008b0793 addi a5,s6,8
c74: f8f43423 sd a5,-120(s0)
c78: 000b3983 ld s3,0(s6)
putc(fd, '0');
c7c: 03000593 li a1,48
c80: 8556 mv a0,s5
c82: 00000097 auipc ra,0x0
c86: e14080e7 jalr -492(ra) # a96 <putc>
putc(fd, 'x');
c8a: 85ea mv a1,s10
c8c: 8556 mv a0,s5
c8e: 00000097 auipc ra,0x0
c92: e08080e7 jalr -504(ra) # a96 <putc>
c96: 4941 li s2,16
putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
c98: 03c9d793 srli a5,s3,0x3c
c9c: 97de add a5,a5,s7
c9e: 0007c583 lbu a1,0(a5)
ca2: 8556 mv a0,s5
ca4: 00000097 auipc ra,0x0
ca8: df2080e7 jalr -526(ra) # a96 <putc>
for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
cac: 0992 slli s3,s3,0x4
cae: 397d addiw s2,s2,-1
cb0: fe0914e3 bnez s2,c98 <vprintf+0x136>
printptr(fd, va_arg(ap, uint64));
cb4: f8843b03 ld s6,-120(s0)
state = 0;
cb8: 4981 li s3,0
cba: b721 j bc2 <vprintf+0x60>
s = va_arg(ap, char*);
cbc: 008b0993 addi s3,s6,8
cc0: 000b3903 ld s2,0(s6)
if(s == 0)
cc4: 02090163 beqz s2,ce6 <vprintf+0x184>
while(*s != 0){
cc8: 00094583 lbu a1,0(s2)
ccc: c9a1 beqz a1,d1c <vprintf+0x1ba>
putc(fd, *s);
cce: 8556 mv a0,s5
cd0: 00000097 auipc ra,0x0
cd4: dc6080e7 jalr -570(ra) # a96 <putc>
s++;
cd8: 0905 addi s2,s2,1
while(*s != 0){
cda: 00094583 lbu a1,0(s2)
cde: f9e5 bnez a1,cce <vprintf+0x16c>
s = va_arg(ap, char*);
ce0: 8b4e mv s6,s3
state = 0;
ce2: 4981 li s3,0
ce4: bdf9 j bc2 <vprintf+0x60>
s = "(null)";
ce6: 00000917 auipc s2,0x0
cea: 46290913 addi s2,s2,1122 # 1148 <malloc+0x31c>
while(*s != 0){
cee: 02800593 li a1,40
cf2: bff1 j cce <vprintf+0x16c>
putc(fd, va_arg(ap, uint));
cf4: 008b0913 addi s2,s6,8
cf8: 000b4583 lbu a1,0(s6)
cfc: 8556 mv a0,s5
cfe: 00000097 auipc ra,0x0
d02: d98080e7 jalr -616(ra) # a96 <putc>
d06: 8b4a mv s6,s2
state = 0;
d08: 4981 li s3,0
d0a: bd65 j bc2 <vprintf+0x60>
putc(fd, c);
d0c: 85d2 mv a1,s4
d0e: 8556 mv a0,s5
d10: 00000097 auipc ra,0x0
d14: d86080e7 jalr -634(ra) # a96 <putc>
state = 0;
d18: 4981 li s3,0
d1a: b565 j bc2 <vprintf+0x60>
s = va_arg(ap, char*);
d1c: 8b4e mv s6,s3
state = 0;
d1e: 4981 li s3,0
d20: b54d j bc2 <vprintf+0x60>
}
}
}
d22: 70e6 ld ra,120(sp)
d24: 7446 ld s0,112(sp)
d26: 74a6 ld s1,104(sp)
d28: 7906 ld s2,96(sp)
d2a: 69e6 ld s3,88(sp)
d2c: 6a46 ld s4,80(sp)
d2e: 6aa6 ld s5,72(sp)
d30: 6b06 ld s6,64(sp)
d32: 7be2 ld s7,56(sp)
d34: 7c42 ld s8,48(sp)
d36: 7ca2 ld s9,40(sp)
d38: 7d02 ld s10,32(sp)
d3a: 6de2 ld s11,24(sp)
d3c: 6109 addi sp,sp,128
d3e: 8082 ret
0000000000000d40 <fprintf>:
void
fprintf(int fd, const char *fmt, ...)
{
d40: 715d addi sp,sp,-80
d42: ec06 sd ra,24(sp)
d44: e822 sd s0,16(sp)
d46: 1000 addi s0,sp,32
d48: e010 sd a2,0(s0)
d4a: e414 sd a3,8(s0)
d4c: e818 sd a4,16(s0)
d4e: ec1c sd a5,24(s0)
d50: 03043023 sd a6,32(s0)
d54: 03143423 sd a7,40(s0)
va_list ap;
va_start(ap, fmt);
d58: fe843423 sd s0,-24(s0)
vprintf(fd, fmt, ap);
d5c: 8622 mv a2,s0
d5e: 00000097 auipc ra,0x0
d62: e04080e7 jalr -508(ra) # b62 <vprintf>
}
d66: 60e2 ld ra,24(sp)
d68: 6442 ld s0,16(sp)
d6a: 6161 addi sp,sp,80
d6c: 8082 ret
0000000000000d6e <printf>:
void
printf(const char *fmt, ...)
{
d6e: 711d addi sp,sp,-96
d70: ec06 sd ra,24(sp)
d72: e822 sd s0,16(sp)
d74: 1000 addi s0,sp,32
d76: e40c sd a1,8(s0)
d78: e810 sd a2,16(s0)
d7a: ec14 sd a3,24(s0)
d7c: f018 sd a4,32(s0)
d7e: f41c sd a5,40(s0)
d80: 03043823 sd a6,48(s0)
d84: 03143c23 sd a7,56(s0)
va_list ap;
va_start(ap, fmt);
d88: 00840613 addi a2,s0,8
d8c: fec43423 sd a2,-24(s0)
vprintf(1, fmt, ap);
d90: 85aa mv a1,a0
d92: 4505 li a0,1
d94: 00000097 auipc ra,0x0
d98: dce080e7 jalr -562(ra) # b62 <vprintf>
}
d9c: 60e2 ld ra,24(sp)
d9e: 6442 ld s0,16(sp)
da0: 6125 addi sp,sp,96
da2: 8082 ret
0000000000000da4 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
da4: 1141 addi sp,sp,-16
da6: e422 sd s0,8(sp)
da8: 0800 addi s0,sp,16
Header *bp, *p;
bp = (Header*)ap - 1;
daa: ff050693 addi a3,a0,-16
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
dae: 00000797 auipc a5,0x0
db2: 3ba7b783 ld a5,954(a5) # 1168 <freep>
db6: a805 j de6 <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;
db8: 4618 lw a4,8(a2)
dba: 9db9 addw a1,a1,a4
dbc: feb52c23 sw a1,-8(a0)
bp->s.ptr = p->s.ptr->s.ptr;
dc0: 6398 ld a4,0(a5)
dc2: 6318 ld a4,0(a4)
dc4: fee53823 sd a4,-16(a0)
dc8: a091 j e0c <free+0x68>
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
p->s.size += bp->s.size;
dca: ff852703 lw a4,-8(a0)
dce: 9e39 addw a2,a2,a4
dd0: c790 sw a2,8(a5)
p->s.ptr = bp->s.ptr;
dd2: ff053703 ld a4,-16(a0)
dd6: e398 sd a4,0(a5)
dd8: a099 j e1e <free+0x7a>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
dda: 6398 ld a4,0(a5)
ddc: 00e7e463 bltu a5,a4,de4 <free+0x40>
de0: 00e6ea63 bltu a3,a4,df4 <free+0x50>
{
de4: 87ba mv a5,a4
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
de6: fed7fae3 bgeu a5,a3,dda <free+0x36>
dea: 6398 ld a4,0(a5)
dec: 00e6e463 bltu a3,a4,df4 <free+0x50>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
df0: fee7eae3 bltu a5,a4,de4 <free+0x40>
if(bp + bp->s.size == p->s.ptr){
df4: ff852583 lw a1,-8(a0)
df8: 6390 ld a2,0(a5)
dfa: 02059713 slli a4,a1,0x20
dfe: 9301 srli a4,a4,0x20
e00: 0712 slli a4,a4,0x4
e02: 9736 add a4,a4,a3
e04: fae60ae3 beq a2,a4,db8 <free+0x14>
bp->s.ptr = p->s.ptr;
e08: fec53823 sd a2,-16(a0)
if(p + p->s.size == bp){
e0c: 4790 lw a2,8(a5)
e0e: 02061713 slli a4,a2,0x20
e12: 9301 srli a4,a4,0x20
e14: 0712 slli a4,a4,0x4
e16: 973e add a4,a4,a5
e18: fae689e3 beq a3,a4,dca <free+0x26>
} else
p->s.ptr = bp;
e1c: e394 sd a3,0(a5)
freep = p;
e1e: 00000717 auipc a4,0x0
e22: 34f73523 sd a5,842(a4) # 1168 <freep>
}
e26: 6422 ld s0,8(sp)
e28: 0141 addi sp,sp,16
e2a: 8082 ret
0000000000000e2c <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
e2c: 7139 addi sp,sp,-64
e2e: fc06 sd ra,56(sp)
e30: f822 sd s0,48(sp)
e32: f426 sd s1,40(sp)
e34: f04a sd s2,32(sp)
e36: ec4e sd s3,24(sp)
e38: e852 sd s4,16(sp)
e3a: e456 sd s5,8(sp)
e3c: e05a sd s6,0(sp)
e3e: 0080 addi s0,sp,64
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
e40: 02051493 slli s1,a0,0x20
e44: 9081 srli s1,s1,0x20
e46: 04bd addi s1,s1,15
e48: 8091 srli s1,s1,0x4
e4a: 0014899b addiw s3,s1,1
e4e: 0485 addi s1,s1,1
if((prevp = freep) == 0){
e50: 00000517 auipc a0,0x0
e54: 31853503 ld a0,792(a0) # 1168 <freep>
e58: c515 beqz a0,e84 <malloc+0x58>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
e5a: 611c ld a5,0(a0)
if(p->s.size >= nunits){
e5c: 4798 lw a4,8(a5)
e5e: 02977f63 bgeu a4,s1,e9c <malloc+0x70>
e62: 8a4e mv s4,s3
e64: 0009871b sext.w a4,s3
e68: 6685 lui a3,0x1
e6a: 00d77363 bgeu a4,a3,e70 <malloc+0x44>
e6e: 6a05 lui s4,0x1
e70: 000a0b1b sext.w s6,s4
p = sbrk(nu * sizeof(Header));
e74: 004a1a1b slliw s4,s4,0x4
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
e78: 00000917 auipc s2,0x0
e7c: 2f090913 addi s2,s2,752 # 1168 <freep>
if(p == (char*)-1)
e80: 5afd li s5,-1
e82: a88d j ef4 <malloc+0xc8>
base.s.ptr = freep = prevp = &base;
e84: 00000797 auipc a5,0x0
e88: 2ec78793 addi a5,a5,748 # 1170 <base>
e8c: 00000717 auipc a4,0x0
e90: 2cf73e23 sd a5,732(a4) # 1168 <freep>
e94: e39c sd a5,0(a5)
base.s.size = 0;
e96: 0007a423 sw zero,8(a5)
if(p->s.size >= nunits){
e9a: b7e1 j e62 <malloc+0x36>
if(p->s.size == nunits)
e9c: 02e48b63 beq s1,a4,ed2 <malloc+0xa6>
p->s.size -= nunits;
ea0: 4137073b subw a4,a4,s3
ea4: c798 sw a4,8(a5)
p += p->s.size;
ea6: 1702 slli a4,a4,0x20
ea8: 9301 srli a4,a4,0x20
eaa: 0712 slli a4,a4,0x4
eac: 97ba add a5,a5,a4
p->s.size = nunits;
eae: 0137a423 sw s3,8(a5)
freep = prevp;
eb2: 00000717 auipc a4,0x0
eb6: 2aa73b23 sd a0,694(a4) # 1168 <freep>
return (void*)(p + 1);
eba: 01078513 addi a0,a5,16
if((p = morecore(nunits)) == 0)
return 0;
}
}
ebe: 70e2 ld ra,56(sp)
ec0: 7442 ld s0,48(sp)
ec2: 74a2 ld s1,40(sp)
ec4: 7902 ld s2,32(sp)
ec6: 69e2 ld s3,24(sp)
ec8: 6a42 ld s4,16(sp)
eca: 6aa2 ld s5,8(sp)
ecc: 6b02 ld s6,0(sp)
ece: 6121 addi sp,sp,64
ed0: 8082 ret
prevp->s.ptr = p->s.ptr;
ed2: 6398 ld a4,0(a5)
ed4: e118 sd a4,0(a0)
ed6: bff1 j eb2 <malloc+0x86>
hp->s.size = nu;
ed8: 01652423 sw s6,8(a0)
free((void*)(hp + 1));
edc: 0541 addi a0,a0,16
ede: 00000097 auipc ra,0x0
ee2: ec6080e7 jalr -314(ra) # da4 <free>
return freep;
ee6: 00093503 ld a0,0(s2)
if((p = morecore(nunits)) == 0)
eea: d971 beqz a0,ebe <malloc+0x92>
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
eec: 611c ld a5,0(a0)
if(p->s.size >= nunits){
eee: 4798 lw a4,8(a5)
ef0: fa9776e3 bgeu a4,s1,e9c <malloc+0x70>
if(p == freep)
ef4: 00093703 ld a4,0(s2)
ef8: 853e mv a0,a5
efa: fef719e3 bne a4,a5,eec <malloc+0xc0>
p = sbrk(nu * sizeof(Header));
efe: 8552 mv a0,s4
f00: 00000097 auipc ra,0x0
f04: b6e080e7 jalr -1170(ra) # a6e <sbrk>
if(p == (char*)-1)
f08: fd5518e3 bne a0,s5,ed8 <malloc+0xac>
return 0;
f0c: 4501 li a0,0
f0e: bf45 j ebe <malloc+0x92>
|
oeis/002/A002383.asm | neoneye/loda-programs | 11 | 175529 | ; A002383: Primes of form n^2 + n + 1.
; Submitted by <NAME>
; 3,7,13,31,43,73,157,211,241,307,421,463,601,757,1123,1483,1723,2551,2971,3307,3541,3907,4423,4831,5113,5701,6007,6163,6481,8011,8191,9901,10303,11131,12211,12433,13807,14281,17293,19183,20023,20593,21757,22651,23563,24181,26083,26407,27061,28057,28393,30103,31153,35533,35911,37057,37831,41413,42643,43891,46441,47743,53593,55933,60271,60763,71023,74257,77563,78121,82657,83233,84391,86143,95791,98911,108571,110557,113233,117307,118681,121453,123553,127807,136531,143263,145543,147073,154057,156421
seq $0,88503 ; Numbers n such that (n^2 + 3)/4 is prime.
pow $0,2
div $0,4
add $0,1
|
tune/blas/gemm/CASES/objs/ATL_dJIK30x30x30TN30x30x0_a1_b1.asm | kevleyski/math-atlas | 0 | 102823 | ; Automatically Tuned Linear Algebra Software v3.10.3
; (C) Copyright 2001 <NAME>
;
; 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. The name of the ATLAS group or the names of its contributers may
; not be used to endorse or promote products derived from this
; software without specific 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 ATLAS GROUP OR ITS 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.
;
;
; ATL_dJIK30x30x30TN30x30x0_a1_b1.asm
;
; ATLAS "Speed of Light" DGEMM() kernel for AMD Athlon
; Code author: <NAME> (<EMAIL> | <EMAIL>)
;
; void ATL_dJIK30x30x30TN30x30x0_a1_b1(const int M, const int N, const int K, const double alpha,
; const double *A, const int lda, const double *B, const int ldb,
; const double beta, double *C, const int ldc)
;
; Compile with "nasmw -f win32 -DWIN32 ATL_dJIK30x30x30TN30x30x0_a1_b1.asm" (Windows)
; Compile with "nasm -f elf -DELF ATL_dJIK30x30x30TN30x30x0_a1_b1.asm" (LINUX)
;
; See config file (ATL_dJIK30x30x30TN30x30x0_a1.cfg) for important macro definitions
;
%include "ATL_dJIK30x30x30TN30x30x0_a1.cfg"
%include "ATL_dJIK30x30x30TN30x30x0_a1.mcr"
%ifdef WIN32
global _ATL_dJIK30x30x30TN30x30x0_a1_b1
section .text
_ATL_dJIK30x30x30TN30x30x0_a1_b1:
%endif
%ifdef ELF
global ATL_dJIK30x30x30TN30x30x0_a1_b1
section .text
ATL_dJIK30x30x30TN30x30x0_a1_b1:
%endif
push ebp
mov ebp,esp
push ebx
push esi
push edi
femms
mov eax,0 ;temporary variable t1
push eax ;t1->stack
mov eax,[ebp+28] ;&A->eax
add eax,NB*NB*8 ;&(A+1)->eax
mov ebx,[ebp+36] ;&B->ebx
sub eax,ebx ;calculate offset
push eax ;&A+1+offset->stack
mov eax,[ebp+56] ;ldc->eax
lea eax,[8*eax]
push eax ;8*ldc->stack
mov eax,NB
push eax ;loop counter->stack
mov eax,[ebp+28] ;&A->eax
mov ebx,[ebp+36] ;&B->ebx
mov ecx,[ebp+52] ;&C->ecx
add ecx,byte 15*8 ;calculate offsets
add ebx,byte 15*8
add eax,5*NB*8
push eax ;&A+offset->stack
push ebp ;ebp->stack
mov edi,-1*NB*8 ;calculate offsets for dot products
mov esi,-3*NB*8
mov ebp,-5*NB*8
mov edx,6*NB*8-15*8 ;offset for the next 6 dot products
;stack dump
;[esp+20]: t1 (temp)
;[esp+16]: &(A+1)+offset
;[esp+12]: ldc*8
;[esp+08]: loop counter
;[esp+04]: &A+offset
;[esp+00]: ebp
align 16
loopj_
fld qword [ebx+ELM1] ;01+1
fld qword [eax+DOTP2]
fmul st0,st1
fadd qword [ecx+ELM2]
fld qword [eax+DOTP3]
fmul st0,st2
fadd qword [ecx+ELM3]
fld qword [eax+DOTP1]
fmul st0,st3
fadd qword [ecx+ELM1]
fxch st0,st3
fld qword [eax+DOTP5]
rep
fmul st0,st1
fadd qword [ecx+ELM5]
fld qword [eax+DOTP6]
fmul st0,st2
fadd qword [ecx+ELM6]
fld qword [ebx+ELM2]
fld qword [eax+DOTP4]
fmulp st4,st0
fld qword [ecx+ELM4]
rep
faddp st4,st0
add eax,byte 15*8
mov edx,edx
OPERATION 2,3 ;02+1
OPERATION 3,4 ;03+1
OPERATION 4,5 ;04+1
OPERATION 5,6 ;05+1
OPERATION 6,7 ;06+1
OPERATION 7,8 ;07+1
OPERATION 8,9 ;08+1
OPERATION 9,10 ;09+1
OPERATION 10,11 ;10+1
OPERATION 11,12 ;11+1
OPERATION 12,13 ;12+1
OPERATION 13,14 ;13+1
OPERATION 14,15 ;14+1
OPERATION 15,16 ;15+1
OPERATION 16,17 ;16+1
OPERATION 17,18 ;17+1
OPERATION 18,19 ;18+1
OPERATION 19,20 ;19+1
OPERATION 20,21 ;20+1
OPERATION 21,22 ;21+1
OPERATION 22,23 ;22+1
OPERATION 23,24 ;23+1
OPERATION 24,25 ;24+1
OPERATION 25,26 ;25+1
OPERATION 26,27 ;26+1
OPERATION 27,28 ;27+1
OPERATION 28,29 ;28+1
OPERATION 29,30 ;29+1
fld qword [eax+DOTP1+ELM30] ;30+1
fmul st0,st1
faddp st7
fld qword [eax+DOTP2+ELM30]
fmul st0,st1
faddp st6
fld qword [eax+DOTP3+ELM30]
fmul st0,st1
faddp st5
fld qword [eax+DOTP4+ELM30]
fmul st0,st1
faddp st4
fld qword [eax+DOTP5+ELM30]
fmul st0,st1
faddp st3
rep
fmul qword [eax+DOTP6+ELM30]
faddp st1
fxch st5
%ifdef PREC_DST4
mov [esp+20],ecx
add ecx,[esp+12]
prefetchw [ecx-2*64]
prefetchw [ecx-1*64]
prefetchw [ecx+0*64]
prefetchw [ecx+1*64]
nop
prefetchw [ecx+2*64-1]
mov ecx,[esp+20]
%endif
%ifdef PREB_DST4
prefetch [ebx+30*8-2*64]
fnop
mov edx,edx
prefetch [ebx+30*8-1*64]
nop
prefetch [ebx+30*8+0*64]
nop
prefetch [ebx+30*8+1*64]
nop
prefetch [ebx+30*8+2*64]
nop
%endif
fstp qword [ecx+ELM1]
fxch st3
fstp qword [ecx+ELM2]
fxch st1
fstp qword [ecx+ELM3]
fstp qword [ecx+ELM4]
fstp qword [ecx+ELM5]
fstp qword [ecx+ELM6]
add eax,edx
fld qword [ebx+ELM1] ;01+2
fld qword [eax+DOTP2]
fmul st0,st1
fadd qword [ecx+ELM8]
fld qword [eax+DOTP3]
fmul st0,st2
fadd qword [ecx+ELM9]
fld qword [eax+DOTP1]
fmul st0,st3
fadd qword [ecx+ELM7]
fxch st0,st3
fld qword [eax+DOTP5]
rep
fmul st0,st1
fadd qword [ecx+ELM11]
fld qword [eax+DOTP6]
fmul st0,st2
fadd qword [ecx+ELM12]
fld qword [ebx+ELM2]
fld qword [eax+DOTP4]
fmulp st4,st0
fld qword [ecx+ELM10]
rep
faddp st4,st0
add eax,byte 15*8
mov edx,edx
OPERATION 2,3 ;02+2
OPERATION 3,4 ;03+2
OPERATION 4,5 ;04+2
OPERATION 5,6 ;05+2
OPERATION 6,7 ;06+2
OPERATION 7,8 ;07+2
OPERATION 8,9 ;08+2
OPERATION 9,10 ;09+2
OPERATION 10,11 ;10+2
OPERATION 11,12 ;11+2
OPERATION 12,13 ;12+2
OPERATION 13,14 ;13+2
OPERATION 14,15 ;14+2
OPERATION 15,16 ;15+2
OPERATION 16,17 ;16+2
OPERATION 17,18 ;17+2
OPERATION 18,19 ;18+2
OPERATION 19,20 ;19+2
OPERATION 20,21 ;20+2
OPERATION 21,22 ;21+2
OPERATION 22,23 ;22+2
OPERATION 23,24 ;23+2
OPERATION 24,25 ;24+2
OPERATION 25,26 ;25+2
OPERATION 26,27 ;26+2
OPERATION 27,28 ;27+2
OPERATION 28,29 ;28+2
OPERATION 29,30 ;29+2
fld qword [eax+DOTP1+ELM30] ;30+2
fmul st0,st1
faddp st7
fld qword [eax+DOTP2+ELM30]
fmul st0,st1
faddp st6
fld qword [eax+DOTP3+ELM30]
fmul st0,st1
faddp st5
fld qword [eax+DOTP4+ELM30]
fmul st0,st1
faddp st4
fld qword [eax+DOTP5+ELM30]
fmul st0,st1
faddp st3
rep
fmul qword [eax+DOTP6+ELM30]
faddp st1
fxch st5
%ifdef PREC_DST3
mov [esp+20],ecx
add ecx,[esp+12]
prefetchw [ecx-2*64]
prefetchw [ecx-1*64]
prefetchw [ecx+0*64]
prefetchw [ecx+1*64]
nop
prefetchw [ecx+2*64-1]
mov ecx,[esp+20]
%endif
%ifdef PREB_DST3
prefetch [ebx+30*8-2*64]
fnop
mov edx,edx
prefetch [ebx+30*8-1*64]
nop
prefetch [ebx+30*8+0*64]
nop
prefetch [ebx+30*8+1*64]
nop
prefetch [ebx+30*8+2*64]
nop
%endif
fstp qword [ecx+ELM7]
fxch st3
fstp qword [ecx+ELM8]
fxch st1
fstp qword [ecx+ELM9]
fstp qword [ecx+ELM10]
fstp qword [ecx+ELM11]
fstp qword [ecx+ELM12]
add eax,edx
fld qword [ebx+ELM1] ;01+3
fld qword [eax+DOTP2]
fmul st0,st1
fadd qword [ecx+ELM14]
fld qword [eax+DOTP3]
fmul st0,st2
fadd qword [ecx+ELM15]
fld qword [eax+DOTP1]
fmul st0,st3
fadd qword [ecx+ELM13]
fxch st0,st3
fld qword [eax+DOTP5]
rep
fmul st0,st1
fadd qword [ecx+ELM17]
fld qword [eax+DOTP6]
fmul st0,st2
fadd qword [ecx+ELM18]
fld qword [ebx+ELM2]
rep
fld qword [eax+DOTP4]
fmulp st4,st0
fld qword [ecx+ELM16]
rep
faddp st4,st0
add eax,byte 15*8
mov edx,edx
OPERATION 2,3 ;02+3
OPERATION 3,4 ;03+3
OPERATION 4,5 ;04+3
OPERATION 5,6 ;05+3
OPERATION 6,7 ;06+3
OPERATION 7,8 ;07+3
OPERATION 8,9 ;08+3
OPERATION 9,10 ;09+3
OPERATION 10,11 ;10+3
OPERATION 11,12 ;11+3
OPERATION 12,13 ;12+3
OPERATION 13,14 ;13+3
OPERATION 14,15 ;14+3
OPERATION 15,16 ;15+3
OPERATION 16,17 ;16+3
OPERATION 17,18 ;17+3
OPERATION 18,19 ;18+3
OPERATION 19,20 ;19+3
OPERATION 20,21 ;20+3
OPERATION 21,22 ;21+3
OPERATION 22,23 ;22+3
OPERATION 23,24 ;23+3
OPERATION 24,25 ;24+3
OPERATION 25,26 ;25+3
OPERATION 26,27 ;26+3
OPERATION 27,28 ;27+3
OPERATION 28,29 ;28+3
OPERATION 29,30 ;29+3
fld qword [eax+DOTP1+ELM30] ;30+3
fmul st0,st1
faddp st7
fld qword [eax+DOTP2+ELM30]
fmul st0,st1
faddp st6
fld qword [eax+DOTP3+ELM30]
fmul st0,st1
faddp st5
fld qword [eax+DOTP4+ELM30]
fmul st0,st1
faddp st4
fld qword [eax+DOTP5+ELM30]
fmul st0,st1
faddp st3
rep
fmul qword [eax+DOTP6+ELM30]
faddp st1
fxch st5
%ifdef PREC_DST2
mov [esp+20],ecx
add ecx,[esp+12]
prefetchw [ecx-2*64]
prefetchw [ecx-1*64]
prefetchw [ecx+0*64]
prefetchw [ecx+1*64]
nop
prefetchw [ecx+2*64-1]
mov ecx,[esp+20]
%endif
%ifdef PREB_DST2
prefetch [ebx+30*8-2*64]
fnop
mov edx,edx
prefetch [ebx+30*8-1*64]
nop
prefetch [ebx+30*8+0*64]
nop
prefetch [ebx+30*8+1*64]
nop
prefetch [ebx+30*8+2*64]
nop
%endif
fstp qword [ecx+ELM13]
fxch st3
fstp qword [ecx+ELM14]
rep
fxch st1
fstp qword [ecx+ELM15]
fstp qword [ecx+ELM16]
fstp qword [ecx+ELM17]
fstp qword [ecx+ELM18]
add eax,edx
fld qword [ebx+ELM1] ;01+4
fld qword [eax+DOTP2]
fmul st0,st1
fadd qword [ecx+ELM20]
fld qword [eax+DOTP3]
fmul st0,st2
fadd qword [ecx+ELM21]
fld qword [eax+DOTP1]
fmul st0,st3
fadd qword [ecx+ELM19]
fxch st0,st3
fld qword [eax+DOTP5]
rep
fmul st0,st1
fadd qword [ecx+ELM23]
fld qword [eax+DOTP6]
fmul st0,st2
fadd qword [ecx+ELM24]
fld qword [ebx+ELM2]
fld qword [eax+DOTP4]
fmulp st4,st0
fld qword [ecx+ELM22]
rep
faddp st4,st0
add eax,byte 15*8
mov edx,edx
OPERATION 2,3 ;02+4
OPERATION 3,4 ;03+4
OPERATION 4,5 ;04+4
OPERATION 5,6 ;05+4
OPERATION 6,7 ;06+4
OPERATION 7,8 ;07+4
OPERATION 8,9 ;08+4
OPERATION 9,10 ;09+4
OPERATION 10,11 ;10+4
OPERATION 11,12 ;11+4
OPERATION 12,13 ;12+4
OPERATION 13,14 ;13+4
OPERATION 14,15 ;14+4
OPERATION 15,16 ;15+4
OPERATION 16,17 ;16+4
OPERATION 17,18 ;17+4
OPERATION 18,19 ;18+4
OPERATION 19,20 ;19+4
OPERATION 20,21 ;20+4
OPERATION 21,22 ;21+4
OPERATION 22,23 ;22+4
OPERATION 23,24 ;23+4
OPERATION 24,25 ;24+4
OPERATION 25,26 ;25+4
OPERATION 26,27 ;26+4
OPERATION 27,28 ;27+4
OPERATION 28,29 ;28+4
OPERATION 29,30 ;29+4
fld qword [eax+DOTP1+ELM30] ;30+4
fmul st0,st1
faddp st7
fld qword [eax+DOTP2+ELM30]
fmul st0,st1
faddp st6
fld qword [eax+DOTP3+ELM30]
fmul st0,st1
faddp st5
fld qword [eax+DOTP4+ELM30]
fmul st0,st1
faddp st4
fld qword [eax+DOTP5+ELM30]
fmul st0,st1
faddp st3
rep
fmul qword [eax+DOTP6+ELM30]
faddp st1
fxch st5
%ifdef PREC_DST1
mov [esp+20],ecx
add ecx,[esp+12]
prefetchw [ecx-2*64]
prefetchw [ecx-1*64]
prefetchw [ecx+0*64]
prefetchw [ecx+1*64]
nop
prefetchw [ecx+2*64-1]
mov ecx,[esp+20]
%endif
%ifdef PREB_DST1
prefetch [ebx+30*8-2*64]
fnop
mov edx,edx
prefetch [ebx+30*8-1*64]
nop
prefetch [ebx+30*8+0*64]
nop
prefetch [ebx+30*8+1*64]
nop
prefetch [ebx+30*8+2*64]
nop
%endif
fstp qword [ecx+ELM19]
fxch st3
fstp qword [ecx+ELM20]
fxch st1
fstp qword [ecx+ELM21]
fstp qword [ecx+ELM22]
fstp qword [ecx+ELM23]
fstp qword [ecx+ELM24]
add eax,edx
fld qword [ebx+ELM1] ;01+5
fld qword [eax+DOTP2]
fmul st0,st1
fadd qword [ecx+ELM26]
fld qword [eax+DOTP3]
fmul st0,st2
fadd qword [ecx+ELM27]
fld qword [eax+DOTP1]
fmul st0,st3
fadd qword [ecx+ELM25]
fxch st0,st3
fld qword [eax+DOTP5]
rep
fmul st0,st1
fadd qword [ecx+ELM29]
fld qword [eax+DOTP6]
fmul st0,st2
fadd qword [ecx+ELM30]
fld qword [ebx+ELM2]
fld qword [eax+DOTP4]
fmulp st4,st0
fld qword [ecx+ELM28]
rep
faddp st4,st0
add eax,byte 15*8
mov edx,edx
OPERATION 2,3 ;02+5
OPERATION 3,4 ;03+5
OPERATION 4,5 ;04+5
OPERATION 5,6 ;05+5
OPERATION 6,7 ;06+5
OPERATION 7,8 ;07+5
OPERATION 8,9 ;08+5
OPERATION 9,10 ;09+5
OPERATION 10,11 ;10+5
OPERATION 11,12 ;11+5
OPERATION 12,13 ;12+5
OPERATION 13,14 ;13+5
OPERATION 14,15 ;14+5
OPERATION 15,16 ;15+5
OPERATION 16,17 ;16+5
OPERATION 17,18 ;17+5
OPERATION 18,19 ;18+5
OPERATION 19,20 ;19+5
OPERATION 20,21 ;20+5
OPERATION 21,22 ;21+5
OPERATION 22,23 ;22+5
OPERATION 23,24 ;23+5
OPERATION 24,25 ;24+5
OPERATION 25,26 ;25+5
OPERATION 26,27 ;26+5
OPERATION 27,28 ;27+5
OPERATION 28,29 ;28+5
OPERATION 29,30 ;29+5
fld qword [eax+DOTP1+ELM30] ;30+5
fmul st0,st1
faddp st7
fld qword [eax+DOTP2+ELM30]
fmul st0,st1
faddp st6
fld qword [eax+DOTP3+ELM30]
fmul st0,st1
faddp st5
fld qword [eax+DOTP4+ELM30]
fmul st0,st1
faddp st4
fld qword [eax+DOTP5+ELM30]
fmul st0,st1
faddp st3
rep
fmul qword [eax+DOTP6+ELM30]
faddp st1
fxch st5
%ifdef PREA_EN
mov [esp+20],edx ;save edx in t1
mov edx,[esp+16] ;&A+1->edx
lea edx,[edx+ebx]
prefetch [edx-2*64]
nop
prefetch [edx-1*64]
prefetch [edx+0*64]
nop
prefetch [edx+1*64]
prefetch [edx+2*64-8]
mov edx,[esp+20] ;restore edx
mov eax,eax
fnop
%endif
fstp qword [ecx+ELM25]
fxch st3
fstp qword [ecx+ELM26]
fxch st1
fstp qword [ecx+ELM27]
fstp qword [ecx+ELM28]
fstp qword [ecx+ELM29]
fstp qword [ecx+ELM30]
sub ebx,edi ;next column of B
mov eax,[esp+4] ;reset eax
add ecx,[esp+12] ;next column of C (+ldc*8)
dec dword [esp+8] ;dec counter
jnz near loopj_
end_
femms
pop ebp
add esp,byte 5*4 ;remove local variables
pop edi ;restore registers
pop esi
pop ebx
leave ;mov esp,ebp / pop ebp
ret
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48.log_21829_1155.asm | ljhsiun2/medusa | 9 | 26871 | .global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r8
push %rax
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x6e33, %rcx
nop
nop
sub %r8, %r8
mov (%rcx), %r13w
nop
nop
nop
add $45731, %rdx
lea addresses_WC_ht+0x194b, %rsi
lea addresses_normal_ht+0x11e33, %rdi
nop
nop
nop
nop
sub %rax, %rax
mov $103, %rcx
rep movsl
nop
nop
xor $12298, %rax
lea addresses_WT_ht+0x13b33, %r8
nop
inc %rdx
mov (%r8), %esi
nop
nop
nop
add %rdi, %rdi
lea addresses_normal_ht+0x1e173, %rsi
lea addresses_normal_ht+0x188f3, %rdi
clflush (%rsi)
nop
nop
nop
add $38510, %rdx
mov $114, %rcx
rep movsb
nop
nop
nop
cmp %r13, %r13
lea addresses_D_ht+0x18484, %r13
nop
nop
nop
inc %rsi
mov (%r13), %rdi
cmp $9196, %r8
lea addresses_WT_ht+0x6833, %rcx
cmp %rsi, %rsi
movw $0x6162, (%rcx)
nop
nop
nop
nop
dec %rax
lea addresses_A_ht+0x9333, %r8
nop
nop
nop
xor $65171, %rsi
mov $0x6162636465666768, %rdx
movq %rdx, (%r8)
nop
nop
nop
nop
xor %rcx, %rcx
lea addresses_normal_ht+0xc233, %rsi
nop
nop
xor $18143, %r8
movl $0x61626364, (%rsi)
add $53566, %r8
lea addresses_A_ht+0x96f3, %r13
lfence
vmovups (%r13), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $0, %xmm0, %rcx
nop
nop
nop
nop
inc %rsi
lea addresses_UC_ht+0x1e1f3, %rdx
nop
nop
lfence
movw $0x6162, (%rdx)
nop
nop
nop
nop
add $30970, %rax
lea addresses_WC_ht+0x7143, %rsi
lea addresses_WT_ht+0xba33, %rdi
nop
nop
add $57546, %rbp
mov $107, %rcx
rep movsw
nop
nop
nop
nop
inc %rcx
lea addresses_UC_ht+0xfe33, %r8
nop
inc %rdx
mov (%r8), %ax
nop
nop
cmp %r13, %r13
lea addresses_UC_ht+0x161df, %r13
nop
nop
nop
sub $32490, %rdx
mov $0x6162636465666768, %rsi
movq %rsi, %xmm2
movups %xmm2, (%r13)
nop
nop
nop
sub %rcx, %rcx
lea addresses_WT_ht+0xd633, %rsi
lea addresses_WT_ht+0xc6af, %rdi
sub %r8, %r8
mov $2, %rcx
rep movsl
nop
nop
and %r8, %r8
lea addresses_D_ht+0x4d6c, %r8
nop
nop
sub %rax, %rax
mov $0x6162636465666768, %r13
movq %r13, (%r8)
cmp %rbp, %rbp
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r8
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r14
push %r8
push %rbp
push %rcx
push %rdi
push %rsi
// Store
lea addresses_WC+0xb933, %rdi
nop
nop
sub $54556, %rbp
movb $0x51, (%rdi)
nop
nop
nop
nop
nop
cmp %r8, %r8
// Faulty Load
lea addresses_RW+0x18e33, %rbp
inc %rcx
mov (%rbp), %si
lea oracles, %r10
and $0xff, %rsi
shlq $12, %rsi
mov (%r10,%rsi,1), %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r14
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 8, 'size': 1, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 11, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 6, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 9, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 8, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 7, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 6, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 6, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 11, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 2, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
oeis/321/A321483.asm | neoneye/loda-programs | 11 | 25497 | <reponame>neoneye/loda-programs<gh_stars>10-100
; A321483: a(n) = 7*2^n + (-1)^n.
; Submitted by <NAME>(s4)
; 8,13,29,55,113,223,449,895,1793,3583,7169,14335,28673,57343,114689,229375,458753,917503,1835009,3670015,7340033,14680063,29360129,58720255,117440513,234881023,469762049,939524095,1879048193,3758096383,7516192769,15032385535,30064771073,60129542143,120259084289,240518168575,481036337153,962072674303,1924145348609,3848290697215,7696581394433,15393162788863,30786325577729,61572651155455,123145302310913,246290604621823,492581209243649,985162418487295,1970324836974593,3940649673949183
mov $1,2
pow $1,$0
mod $0,2
mul $0,2
mul $1,7
add $1,1
sub $1,$0
mov $0,$1
|
oeis/089/A089581.asm | neoneye/loda-programs | 11 | 160968 | ; A089581: a(n) = prime(2*n-1)*prime(2*n).
; 6,35,143,323,667,1147,1763,2491,3599,4757,5767,7387,9797,11021,12317,16637,19043,22499,25591,28891,32399,36863,39203,47053,51983,55687,60491,67591,72899,77837,82919,95477,99221,111547,121103,126727,136891,145157,154433,164009,176399,186623,194477,205193,213443,223693,239117,250997,265189,282943,304679,320347,329467,348091,359999,372091,381923,404471,416021,430327,444853,462391,484391,509771,532891,549077,568507,585209,608351,644773,665831,680621,695531,731021,741317,772637,783221,826277,853751
mul $0,2
seq $0,6094 ; Products of 2 successive primes.
|
Numeral/Natural/Oper/Comparisons.agda | Lolirofle/stuff-in-agda | 6 | 9924 | <gh_stars>1-10
module Numeral.Natural.Oper.Comparisons where
import Lvl
open import Data.Boolean
import Data.Boolean.Operators
open Data.Boolean.Operators.Programming
open import Numeral.Natural
open import Numeral.Sign
ℕbool : Bool → ℕ
ℕbool = if_then 1 else 0
-- Compare
_⋚?_ : ℕ → ℕ → (−|0|+)
𝟎 ⋚? 𝟎 = 𝟎
𝟎 ⋚? 𝐒(b) = ➖
𝐒(a) ⋚? 𝟎 = ➕
𝐒(a) ⋚? 𝐒(b) = a ⋚? b
-- Equality check
_≡?_ : ℕ → ℕ → Bool
a ≡? b = elim₃ 𝐹 𝑇 𝐹 (a ⋚? b)
{-# BUILTIN NATEQUALS _≡?_ #-}
-- Non-equality check
_≢?_ : ℕ → ℕ → Bool
x ≢? y = !(x ≡? y)
-- Positivity check
positive? : ℕ → Bool
positive? (𝟎) = 𝐹
positive? (𝐒(_)) = 𝑇
-- Zero check
zero? : ℕ → Bool
zero? n = !(positive? n)
-- Lesser-than check
_<?_ : ℕ → ℕ → Bool
_ <? 𝟎 = 𝐹
𝟎 <? 𝐒(_) = 𝑇
𝐒(x) <? 𝐒(y) = (x <? y)
{-# BUILTIN NATLESS _<?_ #-}
-- Lesser-than or equals check
_≤?_ : ℕ → ℕ → Bool
x ≤? y = x <? 𝐒(y)
-- Greater-than check
_>?_ : ℕ → ℕ → Bool
x >? y = y <? x
-- Greater-than or equals check
_≥?_ : ℕ → ℕ → Bool
x ≥? y = y ≤? x
|
Ada/inc/Problem_64.ads | Tim-Tom/project-euler | 0 | 3303 | <filename>Ada/inc/Problem_64.ads
package Problem_64 is
procedure Solve;
end Problem_64;
|
src/kernel/x86_64/userspace_test.asm | nothotscott/VisualOS | 28 | 93672 | <gh_stars>10-100
SECTION .text
ALIGN 4096
GLOBAL test_userspace
test_userspace:
; Stack test
push 0x80
push 0x123
pop rax
pop rax
cmp rax, 0x80
jne 0x0
; Text output syscall test
mov rax, 1
mov rdi, 1
mov rsi, test_userspace_data1
mov rdx, 17
syscall
jmp $
; Exit syscall test
mov rax, 60
mov rdi, 0
syscall
jmp $
GLOBAL test_userspace2
test_userspace2:
; Stack test
push 0x80
push 0x123
pop rax
pop rax
cmp rax, 0x80
jne 0x0
; Text output syscall test
mov rax, 1
mov rdi, 1
mov rsi, test_userspace_data2
mov rdx, 18
syscall
jmp $
; Exit syscall test
mov rax, 60
mov rdi, 0
syscall
test_userspace_data1: db "Hello, userspace", 10,0
test_userspace_data2: db "Hello, userspace2", 10,0 |
oeis/229/A229968.asm | neoneye/loda-programs | 11 | 15559 | ; A229968: Numbers not divisible by 3 or 11.
; Submitted by <NAME>
; 1,2,4,5,7,8,10,13,14,16,17,19,20,23,25,26,28,29,31,32,34,35,37,38,40,41,43,46,47,49,50,52,53,56,58,59,61,62,64,65,67,68,70,71,73,74,76,79,80,82,83,85,86,89,91,92,94,95,97,98,100,101,103,104,106,107,109,112,113,115,116,118,119,122,124,125,127,128,130,131,133,134,136,137,139,140,142,145,146,148,149,151,152,155,157,158,160,161,163,164
mov $2,1
lpb $0
lpb $3
add $2,1
mov $4,$1
gcd $4,$2
cmp $4,1
cmp $4,0
sub $3,$4
lpe
sub $0,1
mov $1,33
add $2,1
add $3,22
lpe
mov $0,$2
|
libsrc/_DEVELOPMENT/adt/b_vector/c/sdcc_iy/b_vector_erase.asm | jpoikela/z88dk | 640 | 90548 | <filename>libsrc/_DEVELOPMENT/adt/b_vector/c/sdcc_iy/b_vector_erase.asm
; size_t b_vector_erase(b_vector_t *v, size_t idx)
SECTION code_clib
SECTION code_adt_b_vector
PUBLIC _b_vector_erase
EXTERN _b_array_erase
defc _b_vector_erase = _b_array_erase
|
test/python/isolationtest/parser/specParser.g4 | faizol/babelfish_extensions | 115 | 39 | parser grammar specParser;
options {tokenVocab=specLexer;}
parse: testspec EOF;
testspec : setup* teardown? session+ permutation*;
setup: SETUP SQLBLOCK;
teardown: TEARDOWN SQLBLOCK;
session: SESSION ID setup? step+ teardown?;
step: STEP ID SQLBLOCK;
pstep: ID (OPEN_BRKT blockers CLOSE_BRKT)?;
blockers: (AST | ID) (COMMA (AST | ID))*;
permutation: PERMUTATION pstep+;
|
alloy4fun_models/trashltl/models/9/dRzjErqvbqP34t65a.als | Kaixi26/org.alloytools.alloy | 0 | 4518 | open main
pred iddRzjErqvbqP34t65a_prop10 {
always all f:File | f in Protected implies f in Protected
}
pred __repair { iddRzjErqvbqP34t65a_prop10 }
check __repair { iddRzjErqvbqP34t65a_prop10 <=> prop10o } |
Final Assignment CSE331/Solution/2.asm | afra-tech/CSE331L-Section-1-Fall20-NSU | 0 | 171819 | <reponame>afra-tech/CSE331L-Section-1-Fall20-NSU
.MODEL SMALL
.STACK 100H
OUTPUT MACRO MSG
LEA DX,MSG
MOV AH,9
INT 21H
ENDM
INPUT MACRO
MOV AH,1
INT 21H
ENDM
.DATA
STRING DB "abcdefghijklmnopqrstuvwxyz$"
NLINE DB 13,10,"$"
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
LEA SI, STRING
MOV CX, 25
ADD SI,CX
OUTPUT NLINE
@PRINT:
MOV AH,2
MOV DL,[SI]
INT 21H
DEC SI
loop @PRINT
@EXIT:
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN
|
Transynther/x86/_processed/US/_zr_/i9-9900K_12_0xa0_notsx.log_21829_1196.asm | ljhsiun2/medusa | 9 | 15377 | <filename>Transynther/x86/_processed/US/_zr_/i9-9900K_12_0xa0_notsx.log_21829_1196.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %rax
push %rcx
lea addresses_UC_ht+0x1e23c, %r14
nop
nop
nop
nop
inc %rcx
mov (%r14), %ax
nop
nop
nop
nop
nop
xor $43093, %rcx
pop %rcx
pop %rax
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r9
push %rax
push %rbp
push %rbx
push %rcx
// Store
lea addresses_PSE+0xdd2c, %rcx
nop
nop
nop
nop
xor $51311, %r9
movb $0x51, (%rcx)
nop
nop
nop
nop
nop
cmp $49467, %rbp
// Load
lea addresses_UC+0xe3c, %r9
nop
nop
nop
nop
sub $62459, %r14
movups (%r9), %xmm5
vpextrq $0, %xmm5, %rbx
nop
xor %rbp, %rbp
// Load
lea addresses_PSE+0xee11, %r14
nop
nop
cmp %r9, %r9
movb (%r14), %r12b
nop
nop
nop
nop
and $6465, %r12
// Store
lea addresses_normal+0x1d26c, %r12
nop
nop
nop
sub $7367, %rcx
movb $0x51, (%r12)
nop
nop
nop
nop
nop
add $23393, %rbp
// Load
lea addresses_RW+0x1dd8c, %rbp
nop
nop
nop
nop
cmp %r9, %r9
movups (%rbp), %xmm1
vpextrq $1, %xmm1, %rbx
nop
and $5140, %rbx
// Store
lea addresses_D+0x190bb, %r14
nop
nop
add %rcx, %rcx
movw $0x5152, (%r14)
nop
cmp %rcx, %rcx
// Store
lea addresses_RW+0x179b0, %rax
nop
nop
nop
nop
nop
mfence
movb $0x51, (%rax)
nop
nop
inc %rax
// Faulty Load
lea addresses_US+0x1da3c, %r12
nop
nop
nop
nop
nop
dec %rbx
movb (%r12), %r9b
lea oracles, %rcx
and $0xff, %r9
shlq $12, %r9
mov (%rcx,%r9,1), %r9
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r9
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_US', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 4}}
{'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 7}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'size': 1, 'NT': True, 'same': False, 'congruent': 4}}
{'src': {'type': 'addresses_RW', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 4}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'size': 2, 'NT': False, 'same': True, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 1}}
[Faulty Load]
{'src': {'type': 'addresses_US', 'AVXalign': False, 'size': 1, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': True, 'congruent': 10}, 'OP': 'LOAD'}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
Scripts/AppleScript/Start One Hour Timer.applescript | ghartnett/MenubarCountdown | 75 | 1087 | -- Start a one hour timer
tell application "Menubar Countdown"
set hours to 1
set minutes to 0
set seconds to 0
start timer
end tell
|
source/textio/a-teioed.ads | ytomino/drake | 33 | 15030 | <reponame>ytomino/drake<gh_stars>10-100
pragma License (Unrestricted);
package Ada.Text_IO.Editing is
type Picture is private;
function Valid (
Pic_String : String;
Blank_When_Zero : Boolean := False)
return Boolean;
function To_Picture (
Pic_String : String;
Blank_When_Zero : Boolean := False)
return Picture;
function Pic_String (Pic : Picture) return String;
function Blank_When_Zero (Pic : Picture) return Boolean;
pragma Inline (Blank_When_Zero);
Max_Picture_Length : constant := 30; -- implementation_defined
Picture_Error : exception;
Default_Currency : constant String := "$";
Default_Fill : constant Character := '*';
Default_Separator : constant Character := ',';
Default_Radix_Mark : constant Character := '.';
generic
type Num is delta <> digits <>;
Default_Currency : String := Editing.Default_Currency;
Default_Fill : Character := Editing.Default_Fill;
Default_Separator : Character := Editing.Default_Separator;
Default_Radix_Mark : Character := Editing.Default_Radix_Mark;
package Decimal_Output is
-- extended
function Overloaded_Length (Pic : Picture; Currency : String)
return Natural;
function Overloaded_Length (Pic : Picture; Currency : Wide_String)
return Natural;
function Overloaded_Length (Pic : Picture; Currency : Wide_Wide_String)
return Natural;
function Length (Pic : Picture; Currency : String := Default_Currency)
return Natural
renames Overloaded_Length;
-- extended
function Overloaded_Valid (
Item : Num;
Pic : Picture;
Currency : String)
return Boolean;
function Overloaded_Valid (
Item : Num;
Pic : Picture;
Currency : Wide_String)
return Boolean;
function Overloaded_Valid (
Item : Num;
Pic : Picture;
Currency : Wide_Wide_String)
return Boolean;
function Valid (
Item : Num;
Pic : Picture;
Currency : String := Default_Currency)
return Boolean
renames Overloaded_Valid;
-- extended
function Overloaded_Image (
Item : Num;
Pic : Picture;
Currency : String;
Fill : Character;
Separator : Character;
Radix_Mark : Character)
return String;
function Overloaded_Image (
Item : Num;
Pic : Picture;
Currency : Wide_String;
Fill : Wide_Character;
Separator : Wide_Character;
Radix_Mark : Wide_Character)
return Wide_String;
function Overloaded_Image (
Item : Num;
Pic : Picture;
Currency : Wide_Wide_String;
Fill : Wide_Wide_Character;
Separator : Wide_Wide_Character;
Radix_Mark : Wide_Wide_Character)
return Wide_Wide_String;
function Image (
Item : Num;
Pic : Picture;
Currency : String := Default_Currency;
Fill : Character := Default_Fill;
Separator : Character := Default_Separator;
Radix_Mark : Character := Default_Radix_Mark)
return String
renames Overloaded_Image;
-- extended
procedure Overloaded_Put (
File : File_Type; -- Output_File_Type
Item : Num;
Pic : Picture;
Currency : String;
Fill : Character;
Separator : Character;
Radix_Mark : Character);
procedure Overloaded_Put (
File : File_Type; -- Output_File_Type
Item : Num;
Pic : Picture;
Currency : Wide_String;
Fill : Wide_Character;
Separator : Wide_Character;
Radix_Mark : Wide_Character);
procedure Overloaded_Put (
File : File_Type; -- Output_File_Type
Item : Num;
Pic : Picture;
Currency : Wide_Wide_String;
Fill : Wide_Wide_Character;
Separator : Wide_Wide_Character;
Radix_Mark : Wide_Wide_Character);
procedure Put (
File : File_Type; -- Output_File_Type
Item : Num;
Pic : Picture;
Currency : String := Default_Currency;
Fill : Character := Default_Fill;
Separator : Character := Default_Separator;
Radix_Mark : Character := Default_Radix_Mark)
renames Overloaded_Put;
-- extended
procedure Overloaded_Put (
Item : Num;
Pic : Picture;
Currency : String;
Fill : Character;
Separator : Character;
Radix_Mark : Character);
procedure Overloaded_Put (
Item : Num;
Pic : Picture;
Currency : Wide_String;
Fill : Wide_Character;
Separator : Wide_Character;
Radix_Mark : Wide_Character);
procedure Overloaded_Put (
Item : Num;
Pic : Picture;
Currency : Wide_Wide_String;
Fill : Wide_Wide_Character;
Separator : Wide_Wide_Character;
Radix_Mark : Wide_Wide_Character);
procedure Put (
Item : Num;
Pic : Picture;
Currency : String := Default_Currency;
Fill : Character := Default_Fill;
Separator : Character := Default_Separator;
Radix_Mark : Character := Default_Radix_Mark)
renames Overloaded_Put;
-- extended
procedure Overloaded_Put (
To : out String;
Item : Num;
Pic : Picture;
Currency : String;
Fill : Character;
Separator : Character;
Radix_Mark : Character);
procedure Overloaded_Put (
To : out Wide_String;
Item : Num;
Pic : Picture;
Currency : Wide_String;
Fill : Wide_Character;
Separator : Wide_Character;
Radix_Mark : Wide_Character);
procedure Overloaded_Put (
To : out Wide_Wide_String;
Item : Num;
Pic : Picture;
Currency : Wide_Wide_String;
Fill : Wide_Wide_Character;
Separator : Wide_Wide_Character;
Radix_Mark : Wide_Wide_Character);
procedure Put (
To : out String;
Item : Num;
Pic : Picture;
Currency : String := Default_Currency;
Fill : Character := Default_Fill;
Separator : Character := Default_Separator;
Radix_Mark : Character := Default_Radix_Mark)
renames Overloaded_Put;
end Decimal_Output;
private
type Dollar_Position is (None, Previous);
pragma Discard_Names (Dollar_Position);
type Picture is record
Expanded : String (1 .. Max_Picture_Length);
Length : Natural;
Has_V : Boolean; -- zero width
Has_Dollar : Dollar_Position; -- replaced to Currency
Blank_When_Zero : Boolean;
Real_Blank_When_Zero : Boolean;
First_Sign_Position : Natural;
Radix_Position : Positive;
Aft : Natural;
end record;
end Ada.Text_IO.Editing;
|
adamova.asm | hajzer/asm-basic-examples | 0 | 3618 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Nacitajte z klavesnice retazec znakov ukonceny znakom "noveho
; riadku".Nech slovo je postupnost znakov medzi dvoma
; znakmi"medzera".Urcte pocet slov, v ktorych sucet ASCII kodov
; znakov je vacsi ako 100.Pocet vytlacte desiatkovo.
;
; Autor: LALA -> lala (at) linuxor (dot) sk
; Datum: 20.1.2003
;
; Subor: adamova.asm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.model small
.stack 100
.data
sucet dw 0
pocet dw 0
vypis db "Pocet slov ktorych sucet ASCII kodov je vacsi ako 100 je:$"
.code
jmp Start ; skok na Start
; Procedura umoznuje vypis cisel v nasle-
; dovnych ciselnych sustavach 2,8,10,16.
;
; Vstup: register AX = cislo
; register BX = zaklad sustavy
;
; Vystup: cez INT 21h na obrazovku
premen proc near
push ax
xor cx, cx
wn0:
xor dx, dx
div bx
push dx
inc cx
test ax, ax
jnz wn0
wn2:
pop dx
or dl, '0'
cmp dl, '9'
jbe wn3
add dl, 7
wn3:
mov ah, 2
int 21h
loop wn2
pop ax
ret
premen endp
Start:
mov ax,@data ; zistime kde su data
mov ds,ax ; a ulozime si ich do segmentoveho registra
citaj:
mov ah,1 ; sluzba nacita a zaroven vypise znak
int 21h ; volanie prerusenia
cmp al,' ' ; nacitany znak porovname zo znakom medzera
je space ; ak sa zhoduje skok na navestie space
cmp al,13 ; nacitany znak porovname zo znakom "novy riadok"
je last ; ak sa zhoduje skok na navestie last
mov ah,0 ; do subregistra ah dame 0
add sucet,ax ; pripocitame ASCII hodnotu znaku k celkovemu suctu slova
jmp citaj ; skok na citaj
space:
cmp sucet,100 ; porovnaj sucet ASCII kodov slova a 100
jg pripocitaj ; ak sucet je vacsi tak skok na _pripocitaj
mov sucet,0 ; vynuluj sucet
jmp citaj ; skok na _citaj_znak
last:
cmp sucet,100 ; porovnaj sucet ASCII kodov slova a 100
jg pripocitaj_last ; ak sucet je vacsi tak skok na _pripocitaj_EOF
jmp vypis_text ; skok na vypis_text
pripocitaj:
inc pocet ; zvys pocet o 1
mov sucet,0 ; vynuluj sucet
jmp citaj ; skok
pripocitaj_last:
inc pocet ; zvys pocet o 1
vypis_text: ; vypise hlasku
mov dx,OFFSET vypis ; do registra dx dame offset retazca ktory chceme vypisat
mov ah,09h ; sluzba 09 = vypis retazca na STDOUT
int 21h ; volanie prerusenia
mov ax,pocet ; vypise pocet slov, ktorych sucet ASCII ...
mov bx,10 ; vypise to desiatkovo
call premen ; pouziva sa pri tom procedura premen
koniec:
mov ax,4c00h ; exit do DOS-u
int 21h ; volanie prerusenia
end Start
|
programs/oeis/155/A155095.asm | neoneye/loda | 22 | 101709 | ; A155095: Numbers k such that k^2 == -1 (mod 17).
; 4,13,21,30,38,47,55,64,72,81,89,98,106,115,123,132,140,149,157,166,174,183,191,200,208,217,225,234,242,251,259,268,276,285,293,302,310,319,327,336,344,353,361,370,378,387,395,404,412,421,429,438,446,455,463,472,480,489,497,506,514,523,531,540,548,557,565,574,582,591,599,608,616,625,633,642,650,659,667,676,684,693,701,710,718,727,735,744,752,761,769,778,786,795,803,812,820,829,837,846
mul $0,17
add $0,9
div $0,2
|
programs/oeis/251/A251758.asm | karttu/loda | 1 | 164020 | ; A251758: Let n>=2 be a positive integer with divisors 1 = d_1 < d_2 < ... < d_k = n, and s = d_1*d_2 + d_2*d_3 + ... + d_(k-1)*d_k. The sequence lists the values a(n) = floor(n^2/s).
; 2,3,1,5,1,7,1,2,1,11,1,13,1,2,1,17,1,19,1,2,1,23,1,4,1,2,1,29,1,31,1,2,1,4,1,37,1,2,1,41,1,43,1,2,1,47,1,6,1,2,1,53,1,4,1,2,1,59,1,61,1,2,1,4,1,67,1,2,1,71,1,73,1,2,1,6,1,79,1,2,1,83,1,4,1,2,1,89,1,6,1,2,1,4,1,97,1,2,1,101,1,103,1,2,1,107,1,109,1,2,1,113,1,4,1,2,1,6,1,10,1,2,1,4,1,127,1,2,1,131,1,6,1,2,1,137,1,139,1,2,1,10,1,4,1,2,1,149,1,151,1,2,1,4,1,157,1,2,1,6,1,163,1,2,1,167,1,12,1,2,1,173,1,4,1,2,1,179,1,181,1,2,1,4,1,10,1,2,1,191,1,193,1,2,1,197,1,199,1,2,1,6,1,4,1,2,1,10,1,211,1,2,1,4,1,6,1,2,1,12,1,223,1,2,1,227,1,229,1,2,1,233,1,4,1,2,1,239,1,241,1,2,1,4,1,12,1,2,1,251
mov $3,$0
cal $0,46667 ; a(n) = A046666(n)/2.
mul $0,2
mov $2,-2
mul $2,$0
trn $0,1
add $2,1
add $0,$2
mov $1,$0
add $1,1
add $1,$3
|
45/runtime/rt/rtseg.asm | minblock/msdos | 0 | 160616 | TITLE RTSEG - Segment ordering for the BASIC runtime
;***
;RTSEG.ASM - Segment ordering for the BASIC runtime
;
; Copyright <C> 1987, Microsoft Corporation
;
;Purpose:
; This module contains the segment ordering for the BASIC
; runtime module.
;
;******************************************************************************
INCLUDE switch.inc ;assembly switch file
INCLUDE rmacros.inc ;segment/C macros
;
; Define segment order for runtime module
;
;
; Data Segments
;
USESEG <NULL> ; BEGDATA (empty for RTMs)
USESEG <BR_DATA> ;Hole for user program data
USESEG <CONST> ;runtime constants
USESEG <_BSS> ;runtime data (uninitialized)
USESEG <_DATA> ;runtime data (initialized)
USESEG <BC_DATA> ;users variables
USESEG <BC_FT>
USESEG <BC_CN>
USESEG <BC_DS>
USESEG <BC_SAB> ;beginning of user module start address table
USESEG <BC_SA> ;user module start address table
USESEG <BC_SAE> ;end of user module start address table
; creation of BR_DATA, class BLANK before
; these segments
USESEG <BR_SKYS> ;Soft key definitions
USESEG <COMMON> ;User blank COMMON data
USESEG <NMALLOC> ;start of near malloc buffer
USESEG <ENMALLOC> ;end of near malloc buffer space
USESEG <STACK> ;runtime stack
;
; Code Segments
;
USESEG <RT_TEXT> ;runtime core segment
USESEG <NH_TEXT> ;near heap manager
USESEG <FH_TEXT> ;far heap manager
USESEG <ST_TEXT> ;string functions
USESEG <GR_TEXT> ;graphics
USESEG <MT_TEXT> ;floating point math
USESEG <ER_TEXT> ;error trapping
USESEG <EV_TEXT> ;event trapping
USESEG <SN_TEXT> ;sound and music
USESEG <DV_TEXT> ;device I/O
USESEG <CN_TEXT> ;console I/O
USESEG <DK_TEXT> ;disk I/O
USESEG <OI_TEXT> ;comm/printer I/O
USESEG <OS_TEXT> ;operating system functions/features
USESEG <DB_TEXT> ;debug utilities /D
USESEG <ID_TEXT> ;internal runtime debugging
USESEG <INIT_CODE> ;initialization
USESEG _TEXT ;c
INCLUDE seg.inc ;segment definitions
END
|
atari/cleanmem/cleanmem.asm | JonathanGzzBen/c-study | 0 | 81265 | processor 6502
seg code
org $F000 ; Define the code origin at $F000
Start:
sei ; Disable interrupts
cld ; Disable the BCD decimal math mode
ldx #$FF ; Load the X register with #$FF
txs ; Transfer the X register to the (S)tack pointer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Clear the Page Zero region ($00 to $FF)
; Meaning the entire ram and also the entire TIA registers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
lda #0 ; A = 0
ldx #$FF ; X = #$FF
sta $FF ; Make sure $FF is zeroed before the loop starts
MemLoop:
dex ; X--
sta $0,X ; Store the value of A inside memory address $0 + X
bne MemLoop ; Loop until X is equal to zero (z-flag is set)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Fill the ROm size to exactly 4KB
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org $FFFC
.word Start ; Reset vector at $FFFC (where the program starts)
.word Start ; Interrupt vector at $FFFE (unused in the VCS) |
loader/fixed_loader_x86.asm | AntiRootkit/Amber | 461 | 17406 | ;#==================================================#
;# x86 Fixed Address Reflective Stub (no relocation)#
;# Author: <NAME> <<EMAIL>> #
;# Version: 2.0 #
;#==================================================#
[BITS 32]
[ORG 0]
call start ; Get the address of pre-mapped PE image to stack
incbin "pemap.bin" ; Pre-mapped PE image
start: ;
cld ; Clear direction flags
pop esi ; Get the address of image to esi
call $+5 ; Push the current EIP to stack
sub [esp],esi ; Subtract &PE from EIP and get image_size
mov eax,[esi+0x3C] ; Get the offset of "PE" to eax
mov ebx,[eax+esi+0x34] ; Get the image base address to ebx
mov eax,[eax+esi+0x28] ; Get the address of entry point to eax
push eax ; Save the address of entry to stack
push ebx ; Save image base to stack
push 0x00000000 ; Allocate a DWORD variable inside stack
push esp ; lpflOldProtect
push 0x40 ; PAGE_EXECUTE_READWRITE
push dword [esp+0x14] ; dwSize
push ebx ; lpAddress
push 0x80886EF1 ; crc32( "kernel32.dll", "VirtualProtect" )
call api_call ; VirtualProtect( ImageBase, image_size, PAGE_EXECUTE_READWRITE, lpflOldProtect)
pop eax ; Fix the stack
mov eax,[esi+0x3C] ; Offset to IMAGE_NT_HEADER ("PE")
mov eax,[eax+esi+0x80] ; Import table RVA
add eax,esi ; Import table memory address (first image import descriptor)
push eax ; Save the address of import descriptor to stack
get_modules:
cmp dword [eax],0x00 ; Check if the import names table RVA is NULL
jz complete ; If yes building process is done
mov eax,[eax+0x0C] ; Get RVA of dll name to eax
add eax,esi ; Get the dll name address
call LoadLibraryA ; Load the library
mov ebx,eax ; Move the dll handle to ebx
mov eax,[esp] ; Move the address of current _IMPORT_DESCRIPTOR to eax
call get_procs ; Resolve all windows API function addresses
add dword [esp],0x14 ; Move to the next import descriptor
mov eax,[esp] ; Set the new import descriptor address to eax
jmp get_modules
get_procs:
push ecx ; Save ecx to stack
push dword [eax+0x10] ; Save the current import descriptor IAT RVA
add [esp],esi ; Get the IAT memory address
mov eax,[eax] ; Set the import names table RVA to eax
add eax,esi ; Get the current import descriptor's import names table address
push eax ; Save it to stack
resolve:
cmp dword [eax],0x00 ; Check if end of the import names table
jz all_resolved ; If yes resolving process is done
mov eax,[eax] ; Get the RVA of function hint to eax
cmp eax,0x80000000 ; Check if the high order bit is set
js name_resolve ; If high order bit is not set resolve with INT entry
sub eax,0x80000000 ; Zero out the high bit
call GetProcAddress ; Get the API address with hint
jmp insert_iat ; Insert the address of API tı IAT
name_resolve:
add eax,esi ; Set the address of function hint
add eax,0x02 ; Move to function name
call GetProcAddress ; Get the function address to eax
insert_iat:
mov ecx,[esp+4] ; Move the IAT address to ecx
mov [ecx],eax ; Insert the function address to IAT
add dword [esp],0x04 ; Increase the import names table index
add dword [esp+4],0x04 ; Increase the IAT index
mov eax,[esp] ; Set the address of import names table address to eax
jmp resolve ; Loop
all_resolved:
mov ecx,[esp+4] ; Move the IAT address to ecx
mov dword [ecx],0x00 ; Insert a NULL dword
pop ecx ; Deallocate index values
pop ecx ; ...
pop ecx ; Put back the ecx value
ret ; <-
LoadLibraryA:
push ecx ; Save ecx to stack
push edx ; Save edx to stack
push eax ; Push the address of linrary name string
push 0xE2E6A091 ; ror13( "kernel32.dll", "LoadLibraryA" )
call api_call ; LoadLibraryA([esp+4])
pop edx ; Retreive edx
pop ecx ; Retreive ecx
ret ; <-
GetProcAddress:
push ecx ; Save ecx to stack
push edx ; Save edx to stack
push eax ; Push the address of proc name string
push ebx ; Push the dll handle
push 0xA18B0B38 ; ror13( "kernel32.dll", "GetProcAddress" )
call api_call ; GetProcAddress(ebx,[esp+4])
pop edx ; Retrieve edx
pop ecx ; Retrieve ecx
ret ; <-
complete:
pop eax ; Clean out the stack
pop edi ; ..
mov edx,edi ; Copy the address of new base to EDX
pop eax ; Pop the address_of_entry to EAX
add edi,eax ; Add the address of entry to new image base
pop ecx ; Pop the image_size to ECX
memcpy:
mov al,[esi] ; Move 1 byte of PE image to AL register
mov byte [edx],al ; Move 1 byte of PE image to image base
mov byte [esi],0 ; Overwrite copied byte (for less memory footprint)
inc esi ; Increase PE image index
inc edx ; Increase image base index
loop memcpy ; Loop until ECX = 0
jmp PE_start
; ========== API ==========
%include "CRC32_API/x86_crc32_api.asm"
PE_start:
mov ecx,wipe ; Get the number of bytes until wipe label
call wipe_start ; Call wipe_start
wipe_start:
pop eax ; Get EIP to EAX
wipe:
mov byte [eax],0 ; Wipe 1 byte at a time
dec eax ; Decraise EAX
loop wipe ; Loop until ECX = 0
ret ; Return to AOE |
FinderSyncExtension/Scripts/vscode.scpt | Musk66/FinderGo-Modify | 6 | 4458 | <filename>FinderSyncExtension/Scripts/vscode.scpt
tell application "Finder"
set cwd to POSIX path of ((target of front Finder window) as text)
do shell script "open -a Visual\\ Studio\\ Code " & quoted form of cwd
end tell
|
data/pokemon/base_stats/dragonite.asm | opiter09/ASM-Machina | 1 | 242051 | db DEX_DRAGONITE ; pokedex id
db 91, 134, 95, 80, 100
; hp atk def spd spc
db DRAGON, FLYING ; type
db 45 ; catch rate
db 218 ; base exp
INCBIN "gfx/pokemon/front/dragonite.pic", 0, 1 ; sprite dimensions
dw DragonitePicFront, DragonitePicBack
db WRAP, LEER, THUNDER_WAVE, AGILITY ; level 1 learnset
db GROWTH_SLOW ; growth rate
; tm/hm learnset
tmhm RAZOR_WIND, TOXIC, COUNTER, BODY_SLAM, TAKE_DOWN, \
DOUBLE_EDGE, BUBBLEBEAM, WATER_GUN, ICE_BEAM, BLIZZARD, \
HYPER_BEAM, RAGE, DRAGON_RAGE, THUNDERBOLT, THUNDER, \
MIMIC, DOUBLE_TEAM, REFLECT, BIDE, FIRE_BLAST, \
SWIFT, SKULL_BASH, REST, THUNDER_WAVE, SUBSTITUTE, \
SURF, STRENGTH
; end
db 0 ; padding
|
src/agda/FRP/JS/Model.agda | agda/agda-frp-js | 63 | 10721 | <filename>src/agda/FRP/JS/Model.agda
open import FRP.JS.Level using ( Level ; _⊔_ ) renaming ( zero to o ; suc to ↑ )
open import FRP.JS.Time using ( Time ; _≤_ ; _<_ )
open import FRP.JS.Bool using ( Bool ; true ; false ; not ; _≟_ )
open import FRP.JS.True using ( True ; tt )
module FRP.JS.Model where
-- This model is essentially System F-omega with a kind time
-- together with a type for the partial order on time,
-- and expressions for reflexivity and transitivity.
-- We prove parametricity, and then show that parametricity implies causality.
-- Note that this is a "deep" notion of causality, not the "shallow"
-- causality usually used in FRP. The pragmatic upshot of this is that
-- there is only one time model: nested signals are in the same time
-- model, not a simulated time model. This fits with the JS implementation,
-- which uses wall clock time for all signals.
-- Propositional equality
data _≡_ {α} {A : Set α} (a : A) : A → Set α where
refl : a ≡ a
sym : ∀ {α} {A : Set α} {a b : A} → (a ≡ b) → (b ≡ a)
sym refl = refl
trans : ∀ {α} {A : Set α} {a b c : A} → (a ≡ b) → (b ≡ c) → (a ≡ c)
trans refl refl = refl
cong : ∀ {α β} {A : Set α} {B : Set β} (f : A → B) {a₁ a₂ : A} →
(a₁ ≡ a₂) → (f a₁ ≡ f a₂)
cong f refl = refl
apply : ∀ {α β} {A : Set α} {B : Set β} {F G : A → B} → (F ≡ G) →
∀ {a b} → (a ≡ b) → (F a ≡ G b)
apply refl refl = refl
cast : ∀ {α} {A B : Set α} → (A ≡ B) → A → B
cast refl a = a
cast² : ∀ {α} {A B : Set α} {ℜ ℑ : A → B → Set α} → (ℜ ≡ ℑ) → ∀ {a b} → ℜ a b → ℑ a b
cast² refl aℜb = aℜb
irrel : ∀ b → (b₁ b₂ : True b) → (b₁ ≡ b₂)
irrel true tt tt = refl
irrel false () ()
-- Postulates (including dependent extensionality)
data _≤?_ (t u : Time) : Set where
leq : True (t ≤ u) → (t ≤? u)
geq : True (u ≤ t) → (t ≤? u)
postulate
≤-refl : ∀ t → True (t ≤ t)
≤-trans : ∀ t u v → True (t ≤ u) → True (u ≤ v) → True (t ≤ v)
≤-asym : ∀ t u → True (t ≤ u) → True (u ≤ t) → (t ≡ u)
≤-total : ∀ t u → (t ≤? u)
dext : ∀ {α β} {A : Set α} {B : A → Set β} {F G : ∀ a → B a} → (∀ a → F a ≡ G a) → (F ≡ G)
ext : ∀ {α β} {A : Set α} {B : Set β} {F G : A → B} →
(∀ a → F a ≡ G a) → (F ≡ G)
ext = dext
iext : ∀ {α β} {A : Set α} {B : A → Set β} {F G : ∀ {a} → B a} →
(∀ a → F {a} ≡ G {a}) → ((λ {a} → F {a}) ≡ (λ {a} → G {a}))
iext F≈G = cong (λ X {a} → X a) (dext F≈G)
-- Finite products
record ⊤ {α} : Set α where
constructor tt
open ⊤ public
record Σ {α β} (A : Set α) (B : A → Set β) : Set (α ⊔ β) where
constructor _,_
field
proj₁ : A
proj₂ : B proj₁
open Σ public
_×_ : ∀ {α β} → Set α → Set β → Set (α ⊔ β)
A × B = Σ A (λ a → B)
_ײ_ : ∀ {α β} {A C : Set α} {B D : Set β} →
(A → C → Set α) → (B → D → Set β) → ((A × B) → (C × D) → Set (α ⊔ β))
(ℜ ײ ℑ) (a , b) (c , d) = (ℜ a c × ℑ b d)
_→²_ : ∀ {α β} {A C : Set α} {B D : Set β} →
(A → C → Set α) → (B → D → Set β) → ((A → B) → (C → D) → Set (α ⊔ β))
(ℜ →² ℑ) f g = ∀ {a b} → ℜ a b → ℑ (f a) (g b)
-- Case on booleans
data Case (c : Bool) : Set where
_,_ : ∀ b → True (b ≟ c) → Case c
switch : ∀ b → Case b
switch true = (true , tt)
switch false = (false , tt)
-- Reactive sets
RSet : ∀ α → Set (↑ α)
RSet α = Time → Set α
-- Equalitional reasoning
infix 4 _IsRelatedTo_
infix 2 _∎
infixr 2 _≡⟨_⟩_
infix 1 begin_
data _IsRelatedTo_ {α} {A : Set α} (a b : A) : Set α where
relTo : (a≡b : a ≡ b) → a IsRelatedTo b
begin_ : ∀ {α} {A : Set α} {a b : A} → a IsRelatedTo b → a ≡ b
begin relTo a≡b = a≡b
_≡⟨_⟩_ : ∀ {α} {A : Set α} a {b c : A} → a ≡ b → b IsRelatedTo c → a IsRelatedTo c
_ ≡⟨ a≡b ⟩ relTo b≡c = relTo (trans a≡b b≡c)
_∎ : ∀ {α} {A : Set α} (a : A) → a IsRelatedTo a
_∎ _ = relTo refl
-- Kinds
data Kind : Set where
time : Kind
set : Level → Kind
_⇒_ : Kind → Kind → Kind
level : Kind → Level
level time = o
level (set α) = ↑ α
level (K ⇒ L) = level K ⊔ level L
K⟦_⟧ : ∀ K → Set (level K)
K⟦ time ⟧ = Time
K⟦ set α ⟧ = Set α
K⟦ K ⇒ L ⟧ = K⟦ K ⟧ → K⟦ L ⟧
_∋_↔_ : ∀ K → K⟦ K ⟧ → K⟦ K ⟧ → Set (level K)
time ∋ t ↔ u = (t ≡ u)
set α ∋ A ↔ B = A → B → Set α
(K ⇒ L) ∋ F ↔ G = ∀ {A B} → (K ∋ A ↔ B) → (L ∋ F A ↔ G B)
-- ≡ can be used as a structural equivalence on relations.
struct : ∀ K {A B C D} → (A ≡ B) → (K ∋ B ↔ D) → (C ≡ D) → (K ∋ A ↔ C)
struct K refl ℜ refl = ℜ
struct-ext : ∀ K L {A B} {F G H I : K⟦ K ⇒ L ⟧}
(F≈G : ∀ A → F A ≡ G A) (ℜ : (K ⇒ L) ∋ G ↔ I) (H≈I : ∀ B → H B ≡ I B) (ℑ : K ∋ A ↔ B) →
struct L (F≈G A) (ℜ ℑ) (H≈I B) ≡ struct (K ⇒ L) (ext F≈G) ℜ (ext H≈I) ℑ
struct-ext K L {A} {B} F≈G ℜ H≈I ℑ
with ext F≈G | ext H≈I | F≈G A | H≈I B
... | refl | refl | refl | refl = refl
struct-apply : ∀ K L {F G H I A B C D} →
(F≡G : F ≡ G) (ℜ : (K ⇒ L) ∋ G ↔ I) (H≡I : H ≡ I) →
(A≡B : A ≡ B) (ℑ : K ∋ B ↔ D) (C≡D : C ≡ D) →
struct (K ⇒ L) F≡G ℜ H≡I (struct K A≡B ℑ C≡D)
≡ struct L (apply F≡G A≡B) (ℜ ℑ) (apply H≡I C≡D)
struct-apply K L refl ℜ refl refl ℑ refl = refl
struct-cast : ∀ {α A B C D} (ℜ : set α ∋ B ↔ D) (A≡B : A ≡ B) (C≡D : C ≡ D) {a c} →
struct (set α) A≡B ℜ C≡D a c → ℜ (cast A≡B a) (cast C≡D c)
struct-cast ℜ refl refl aℜc = aℜc
struct-sym : ∀ K {A B C D ℑ ℜ} → (A≡B : A ≡ B) → (C≡D : C ≡ D) →
(ℑ ≡ struct K A≡B ℜ C≡D) →
(ℜ ≡ struct K (sym A≡B) ℑ (sym C≡D))
struct-sym K refl refl refl = refl
struct-trans : ∀ K {A B C D E F}
(A≡B : A ≡ B) (B≡C : B ≡ C) (ℜ : K ∋ C ↔ F) (E≡F : E ≡ F) (D≡E : D ≡ E) →
struct K A≡B (struct K B≡C ℜ E≡F) D≡E ≡
struct K (trans A≡B B≡C) ℜ (trans D≡E E≡F)
struct-trans K refl refl ℜ refl refl = refl
-- Type contexts
infixr 4 _∷_
data Kinds : Set where
[] : Kinds
_∷_ : Kind → Kinds → Kinds
levels : Kinds → Level
levels [] = o
levels (K ∷ Σ) = level K ⊔ levels Σ
Σ⟦_⟧ : ∀ Σ → Set (levels Σ)
Σ⟦ [] ⟧ = ⊤
Σ⟦ K ∷ Σ ⟧ = K⟦ K ⟧ × Σ⟦ Σ ⟧
_∋_↔*_ : ∀ Σ → Σ⟦ Σ ⟧ → Σ⟦ Σ ⟧ → Set (levels Σ)
[] ∋ tt ↔* tt = ⊤
(K ∷ Σ) ∋ (A , As) ↔* (B , Bs) = (K ∋ A ↔ B) × (Σ ∋ As ↔* Bs)
-- Inclusion order on type contexts.
-- Credited by R<NAME> to Geuvers and Nederhof, JAR 1991.
-- http://thread.gmane.org/gmane.comp.lang.agda/3259/focus=3267
data _⊑_ : Kinds → Kinds → Set where
id : ∀ {Σ} → Σ ⊑ Σ
keep : ∀ K {Σ Υ} → (Σ ⊑ Υ) → ((K ∷ Σ) ⊑ (K ∷ Υ))
skip : ∀ K {Σ Υ} → (Σ ⊑ Υ) → (Σ ⊑ (K ∷ Υ))
⊑⟦_⟧ : ∀ {Σ Υ} → (Σ ⊑ Υ) → Σ⟦ Υ ⟧ → Σ⟦ Σ ⟧
⊑⟦ id ⟧ As = As
⊑⟦ keep K Σ⊑Υ ⟧ (A , As) = (A , ⊑⟦ Σ⊑Υ ⟧ As)
⊑⟦ skip K Σ⊑Υ ⟧ (A , As) = ⊑⟦ Σ⊑Υ ⟧ As
⊑⟦_⟧² : ∀ {Σ Υ} → (Σ⊑Υ : Σ ⊑ Υ) → ∀ {As Bs} → (Υ ∋ As ↔* Bs) → (Σ ∋ ⊑⟦ Σ⊑Υ ⟧ As ↔* ⊑⟦ Σ⊑Υ ⟧ Bs)
⊑⟦ id ⟧² ℜs = ℜs
⊑⟦ keep K Σ⊑Υ ⟧² (ℜ , ℜs) = (ℜ , ⊑⟦ Σ⊑Υ ⟧² ℜs)
⊑⟦ skip K Σ⊑Υ ⟧² (ℜ , ℜs) = ⊑⟦ Σ⊑Υ ⟧² ℜs
-- Concatenation of type contexts
_++_ : Kinds → Kinds → Kinds
[] ++ Υ = Υ
(K ∷ Σ) ++ Υ = K ∷ (Σ ++ Υ)
_∋_++_∋_ : ∀ Σ → Σ⟦ Σ ⟧ → ∀ Υ → Σ⟦ Υ ⟧ → Σ⟦ Σ ++ Υ ⟧
[] ∋ tt ++ Υ ∋ Bs = Bs
(K ∷ Σ) ∋ (A , As) ++ Υ ∋ Bs = (A , (Σ ∋ As ++ Υ ∋ Bs))
_∋_++²_∋_ : ∀ Σ {As Bs} → (Σ ∋ As ↔* Bs) → ∀ Υ {Cs Ds} → (Υ ∋ Cs ↔* Ds) →
((Σ ++ Υ) ∋ (Σ ∋ As ++ Υ ∋ Cs) ↔* (Σ ∋ Bs ++ Υ ∋ Ds))
[] ∋ tt ++² Υ ∋ ℑs = ℑs
(K ∷ Σ) ∋ (ℜ , ℜs) ++² Υ ∋ ℑs = (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs))
-- Type variables
data TVar (K : Kind) : Kinds → Set where
zero : ∀ {Σ} → TVar K (K ∷ Σ)
suc : ∀ {L Σ} → TVar K Σ → TVar K (L ∷ Σ)
τ⟦_⟧ : ∀ {Σ K} (τ : TVar K Σ) → Σ⟦ Σ ⟧ → K⟦ K ⟧
τ⟦ zero ⟧ (A , As) = A
τ⟦ suc τ ⟧ (A , As) = τ⟦ τ ⟧ As
τ⟦_⟧² : ∀ {Σ K} (τ : TVar K Σ) {As Bs} → (Σ ∋ As ↔* Bs) → (K ∋ τ⟦ τ ⟧ As ↔ τ⟦ τ ⟧ Bs)
τ⟦ zero ⟧² (ℜ , ℜs) = ℜ
τ⟦ suc τ ⟧² (ℜ , ℜs) = τ⟦ τ ⟧² ℜs
-- Type constants
data TConst : Kind → Set where
prod fun : ∀ {α β} → TConst (set α ⇒ (set β ⇒ set (α ⊔ β)))
leq : TConst (time ⇒ (time ⇒ set o))
univ : ∀ K {α} → TConst ((K ⇒ set α) ⇒ set (level K ⊔ α))
C⟦_⟧ : ∀ {K} → (TConst K) → K⟦ K ⟧
C⟦ prod ⟧ = λ A B → (A × B)
C⟦ fun ⟧ = λ A B → (A → B)
C⟦ leq ⟧ = λ t u → True (t ≤ u)
C⟦ univ K ⟧ = λ F → ∀ A → F A
C⟦_⟧² : ∀ {K} (C : TConst K) → (K ∋ C⟦ C ⟧ ↔ C⟦ C ⟧)
C⟦ prod ⟧² = λ ℜ ℑ → (ℜ ײ ℑ)
C⟦ fun ⟧² = λ ℜ ℑ → (ℜ →² ℑ)
C⟦ leq ⟧² = λ _ _ _ _ → ⊤
C⟦ univ K ⟧² = λ ℜ f g → ∀ {a b} ℑ → ℜ ℑ (f a) (g b)
-- Types
data Typ (Σ : Kinds) : Kind → Set where
const : ∀ {K} → TConst K → Typ Σ K
abs : ∀ K {L} → Typ (K ∷ Σ) L → Typ Σ (K ⇒ L)
app : ∀ {K L} → Typ Σ (K ⇒ L) → Typ Σ K → Typ Σ L
var : ∀ {K} → TVar K Σ → Typ Σ K
tlevel : ∀ {Σ α} → Typ Σ (set α) → Level
tlevel {Σ} {α} T = α
T⟦_⟧ : ∀ {Σ K} (T : Typ Σ K) → Σ⟦ Σ ⟧ → K⟦ K ⟧
T⟦ const C ⟧ As = C⟦ C ⟧
T⟦ abs K T ⟧ As = λ A → T⟦ T ⟧ (A , As)
T⟦ app T U ⟧ As = T⟦ T ⟧ As (T⟦ U ⟧ As)
T⟦ var τ ⟧ As = τ⟦ τ ⟧ As
T⟦_⟧² : ∀ {Σ K} (T : Typ Σ K) {As Bs} → (Σ ∋ As ↔* Bs) → (K ∋ T⟦ T ⟧ As ↔ T⟦ T ⟧ Bs)
T⟦ const C ⟧² ℜs = C⟦ C ⟧²
T⟦ abs K T ⟧² ℜs = λ ℜ → T⟦ T ⟧² (ℜ , ℜs)
T⟦ app T U ⟧² ℜs = T⟦ T ⟧² ℜs (T⟦ U ⟧² ℜs)
T⟦ var τ ⟧² ℜs = τ⟦ τ ⟧² ℜs
-- Type shorthands
app₂ : ∀ {Σ K L M} → Typ Σ (K ⇒ (L ⇒ M)) → Typ Σ K → Typ Σ L → Typ Σ M
app₂ T U V = app (app T U) V
capp : ∀ {Σ K L} → TConst (K ⇒ L) → Typ Σ K → Typ Σ L
capp C = app (const C)
capp₂ : ∀ {Σ K L M} → TConst (K ⇒ (L ⇒ M)) → Typ Σ K → Typ Σ L → Typ Σ M
capp₂ C = app₂ (const C)
_⊗_ : ∀ {Σ α β} → Typ Σ (set α) → Typ Σ (set β) → Typ Σ (set (α ⊔ β))
_⊗_ = capp₂ prod
_⊸_ : ∀ {Σ α β} → Typ Σ (set α) → Typ Σ (set β) → Typ Σ (set (α ⊔ β))
_⊸_ = capp₂ fun
_≼_ : ∀ {Σ} → Typ Σ time → Typ Σ time → Typ Σ (set o)
_≼_ = capp₂ leq
Π : ∀ {Σ α} K → Typ (K ∷ Σ) (set α) → Typ Σ (set (level K ⊔ α))
Π K T = capp (univ K) (abs K T)
tvar₀ : ∀ {Σ K} → Typ (K ∷ Σ) K
tvar₀ = var zero
tvar₁ : ∀ {Σ K L} → Typ (L ∷ K ∷ Σ) K
tvar₁ = var (suc zero)
tvar₂ : ∀ {Σ K L M} → Typ (M ∷ L ∷ K ∷ Σ) K
tvar₂ = var (suc (suc zero))
tvar₃ : ∀ {Σ K L M N} → Typ (N ∷ M ∷ L ∷ K ∷ Σ) K
tvar₃ = var (suc (suc (suc zero)))
rset : Level → Kind
rset α = time ⇒ set α
rset₀ : Kind
rset₀ = rset o
prodʳ : ∀ {Σ α β} → Typ Σ (rset α ⇒ (rset β ⇒ rset (α ⊔ β)))
prodʳ {Σ} {α} {β} = abs (rset α) (abs (rset β) (abs time (app tvar₂ tvar₀ ⊗ app tvar₁ tvar₀)))
_⊗ʳ_ : ∀ {Σ α β} → Typ Σ (rset α) → Typ Σ (rset β) → Typ Σ (rset (α ⊔ β))
_⊗ʳ_ = app₂ prodʳ
funʳ : ∀ {Σ α β} → Typ Σ (rset α ⇒ (rset β ⇒ rset (α ⊔ β)))
funʳ {Σ} {α} {β} = abs (rset α) (abs (rset β) (abs time (app tvar₂ tvar₀ ⊸ app tvar₁ tvar₀)))
_⊸ʳ_ : ∀ {Σ α β} → Typ Σ (rset α) → Typ Σ (rset β) → Typ Σ (rset (α ⊔ β))
_⊸ʳ_ = app₂ funʳ
always : ∀ {Σ α} → Typ Σ (set α ⇒ rset α)
always {Σ} {α} = abs (set α) (abs time tvar₁)
interval : ∀ {Σ α} → Typ Σ (rset α ⇒ (time ⇒ (time ⇒ set α)))
interval {Σ} {α} = abs (rset α) (abs time (abs time (Π time
((tvar₂ ≼ tvar₀) ⊸ ((tvar₀ ≼ tvar₁) ⊸ app tvar₃ tvar₀)))))
_[_,_] : ∀ {Σ α} → Typ Σ (rset α) → Typ Σ time → Typ Σ time → Typ Σ (set α)
T [ t , u ] = app (app (app interval T) t) u
constreq : ∀ {Σ α β} → Typ Σ (rset α ⇒ (rset β ⇒ rset (α ⊔ β)))
constreq {Σ} {α} {β} = abs (rset α) (abs (rset β) (abs time (Π time
((tvar₁ ≼ tvar₀) ⊸ ((tvar₃ [ tvar₁ , tvar₀ ]) ⊸ app tvar₂ tvar₀)))))
_⊵_ : ∀ {Σ α β} → Typ Σ (rset α) → Typ Σ (rset β) → Typ Σ (rset (α ⊔ β))
T ⊵ U = app₂ constreq T U
-- Contexts
data Typs (Σ : Kinds) : Set where
[] : Typs Σ
_∷_ : ∀ {α} → (Typ Σ (set α)) → Typs Σ → Typs Σ
tlevels : ∀ {Σ} → Typs Σ → Level
tlevels [] = o
tlevels (T ∷ Γ) = tlevel T ⊔ tlevels Γ
Γ⟦_⟧ : ∀ {Σ} (Γ : Typs Σ) → Σ⟦ Σ ⟧ → Set (tlevels Γ)
Γ⟦ [] ⟧ As = ⊤
Γ⟦ T ∷ Γ ⟧ As = T⟦ T ⟧ As × Γ⟦ Γ ⟧ As
Γ⟦_⟧² : ∀ {Σ} (Γ : Typs Σ) {As Bs} (ℜs : Σ ∋ As ↔* Bs) → (Γ⟦ Γ ⟧ As → Γ⟦ Γ ⟧ Bs → Set (tlevels Γ))
Γ⟦ [] ⟧² ℜs tt tt = ⊤
Γ⟦ T ∷ Γ ⟧² ℜs (a , as) (b , bs) = T⟦ T ⟧² ℜs a b × Γ⟦ Γ ⟧² ℜs as bs
-- Weakening of type variables
τweaken : ∀ {Σ Υ K} → (Σ ⊑ Υ) → TVar K Σ → TVar K Υ
τweaken id x = x
τweaken (keep K Σ⊑Υ) zero = zero
τweaken (keep K Σ⊑Υ) (suc x) = suc (τweaken Σ⊑Υ x)
τweaken (skip K Σ⊑Υ) x = suc (τweaken Σ⊑Υ x)
τweaken⟦_⟧ : ∀ {Σ Υ K} (τ : TVar K Σ) (Σ⊑Υ : Σ ⊑ Υ) (As : Σ⟦ Υ ⟧) →
τ⟦ τ ⟧ (⊑⟦ Σ⊑Υ ⟧ As) ≡ τ⟦ τweaken Σ⊑Υ τ ⟧ As
τweaken⟦ τ ⟧ id As = refl
τweaken⟦ zero ⟧ (keep K Σ⊑Υ) (A , As) = refl
τweaken⟦ suc τ ⟧ (keep K Σ⊑Υ) (A , As) = τweaken⟦ τ ⟧ Σ⊑Υ As
τweaken⟦ τ ⟧ (skip K Σ⊑Υ) (A , As) = τweaken⟦ τ ⟧ Σ⊑Υ As
τweaken⟦_⟧² : ∀ {Σ Υ K} (τ : TVar K Σ) (Σ⊑Υ : Σ ⊑ Υ) {As Bs} (ℜs : Υ ∋ As ↔* Bs) →
τ⟦ τ ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs) ≡
struct K (τweaken⟦ τ ⟧ Σ⊑Υ As) (τ⟦ τweaken Σ⊑Υ τ ⟧² ℜs) (τweaken⟦ τ ⟧ Σ⊑Υ Bs)
τweaken⟦ τ ⟧² id ℜs = refl
τweaken⟦ zero ⟧² (keep K Σ⊑Υ) (ℜ , ℜs) = refl
τweaken⟦ suc τ ⟧² (keep K Σ⊑Υ) (ℜ , ℜs) = τweaken⟦ τ ⟧² Σ⊑Υ ℜs
τweaken⟦ τ ⟧² (skip K Σ⊑Υ) (ℜ , ℜs) = τweaken⟦ τ ⟧² Σ⊑Υ ℜs
-- Weakening of types
weaken : ∀ {Σ Υ K} → (Σ ⊑ Υ) → Typ Σ K → Typ Υ K
weaken Σ⊑Υ (const C) = const C
weaken Σ⊑Υ (abs K T) = abs K (weaken (keep K Σ⊑Υ) T)
weaken Σ⊑Υ (app T U) = app (weaken Σ⊑Υ T) (weaken Σ⊑Υ U)
weaken Σ⊑Υ (var τ) = var (τweaken Σ⊑Υ τ)
weaken⟦_⟧ : ∀ {Σ Υ K} (T : Typ Σ K) (Σ⊑Υ : Σ ⊑ Υ) (As : Σ⟦ Υ ⟧) →
T⟦ T ⟧ (⊑⟦ Σ⊑Υ ⟧ As) ≡ T⟦ weaken Σ⊑Υ T ⟧ As
weaken⟦ const C ⟧ Σ⊑Υ As = refl
weaken⟦ abs K T ⟧ Σ⊑Υ As = ext (λ A → weaken⟦ T ⟧ (keep K Σ⊑Υ) (A , As))
weaken⟦ app T U ⟧ Σ⊑Υ As = apply (weaken⟦ T ⟧ Σ⊑Υ As) (weaken⟦ U ⟧ Σ⊑Υ As)
weaken⟦ var τ ⟧ Σ⊑Υ As = τweaken⟦ τ ⟧ Σ⊑Υ As
weaken⟦_⟧² : ∀ {Σ Υ K} (T : Typ Σ K) (Σ⊑Υ : Σ ⊑ Υ) {As Bs} (ℜs : Υ ∋ As ↔* Bs) →
T⟦ T ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs) ≡ struct K (weaken⟦ T ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ T ⟧² ℜs) (weaken⟦ T ⟧ Σ⊑Υ Bs)
weaken⟦ const C ⟧² Σ⊑Υ ℜs = refl
weaken⟦ abs K {L} T ⟧² Σ⊑Υ {As} {Bs} ℜs =
iext (λ A → iext (λ B → ext (λ ℜ → begin
T⟦ abs K T ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs) ℜ
≡⟨ weaken⟦ T ⟧² (keep K Σ⊑Υ) (ℜ , ℜs) ⟩
struct L
(weaken⟦ T ⟧ (keep K Σ⊑Υ) (A , As))
(T⟦ weaken (keep K Σ⊑Υ) T ⟧² (ℜ , ℜs))
(weaken⟦ T ⟧ (keep K Σ⊑Υ) (B , Bs))
≡⟨ struct-ext K L
(λ A → weaken⟦ T ⟧ (keep K Σ⊑Υ) (A , As))
(λ ℜ → T⟦ weaken (keep K Σ⊑Υ) T ⟧² (ℜ , ℜs))
(λ B → weaken⟦ T ⟧ (keep K Σ⊑Υ) (B , Bs)) ℜ ⟩
struct (K ⇒ L)
(weaken⟦ abs K T ⟧ Σ⊑Υ As)
(T⟦ weaken Σ⊑Υ (abs K T) ⟧² ℜs)
(weaken⟦ abs K T ⟧ Σ⊑Υ Bs) ℜ
∎)))
weaken⟦ app {K} {L} T U ⟧² Σ⊑Υ {As} {Bs} ℜs =
begin
T⟦ app T U ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs)
≡⟨ cong (T⟦ T ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs)) (weaken⟦ U ⟧² Σ⊑Υ ℜs) ⟩
T⟦ T ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs)
(struct K (weaken⟦ U ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ U ⟧² ℜs) (weaken⟦ U ⟧ Σ⊑Υ Bs))
≡⟨ cong (λ X → X (struct K (weaken⟦ U ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ U ⟧² ℜs) (weaken⟦ U ⟧ Σ⊑Υ Bs)))
(weaken⟦ T ⟧² Σ⊑Υ ℜs) ⟩
(struct (K ⇒ L) (weaken⟦ T ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ T ⟧² ℜs) (weaken⟦ T ⟧ Σ⊑Υ Bs))
(struct K (weaken⟦ U ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ U ⟧² ℜs) (weaken⟦ U ⟧ Σ⊑Υ Bs))
≡⟨ struct-apply K L
(weaken⟦ T ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ T ⟧² ℜs) (weaken⟦ T ⟧ Σ⊑Υ Bs)
(weaken⟦ U ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ U ⟧² ℜs) (weaken⟦ U ⟧ Σ⊑Υ Bs) ⟩
struct L
(weaken⟦ app T U ⟧ Σ⊑Υ As)
(T⟦ weaken Σ⊑Υ (app T U) ⟧² ℜs)
(weaken⟦ app T U ⟧ Σ⊑Υ Bs)
∎
weaken⟦ var τ ⟧² Σ⊑Υ ℜs = τweaken⟦ τ ⟧² Σ⊑Υ ℜs
-- Weakening on type contexts
weakens : ∀ {Σ Υ} → (Σ ⊑ Υ) → Typs Σ → Typs Υ
weakens Σ⊑Υ [] = []
weakens Σ⊑Υ (T ∷ Γ) = weaken Σ⊑Υ T ∷ weakens Σ⊑Υ Γ
weakens⟦_⟧ : ∀ {Σ Υ} (Γ : Typs Σ) (Σ⊑Υ : Σ ⊑ Υ) (As : Σ⟦ Υ ⟧) →
Γ⟦ Γ ⟧ (⊑⟦ Σ⊑Υ ⟧ As) → Γ⟦ weakens Σ⊑Υ Γ ⟧ As
weakens⟦ [] ⟧ Σ⊑Υ As tt = tt
weakens⟦ T ∷ Γ ⟧ Σ⊑Υ As (B , Bs) = (cast (weaken⟦ T ⟧ Σ⊑Υ As) B , weakens⟦ Γ ⟧ Σ⊑Υ As Bs)
weakens⟦_⟧² : ∀ {Σ Υ} (Γ : Typs Σ) (Σ⊑Υ : Σ ⊑ Υ) {As Bs} (ℜs : Υ ∋ As ↔* Bs) {as bs} →
Γ⟦ Γ ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs) as bs →
Γ⟦ weakens Σ⊑Υ Γ ⟧² ℜs (weakens⟦ Γ ⟧ Σ⊑Υ As as) (weakens⟦ Γ ⟧ Σ⊑Υ Bs bs)
weakens⟦ [] ⟧² Σ⊑Υ ℜs tt
= tt
weakens⟦ T ∷ Γ ⟧² Σ⊑Υ ℜs (aℜb , asℜbs)
= ( struct-cast (T⟦ weaken Σ⊑Υ T ⟧² ℜs)
(weaken⟦ T ⟧ Σ⊑Υ _) (weaken⟦ T ⟧ Σ⊑Υ _) (cast² (weaken⟦ T ⟧² Σ⊑Υ ℜs) aℜb)
, weakens⟦ Γ ⟧² Σ⊑Υ ℜs asℜbs)
-- Susbtitution on type variables under a context
τsubstn+ : ∀ Σ {Υ K L} → TVar K (Σ ++ (L ∷ Υ)) → Typ Υ L → Typ (Σ ++ Υ) K
τsubstn+ [] zero U = U
τsubstn+ [] (suc τ) U = var τ
τsubstn+ (K ∷ Σ) zero U = var zero
τsubstn+ (K ∷ Σ) (suc τ) U = weaken (skip K id) (τsubstn+ Σ τ U)
τsubstn+_⟦_⟧⟦_⟧ : ∀ Σ {Υ K L} (τ : TVar K (Σ ++ (L ∷ Υ))) (U : Typ Υ L)
(As : Σ⟦ Σ ⟧) (Bs : Σ⟦ Υ ⟧) →
τ⟦ τ ⟧ (Σ ∋ As ++ (L ∷ Υ) ∋ (T⟦ U ⟧ Bs , Bs)) ≡
T⟦ τsubstn+ Σ τ U ⟧ (Σ ∋ As ++ Υ ∋ Bs)
τsubstn+ [] ⟦ zero ⟧⟦ U ⟧ tt Bs = refl
τsubstn+ [] ⟦ suc τ ⟧⟦ U ⟧ tt Bs = refl
τsubstn+ (K ∷ Σ) ⟦ zero ⟧⟦ U ⟧ (A , As) Bs = refl
τsubstn+ (K ∷ Σ) ⟦ suc τ ⟧⟦ U ⟧ (A , As) Bs = trans
(τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Bs)
(weaken⟦ τsubstn+ Σ τ U ⟧ (skip K id) (A , (Σ ∋ As ++ _ ∋ Bs)))
τsubstn+_⟦_⟧⟦_⟧² : ∀ Σ {Υ L K} (τ : TVar K (Σ ++ (L ∷ Υ))) (U : Typ Υ L) {As Bs Cs Ds}
(ℜs : Σ ∋ As ↔* Bs) → (ℑs : Υ ∋ Cs ↔* Ds) →
τ⟦ τ ⟧² (Σ ∋ ℜs ++² (L ∷ Υ) ∋ (T⟦ U ⟧² ℑs , ℑs)) ≡
struct K
(τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs)
(T⟦ τsubstn+ Σ τ U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs) )
(τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds)
τsubstn+ [] ⟦ zero ⟧⟦ U ⟧² tt ℑs = refl
τsubstn+ [] ⟦ suc τ ⟧⟦ U ⟧² tt ℑs = refl
τsubstn+ (J ∷ Σ) ⟦ zero ⟧⟦ U ⟧² (ℜ , ℜs) ℑs = refl
τsubstn+_⟦_⟧⟦_⟧² (J ∷ Σ) {Υ} {L} {K} (suc τ) U {A , As} {B , Bs} {Cs} {Ds} (ℜ , ℜs) ℑs =
begin
τ⟦ τ ⟧² (Σ ∋ ℜs ++² (L ∷ Υ) ∋ (T⟦ U ⟧² ℑs , ℑs))
≡⟨ τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧² ℜs ℑs ⟩
struct K
(τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs)
(T⟦ τsubstn+ Σ τ U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))
(τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds)
≡⟨ cong (λ X → struct K (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs) X (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds))
(weaken⟦ τsubstn+ Σ τ U ⟧² (skip J id) (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs))) ⟩
struct K
(τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs)
(struct K
(weaken⟦ τsubstn+ Σ τ U ⟧ (skip J id) (A , (Σ ∋ As ++ Υ ∋ Cs)))
(T⟦ weaken (skip J id) (τsubstn+ Σ τ U) ⟧² (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs)))
(weaken⟦ τsubstn+ Σ τ U ⟧ (skip J id) (B , (Σ ∋ Bs ++ Υ ∋ Ds))))
(τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds)
≡⟨ struct-trans K
(τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs)
(weaken⟦ τsubstn+ Σ τ U ⟧ (skip J id) (A , (Σ ∋ As ++ Υ ∋ Cs)))
(T⟦ weaken (skip J id) (τsubstn+ Σ τ U) ⟧² (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs)))
(weaken⟦ τsubstn+ Σ τ U ⟧ (skip J id) (B , (Σ ∋ Bs ++ Υ ∋ Ds)))
(τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds) ⟩
struct K
(τsubstn+ (J ∷ Σ) ⟦ suc τ ⟧⟦ U ⟧ (A , As) Cs)
(T⟦ τsubstn+ (J ∷ Σ) (suc τ) U ⟧² (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs)) )
(τsubstn+ (J ∷ Σ) ⟦ suc τ ⟧⟦ U ⟧ (B , Bs) Ds)
∎
-- Substitution on types under a context
substn+ : ∀ Σ {Υ K L} → Typ (Σ ++ (L ∷ Υ)) K → Typ Υ L → Typ (Σ ++ Υ) K
substn+ Σ (const C) U = const C
substn+ Σ (abs K T) U = abs K (substn+ (K ∷ Σ) T U)
substn+ Σ (app S T) U = app (substn+ Σ S U) (substn+ Σ T U)
substn+ Σ (var τ) U = τsubstn+ Σ τ U
substn+_⟦_⟧⟦_⟧ : ∀ Σ {Υ K L} (T : Typ (Σ ++ (L ∷ Υ)) K) (U : Typ Υ L)
(As : Σ⟦ Σ ⟧) (Bs : Σ⟦ Υ ⟧) →
T⟦ T ⟧ (Σ ∋ As ++ (L ∷ Υ) ∋ (T⟦ U ⟧ Bs , Bs)) ≡
T⟦ substn+ Σ T U ⟧ (Σ ∋ As ++ Υ ∋ Bs)
substn+ Σ ⟦ const C ⟧⟦ U ⟧ As Bs = refl
substn+ Σ ⟦ abs K T ⟧⟦ U ⟧ As Bs = ext (λ A → substn+ K ∷ Σ ⟦ T ⟧⟦ U ⟧ (A , As) Bs)
substn+ Σ ⟦ app S T ⟧⟦ U ⟧ As Bs = apply (substn+ Σ ⟦ S ⟧⟦ U ⟧ As Bs) (substn+ Σ ⟦ T ⟧⟦ U ⟧ As Bs)
substn+ Σ ⟦ var τ ⟧⟦ U ⟧ As Bs = τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Bs
substn+_⟦_⟧⟦_⟧² : ∀ Σ {Υ L K} (T : Typ (Σ ++ (L ∷ Υ)) K) (U : Typ Υ L) {As Bs Cs Ds}
(ℜs : Σ ∋ As ↔* Bs) → (ℑs : Υ ∋ Cs ↔* Ds) →
T⟦ T ⟧² (Σ ∋ ℜs ++² (L ∷ Υ) ∋ (T⟦ U ⟧² ℑs , ℑs)) ≡
struct K
(substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs)
(T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs) )
(substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds)
substn+ Σ ⟦ const C ⟧⟦ U ⟧² ℜs ℑs = refl
substn+_⟦_⟧⟦_⟧² Σ {Υ} {L} (abs J {K} T) U {As} {Bs} {Cs} {Ds} ℜs ℑs =
iext (λ A → iext (λ B → ext (λ ℜ → begin
T⟦ abs J T ⟧² (Σ ∋ ℜs ++² (L ∷ Υ) ∋ (T⟦ U ⟧² ℑs , ℑs)) ℜ
≡⟨ substn+ (J ∷ Σ) ⟦ T ⟧⟦ U ⟧² (ℜ , ℜs) ℑs ⟩
struct K
(substn+ J ∷ Σ ⟦ T ⟧⟦ U ⟧ (A , As) Cs)
(T⟦ substn+ (J ∷ Σ) T U ⟧² ((J ∷ Σ) ∋ (ℜ , ℜs) ++² Υ ∋ ℑs))
(substn+ J ∷ Σ ⟦ T ⟧⟦ U ⟧ (B , Bs) Ds)
≡⟨ struct-ext J K
(λ A → substn+ J ∷ Σ ⟦ T ⟧⟦ U ⟧ (A , As) Cs)
(λ ℜ → T⟦ substn+ (J ∷ Σ) T U ⟧² ((J ∷ Σ) ∋ ℜ , ℜs ++² Υ ∋ ℑs))
(λ B → substn+ J ∷ Σ ⟦ T ⟧⟦ U ⟧ (B , Bs) Ds) ℜ ⟩
struct (J ⇒ K)
(substn+ Σ ⟦ abs J T ⟧⟦ U ⟧ As Cs)
(T⟦ substn+ Σ (abs J T) U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))
(substn+ Σ ⟦ abs J T ⟧⟦ U ⟧ Bs Ds) ℜ
∎)))
substn+_⟦_⟧⟦_⟧² Σ {Υ} {L} (app {J} {K} S T) U {As} {Bs} {Cs} {Ds} ℜs ℑs =
begin
T⟦ app S T ⟧² (Σ ∋ ℜs ++² L ∷ Υ ∋ (T⟦ U ⟧² ℑs , ℑs))
≡⟨ cong (T⟦ S ⟧² (Σ ∋ ℜs ++² L ∷ Υ ∋ (T⟦ U ⟧² ℑs , ℑs))) (substn+ Σ ⟦ T ⟧⟦ U ⟧² ℜs ℑs) ⟩
T⟦ S ⟧² (Σ ∋ ℜs ++² L ∷ Υ ∋ (T⟦ U ⟧² ℑs , ℑs))
(struct J
(substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs)
(T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))
(substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds))
≡⟨ cong (λ X → X (struct J
(substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs)
(T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))
(substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds)))
(substn+ Σ ⟦ S ⟧⟦ U ⟧² ℜs ℑs) ⟩
struct (J ⇒ K)
(substn+ Σ ⟦ S ⟧⟦ U ⟧ As Cs)
(T⟦ substn+ Σ S U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))
(substn+ Σ ⟦ S ⟧⟦ U ⟧ Bs Ds)
(struct J
(substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs)
(T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))
(substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds))
≡⟨ struct-apply J K
(substn+ Σ ⟦ S ⟧⟦ U ⟧ As Cs)
(T⟦ substn+ Σ S U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))
(substn+ Σ ⟦ S ⟧⟦ U ⟧ Bs Ds)
(substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs)
(T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))
(substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds) ⟩
struct K
(substn+ Σ ⟦ app S T ⟧⟦ U ⟧ As Cs)
(T⟦ substn+ Σ (app S T) U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs))
(substn+ Σ ⟦ app S T ⟧⟦ U ⟧ Bs Ds)
∎
substn+ Σ ⟦ var τ ⟧⟦ U ⟧² ℜs ℑs = τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧² ℜs ℑs
-- Substitution on types
substn : ∀ {Σ K L} → Typ (L ∷ Σ) K → Typ Σ L → Typ Σ K
substn = substn+ []
substn⟦_⟧⟦_⟧ : ∀ {Σ K L} (T : Typ (L ∷ Σ) K) (U : Typ Σ L) (As : Σ⟦ Σ ⟧)→
T⟦ T ⟧ (T⟦ U ⟧ As , As) ≡ T⟦ substn T U ⟧ As
substn⟦ T ⟧⟦ U ⟧ = substn+ [] ⟦ T ⟧⟦ U ⟧ tt
substn⟦_⟧⟦_⟧² : ∀ {Σ K L} (T : Typ (L ∷ Σ) K) (U : Typ Σ L) {As Bs} (ℜs : Σ ∋ As ↔* Bs) →
T⟦ T ⟧² (T⟦ U ⟧² ℜs , ℜs) ≡
struct K (substn⟦ T ⟧⟦ U ⟧ As) (T⟦ substn T U ⟧² ℜs) (substn⟦ T ⟧⟦ U ⟧ Bs)
substn⟦ T ⟧⟦ U ⟧² = substn+ [] ⟦ T ⟧⟦ U ⟧² tt
-- Eta-beta equivalence on types
data _∋_≣_ {Σ} : ∀ K → Typ Σ K → Typ Σ K → Set where
abs : ∀ K {L T U} → (L ∋ T ≣ U) → ((K ⇒ L) ∋ abs K T ≣ abs K U)
app : ∀ {K L F G T U} → ((K ⇒ L) ∋ F ≣ G) → (K ∋ T ≣ U) → (L ∋ app F T ≣ app G U)
beta : ∀ {K L} T U → (L ∋ app (abs K T) U ≣ substn T U)
eta : ∀ {K L} T → ((K ⇒ L) ∋ T ≣ abs K (app (weaken (skip K id) T) tvar₀))
≣-refl : ∀ {K T} → (K ∋ T ≣ T)
≣-sym : ∀ {K T U} → (K ∋ T ≣ U) → (K ∋ U ≣ T)
≣-trans : ∀ {K T U V} → (K ∋ T ≣ U) → (K ∋ U ≣ V) → (K ∋ T ≣ V)
≣⟦_⟧ : ∀ {Σ K} {T U : Typ Σ K} → (K ∋ T ≣ U) → ∀ As → T⟦ T ⟧ As ≡ T⟦ U ⟧ As
≣⟦ abs K T≣U ⟧ As = ext (λ A → ≣⟦ T≣U ⟧ (A , As))
≣⟦ app F≣G T≣U ⟧ As = apply (≣⟦ F≣G ⟧ As) (≣⟦ T≣U ⟧ As)
≣⟦ beta T U ⟧ As = substn⟦ T ⟧⟦ U ⟧ As
≣⟦ eta {K} T ⟧ As = ext (λ A → apply (weaken⟦ T ⟧ (skip K id) (A , As)) refl)
≣⟦ ≣-refl ⟧ As = refl
≣⟦ ≣-sym T≣U ⟧ As = sym (≣⟦ T≣U ⟧ As)
≣⟦ ≣-trans T≣U U≣V ⟧ As = trans (≣⟦ T≣U ⟧ As) (≣⟦ U≣V ⟧ As)
≣⟦_⟧² : ∀ {Σ K} {T U : Typ Σ K} (T≣U : K ∋ T ≣ U) {As Bs} (ℜs : Σ ∋ As ↔* Bs) →
T⟦ T ⟧² ℜs ≡ struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs)
≣⟦ abs K {L} {T} {U} T≣U ⟧² {As} {Bs} ℜs =
iext (λ A → iext (λ B → ext (λ ℜ → begin
T⟦ T ⟧² (ℜ , ℜs)
≡⟨ ≣⟦ T≣U ⟧² (ℜ , ℜs) ⟩
struct L (≣⟦ T≣U ⟧ (A , As)) (T⟦ U ⟧² (ℜ , ℜs)) (≣⟦ T≣U ⟧ (B , Bs))
≡⟨ struct-ext K L (λ A → ≣⟦ T≣U ⟧ (A , As)) (λ ℜ' → T⟦ U ⟧² (ℜ' , ℜs)) (λ B → ≣⟦ T≣U ⟧ (B , Bs)) ℜ ⟩
struct (K ⇒ L) (≣⟦ abs K T≣U ⟧ As) (T⟦ abs K U ⟧² ℜs) (≣⟦ abs K T≣U ⟧ Bs) ℜ
∎)))
≣⟦ app {K} {L} {F} {G} {T} {U} F≣G T≣U ⟧² {As} {Bs} ℜs =
begin
T⟦ app F T ⟧² ℜs
≡⟨ cong (T⟦ F ⟧² ℜs) (≣⟦ T≣U ⟧² ℜs) ⟩
T⟦ F ⟧² ℜs (struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs))
≡⟨ cong (λ X → X (struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs)))
(≣⟦ F≣G ⟧² ℜs) ⟩
struct (K ⇒ L) (≣⟦ F≣G ⟧ As) (T⟦ G ⟧² ℜs) (≣⟦ F≣G ⟧ Bs)
(struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs))
≡⟨ struct-apply K L
(≣⟦ F≣G ⟧ As) (T⟦ G ⟧² ℜs) (≣⟦ F≣G ⟧ Bs)
(≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs) ⟩
struct L (≣⟦ app F≣G T≣U ⟧ As) (T⟦ app G U ⟧² ℜs) (≣⟦ app F≣G T≣U ⟧ Bs)
∎
≣⟦ beta T U ⟧² ℜs = substn⟦ T ⟧⟦ U ⟧² ℜs
≣⟦ eta {K} {L} T ⟧² {As} {Bs} ℜs = iext (λ A → iext (λ B → ext (λ ℜ →
begin
T⟦ T ⟧² ℜs ℜ
≡⟨ cong (λ X → X ℜ) (weaken⟦ T ⟧² (skip K id) (ℜ , ℜs)) ⟩
struct (K ⇒ L)
(weaken⟦ T ⟧ (skip K id) (A , As))
(T⟦ weaken (skip K id) T ⟧² (ℜ , ℜs))
(weaken⟦ T ⟧ (skip K id) (B , Bs)) ℜ
≡⟨ struct-apply K L
(weaken⟦ T ⟧ (skip K id) (A , As))
(T⟦ weaken (skip K id) T ⟧² (ℜ , ℜs))
(weaken⟦ T ⟧ (skip K id) (B , Bs)) refl ℜ refl ⟩
struct L
(apply (weaken⟦ T ⟧ (skip K id) (A , As)) refl)
(T⟦ weaken (skip K id) T ⟧² (ℜ , ℜs) ℜ)
(apply (weaken⟦ T ⟧ (skip K id) (B , Bs)) refl)
≡⟨ struct-ext K L
(λ A → apply (weaken⟦ T ⟧ (skip K id) (A , As)) refl)
(λ ℜ → T⟦ weaken (skip K id) T ⟧² (ℜ , ℜs) ℜ)
(λ B → apply (weaken⟦ T ⟧ (skip K id) (B , Bs)) refl) ℜ ⟩
struct (K ⇒ L)
(≣⟦ eta T ⟧ As)
(T⟦ abs K (app (weaken (skip K id) T) (var zero)) ⟧² ℜs)
(≣⟦ eta T ⟧ Bs) ℜ
∎)))
≣⟦ ≣-refl ⟧² ℜs = refl
≣⟦ ≣-sym {K} {T} {U} T≣U ⟧² {As} {Bs} ℜs =
struct-sym K (≣⟦ T≣U ⟧ As) (≣⟦ T≣U ⟧ Bs) (≣⟦ T≣U ⟧² ℜs)
≣⟦ ≣-trans {K} {T} {U} {V} T≣U U≣V ⟧² {As} {Bs} ℜs =
begin
T⟦ T ⟧² ℜs
≡⟨ ≣⟦ T≣U ⟧² ℜs ⟩
struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs)
≡⟨ cong (λ X → struct K (≣⟦ T≣U ⟧ As) X (≣⟦ T≣U ⟧ Bs)) (≣⟦ U≣V ⟧² ℜs) ⟩
struct K (≣⟦ T≣U ⟧ As) (struct K (≣⟦ U≣V ⟧ As) (T⟦ V ⟧² ℜs) (≣⟦ U≣V ⟧ Bs)) (≣⟦ T≣U ⟧ Bs)
≡⟨ struct-trans K (≣⟦ T≣U ⟧ As) (≣⟦ U≣V ⟧ As) (T⟦ V ⟧² ℜs) (≣⟦ U≣V ⟧ Bs) (≣⟦ T≣U ⟧ Bs) ⟩
struct K (≣⟦ ≣-trans T≣U U≣V ⟧ As) (T⟦ V ⟧² ℜs) (≣⟦ ≣-trans T≣U U≣V ⟧ Bs)
∎
-- Variables
data Var {Σ : Kinds} {α} (T : Typ Σ (set α)) : Typs Σ → Set where
zero : ∀ {Γ} → Var T (T ∷ Γ)
suc : ∀ {β Γ} {U : Typ Σ (set β)} → Var T Γ → Var T (U ∷ Γ)
x⟦_⟧ : ∀ {Σ} {Γ : Typs Σ} {α} {T : Typ Σ (set α)} →
Var T Γ → (As : Σ⟦ Σ ⟧) → (as : Γ⟦ Γ ⟧ As) → (T⟦ T ⟧ As)
x⟦ zero ⟧ As (a , as) = a
x⟦ suc x ⟧ As (a , as) = x⟦ x ⟧ As as
x⟦_⟧² : ∀ {Σ} {Γ : Typs Σ} {α} {T : Typ Σ (set α)} (x : Var T Γ) →
∀ {As Bs} (ℜs : Σ ∋ As ↔* Bs) {as bs} →
(Γ⟦ Γ ⟧² ℜs as bs) → (T⟦ T ⟧² ℜs (x⟦ x ⟧ As as) (x⟦ x ⟧ Bs bs))
x⟦ zero ⟧² ℜs (aℜb , asℜbs) = aℜb
x⟦ suc x ⟧² ℜs (aℜb , asℜbs) = x⟦ x ⟧² ℜs asℜbs
-- Constants
data Const {Σ : Kinds} : ∀ {α} → Typ Σ (set α) → Set where
pair : ∀ {α β} → Const (Π (set α) (Π (set β) (tvar₁ ⊸ (tvar₀ ⊸ (tvar₁ ⊗ tvar₀)))))
fst : ∀ {α β} → Const (Π (set α) (Π (set β) ((tvar₁ ⊗ tvar₀) ⊸ tvar₁)))
snd : ∀ {α β} → Const (Π (set α) (Π (set β) ((tvar₁ ⊗ tvar₀) ⊸ tvar₀)))
≼-refl : Const (Π time (tvar₀ ≼ tvar₀))
≼-trans : Const (Π time (Π time (Π time ((tvar₂ ≼ tvar₁) ⊸ ((tvar₁ ≼ tvar₀) ⊸ (tvar₂ ≼ tvar₀))))))
≼-antisym : ∀ {α} → Const (Π (rset α) (Π time (Π time ((tvar₁ ≼ tvar₀) ⊸ ((tvar₀ ≼ tvar₁) ⊸ (app tvar₂ tvar₁ ⊸ app tvar₂ tvar₀))))))
≼-case : ∀ {α} → Const (Π (set α) (Π time (Π time (((tvar₁ ≼ tvar₀) ⊸ tvar₂) ⊸ (((tvar₀ ≼ tvar₁) ⊸ tvar₂) ⊸ tvar₂)))))
≤-antisym : ∀ {α} (A : RSet α) t u → True (t ≤ u) → True (u ≤ t) → A t → A u
≤-antisym A t u t≤u u≤t a with ≤-asym t u t≤u u≤t
≤-antisym A t .t _ _ a | refl = a
≤-case′ : ∀ {α} {A : Set α} {t u} → (t ≤? u) → (True (t ≤ u) → A) → (True (u ≤ t) → A) → A
≤-case′ (leq t≤u) f g = f t≤u
≤-case′ (geq u≤t) f g = g u≤t
≤-case : ∀ {α} (A : Set α) t u → (True (t ≤ u) → A) → (True (u ≤ t) → A) → A
≤-case A t u = ≤-case′ (≤-total t u)
c⟦_⟧ : ∀ {Σ} {α} {T : Typ Σ (set α)} →
Const T → (As : Σ⟦ Σ ⟧) → (T⟦ T ⟧ As)
c⟦ pair ⟧ As = λ A B a b → (a , b)
c⟦ fst ⟧ As = λ A B → proj₁
c⟦ snd ⟧ As = λ A B → proj₂
c⟦ ≼-refl ⟧ As = ≤-refl
c⟦ ≼-trans ⟧ As = ≤-trans
c⟦ ≼-antisym ⟧ As = ≤-antisym
c⟦ ≼-case ⟧ As = ≤-case
c⟦_⟧² : ∀ {Σ} {α} {T : Typ Σ (set α)} (c : Const T) →
∀ {As Bs} (ℜs : Σ ∋ As ↔* Bs) →
(T⟦ T ⟧² ℜs (c⟦ c ⟧ As) (c⟦ c ⟧ Bs))
c⟦ pair ⟧² ℜs = λ ℜ ℑ aℜb cℑd → (aℜb , cℑd)
c⟦ fst ⟧² ℜs = λ ℜ ℑ → proj₁
c⟦ snd ⟧² ℜs = λ ℜ ℑ → proj₂
c⟦ ≼-refl ⟧² ℜs = _
c⟦ ≼-trans ⟧² ℜs = _
c⟦ ≼-antisym {α} ⟧² ℜs = lemma where
lemma : ∀ {α} {A B : RSet α} (ℜ : rset α ∋ A ↔ B) →
{t u : Time} → (t≡u : t ≡ u) → {v w : Time} → (v≡w : v ≡ w) →
{t≤v : True (t ≤ v)} {u≤w : True (u ≤ w)} → ⊤ →
{v≤t : True (v ≤ t)} {w≤u : True (w ≤ u)} → ⊤ →
{a : A t} {b : B u} → ℜ t≡u a b →
ℜ v≡w (≤-antisym A t v t≤v v≤t a) (≤-antisym B u w u≤w w≤u b)
lemma ℜ {t} refl {v} refl {t≤v} {u≤w} tt {v≤t} {w≤u} tt aℜb
with irrel (t ≤ v) t≤v u≤w | irrel (v ≤ t) v≤t w≤u
lemma ℜ {t} refl {v} refl {t≤v} tt {v≤t} tt aℜb
| refl | refl with ≤-asym t v t≤v v≤t
lemma ℜ refl refl tt tt aℜb
| refl | refl | refl = aℜb
c⟦ ≼-case {α} ⟧² ℜs = lemma where
lemma : ∀ {α} {A B : Set α} (ℜ : set α ∋ A ↔ B) →
∀ {t u : Time} → (t≡u : t ≡ u) → ∀ {v w : Time} → (v≡w : v ≡ w) →
∀ {f g} → (∀ {t≤v} {u≤w} → ⊤ → ℜ (f t≤v) (g u≤w)) →
∀ {h i} → (∀ {v≤t} {w≤u} → ⊤ → ℜ (h v≤t) (i w≤u)) →
ℜ (≤-case A t v f h) (≤-case B u w g i)
lemma ℜ {t} refl {v} refl {f} {g} fℜg {h} {i} hℜi = lemma′ (≤-total t v) where
lemma′ : ∀ t≤?v → ℜ (≤-case′ t≤?v f h) (≤-case′ t≤?v g i)
lemma′ (leq t≤v) = fℜg {t≤v} {t≤v} tt
lemma′ (geq v≤t) = hℜi {v≤t} {v≤t} tt
-- Expressions
data Exp {Σ : Kinds} (Γ : Typs Σ) : ∀ {α} → Typ Σ (set α) → Set where
const : ∀ {α} {T : Typ Σ (set α)} → Const T → Exp Γ T
abs : ∀ {α β} (T : Typ Σ (set α)) {U : Typ Σ (set β)} (M : Exp (T ∷ Γ) U) → Exp Γ (T ⊸ U)
app : ∀ {α β} {T : Typ Σ (set α)} {U : Typ Σ (set β)} (M : Exp Γ (T ⊸ U)) (N : Exp Γ T) → Exp Γ U
var : ∀ {α} {T : Typ Σ (set α)} → Var T Γ → Exp Γ T
tabs : ∀ K {α} {T : Typ (K ∷ Σ) (set α)} (M : Exp (weakens (skip K id) Γ) T) → Exp Γ (Π K T)
tapp : ∀ {K α} {T : Typ (K ∷ Σ) (set α)} → Exp Γ (Π K T) → ∀ U → Exp Γ (substn T U)
eq : ∀ {α T U} → (set α ∋ T ≣ U) → (Exp Γ T) → (Exp Γ U)
ctxt : ∀ {Σ Γ α T} → Exp {Σ} Γ {α} T → Typs Σ
ctxt {Σ} {Γ} M = Γ
M⟦_⟧ : ∀ {Σ} {Γ : Typs Σ} {α} {T : Typ Σ (set α)} →
Exp Γ T → (As : Σ⟦ Σ ⟧) → (as : Γ⟦ Γ ⟧ As) → (T⟦ T ⟧ As)
M⟦ const c ⟧ As as = c⟦ c ⟧ As
M⟦ abs T M ⟧ As as = λ a → M⟦ M ⟧ As (a , as)
M⟦ app M N ⟧ As as = M⟦ M ⟧ As as (M⟦ N ⟧ As as)
M⟦ var x ⟧ As as = x⟦ x ⟧ As as
M⟦ tabs K M ⟧ As as = λ A →
M⟦ M ⟧ (A , As) (weakens⟦ ctxt (tabs K M) ⟧ (skip K id) (A , As) as)
M⟦ tapp {T = T} M U ⟧ As as =
cast (substn⟦ T ⟧⟦ U ⟧ As) (M⟦ M ⟧ As as (T⟦ U ⟧ As))
M⟦ eq T≣U M ⟧ As as = cast (≣⟦ T≣U ⟧ As) (M⟦ M ⟧ As as)
M⟦_⟧² : ∀ {Σ} {Γ : Typs Σ} {α} {T : Typ Σ (set α)} (M : Exp Γ T) →
∀ {As Bs} (ℜs : Σ ∋ As ↔* Bs) {as bs} →
(Γ⟦ Γ ⟧² ℜs as bs) → (T⟦ T ⟧² ℜs (M⟦ M ⟧ As as) (M⟦ M ⟧ Bs bs))
M⟦ const c ⟧² ℜs asℜbs = c⟦ c ⟧² ℜs
M⟦ abs T M ⟧² ℜs asℜbs = λ aℜb → M⟦ M ⟧² ℜs (aℜb , asℜbs)
M⟦ app M N ⟧² ℜs asℜbs = M⟦ M ⟧² ℜs asℜbs (M⟦ N ⟧² ℜs asℜbs)
M⟦ var x ⟧² ℜs asℜbs = x⟦ x ⟧² ℜs asℜbs
M⟦ tabs K M ⟧² ℜs asℜbs = λ ℜ →
M⟦ M ⟧² (ℜ , ℜs) (weakens⟦ ctxt (tabs K M) ⟧² (skip K id) (ℜ , ℜs) asℜbs)
M⟦ tapp {T = T} M U ⟧² ℜs asℜbs =
struct-cast (T⟦ substn T U ⟧² ℜs) (substn⟦ T ⟧⟦ U ⟧ _) (substn⟦ T ⟧⟦ U ⟧ _)
(cast² (substn⟦ T ⟧⟦ U ⟧² ℜs) (M⟦ M ⟧² ℜs asℜbs (T⟦ U ⟧² ℜs)))
M⟦ eq {α} {T} {U} T≣U M ⟧² {As} {Bs} ℜs asℜbs =
struct-cast (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ As) (≣⟦ T≣U ⟧ Bs) (cast² (≣⟦ T≣U ⟧² ℜs) (M⟦ M ⟧² ℜs asℜbs))
-- Types with a chosen free world variable
_∷ʳ_ : Kinds → Kind → Kinds
[] ∷ʳ K = K ∷ []
(T ∷ Σ) ∷ʳ K = T ∷ (Σ ∷ʳ K)
TVar+ : Kind → Kinds → Set
TVar+ K Σ = TVar K (Σ ∷ʳ rset₀)
Typ+ : Kinds → Kind → Set
Typ+ Σ = Typ (Σ ∷ʳ rset₀)
wvar : ∀ Σ → TVar+ rset₀ Σ
wvar [] = zero
wvar (K ∷ Σ) = suc (wvar Σ)
world : ∀ {Σ} → Typ+ Σ rset₀
world {Σ} = var (wvar Σ)
World : Time → Set
World t = ⊤
taut : ∀ {Σ α} → Typ+ Σ (rset α ⇒ set α)
taut {Σ} {α} = abs (rset α) (Π time
(app (world {time ∷ rset α ∷ Σ}) tvar₀ ⊸ app tvar₁ tvar₀))
-- Surface types
data STyp : Kind → Set where
⟨_⟩ : ∀ {α} → STyp (set α) → STyp (rset α)
[_] : ∀ {α} → STyp (rset α) → STyp (set α)
_⊠_ _↦_ : ∀ {α β} → STyp (set α) → STyp (set β) → STyp (set (α ⊔ β))
_∧_ _⇒_ : ∀ {α β} → STyp (rset α) → STyp (rset β) → STyp (rset (α ⊔ β))
□ : ∀ {α} → STyp (rset α) → STyp (rset α)
⟪_⟫ : ∀ {K} → STyp K → Typ+ [] K
⟪ ⟨ T ⟩ ⟫ = app always ⟪ T ⟫
⟪ [ T ] ⟫ = app (taut {[]}) ⟪ T ⟫
⟪ T ⊠ U ⟫ = ⟪ T ⟫ ⊗ ⟪ U ⟫
⟪ T ↦ U ⟫ = ⟪ T ⟫ ⊸ ⟪ U ⟫
⟪ T ∧ U ⟫ = ⟪ T ⟫ ⊗ʳ ⟪ U ⟫
⟪ T ⇒ U ⟫ = ⟪ T ⟫ ⊸ʳ ⟪ U ⟫
⟪ □ T ⟫ = tvar₀ ⊵ ⟪ T ⟫
T⟪_⟫ : ∀ {K} → STyp K → K⟦ K ⟧
T⟪ T ⟫ = T⟦ ⟪ T ⟫ ⟧ (World , tt)
-- Signals of T are iso to □ T
Signal : ∀ {α} → RSet α → RSet α
Signal A s = ∀ t → True (s ≤ t) → A t
sig : ∀ {α} (T : STyp (rset α)) s →
T⟪ □ T ⟫ s → Signal T⟪ T ⟫ s
sig T s σ t s≤t = σ t s≤t _
sig⁻¹ : ∀ {α} (T : STyp (rset α)) s →
Signal T⟪ T ⟫ s → T⟪ □ T ⟫ s
sig⁻¹ T s σ t s≤t _ = σ t s≤t
sig-iso : ∀ {α} (T : STyp (rset α)) s σ →
(sig T s (sig⁻¹ T s σ) ≡ σ)
sig-iso T s σ = refl
sig-iso⁻¹ : ∀ {α} (T : STyp (rset α)) s σ →
(sig⁻¹ T s (sig T s σ) ≡ σ)
sig-iso⁻¹ T s σ = refl
-- Signal functions from T to U are iso to □ T ⇒ □ U
SF : ∀ {α β} → RSet α → RSet β → RSet (α ⊔ β)
SF A B s = Signal A s → Signal B s
sf : ∀ {α β} (T : STyp (rset α)) (U : STyp (rset β)) s →
T⟪ □ T ⇒ □ U ⟫ s → SF T⟪ T ⟫ T⟪ U ⟫ s
sf T U s f σ = sig U s (f (sig⁻¹ T s σ))
sf⁻¹ : ∀ {α β} (T : STyp (rset α)) (U : STyp (rset β)) s →
SF T⟪ T ⟫ T⟪ U ⟫ s → T⟪ □ T ⇒ □ U ⟫ s
sf⁻¹ T U s f σ = sig⁻¹ U s (f (sig T s σ))
sf-iso : ∀ {α β} (T : STyp (rset α)) (U : STyp (rset β)) s f →
(sf T U s (sf⁻¹ T U s f) ≡ f)
sf-iso T U s f = refl
sf-iso⁻¹ : ∀ {α β} (T : STyp (rset α)) (U : STyp (rset β)) s f →
(sf⁻¹ T U s (sf T U s f) ≡ f)
sf-iso⁻¹ T U s f = refl
-- Causality
mutual
_at_⊨_≈[_]_ : ∀ {α} (T : STyp (rset α)) s → T⟪ T ⟫ s → Time → T⟪ T ⟫ s → Set α
⟨ T ⟩ at s ⊨ a ≈[ u ] b = T ⊨ a ≈[ u ] b
(T ∧ U) at s ⊨ (a , b) ≈[ u ] (c , d) = (T at s ⊨ a ≈[ u ] c) × (U at s ⊨ b ≈[ u ] d)
(T ⇒ U) at s ⊨ f ≈[ u ] g = ∀ a b → (T at s ⊨ a ≈[ u ] b) → (U at s ⊨ f a ≈[ u ] g b)
□ T at s ⊨ σ ≈[ u ] τ = (∀ t s≤t → True (t ≤ u) → (T at t ⊨ σ t s≤t _ ≈[ u ] τ t s≤t _))
_⊨_≈[_]_ : ∀ {α} → (T : STyp (set α)) → T⟪ T ⟫ → Time → T⟪ T ⟫ → Set α
[ T ] ⊨ σ ≈[ u ] τ = ∀ s → True (s ≤ u) → (T at s ⊨ σ s _ ≈[ u ] τ s _)
(T ⊠ U) ⊨ (a , b) ≈[ u ] (c , d) = (T ⊨ a ≈[ u ] c) × (U ⊨ b ≈[ u ] d)
(T ↦ U) ⊨ f ≈[ u ] g = ∀ a b → (T ⊨ a ≈[ u ] b) → (U ⊨ f a ≈[ u ] g b)
Causal : ∀ {α β} (T : STyp (set α)) (U : STyp (set β)) → T⟪ T ↦ U ⟫ → Set (α ⊔ β)
Causal T U f = ∀ u σ τ →
(T ⊨ σ ≈[ u ] τ) → (U ⊨ f σ ≈[ u ] f τ)
-- Parametricity implies causality
ℜ[_] : Time → (rset o ∋ World ↔ World)
ℜ[ u ] {t} s≡t tt tt = True (t ≤ u)
mutual
ℜ-impl-≈_at : ∀ {α} (T : STyp (rset α)) s u → True (s ≤ u) → ∀ a b →
(T⟦ ⟪ T ⟫ ⟧² (ℜ[ u ] , tt) refl a b) → (T at s ⊨ a ≈[ u ] b)
ℜ-impl-≈ ⟨ T ⟩ at s u s≤u a b aℜb
= ℜ-impl-≈ T u a b aℜb
ℜ-impl-≈ (T ∧ U) at s u s≤u (a , b) (c , d) (aℜc , bℜd)
= (ℜ-impl-≈ T at s u s≤u a c aℜc , ℜ-impl-≈ U at s u s≤u b d bℜd)
ℜ-impl-≈ (T ⇒ U) at s u s≤u f g fℜg
= λ a b a≈b → ℜ-impl-≈ U at s u s≤u (f a) (g b) (fℜg (≈-impl-ℜ T at s u s≤u a b a≈b))
ℜ-impl-≈_at (□ T) s u s≤u σ τ σℜτ = λ t s≤t t≤u →
ℜ-impl-≈ T at t u t≤u (σ t s≤t _) (τ t s≤t _)
(σℜτ refl tt (λ {r} _ _ {r≤t} _ → ≤-trans r t u r≤t t≤u))
≈-impl-ℜ_at : ∀ {α} (T : STyp (rset α)) s u → True (s ≤ u) → ∀ a b →
(T at s ⊨ a ≈[ u ] b) → (T⟦ ⟪ T ⟫ ⟧² (ℜ[ u ] , tt) refl a b)
≈-impl-ℜ ⟨ T ⟩ at s u s≤u a b a≈b
= ≈-impl-ℜ T u a b a≈b
≈-impl-ℜ (T ∧ U) at s u s≤u (a , b) (c , d) (a≈c , b≈d)
= (≈-impl-ℜ T at s u s≤u a c a≈c , ≈-impl-ℜ U at s u s≤u b d b≈d)
≈-impl-ℜ (T ⇒ U) at s u s≤u f g f≈g
= λ {a} {b} aℜb → ≈-impl-ℜ U at s u s≤u (f a) (g b) (f≈g a b (ℜ-impl-≈ T at s u s≤u a b aℜb))
≈-impl-ℜ (□ T) at s u s≤u σ τ σ≈τ = lemma where
lemma : T⟦ ⟪ □ T ⟫ ⟧² (ℜ[ u ] , tt) {s} refl σ τ
lemma {t} refl {s≤t} {s≤t′} tt kℜk′ with irrel (s ≤ t) s≤t s≤t′
lemma {t} refl {s≤t} tt kℜk′ | refl
= ≈-impl-ℜ T at t u t≤u (σ t s≤t _) (τ t s≤t _) (σ≈τ t s≤t t≤u) where
t≤u = kℜk′ {t} refl {s≤t} {s≤t} tt {≤-refl t} {≤-refl t} tt
ℜ-impl-≈ : ∀ {α} (T : STyp (set α)) (u : Time) (a b : T⟪ T ⟫) →
(T⟦ ⟪ T ⟫ ⟧² (ℜ[ u ] , tt) a b) → (T ⊨ a ≈[ u ] b)
ℜ-impl-≈ (T ⊠ U) u (a , b) (c , d) (aℜc , bℜd)
= (ℜ-impl-≈ T u a c aℜc , ℜ-impl-≈ U u b d bℜd)
ℜ-impl-≈ (T ↦ U) u f g fℜg
= λ a b a≈b → ℜ-impl-≈ U u (f a) (g b) (fℜg (≈-impl-ℜ T u a b a≈b))
ℜ-impl-≈ [ T ] u σ τ σℜτ
= λ s s≤u → ℜ-impl-≈ T at s u s≤u (σ s _) (τ s _) (σℜτ refl s≤u)
≈-impl-ℜ : ∀ {α} (T : STyp (set α)) (u : Time) (a b : T⟪ T ⟫) →
(T ⊨ a ≈[ u ] b) → (T⟦ ⟪ T ⟫ ⟧² (ℜ[ u ] , tt) a b)
≈-impl-ℜ (T ⊠ U) u (a , b) (c , d) (a≈c , b≈d)
= (≈-impl-ℜ T u a c a≈c , ≈-impl-ℜ U u b d b≈d)
≈-impl-ℜ (T ↦ U) u f g f≈g
= λ {a} {b} aℜb → ≈-impl-ℜ U u (f a) (g b) (f≈g a b (ℜ-impl-≈ T u a b aℜb))
≈-impl-ℜ [ T ] u σ τ σ≈τ = lemma where
lemma : T⟦ ⟪ [ T ] ⟫ ⟧² (ℜ[ u ] , tt) σ τ
lemma {s} refl s≤u = ≈-impl-ℜ T at s u s≤u (σ s _) (τ s _) (σ≈τ s s≤u)
-- Every F-omega function is causal
causality : ∀ {α β} (T : STyp (set α)) (U : STyp (set β)) (M : Exp [] ⟪ T ↦ U ⟫) →
Causal T U (M⟦ M ⟧ (World , tt) tt)
causality T U M u
= ℜ-impl-≈ (T ↦ U) u
(M⟦ M ⟧ (World , tt) tt)
(M⟦ M ⟧ (World , tt) tt)
(M⟦ M ⟧² (ℜ[ u ] , _) tt)
|
programs/oeis/014/A014979.asm | neoneye/loda | 22 | 244862 | <reponame>neoneye/loda<gh_stars>10-100
; A014979: Numbers that are both triangular and pentagonal.
; 0,1,210,40755,7906276,1533776805,297544793910,57722156241751,11197800766105800,2172315626468283465,421418033734080886426,81752926228785223683195,15859646270350599313653420
mul $0,2
trn $0,1
seq $0,157089 ; Consider all Consecutive Integer Pythagorean septuples (X, X+1, X+2, X+3, Z-2, Z-1, Z) ordered by increasing Z; sequence gives Z values.
div $0,24
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_1930.asm | ljhsiun2/medusa | 9 | 16996 | .global s_prepare_buffers
s_prepare_buffers:
ret
.global s_faulty_load
s_faulty_load:
push %r14
push %r8
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
// Load
lea addresses_PSE+0xa0f9, %r8
nop
nop
nop
sub %r14, %r14
mov (%r8), %bx
nop
nop
add $62330, %r9
// Load
lea addresses_WC+0x1f2f9, %r14
nop
add $34260, %rsi
movb (%r14), %bl
nop
xor $48700, %r14
// REPMOV
lea addresses_RW+0x18459, %rsi
lea addresses_D+0x1c8ff, %rdi
nop
nop
and %r9, %r9
mov $38, %rcx
rep movsw
nop
xor %rsi, %rsi
// REPMOV
lea addresses_D+0x162f9, %rsi
lea addresses_WC+0x2af9, %rdi
cmp %r8, %r8
mov $32, %rcx
rep movsb
nop
nop
cmp %r9, %r9
// Faulty Load
lea addresses_PSE+0x192f9, %rdi
nop
add %rax, %rax
vmovups (%rdi), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $1, %xmm0, %r9
lea oracles, %rdi
and $0xff, %r9
shlq $12, %r9
mov (%rdi,%r9,1), %r9
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r8
pop %r14
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 9, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 9, 'same': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'}
{'src': {'congruent': 3, 'same': False, 'type': 'addresses_RW'}, 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_D'}, 'OP': 'REPM'}
{'src': {'congruent': 8, 'same': False, 'type': 'addresses_D'}, 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_WC'}, 'OP': 'REPM'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_PSE'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
other.7z/SFC.7z/SFC/ソースデータ/ゼルダの伝説神々のトライフォース/日本_Ver3/asm/zel_bgwt.asm | prismotizm/gigaleak | 0 | 104066 | Name: zel_bgwt.asm
Type: file
Size: 294883
Last-Modified: '2016-05-13T04:36:32Z'
SHA-1: 03C4E56F31703339D41679A7829FFCFA6B7876B0
Description: null
|
src/rules_process.asm | mvdhout1992/ts-patches | 33 | 175328 | ;
; Implementation of RulesClass::Process in ASM to allow additional section loading.
;
; Author: CCHyper (13.01.2020)
;
%include "macros/patch.inc"
%include "macros/datatypes.inc"
%include "macros/string.inc"
%include "TiberianSun.inc"
sstring str_INI_Weapons, "Weapons"
%define INIClass_EntryCount 0x004DC6A0
%define INIClass_GetEntry 0x004DC8D0
%define INIClass_GetString 0x004DDF60
%define WeaponTypeClass_FindOrMake 0x006817E0
; arg_0 = INIClass instance.
sfunction RulesClass_WeaponTypes
sub esp, 0x20 ; stack size.
push ebx
push esi
push edi
mov edi, [esp+0x30] ; arg_0
push str_INI_Weapons
mov ecx, edi
call INIClass_EntryCount
mov ebx, eax ; entry count stored in EBX.
xor esi, esi
test ebx, ebx
jle .out
.loop:
lea eax, [esp+0x0C] ; buffer[32]
push 32 ; buffer size.
push eax
push 0x0074CC5C ; NULL
push esi
push str_INI_Weapons
mov ecx, edi
call INIClass_GetEntry
push eax
push str_INI_Weapons
mov ecx, edi
call INIClass_GetString
test eax, eax
jz .can_loop
lea ecx, [esp+0x0C] ; buffer[32]
call WeaponTypeClass_FindOrMake
.can_loop:
inc esi
cmp esi, ebx
jl .loop
.out:
xor eax, eax
pop edi
test ebx, ebx
pop esi
pop ebx
setnle al
add esp, 0x20
retn 4
hack 0x005C6710
RulesClass_Process_patch_1:
push ebx
push ebp
push esi
mov esi, [esp+0x10]
push edi
; ESI = INIClass instance.
; EBP = 'this' pointer.
mov ebp, ecx
push esi
mov ecx, ebp
call 0x005C9530 ; RulesClass::Colors()
push esi
mov ecx, ebp
call 0x005CC490 ; RulesClass::Houses()
push esi
mov ecx, ebp
call 0x005CC5E0 ; RulesClass::Sides()
push esi
mov ecx, ebp
call 0x005CC9D0 ; RulesClass::OverlayTypes
push esi
mov ecx, ebp
call RulesClass_WeaponTypes
push esi
mov ecx, ebp
call 0x005CC780 ; RulesClass::SuperWeaponTypes
push esi
mov ecx, ebp
call 0x005CCB20 ; RulesClass::Warheads()
push esi
mov ecx, ebp
call 0x005CC960 ; RulesClass::SmudgeTypes
push esi
mov ecx, ebp
call 0x005CC860 ; RulesClass::TerrainTypes
push esi
mov ecx, ebp
call 0x005CC7F0 ; RulesClass::BuildingTypes
push esi
mov ecx, ebp
call 0x005CC500 ; RulesClass::VehicleTypes
push esi
mov ecx, ebp
call 0x005CC570 ; RulesClass::AircraftTypes()
push esi
mov ecx, ebp
call 0x005CC420 ; RulesClass::InfantryTypes()
push esi
mov ecx, ebp
call 0x005CCA40 ; RulesClass::Animations()
push esi
mov ecx, ebp
call 0x005CCAB0 ; RulesClass::VoxelAnims()
push esi
mov ecx, ebp
call 0x005CCB90 ; RulesClass::Particles()
push esi
mov ecx, ebp
call 0x005CCC00 ; RulesClass::ParticleSystems()
push esi
mov ecx, ebp
call 0x005CE040 ; RulesClass::JumpjetControls()
push esi
mov ecx, ebp
call 0x005CC260 ; RulesClass::MultiplayerDefualts()
push esi
mov ecx, ebp
call 0x005CCC70 ; RulesClass::AI()
push esi
mov ecx, ebp
call 0x005CDCA0 ; RulesClass::Powerups()
push esi
mov ecx, ebp
call 0x005CDDD0 ; RulesClass::Land_Types()
push esi
mov ecx, ebp
call 0x005CDEB0 ; RulesClass::IQ()
push esi
mov ecx, ebp
call 0x005C9630 ; RulesClass::General()
push esi
mov ecx, ebp
call 0x005D1800 ; RulesClass::Objects()
push esi
mov ecx, ebp
call 0x005CC3D0 ; RulesClass::Maximums()
push esi
mov ecx, ebp
call 0x005CE190 ; RulesClass::Difficulty()
push esi
mov ecx, ebp
call 0x005C8600 ; RulesClass::CrateRules()
push esi
mov ecx, ebp
call 0x005C8850 ; RulesClass::CombatDamage()
push esi
mov ecx, ebp
call 0x005C6CF0 ; RulesClass::AudioVisual()
push esi
mov ecx, ebp
call 0x005C6A60 ; RulesClass::SpecialWeapons()
mov ecx, esi
call 0x00644EB0 ; TiberiumClass::Process_INI()
pop edi
pop esi
pop ebp
pop ebx
retn 4
|
main.asm | svatoun/dcc-fndecoder | 0 | 5295 | <gh_stars>0
; original File = dcc_func_wagon.HEX
processor 12F629
#include "p12f629.inc"
__config 0x3FC4
; _CPD_OFF & _CP_OFF & _BODEN_ON & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF
; & _INTRC_OSC_NOCLKOUT
; EEPROM-Data
Org 0x2100
DE 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x0D ; ........
DE 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF ; ........
DE 0xC0, 0x64, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ; .d......
DE 0xFF, 0xFF, 0xFF, 0xFF, 0x06, 0xFF, 0xFF, 0xFF ; ........
DE 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F ; ........
DE 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ; ........
DE 0xFF, 0x0C, 0x0C, 0x0C, 0x0C, 0xFF, 0xFF, 0xFF ; ........
DE 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ; ........
DE 0x01, 0x02, 0x04, 0x04, 0x08, 0x08, 0x00, 0x00 ; ........
DE 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ; ........
DE 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ; ........
DE 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ; ........
DE 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ; ........
DE 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ; ........
DE 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ; ........
DE 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ; ........
#define DCCIN GPIO,2 ; DCC input pin
#define CV_ANALOG_ENABLE CV29,2
#define CV_SPEED_28 CV29,1
#define PACKET_READY LRAM_0x5B,0 ; received packet ready
#define IGNORE_CV_FLAG LRAM_0x5B,1
#define RESCV_FLAG LRAM_0x5B,2 ; received packet ready
#define FOUR_BYTE LRAM_0x5B,3 ; four-byte packet ???
#define SRVMODE_FLAG LRAM_0x5B,4 ; service mode enabled
#define SRV2X_FLAG LRAM_0x5B,6 ; one service-mode packet received
#define RESET_FLAG LRAM_0x5B,7 ; reset packet received
#define DCC_HIGH_FLAG LRAM_0x5C,0 ; Polarity A; exclusive with Polarity B
#define DCC_LOW_FLAG LRAM_0x5C,1 ; Polarity B
#define FLASH_A_STATE LRAM_0x5C,3 ; state of flash "A"
#define FLASH_B_STATE LRAM_0x5C,4 ; state of flash "B"
#define CURRENT_DIR SPEED,7 ; current effective direction. 1 - forward, 0 - backward.
#define FN_DIRLIGHT_BIT FSTATE,4
Load_Osccal equ 0x3ff
; RAM-Variable
INT_W equ 0x20 ; save during INTR
INT_STAT equ 0x21 ; save during INTR
INT_FSR equ 0x22 ; save during INTR
INT_READ_BYTE equ 0x23
INT_XOR_BYTE equ 0x24
DCCSTATE equ 0x25
INT_BUF_PTR equ 0x26
INT_BIT_COUNT equ 0x27
AnalogTimeCounter equ 0x28
Maybe_PAGEREG equ 0x2A
DATA1 equ 0x2B
DATA2 equ 0x2C
DATA3 equ 0x2D
DATA4 equ 0x2E
DATA5 equ 0x2F
COMMAND1 equ 0x31
COMMAND2 equ 0x32
COMMAND3 equ 0x33
SPEED equ 0x34 ; Bit 0 is insignificant, AND to 0x7E to get speed
FSTATE equ 0x35 ; Functions 0-4. Bits 0..3 are assigned to F1..F4. Bit 4 is F0 (FL/FR)
LRAM_0x36 equ 0x36 ; Functions 5-12
LRAM_0x37 equ 0x37 ; Functions 13-20
LRAM_0x38 equ 0x38 ; Functions 21-28
LRAM_0x39 equ 0x39
LRAM_0x3A equ 0x3A
LRAM_0x3B equ 0x3B
BRIGHT_FA equ 0x3C ; "nejaky counter" s FA
BRIGHT_FB equ 0x3D ; "nejaky counter" s FB
BRIGHT_FC equ 0x3E ; "nejaky counter" s FC
BRIGHT_FD equ 0x3F ; "nejaky counter" s FD
BRIGHT_BASE equ BRIGHT_FA
LRAM_0x40 equ 0x40
INCREMENT equ 0x41
FLASH_A_COUNTER equ 0x42
FLASH_B_COUNTER equ 0x43
; 0x44, 6 = FA OFF
; 0x44, 7 = FA ON
; lower 4 bits of 0x44 = state for dispatch (whatever it means)
; 0x45, 6 = FB OFF
; 0x45, 7 = FB ON
; 0x46, 6 = FC OFF
; 0x46, 7 = FC ON
; 0x47, 6 = FD OFF
; 0x47, 7 = FD ON
TODO_FA equ 0x44
TODO_FB equ 0x45
TODO_FC equ 0x46
TODO_FD equ 0x47
TODO_BASE equ TODO_FA
UNUSED_FE equ 0x48
UNUSED_FF equ 0x49
UNUSED_FG equ 0x4A
UNUSED_FI equ 0x4B
UNUSED_FJ equ 0x4C
UNUSED_FK equ 0x4D
UNUSED_FL equ 0x4E
CV_INDEX equ 0x4F ; temporary; CV index during lock check
CV1 equ 0x50
CV17 equ 0x51
CV18 equ 0x52
CV29 equ 0x53
CV15 equ 0x54
CV16 equ 0x55
TEMP_VAR equ 0x59 ; temporary variable, saving intermediate results
FUNCTION_ID equ 0x5A
LRAM_0x5B equ 0x5B
LRAM_0x5C equ 0x5C
EEDATA0 equ 0x5E
EEPROM_WRITE_START equ 0x5F
; EEPROM contains CV values, starting from 0 = CV1.
EEPROM_CV1 equ 0x00
EEPROM_CV13 equ 0x0C
EEPROM_CV15 equ 0x0E
EEPROM_CV16 equ 0x0F
EEPROM_CV17 equ 0x10
EEPROM_CV18 equ 0x11
EEPROM_CV29 equ 0x1C
EEPROM_CV37 equ 0x24
EEPROM_CV50 equ 0x31
EEPROM_CV120 equ 0x40
EEPROM_CV124 equ 0x44
EEPROM_OUTCONF_BASE equ EEPROM_CV120
; Program
Org 0x0000
; Reset-Vector
CLRF STATUS
CLRF INTCON
CLRF PCLATH ; !!Bank Program-Page-Select
GOTO INIT
; Interrupt-Vector
Interrupt:
MOVWF INT_W ; 1
SWAPF STATUS,W ; 2
CLRF STATUS ; 3
MOVWF INT_STAT ; 4
BTFSC INTCON,T0IF ; 5
GOTO In_LongBit ; 6,7
MOVLW 0xB3 ; (256 - 77us): between 64us (one) and 90us (zero);8
MOVWF TMR0 ; !!Bank!! TMR0 - OPTION_REG
MOVF DCCSTATE,W
ADDWF PCL,F ; !!Program-Counter-Modification
GOTO IN_StartPreamble ; 0x00
GOTO IN_PreambleBit ; 0x01 reading up to 0x16 short changes = 11 preamble bits
GOTO In_ExitInterrupt ; 0x02 ignore following longs, regardless of high/low
GOTO IN_ResetReader ; 0x03 bail out on malformed start/stop bit (0/1)
GOTO IN_OneFirst ; 0x04 dec cnt, shift to 6. On terminal bit, transition to 7
GOTO IN_ResetReader ; 0x05 reset, first change = 0, 2nd change = 1, invalid bit.
GOTO IN_ShiftBit_1 ; 0x06 shit bit, go to 4
GOTO IN_TerminalBitOK ; 0x07 terminal bit received
In_LongBit:
MOVLW 0xB3 ; b'10110011' d'179'
MOVWF TMR0 ; 77us: between 64us (one) and 90us (zero);8
MOVF DCCSTATE,W
ADDWF PCL,F ; !!Program-Counter-Modification
GOTO In_ExitInterrupt ; 0x00 looking for preamble
GOTO IN_ResetReader ; 0x01 short preamble, reset
GOTO IN_StartBitFirst ; 0x02 start bit, 1st change
GOTO IN_StartBitSecond ; 0x03 start bit, complete. shift to state 4, still cnt = 9
GOTO IN_ZeroFirst ; 0x04 0, first change. shift to state 5, dec cnt, don't store bit, but store byte if complete
GOTO IN_ShiftBit_0 ; 0x05 0, complete. shift to state 4, shift bit.
GOTO IN_ResetReader ; 0x06 reset, first change = 1, 2nd change = 0, invalid bit.
GOTO IN_ResetReader ; 0x07 reset, invalid terminal bit (1/0)
IN_ResetReader:
CLRF DCCSTATE
In_ExitInterrupt:
MOVF GPIO,W ; !!Bank!! GPIO - TRISIO
BCF INTCON,GPIF
BCF INTCON,T0IF
SWAPF INT_STAT,W
MOVWF STATUS
SWAPF INT_W,F
SWAPF INT_W,W
RETFIE
IN_StartPreamble:
MOVLW 0x16 ; b'00010110' d'022'
MOVWF INT_BIT_COUNT
INCF DCCSTATE,F
GOTO In_ExitInterrupt
IN_OneFirst:
BSF DCCSTATE,1 ; DCCSTATE = 6
IN_PreambleBit:
DECFSZ INT_BIT_COUNT,F
GOTO In_ExitInterrupt
IN_StartBitSecond:
IN_PreambleOK:
INCF DCCSTATE,F
GOTO In_ExitInterrupt
IN_StartBitFirst:
; Start bit (0) was already received. The next bit will be MSB of the 1st data byte.
MOVLW DATA1 ; 2B, 2C, 2D, 2E, 2F - 5 byte buffer b'00101011' d'043' "+"
MOVWF INT_BUF_PTR
CLRF INT_XOR_BYTE
GOTO IN_ExpectStartBitEnd
; This routine is ALSO called when the 1st change of 9th bit (separator) is read.
; In the case a regular bit first 0 change is read, it's just ignored/accepted,
; store is done in 2nd change (verification). If the bit is final (start/stop),
; the result byte is stored in buffer and XORed.
IN_ZeroFirst:
INCF DCCSTATE,F ; = 5
DECFSZ INT_BIT_COUNT,F
GOTO In_ExitInterrupt
BTFSS INT_BUF_PTR,3 ; buffer is 2B .. 2F, 5 byte
GOTO IN_ResetReader
MOVF FSR,W
MOVWF INT_FSR
MOVF INT_BUF_PTR,W
MOVWF FSR
MOVF INT_READ_BYTE,W
MOVWF INDF
XORWF INT_XOR_BYTE,F
INCF INT_BUF_PTR,F
MOVF INT_FSR,W
MOVWF FSR
IN_ExpectStartBitEnd:
MOVLW 0x09 ; b'00001001' d'009'
MOVWF INT_BIT_COUNT
MOVLW 0x03 ; b'00000011' d'003'
MOVWF DCCSTATE
GOTO In_ExitInterrupt
IN_ShiftBit_0:
BCF STATUS,C
RLF INT_READ_BYTE,F
DECF DCCSTATE,F
GOTO In_ExitInterrupt
IN_ShiftBit_1: ; Shifts a bit into the current byte
BSF STATUS,C
RLF INT_READ_BYTE,F
BCF DCCSTATE,1
GOTO In_ExitInterrupt
Bit_GetValue:
ADDWF PCL,F ; !!Program-Counter-Modification
RETLW 0x01 ; b'00000001' d'001'
RETLW 0x02 ; b'00000010' d'002'
RETLW 0x04 ; b'00000100' d'004'
RETLW 0x08 ; b'00001000' d'008'
RETLW 0x10 ; b'00010000' d'016'
RETLW 0x20 ; b'00100000' d'032' " "
RETLW 0x40 ; b'01000000' d'064' "@"
RETLW 0x80 ; b'10000000' d'128'
Process_Command:
SWAPF COMMAND1,W
MOVWF TEMP_VAR
RRF TEMP_VAR,W
ANDLW 0x07 ; b'00000111' d'007'
ADDWF PCL,F ; !!Program-Counter-Modification
RETURN ; 0x00 - Decoder operation, Consist control. Ignore ??
GOTO LADR_0x013C ; 0x01 - Advanced operation
GOTO LADR_0x0152 ; 0x02 - Speed and Direction reverse
GOTO LADR_0x0145 ; 0x03 - Speed and Direction forward
GOTO Function_Group1 ; 0x04 - Function group 1
GOTO Function_Group2 ; 0x05 - Function group 2
GOTO Function_Extended ; 0x06 - Functions 13-28
GOTO Command_POM ; 0x07 - POM
; OPTIMIZATION: can save bytes; the following checks if LRAM_0x40 < 4, if so,
; it jumps with the value to Read_Effect; otherwise just returns the value.
LADR_0x006A:
MOVF LRAM_0x40,W
ADDWF PCL,F ; !!Program-Counter-Modification ADDLW 0xFC
GOTO Read_Effect ; 0x00 BTFSS STATUS,C
GOTO Read_Effect ; 0x01 GOTO Read_Effect
GOTO Read_Effect ; 0x02 ADDLW (256 -4 - 12)
GOTO Read_Effect ; 0x03 BTFSS STATUS,C
RETURN ; 0x04 RETURN
RETURN ; 0x05 ; MOVF LRAM_0x40,W at Read_Effect
RETURN ; 0x06 ; save1
RETURN ; 0x07 ; save2
RETURN ; 0x08 ; save3
RETURN ; 0x09 ; save4
RETURN ; 0x0a ; save5
RETURN ; 0x0b ; save6
; 14 instructions
; 0x0c
MOVLW 0xFF ; NOTE: 0xFF will be INCREMENTED aftr return to 0.
MOVWF LRAM_0x40
DECFSZ FLASH_A_COUNTER,F
GOTO FlashB
MOVLW 0x31 ; CV 50 - Flash "A" active period
BTFSC FLASH_A_STATE
MOVLW 0x32 ; CV 51 - Flash "A" inactive period
CALL EE_Read
MOVWF FLASH_A_COUNTER
MOVLW 0x08 ;
XORWF LRAM_0x5C,F ; Change flash phase
FlashB:
DECFSZ FLASH_B_COUNTER,F
RETURN
MOVLW 0x33 ; CV 52 - Flash "B" active period
BTFSC FLASH_B_STATE
MOVLW 0x34 ; CV 52 - Flash "B" inactive period
CALL EE_Read
MOVWF FLASH_B_COUNTER
MOVLW 0x10 ;
XORWF LRAM_0x5C,F
RETURN
Read_Effect:
ADDLW 0x20 ; b'00100000' d'032' " "
CALL EE_Read
ANDLW 0x07 ; b'00000111' d'007'
ADDWF PCL,F ; !!Program-Counter-Modification
GOTO Effect_Incandesc
GOTO Effect_Fluor
GOTO Effect_Fluor_Broken
GOTO Effect_Fluor_EOL
GOTO Effect_FlashA
GOTO Effect_FlashA_Neg
GOTO Effect_FlashB
GOTO Effect_FlashB_Neg
IN_TerminalBitOK:
MOVF INT_READ_BYTE,W
XORWF INT_XOR_BYTE,F
BTFSS STATUS,Z
GOTO IN_ResetReader ; reset, invalid checksum
BTFSS DCCIN ; WTF ??????
; this is after receiving TWO "1" signal changes. Check of DCC signal polarity ??
GOTO IN_DccInLow ; Jump if DCCIN is low
BSF DCC_HIGH_FLAG ; DCCIN is high
BCF DCC_LOW_FLAG
GOTO IN_ProcessPacket
IN_DccInLow:
BCF DCC_HIGH_FLAG ; DCCIN is low
BSF DCC_LOW_FLAG
IN_ProcessPacket:
CLRF AnalogTimeCounter
MOVF DATA1,W
BTFSC STATUS,Z ; skip if NONzero = not RESET packet
GOTO IN_MaybeReset
; nonzero address/1st data packeet
ANDLW 0xF0
XORLW 0x70 ; check of 0x0111????
BTFSC STATUS,Z ; skip of other
GOTO IN_CheckServiceMode ; received byte / address was 0x0111????
BCF RESET_FLAG
BCF SRVMODE_FLAG
MOVF DATA1,W
BTFSS DATA1,7 ; bit 7 = long address ?
BTFSC CV29,5 ; skip when SHORT address is used (CV1)
GOTO IN_CheckLongAddress
XORWF CV1,W
BTFSS STATUS,Z
GOTO IN_ResetReader ; not OUR packet, skip.
IN_DecoderCommand:
MOVF DATA2,W
MOVWF COMMAND1
MOVF DATA3,W
MOVWF COMMAND2
MOVF DATA4,W
MOVWF COMMAND3
BSF PACKET_READY
GOTO IN_ResetReader
IN_CheckLongAddress:
XORWF CV17,W
BTFSC DATA1,7
BTFSS STATUS,Z ; zero = LSB matches
GOTO IN_ResetReader ; 10xxxx - accessory packet, bail out
MOVF DATA2,W
XORWF CV18,W
BTFSC CV29,5 ; check for long address flag again
BTFSS STATUS,Z
GOTO IN_ResetReader
MOVF DATA3,W ; accept data ??
MOVWF COMMAND1
MOVF DATA4,W
MOVWF COMMAND2
MOVF DATA5,W
MOVWF COMMAND3
BSF PACKET_READY
GOTO IN_ResetReader
IN_CheckServiceMode:
BTFSS RESET_FLAG
GOTO IN_ServModeFail
BTFSS SRV2X_FLAG
GOTO IN_ServModeFirst
BCF SRV2X_FLAG
BSF SRVMODE_FLAG
BCF FOUR_BYTE
MOVF INT_BUF_PTR,W
XORLW 0x2D ; (address) + 0x2B, 0x2C = 3 byte packet
BTFSS STATUS,Z
BSF FOUR_BYTE ; 2-byte or 4 byte packet
MOVF DATA1,W
MOVWF COMMAND1
MOVF DATA2,W
MOVWF COMMAND2
MOVF DATA3,W
MOVWF COMMAND3
BSF PACKET_READY
GOTO IN_ResetReader
IN_ServModeFirst:
BSF SRV2X_FLAG
GOTO IN_ResetReader
IN_ServModeFail:
BCF RESET_FLAG
BCF SRV2X_FLAG
GOTO IN_ResetReader
IN_MaybeReset:
BCF RESET_FLAG
BCF SRVMODE_FLAG
MOVF DATA2,W
BTFSS STATUS,Z
GOTO IN_DecoderCommand ; packet's 2nd byte is != 0, normal command
BSF RESET_FLAG
BCF SRV2X_FLAG
GOTO IN_ResetReader
INIT:
CLRF GPIO ; GPIO
MOVLW 0x07 ; b'00000111' d'007'
MOVWF CMCON ; Comparators OFF
BSF STATUS,RP0
MOVLW 0x04 ; Input pin mask
MOVWF TRISIO ; GPIO,2 = in, all others = out
CALL Load_Osccal
MOVWF OSCCAL
MOVLW 0x33 ; Disable weak pull-up for GPIO,2 ???
MOVWF WPU ; !!Bank!! Unimplemented - WPU
MOVLW 0x04 ; b'00000100' d'004'
MOVWF IOC ; Enable interrupt on GPIO,2 change
CLRF VRCON ; !!Bank!! CMCON - VRCON
MOVLW 0x88 ; b'10001000' d'136'
MOVWF OPTION_REG ; Option register: no pull-up, falling GP2, no prescaler, wdt 1:1
CLRF PIE1 ; Disable all interrupts
BCF STATUS,RP0 ; !!Bank Register-Bank(0/1)-Select
CLRF PIR1 ; !!Bank!! PIR1 - PIE1
MOVLW 0x01
MOVWF T1CON ; Timer 1 on, 1:1
MOVLW 0x20 ; b'00100000' d'032' " "
MOVWF FSR
Clear_RAM:
CLRF INDF
INCF FSR,F
MOVLW 0x60 ; b'01100000' d'096' "`"
XORWF FSR,W
BTFSS STATUS,Z
GOTO Clear_RAM
MOVLW 0x88 ; GIE = ON, GPIE = ON
MOVWF INTCON
ADDLW 0xC2 ; 0x4A
MOVWF EEDATA0 ; will send to EE ??
CLRF Maybe_PAGEREG
ADDLW 0xBD ; = 0x07
MOVWF FLASH_A_COUNTER
MOVWF FLASH_B_COUNTER
INCF INCREMENT,F ; = 0x01 (increment from 0)
CALL EE_Write ; EEPROM(0x07) := 0x4A ???
CALL LoadAddress
MainLoop:
BTFSC PACKET_READY
CALL Process_Packet
CALL Sub_Function_Bits
BTFSS RESET_FLAG ; goto main loop on reset flag, ignore timer
BTFSS PIR1,0
GOTO MainLoop ; loop if timer did not fire
; Some data ... ? Overwrites in "W"
MOVLW 0x8F ; b'10001111' d'143'
MOVLW 0x0E ; b'00001110' d'014'
MOVLW 0xFD ; 3 * 0x100; if TMR1 runs @ 4MHz, then 5,2x / sec = ~200ms
MOVWF TMR1H ;
BCF PIR1,0
CALL LADR_0x0270
BTFSC CV_ANALOG_ENABLE
DECFSZ AnalogTimeCounter,F ; decrement in analog-enable mode. 256 cycles after packet, 32 cycles when "idle"
GOTO MainLoop
CALL AnalogOperation
GOTO MainLoop
Process_Packet:
BCF PACKET_READY
BTFSC SRVMODE_FLAG
GOTO Process_ServiceMode
GOTO Process_Command
Command_POM:
BTFSS SRV2X_FLAG
GOTO Set_POM_Flag
BCF SRV2X_FLAG
MOVF COMMAND3,W ; save potential write or compare byte
MOVWF EEDATA0
MOVLW 0xEC ; 0x11101100 (0x111???? = POM, 0x???11 = write byte)
XORWF COMMAND1,W
BTFSS STATUS,Z
RETURN
; POM Write CV
MOVF COMMAND2,W ; CV number
CALL Write_CV_Start
BTFSC IGNORE_CV_FLAG
RETURN
BTFSC RESCV_FLAG
GOTO Check_ResetCommand
GOTO Real_CV_Write
Set_POM_Flag:
BSF SRV2X_FLAG
RETURN
LADR_0x013C
MOVF COMMAND1,W
XORLW 0x3F ; b'00111111' d'063' "?"
BTFSS STATUS,Z
RETURN
MOVF COMMAND2,W
Sub_Set_SpeedDir:
BTFSC CV29,0
XORLW 0x80 ; invert direction bit on reverse direction
MOVWF SPEED
RETURN
LADR_0x0145
MOVLW 0x80 ; forward speed
LADR_0x0146
CALL Sub_Set_SpeedDir
MOVF COMMAND1,W
ANDLW 0x1F
BTFSS CV_SPEED_28
ANDLW 0x0F ; 16 speed steps; bit 4 of speed controls the light.
IORWF SPEED,F
BTFSC CV_SPEED_28
RETURN
Set_FL:
BCF FN_DIRLIGHT_BIT
BTFSC COMMAND1,4
BSF FN_DIRLIGHT_BIT
RETURN
LADR_0x0152
MOVLW 0x00 ; b'00000000' d'000'
GOTO LADR_0x0146
AnalogOperation:
BSF AnalogTimeCounter,5 ; set to 32
MOVLW 0x82 ; Going Forward, speed = 2
BTFSS DCCIN ; Detect polarity
MOVLW 0x02 ; Going Backward, speed = 2
CALL Sub_Set_SpeedDir
MOVLW 0x0C ; load CV 13, analog active functions
CALL EE_Read
MOVWF TEMP_VAR
ANDLW 0x0F
MOVWF FSTATE ; Bits 0..3 correspond to F1..F4 state
SWAPF TEMP_VAR,W
ANDLW 0x0F ; Functions F5 - F8
MOVWF LRAM_0x36
MOVLW 0x0D ; read CV 14
CALL EE_Read
MOVWF TEMP_VAR
BTFSC CURRENT_DIR
BTFSS TEMP_VAR,0 ; Going forward
GOTO Maybe_Set_RevLight_Analog ; Going reverse, OR (going forward AND CV14/FL = 0)
BSF FN_DIRLIGHT_BIT ; Going forward AND CV14/FL = 1
Maybe_Set_RevLight_Analog:
BTFSS CURRENT_DIR
BTFSS TEMP_VAR,1 ; Going reverse
GOTO Finish_Set_Light_Analog ; Going forward, OR (going reverse AND CV14/FR = 0)
BSF FN_DIRLIGHT_BIT ; Going reverse AND CV14/FR = 1
Finish_Set_Light_Analog:
RLF TEMP_VAR,F
RLF TEMP_VAR,W ; Rotate by 2 bits, F12 is in 7th bit
ANDLW 0xF0
IORWF LRAM_0x36,F ; Merge with functions F5-F8
CLRF LRAM_0x37 ; No functions F13-F20
CLRF LRAM_0x38 ; No functions F21-F28
BCF DCC_HIGH_FLAG ; DCC not detected (neither polarity)
BCF DCC_LOW_FLAG
RETURN
Function_Group1:
BTFSC CV_SPEED_28 ; skip if CV29 = 0, 4th bit of control directs FL
CALL Set_FL ; if CV29 = 1, get FL from 4th bit of Function group 1
MOVLW 0xF0
ANDWF FSTATE,F
MOVF COMMAND1,W
ANDLW 0x0F
IORWF FSTATE,F
RETURN
Function_Group2:
BTFSS COMMAND1,4
GOTO Set_F9_12
MOVLW 0xF0 ; b'11110000' d'240'
ANDWF LRAM_0x36,F
MOVF COMMAND1,W
ANDLW 0x0F ; b'00001111' d'015'
IORWF LRAM_0x36,F
RETURN
Set_F9_12:
MOVLW 0x0F ; b'00001111' d'015'
ANDWF LRAM_0x36,F
SWAPF COMMAND1,W
ANDLW 0xF0 ; b'11110000' d'240'
IORWF LRAM_0x36,F
RETURN
Function_Extended:
MOVF COMMAND1,W
XORLW 0xDE ; Extended command 11110
BTFSS STATUS,Z
GOTO Function_F21_Check
MOVF COMMAND2,W
MOVWF LRAM_0x37 ; State of F13-20
RETURN
Function_F21_Check:
XORLW 0x01 ; Extended command 11111
BTFSS STATUS,Z
RETURN
MOVF COMMAND2,W
MOVWF LRAM_0x38 ; State of F21-28
RETURN
Process_ServiceMode:
BTFSC FOUR_BYTE
GOTO Service_Direct
; 3-byte service mode packets
MOVF COMMAND2,W
MOVWF EEDATA0 ; .. command data ??
MOVF COMMAND1,W ; CV number ??
; XXX should check decoder CV lock.
ANDLW 0xF7 ; ignore "C" (read/write flag)
XORLW 0x75 ; 0111-x101, undefined ??
BTFSC STATUS,Z
GOTO Set_PageRegister
XORLW 0x01 ; 0111-x100, basic configuration register
BTFSC STATUS,Z
GOTO Phys_CV29
XORLW 0x02 ; b'0111?110' --- version number, CV7
BTFSC STATUS,Z
GOTO LADR_0x01BF
XORLW 0x01 ; b'0111?111' --- manufacture, CV8
BTFSC STATUS,Z
GOTO LADR_0x01C1
MOVF COMMAND1,W
ANDLW 0x03 ; b'00000011' d'003'
ADDWF Maybe_PAGEREG,W
CALL Write_CV_Start
BTFSC IGNORE_CV_FLAG
RETURN
Phys_Operation:
; !!! must check lock
BTFSS COMMAND1,3
GOTO Phys_VerifyCV
GOTO Real_CV_Write
Phys_CV29:
MOVLW 0x1C ; b'00011100' d'028'
GOTO Phys_Operation
Set_PageRegister:
DECF COMMAND2,F
RLF COMMAND2,F
RLF COMMAND2,W
ANDLW 0xFC ; b'11111100' d'252'
BTFSS COMMAND1,3
GOTO Verify_PageReg
MOVWF Maybe_PAGEREG
RETURN
Verify_PageReg:
XORWF Maybe_PAGEREG,W
GOTO ACK_If_Zero
LADR_0x01BF
MOVLW 0x06 ; b'00000110' d'006'
GOTO Phys_Operation
LADR_0x01C1
MOVF COMMAND2,W
GOTO Check_ResetTrigger
Phys_VerifyCV:
CALL EE_Read
XORWF COMMAND2,W
ACK_If_Zero:
BTFSS STATUS,Z
RETURN
Blink_Led:
MOVLW 0x33 ; All outputs ON
MOVWF GPIO
MOVLW 0x06 ; b'00000110' d'006'
MOVWF TEMP_VAR
; XXX instruction can be saved: Do not initialize to 0, 1st outer cycle will
; last 6 inner cycles less. Increase outer cycle by 1
MOVLW 0x00
Blink_Led_wait:
ADDLW 0xFF
BTFSS STATUS,Z
GOTO Blink_Led_wait
DECFSZ TEMP_VAR,F
GOTO Blink_Led_wait
CLRF GPIO ; turn off LEDs
RETURN
; !!!!! Must process
Service_Direct:
MOVF COMMAND3,W ; value of CV to set or verify
MOVWF EEDATA0
BTFSS COMMAND1,1
BTFSC COMMAND1,0
RETURN ; filter out CVs with address > 0x100
;; Direct mode, bits COMMAND1,2-3 has the instruction, COMMAND2 is the CV#
MOVF COMMAND2,W
CALL Write_CV_Start
BTFSC IGNORE_CV_FLAG
RETURN ; invalid CV#
BTFSC COMMAND1,3 ; skip if NOT 0x08
GOTO Service_Direct2 ; 11 write byte or 10 bit manipulation
BTFSS COMMAND1,2
RETURN
Service_Direct2:
BTFSS COMMAND1,2
GOTO Service_BitOper ; 10 - bit manipulation
BTFSS COMMAND1,3
GOTO Verify_CV_Byte
; 0x0c..0x0f
Real_CV_Write:
BTFSC RESCV_FLAG
GOTO Check_ResetCommand
CALL EE_Write
CALL Blink_Led
CALL LoadAddress
RETURN
Verify_CV_Byte:
CALL EE_Read
XORWF COMMAND3,W
GOTO ACK_If_Zero
Check_ResetCommand:
MOVF COMMAND3,W
Check_ResetTrigger:
XORLW 0x21 ; b'00100001' d'033' "!"
BTFSS STATUS,Z
RETURN
GOTO Reset_CVs
Service_BitOper:
CALL EE_Read ; read the current CV
MOVWF EEDATA0
MOVLW EEDATA0
MOVWF FSR ; prepare for bit operation
MOVLW 0x07
ANDWF COMMAND3,W ; bit number in COMMAND3
CALL Bit_GetValue
BTFSS COMMAND3,4
GOTO Service_BitVerify
BTFSC COMMAND3,3
IORWF INDF,F ; bit value in W
XORLW 0xFF
BTFSS COMMAND3,3
ANDWF INDF,F ; clear bit
MOVF COMMAND2,W
CALL Write_CV_Start
GOTO Real_CV_Write
Service_BitVerify:
ANDWF INDF,W
BTFSC STATUS,Z
GOTO Service_BitVerify_0
BTFSC COMMAND3,3
GOTO Blink_Led
RETURN
Service_BitVerify_0:
BTFSS COMMAND3,3
GOTO Blink_Led
RETURN
Write_CV_Start:
BCF IGNORE_CV_FLAG
BCF RESCV_FLAG
MOVWF TEMP_VAR
BTFSS TEMP_VAR,7
BTFSC TEMP_VAR,6
GOTO Check_High_CV_Addr ; CVs > 0x3F (64 +)
; CVs <= 0x3f
XORLW 0x06 ; check for CV-7
BTFSC STATUS,Z
BSF RESCV_FLAG ; if TEMP_VAR == 0x06
XORLW 0x01 ; check for CV-8
BTFSC STATUS,Z
BSF RESCV_FLAG ; if TEMP_VAR == 0x07
MOVF TEMP_VAR,W
RETURN
Check_High_CV_Addr:
ADDLW 0x89 ; CV 120 will correspond to 0x00
BTFSS STATUS,C
BSF IGNORE_CV_FLAG ; Ignore if CV < 120, below func table
ADDLW 0xC0 ; If CV >= 120 && CV < 184 => status,c := 0
BTFSC STATUS,C
BSF IGNORE_CV_FLAG ; Ignore if CV > 184
ADDLW 0x40
ADDLW 0x40 ; Adjust so that CV120 will become 0x040 = eeprom address
RETURN
Reset_CVs:
MOVLW 0x0F
MOVWF EEDATA0
MOVLW EEPROM_CV37
MOVWF EEPROM_WRITE_START
MOVLW 0x04
CALL Fill_eeprom_bytes ; write 0x0f to EEPROM 0x24-0x27, CV37-40
MOVLW 0xC0
MOVWF EEDATA0
MOVLW EEPROM_CV17 ; CV17 := 0xc0
CALL EE_Write
SWAPF EEDATA0,F ; prepare to write 0x0C
MOVLW EEPROM_CV50
MOVWF EEPROM_WRITE_START
MOVLW 0x04
CALL Fill_eeprom_bytes ; write 0x0C to CV50-53
; XXX Instrunction can be saved by
; BCF EEDATA0,2 ; 0x0C --> 0x08
;
MOVLW 0x64
MOVWF EEDATA0
MOVLW EEPROM_CV18
CALL EE_Write
MOVLW 0x06
MOVWF EEDATA0
MOVLW EEPROM_CV29
CALL EE_Write
; fill CV124-125
MOVLW 0x08
MOVWF EEDATA0
MOVLW EEPROM_CV124
MOVWF EEPROM_WRITE_START
MOVLW 0x02 ; b'00000010' d'002'
CALL Fill_eeprom_bytes
; Initialize with zeroes
; 0x0C, 0x20-23, 0x46-7F
; XXXX several instructions can be saved by setting ALL eeprom content to zero
; save 6 instructions
CLRF EEDATA0
MOVLW EEPROM_CV13
CALL EE_Write
MOVLW 0x20
MOVWF EEPROM_WRITE_START
MOVLW 0x04 ; b'00000100' d'004'
CALL Fill_eeprom_bytes
MOVLW 0x46 ; b'01000110' d'070' "F"
MOVWF EEPROM_WRITE_START
MOVLW 0x3A ; b'00111010' d'058' ":"
CALL Fill_eeprom_bytes
; Write 1
INCF EEDATA0,F
MOVLW 0x40 ; b'01000000' d'064' "@"
CALL EE_Write
; Write 2
INCF EEDATA0,F
MOVLW 0x41 ; b'01000001' d'065' "A"
CALL EE_Write
; Write 3
INCF EEDATA0,F
MOVLW 0x00 ; b'00000000' d'000'
CALL EE_Write
MOVLW 0x0D ; b'00001101' d'013'
CALL EE_Write
; Write 4
INCF EEDATA0,F
MOVLW 0x42 ; b'01000010' d'066' "B"
MOVWF EEPROM_WRITE_START
MOVLW 0x02 ; b'00000010' d'002'
CALL Fill_eeprom_bytes
CALL Blink_Led
; Fall through
LoadAddress:
MOVLW EEPROM_CV1
CALL EE_Read ; Read EEPROM(0)
MOVWF CV1
MOVLW EEPROM_CV17
CALL EE_Read ; Read EEPROM(0x10)
MOVWF CV17
MOVLW EEPROM_CV18
CALL EE_Read ; Read EEPROM(0x11)
MOVWF CV18
MOVLW EEPROM_CV29
CALL EE_Read ; Read EEPROM(0x1C)
MOVWF CV29
RETURN
Fill_eeprom_bytes:
MOVWF FUNCTION_ID
Fill_eeprom_loop:
MOVF EEPROM_WRITE_START,W
CALL EE_Write
INCF EEPROM_WRITE_START,F
DECFSZ FUNCTION_ID,F
GOTO Fill_eeprom_loop
RETURN
LADR_0x0270
MOVLW 0x10 ; b'00010000' d'016'
ADDWF INCREMENT,F ; Series 0x01, 0x11, 0x21, ... 0xf1
CLRF TEMP_VAR ; Initially zero
MOVF INCREMENT,W
ADDWF BRIGHT_FA,W ; Add to brightness. Brightness 0x80 will stay on for 0x81..0xf1, off for 0x01..0x71 (8 states from 8).
BTFSC STATUS,C ; Brightness 0x00 nevers turn on. Brightness 0xff will stay on even for 0x01.
BSF TEMP_VAR,0
MOVF INCREMENT,W
ADDWF BRIGHT_FB,W
BTFSC STATUS,C
BSF TEMP_VAR,1
MOVF INCREMENT,W
ADDWF BRIGHT_FC,W
BTFSC STATUS,C
BSF TEMP_VAR,4
MOVF INCREMENT,W
ADDWF BRIGHT_FD,W
BTFSC STATUS,C
BSF TEMP_VAR,5
MOVF TEMP_VAR,W
MOVWF GPIO ; !!Bank!! GPIO - TRISIO
CALL LADR_0x006A
INCF LRAM_0x40,F
RETURN
Sub_Function_Bits:
CLRF FUNCTION_ID ; F0
CLRF LRAM_0x39 ; Set enabled outputs to NONE initially
BTFSC FSTATE,4 ; F0
CALL Load_Function_Cfg
INCF FUNCTION_ID,F
BTFSC FSTATE,0 ; F1
CALL Load_Function_Cfg
INCF FUNCTION_ID,F
BTFSC FSTATE,1 ; F2
CALL Load_Function_Cfg
INCF FUNCTION_ID,F
BTFSC FSTATE,2 ; F3
CALL Load_Function_Cfg
INCF FUNCTION_ID,F
BTFSC FSTATE,3 ; F4
CALL Load_Function_Cfg
; OPTIMIZATION: save instrunctions, by using
; FSR + INDF (0x036 - 0x038). Increment at the start of the loop. End when
; FSR bit #3 is set = 0x038
; 29 instrs. vs. 72 instrs.
INCF FUNCTION_ID,F ; F5
BTFSC LRAM_0x36,0
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F6
BTFSC LRAM_0x36,1
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F7
BTFSC LRAM_0x36,2
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F8
BTFSC LRAM_0x36,3
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F9
BTFSC LRAM_0x36,4
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F10
BTFSC LRAM_0x36,5
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F11
BTFSC LRAM_0x36,6
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F12
BTFSC LRAM_0x36,7
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F13
BTFSC LRAM_0x37,0
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F14
BTFSC LRAM_0x37,1
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F15
BTFSC LRAM_0x37,2
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F16
BTFSC LRAM_0x37,3
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F17
BTFSC LRAM_0x37,4
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F18
BTFSC LRAM_0x37,5
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F19
BTFSC LRAM_0x37,6
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F20
BTFSC LRAM_0x37,7
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F21
BTFSC LRAM_0x38,0
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F22
BTFSC LRAM_0x38,1
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F23
BTFSC LRAM_0x38,2
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F24
BTFSC LRAM_0x38,3
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F25
BTFSC LRAM_0x38,4
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F26
BTFSC LRAM_0x38,5
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F27
BTFSC LRAM_0x38,6
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F28
BTFSC LRAM_0x38,7
CALL Load_Function_Cfg
INCF FUNCTION_ID,F ; F29 :)) == Stop FWD/BWD
MOVF SPEED,W
ANDLW 0x7E ; b'01111110' d'126' "~"
BTFSS STATUS,Z
INCF FUNCTION_ID,F ; F29 :)) == Moving FWD/BWD
CALL Load_Function_Cfg
BTFSC DCC_HIGH_FLAG
MOVLW 0x7E ; DCC HIGH on = 0x7E
BTFSC DCC_LOW_FLAG
MOVLW 0x7F ; DCC LOW on = 0x7F
BTFSS DCC_HIGH_FLAG
BTFSC DCC_LOW_FLAG
CALL Load_Eeprom_Bits ; read CV182 when DCC HIGH, CV 183 when DCC LOW
MOVF LRAM_0x39,W
XORWF LRAM_0x3A,F ; 3A = changes, W = enabled bits
BTFSS LRAM_0x3A,0 ; change on FA
GOTO Proc_Change_FB
BTFSS LRAM_0x39,0 ; new state = 1 -> jump
BSF TODO_FA,6 ; new FA = OFF
BTFSC LRAM_0x39,0
BSF TODO_FA,7 ; new FA = ON
Proc_Change_FB:
BTFSS LRAM_0x3A,1
GOTO Proc_Change_FC
BTFSS LRAM_0x39,1
BSF TODO_FB,6
BTFSC LRAM_0x39,1
BSF TODO_FB,7
Proc_Change_FC:
BTFSS LRAM_0x3A,2
GOTO Proc_Change_FD
BTFSS LRAM_0x39,2
BSF TODO_FC,6
BTFSC LRAM_0x39,2
BSF TODO_FC,7
Proc_Change_FD:
BTFSS LRAM_0x3A,3
GOTO Proc_Change_End
BTFSS LRAM_0x39,3
BSF TODO_FD,6
BTFSC LRAM_0x39,3
BSF TODO_FD,7
Proc_Change_End:
MOVWF LRAM_0x3A ; 0x3A := enabled bits
RETURN
;---------------------------------------------------------------------
; turn ON outputs according to configuration in EEPROM. Desired Function ID in FUNCTION_ID
Load_Function_Cfg:
BCF STATUS,C
BTFSS CURRENT_DIR
BSF STATUS,C
RLF FUNCTION_ID,W
ADDLW EEPROM_OUTCONF_BASE
Load_Eeprom_Bits:
CALL EE_Read
IORWF LRAM_0x39,F
RETURN
Final_State_FSR:
CALL Fetch_TODO_FSR
BTFSC INDF,7
MOVLW 0x10 ; Desired state = ON, set 4th bit, clear others.
BTFSC INDF,6
MOVLW 0x00 ; Desired state = OFF, clear 4th bit (and others)
MOVWF INDF
RETURN
Fetch_State_Or_Off:
CALL Fetch_TODO_FSR
BTFSC INDF,6
MOVLW 0x00 ; Desired state = OFF, clear. Otherwise KEEP existing state
MOVWF INDF
ANDLW 0x0F ; Return current state/phase ??
RETURN
Effect_Incandesc:
CALL Final_State_FSR
MOVLW 0x00 ; set brightness to 0, if bit 4 = 0
BTFSC INDF,4
CALL Load_Brightness
Set_Cur_Brightness:
MOVWF TEMP_VAR
MOVF LRAM_0x40,W
ADDLW BRIGHT_BASE
MOVWF FSR
MOVF TEMP_VAR,W
MOVWF INDF
RETURN
Effect_Fluor_EOL:
CALL Fetch_State_Or_Off
BTFSS STATUS,Z ; Zero if turned OFF, or when state == 0
GOTO LADR_0x033C
BSF INDF,4 ; Set 4th bit, indicator "ON"
BSF INDF,5 ; ???
GOTO LADR_0x0337
Effect_Fluor_Broken:
CALL Fetch_State_Or_Off
BTFSS STATUS,Z
GOTO LADR_0x033C ; goto if not off
BSF INDF,4 ; set "lit" flag on ?
GOTO LADR_0x0337
Effect_Fluor:
CALL Fetch_State_Or_Off
BTFSS STATUS,Z
GOTO LADR_0x033C
LADR_0x0337:
MOVLW 0x00 ; b'00000000' d'000'
BTFSS INDF,7 ; bit 7 means turn ON
GOTO Set_Cur_Brightness ; erase (0x00) to reg (0x3c + [0x40]), unless 7 bit.
MOVLW 0x01 ; Initial flip will make the value in W 0; then Func State will increase to 2.
CALL Set_Func_State
LADR_0x033C:
XORLW 0x01 ; flip '1' in state
BTFSS STATUS,Z
GOTO LADR_0x0348
CALL Inc_Func_State ; every other state change, will increment.
CALL Random
ANDLW 0x07 ; b'00000111' d'007'
ADDLW 0x03 ; b'00000011' d'003'
CALL Set_Func_0x48
MOVLW 0x0A ; b'00001010' d'010'
CALL Set_Func_0x4c
LADR_0x0346:
CALL Load_Brightness
GOTO Set_Cur_Brightness
LADR_0x0348:
XORLW 0x03 ; b'00000011' d'003'
BTFSS STATUS,Z
GOTO LADR_0x0363
CALL Load_Func_0x4c
DECFSZ INDF,F
RETURN
CALL Load_Func_0x48
DECFSZ INDF,F
GOTO LADR_0x0354
CALL Inc_Func_State
CALL Load_Brightness
GOTO Set_Cur_Brightness
LADR_0x0354
MOVF LRAM_0x40,W
ADDLW 0x3C ; b'00111100' d'060' "<"
MOVWF FSR
CALL Load_Brightness
XORWF INDF,F
BTFSS STATUS,Z
GOTO LADR_0x035F
CALL Random
ANDLW 0x1F ; b'00011111' d'031'
ADDLW 0x14 ; b'00010100' d'020'
GOTO Set_Func_0x4c
LADR_0x035F
CALL Random
ANDLW 0x07 ; b'00000111' d'007'
ADDLW 0x06 ; b'00000110' d'006'
GOTO Set_Func_0x4c
LADR_0x0363
XORLW 0x01 ; b'00000001' d'001'
BTFSS STATUS,Z
GOTO LADR_0x0373
BTFSS INDF,4
GOTO LADR_0x0346
CALL Random
ANDLW 0x07 ; b'00000111' d'007'
ADDLW 0x03 ; b'00000011' d'003'
CALL Set_Func_0x4c
MOVLW 0x30 ; b'00110000' d'048' "0"
CALL Set_Func_0x48
CALL Inc_Func_State
BTFSS INDF,5
GOTO LADR_0x0346
MOVLW 0x10 ; b'00010000' d'016'
GOTO Set_Cur_Brightness
LADR_0x0373
CALL Load_Func_0x48
DECFSZ INDF,F
RETURN
MOVLW 0x30 ; b'00110000' d'048' "0"
CALL Set_Func_0x48
CALL Load_Func_0x4c
DECFSZ INDF,F
RETURN
MOVLW 0x02 ; b'00000010' d'002'
CALL Set_Func_State
CALL Random
ANDLW 0x07 ; b'00000111' d'007'
ADDLW 0x05 ; b'00000101' d'005'
CALL Set_Func_0x48
MOVLW 0x0A ; b'00001010' d'010'
CALL Set_Func_0x4c
MOVLW 0x00 ; b'00000000' d'000'
GOTO Set_Cur_Brightness
Effect_FlashA
CALL Final_State_FSR
MOVLW 0x00 ; b'00000000' d'000'
BTFSC INDF,4
BTFSS FLASH_A_STATE
GOTO Set_Cur_Brightness
CALL Load_Brightness
GOTO Set_Cur_Brightness
Effect_FlashA_Neg
CALL Final_State_FSR
MOVLW 0x00 ; b'00000000' d'000'
BTFSC INDF,4
BTFSC FLASH_A_STATE
GOTO Set_Cur_Brightness
CALL Load_Brightness
GOTO Set_Cur_Brightness
Effect_FlashB
CALL Final_State_FSR
MOVLW 0x00 ; b'00000000' d'000'
BTFSC INDF,4
BTFSS FLASH_B_STATE
GOTO Set_Cur_Brightness
CALL Load_Brightness
GOTO Set_Cur_Brightness
Effect_FlashB_Neg
CALL Final_State_FSR
MOVLW 0x00 ; b'00000000' d'000'
BTFSC INDF,4
BTFSC FLASH_B_STATE
GOTO Set_Cur_Brightness
CALL Load_Brightness
GOTO Set_Cur_Brightness
Load_Brightness:
MOVF LRAM_0x40,W
ADDLW 0x24 ; CV 37-40, max brightness
CALL EE_Read
MOVWF EEDATA0
SWAPF EEDATA0,W
IORLW 0x0F ; brightness * 16 + 0x0f
RETURN
Random:
MOVF LRAM_0x3B,W
BTFSC STATUS,Z ; neni 0 - preskocit
MOVF TMR0,W ; Read TMR0 -- random generator ??
BTFSC STATUS,Z ; nebyla 0 v 0x3b, neni ani ted
INCF LRAM_0x3B,W
MOVWF TEMP_VAR
RRF TEMP_VAR,F
SWAPF TEMP_VAR,F
XORWF TEMP_VAR,F
RRF TEMP_VAR,F
RRF LRAM_0x3B,W
MOVWF LRAM_0x3B
RETURN
Fetch_TODO_FSR:
MOVF LRAM_0x40,W
ADDLW TODO_BASE
MOVWF FSR
MOVF INDF,W
RETURN
Inc_Func_State:
MOVF LRAM_0x40,W
ADDLW TODO_BASE
MOVWF FSR
INCF INDF,W
Set_Func_State:
ANDLW 0x0F ; State counter (?) goes to lower 4 bits
MOVWF TEMP_VAR
MOVF LRAM_0x40,W
ADDLW TODO_BASE
MOVWF FSR
MOVLW 0xF0 ; Keep existing flags
ANDWF INDF,F
MOVF TEMP_VAR,W
IORWF INDF,F
RETURN
Set_Func_0x48:
MOVWF TEMP_VAR
MOVF LRAM_0x40,W
ADDLW 0x48 ; b'01001000' d'072' "H"
MOVWF FSR
MOVF TEMP_VAR,W
MOVWF INDF
RETURN
Load_Func_0x48:
MOVF LRAM_0x40,W
ADDLW 0x48 ; b'01001000' d'072' "H"
MOVWF FSR
MOVF INDF,W
RETURN
Set_Func_0x4c:
MOVWF TEMP_VAR
MOVF LRAM_0x40,W
ADDLW 0x4C ; b'01001100' d'076' "L"
MOVWF FSR
MOVF TEMP_VAR,W
MOVWF INDF
RETURN
Load_Func_0x4c:
MOVF LRAM_0x40,W
ADDLW 0x4C ; b'01001100' d'076' "L"
MOVWF FSR
MOVF INDF,W
RETURN
EE_Read:
BSF STATUS,RP0 ; !!Bank Register-Bank(0/1)-Select
MOVWF EEADR ; !!Bank!! Unimplemented - EEADR
BSF EECON1,RD ; !!Bank!! Unimplemented - EECON1
MOVF EEDATA,W ; !!Bank!! Unimplemented - EEDATA
BCF STATUS,RP0 ; !!Bank Register-Bank(0/1)-Select
RETURN
EE_Write:
CALL EE_Read
XORWF EEDATA0,W
BTFSC STATUS,Z
RETURN
MOVF EEDATA0,W
BSF STATUS,RP0 ;
MOVWF EEDATA ; !!Bank!! Unimplemented - EEDATA
BSF EECON1,WREN ; !!Bank!! Unimplemented - EECON1
BCF INTCON,GIE
MOVLW 0x55 ; b'01010101' d'085' "U"
MOVWF EECON2 ; !!Bank!! Unimplemented - EECON2
MOVLW 0xAA ; b'10101010' d'170'
MOVWF EECON2 ; !!Bank!! Unimplemented - EECON2
BSF EECON1,WR ; !!Bank!! Unimplemented - EECON1
BSF INTCON,GIE
BCF EECON1,WREN ; !!Bank!! Unimplemented - EECON1
EEWrite0:
BTFSC EECON1,1 ; !!Bank!! Unimplemented - EECON1
GOTO EEWrite0
BCF STATUS,RP0 ; !!Bank Register-Bank(0/1)-Select
RETURN
End
|
misc/Utilities.agda | yurrriq/parser-combinators | 7 | 14886 | <filename>misc/Utilities.agda
------------------------------------------------------------------------
-- Some types and functions used by several parser variants
------------------------------------------------------------------------
module Utilities where
open import Data.Product
open import Data.List
open import Data.Function using (flip)
------------------------------------------------------------------------
-- Associativity
-- Used to specify how chain₁, chain and chain≥ should apply the
-- parsed operators: left or right associatively.
data Assoc : Set where
left : Assoc
right : Assoc
------------------------------------------------------------------------
-- Post-processing for the chain parsers
-- Application.
appʳ : forall {r} -> r × (r -> r -> r) -> r -> r
appʳ (x , _•_) y = x • y
appˡ : forall {r} -> r -> (r -> r -> r) × r -> r
appˡ x (_•_ , y) = x • y
-- Shifting. See Examples below for an illuminating example.
shiftˡ : forall {a b} -> List (a × b) -> a -> a × List (b × a)
shiftˡ [] x = (x , [])
shiftˡ ((x₁ , x₂) ∷ xs₃) x₄ = (x₁ , (x₂ , proj₁ x₃xs₄) ∷ proj₂ x₃xs₄)
where x₃xs₄ = shiftˡ xs₃ x₄
-- The post-processing function. See Examples below for some
-- illuminating examples.
chain₁-combine : forall {r} ->
Assoc -> List (r × (r -> r -> r)) -> r -> r
chain₁-combine right xs y = foldr appʳ y xs
chain₁-combine left xs y with shiftˡ xs y
... | (x , ys) = foldl appˡ x ys
-- Variants.
shiftʳ : forall {a b} -> a -> List (b × a) -> List (a × b) × a
shiftʳ x [] = ([] , x)
shiftʳ x₁ ((x₂ , x₃) ∷ xs₄) = ((x₁ , x₂) ∷ proj₁ xs₃x₄ , proj₂ xs₃x₄)
where xs₃x₄ = shiftʳ x₃ xs₄
chain≥-combine : forall {r} ->
Assoc -> r -> List ((r -> r -> r) × r) -> r
chain≥-combine left x ys = foldl appˡ x ys
chain≥-combine right x ys with shiftʳ x ys
... | (xs , y) = foldr appʳ y xs
private
module Examples {r s : Set}
(x y z : r)
(A B : s)
(_+_ _*_ : r -> r -> r)
where
open import Relation.Binary.PropositionalEquality
ex₁ : shiftˡ ((x , A) ∷ (y , B) ∷ []) z ≡ (x , ((A , y) ∷ (B , z) ∷ []))
ex₁ = refl
ex₁ʳ : chain₁-combine right ((x , _+_) ∷ (y , _*_) ∷ []) z ≡ x + (y * z)
ex₁ʳ = refl
ex₁ˡ : chain₁-combine left ((x , _+_) ∷ (y , _*_) ∷ []) z ≡ (x + y) * z
ex₁ˡ = refl
ex≥ : shiftʳ x ((A , y) ∷ (B , z) ∷ []) ≡ ((x , A) ∷ (y , B) ∷ [] , z)
ex≥ = refl
ex≥ʳ : chain≥-combine right x ((_+_ , y) ∷ (_*_ , z) ∷ []) ≡ x + (y * z)
ex≥ʳ = refl
ex≥ˡ : chain≥-combine left x ((_+_ , y) ∷ (_*_ , z) ∷ []) ≡ (x + y) * z
ex≥ˡ = refl
------------------------------------------------------------------------
-- Some suitably typed composition operators
infixr 9 _∘′_ _∘₂_
_∘′_ : {a c : Set} {b : a -> Set1} ->
(forall {x} -> b x -> c) -> ((x : a) -> b x) -> (a -> c)
f ∘′ g = \x -> f (g x)
_∘₂_ : {a b c : Set2} -> (b -> c) -> (a -> b) -> (a -> c)
f ∘₂ g = \x -> f (g x)
|
xcode_toggleImplAndTests.scpt | takasek/XCJumpToTests | 26 | 464 | <reponame>takasek/XCJumpToTests
#!/usr/bin/osascript
use AppleScript version "2.4" # Yosemite or later
use scripting additions
use framework "Foundation"
on run
tell application "Xcode"
# Xcodeで表示中のファイルの情報を取得
set projectPath to path of active workspace document
set projectFolder to characters 1 thru -((offset of "/" in (reverse of items of projectPath as string)) + 1) of projectPath as string
# display dialog projectFolder
set sourceName to (get name of window 1)
# display dialog sourceName
# Hoge.swift ⇄ HogeTests.swift のトグル変換
set w1 to ".swift"
set w2 to "Tests.swift"
set w3 to "Spec.swift"
if sourceName contains w2 then
set destinationName to (my replaceThis:(w2 & ".*") inString:sourceName usingThis:w1)
else if sourceName contains w3 then
set destinationName to (my replaceThis:(w3 & ".*") inString:sourceName usingThis:w1)
else
set destinationName to (my replaceThis:(w1 & ".*") inString:sourceName usingThis:w2)
end if
# display dialog destinationName
# ファイルパスを探して開く
# display dialog command
set command to "find " & quoted form of projectFolder & " -name " & quoted form of destinationName
set destinationPath to do shell script command
if length of destinationPath < 1 then
set destinationName to (my replaceThis:(w1 & ".*") inString:sourceName usingThis:w3)
set command to "find " & quoted form of projectFolder & " -name " & quoted form of destinationName
set destinationPath to do shell script command
end if
if length of destinationPath > 0 then
open destinationPath
else
display dialog "the file" & quoted form of destinationName & " not found."
end if
end tell
end run
# 正規表現置換
on replaceThis:thePattern inString:theString usingThis:theTemplate
set theNSString to current application's NSString's stringWithString:theString
set theOptions to (current application's NSRegularExpressionDotMatchesLineSeparators as integer) + (current application's NSRegularExpressionAnchorsMatchLines as integer)
set theRegEx to current application's NSRegularExpression's regularExpressionWithPattern:thePattern options:theOptions |error|:(missing value)
set theResult to theRegEx's stringByReplacingMatchesInString:theNSString options:0 range:{location:0, |length|:theNSString's |length|()} withTemplate:theTemplate
return theResult as text
end replaceThis:inString:usingThis:
|
projects/batfish/src/main/antlr4/org/batfish/grammar/f5_bigip_structured/F5BigipStructured_common.g4 | loftwah/batfish | 0 | 4732 | parser grammar F5BigipStructured_common;
options {
tokenVocab = F5BigipStructuredLexer;
}
bracket_list
:
BRACKET_LEFT
(
u_word
| u_word_list
)+ BRACKET_RIGHT
;
empty_list
:
BRACE_LEFT BRACE_RIGHT
;
list
:
empty_list
| word_list
| u_list
;
/* An unrecognized fragment of syntax. When used, MUST be LAST alternative */
unrecognized
:
(
(
IF u_word_list
)
| u_word+
) list? NEWLINE
;
u_list
:
BRACE_LEFT NEWLINE unrecognized+ BRACE_RIGHT
;
u_word
:
bracket_list
| word
;
u_word_list
:
BRACE_LEFT u_word+ BRACE_RIGHT
;
word
:
~( BRACE_LEFT | BRACE_RIGHT | BRACKET_LEFT | BRACKET_RIGHT | IMISH_CHUNK | NEWLINE )
;
word_list
:
BRACE_LEFT word+ BRACE_RIGHT
;
|
ECE263/Homework/Assignment-3.asm | Reiuiji/UmassdPortfolio | 3 | 99760 | <gh_stars>1-10
;<NAME>: Assignment 3
; export symbols
XDEF Entry, _Startup ;export 'Entry' symbol
ABSENTRY Entry ;for absolute assembly: mark this as entry point
;Memory Locations
ROMStart EQU $C000 ;absoolute address to place code/constant data
STRT_ADR EQU $8000
BYTE_SIZE EQU $8002
LAST_ADR EQU $8004
TEMP EQU $8010
TEMP_2 EQU $8012
;Set up the code variables section
ORG STRT_ADR
DC.W $4000 ;START ADDRESS value
DC.W $0010 ;BYTE_SIZE value
DC.W $0000 ;reset the last address value
;Set up the program code
ORG ROMStart
Entry:
_Startup:
;Phase 1
PHASE_1 LDD STRT_ADR
ADDD BYTE_SIZE
STD LAST_ADR ;sets the last address for the memory block
LDY BYTE_SIZE ;loads the size to y
LDAA Y
LDX STRT_ADR
LDAA X
CLRB
INX
BRA PHASE_2
;Phase 2: Bubble sort
PHASE_2 CMPA X
BLE PHASE_2.1
STAA TEMP ;swaps the bytes so to compare to the larges and
LDAA X ;put the smallest in its location
LDAB TEMP
STAB X
CLRB
PHASE_2.1 INX ;increment x then checks to see if it is the
CPX LAST_ADR ;last byte, if so then it will go to phase 4
BEQ PHASE_4 ;else it will return to the sort (phase 2)
BRA PHASE_2
PHASE_3 STAA TEMP ;will reset the current last address with the
LDD STRT_ADR ;new size
STY TEMP_2
ADDD TEMP_2
STD LAST_ADR
LDAA TEMP
CLRB
LDX STRT_ADR
BRA PHASE_2
PHASE_4 DEY ;decrement the size
CPY #$0
BEQ STOP
BRA PHASE_3
;endless loop for stop
STOP: BRA STOP
;Interrupt Vectors
ORG $FFFE
DC.W Entry ;reset vector
|
src/Data/QuadTree/Implementation/DataLenses.agda | JonathanBrouwer/research-project | 1 | 6438 | <reponame>JonathanBrouwer/research-project
module Data.QuadTree.Implementation.DataLenses where
open import Haskell.Prelude renaming (zero to Z; suc to S)
open import Data.Lens.Lens
open import Data.Logic
open import Data.QuadTree.Implementation.PropDepthRelation
open import Data.QuadTree.Implementation.Definition
open import Data.QuadTree.Implementation.ValidTypes
open import Data.QuadTree.Implementation.QuadrantLenses
{-# FOREIGN AGDA2HS
{-# LANGUAGE Safe #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE Rank2Types #-}
import Data.Nat
import Data.Lens.Lens
import Data.Logic
import Data.QuadTree.Implementation.Definition
import Data.QuadTree.Implementation.ValidTypes
import Data.QuadTree.Implementation.QuadrantLenses
#-}
---- Functions for whether a coordinate is inside
isInsideQuadTree : {t : Set} -> (Nat × Nat) -> QuadTree t -> Bool
isInsideQuadTree (x , y) (Wrapper (w , h) _) = x < w && y < h
isInsidePow : (Nat × Nat) -> Nat -> Bool
isInsidePow (x , y) deps = x < pow 2 deps && y < pow 2 deps
insideQTtoInsidePow : {t : Set} {{eqT : Eq t}} -> (loc : Nat × Nat) -> {dep : Nat} -> (vqt : VQuadTree t {dep})
-> IsTrue (isInsideQuadTree loc (qtFromSafe vqt))
-> IsTrue (isInsidePow loc dep)
insideQTtoInsidePow (x , y) {dep} (CVQuadTree (Wrapper (w , h) qd) {p} {q}) it =
let
p1 : IsTrue (pow 2 dep >= (max w h))
p1 = log2upPow dep (max w h) (eqToGte dep (log2up (max w h)) q)
p2 : IsTrue ((max w h) <= pow 2 dep)
p2 = gteInvert (pow 2 dep) (max w h) p1
p3 : IsTrue (w <= pow 2 dep && h <= pow 2 dep)
p3 = useEq (sym $ propMaxLte w h (pow 2 dep)) p2
in andCombine
( ltLteTransitive x w (pow 2 dep) (andFst {x < w} it) (andFst p3) )
( ltLteTransitive y h (pow 2 dep) (andSnd {x < w} it) (andSnd p3) )
---- Data access
-- Lens into the leaf quadrant corresponding to a location in a quadrant
go : {t : Set} {{eqT : Eq t}}
-> (loc : Nat × Nat) -> (dep : Nat)
-> {.(IsTrue (isInsidePow loc dep))}
-> Lens (VQuadrant t {dep}) t
go _ Z = lensLeaf
go {t} (x , y) (S deps) =
let
mid = pow 2 deps
gorec = go {t} (mod x mid {pow_not_zero_cv deps} , mod y mid {pow_not_zero_cv deps}) deps
{andCombine (modLt x mid {pow_not_zero_cv deps}) (modLt y mid {pow_not_zero_cv deps})}
in
if (y < mid)
then if x < mid
then (lensA ∘ gorec)
else (lensB ∘ gorec)
else if x < mid
then (lensC ∘ gorec)
else (lensD ∘ gorec)
{-# COMPILE AGDA2HS go #-}
-- Lenses into the root quadrant of a quadtree
lensWrappedTree : {t : Set} {{eqT : Eq t}}
-> {dep : Nat}
-> Lens (VQuadTree t {dep}) (VQuadrant t {dep})
lensWrappedTree fun (CVQuadTree (Wrapper (w , h) qd) {p} {q}) =
fmap
(λ where (CVQuadrant qd {p}) → CVQuadTree (Wrapper (w , h) qd) {p} {q})
(fun (CVQuadrant qd {p}))
{-# COMPILE AGDA2HS lensWrappedTree #-}
-- Lens into the leaf quadrant corresponding to a location in a quadtree
atLocation : {t : Set} {{eqT : Eq t}}
-> (loc : Nat × Nat) -> (dep : Nat)
-> {.(IsTrue (isInsidePow loc dep))}
-> Lens (VQuadTree t {dep}) t
atLocation index dep {p} = lensWrappedTree ∘ (go index dep {p})
{-# COMPILE AGDA2HS atLocation #-} |
scripts/ViridianSchoolHouse.asm | opiter09/ASM-Machina | 1 | 96060 | ViridianSchoolHouse_Script:
jp EnableAutoTextBoxDrawing
ViridianSchoolHouse_TextPointers:
dw SchoolText1
dw SchoolText2
SchoolText1:
text_far _SchoolText1
text_end
SchoolText2:
text_far _SchoolText2
text_end
|
src/lambda.adb | ebolar/Unbounded | 0 | 9757 | <filename>src/lambda.adb
-- Lambda Calculus interpreter
-- ---------------------------
-- Parses and reduces Lamdba Calculus statements.
--
-- Source:
-- lambda - [This file] definitions and helper functions
-- lambda_REPL - REPL and command line parsers
-- lambda_parser - parse tree generator
-- lambda_reducer - optimises and reduces lambda expressions
--
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Text_IO.Unbounded_IO;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Maps; use Ada.Strings.Maps;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.IO_Exceptions;
with Ada.Containers; use Ada.Containers;
with Ada.Containers.Multiway_Trees;
Package body Lambda is
-- Format all the elements in an instructions tree for printing
-- Public function
function format ( I: Instructions.tree ) return Statement is
Buffer : SU.Unbounded_String := SU.Null_Unbounded_String;
Curs : Instructions.Cursor;
begin
if not Instructions.is_Empty(I)
then
for Curs in Iterate_Children( Container => I, Parent => Root(I) )
loop
SU.Append(Buffer, format_Element(I, Curs));
end loop;
end if;
return SU.To_String(Buffer);
end;
-- Format all the elements in an instructions sub-tree for printing
-- Public function
function format ( I: Instructions.tree; Curs : Instructions.Cursor ) return Statement is
Buffer : SU.Unbounded_String := SU.Null_Unbounded_String;
begin
if not Instructions.is_Empty(I) and then Curs /= Instructions.No_Element
then
SU.Append(Buffer, format_Element(I, Curs));
end if;
return SU.To_String(Buffer);
end;
-- Recursively format all of the instruction elements
-- Private function
function format_Element ( I : Instructions.tree; Curs : Instructions.Cursor ) return SU.Unbounded_String is
Buffer : SU.Unbounded_String := SU.Null_Unbounded_String;
Node : Element_Record := Instructions.Element(Curs);
E : Element_Record;
variables : Boolean;
begin
case Node.Element is
when L_Expression =>
SU.Append(Buffer, '(');
for C in Iterate_Children( Container => I, Parent => Curs )
loop
SU.Append(Buffer, format_Element(I, C));
end loop;
SU.Append(Buffer, ')');
when L_Function =>
SU.Append(Buffer, Node.Name);
variables := True;
for C in Iterate_Children( Container => I, Parent => Curs )
loop
if variables
then
E := Instructions.Element(C);
if E.Element /= L_Variable
then
variables := False;
SU.Append(Buffer, '.');
end if;
end if;
SU.Append(Buffer, format_Element(I, C));
end loop;
when L_Definition =>
-- put Synonym
SU.Append(Buffer, Node.Name);
SU.Append(Buffer, '=');
-- format(Expression)
for C in Iterate_Children( Container => I, Parent => Curs )
loop
SU.Append(Buffer, format_Element(I, C));
end loop;
when L_Variable | L_Synonym =>
SU.Append(Buffer, Node.Name);
when L_Comments =>
declare
First : Element_Record := First_Child_Element(Root(I));
begin
if First.Element /= L_Comments
then
-- add a separator
SU.Append(Buffer, " ");
end if;
SU.Append(Buffer, Node.Name);
SU.Append(Buffer, Node.Comments);
end;
end case;
return Buffer;
end;
-- Log the structure of the instructions tree
procedure Log_Format ( I: Instructions.tree ) is
Curs : Instructions.Cursor;
procedure Log_Format_Element ( I : Instructions.tree; Curs : Instructions.Cursor ) is
Node : Element_Record := Instructions.Element(Curs);
begin
case Node.Element is
when L_Expression | L_Function | L_Definition =>
Log(Log_Format, Indent(Natural(Instructions.Depth(Curs))) &
"[" & Element_Type'Image(Node.Element) &
", " & Node.Name &
", Is_Explicit=" & Boolean'Image(Node.Is_Explicit) &
"]");
for C in Iterate_Children( Container => I, Parent => Curs )
loop
Log_Format_Element(I, C);
end loop;
when L_Variable | L_Synonym =>
Log(Log_Format, Indent(Natural(Instructions.Depth(Curs))) &
"[" & Element_Type'Image(Node.Element) &
", " & Node.Name &
", Is_Explicit=" & Boolean'Image(Node.Is_Explicit) &
"]");
when L_Comments =>
Log(Log_Format, Indent(Natural(Instructions.Depth(Curs))) &
"[" & Element_Type'Image(Node.Element) &
", '" & Node.Name & Ada.Strings.Fixed.Trim(Node.Comments, Right ) & "'" &
", Is_Explicit=" & Boolean'Image(Node.Is_Explicit) &
"]");
end case;
end;
begin
if Trace and Trace_Format and not Instructions.is_Empty(I)
then
for Curs in Iterate_Children( Container => I, Parent => Root(I) )
loop
Log_Format_Element(I, Curs);
end loop;
end if;
end;
-- Add a Synonym to the list
--
-- Nb: Synonyms are stored in alphabetical order
procedure Add_Synonym ( Source: Instructions.Cursor ) is
Node : Element_Record := Instructions.Element(Source);
Before : Instructions.Cursor := No_Element;
Parent : Instructions.Cursor := Root(Synonyms);
SE : Element_Record;
begin
If Node.Element /= L_Definition then
raise Program_Error with "Cannot add " & Element_Type'Image(Node.Element) & " as a synonym";
end if;
if not(Instructions.Is_Empty(Synonyms)) then
-- Search for a Synonym of the same name
for Curs in Iterate_Children( Container => Synonyms, Parent => Root(Synonyms) )
loop
SE := Instructions.Element(Curs);
if SE.Name >= Node.Name then
Before := Curs;
exit;
end if;
end loop;
end if;
Copy_Subtree( Target => Synonyms,
Parent => Parent,
Before => Before,
Source => Source);
if not(Instructions.Is_Empty(Synonyms)) and then SE.Name = Node.Name then
Delete_Subtree( Container => Synonyms, Position => Before );
end if;
end;
-- Remove a Synonym from the list
procedure Remove_Synonym ( S: Statement ) is
SE : Element_Record;
Curs : Instructions.Cursor;
Found : Boolean := FALSE;
begin
Curs := First_Child(Root(Synonyms));
loop
exit when Curs = No_Element;
SE := Instructions.Element(Curs);
if SE.Name = S(S'First)
then
Log("Removing ", Synonyms, Curs);
Delete_Subtree( Container => Synonyms, Position => Curs);
Found := TRUE;
exit;
end if;
Curs := Next_Sibling(Curs);
end loop;
if not Found
then
Put_Line(". Synonym " & S(S'First) & " not found");
end if;
end;
-- List all Synonyms
procedure List_Synonyms is
begin
if not(Instructions.Is_Empty(Synonyms)) then
for Curs in Iterate_Children( Container => Synonyms, Parent => Root(Synonyms) )
loop
Put_Line(format(Synonyms, Curs));
end loop;
else
Put_Line(". empty");
end if;
end;
-- General logging, eg for the REPL
procedure Log(S : String) is
begin
if Trace
then
Put_Line(".. " & S);
end if;
end;
procedure Log(S : String; I : Instructions.Tree ) is
begin
if Trace
then
Put_Line(".. " & S & format(I));
end if;
end;
procedure Log(S : String; I : Instructions.Tree; C : Instructions.Cursor ) is
begin
if Trace
then
Put_Line(".. " & S & format(I, C));
end if;
end;
-- Granular logging
procedure Log(T : Log_Type; S : String) is
begin
if Trace
then
case T is
when Log_Parse =>
if Trace_Parse then
Put_Line("... P-" & S);
end if;
when Log_Reduce =>
if Trace_Reduce then
Put_Line("... R-" & S);
end if;
when Log_Format =>
if Trace_Format then
Put_Line("... F-" & S);
end if;
when others =>
raise program_error with "Unexpected log type " & Log_Type'image(T);
end case;
end if;
end;
procedure Log(T : Log_Type; S : String; I : Instructions.Tree ) is
begin
if Trace
then
case T is
when Log_Parse =>
if Trace_Parse then
Put_Line("... P-" & S & Format(I));
end if;
when Log_Reduce =>
if Trace_Reduce then
Put_Line("... R-" & S & Format(I));
end if;
when Log_Format =>
if Trace_Format then
Put_Line("... F-" & S & Format(I));
end if;
when others =>
raise program_error with "Unexpected log type " & Log_Type'image(T);
end case;
end if;
end;
procedure Log(T : Log_Type; S : String; I : Instructions.Tree; C : Instructions.Cursor ) is
begin
if Trace
then
case T is
when Log_Parse =>
if Trace_Parse then
Put_Line("... P-" & S & Format(I, C));
end if;
when Log_Reduce =>
if Trace_Reduce then
Put_Line("... R-" & S & Format(I, C));
end if;
when Log_Format =>
if Trace_Format then
Put_Line("... F-" & S & Format(I, C));
end if;
when others =>
raise program_error with "Unexpected log type " & Log_Type'image(T);
end case;
end if;
end;
function indent( I : Natural ) return String is
-- should be more than long enough
M : String := Ada.Strings.Fixed.Head("", Max_Statement_Length/2, ' ');
begin
return M(1..I);
end;
end Lambda;
|
tpantlr2-code/code/debug/DOT.g4 | cgonul/antlr-poc | 10 | 7390 | /** Derived from http://www.graphviz.org/doc/info/lang.html.
Comments pulled from spec.
has some ambig on
digraph structs {
node [shape=plaintext]
struct1 [label=<<i>foo</i>>];
struct1 [label=<ε>];
struct2 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
<TR><TD PORT="f0">one</TD><TD>two</TD></TR>
</TABLE>>];
struct3 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
<TD ROWSPAN="3">hello<BR/>world</TD>
<TD COLSPAN="3">b</TD>
<TD ROWSPAN="3">g</TD>
<TD ROWSPAN="3">h</TD>
</TR>
<TR>
<TD>c</TD><TD PORT="here">d</TD><TD>e</TD>
</TR>
<TR>
<TD COLSPAN="3">f</TD>
</TR>
</TABLE>>];
struct1:f1 -> struct2:f0;
struct1:f2 -> struct3:here;
}
*/
grammar DOT;
graph : STRICT? (GRAPH | DIGRAPH) id? '{' stmt_list '}' ;
stmt_list : ( stmt ';'? )* ;
stmt : node_stmt
| edge_stmt
| attr_stmt
| id '=' id
| subgraph
;
attr_stmt : (GRAPH | NODE | EDGE) attr_list ;
attr_list : ('[' a_list? ']')+ ;
a_list : (id ('=' id)? ','?)+ ;
edge_stmt : (node_id | subgraph) edgeRHS attr_list? ;
edgeRHS : ( edgeop (node_id | subgraph) )+ ;
edgeop : '->' | '--' ;
node_stmt : node_id attr_list? ;
node_id : id port? ;
port : ':' id (':' compass_pt)?
| ':' compass_pt
;
subgraph : (SUBGRAPH id?)? '{' stmt_list '}' ;
/** "the allowed compass point values are not keywords, so these strings
* can be used elsewhere as ordinary identifiers and, conversely, the
* parser will actually accept any identifier.
* 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw' | 'c' | '_'"
* TJP: later the ID needs to be checked for membership in these
* compass points.
*/
compass_pt : ID | '_' ;
id : ID
| STRING
| HTML_STRING
| NUMBER
;
// "The keywords node, edge, graph, digraph, subgraph, and strict are
// case-independent"
STRICT : [Ss][Tt][Rr][Ii][Cc][Tt] ;
GRAPH : [Gg][Rr][Aa][Pp][Hh] ;
DIGRAPH : [Dd][Ii][Gg][Rr][Aa][Pp][Hh] ;
NODE : [Nn][Oo][Dd][Ee] ;
EDGE : [Ee][Dd][Gg][Ee] ;
SUBGRAPH : [Ss][Uu][Bb][Gg][Rr][Aa][Pp][Hh] ;
/** "a numeral [-]?(.[0-9]+ | [0-9]+(.[0-9]*)? )" */
NUMBER : '-'? ('.' DIGIT+ | DIGIT+ ('.' DIGIT*)? ) ;
fragment
DIGIT : '0'..'9' ;
/** "any double-quoted string ("...") possibly containing escaped quotes" */
STRING : '"' ('\\"'|.)*? '"' ;
/** "HTML strings, angle brackets must occur in matched pairs, and
* unescaped newlines are allowed."
*/
HTML_STRING : '<' (TAG|EntityRef|.)* '>' ;
TAG : '<' .*? '>' ;
EntityRef : '&' LETTER+ ';' ;
/** "Any string of alphabetic ([a-zA-Z\200-\377]) characters, underscores
* ('_') or digits ([0-9]), not beginning with a digit"
*/
ID : LETTER (LETTER|DIGIT)*;
fragment
LETTER : [a-zA-Z\u0080-\u00FF_] ;
COMMENT : '/*' .*? '*/' {skip();} ;
LINE_COMMENT: '//' .*? '\r'? '\n' {skip();} ;
/** "a '#' character is considered a line output from a C preprocessor (e.g.,
* # 34 to indicate line 34 ) and discarded"
*/
PREPROC : '#' .*? '\n' -> skip ;
WS : [ \t\r\n] -> skip ;
|
old/Structure/Logic/Constructive/Functions.agda | Lolirofle/stuff-in-agda | 6 | 9298 | import Lvl
open import Type
module Structure.Logic.Constructive.Functions {ℓₒ} (Domain : Type{ℓₒ}) where
private
module Meta where
open import Numeral.Finite public
open import Numeral.Natural public
-- The type of a function. Functions on the domain in the meta-logic.
Function : Type{_}
Function = (Domain → Domain)
BinaryOperator : Type{_}
BinaryOperator = (Domain → Domain → Domain)
Tuple : Meta.ℕ → Type{_}
Tuple(n) = Meta.𝕟(n) → Domain
Sequence : Type{_}
Sequence = Meta.ℕ → Domain
|
programs/oeis/016/A016971.asm | karttu/loda | 1 | 98703 | ; A016971: a(n) = (6*n + 5)^3.
; 125,1331,4913,12167,24389,42875,68921,103823,148877,205379,274625,357911,456533,571787,704969,857375,1030301,1225043,1442897,1685159,1953125,2248091,2571353,2924207,3307949,3723875,4173281,4657463,5177717,5735339,6331625,6967871,7645373,8365427,9129329,9938375,10793861,11697083,12649337,13651919,14706125,15813251,16974593,18191447,19465109,20796875,22188041,23639903,25153757,26730899,28372625,30080231,31855013,33698267,35611289,37595375,39651821,41781923,43986977,46268279,48627125,51064811,53582633,56181887,58863869,61629875,64481201,67419143,70444997,73560059,76765625,80062991,83453453,86938307,90518849,94196375,97972181,101847563,105823817,109902239,114084125,118370771,122763473,127263527,131872229,136590875,141420761,146363183,151419437,156590819,161878625,167284151,172808693,178453547,184220009,190109375,196122941,202262003,208527857,214921799,221445125,228099131,234885113,241804367,248858189,256047875,263374721,270840023,278445077,286191179,294079625,302111711,310288733,318611987,327082769,335702375,344472101,353393243,362467097,371694959,381078125,390617891,400315553,410172407,420189749,430368875,440711081,451217663,461889917,472729139,483736625,494913671,506261573,517781627,529475129,541343375,553387661,565609283,578009537,590589719,603351125,616295051,629422793,642735647,656234909,669921875,683797841,697864103,712121957,726572699,741217625,756058031,771095213,786330467,801765089,817400375,833237621,849278123,865523177,881974079,898632125,915498611,932574833,949862087,967361669,985074875,1003003001,1021147343,1039509197,1058089859,1076890625,1095912791,1115157653,1134626507,1154320649,1174241375,1194389981,1214767763,1235376017,1256216039,1277289125,1298596571,1320139673,1341919727,1363938029,1386195875,1408694561,1431435383,1454419637,1477648619,1501123625,1524845951,1548816893,1573037747,1597509809,1622234375,1647212741,1672446203,1697936057,1723683599,1749690125,1775956931,1802485313,1829276567,1856331989,1883652875,1911240521,1939096223,1967221277,1995616979,2024284625,2053225511,2082440933,2111932187,2141700569,2171747375,2202073901,2232681443,2263571297,2294744759,2326203125,2357947691,2389979753,2422300607,2454911549,2487813875,2521008881,2554497863,2588282117,2622362939,2656741625,2691419471,2726397773,2761677827,2797260929,2833148375,2869341461,2905841483,2942649737,2979767519,3017196125,3054936851,3092990993,3131359847,3170044709,3209046875,3248367641,3288008303,3327970157,3368254499
mul $0,6
add $0,5
pow $0,3
mov $1,$0
|
coverage/IN_CTS/0439-COVERAGE-nir-opt-constant-folding-238-340-nir-range-analysis-866/work/variant/1_spirv_asm/shader.frag.asm | asuonpaa/ShaderTests | 0 | 81149 | ; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 188
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %12 %186
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %9 "coord"
OpName %12 "gl_FragCoord"
OpName %16 "res"
OpName %21 "buf1"
OpMemberName %21 0 "_GLF_uniform_int_values"
OpName %23 ""
OpName %41 "i"
OpName %51 "j"
OpName %59 "a"
OpName %66 "f0"
OpName %73 "indexable"
OpName %77 "indexable"
OpName %81 "indexable"
OpName %85 "f1"
OpName %87 "indexable"
OpName %91 "indexable"
OpName %95 "indexable"
OpName %99 "v0"
OpName %102 "v1"
OpName %106 "tex"
OpName %114 "v2"
OpName %119 "indexable"
OpName %123 "v3"
OpName %128 "indexable"
OpName %132 "v4"
OpName %149 "indexable"
OpName %153 "v5"
OpName %158 "v6"
OpName %169 "buf0"
OpMemberName %169 0 "_GLF_uniform_float_values"
OpName %171 ""
OpName %186 "_GLF_color"
OpDecorate %12 BuiltIn FragCoord
OpDecorate %20 ArrayStride 16
OpMemberDecorate %21 0 Offset 0
OpDecorate %21 Block
OpDecorate %23 DescriptorSet 0
OpDecorate %23 Binding 1
OpDecorate %106 RelaxedPrecision
OpDecorate %106 DescriptorSet 0
OpDecorate %106 Binding 2
OpDecorate %107 RelaxedPrecision
OpDecorate %109 RelaxedPrecision
OpDecorate %110 RelaxedPrecision
OpDecorate %111 RelaxedPrecision
OpDecorate %115 RelaxedPrecision
OpDecorate %117 RelaxedPrecision
OpDecorate %124 RelaxedPrecision
OpDecorate %126 RelaxedPrecision
OpDecorate %133 RelaxedPrecision
OpDecorate %147 RelaxedPrecision
OpDecorate %168 ArrayStride 16
OpMemberDecorate %169 0 Offset 0
OpDecorate %169 Block
OpDecorate %171 DescriptorSet 0
OpDecorate %171 Binding 0
OpDecorate %186 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeFloat 32
%7 = OpTypeVector %6 2
%8 = OpTypePointer Function %7
%10 = OpTypeVector %6 4
%11 = OpTypePointer Input %10
%12 = OpVariable %11 Input
%15 = OpTypePointer Function %10
%17 = OpTypeInt 32 1
%18 = OpTypeInt 32 0
%19 = OpConstant %18 2
%20 = OpTypeArray %17 %19
%21 = OpTypeStruct %20
%22 = OpTypePointer Uniform %21
%23 = OpVariable %22 Uniform
%24 = OpConstant %17 0
%25 = OpTypePointer Uniform %17
%29 = OpConstant %17 1
%40 = OpTypePointer Function %17
%48 = OpConstant %17 3
%49 = OpTypeBool
%63 = OpConstant %17 9
%65 = OpTypePointer Function %6
%67 = OpConstant %18 9
%68 = OpTypeArray %6 %67
%69 = OpConstant %6 0
%70 = OpConstantComposite %68 %69 %69 %69 %69 %69 %69 %69 %69 %69
%72 = OpTypePointer Function %68
%103 = OpTypeImage %6 2D 0 0 0 1 Unknown
%104 = OpTypeSampledImage %103
%105 = OpTypePointer UniformConstant %104
%106 = OpVariable %105 UniformConstant
%154 = OpConstant %6 1
%155 = OpConstantComposite %10 %154 %154 %154 %154
%167 = OpConstant %18 1
%168 = OpTypeArray %6 %167
%169 = OpTypeStruct %168
%170 = OpTypePointer Uniform %169
%171 = OpVariable %170 Uniform
%172 = OpTypePointer Uniform %6
%185 = OpTypePointer Output %10
%186 = OpVariable %185 Output
%4 = OpFunction %2 None %3
%5 = OpLabel
%9 = OpVariable %8 Function
%16 = OpVariable %15 Function
%41 = OpVariable %40 Function
%51 = OpVariable %40 Function
%59 = OpVariable %40 Function
%66 = OpVariable %65 Function
%73 = OpVariable %72 Function
%77 = OpVariable %72 Function
%81 = OpVariable %72 Function
%85 = OpVariable %65 Function
%87 = OpVariable %72 Function
%91 = OpVariable %72 Function
%95 = OpVariable %72 Function
%99 = OpVariable %15 Function
%102 = OpVariable %15 Function
%114 = OpVariable %15 Function
%119 = OpVariable %72 Function
%123 = OpVariable %15 Function
%128 = OpVariable %72 Function
%132 = OpVariable %15 Function
%149 = OpVariable %72 Function
%153 = OpVariable %15 Function
%158 = OpVariable %15 Function
%13 = OpLoad %10 %12
%14 = OpVectorShuffle %7 %13 %13 0 1
OpStore %9 %14
%26 = OpAccessChain %25 %23 %24 %24
%27 = OpLoad %17 %26
%28 = OpConvertSToF %6 %27
%30 = OpAccessChain %25 %23 %24 %29
%31 = OpLoad %17 %30
%32 = OpConvertSToF %6 %31
%33 = OpAccessChain %25 %23 %24 %29
%34 = OpLoad %17 %33
%35 = OpConvertSToF %6 %34
%36 = OpAccessChain %25 %23 %24 %24
%37 = OpLoad %17 %36
%38 = OpConvertSToF %6 %37
%39 = OpCompositeConstruct %10 %28 %32 %35 %38
OpStore %16 %39
OpStore %41 %24
OpBranch %42
%42 = OpLabel
OpLoopMerge %44 %45 None
OpBranch %46
%46 = OpLabel
%47 = OpLoad %17 %41
%50 = OpSLessThan %49 %47 %48
OpBranchConditional %50 %43 %44
%43 = OpLabel
OpStore %51 %24
OpBranch %52
%52 = OpLabel
OpLoopMerge %54 %55 None
OpBranch %56
%56 = OpLabel
%57 = OpLoad %17 %51
%58 = OpSLessThan %49 %57 %48
OpBranchConditional %58 %53 %54
%53 = OpLabel
%60 = OpLoad %17 %41
%61 = OpLoad %17 %51
%62 = OpIAdd %17 %60 %61
%64 = OpExtInst %17 %1 SClamp %62 %24 %63
OpStore %59 %64
%71 = OpLoad %17 %59
OpStore %73 %70
%74 = OpAccessChain %65 %73 %71
%75 = OpLoad %6 %74
%76 = OpLoad %17 %59
OpStore %77 %70
%78 = OpAccessChain %65 %77 %76
%79 = OpLoad %6 %78
%80 = OpLoad %17 %59
OpStore %81 %70
%82 = OpAccessChain %65 %81 %80
%83 = OpLoad %6 %82
%84 = OpExtInst %6 %1 FClamp %75 %79 %83
OpStore %66 %84
%86 = OpLoad %17 %59
OpStore %87 %70
%88 = OpAccessChain %65 %87 %86
%89 = OpLoad %6 %88
%90 = OpLoad %17 %59
OpStore %91 %70
%92 = OpAccessChain %65 %91 %90
%93 = OpLoad %6 %92
%94 = OpLoad %17 %59
OpStore %95 %70
%96 = OpAccessChain %65 %95 %94
%97 = OpLoad %6 %96
%98 = OpExtInst %6 %1 FClamp %89 %93 %97
OpStore %85 %98
%100 = OpLoad %6 %66
%101 = OpCompositeConstruct %10 %100 %100 %100 %100
OpStore %99 %101
%107 = OpLoad %104 %106
%108 = OpLoad %17 %41
%109 = OpConvertSToF %6 %108
%110 = OpCompositeConstruct %7 %109 %109
%111 = OpImageSampleImplicitLod %10 %107 %110
%112 = OpLoad %6 %85
%113 = OpVectorTimesScalar %10 %111 %112
OpStore %102 %113
%115 = OpLoad %104 %106
%116 = OpLoad %7 %9
%117 = OpImageSampleImplicitLod %10 %115 %116
%118 = OpLoad %17 %59
OpStore %119 %70
%120 = OpAccessChain %65 %119 %118
%121 = OpLoad %6 %120
%122 = OpVectorTimesScalar %10 %117 %121
OpStore %114 %122
%124 = OpLoad %104 %106
%125 = OpLoad %7 %9
%126 = OpImageSampleImplicitLod %10 %124 %125
%127 = OpLoad %17 %59
OpStore %128 %70
%129 = OpAccessChain %65 %128 %127
%130 = OpLoad %6 %129
%131 = OpVectorTimesScalar %10 %126 %130
OpStore %123 %131
%133 = OpLoad %104 %106
%134 = OpLoad %7 %9
%135 = OpLoad %17 %41
%136 = OpAccessChain %25 %23 %24 %24
%137 = OpLoad %17 %136
%138 = OpISub %17 %135 %137
%139 = OpConvertSToF %6 %138
%140 = OpLoad %17 %51
%141 = OpAccessChain %25 %23 %24 %24
%142 = OpLoad %17 %141
%143 = OpISub %17 %140 %142
%144 = OpConvertSToF %6 %143
%145 = OpCompositeConstruct %7 %139 %144
%146 = OpFAdd %7 %134 %145
%147 = OpImageSampleImplicitLod %10 %133 %146
%148 = OpLoad %17 %59
OpStore %149 %70
%150 = OpAccessChain %65 %149 %148
%151 = OpLoad %6 %150
%152 = OpVectorTimesScalar %10 %147 %151
OpStore %132 %152
%156 = OpLoad %10 %114
%157 = OpExtInst %10 %1 FMin %155 %156
OpStore %153 %157
%159 = OpLoad %10 %123
%160 = OpLoad %10 %153
%161 = OpExtInst %10 %1 FMin %159 %160
OpStore %158 %161
%162 = OpLoad %10 %99
%163 = OpLoad %10 %102
%164 = OpExtInst %10 %1 FMin %162 %163
%165 = OpLoad %10 %158
%166 = OpExtInst %10 %1 FMin %164 %165
%173 = OpAccessChain %172 %171 %24 %24
%174 = OpLoad %6 %173
%175 = OpCompositeConstruct %10 %174 %174 %174 %174
%176 = OpFAdd %10 %166 %175
%177 = OpLoad %10 %132
%178 = OpExtInst %10 %1 FMin %176 %177
%179 = OpLoad %10 %16
%180 = OpFAdd %10 %179 %178
OpStore %16 %180
OpBranch %55
%55 = OpLabel
%181 = OpLoad %17 %51
%182 = OpIAdd %17 %181 %29
OpStore %51 %182
OpBranch %52
%54 = OpLabel
OpBranch %45
%45 = OpLabel
%183 = OpLoad %17 %41
%184 = OpIAdd %17 %183 %29
OpStore %41 %184
OpBranch %42
%44 = OpLabel
%187 = OpLoad %10 %16
OpStore %186 %187
OpReturn
OpFunctionEnd
|
test/Fail/RecordPattern2.agda | shlevy/agda | 1,989 | 15707 | postulate A : Set
record R : Set where
field f : A
record S : Set where
field g : A
test : R → A
test record{g = a} = a
|
models/tests/test65a.als | transclosure/Amalgam | 4 | 785 | <gh_stars>1-10
module tests/test
open util/time
one sig Light { brightness: dynamic[Int] }
let b = Light.brightness
pred incr [t, t': Time] {
b.t' = b.t + 1
t' = t.next
}
pred decr [t, t': Time] {
b.t' = b.t - 1
t' = t.next
}
pred incrThenReturnOld [out: Int, t,t': Time] {
out = b.t
b.t' = b.t + 1
t' = t.next
}
let both = incr.then[decr]
let cond[t] = b.t > 0
run {
some t:Time | some x:Int | { incrThenReturnOld[x].then[both].then[decr] [first, t] && b.t=x }
} for 7 Time expect 1
run {
some t:Time | some x:Int | { incrThenReturnOld[x].then[decr].then[both].then[decr] [first, t] && b.t=x }
} for 7 Time expect 0
run {
some t:Time | b.first=3 && while[cond, decr, first, t]
} for 7 Time expect 1
run {
some t:Time | b.first=4 && while[cond, decr, first, t]
} for 7 Time expect 0
|
grammar/YAML.g4 | omry/addax | 0 | 419 | <gh_stars>0
/** Grammars always start with a grammar header. This grammar is called
* ArrayInit and must match the filename: ArrayInit.g4
*/
grammar YAML;
// Comments starting with /// are copied from the YAML 1.2 reference https://yaml.org/spec/1.2/spec.htm.
tokens {
INDENT,
DEDENT
}
//=============== Parser ===============
document:;
//=============== LEXER ===============
fragment BOM_UTF32_BE: '\u0000' '\u0000' '\u00fe' '\u00ff';
fragment BOM_UTF32_LE: '\u00ff' '\u00fe' '\u0000' '\u0000';
fragment BOM_UTF16_BE: '\u00fe' '\u00ff';
fragment BOM_UTF16_LE: '\u00ff' '\u00fe';
fragment BOM_UTF8 : '\u00ef' '\u00bb' '\u00bf';
BOM_MARKER: BOM_UTF32_BE | BOM_UTF32_LE | BOM_UTF16_BE | BOM_UTF16_LE | BOM_UTF8;
// Character Set
// with all other tokens removed from it to prevent conflicts
/// 8 bit : #x9 | #xA | #xD | [#x20-#x7E]
fragment PRINTABLE_8BIT: '\u0024' | '\u0028'..'\u0029' | '\u002B' | '\u002E'..'\u0039' | '\u003B'..'\u003D' | '\u0041'..'\u005A' | '\u005C' | '\u005E'..'\u005F' | '\u0061'..'\u007A' | '\u007E';
/// 16 bit: #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD]
fragment PRINTABLE_16BIT: '\u0085' | '\u00A0'..'\u0D09' | '\u0D0B'..'\uD7FF' | '\uE000'..'\uFEFE' | '\uFF00'..'\uFFFD';
/// 32 bit: [#x10000-#x10FFFF]
fragment PRINTABLE_32BIT: '\u{010000}'..'\u{10FFFF}';
// None space char
NS_CHAR: PRINTABLE_8BIT | PRINTABLE_16BIT | PRINTABLE_32BIT;
// TODO: this should only be allowed inside quoted strings.
/// nb-json ::= #x9 | [#x20-#x10FFFF]
//fragment NB_JSON: '\u{000020}'..'\u{10FFFF}';
// Indicator Characters
C_SEQUENCE_ENTRY: '-';
C_MAPPING_KEY : '?';
C_MAPPING_VALUE : ':';
C_COLLECT_ENTRY : ',';
C_SEQUENCE_START : '[';
C_SEQUENCE_END : ']';
C_MAPPING_START : '{';
C_MAPPING_END : '}';
C_COMMENT : '#';
C_ANCHOR : '&';
C_ALIAS : '*';
C_TAG : '!';
C_LITERAL : '|';
C_FOLDED : '>';
C_SINGLE_QUOTE : '\'';
C_DOUBLE_QUOTE : '"';
C_DIRECTIVE : '%';
C_RESERVED : '@' | '`';
fragment
C_INDICATOR : C_SEQUENCE_ENTRY | C_MAPPING_KEY| C_MAPPING_VALUE | C_COLLECT_ENTRY |
C_SEQUENCE_START | C_SEQUENCE_END | C_MAPPING_START | C_MAPPING_END |
C_COMMENT | C_ANCHOR | C_ALIAS | C_TAG | C_LITERAL | C_FOLDED |
C_SINGLE_QUOTE | C_DOUBLE_QUOTE | C_DIRECTIVE | C_RESERVED;
fragment
C_FLOW_INDICATOR : C_COLLECT_ENTRY | C_SEQUENCE_START | C_SEQUENCE_END | C_MAPPING_START | C_MAPPING_END;
/// Line Break Characters
/// [24] b-line-feed ::= #xA /* LF */
/// [25] b-carriage-return ::= #xD /* CR */
/// [26] b-char ::= b-line-feed | b-carriage-return
fragment B_LINE_FEED: '\u000a'; /* LF */
fragment B_CARRIAGE_RETURN: '\u000d'; /* CR */
fragment B_CHAR: B_LINE_FEED | B_CARRIAGE_RETURN;
/// [28] b-break ::= ( b-carriage-return b-line-feed ) /* DOS, Windows */
/// | b-carriage-return /* MacOS upto 9.x */
/// | b-line-feed /* UNIX, MacOS X */
B_BREAK: (B_CARRIAGE_RETURN B_LINE_FEED |
B_CARRIAGE_RETURN |
B_LINE_FEED);
/// [29] b-as-line-feed ::= b-break
fragment B_AS_LINE_FEED: B_BREAK;
//. [30] b-non-content ::= b-break
fragment B_NON_CONTENT: B_BREAK;
/// Whitespace characters
/// [31] s-space ::= #x20 /* SP */
/// [32] s-tab ::= #x9 /* TAB */
/// [33] s-white ::= s-space | s-tab
fragment S_SPACE: ' ';
fragment S_TAB: '\t';
fragment S_WHITE: S_SPACE | S_TAB;
/// [35] ns-dec-digit ::= [#x30-#x39] /* 0-9 */
fragment NS_DEC_DIGIT: '0'..'9';
/// [36] ns-hex-digit ::= ns-dec-digit
/// | [#x41-#x46] /* A-F */ | [#x61-#x66] /* a-f */
fragment NS_HEX_DIGIT: NS_DEC_DIGIT | 'A'..'F' | 'a'..'f';
/// [37] ns-ascii-letter ::= [#x41-#x5A] /* A-Z */ | [#x61-#x7A] /* a-z */
fragment NS_ASCII_LETTER: 'A'..'Z' | 'a'..'z';
/// [38] ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-”
fragment NS_WORD_CHAR: NS_DEC_DIGIT | NS_ASCII_LETTER | '-';
/// [39] ns-uri-char ::= “%” ns-hex-digit ns-hex-digit | ns-word-char | “#”
/// | “;” | “/” | “?” | “:” | “@” | “&” | “=” | “+” | “$” | “,”
/// | “_” | “.” | “!” | “~” | “*” | “'” | “(” | “)” | “[” | “]”
fragment NS_URI_CHAR: '%' NS_HEX_DIGIT NS_HEX_DIGIT | NS_WORD_CHAR
| '#' | ';' | '/' | '?' | ':' | '@' | '&' | '=' | '+' | '$'
| ',' | '_' | '.' | '!' | '~' | '*' | '\''| '(' | ')' | '[' | ']';
/// [40] ns-tag-char ::= ns-uri-char - “!” - c-flow-indicator
fragment NS_TAG_CHAR: '%' NS_HEX_DIGIT NS_HEX_DIGIT | NS_WORD_CHAR
| '#' | ';' | '/' | '?' | ':' | '@' | '&' | '=' | '+'
| '$' | '_' | '.' | '~' | '*' | '\''| '(' | ')' |;
/// Escaped characters
/// [41] c-escape ::= “\”
fragment C_ESCAPE: '\\';
/// [42] ns-esc-null ::= “0”
/// Escaped ASCII null (#x0) character.
fragment NS_ESC_NULL: '0';
/// [43] ns-esc-bell ::= “a”
/// Escaped ASCII bell (#x7) character.
fragment NS_ESC_BELL: 'a';
/// [44] ns-esc-backspace ::= “b”
/// Escaped ASCII backspace (#x8) character.
fragment NS_ESC_BAKSPACE: 'b';
/// [45] ns-esc-horizontal-tab ::= “t” | #x9
/// Escaped ASCII horizontal tab (#x9) character. This is useful at the start or the end of a line to force a leading or trailing tab to become part of the content.
fragment NS_ESC_HORIZONTAL_TAB: 't';
/// [46] ns-esc-line-feed ::= “n”
/// Escaped ASCII line feed (#xA) character.
fragment NS_ESC_LINE_FEED: 'n';
/// [47] ns-esc-vertical-tab ::= “v”
/// Escaped ASCII vertical tab (#xB) character.
fragment NS_ESC_VERTICAL_TAB : 'v';
/// [48] ns-esc-form-feed ::= “f”
/// Escaped ASCII form feed (#xC) character.
fragment NS_ESC_FORM_FEED: 'f';
/// [49] ns-esc-carriage-return ::= “r”
/// Escaped ASCII carriage return (#xD) character.
fragment NS_ESC_CARRIAGE_RETURN: 'r';
/// [50] ns-esc-escape ::= “e”
/// Escaped ASCII escape (#x1B) character.
fragment NS_ESC_ESCAPE: 'e';
/// [51] ns-esc-space ::= #x20
/// Escaped ASCII space (#x20) character. This is useful at the start or the end of a line to force a leading or trailing space to become part of the content.
fragment NS_ESC_SPACE: ' ';
/// [52] ns-esc-double-quote ::= “"”
/// Escaped ASCII double quote (#x22).
fragment NS_ESC_DOUBLE_QUOTE: '"';
/// [53] ns-esc-slash ::= “/”
/// Escaped ASCII slash (#x2F), for JSON compatibility.
fragment NS_ESC_SLASH: '/';
/// [54] ns-esc-backslash ::= “\”
/// Escaped ASCII back slash (#x5C).
fragment NS_ESC_BACKSLASH: '\\';
/// [55] ns-esc-next-line ::= “N”
/// Escaped Unicode next line (#x85) character.
fragment NS_ESC_NEXT_LINE: 'N';
/// [56] ns-esc-non-breaking-space ::= “_”
/// Escaped Unicode non-breaking space (#xA0) character.
fragment NS_ESC_NON_BREAKING_SPACE: '_';
/// [57] ns-esc-line-separator ::= “L”
/// Escaped Unicode line separator (#x2028) character.
fragment NS_ESC_LINE_SEPARATOR: 'L';
/// [58] ns-esc-paragraph-separator ::= “P”
/// Escaped Unicode paragraph separator (#x2029) character.
fragment NS_ESC_PARAGRAPH_SEPARATOR: 'P';
/// [59] ns-esc-8-bit ::= “x” ( ns-hex-digit × 2 )
/// Escaped 8-bit Unicode character.
fragment NS_ESC_8_BIT: 'x' NS_HEX_DIGIT NS_HEX_DIGIT;
/// [60] ns-esc-16-bit ::= “u” ( ns-hex-digit × 4 )
/// Escaped 16-bit Unicode character.
fragment NS_ESC_16_BIT: 'u' NS_HEX_DIGIT NS_HEX_DIGIT NS_HEX_DIGIT NS_HEX_DIGIT;
//[61] ns-esc-32-bit ::= “U” ( ns-hex-digit × 8 )
// Escaped 32-bit Unicode character.
fragment NS_ESC_32_BIT: 'U' NS_HEX_DIGIT NS_HEX_DIGIT NS_HEX_DIGIT NS_HEX_DIGIT
NS_HEX_DIGIT NS_HEX_DIGIT NS_HEX_DIGIT NS_HEX_DIGIT;
/// [62] c-ns-esc-char ::= “\”
/// ( ns-esc-null | ns-esc-bell | ns-esc-backspace
/// | ns-esc-horizontal-tab | ns-esc-line-feed
/// | ns-esc-vertical-tab | ns-esc-form-feed
/// | ns-esc-carriage-return | ns-esc-escape | ns-esc-space
/// | ns-esc-double-quote | ns-esc-slash | ns-esc-backslash
/// | ns-esc-next-line | ns-esc-non-breaking-space
/// | ns-esc-line-separator | ns-esc-paragraph-separator
/// | ns-esc-8-bit | ns-esc-16-bit | ns-esc-32-bit )
fragment C_NS_ESC_CHAR: C_ESCAPE (
| NS_ESC_NULL | NS_ESC_BELL
| NS_ESC_BAKSPACE | NS_ESC_HORIZONTAL_TAB
| NS_ESC_LINE_FEED | NS_ESC_VERTICAL_TAB
| NS_ESC_FORM_FEED | NS_ESC_CARRIAGE_RETURN
| NS_ESC_ESCAPE | NS_ESC_SPACE
| NS_ESC_DOUBLE_QUOTE | NS_ESC_SLASH
| NS_ESC_BACKSLASH | NS_ESC_NEXT_LINE
| NS_ESC_NON_BREAKING_SPACE | NS_ESC_LINE_SEPARATOR
| NS_ESC_PARAGRAPH_SEPARATOR | NS_ESC_8_BIT
| NS_ESC_16_BIT | NS_ESC_32_BIT
);
// TODO: test escape characters once double quoted string is implemented
/// [63] s-indent(n) ::= s-space × n
/// [64] s-indent(<n) ::= s-space × m /* Where m < n */
/// [65] s-indent(≤n) ::= s-space × m /* Where m ≤ n */
S_INDENT: S_SPACE+;
/// [66] s-separate-in-line ::= s-white+ | /* Start of line *//
fragment S_SEPARATE_IN_LINE : S_WHITE+;
// TODO: for now this captures only block_in. this should probably be using lexer modes
/// [67] s-line-prefix(n,c) ::= c = block-out ⇒ s-block-line-prefix(n)
/// c = block-in ⇒ s-block-line-prefix(n)
/// c = flow-out ⇒ s-flow-line-prefix(n)
/// c = flow-in ⇒ s-flow-line-prefix(n)
fragment S_LINE_PREFIX: S_BLOCK_LINE_PREFIX;
/// [68] s-block-line-prefix(n) ::= s-indent(n)
fragment S_BLOCK_LINE_PREFIX: S_INDENT;
/// [69] s-flow-line-prefix(n) ::= s-indent(n) s-separate-in-line?
fragment S_FLOW_LINE_PREFIX: S_INDENT S_SEPARATE_IN_LINE?;
/// [70] l-empty(n,c) ::= ( s-line-prefix(n,c) | s-indent(<n) )
/// b-as-line-feed
fragment L_EMPTY: (S_LINE_PREFIX | S_INDENT) B_AS_LINE_FEED;
/// [71] b-l-trimmed(n,c) ::= b-non-content l-empty(n,c)+
fragment B_L_TRIMMED: B_NON_CONTENT L_EMPTY+;
/// [72] b-as-space ::= b-break
fragment B_AS_SPACE: B_BREAK;
/// [73] b-l-folded(n,c) ::= b-l-trimmed(n,c) | b-as-space
fragment B_L_FOLDED: B_L_TRIMMED | B_AS_SPACE;
// TODO: flow not supported yet
/// [74] s-flow-folded(n) ::= s-separate-in-line? b-l-folded(n,flow-in)
/// s-flow-line-prefix(n)
// TODO: work in progress to support some early testing
/// [126] ns-plain-first(c) ::= ( ns-char - c-indicator )
/// | ( ( “?” | “:” | “-” )
/// /* Followed by an ns-plain-safe(c)) */ )
fragment NS_PLAIN_FIRST: NS_CHAR | (C_MAPPING_KEY | C_MAPPING_VALUE | C_SEQUENCE_ENTRY );
/// /* Followed by an ns-plain-safe(c)) */ )
/// [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out
/// c = flow-in ⇒ ns-plain-safe-in
/// c = block-key ⇒ ns-plain-safe-out
/// c = flow-key ⇒ ns-plain-safe-in
fragment NS_PLAIN_SAFE: NS_PLAIN_SAFE_IN;
/// [128] ns-plain-safe-out ::= ns-char
/// [129] ns-plain-safe-in ::= ns-char - c-flow-indicator
fragment NS_PLAIN_SAFE_IN: NS_CHAR;
/// [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” )
/// | ( /* An ns-char preceding */ “#” )
/// | ( “:” /* Followed by an ns-plain-safe(c) */ )
fragment NS_PLAIN_CHAR: NS_PLAIN_SAFE | C_COMMENT | C_MAPPING_VALUE NS_PLAIN_SAFE;
/// [131] ns-plain(n,c) ::= c = flow-out ⇒ ns-plain-multi-line(n,c)
/// c = flow-in ⇒ ns-plain-multi-line(n,c)
/// c = block-key ⇒ ns-plain-one-line(c)
/// c = flow-key ⇒ ns-plain-one-line(c)
/// [132] nb-ns-plain-in-line(c) ::= ( s-white* ns-plain-char(c) )*
// TODO not following spec
NB_NS_PLAIN_IN_LINE: (NS_PLAIN_CHAR)+;
/// [133] ns-plain-one-line(c) ::= ns-plain-first(c) nb-ns-plain-in-line(c) |
test/include/gmp-6.1.2/mpn/mul_1.asm | kcpikkt/apa | 43 | 20106 | <reponame>kcpikkt/apa<filename>test/include/gmp-6.1.2/mpn/mul_1.asm
dnl AMD64 mpn_mul_1 optimised for Intel Broadwell.
dnl Copyright 2015 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C cycles/limb
C AMD K8,K9 -
C AMD K10 -
C AMD bull -
C AMD pile -
C AMD steam -
C AMD excavator -
C AMD bobcat -
C AMD jaguar -
C Intel P4 -
C Intel core2 -
C Intel NHM -
C Intel SBR -
C Intel IBR -
C Intel HWL 1.70
C Intel BWL 1.51
C Intel SKL 1.52
C Intel atom -
C Intel SLM -
C VIA nano -
C The loop of this code is the result of running a code generation and
C optimisation tool suite written by <NAME> and <NAME>.
C TODO
C * Put an initial mulx before switching, targeting some free registers.
C * Tune feed-in code.
C * Trim nop execution after L(f2).
C * Port to DOS64, not forgetting nop execution.
define(`rp', `%rdi') C rcx
define(`up', `%rsi') C rdx
define(`n_param', `%rdx') C r8
define(`v0_param',`%rcx') C r9
define(`n', `%rcx')
dnl ABI_SUPPORT(DOS64)
ABI_SUPPORT(STD64)
dnl IFDOS(` define(`up', ``%rsi'') ') dnl
dnl IFDOS(` define(`rp', ``%rcx'') ') dnl
dnl IFDOS(` define(`vl', ``%r9'') ') dnl
dnl IFDOS(` define(`r9', ``rdi'') ') dnl
dnl IFDOS(` define(`n', ``%r8'') ') dnl
dnl IFDOS(` define(`r8', ``r11'') ') dnl
ASM_START()
TEXT
ALIGN(32)
PROLOGUE(mpn_mul_1)
mov v0_param, %r10
mov n_param, n
mov R32(n_param), R32(%r8)
shr $3, n
and $7, R32(%r8) C clear OF, CF as side-effect
mov %r10, %rdx
lea L(tab)(%rip), %r10
ifdef(`PIC',
` movslq (%r10,%r8,4), %r8
lea (%r8, %r10), %r10
jmp *%r10
',`
jmp *(%r10,%r8,8)
')
JUMPTABSECT
ALIGN(8)
L(tab): JMPENT( L(f0), L(tab))
JMPENT( L(f1), L(tab))
JMPENT( L(f2), L(tab))
JMPENT( L(f3), L(tab))
JMPENT( L(f4), L(tab))
JMPENT( L(f5), L(tab))
JMPENT( L(f6), L(tab))
JMPENT( L(f7), L(tab))
TEXT
L(f0): mulx( (up), %r10, %r8)
lea 56(up), up
lea -8(rp), rp
jmp L(b0)
L(f3): mulx( (up), %r9, %rax)
lea 16(up), up
lea 16(rp), rp
inc n
jmp L(b3)
L(f4): mulx( (up), %r10, %r8)
lea 24(up), up
lea 24(rp), rp
inc n
jmp L(b4)
L(f5): mulx( (up), %r9, %rax)
lea 32(up), up
lea 32(rp), rp
inc n
jmp L(b5)
L(f6): mulx( (up), %r10, %r8)
lea 40(up), up
lea 40(rp), rp
inc n
jmp L(b6)
L(f7): mulx( (up), %r9, %rax)
lea 48(up), up
lea 48(rp), rp
inc n
jmp L(b7)
L(f1): mulx( (up), %r9, %rax)
test n, n
jnz L(b1)
L(1): mov %r9, (rp)
ret
L(f2): mulx( (up), %r10, %r8)
lea 8(up), up
lea 8(rp), rp
mulx( (up), %r9, %rax)
test n, n
jz L(end)
ALIGN(32)
L(top): mov %r10, -8(rp)
adc %r8, %r9
L(b1): mulx( 8,(up), %r10, %r8)
adc %rax, %r10
lea 64(up), up
mov %r9, (rp)
L(b0): mov %r10, 8(rp)
mulx( -48,(up), %r9, %rax)
lea 64(rp), rp
adc %r8, %r9
L(b7): mulx( -40,(up), %r10, %r8)
mov %r9, -48(rp)
adc %rax, %r10
L(b6): mov %r10, -40(rp)
mulx( -32,(up), %r9, %rax)
adc %r8, %r9
L(b5): mulx( -24,(up), %r10, %r8)
mov %r9, -32(rp)
adc %rax, %r10
L(b4): mulx( -16,(up), %r9, %rax)
mov %r10, -24(rp)
adc %r8, %r9
L(b3): mulx( -8,(up), %r10, %r8)
adc %rax, %r10
mov %r9, -16(rp)
dec n
mulx( (up), %r9, %rax)
jnz L(top)
L(end): mov %r10, -8(rp)
adc %r8, %r9
mov %r9, (rp)
adc %rcx, %rax
ret
EPILOGUE()
ASM_END()
|
source/nodes/program-nodes-if_expressions.ads | reznikmm/gela | 0 | 7900 | <filename>source/nodes/program-nodes-if_expressions.ads
-- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Elsif_Paths;
with Program.Elements.If_Expressions;
with Program.Element_Visitors;
package Program.Nodes.If_Expressions is
pragma Preelaborate;
type If_Expression is
new Program.Nodes.Node and Program.Elements.If_Expressions.If_Expression
and Program.Elements.If_Expressions.If_Expression_Text
with private;
function Create
(If_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Condition : not null Program.Elements.Expressions.Expression_Access;
Then_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Then_Expression : not null Program.Elements.Expressions.Expression_Access;
Elsif_Paths : Program.Elements.Elsif_Paths.Elsif_Path_Vector_Access;
Else_Token : Program.Lexical_Elements.Lexical_Element_Access;
Else_Expression : Program.Elements.Expressions.Expression_Access)
return If_Expression;
type Implicit_If_Expression is
new Program.Nodes.Node and Program.Elements.If_Expressions.If_Expression
with private;
function Create
(Condition : not null Program.Elements.Expressions
.Expression_Access;
Then_Expression : not null Program.Elements.Expressions
.Expression_Access;
Elsif_Paths : Program.Elements.Elsif_Paths
.Elsif_Path_Vector_Access;
Else_Expression : Program.Elements.Expressions.Expression_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_If_Expression
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_If_Expression is
abstract new Program.Nodes.Node
and Program.Elements.If_Expressions.If_Expression
with record
Condition : not null Program.Elements.Expressions
.Expression_Access;
Then_Expression : not null Program.Elements.Expressions
.Expression_Access;
Elsif_Paths : Program.Elements.Elsif_Paths
.Elsif_Path_Vector_Access;
Else_Expression : Program.Elements.Expressions.Expression_Access;
end record;
procedure Initialize (Self : in out Base_If_Expression'Class);
overriding procedure Visit
(Self : not null access Base_If_Expression;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Condition
(Self : Base_If_Expression)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Then_Expression
(Self : Base_If_Expression)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Elsif_Paths
(Self : Base_If_Expression)
return Program.Elements.Elsif_Paths.Elsif_Path_Vector_Access;
overriding function Else_Expression
(Self : Base_If_Expression)
return Program.Elements.Expressions.Expression_Access;
overriding function Is_If_Expression
(Self : Base_If_Expression)
return Boolean;
overriding function Is_Expression
(Self : Base_If_Expression)
return Boolean;
type If_Expression is
new Base_If_Expression
and Program.Elements.If_Expressions.If_Expression_Text
with record
If_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
Then_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
Else_Token : Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_If_Expression_Text
(Self : in out If_Expression)
return Program.Elements.If_Expressions.If_Expression_Text_Access;
overriding function If_Token
(Self : If_Expression)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Then_Token
(Self : If_Expression)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Else_Token
(Self : If_Expression)
return Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_If_Expression is
new Base_If_Expression
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_If_Expression_Text
(Self : in out Implicit_If_Expression)
return Program.Elements.If_Expressions.If_Expression_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_If_Expression)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_If_Expression)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_If_Expression)
return Boolean;
end Program.Nodes.If_Expressions;
|
programs/oeis/048/A048644.asm | neoneye/loda | 22 | 12882 | <reponame>neoneye/loda
; A048644: Differences between partial sums of Gray code (A048641) and triangular numbers (A000217).
; 0,0,1,0,2,4,3,0,4,8,13,16,14,12,7,0,8,16,25,32,42,52,59,64,60,56,53,48,38,28,15,0,16,32,49,64,82,100,115,128,148,168,189,208,222,236,247,256,248,240,233,224,218,212,203,192,172,152,133,112,86,60,31,0,32,64
lpb $0
mov $2,$0
sub $0,1
seq $2,286548 ; a(n) = A003188(n) - n.
add $1,$2
lpe
mov $0,$1
|
jetbrick-template/src/main/antlr4/jetbrick/template/runtime/parser/grammer/JetTemplateLexer.g4 | LeoAugust19/jetbrick-template-2x | 392 | 5643 | <filename>jetbrick-template/src/main/antlr4/jetbrick/template/runtime/parser/grammer/JetTemplateLexer.g4<gh_stars>100-1000
/**
* Copyright 2013-2014 <NAME>, Shanghai, China. All rights reserved.
*
* Author: <NAME>
* Email: <EMAIL>
* WebURL: https://github.com/subchen
*
* 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.
*/
lexer grammar JetTemplateLexer;
/*
@header {
package jetbrick.template.parser.grammer;
}
*/
// *******************************************************************
// ------- DEFAULT mode for Plain Text -------------------------------
COMMENT_LINE : ('##'|'#//') ~[\r\n]* NEWLINE -> skip ;
COMMENT_BLOCK : '#--' .*? '--#' -> skip ;
fragment NEWLINE : ('\r'? '\n' | EOF) ;
// Texts
TEXT_PLAIN : ~('$'|'#'|'\\')+ ;
TEXT_CDATA : '#[[' .*? ']]#' ;
TEXT_CHAR_ESCAPED : ('\\#'|'\\$'|'\\\\') ;
TEXT_CHAR_SINGLE : ('#'|'$'|'\\') ;
// Values
VALUE_OPEN : '${' -> pushMode(INSIDE) ;
VALUE_OPEN_ESCAPED : '$!{' -> pushMode(INSIDE) ;
// Directives
DIRECTIVE_OPEN_OPTIONS : '#options' ARG_START -> pushMode(INSIDE) ;
DIRECTIVE_OPEN_DEFINE : '#define' ARG_START -> pushMode(INSIDE) ;
DIRECTIVE_OPEN_SET : '#set' ARG_START -> pushMode(INSIDE) ;
DIRECTIVE_OPEN_IF : '#if' ARG_START -> pushMode(INSIDE) ;
DIRECTIVE_OPEN_ELSEIF : '#elseif' ARG_START -> pushMode(INSIDE) ;
DIRECTIVE_OPEN_FOR : '#for' ARG_START -> pushMode(INSIDE) ;
DIRECTIVE_OPEN_BREAK : '#break' ARG_START -> pushMode(INSIDE) ;
DIRECTIVE_OPEN_CONTINUE : '#continue' ARG_START -> pushMode(INSIDE) ;
DIRECTIVE_OPEN_STOP : '#stop' ARG_START -> pushMode(INSIDE) ;
DIRECTIVE_OPEN_RETURN : '#return' ARG_START -> pushMode(INSIDE) ;
DIRECTIVE_OPEN_INCLUDE : '#include' ARG_START -> pushMode(INSIDE) ;
DIRECTIVE_OPEN_TAG : '#tag' NAME_ARG_START -> pushMode(INSIDE) ;
DIRECTIVE_OPEN_CALL : '#call' NAME_ARG_START -> pushMode(INSIDE) ;
DIRECTIVE_OPEN_MACRO : '#macro' NAME_ARG_START -> pushMode(INSIDE) ;
DIRECTIVE_ELSE : '#else' EMPTY_ARG? ;
DIRECTIVE_END : '#end' EMPTY_ARG? ;
DIRECTIVE_BREAK : '#break' ;
DIRECTIVE_CONTINUE : '#continue' ;
DIRECTIVE_STOP : '#stop' ;
DIRECTIVE_RETURN : '#return' ;
//fragment IF_ARG_START : [ \t]+ 'if' ARG_START ;
fragment NAME_ARG_START : [ \t]+ ID ARG_START ;
fragment ARG_START : [ \t]* '(' ;
fragment EMPTY_ARG : '()' ;
fragment ID : [_a-zA-Z][_a-zA-Z0-9]* ;
// Following is invalid directives
DIRECTIVE_OPTIONS : '#options' ;
DIRECTIVE_DEFINE : '#define' ;
DIRECTIVE_SET : '#set' ;
DIRECTIVE_IF : '#if' ;
DIRECTIVE_ELSEIF : '#elseif' ;
DIRECTIVE_FOR : '#for' ;
DIRECTIVE_INCLUDE : '#include' ;
DIRECTIVE_TAG : '#tag' ;
DIRECTIVE_CALL : '#call' ;
DIRECTIVE_MACRO : '#macro' ;
// It is a text which like a directive.
// It must be put after directive definition to avoid conflict.
TEXT_DIRECTIVE_LIKE : '#' [a-zA-Z0-9]+ ;
// *******************************************************************
// -------- INSIDE mode for directive --------------------------------
mode INSIDE;
WHITESPACE : [ \t\r\n]+ -> skip ;
// Separators
LPAREN : '(' -> pushMode(INSIDE) ;
RPAREN : ')' -> popMode ;
LBRACK : '[' ;
RBRACK : ']' ;
LBRACE : '{' -> pushMode(INSIDE) ;
RBRACE : '}' -> popMode ;
//
COMMA : ',' ;
QUESTION : '?' ;
COLON : ':' ;
COLON2 : '::' ;
DOT : '.' ;
ASSIGN : '=' ;
NULL_AS_DEFAULT : '?!' ;
// Equals and Compares
IDENTICALLY_EQUAL : '===' ;
IDENTICALLY_EQUAL_NOT : '!==' ;
EQ : '==' ;
NE : '!=' ;
GT : '>' ;
LT : '<' ;
GE : '>=' ;
LE : '<=' ;
// Condition
AND : '&&' ;
OR : '||' ;
NOT : '!' ;
// Unary and Binary Operators
PLUS : '+' ;
MINUS : '-' ;
MUL : '*' ;
DIV : '/' ;
MOD : '%' ;
// Bitwise Operators
BIT_AND : '&' ;
BIT_OR : '|' ;
BIT_NOT : '~' ;
BIT_XOR : '^' ;
BIT_SHL : '<<' ;
BIT_SHR : '>>' ;
BIT_USHR : '>>>' ;
// Keywords
INSTANCEOF : 'instanceof' ;
NEW : 'new' ;
TRUE : 'true' ;
FALSE : 'false' ;
NULL : 'null' ;
//THIS : 'this' ;
//SUPER : 'super' ;
// Id
IDENTIFIER : [_a-zA-Z][_a-zA-Z0-9]* ;
// Numbers
INTEGER : INT [lLfFdD]? ;
INTEGER_HEX : '0x' HEX+ [lL]? ;
FLOATING_POINT : INT ('.' FRAC)? EXP? [fFdD]? ;
fragment INT : '0' | [1-9] [0-9]* ;
fragment FRAC : [0-9]+ ;
fragment EXP : [Ee] [+\-]? INT ;
// Strings
STRING_DOUBLE : '"' (ESC|OTHERS)*? '"' ;
STRING_SINGLE : '\'' (ESC|OTHERS)*? '\'' ;
fragment OTHERS : ~('\\' | '\r' | '\n') ;
fragment ESC : '\\' ([btnfr"'\\]|UNICODE) ;
fragment UNICODE : 'u' HEX HEX HEX HEX ;
fragment HEX : [0-9a-fA-F] ;
|
src/model/jason-projects-models.adb | stcarrez/jason | 2 | 10063 | <reponame>stcarrez/jason<gh_stars>1-10
-----------------------------------------------------------------------
-- Jason.Projects.Models -- Jason.Projects.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-body.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095
-----------------------------------------------------------------------
-- Copyright (C) 2020 Stephane.Carrez
-- Written by Stephane.Carrez (<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 Ada.Unchecked_Deallocation;
with Util.Beans.Objects.Time;
with ASF.Events.Faces.Actions;
package body Jason.Projects.Models is
use type ADO.Objects.Object_Record_Access;
use type ADO.Objects.Object_Ref;
pragma Warnings (Off, "formal parameter * is not referenced");
function Project_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => PROJECT_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Project_Key;
function Project_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => PROJECT_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Project_Key;
function "=" (Left, Right : Project_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Project_Ref'Class;
Impl : out Project_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Project_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Project_Ref) is
Impl : Project_Access;
begin
Impl := new Project_Impl;
Impl.Version := 0;
Impl.Create_Date := ADO.DEFAULT_TIME;
Impl.Status := Jason.Projects.Models.Status_Type'First;
Impl.Last_Ticket := 0;
Impl.Update_Date := ADO.DEFAULT_TIME;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Project
-- ----------------------------------------
procedure Set_Id (Object : in out Project_Ref;
Value : in ADO.Identifier) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Project_Ref)
return ADO.Identifier is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
function Get_Version (Object : in Project_Ref)
return Integer is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Name (Object : in out Project_Ref;
Value : in String) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Name, Value);
end Set_Name;
procedure Set_Name (Object : in out Project_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Name, Value);
end Set_Name;
function Get_Name (Object : in Project_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Name);
end Get_Name;
function Get_Name (Object : in Project_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Name;
end Get_Name;
procedure Set_Create_Date (Object : in out Project_Ref;
Value : in Ada.Calendar.Time) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 4, Impl.Create_Date, Value);
end Set_Create_Date;
function Get_Create_Date (Object : in Project_Ref)
return Ada.Calendar.Time is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Create_Date;
end Get_Create_Date;
procedure Set_Status (Object : in out Project_Ref;
Value : in Jason.Projects.Models.Status_Type) is
procedure Set_Field_Enum is
new ADO.Objects.Set_Field_Operation (Status_Type);
Impl : Project_Access;
begin
Set_Field (Object, Impl);
Set_Field_Enum (Impl.all, 5, Impl.Status, Value);
end Set_Status;
function Get_Status (Object : in Project_Ref)
return Jason.Projects.Models.Status_Type is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Status;
end Get_Status;
procedure Set_Last_Ticket (Object : in out Project_Ref;
Value : in Integer) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 6, Impl.Last_Ticket, Value);
end Set_Last_Ticket;
function Get_Last_Ticket (Object : in Project_Ref)
return Integer is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Last_Ticket;
end Get_Last_Ticket;
procedure Set_Update_Date (Object : in out Project_Ref;
Value : in Ada.Calendar.Time) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 7, Impl.Update_Date, Value);
end Set_Update_Date;
function Get_Update_Date (Object : in Project_Ref)
return Ada.Calendar.Time is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Update_Date;
end Get_Update_Date;
procedure Set_Description (Object : in out Project_Ref;
Value : in String) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 8, Impl.Description, Value);
end Set_Description;
procedure Set_Description (Object : in out Project_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 8, Impl.Description, Value);
end Set_Description;
function Get_Description (Object : in Project_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Description);
end Get_Description;
function Get_Description (Object : in Project_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Description;
end Get_Description;
procedure Set_Wiki (Object : in out Project_Ref;
Value : in AWA.Wikis.Models.Wiki_Space_Ref'Class) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 9, Impl.Wiki, Value);
end Set_Wiki;
function Get_Wiki (Object : in Project_Ref)
return AWA.Wikis.Models.Wiki_Space_Ref'Class is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Wiki;
end Get_Wiki;
procedure Set_Owner (Object : in out Project_Ref;
Value : in AWA.Users.Models.User_Ref'Class) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 10, Impl.Owner, Value);
end Set_Owner;
function Get_Owner (Object : in Project_Ref)
return AWA.Users.Models.User_Ref'Class is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Owner;
end Get_Owner;
-- Copy of the object.
procedure Copy (Object : in Project_Ref;
Into : in out Project_Ref) is
Result : Project_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Project_Access
:= new Project_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Version := Impl.Version;
Copy.Name := Impl.Name;
Copy.Create_Date := Impl.Create_Date;
Copy.Status := Impl.Status;
Copy.Last_Ticket := Impl.Last_Ticket;
Copy.Update_Date := Impl.Update_Date;
Copy.Description := Impl.Description;
Copy.Wiki := Impl.Wiki;
Copy.Owner := Impl.Owner;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Project_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Project_Access := new Project_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Project_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Project_Access := new Project_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Project_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Project_Access := new Project_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Project_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Project_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Project_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Project_Impl) is
type Project_Impl_Ptr is access all Project_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Project_Impl, Project_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Project_Impl_Ptr := Project_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Project_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, PROJECT_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Project_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Project_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (PROJECT_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_1_NAME, -- name
Value => Object.Name);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_1_NAME, -- create_date
Value => Object.Create_Date);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_1_NAME, -- status
Value => Integer (Status_Type'Pos (Object.Status)));
Object.Clear_Modified (5);
end if;
if Object.Is_Modified (6) then
Stmt.Save_Field (Name => COL_5_1_NAME, -- last_ticket
Value => Object.Last_Ticket);
Object.Clear_Modified (6);
end if;
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_1_NAME, -- update_date
Value => Object.Update_Date);
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (8) then
Stmt.Save_Field (Name => COL_7_1_NAME, -- description
Value => Object.Description);
Object.Clear_Modified (8);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_1_NAME, -- wiki_id
Value => Object.Wiki);
Object.Clear_Modified (9);
end if;
if Object.Is_Modified (10) then
Stmt.Save_Field (Name => COL_9_1_NAME, -- owner_id
Value => Object.Owner);
Object.Clear_Modified (10);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Project_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (PROJECT_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_1_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_2_1_NAME, -- name
Value => Object.Name);
Query.Save_Field (Name => COL_3_1_NAME, -- create_date
Value => Object.Create_Date);
Query.Save_Field (Name => COL_4_1_NAME, -- status
Value => Integer (Status_Type'Pos (Object.Status)));
Query.Save_Field (Name => COL_5_1_NAME, -- last_ticket
Value => Object.Last_Ticket);
Query.Save_Field (Name => COL_6_1_NAME, -- update_date
Value => Object.Update_Date);
Query.Save_Field (Name => COL_7_1_NAME, -- description
Value => Object.Description);
Query.Save_Field (Name => COL_8_1_NAME, -- wiki_id
Value => Object.Wiki);
Query.Save_Field (Name => COL_9_1_NAME, -- owner_id
Value => Object.Owner);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Project_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (PROJECT_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Project_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Project_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Project_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "name" then
return Util.Beans.Objects.To_Object (Impl.Name);
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Create_Date);
elsif Name = "status" then
return Jason.Projects.Models.Status_Type_Objects.To_Object (Impl.Status);
elsif Name = "last_ticket" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Last_Ticket));
elsif Name = "update_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Update_Date);
elsif Name = "description" then
return Util.Beans.Objects.To_Object (Impl.Description);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
procedure List (Object : in out Project_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, PROJECT_DEF'Access);
begin
Stmt.Execute;
Project_Vectors.Clear (Object);
while Stmt.Has_Elements loop
declare
Item : Project_Ref;
Impl : constant Project_Access := new Project_Impl;
begin
Impl.Load (Stmt, Session);
ADO.Objects.Set_Object (Item, Impl.all'Access);
Object.Append (Item);
end;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Project_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Name := Stmt.Get_Unbounded_String (2);
Object.Create_Date := Stmt.Get_Time (3);
Object.Status := Status_Type'Val (Stmt.Get_Integer (4));
Object.Last_Ticket := Stmt.Get_Integer (5);
Object.Update_Date := Stmt.Get_Time (6);
Object.Description := Stmt.Get_Unbounded_String (7);
if not Stmt.Is_Null (8) then
Object.Wiki.Set_Key_Value (Stmt.Get_Identifier (8), Session);
end if;
if not Stmt.Is_Null (9) then
Object.Owner.Set_Key_Value (Stmt.Get_Identifier (9), Session);
end if;
Object.Version := Stmt.Get_Integer (1);
ADO.Objects.Set_Created (Object);
end Load;
function Attribute_Definition_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => ATTRIBUTE_DEFINITION_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Attribute_Definition_Key;
function Attribute_Definition_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => ATTRIBUTE_DEFINITION_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Attribute_Definition_Key;
function "=" (Left, Right : Attribute_Definition_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Attribute_Definition_Ref'Class;
Impl : out Attribute_Definition_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Attribute_Definition_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Attribute_Definition_Ref) is
Impl : Attribute_Definition_Access;
begin
Impl := new Attribute_Definition_Impl;
Impl.Version := 0;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Attribute_Definition
-- ----------------------------------------
procedure Set_Id (Object : in out Attribute_Definition_Ref;
Value : in ADO.Identifier) is
Impl : Attribute_Definition_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Attribute_Definition_Ref)
return ADO.Identifier is
Impl : constant Attribute_Definition_Access
:= Attribute_Definition_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
function Get_Version (Object : in Attribute_Definition_Ref)
return Integer is
Impl : constant Attribute_Definition_Access
:= Attribute_Definition_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Name (Object : in out Attribute_Definition_Ref;
Value : in String) is
Impl : Attribute_Definition_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Name, Value);
end Set_Name;
procedure Set_Name (Object : in out Attribute_Definition_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Attribute_Definition_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Name, Value);
end Set_Name;
function Get_Name (Object : in Attribute_Definition_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Name);
end Get_Name;
function Get_Name (Object : in Attribute_Definition_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Attribute_Definition_Access
:= Attribute_Definition_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Name;
end Get_Name;
procedure Set_Default_Value (Object : in out Attribute_Definition_Ref;
Value : in String) is
Impl : Attribute_Definition_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 4, Impl.Default_Value, Value);
end Set_Default_Value;
procedure Set_Default_Value (Object : in out Attribute_Definition_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Attribute_Definition_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 4, Impl.Default_Value, Value);
end Set_Default_Value;
function Get_Default_Value (Object : in Attribute_Definition_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Default_Value);
end Get_Default_Value;
function Get_Default_Value (Object : in Attribute_Definition_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Attribute_Definition_Access
:= Attribute_Definition_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Default_Value;
end Get_Default_Value;
procedure Set_Project (Object : in out Attribute_Definition_Ref;
Value : in Jason.Projects.Models.Project_Ref'Class) is
Impl : Attribute_Definition_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 5, Impl.Project, Value);
end Set_Project;
function Get_Project (Object : in Attribute_Definition_Ref)
return Jason.Projects.Models.Project_Ref'Class is
Impl : constant Attribute_Definition_Access
:= Attribute_Definition_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Project;
end Get_Project;
-- Copy of the object.
procedure Copy (Object : in Attribute_Definition_Ref;
Into : in out Attribute_Definition_Ref) is
Result : Attribute_Definition_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Attribute_Definition_Access
:= Attribute_Definition_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Attribute_Definition_Access
:= new Attribute_Definition_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Version := Impl.Version;
Copy.Name := Impl.Name;
Copy.Default_Value := Impl.Default_Value;
Copy.Project := Impl.Project;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Attribute_Definition_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Attribute_Definition_Access := new Attribute_Definition_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Attribute_Definition_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Attribute_Definition_Access := new Attribute_Definition_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Attribute_Definition_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Attribute_Definition_Access := new Attribute_Definition_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Attribute_Definition_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Attribute_Definition_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Attribute_Definition_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Attribute_Definition_Impl) is
type Attribute_Definition_Impl_Ptr is access all Attribute_Definition_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Attribute_Definition_Impl, Attribute_Definition_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Attribute_Definition_Impl_Ptr := Attribute_Definition_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Attribute_Definition_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, ATTRIBUTE_DEFINITION_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Attribute_Definition_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Attribute_Definition_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (ATTRIBUTE_DEFINITION_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_2_NAME, -- name
Value => Object.Name);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_2_NAME, -- default_value
Value => Object.Default_Value);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_2_NAME, -- project_id
Value => Object.Project);
Object.Clear_Modified (5);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Attribute_Definition_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (ATTRIBUTE_DEFINITION_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_2_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_2_2_NAME, -- name
Value => Object.Name);
Query.Save_Field (Name => COL_3_2_NAME, -- default_value
Value => Object.Default_Value);
Query.Save_Field (Name => COL_4_2_NAME, -- project_id
Value => Object.Project);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Attribute_Definition_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (ATTRIBUTE_DEFINITION_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Attribute_Definition_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Attribute_Definition_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Attribute_Definition_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "name" then
return Util.Beans.Objects.To_Object (Impl.Name);
elsif Name = "default_value" then
return Util.Beans.Objects.To_Object (Impl.Default_Value);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
procedure List (Object : in out Attribute_Definition_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, ATTRIBUTE_DEFINITION_DEF'Access);
begin
Stmt.Execute;
Attribute_Definition_Vectors.Clear (Object);
while Stmt.Has_Elements loop
declare
Item : Attribute_Definition_Ref;
Impl : constant Attribute_Definition_Access := new Attribute_Definition_Impl;
begin
Impl.Load (Stmt, Session);
ADO.Objects.Set_Object (Item, Impl.all'Access);
Object.Append (Item);
end;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Attribute_Definition_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Name := Stmt.Get_Unbounded_String (2);
Object.Default_Value := Stmt.Get_Unbounded_String (3);
if not Stmt.Is_Null (4) then
Object.Project.Set_Key_Value (Stmt.Get_Identifier (4), Session);
end if;
Object.Version := Stmt.Get_Integer (1);
ADO.Objects.Set_Created (Object);
end Load;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in List_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "title" then
return Util.Beans.Objects.To_Object (From.Title);
elsif Name = "status" then
return Jason.Projects.Models.Status_Type_Objects.To_Object (From.Status);
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (From.Create_Date);
elsif Name = "total_duration" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Total_Duration));
elsif Name = "total_done" then
return Util.Beans.Objects.To_Object (From.Total_Done);
elsif Name = "close_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Close_Count));
elsif Name = "open_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Open_Count));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out List_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "title" then
Item.Title := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "status" then
Item.Status := Jason.Projects.Models.Status_Type_Objects.To_Value (Value);
elsif Name = "create_date" then
Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "total_duration" then
Item.Total_Duration := Util.Beans.Objects.To_Integer (Value);
elsif Name = "total_done" then
Item.Total_Done := Util.Beans.Objects.To_Float (Value);
elsif Name = "close_count" then
Item.Close_Count := Util.Beans.Objects.To_Integer (Value);
elsif Name = "open_count" then
Item.Open_Count := Util.Beans.Objects.To_Integer (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out List_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The list of projects.
-- --------------------
procedure List (Object : in out List_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out List_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out List_Info) is
begin
Into.Id := Stmt.Get_Identifier (0);
Into.Title := Stmt.Get_Unbounded_String (1);
Into.Status := Jason.Projects.Models.Status_Type'Val (Stmt.Get_Integer (2));
Into.Create_Date := Stmt.Get_Time (3);
Into.Total_Duration := Stmt.Get_Natural (4);
Into.Total_Done := Stmt.Get_Float (5);
Into.Close_Count := Stmt.Get_Natural (6);
Into.Open_Count := Stmt.Get_Natural (7);
end Read;
begin
Stmt.Execute;
List_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
procedure Op_Load (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Project_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Project_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Project_Bean,
Method => Op_Load,
Name => "load");
procedure Op_Create (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Create (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Project_Bean'Class (Bean).Create (Outcome);
end Op_Create;
package Binding_Project_Bean_2 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Project_Bean,
Method => Op_Create,
Name => "create");
procedure Op_Save (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Save (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Project_Bean'Class (Bean).Save (Outcome);
end Op_Save;
package Binding_Project_Bean_3 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Project_Bean,
Method => Op_Save,
Name => "save");
procedure Op_Create_Wiki (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Create_Wiki (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Project_Bean'Class (Bean).Create_Wiki (Outcome);
end Op_Create_Wiki;
package Binding_Project_Bean_4 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Project_Bean,
Method => Op_Create_Wiki,
Name => "create_wiki");
procedure Op_Load_Wiki (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load_Wiki (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Project_Bean'Class (Bean).Load_Wiki (Outcome);
end Op_Load_Wiki;
package Binding_Project_Bean_5 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Project_Bean,
Method => Op_Load_Wiki,
Name => "load_wiki");
Binding_Project_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Project_Bean_1.Proxy'Access,
2 => Binding_Project_Bean_2.Proxy'Access,
3 => Binding_Project_Bean_3.Proxy'Access,
4 => Binding_Project_Bean_4.Proxy'Access,
5 => Binding_Project_Bean_5.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Project_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Project_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Project_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "name" then
Item.Set_Name (Util.Beans.Objects.To_String (Value));
elsif Name = "create_date" then
Item.Set_Create_Date (Util.Beans.Objects.Time.To_Time (Value));
elsif Name = "status" then
Item.Set_Status (Status_Type_Objects.To_Value (Value));
elsif Name = "last_ticket" then
Item.Set_Last_Ticket (Util.Beans.Objects.To_Integer (Value));
elsif Name = "update_date" then
Item.Set_Update_Date (Util.Beans.Objects.Time.To_Time (Value));
elsif Name = "description" then
Item.Set_Description (Util.Beans.Objects.To_String (Value));
end if;
end Set_Value;
procedure Op_Load (Bean : in out Project_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Project_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Project_List_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Project_List_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Project_List_Bean,
Method => Op_Load,
Name => "load");
Binding_Project_List_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Project_List_Bean_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Project_List_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Project_List_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Project_List_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "page" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page));
elsif Name = "page_size" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Size));
elsif Name = "count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Count));
elsif Name = "tag" then
return Util.Beans.Objects.To_Object (From.Tag);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Project_List_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "page" then
Item.Page := Util.Beans.Objects.To_Integer (Value);
elsif Name = "page_size" then
Item.Page_Size := Util.Beans.Objects.To_Integer (Value);
elsif Name = "count" then
Item.Count := Util.Beans.Objects.To_Integer (Value);
elsif Name = "tag" then
Item.Tag := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
end Set_Value;
end Jason.Projects.Models;
|
Examples/ch11/Console1.asm | satadriver/LiunuxOS | 0 | 169535 | <gh_stars>0
TITLE Win32 Console Example #1 (Console1.asm)
; This program calls the following Win32 Console functions:
; GetStdHandle, ExitProcess, WriteConsole
; Last update: 1/20/02
INCLUDE Irvine32.inc
.data
endl EQU <0dh,0ah> ; end of line sequence
message \
BYTE "-------------------- Console1.asm -----------------------"
BYTE endl,endl
BYTE "This program is a simple demonstration of console ",endl
BYTE "mode output, using the GetStdHandle and WriteConsole ",endl
BYTE "functions.",endl
BYTE "---------------------------------------------------------"
BYTE endl,endl,endl
messageSize = ($-message)
consoleHandle DWORD 0 ; handle to standard output device
bytesWritten DWORD ? ; number of bytes written
.code
main PROC
; Get the console output handle:
INVOKE GetStdHandle, STD_OUTPUT_HANDLE
mov consoleHandle,eax
; Write a string to the console:
INVOKE WriteConsole,
consoleHandle, ; console output handle
ADDR message, ; string pointer
messageSize, ; string length
ADDR bytesWritten, ; returns num bytes written
0 ; not used
INVOKE ExitProcess,0
main ENDP
END main |
typedef_dsl.g4 | jamiepenney/typedef | 3 | 2268 | <reponame>jamiepenney/typedef
grammar typedef_dsl;
/*
* Parser
*/
statements
: literal_statement+ EOF
;
literal_statement
: VARIABLE_NAME VARIABLE_NAME_SEPERATOR phrase END_OF_STATEMENT
;
phrase
: (type_decl WS* value) #valuePhrase
| (STRUCT struct_members) #structPhrase
;
// type definitions
type_decl
: TYPE_EMBEDDED OPEN_EMBEDDED type_decl (VALUE_SEPERATOR type_decl)* CLOSE_EMBEDDED #embeddedType
| TYPE_LITERAL #literalType
;
// literal value definitions
value
: BOOLEAN_VALUE #booleanValue
| NUMBER #numberValue
| STRING_LITERAL #stringValue // TODO: Do better string parsing
| OPEN_SQUARE multiple_values? CLOSE_SQUARE VALUE_SEPERATOR? #arrayValue
| OPEN_BRACKET multiple_values? CLOSE_BRACKET VALUE_SEPERATOR? #setValue
| OPEN_BRACKET key_value_pair+ CLOSE_BRACKET VALUE_SEPERATOR? #mapValue
;
multiple_values
: value (VALUE_SEPERATOR value)*
;
key_value_pair
: map_kv_key KEY_SEPERATOR map_kv_value VALUE_SEPERATOR?
;
// Arrange key/vals like this to make easier flagging to handlers
map_kv_key
: value
;
// Arrange key/vals like this to make easier flagging to handlers
map_kv_value
: value
;
struct_members
: OPEN_BRACKET VARIABLE_NAME type_decl (NEWLINE+ VARIABLE_NAME type_decl)* CLOSE_BRACKET
;
/*
* Lexar
*/
// definitions for literal values
NUMBER
: INTEGER
| FLOAT
| BINARY
| HEX
;
fragment INTEGER
: '-'? '1'..'9' '0'..'9'*
;
fragment FLOAT
: '-'? '1'..'9' '0'..'9'* '.'? '0'..'9'+
;
fragment BINARY
: '0b' ('0' | '1')+
;
fragment HEX
: '0x' '0'..'9'+
;
STRING_LITERAL
: '"' (ESC | ~'"')* '"'
;
fragment ESC
: '\\' .
;
WS
: [ \t] -> skip
;
NEWLINE
: [\r\n] -> skip
;
BOOLEAN_VALUE
: BOOLEAN_TRUE
| BOOLEAN_FALSE
;
fragment BOOLEAN_TRUE
: 'true'
;
fragment BOOLEAN_FALSE
: 'false'
;
// definitions for type values
TYPE_LITERAL
: INT_TYPE
| STRING_TYPE
| BOOLEAN_TYPE
| FLOAT_TYPE
;
TYPE_EMBEDDED
: SET_TYPE
| MAP_TYPE
| ARRAY_TYPE
;
fragment SET_TYPE
: 'set'
;
fragment MAP_TYPE
: 'map'
;
fragment ARRAY_TYPE
: 'array'
;
fragment INT_TYPE
: 'int'
;
fragment STRING_TYPE
: 'string'
;
fragment BOOLEAN_TYPE
: 'bool'
;
fragment FLOAT_TYPE
: 'float'
;
// struct is unique from other literal types
STRUCT
: 'struct'
;
VARIABLE_NAME_SEPERATOR
: '->'
;
// mandate lower-case beginning with Camel Case?
VARIABLE_NAME
: 'a'..'z'
| ('a'..'z' (ALPHA_NUMERIC | '-' | '_')* ALPHA_NUMERIC )
;
fragment ALPHA_NUMERIC
: 'a'..'z'
| '0'..'9'
| 'A'..'Z'+
;
// SPECIAL CHARS
OPEN_PAREN
: '('
;
CLOSE_PAREN
: ')'
;
OPEN_BRACKET
: '{'
;
CLOSE_BRACKET
: '}'
;
OPEN_SQUARE
: '['
;
CLOSE_SQUARE
: ']'
;
KEY_SEPERATOR
: ':'
;
VALUE_SEPERATOR
: ','
;
END_OF_STATEMENT
: ';'
;
OPEN_EMBEDDED
: '<'
;
CLOSE_EMBEDDED
: '>'
;
|
libsrc/_DEVELOPMENT/arch/zx/nirvanap/c/sdcc/NIRVANAP_printC.asm | teknoplop/z88dk | 0 | 161253 | ; ----------------------------------------------------------------
; Z88DK INTERFACE LIBRARY FOR NIRVANA+ ENGINE - by <NAME>
;
; See "nirvana+.h" for further details
; ----------------------------------------------------------------
; void NIRVANAP_printC(unsigned int ch, unsigned char *attrs, unsigned int lin, unsigned int col)
SECTION code_clib
SECTION code_nirvanap
PUBLIC _NIRVANAP_printC
EXTERN asm_NIRVANAP_printC
_NIRVANAP_printC:
ld hl,2
add hl,sp
ld a,(hl) ; ch
inc hl
inc hl
ld c,(hl)
inc hl
ld b,(hl) ; attrs
inc hl
ld d,(hl) ; lin
inc hl
inc hl
ld e,(hl) ; col
jp asm_NIRVANAP_printC
|
test/fail/Issue755.agda | larrytheliquid/agda | 1 | 6341 |
module Issue755 where
open import Common.Prelude renaming (Nat to ℕ)
open import Common.Equality
abstract
foo : ℕ → ℕ
foo x = zero
bar : foo zero ≡ foo (suc zero) → foo zero ≡ foo (suc zero)
bar refl = refl
-- 0 != 1 of type ℕ
-- when checking that the pattern refl has type
-- foo zero ≡ foo (suc zero)
|
libsrc/spectrum/zx_printer.asm | dex4er/deb-z88dk | 1 | 168285 | ;
; ZX Spectrum specific routines
; by <NAME>, 14/09/2006
;
; int zx_printer();
;
; The result is:
; - 1 (true) if the ZX printer is connected
; - 0 (false) otherwise
;
; $Id: zx_printer.asm,v 1.1 2006/12/01 16:58:30 stefano Exp $
;
XLIB zx_printer
zx_printer:
ld hl,0
in a,($fb)
bit 6,a
ret nz
inc hl
ret
|
alloy4fun_models/trashltl/models/9/odmCnSvEWgrnAazbs.als | Kaixi26/org.alloytools.alloy | 0 | 1298 | <reponame>Kaixi26/org.alloytools.alloy<gh_stars>0
open main
pred idodmCnSvEWgrnAazbs_prop10 {
always (all f:Protected | f in Protected)
}
pred __repair { idodmCnSvEWgrnAazbs_prop10 }
check __repair { idodmCnSvEWgrnAazbs_prop10 <=> prop10o } |
programs/oeis/168/A168667.asm | neoneye/loda | 22 | 241057 | ; A168667: a(n) = n^7*(n^10 + 1)/2.
; 0,1,65600,64571175,8589942784,381469765625,8463329862336,116315257405375,1125899907891200,8338590852224769,50000000005000000,252723514259390471,1109305553388134400,4325207959722043225,15245673364718304704,49263062667932109375,147573952589810630656,413620130943373551425,1092955779869654376000,2740193428892848028839,6553600000000640000000,15020971247541746491641,33124976459730963755200,70525019780333186875775,145398897491343571943424,291038304567340087890625,566913657692579378682176,1076846981537784113331975,1998280899253456001228800,3628573868365045182357209,6457008150000010935000000,11275058387081385345648511,19342813113834083975168000,32636755824132242795133825,54214017802982992438778944,88741498560793718082734375,143255899979035255101136896,228243970413017625168012025,359162633111784853265489600,558558060923350488528354879,858993459200000081920000000,1307060133750387711479006081,1968828743357673875283412800,2937201553180210145349082375,4341756914529693570721931264,6361839942804935260687265625,9243855392647608549449914816,13323968253481096972972656575,19057724291985084376311398400,27058478018976056173591366849,38146972656250000390625000000,53414971130082109048060509351,74306506941081238463954329600,102721129828140696990399186425,141144487564119754442403720384,192812739753453740308947109375,261918674026948101584045735936,353869026058693587584908130625,475604434074342072758022395200,635995733508753872096182938119,846332972236800001399680000000,1120926662627442672844729903321,1477844452911529538718970558400,1939810675325738196770806110975,2535301200456458805192429666304,3299871795418296027918032890625,4277764859380658537329082120256,5523847118334179527038423099175,7105939741472583346126853120000,9107612550010232101313614813689,11631525699360350004117715000000,14803415620631136002970166732991,18776837322052103825957663539200,23738792613350049348561182721025,29916393689975039950641812489024,37584734091069549328802490234375,47076164647227856796197229387776,58791201016548587382592676027225,73211322161345386247600061412800,90913956073296022682237212938559,112589990684262400010485760000000,139064194721846755640081284343361,171318985850930805368024465512000,210522042406585345741419816081575,258058321049377015087276256108544,315567116503271775901420089765625,384984881978436486374686818658496,468594620818201364544918297179775,569082762301235974797908220313600,689604548420462671384035751457729,833859084983328450023914845000000,1006175350764399217278259103879431,1211610614025107319259645581516800,1456062877942205421341209669457625,1746399166920274309271843099644864,2090601676095887064373219477109375,2497934038399068940935349105852416,2979130219294025666680990870621825,3546608830903229590380346610062400,4214715966919634416289424606716199
mov $1,$0
pow $0,7
mov $2,$1
pow $2,10
mul $2,$0
add $0,$2
div $0,2
|
arbitrary-log.ads | joewing/arbitrary | 0 | 9308 | --------------------------------------------------------------------------
-- Arbitrary Precision Math Library: Logarithmic Functions
-- <NAME> 20020320 <> 20020327
--------------------------------------------------------------------------
package Arbitrary.Log is
function Exp(a : Arbitrary_Type) return Arbitrary_Type;
function Ln2(precision : integer) return Arbitrary_Type;
function Ln(a : Arbitrary_Type) return Arbitrary_Type;
end Arbitrary.Log;
|
sources/ippcp/asm_ia32/pcpaesgcmtable2kv8as.asm | idesai/ipp-crypto | 1 | 13239 | <reponame>idesai/ipp-crypto
;===============================================================================
; Copyright 2014-2018 Intel Corporation
; All Rights Reserved.
;
; If this software was obtained under the Intel Simplified Software License,
; the following terms apply:
;
; The source code, information and material ("Material") contained herein is
; owned by Intel Corporation or its suppliers or licensors, and title to such
; Material remains with Intel Corporation or its suppliers or licensors. The
; Material contains proprietary information of Intel or its suppliers and
; licensors. The Material is protected by worldwide copyright laws and treaty
; provisions. No part of the Material may be used, copied, reproduced,
; modified, published, uploaded, posted, transmitted, distributed or disclosed
; in any way without Intel's prior express written permission. No license under
; any patent, copyright or other intellectual property rights in the Material
; is granted to or conferred upon you, either expressly, by implication,
; inducement, estoppel or otherwise. Any license under such intellectual
; property rights must be express and approved by Intel in writing.
;
; Unless otherwise agreed by Intel in writing, you may not remove or alter this
; notice or any other notice embedded in Materials by Intel or Intel's
; suppliers or licensors in any way.
;
;
; If this software was obtained under the Apache License, Version 2.0 (the
; "License"), the following terms apply:
;
; 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.
;===============================================================================
;
;
; Purpose: Cryptography Primitive.
; Encrypt/Decrypt byte data stream according to Rijndael128 (GCM mode)
;
; Content:
; AesGcmMulGcm_table2K()
; AesGcmAuth_table2K()
;
.686P
.MODEL FLAT,C
INCLUDE asmdefs.inc
INCLUDE ia_emm.inc
IFDEF IPP_PIC
LD_ADDR MACRO reg:REQ, addr:REQ
LOCAL LABEL
call LABEL
LABEL: pop reg
sub reg, LABEL-addr
ENDM
ELSE
LD_ADDR MACRO reg:REQ, addr:REQ
lea reg, addr
ENDM
ENDIF
IF _IPP GE _IPP_V8
IPPCODE SEGMENT 'CODE' ALIGN (IPP_ALIGN_FACTOR)
;
; getAesGcmConst_table_ct provides c-e-t access to pre-computed Ipp16u AesGcmConst_table[256]
;
; input:
; edx: address of the AesGcmConst_table
; ecx: index in the table
;
; output:
; eax
;
; register ecx destoyed
; registers mmx2, mmx3, mmx6, and mmx7 destoyed
;
ALIGN IPP_ALIGN_FACTOR
_CONST_DATA:
_INIT_IDX DW 000h,001h,002h,003h,004h,005h,006h,007h ;; initial search inx = {fdf8:f53e:61e4::18}
_INCR_IDX DW 008h,008h,008h,008h,008h,008h,008h,008h ;; index increment = {8:8:8:8:8:8:8:8}
INIT_IDX equ [ebx+(_INIT_IDX - _CONST_DATA)]
INCR_IDX equ [ebx+(_INCR_IDX - _CONST_DATA)]
ALIGN IPP_ALIGN_FACTOR
IPPASM getAesGcmConst_table_ct PROC NEAR PRIVATE
push ebx
LD_ADDR ebx, _CONST_DATA
pxor xmm2, xmm2 ;; accumulator xmm2 = 0
mov eax, ecx ;; broadcast inx into dword
shl ecx, 16
or ecx, eax
movd xmm3, ecx
pshufd xmm3, xmm3, 00b ;; search index xmm3 = broadcast(idx)
movdqa xmm6, xmmword ptr INIT_IDX ;; current indexes
xor eax, eax
ALIGN IPP_ALIGN_FACTOR
search_loop:
movdqa xmm7, xmm6 ;; copy current indexes
paddw xmm6, xmmword ptr INCR_IDX ;; advance current indexes
pcmpeqw xmm7, xmm3 ;; selection mask
pand xmm7, xmmword ptr[edx+eax*sizeof(word)];; mask data
add eax, 8
cmp eax, 256
por xmm2, xmm7 ;; and accumulate
jl search_loop
movdqa xmm3, xmm2 ;; pack result in qword
psrldq xmm2, sizeof(xmmword)/2
por xmm2, xmm3
movdqa xmm3, xmm2 ;; pack result in dword
psrldq xmm2, sizeof(xmmword)/4
por xmm2, xmm3
movd eax, xmm2
pop ebx
and ecx, 3 ;; select tbl[idx] value
shl ecx, 4 ;; rcx *=16 = sizeof(word)*8
shr eax, cl
ret
IPPASM getAesGcmConst_table_ct ENDP
;
; void AesGcmMulGcm_table2K(Ipp8u* pHash, const Ipp8u* pPrecomputedData, , const void* pParam))
;
ALIGN IPP_ALIGN_FACTOR
IPPASM AesGcmMulGcm_table2K PROC NEAR C PUBLIC \
USES esi edi ebx,\
pHash: PTR BYTE,\
pMulTbl: PTR BYTE,\
pParam: PTR WORD
mov edi, pHash
movdqu xmm0, [edi] ; hash value
mov esi, pMulTbl
mov edx, pParam ; pointer to the fixed table
movd ebx, xmm0 ; ebx = hash.0
mov eax, 0f0f0f0f0h
and eax, ebx ; eax = 4 x 4_bits
shl ebx, 4
and ebx, 0f0f0f0f0h ; ebx = 4 x 4_bits (another)
movzx ecx, ah
movdqa xmm5, oword ptr [esi+1024+ecx]
movzx ecx, al
movdqa xmm4, oword ptr [esi+1024+ecx]
shr eax, 16
movzx ecx, ah
movdqa xmm3, oword ptr [esi+1024+ecx]
movzx ecx, al
movdqa xmm2, oword ptr [esi+1024+ecx]
psrldq xmm0, 4 ; shift xmm0
movd eax, xmm0 ; eax = hash[1]
and eax, 0f0f0f0f0h ; eax = 4 x 4_bits
movzx ecx, bh
pxor xmm5, oword ptr [esi+ 0*256 + ecx]
movzx ecx, bl
pxor xmm4, oword ptr [esi+ 0*256 + ecx]
shr ebx, 16
movzx ecx, bh
pxor xmm3, oword ptr [esi+ 0*256 + ecx]
movzx ecx, bl
pxor xmm2, oword ptr [esi+ 0*256 + ecx]
movd ebx, xmm0 ; ebx = hash[1]
shl ebx, 4 ; another 4 x 4_bits
and ebx, 0f0f0f0f0h
movzx ecx, ah
pxor xmm5, oword ptr [esi+1024+ 1*256 + ecx]
movzx ecx, al
pxor xmm4, oword ptr [esi+1024+ 1*256 + ecx]
shr eax, 16
movzx ecx, ah
pxor xmm3, oword ptr [esi+1024+ 1*256 + ecx]
movzx ecx, al
pxor xmm2, oword ptr [esi+1024+ 1*256 + ecx]
psrldq xmm0, 4
movd eax, xmm0 ; eax = hash.2
and eax, 0f0f0f0f0h
movzx ecx, bh
pxor xmm5, oword ptr [esi+ 1*256 + ecx]
movzx ecx, bl
pxor xmm4, oword ptr [esi+ 1*256 + ecx]
shr ebx, 16
movzx ecx, bh
pxor xmm3, oword ptr [esi+ 1*256 + ecx]
movzx ecx, bl
pxor xmm2, oword ptr [esi+ 1*256 + ecx]
movd ebx, xmm0
shl ebx, 4
and ebx, 0f0f0f0f0h
movzx ecx, ah
pxor xmm5, oword ptr [esi+1024+ 2*256 + ecx]
movzx ecx, al
pxor xmm4, oword ptr [esi+1024+ 2*256 + ecx]
shr eax, 16
movzx ecx, ah
pxor xmm3, oword ptr [esi+1024+ 2*256 + ecx]
movzx ecx, al
pxor xmm2, oword ptr [esi+1024+ 2*256 + ecx]
psrldq xmm0, 4
movd eax, xmm0 ; eax = hash.3
and eax, 0f0f0f0f0h
movzx ecx, bh
pxor xmm5, oword ptr [esi+ 2*256 + ecx]
movzx ecx, bl
pxor xmm4, oword ptr [esi+ 2*256 + ecx]
shr ebx, 16
movzx ecx, bh
pxor xmm3, oword ptr [esi+ 2*256 + ecx]
movzx ecx, bl
pxor xmm2, oword ptr [esi+ 2*256 + ecx]
movd ebx, xmm0
shl ebx, 4
and ebx, 0f0f0f0f0h
movzx ecx, ah
pxor xmm5, oword ptr [esi+1024+ 3*256 + ecx]
movzx ecx, al
pxor xmm4, oword ptr [esi+1024+ 3*256 + ecx]
shr eax, 16
movzx ecx, ah
pxor xmm3, oword ptr [esi+1024+ 3*256 + ecx]
movzx ecx, al
pxor xmm2, oword ptr [esi+1024+ 3*256 + ecx]
movzx ecx, bh
pxor xmm5, oword ptr [esi+ 3*256 + ecx]
movzx ecx, bl
pxor xmm4, oword ptr [esi+ 3*256 + ecx]
shr ebx, 16
movzx ecx, bh
pxor xmm3, oword ptr [esi+ 3*256 + ecx]
movzx ecx, bl
pxor xmm2, oword ptr [esi+ 3*256 + ecx]
movdqa xmm0, xmm3
pslldq xmm3, 1
pxor xmm2, xmm3
movdqa xmm1, xmm2
pslldq xmm2, 1
pxor xmm5, xmm2
psrldq xmm0, 15
movd ecx, xmm0
CALLASM getAesGcmConst_table_ct ;;movzx eax, word ptr [edx + ecx*sizeof(word)]
shl eax, 8
movdqa xmm0, xmm5
pslldq xmm5, 1
pxor xmm4, xmm5
psrldq xmm1, 15
movd ecx, xmm1
mov ebx, eax ;;xor ax, word ptr [edx + ecx*sizeof(word)]
CALLASM getAesGcmConst_table_ct ;;
xor eax, ebx ;;
shl eax, 8
psrldq xmm0, 15
movd ecx, xmm0
mov ebx, eax ;;xor ax, word ptr [edx + ecx*sizeof(word)]
CALLASM getAesGcmConst_table_ct ;;
xor eax, ebx ;;
movd xmm0, eax
pxor xmm0, xmm4
movdqu oword ptr[edi], xmm0 ; store hash value
ret
IPPASM AesGcmMulGcm_table2K ENDP
;
; void AesGcmAuth_table2K(Ipp8u* pHash, const Ipp8u* pSrc, int len, const Ipp8u* pPrecomputedData, const void* pParam)
;
ALIGN IPP_ALIGN_FACTOR
IPPASM AesGcmAuth_table2K PROC NEAR C PUBLIC \
USES esi edi ebx,\
pHash: PTR BYTE,\
pSrc: PTR BYTE,\
len: DWORD,\
pMulTbl: PTR BYTE,\
pParam: PTR WORD
mov edi, pHash
movdqu xmm0, [edi] ; hash value
mov esi, pMulTbl
mov edi, pSrc
mov edx, pParam ; pointer to the fixed table
ALIGN IPP_ALIGN_FACTOR
auth_loop:
movdqu xmm4, [edi] ; get src[]
pxor xmm0, xmm4 ; hash ^= src[]
movd ebx, xmm0 ; ebx = hash.0
mov eax, 0f0f0f0f0h
and eax, ebx ; eax = 4 x 4_bits
shl ebx, 4
and ebx, 0f0f0f0f0h ; ebx = 4 x 4_bits (another)
movzx ecx, ah
movdqa xmm5, oword ptr [esi+1024+ecx]
movzx ecx, al
movdqa xmm4, oword ptr [esi+1024+ecx]
shr eax, 16
movzx ecx, ah
movdqa xmm3, oword ptr [esi+1024+ecx]
movzx ecx, al
movdqa xmm2, oword ptr [esi+1024+ecx]
psrldq xmm0, 4 ; shift xmm0
movd eax, xmm0 ; eax = hash[1]
and eax, 0f0f0f0f0h ; eax = 4 x 4_bits
movzx ecx, bh
pxor xmm5, oword ptr [esi+ 0*256 + ecx]
movzx ecx, bl
pxor xmm4, oword ptr [esi+ 0*256 + ecx]
shr ebx, 16
movzx ecx, bh
pxor xmm3, oword ptr [esi+ 0*256 + ecx]
movzx ecx, bl
pxor xmm2, oword ptr [esi+ 0*256 + ecx]
movd ebx, xmm0 ; ebx = hash[1]
shl ebx, 4 ; another 4 x 4_bits
and ebx, 0f0f0f0f0h
movzx ecx, ah
pxor xmm5, oword ptr [esi+1024+ 1*256 + ecx]
movzx ecx, al
pxor xmm4, oword ptr [esi+1024+ 1*256 + ecx]
shr eax, 16
movzx ecx, ah
pxor xmm3, oword ptr [esi+1024+ 1*256 + ecx]
movzx ecx, al
pxor xmm2, oword ptr [esi+1024+ 1*256 + ecx]
psrldq xmm0, 4
movd eax, xmm0 ; eax = hash[2]
and eax, 0f0f0f0f0h
movzx ecx, bh
pxor xmm5, oword ptr [esi+ 1*256 + ecx]
movzx ecx, bl
pxor xmm4, oword ptr [esi+ 1*256 + ecx]
shr ebx, 16
movzx ecx, bh
pxor xmm3, oword ptr [esi+ 1*256 + ecx]
movzx ecx, bl
pxor xmm2, oword ptr [esi+ 1*256 + ecx]
movd ebx, xmm0
shl ebx, 4
and ebx, 0f0f0f0f0h
movzx ecx, ah
pxor xmm5, oword ptr [esi+1024+ 2*256 + ecx]
movzx ecx, al
pxor xmm4, oword ptr [esi+1024+ 2*256 + ecx]
shr eax, 16
movzx ecx, ah
pxor xmm3, oword ptr [esi+1024+ 2*256 + ecx]
movzx ecx, al
pxor xmm2, oword ptr [esi+1024+ 2*256 + ecx]
psrldq xmm0, 4
movd eax, xmm0 ; eax = hash[3]
and eax, 0f0f0f0f0h
movzx ecx, bh
pxor xmm5, oword ptr [esi+ 2*256 + ecx]
movzx ecx, bl
pxor xmm4, oword ptr [esi+ 2*256 + ecx]
shr ebx, 16
movzx ecx, bh
pxor xmm3, oword ptr [esi+ 2*256 + ecx]
movzx ecx, bl
pxor xmm2, oword ptr [esi+ 2*256 + ecx]
movd ebx, xmm0
shl ebx, 4
and ebx, 0f0f0f0f0h
movzx ecx, ah
pxor xmm5, oword ptr [esi+1024+ 3*256 + ecx]
movzx ecx, al
pxor xmm4, oword ptr [esi+1024+ 3*256 + ecx]
shr eax, 16
movzx ecx, ah
pxor xmm3, oword ptr [esi+1024+ 3*256 + ecx]
movzx ecx, al
pxor xmm2, oword ptr [esi+1024+ 3*256 + ecx]
movzx ecx, bh
pxor xmm5, oword ptr [esi+ 3*256 + ecx]
movzx ecx, bl
pxor xmm4, oword ptr [esi+ 3*256 + ecx]
shr ebx, 16
movzx ecx, bh
pxor xmm3, oword ptr [esi+ 3*256 + ecx]
movzx ecx, bl
pxor xmm2, oword ptr [esi+ 3*256 + ecx]
movdqa xmm0, xmm3
pslldq xmm3, 1
pxor xmm2, xmm3
movdqa xmm1, xmm2
pslldq xmm2, 1
pxor xmm5, xmm2
psrldq xmm0, 15
movd ecx, xmm0
CALLASM getAesGcmConst_table_ct ;;movzx eax, word ptr [edx + ecx*sizeof(word)]
shl eax, 8
movdqa xmm0, xmm5
pslldq xmm5, 1
pxor xmm4, xmm5
psrldq xmm1, 15
movd ecx, xmm1
mov ebx, eax ;;xor ax, word ptr [edx + ecx*sizeof(word)]
CALLASM getAesGcmConst_table_ct ;;
xor eax, ebx ;;
shl eax, 8
psrldq xmm0, 15
movd ecx, xmm0
mov ebx, eax ;;xor ax, word ptr [edx + ecx*sizeof(word)]
CALLASM getAesGcmConst_table_ct ;;
xor eax, ebx ;;
movd xmm0, eax
pxor xmm0, xmm4
add edi, sizeof(oword) ; advance src address
sub len, sizeof(oword) ; decrease counter
jnz auth_loop ; process next block
mov edi, pHash
movdqu oword ptr[edi], xmm0 ; store hash value
ret
IPPASM AesGcmAuth_table2K ENDP
ENDIF
END
|
src/test01/src/main.adb | hannesb0/rtpl18 | 0 | 16450 | -- Task 2 of RTPL WS17/18
-- Team members: <NAME>. and <NAME>.
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Handling; -- For detecting ENTER key
-- User defined packages
with counting; use counting;
with convert; use convert;
with calculate; use calculate;
with myTasks; use myTasks;
with dice; use dice;
-- Main procedure
procedure main is
-- Control characters for user input
C1 : Character := ' ';
C2 : Character := ' ';
task1 : myGrow;
begin
-- Main loop
while C1 /= 'x' loop
-- Clear terminal (only working in gps terminal)
Put (ASCII.ESC & "[2J");
-- Print available options
Put_Line ("");
Put_Line ("-----------------------------------------------");
Put_Line ("Please select one of the following options:");
Put_Line ("-----------------------------------------------");
Put_Line ("A) Counting: . . . . . . . . . . . . . . . [1]");
Put_Line ("B) Celsius to Fahrenheit: . . . . . . . . [2]");
Put_Line ("B) Fahrenheit to Celsius: . . . . . . . . [3]");
Put_Line ("C) Calculate magnitude of vector: . . . . [4]");
Put_Line ("D) Add/Remove element to/from basket . . . [5]");
Put_Line ("D) Start growth . . . . . . . . . . . . . [6]");
Put_Line ("D) Stop growth . . . . . . . . . . . . . . [7]");
Put_Line ("E) Dice game . . . . . . . . . . . . . . . [8]");
Put_Line ("F) Float add . . . . . . . . . . . . . . . [9]");
Put_Line ("Exit Application . . . . . . . . . . . . . [x]");
Put_Line ("-----------------------------------------------");
-- Get user input
Put ("Your Choice: ");
Get (C1);
Put_Line ("");
-- Parse user input
case C1 is
when '1' => opt1;
when '2' => opt2;
when '3' => opt3;
when '4' => opt4;
when '5' => opt5;
when '6' => opt6;
when '7' => opt7;
when '8' => opt8;
when '9' => opt9;
when others => Put_Line ("Wrong Input!");
end case;
if C1 /= 'x' then
-- Wait for user pressing ENTER
Put_Line ("");
Put ("Please press ENTER to continue.");
loop
Get_Immediate (C2);
exit when Ada.Characters.Handling.Is_Line_Terminator (C2);
end loop;
end if;
-- Clear terminal
Put (ASCII.ESC & "[2J");
-- End of main loop
end loop;
-- Terminate myGrow task
myGrowEnd := True;
end main;
|
oeis/127/A127239.asm | neoneye/loda-programs | 11 | 175437 | <reponame>neoneye/loda-programs<filename>oeis/127/A127239.asm
; A127239: Central coefficients of Thue-Morse binomial triangle A127236.
; 1,1,0,0,1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,1,1,0,1,1,1,0,0,1,0,0,0,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,1,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,0,1,1,1,1,0,0,1,0,0,0,1,0,0,1,1
seq $0,82481 ; Number of 1's in binary representation of C(2n,n).
mod $0,2
|
libsrc/_DEVELOPMENT/arch/ts2068/display/c/sccz80/tshc_aaddr2px.asm | jpoikela/z88dk | 38 | 160946 | <reponame>jpoikela/z88dk
; uchar tshc_aaddr2px(void *aaddr)
SECTION code_clib
SECTION code_arch
PUBLIC tshc_aaddr2px
EXTERN zx_saddr2px
defc tshc_aaddr2px = zx_saddr2px
|
data/pokemon/dex_entries/exeggutor.asm | AtmaBuster/pokeplat-gen2 | 6 | 26199 | <gh_stars>1-10
db "COCONUT@" ; species name
db "Living in a good"
next "environment makes"
next "it grow lots of"
page "heads. A head that"
next "drops off becomes"
next "an EXEGGCUTE.@"
|
Grammar/rasm.g4 | Tjakka5/RiSC-CPU | 0 | 1069 | grammar Rasm;
file: (line | NL)*;
statement: keyword (arg? arg? arg?) | (special_keyword arg);
labelDef: LABEL NL? statement+;
line: (statement | labelDef) COMMENT? NL?;
keyword: 'add' | 'addi' | 'nand' | 'lui' | 'sw' | 'lw' | 'beq' | 'jalr' | 'nop' | 'halt' | 'lli' | 'movi';
special_keyword: '.fill' | '.space';
arg: OCTAL | DECIMAL | HEXADECIMAL | WORD;
LABEL: [a-zA-Z0-9]+':';
WORD: [a-zA-Z]+;
OCTAL : '0' [1-7] ([0-7])*;
DECIMAL : ('-')? ([0-9])+;
HEXADECIMAL : '0x' ([a-fA-F0-9])+;
COMMENT: '#' ~( '\r' | '\n' )*;
NL: '\r'? '\n';
WS: [ \t\n\r] -> skip; |
src/pyfx/model/common/jsonpath/JSONPath.g4 | cielong/pyfx | 9 | 6021 | /*
JSONPath grammar
*/
grammar JSONPath;
jsonpath: ROOT (expression)* EOF
;
expression: singleDotExpression
| doubleDotExpression
;
// only limited double dot expression supported
doubleDotExpression: DOUBLE_DOT field
| DOUBLE_DOT bracketField
;
singleDotExpression: fieldAccessor
| SINGLE_DOT wildcard
| (SINGLE_DOT)? bracketWildcard
| (SINGLE_DOT)? filters
| (SINGLE_DOT)? arraySlice
| (SINGLE_DOT)? union
;
// filters
// only support direct field comparison (with no more nested JSONPath)
filters: '[' '?' '(' numericFilter ')' ']'
| '[' '?' '(' stringFilter ')' ']'
| '[' '?' '(' booleanFilter ')' ']'
;
numericFilter: CURRENT fieldAccessor ('>'|'<'|'==') INT
;
stringFilter: CURRENT fieldAccessor '==' STRING
;
booleanFilter: CURRENT fieldAccessor
;
// union
union: '[' (STRING|LETTER) (',' (STRING|LETTER))+ ']'
;
// array slice
arraySlice: '[' INT? ':' INT? (':' INT)? ']'
;
// accessors
fieldAccessor: SINGLE_DOT field
| (SINGLE_DOT)? bracketField
| (SINGLE_DOT)? arrayIndex
;
field: LETTER
;
bracketField: '[' (STRING|LETTER) ']'
;
arrayIndex: '[' INT ']'
;
wildcard: '*'
;
bracketWildcard: '[*]'
;
// lexer
// JSONPath specific
ROOT : '$' ;
CURRENT : '@' ;
SINGLE_DOT : '.' ;
DOUBLE_DOT : '..' ;
// ascii letters
LETTER : [a-zA-Z]+ ;
// string
// the potential EOF ending is for parsing incomplete (with only single sided quote as string)
STRING : '\'' (QUOTE|.)*? ('\''|EOF) ;
fragment
QUOTE : '\\\'' | '\\\\';
// integer
INT : '0' | [1-9]([0-9])* ;
// skip white spaces
WS : [ \t\r\n]+ -> skip ;
|
oeis/335/A335025.asm | neoneye/loda-programs | 11 | 170337 | ; A335025: Largest side lengths of almost-equilateral Heronian triangles.
; 5,15,53,195,725,2703,10085,37635,140453,524175,1956245,7300803,27246965,101687055,379501253,1416317955,5285770565,19726764303,73621286645,274758382275,1025412242453,3826890587535,14282150107685,53301709843203,198924689265125,742397047217295,2770663499604053,10340256951198915,38590364305191605,144021200269567503,537494436773078405,2005956546822746115,7486331750517906053,27939370455248878095,104271150070477606325,389145229826661547203,1452309769236168582485,5420093847118012782735
mov $1,2
mov $2,4
lpb $0
sub $0,1
add $2,$1
add $1,$2
add $2,$1
lpe
mov $0,$2
add $0,1
|
libsrc/_DEVELOPMENT/inttypes/c/sccz80/_imaxdiv__callee.asm | jpoikela/z88dk | 640 | 11367 | <reponame>jpoikela/z88dk
; void _imaxdiv_(imaxdiv_t *md, intmax_t numer, intmax_t denom)
SECTION code_clib
SECTION code_inttypes
PUBLIC _imaxdiv__callee
EXTERN _ldiv__callee
defc _imaxdiv__callee = _ldiv__callee
|
programs/oeis/061/A061776.asm | jmorken/loda | 1 | 242140 | ; A061776: Start with a single triangle; at n-th generation add a triangle at each vertex, allowing triangles to overlap; sequence gives number of triangles in n-th generation.
; 1,3,6,12,18,30,42,66,90,138,186,282,378,570,762,1146,1530,2298,3066,4602,6138,9210,12282,18426,24570,36858,49146,73722,98298,147450,196602,294906,393210,589818,786426,1179642,1572858,2359290,3145722,4718586,6291450,9437178,12582906,18874362,25165818,37748730,50331642,75497466,100663290,150994938,201326586,301989882,402653178,603979770,805306362,1207959546,1610612730,2415919098,3221225466,4831838202,6442450938,9663676410,12884901882,19327352826,25769803770,38654705658,51539607546,77309411322,103079215098,154618822650,206158430202,309237645306,412316860410,618475290618,824633720826,1236950581242,1649267441658,2473901162490,3298534883322,4947802324986,6597069766650,9895604649978,13194139533306,19791209299962,26388279066618,39582418599930,52776558133242,79164837199866,105553116266490,158329674399738,211106232532986,316659348799482,422212465065978,633318697598970,844424930131962,1266637395197946,1688849860263930,2533274790395898,3377699720527866,5066549580791802,6755399441055738
mov $2,1
lpb $0
add $1,1
trn $2,$0
sub $0,1
add $2,$1
mov $1,$2
lpe
add $2,$1
add $1,$2
|
mastersystem/zxb-sms-2012-02-23/zxb-sms/wip/zxb/library-asm/printstr.asm | gb-archive/really-old-stuff | 10 | 6108 | #include once <print.asm>
#include once <sposn.asm>
#include once <attr.asm>
#include once <free.asm>
; PRINT command routine
; Prints string pointed by HL
PRINT_STR:
__PRINTSTR: ; __FASTCALL__ Entry to print_string
PROC
LOCAL __PRINT_STR_LOOP
LOCAL __PRINT_STR_END
ld d, a ; Saves A reg (Flag) for later
ld a, h
or l
ret z ; Return if the pointer is NULL
push hl
ld c, (hl)
inc hl
ld b, (hl)
inc hl ; BC = LEN(a$); HL = &a$
__PRINT_STR_LOOP:
ld a, b
or c
jr z, __PRINT_STR_END ; END if BC (counter = 0)
ld a, (hl)
call __PRINTCHAR
inc hl
dec bc
jp __PRINT_STR_LOOP
__PRINT_STR_END:
pop hl
ld a, d ; Recovers A flag
or a ; If not 0 this is a temporary string. Free it
ret z
jp __MEM_FREE ; Frees str from heap and return from there
__PRINT_STR:
; Fastcall Entry
; It ONLY prints strings
; HL = String start
; BC = String length (Number of chars)
push hl ; Push str address for later
ld d, a ; Saves a FLAG
jp __PRINT_STR_LOOP
ENDP
|
Confuser.Core/Project/PatternParser.g4 | lysep-corp/ConfuserEx-LSREMAKE | 9 | 7546 | parser grammar PatternParser;
options { tokenVocab=PatternLexer; }
pattern : function
| pattern AND pattern
| pattern OR pattern
| NOT pattern
| PAREN_OPEN pattern PAREN_CLOSE;
function : declTypeFunction
| fullNameFunction
| hasAttrFunction
| inheritsFunction
| isPublicFunction
| isTypeFunction
| matchFunction
| matchNameFunction
| matchTypeNameFunction
| memberTypeFunction
| moduleFunction
| nameFunction
| namespaceFunction
| trueLiteral
| falseLiteral;
declTypeFunction : DECL_TYPE PAREN_OPEN literalExpression PAREN_CLOSE;
fullNameFunction : FULL_NAME PAREN_OPEN literalExpression PAREN_CLOSE;
hasAttrFunction : HAS_ATTR PAREN_OPEN literalExpression PAREN_CLOSE;
inheritsFunction : INHERITS PAREN_OPEN literalExpression PAREN_CLOSE;
isPublicFunction : IS_PUBLIC;
isTypeFunction : IS_TYPE PAREN_OPEN literalExpression PAREN_CLOSE;
matchFunction : MATCH PAREN_OPEN literalExpression PAREN_CLOSE;
matchNameFunction : MATCH_NAME PAREN_OPEN literalExpression PAREN_CLOSE;
matchTypeNameFunction : MATCH_TYPE_NAME PAREN_OPEN literalExpression PAREN_CLOSE;
memberTypeFunction : MEMBER_TYPE PAREN_OPEN literalExpression PAREN_CLOSE;
moduleFunction : MODULE PAREN_OPEN literalExpression PAREN_CLOSE;
nameFunction : NAME PAREN_OPEN literalExpression PAREN_CLOSE;
namespaceFunction : NAMESPACE PAREN_OPEN literalExpression PAREN_CLOSE;
literalExpression : LITERAL;
trueLiteral : TRUE;
falseLiteral : FALSE;
|
src/MJ/Examples/DynDispatch.agda | metaborg/mj.agda | 10 | 8952 | <reponame>metaborg/mj.agda
module MJ.Examples.DynDispatch where
open import Prelude
import Data.Vec.All as Vec∀
open import Data.Star
open import Data.Bool
open import Data.List
open import Data.List.Any
open import Data.List.Membership.Propositional
open import Data.List.All hiding (lookup)
open import Data.Product hiding (Σ)
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary.Decidable
open import Data.String
open import MJ.Types
open import MJ.Classtable.Core 2
{-
// We test field inheritance and
// method call dispatching combining super calls and dynamic dispatch.
// The Agda test is equivalent to the following Java code
class Int {
int x;
public Int(int i) {
this.x = i;
return;
}
public int get() {
System.out.println("never");
return x;
}
public int set (Int y) {
x = y.x;
// in the test main this should dispatch to
// the implementation of the child Int2
return this.get();
}
}
class Int2 extends Int {
public Int2(int i) {
super(i);
}
public int get() {
return x + 1;
}
public int set (Int y) {
// test super dispatch
return super.set(new Int(y.x + 1));
}
}
class Main {
public static void main(String[] args) {
Int y = new Int(18);
Int2 x = new Int2(0);
// should print 20
// because we use the set(..) and get() of Int2
// which both increment with one
System.out.println(x.set(y));
}
}
-}
INT : Cid 2
INT = (cls (# 0))
INT+ : Cid 2
INT+ = (cls (# 1))
decls : (ns : NS) → List (String × typing ns)
decls METHOD =
("get" , ([] , int))
∷ ("set" , (ref INT ∷ [] , int))
∷ []
decls FIELD =
("x" , int)
∷ []
-- override methods; no extra fields
decls+ : (ns : NS) → List (String × typing ns)
decls+ METHOD =
("get" , ([] , int))
∷ ("set" , (ref INT ∷ [] , int))
∷ []
decls+ FIELD = []
IntegerSig = (class Object (int ∷ []) decls)
Integer+Sig = (class INT (int ∷ []) decls+)
-- class table signature
Σ : Classtable
Σ = record {
Σ = λ{
(cls zero) → IntegerSig ;
(cls (suc zero)) → Integer+Sig ;
(cls (suc (suc ()))) ;
Object → ObjectClass} ;
founded = refl ;
rooted = λ{
(cls zero) → super ◅ ε ;
(cls (suc zero)) → super ◅ super ◅ ε ;
(cls (suc (suc ()))) ;
Object → ε };
Σ-Object = refl }
open import MJ.Classtable.Code Σ
open import MJ.Syntax Σ
open import MJ.Syntax.Program Σ
-- Integer class body
IntegerImpl : Implementation INT
IntegerImpl = implementation
(body (body
(set
(var (here refl))
"x"
(var (there (here refl))) ◅ ε)
unit))
-- methods
(
-- get
body (body ε (get (var (here refl)) "x"))
-- set
∷ (body (body
(set
(var (here refl))
"x"
{int}
(get (var (there (here refl))) "x") ◅ ε)
(call (var (here refl)) "get" [])))
∷ []
)
-- Integer+ class body
Integer+Impl : Implementation INT+
Integer+Impl = implementation
(body (body
(
set (var (here refl)) "x" (var (there (here refl)))
◅ ε)
unit))
-- methods
(
-- override get
(body (body ε (iop (λ l r → l + r) (get (var (here refl)) "x") (num 1))))
-- set
∷ (super _ ⟨ new INT (iop (λ l r → l + r) (get (var (there (here refl))) "x") (num 1) ∷ []) ∷ [] ⟩then
body
ε
(var (here refl)))
∷ []
)
-- Implementation of the class table
Lib : Code
Lib (cls zero) = IntegerImpl
Lib (cls (suc zero)) = Integer+Impl
Lib (cls (suc (suc ())))
Lib Object = implementation (body (body ε unit)) []
open import MJ.Semantics Σ Lib
open import MJ.Semantics.Values Σ
-- a simple program
p₀ : Prog int
p₀ = Lib ,
let
x = (here refl)
y = (there (here refl))
in body
(
loc (ref INT) -- y
◅ loc (ref INT+) -- x
◅ asgn x (new INT+ ((num 0) ∷ []))
◅ asgn y (new INT ((num 18) ∷ []))
◅ ε
)
(call (var x) "set" (var y ∷ []))
test0 : p₀ ⇓⟨ 100 ⟩ (λ {W} (v : Val W int) → v ≡ num 20)
test0 = refl
|
test/Succeed/ReduceDefs.agda | shlevy/agda | 0 | 83 | open import Agda.Builtin.Unit
open import Agda.Builtin.Nat
open import Agda.Builtin.List
open import Agda.Builtin.Reflection renaming (bindTC to _>>=_)
open import Agda.Builtin.Equality
macro
macro₁ : Term -> TC ⊤
macro₁ goal = do
u ← quoteTC ((1 + 2) - 3)
u' ← onlyReduceDefs (quote _+_ ∷ []) (normalise u)
qu' ← quoteTC u'
unify qu' goal
test₁ : macro₁ ≡ def (quote _-_)
(arg (arg-info visible relevant) (lit (nat 3)) ∷
arg (arg-info visible relevant) (lit (nat 3)) ∷ [])
test₁ = refl
macro
macro₂ : Term -> TC ⊤
macro₂ goal = do
u ← quoteTC ((1 - 2) + 3)
u' ← dontReduceDefs (quote _+_ ∷ []) (normalise u)
qu' ← quoteTC u'
unify qu' goal
test₂ : macro₂ ≡ def (quote _+_)
(arg (arg-info visible relevant) (lit (nat 0)) ∷
arg (arg-info visible relevant) (lit (nat 3)) ∷ [])
test₂ = refl
|
awa/src/model/awa-events-models.ads | Letractively/ada-awa | 0 | 7381 | -----------------------------------------------------------------------
-- AWA.Events.Models -- AWA.Events.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-spec.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095
-----------------------------------------------------------------------
-- Copyright (C) 2013 <NAME>
-- Written by <NAME> (<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.
-----------------------------------------------------------------------
pragma Warnings (Off, "unit * is not referenced");
with ADO.Sessions;
with ADO.Objects;
with ADO.Statements;
with ADO.SQL;
with ADO.Schemas;
with ADO.Queries;
with ADO.Queries.Loaders;
with Ada.Calendar;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Beans.Objects.Enums;
with Util.Beans.Basic.Lists;
with AWA.Users.Models;
pragma Warnings (On, "unit * is not referenced");
package AWA.Events.Models is
type Message_Status_Type is (QUEUED, PROCESSING, PROCESSED);
for Message_Status_Type use (QUEUED => 0, PROCESSING => 1, PROCESSED => 2);
package Message_Status_Type_Objects is
new Util.Beans.Objects.Enums (Message_Status_Type);
type Message_Type_Ref is new ADO.Objects.Object_Ref with null record;
type Queue_Ref is new ADO.Objects.Object_Ref with null record;
type Message_Ref is new ADO.Objects.Object_Ref with null record;
-- Create an object key for Message_Type.
function Message_Type_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Message_Type from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Message_Type_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Message_Type : constant Message_Type_Ref;
function "=" (Left, Right : Message_Type_Ref'Class) return Boolean;
--
procedure Set_Id (Object : in out Message_Type_Ref;
Value : in ADO.Identifier);
--
function Get_Id (Object : in Message_Type_Ref)
return ADO.Identifier;
-- Set the message type name
procedure Set_Name (Object : in out Message_Type_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Name (Object : in out Message_Type_Ref;
Value : in String);
-- Get the message type name
function Get_Name (Object : in Message_Type_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Name (Object : in Message_Type_Ref)
return String;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Message_Type_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Message_Type_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Message_Type_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Message_Type_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Message_Type_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Message_Type_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
MESSAGE_TYPE_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Message_Type_Ref);
-- Copy of the object.
procedure Copy (Object : in Message_Type_Ref;
Into : in out Message_Type_Ref);
package Message_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Natural,
Element_Type => Message_Type_Ref,
"=" => "=");
subtype Message_Type_Vector is Message_Type_Vectors.Vector;
procedure List (Object : in out Message_Type_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class);
-- --------------------
-- The message queue tracks the event messages that must be dispatched by
-- a given server.
-- --------------------
-- Create an object key for Queue.
function Queue_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Queue from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Queue_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Queue : constant Queue_Ref;
function "=" (Left, Right : Queue_Ref'Class) return Boolean;
--
procedure Set_Id (Object : in out Queue_Ref;
Value : in ADO.Identifier);
--
function Get_Id (Object : in Queue_Ref)
return ADO.Identifier;
--
procedure Set_Server_Id (Object : in out Queue_Ref;
Value : in Integer);
--
function Get_Server_Id (Object : in Queue_Ref)
return Integer;
-- Set the message queue name
procedure Set_Name (Object : in out Queue_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Name (Object : in out Queue_Ref;
Value : in String);
-- Get the message queue name
function Get_Name (Object : in Queue_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Name (Object : in Queue_Ref)
return String;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Queue_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Queue_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Queue_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Queue_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Queue_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Queue_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
QUEUE_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Queue_Ref);
-- Copy of the object.
procedure Copy (Object : in Queue_Ref;
Into : in out Queue_Ref);
-- Create an object key for Message.
function Message_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Message from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Message_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Message : constant Message_Ref;
function "=" (Left, Right : Message_Ref'Class) return Boolean;
-- Set the message identifier
procedure Set_Id (Object : in out Message_Ref;
Value : in ADO.Identifier);
-- Get the message identifier
function Get_Id (Object : in Message_Ref)
return ADO.Identifier;
-- Set the message creation date
procedure Set_Create_Date (Object : in out Message_Ref;
Value : in Ada.Calendar.Time);
-- Get the message creation date
function Get_Create_Date (Object : in Message_Ref)
return Ada.Calendar.Time;
-- Set the message priority
procedure Set_Priority (Object : in out Message_Ref;
Value : in Integer);
-- Get the message priority
function Get_Priority (Object : in Message_Ref)
return Integer;
-- Set the message count
procedure Set_Count (Object : in out Message_Ref;
Value : in Integer);
-- Get the message count
function Get_Count (Object : in Message_Ref)
return Integer;
-- Set the message parameters
procedure Set_Parameters (Object : in out Message_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Parameters (Object : in out Message_Ref;
Value : in String);
-- Get the message parameters
function Get_Parameters (Object : in Message_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Parameters (Object : in Message_Ref)
return String;
-- Set the server identifier which processes the message
procedure Set_Server_Id (Object : in out Message_Ref;
Value : in Integer);
-- Get the server identifier which processes the message
function Get_Server_Id (Object : in Message_Ref)
return Integer;
-- Set the task identfier on the server which processes the message
procedure Set_Task_Id (Object : in out Message_Ref;
Value : in Integer);
-- Get the task identfier on the server which processes the message
function Get_Task_Id (Object : in Message_Ref)
return Integer;
-- Set the message status
procedure Set_Status (Object : in out Message_Ref;
Value : in AWA.Events.Models.Message_Status_Type);
-- Get the message status
function Get_Status (Object : in Message_Ref)
return AWA.Events.Models.Message_Status_Type;
-- Set the message processing date
procedure Set_Processing_Date (Object : in out Message_Ref;
Value : in ADO.Nullable_Time);
-- Get the message processing date
function Get_Processing_Date (Object : in Message_Ref)
return ADO.Nullable_Time;
--
function Get_Version (Object : in Message_Ref)
return Integer;
-- Set the entity identifier to which this event is associated.
procedure Set_Entity_Id (Object : in out Message_Ref;
Value : in ADO.Identifier);
-- Get the entity identifier to which this event is associated.
function Get_Entity_Id (Object : in Message_Ref)
return ADO.Identifier;
-- Set the entity type of the entity identifier to which this event is associated.
procedure Set_Entity_Type (Object : in out Message_Ref;
Value : in ADO.Entity_Type);
-- Get the entity type of the entity identifier to which this event is associated.
function Get_Entity_Type (Object : in Message_Ref)
return ADO.Entity_Type;
-- Set the date and time when the event was finished to be processed.
procedure Set_Finish_Date (Object : in out Message_Ref;
Value : in ADO.Nullable_Time);
-- Get the date and time when the event was finished to be processed.
function Get_Finish_Date (Object : in Message_Ref)
return ADO.Nullable_Time;
--
procedure Set_Queue (Object : in out Message_Ref;
Value : in AWA.Events.Models.Queue_Ref'Class);
--
function Get_Queue (Object : in Message_Ref)
return AWA.Events.Models.Queue_Ref'Class;
-- Set the message type
procedure Set_Message_Type (Object : in out Message_Ref;
Value : in AWA.Events.Models.Message_Type_Ref'Class);
-- Get the message type
function Get_Message_Type (Object : in Message_Ref)
return AWA.Events.Models.Message_Type_Ref'Class;
-- Set the optional user who triggered the event message creation
procedure Set_User (Object : in out Message_Ref;
Value : in AWA.Users.Models.User_Ref'Class);
-- Get the optional user who triggered the event message creation
function Get_User (Object : in Message_Ref)
return AWA.Users.Models.User_Ref'Class;
-- Set the optional user session that triggered the message creation
procedure Set_Session (Object : in out Message_Ref;
Value : in AWA.Users.Models.Session_Ref'Class);
-- Get the optional user session that triggered the message creation
function Get_Session (Object : in Message_Ref)
return AWA.Users.Models.Session_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Message_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Message_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Message_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Message_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Message_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Message_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
MESSAGE_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Message_Ref);
-- Copy of the object.
procedure Copy (Object : in Message_Ref;
Into : in out Message_Ref);
package Message_Vectors is
new Ada.Containers.Vectors (Index_Type => Natural,
Element_Type => Message_Ref,
"=" => "=");
subtype Message_Vector is Message_Vectors.Vector;
procedure List (Object : in out Message_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class);
Query_Queue_Pending_Message : constant ADO.Queries.Query_Definition_Access;
private
MESSAGE_TYPE_NAME : aliased constant String := "awa_message_type";
COL_0_1_NAME : aliased constant String := "id";
COL_1_1_NAME : aliased constant String := "name";
MESSAGE_TYPE_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 2,
Table => MESSAGE_TYPE_NAME'Access,
Members => (
1 => COL_0_1_NAME'Access,
2 => COL_1_1_NAME'Access
)
);
MESSAGE_TYPE_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= MESSAGE_TYPE_DEF'Access;
Null_Message_Type : constant Message_Type_Ref
:= Message_Type_Ref'(ADO.Objects.Object_Ref with others => <>);
type Message_Type_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => MESSAGE_TYPE_DEF'Access)
with record
Name : Ada.Strings.Unbounded.Unbounded_String;
end record;
type Message_Type_Access is access all Message_Type_Impl;
overriding
procedure Destroy (Object : access Message_Type_Impl);
overriding
procedure Find (Object : in out Message_Type_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Message_Type_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Message_Type_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Message_Type_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Message_Type_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Message_Type_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Message_Type_Ref'Class;
Impl : out Message_Type_Access);
QUEUE_NAME : aliased constant String := "awa_queue";
COL_0_2_NAME : aliased constant String := "id";
COL_1_2_NAME : aliased constant String := "server_id";
COL_2_2_NAME : aliased constant String := "name";
QUEUE_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 3,
Table => QUEUE_NAME'Access,
Members => (
1 => COL_0_2_NAME'Access,
2 => COL_1_2_NAME'Access,
3 => COL_2_2_NAME'Access
)
);
QUEUE_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= QUEUE_DEF'Access;
Null_Queue : constant Queue_Ref
:= Queue_Ref'(ADO.Objects.Object_Ref with others => <>);
type Queue_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => QUEUE_DEF'Access)
with record
Server_Id : Integer;
Name : Ada.Strings.Unbounded.Unbounded_String;
end record;
type Queue_Access is access all Queue_Impl;
overriding
procedure Destroy (Object : access Queue_Impl);
overriding
procedure Find (Object : in out Queue_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Queue_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Queue_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Queue_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Queue_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Queue_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Queue_Ref'Class;
Impl : out Queue_Access);
MESSAGE_NAME : aliased constant String := "awa_message";
COL_0_3_NAME : aliased constant String := "id";
COL_1_3_NAME : aliased constant String := "create_date";
COL_2_3_NAME : aliased constant String := "priority";
COL_3_3_NAME : aliased constant String := "count";
COL_4_3_NAME : aliased constant String := "parameters";
COL_5_3_NAME : aliased constant String := "server_id";
COL_6_3_NAME : aliased constant String := "task_id";
COL_7_3_NAME : aliased constant String := "status";
COL_8_3_NAME : aliased constant String := "processing_date";
COL_9_3_NAME : aliased constant String := "version";
COL_10_3_NAME : aliased constant String := "entity_id";
COL_11_3_NAME : aliased constant String := "entity_type";
COL_12_3_NAME : aliased constant String := "finish_date";
COL_13_3_NAME : aliased constant String := "queue_id";
COL_14_3_NAME : aliased constant String := "message_type_id";
COL_15_3_NAME : aliased constant String := "user_id";
COL_16_3_NAME : aliased constant String := "session_id";
MESSAGE_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 17,
Table => MESSAGE_NAME'Access,
Members => (
1 => COL_0_3_NAME'Access,
2 => COL_1_3_NAME'Access,
3 => COL_2_3_NAME'Access,
4 => COL_3_3_NAME'Access,
5 => COL_4_3_NAME'Access,
6 => COL_5_3_NAME'Access,
7 => COL_6_3_NAME'Access,
8 => COL_7_3_NAME'Access,
9 => COL_8_3_NAME'Access,
10 => COL_9_3_NAME'Access,
11 => COL_10_3_NAME'Access,
12 => COL_11_3_NAME'Access,
13 => COL_12_3_NAME'Access,
14 => COL_13_3_NAME'Access,
15 => COL_14_3_NAME'Access,
16 => COL_15_3_NAME'Access,
17 => COL_16_3_NAME'Access
)
);
MESSAGE_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= MESSAGE_DEF'Access;
Null_Message : constant Message_Ref
:= Message_Ref'(ADO.Objects.Object_Ref with others => <>);
type Message_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => MESSAGE_DEF'Access)
with record
Create_Date : Ada.Calendar.Time;
Priority : Integer;
Count : Integer;
Parameters : Ada.Strings.Unbounded.Unbounded_String;
Server_Id : Integer;
Task_Id : Integer;
Status : AWA.Events.Models.Message_Status_Type;
Processing_Date : ADO.Nullable_Time;
Version : Integer;
Entity_Id : ADO.Identifier;
Entity_Type : ADO.Entity_Type;
Finish_Date : ADO.Nullable_Time;
Queue : AWA.Events.Models.Queue_Ref;
Message_Type : AWA.Events.Models.Message_Type_Ref;
User : AWA.Users.Models.User_Ref;
Session : AWA.Users.Models.Session_Ref;
end record;
type Message_Access is access all Message_Impl;
overriding
procedure Destroy (Object : access Message_Impl);
overriding
procedure Find (Object : in out Message_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Message_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Message_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Message_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Message_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Message_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Message_Ref'Class;
Impl : out Message_Access);
package File_1 is
new ADO.Queries.Loaders.File (Path => "queue-messages.xml",
Sha1 => "9B2B599473F75F92CB5AB5045675E4CCEF926543");
package Def_Queue_Pending_Message is
new ADO.Queries.Loaders.Query (Name => "queue-pending-message",
File => File_1.File'Access);
Query_Queue_Pending_Message : constant ADO.Queries.Query_Definition_Access
:= Def_Queue_Pending_Message.Query'Access;
end AWA.Events.Models;
|
FictionTools/z88dk/libsrc/target/svi/stdio/generic_console.asm | polluks/Puddle-BuildTools | 38 | 95530 | ; SVI console driver
;
; Supports:
; Mode 0: VDP 32x24
; Mode 10: SVI806 80x24
;
SECTION code_clib
PUBLIC generic_console_cls
PUBLIC generic_console_scrollup
PUBLIC generic_console_printc
PUBLIC generic_console_set_ink
PUBLIC generic_console_set_paper
PUBLIC generic_console_set_attribute
PUBLIC generic_console_vpeek
PUBLIC generic_console_ioctl
EXTERN __tms9918_cls
EXTERN __tms9918_console_vpeek
EXTERN __tms9918_scrollup
EXTERN __tms9918_printc
EXTERN __tms9918_console_ioctl
EXTERN __tms9918_set_ink
EXTERN __tms9918_set_paper
EXTERN __tms9918_set_attribute
EXTERN generic_console_flags
EXTERN l_push_di
EXTERN l_pop_ei
EXTERN CONSOLE_COLUMNS
EXTERN CONSOLE_ROWS
PUBLIC __svi_mode
EXTERN __console_w
INCLUDE "ioctl.def"
defc DISPLAY = $f000
PUBLIC CLIB_GENCON_CAPS
EXTERN __tms9918_CLIB_GENCON_CAPS
defc CLIB_GENCON_CAPS = __tms9918_CLIB_GENCON_CAPS
EXTERN generic_console_caps
defc generic_console_set_attribute = __tms9918_set_attribute
defc generic_console_set_paper = __tms9918_set_paper
defc generic_console_set_ink = __tms9918_set_ink
generic_console_ioctl:
cp IOCTL_GENCON_SET_MODE
jp nz, __tms9918_console_ioctl
; Set the mode here
ex de,hl
ld a,(hl)
ld hl,$1950
cp 10
jr z,set_mode
ld hl,$1820
and a
jr z,set_mode
scf
ret
set_mode:
ld (__svi_mode),a
ld (__console_w),hl
ld a,CAP_GENCON_INVERSE
ld (generic_console_caps),a
and a
ret
generic_console_cls:
ld a,(__svi_mode)
cp 10
jp nz,__tms9918_cls
call l_push_di
ld a,255
out ($58),a
xor a
ld hl,DISPLAY
ld de,DISPLAY + 1
ld bc,80 * 25 - 1
ld (hl),a
ldir
out ($58),a
call l_pop_ei
ret
generic_console_vpeek:
ld a,(__svi_mode)
cp 10
jp nz,__tms9918_console_vpeek
ld a,e ;Save raw mode
call calc_xypos
call l_push_di
ld a,255
out ($58),a
ld d,(hl)
xor a
out ($58),a
call l_pop_ei
ld a,d
rr e
call nc,vpeek_unmap
and a
ret
vpeek_unmap:
cp 96 * 2
ret nc
add 32
res 7,a
ret
; c = x
; b = y
; a = character to print
; e = raw
generic_console_printc:
ld a,(__svi_mode)
cp 10
ld a,d
jp nz,__tms9918_printc
ld a,d
rr e
call nc,convert_inverse
call calc_xypos
ld d,a
call l_push_di
ld a,255
out ($58),a
ld (hl),d
xor a
out ($58),a
call l_pop_ei
ret
convert_inverse:
sub 32
ld hl,generic_console_flags
bit 7,(hl)
ret z
add 96
ret
calc_xypos:
ld hl,DISPLAY
ld de,80
and a
sbc hl,de
inc b
xypos_1:
add hl,de
djnz xypos_1
add hl,bc ;hl is now offset in display
ret
generic_console_scrollup:
ld a,(__svi_mode)
cp 10
jp nz,__tms9918_scrollup
push bc
push de
call l_push_di
ld a,255
out ($58),a
ld hl,DISPLAY + 80
ld de,DISPLAY
ld bc, 24 * 80
ldir
ex de,hl
ld b,80
xor a
clear_loop:
ld (hl),a
inc hl
djnz clear_loop
out ($58),a
call l_pop_ei
pop de
pop bc
ret
SECTION bss_clib
__svi_mode: defb 0
SECTION code_crt_init
EXTERN asm_set_cursor_state
ld hl,mc6845_init
ld c,0
ld b,16
init_loop:
ld a,c
out ($50),a
ld a,(hl)
out ($51),a
inc hl
inc c
djnz init_loop
SECTION rodata_clib
mc6845_init:
defb $6b ;Horizontal total
defb $50 ;Horizontal displayed
defb $58 ;Horizontal sync
defb $08 ;Horizontal + vertical syncs VVVVHHHH
defb $26 ;Vertical total
defb $05 ;Vertical Total adjust
defb $18 ;Vertical displayed
defb $1e ;Vertical sync position
defb $00 ;Interlace and skew
defb $07 ;Maximum raster address
defb $00 ;Cursor start raster
defb $00 ;Cursor end raster
defb $00 ;Display start address (high)
defb $00 ;Display start address (low)
defb $00 ;Cursor address (high)
defb $00 ;Cursor address (low)
|
etude/etude9.als | nishio/learning_alloy | 1 | 159 | // combinator logic
abstract sig Bird{
apply: Bird -> Bird
}
one sig K extends Bird{}
one sig S extends Bird{}
fact {
all x, y: Bird | K.apply.x.apply.y = x
all x, y, z: Bird {
S.apply.x.apply.y.apply.z =
x.apply.z.apply.(y.apply.z)
}
}
/*
pred equal(f, g: Bird){
f in g.same_birds and g in f.same_birds
}
pred apply(f, g: Bird) {
one a: Apply {
a.x = f and a.y = g
}
}
*/
run {} for 10 Bird
// //some b: Bird | all x: Bird | b.apply.x = K
|
src/cobs-queue-encoder.ads | Fabien-Chouteau/COBS | 0 | 29789 | <gh_stars>0
-- This unit provides a COBS encoder using lock-free BipBuffer (BBqueue).
with BBqueue;
package COBS.Queue.Encoder
with Preelaborate
is
Min_Buf_Size : constant := 255;
subtype Buffer_Size
is BBqueue.Buffer_Size range 2 * Min_Buf_Size ..
BBqueue.Buffer_Size'Last;
-- The idea behind "2 * Min_Buf_Size" is to make sure we can get a grant
-- for the worst case COBS frame, but I'm not 100% sure it makes sens...
type Instance (Size : Buffer_Size) is limited private;
procedure Push (This : in out Instance;
Data : Storage_Element;
Success : out Boolean);
-- Push an input byte into the decoder. The procedure can fail if there is
-- no more writable memory in the buffer.
procedure End_Frame (This : in out Instance;
Success : out Boolean);
-- Signal the end of the current frame. The procedure can fail if there is
-- no more writable memory in the buffer.
type Slice_Rec is record
Length : BBqueue.Count;
Addr : System.Address;
end record;
function Read_Slice (This : in out Instance) return Slice_Rec;
-- Get a slice of readable encoded data. Slice's Length can be zero if
-- there is no data to read.
procedure Release (This : in out Instance);
-- Release a slice of readable encoded data
generic
with procedure Process_Read (Data : Storage_Array;
To_Release : out BBqueue.Count);
procedure Read_CB (This : in out Instance;
Result : out BBqueue.Result_Kind);
-- Read from the buffer using a "callback". This procedure will call
-- Process_Read () on a readabled encoded data slice, if available. It will
-- then call Release with the value To_Release returned by Process_Read ().
private
type Instance (Size : Buffer_Size) is limited record
Buffer : Storage_Array (1 .. Size);
Queue : BBqueue.Offsets_Only (Size);
WG : BBqueue.Write_Grant := BBqueue.Empty;
RG : BBqueue.Read_Grant := BBqueue.Empty;
Code : Storage_Element := 1;
Prev_Code : Storage_Element := 1;
Code_Pointer : Storage_Offset;
Encode_Pointer : Storage_Offset;
end record;
end COBS.Queue.Encoder;
|
programs/oeis/186/A186316.asm | karttu/loda | 1 | 16427 | <filename>programs/oeis/186/A186316.asm<gh_stars>1-10
; A186316: Adjusted joint rank sequence of (f(i)) and (g(j)) with f(i) before g(j) when f(i)=g(j), where f and g are the squares and hexagonal numbers. Complement of A186315.
; 2,4,6,9,11,14,16,18,21,23,26,28,31,33,35,38,40,43,45,47,50,52,55,57,60,62,64,67,69,72,74,76,79,81,84,86,88,91,93,96,98,101,103,105,108,110,113,115,117,120,122,125,127,130,132,134,137,139,142,144,146,149,151,154,156,158,161,163,166,168,171,173,175,178,180,183,185,187,190,192,195,197,200,202,204,207,209,212,214,216,219,221,224,226,228,231,233,236,238,241
add $0,5
mul $0,70
div $0,29
mov $1,$0
sub $1,10
|
src/framework/aunit-suite_builders_generic.adb | persan/AUnit-addons | 0 | 19901 | with Ada.Strings.Fixed;
with AUnit.Test_Caller;
package body AUnit.Suite_Builders_Generic is
package Caller is new AUnit.Test_Caller (Fixture);
Package_Name : constant String := GNAT.Source_Info.Enclosing_Entity;
Separator : constant String := " : ";
--
-- The separator for suite and test names.
---------------------------
-- Compute_Suite_Prefix --
---------------------------
procedure Compute_Suite_Prefix
(This : in out Builder'Class)
is
Prefix : String := Package_Name;
Last_Dot : Natural := 0;
Test_Suffix : constant String := ".Tests";
Suffix_Index : Natural := 0;
begin
-- Trim off the name of this package.
--
Last_Dot := Ada.Strings.Fixed.Index
(Source => Prefix,
Pattern => ".",
Going => Ada.Strings.Backward);
if Last_Dot > 0 then
Ada.Strings.Fixed.Delete
(Source => Prefix,
From => Last_Dot,
Through => Prefix'Last);
end if;
-- Strip off a useless ".Test" suffix.
--
-- Note: Assumes the suffix doesn't also occur in the middle of the name.
--
Suffix_Index := Ada.Strings.Fixed.Index
(Source => Prefix,
Pattern => Test_Suffix,
Going => Ada.Strings.Backward);
if Suffix_Index > 0 then
Ada.Strings.Fixed.Delete
(Source => Prefix,
From => Suffix_Index,
Through => Prefix'Last);
end if;
This.M_Prefix := Ada.Strings.Unbounded.To_Unbounded_String
(Ada.Strings.Fixed.Trim (Prefix, Ada.Strings.Both) & Separator);
end Compute_Suite_Prefix;
function To_Suite
(This : in Builder)
return not null AUnit.Test_Suites.Access_Test_Suite
is
begin
return This.M_Suite;
end To_Suite;
procedure Set_Suite_Name
(This : in out Builder;
Name : in String)
is
begin
This.M_Prefix := Ada.Strings.Unbounded.To_Unbounded_String (Name & Separator);
end Set_Suite_Name;
----------------------------------------------------------------------------
procedure Add
(This : in out Builder;
Name : in String;
Test : access procedure (T : in out Fixture))
is
begin
This.M_Suite.Add_Test
(Caller.Create (Ada.Strings.Unbounded.To_String (This.M_Prefix) & Name, Test));
end Add;
----------------------------------------------------------------------------
procedure Add
(This : in out Builder;
Test : not null access AUnit.Test_Cases.Test_Case'Class)
is
begin
This.M_Suite.Add_Test (Test);
end Add;
----------------------------------------------------------------------------
procedure Add
(This : in out Builder;
Suite : not null access AUnit.Test_Suites.Test_Suite'Class)
is
begin
This.M_Suite.Add_Test (Suite);
end Add;
overriding
procedure Initialize
(This : in out Builder)
is
begin
This.M_Suite := AUnit.Test_Suites.New_Suite;
This.Compute_Suite_Prefix;
end Initialize;
end AUnit.Suite_Builders_Generic;
|
proglangs-learning/Agda/sv20/assign2/SetTheory/Subset.agda | helq/old_code | 0 | 13160 | <filename>proglangs-learning/Agda/sv20/assign2/SetTheory/Subset.agda
-- Properties involving susbets and membership
-- between sets.
module sv20.assign2.SetTheory.Subset where
open import sv20.assign2.SetTheory.Logic
open import sv20.assign2.SetTheory.ZAxioms
memberEq : (x y z : 𝓢) → x ∈ y ∧ y ≡ z → x ∈ z
memberEq x y z (x₁ , x₂) = subs _ x₂ x₁
-- Theorem 1, p. 21 (Suppes 1960)
notInEmpty : ∀ x → x ∉ ∅
notInEmpty x h = (proj₂ _ empt) x h
prop-∅ : (x A : 𝓢) → x ∈ A → A ≢ ∅
prop-∅ x A x∈A h = notInEmpty x (subs _ h x∈A)
prop₂-∅ : (x : 𝓢) → ∃ (λ y → y ∈ x) → x ≢ ∅
prop₂-∅ x h₁ h₂ = cont _ (h₂ , prop-∅ _ _ aux-p)
where
aux : 𝓢
aux = proj₁ h₁
aux-p : aux ∈ x
aux-p = proj₂ _ h₁
-- Theorem 3, p. 22 (Suppes 1960)
subsetOfItself : ∀ {x} → x ⊆ x
subsetOfItself _ t∈x = t∈x
-- Theorem 4, p. 22 (Suppes 1960)
equalitySubset : (x y : 𝓢) → x ⊆ y ∧ y ⊆ x → x ≡ y
equalitySubset x y (x⊆y , y⊆x) = ext x y ((x⊆y x) , (y⊆x x))
-- Theorem 6, p. 23 (Suppes 1960)
trans-⊆ : (x y z : 𝓢) → x ⊆ y ∧ y ⊆ z → x ⊆ z
trans-⊆ x y z (x⊆y , y⊆z) t t∈x = y⊆z t (x⊆y t t∈x)
-- Theorem 7, p. 23 (Suppes 1960)
notContainedInItself : ∀ {x} → ¬ (x ⊂ x)
notContainedInItself (_ , x≢x) = x≢x refl
-- Theorem 8, p. 23 (Suppes 1960)
nonSymmetry-⊂ : (x y : 𝓢) (p : x ⊂ y) → ¬ (y ⊂ x)
nonSymmetry-⊂ x y (x⊆y , x≢y) (y⊆x , _) = x≢y (equalitySubset x y (x⊆y , y⊆x))
-- Theorem 10, p. 23 (Suppes 1960)
⊂→⊆ : ∀ {x y} → x ⊂ y → x ⊆ y
⊂→⊆ (x⊆y , _) z z∈x = x⊆y z z∈x
prop-⊆ : (x A B : 𝓢) → x ∈ A → A ⊆ B → x ∈ B
prop-⊆ x A B x₁ x₂ = i x₁
where
i : x ∈ A → x ∈ B
i = x₂ _
-- References
--
-- Suppes, Patrick (1960). Axiomatic Set Theory.
-- The University Series in Undergraduate Mathematics.
-- <NAME> Company, inc.
--
-- Enderton, <NAME>. (1977). Elements of Set Theory.
-- Academic Press Inc.
|
bin/JWASM/Samples/Win32_6w.asm | Abd-Beltaji/ASMEMU | 3 | 173321 | <gh_stars>1-10
;--- sample how to use Unicode in assembly
;--- similar to Win32_6.asm, but uses the WinInc include files
;--- assemble the ANSI version: jwasm -coff Win32_6w.ASM
;--- assemble the UNICODE version: jwasm -coff -DUNICODE Win32_6w.ASM
;--- link:
;--- MS Link: link /subsystem:console Win32_6w.OBJ kernel32.lib
;--- JWLink: jwlink format win pe file Win32_6w.OBJ lib kernel32.lib
.386
.MODEL FLAT, stdcall
option casemap:none
pushcontext listing ;suppress listing of includes
.nolist
.nocref
WIN32_LEAN_AND_MEAN equ 1 ;this is to reduce assembly time
include \wininc\include\windows.inc
include \wininc\include\tchar.inc
popcontext listing
.CONST
string TCHAR _T(13,10,"Hello, world.",13,10)
.CODE
main proc
local dwWritten:dword
local hConsole:dword
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov hConsole,eax
invoke WriteConsole, hConsole, addr string, lengthof string, addr dwWritten, 0
xor eax,eax
ret
main endp
;--- entry
mainCRTStartup proc c
invoke main
invoke ExitProcess, eax
mainCRTStartup endp
END mainCRTStartup
|
test/Fail/Issue676.agda | cruhland/agda | 1,989 | 232 |
module Issue676 where
data Bool : Set where
true false : Bool
data ⊥ : Set where
data Silly A : Set where
[_] : A → Silly A
fail : ⊥ → Silly A
-- This shouldn't be projection-like since the second clause won't reduce.
unsillify : ∀ {A} → Silly A → A
unsillify [ x ] = x
unsillify (fail ())
data _≡_ {A : Set}(x : A) : A → Set where
refl : x ≡ x
-- Triggers an __IMPOSSIBLE__ if unsillify is projection like.
bad : (x : ⊥) → unsillify (fail x) ≡ true
bad x = refl
|
antlr-plugin/src/test/resources/org/nemesis/antlrformatting/grammarfile/golden/TestFive-0-golden.g4 | timboudreau/ANTLR4-Plugins-for-NetBeans | 1 | 3574 | parser grammar TestFive;
options { tokenVocab=TestFour; }
word : Word; |
programs/oeis/326/A326186.asm | jmorken/loda | 1 | 88372 | ; A326186: a(n) = n - A057521(n), where A057521 gives the powerful part of n.
; 0,1,2,0,4,5,6,0,0,9,10,8,12,13,14,0,16,9,18,16,20,21,22,16,0,25,0,24,28,29,30,0,32,33,34,0,36,37,38,32,40,41,42,40,36,45,46,32,0,25,50,48,52,27,54,48,56,57,58,56,60,61,54,0,64,65,66,64,68,69,70,0,72,73,50,72,76,77,78,64,0,81,82,80,84,85,86,80,88,81,90,88,92,93,94,64,96,49,90,0,100,101,102,96,104,105,106,0,108,109,110,96,112,113,114,112,108,117,118,112,0,121,122,120,0,117,126,0,128,129,130,128,132,133,108,128,136,137,138,136,140,141,142,0,144,145,98,144,148,125,150,144,144,153,154,152,156,157,158,128,160,81,162,160,164,165,166,160,0,169,162,168,172,173,150,160,176,177,178,144,180,181,182,176,184,185,186,184,162,189,190,128,192,193,194,0,196,189,198,0,200,201,202,200,204,205,198,192,208,209,210,208,212,213,214,0,216,217,218,216,220,221,222,192,0,225,226,224,228,229,230,224,232,225,234,232,236,237,238,224,240,121,0,240,196,245,246,240,248,125
mov $2,$0
cal $0,57521 ; Powerful (1) part of n: if n = Product_i (pi^ei) then a(n) = Product_{i : ei > 1} (pi^ei); if n=b*c^2*d^3 then a(n)=c^2*d^3 when b is minimized.
sub $0,1
add $2,15
sub $0,$2
mov $1,2
sub $1,$0
mul $1,17
sub $1,289
div $1,17
|
programs/oeis/291/A291011.asm | jmorken/loda | 1 | 99727 | ; A291011: p-INVERT of (1,1,1,1,1,...), where p(S) = (1 - S)^2 (1 - 2 S).
; 4,15,52,172,552,1736,5384,16536,50440,153112,463176,1397720,4210568,12668568,38083528,114414424,343587336,1031482904,3095956040,9291013848,27879595144,83652416920,250985562312,753015407192,2259167856392,6777755227416,20333785775944,61002431069656,183009507801480,549033086807192,1647108655662536,4941345294340440
mov $1,$0
add $1,8
mov $2,8
lpb $0
sub $0,1
mul $1,2
mul $2,3
lpe
sub $2,$1
add $2,1
mul $2,2
add $0,$2
add $0,$1
mov $1,$0
sub $1,10
div $1,2
add $1,4
|
Task/Self-referential-sequence/Ada/self-referential-sequence.ada | LaudateCorpus1/RosettaCodeData | 1 | 10413 | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Containers.Vectors;
procedure SelfRef is
subtype Seed is Natural range 0 .. 1_000_000;
subtype Num is Natural range 0 .. 10;
type NumList is array (0 .. 10) of Num;
package IO is new Ada.Text_IO.Integer_IO (Natural);
package DVect is new Ada.Containers.Vectors (Positive, NumList);
function Init (innum : Seed) return NumList is
list : NumList := (others => 0);
number : Seed := innum; d : Num;
begin
loop
d := Num (number mod 10);
list (d) := list (d) + 1;
number := number / 10; exit when number = 0;
end loop; return list;
end Init;
procedure Next (inoutlist : in out NumList) is
list : NumList := (others => 0);
begin
for i in list'Range loop
if inoutlist (i) /= 0 then
list (i) := list (i) + 1;
list (inoutlist (i)) := list (inoutlist (i)) + 1;
end if;
end loop; inoutlist := list;
end Next;
procedure Show (list : NumList) is begin
for i in reverse list'Range loop
if list (i) > 0 then
IO.Put (list (i), Width => 1); IO.Put (i, Width => 1);
end if;
end loop; New_Line;
end Show;
function Iterate (theseed : Seed; p : Boolean) return Natural is
list : NumList := Init (theseed);
vect : DVect.Vector;
begin
vect.Append (list);
loop
if p then Show (list); end if;
Next (list); exit when vect.Contains (list); vect.Append (list);
end loop;
return Integer (DVect.Length (vect)) + 1;
end Iterate;
mseed : Seed;
len, maxlen : Natural := 0;
begin
for i in Seed'Range loop
len := Iterate (i, False);
if len > maxlen then mseed := i; maxlen := len; end if;
end loop;
IO.Put (maxlen, Width => 1); Put_Line (" Iterations:");
IO.Put (mseed, Width => 1); New_Line;
len := Iterate (mseed, True);
end SelfRef;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.