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
|
---|---|---|---|---|
src/bak/font.asm
|
vbguyny/c64kernel
| 2 |
168426
|
<reponame>vbguyny/c64kernel<gh_stars>1-10
byte $38,$44,$5c,$54,$5c,$40,$38,$00 ; character 0
byte $00,$00,$38,$04,$3c,$44,$3c,$00 ; character 1
byte $00,$40,$40,$78,$44,$44,$78,$00 ; character 2
byte $00,$00,$3c,$40,$40,$40,$3c,$00 ; character 3
byte $00,$04,$04,$3c,$44,$44,$3c,$00 ; character 4
byte $00,$00,$38,$44,$7c,$40,$38,$00 ; character 5
byte $00,$0c,$10,$3c,$10,$10,$10,$00 ; character 6
byte $00,$00,$3c,$44,$44,$3c,$04,$78 ; character 7
byte $00,$40,$40,$78,$44,$44,$44,$00 ; character 8
byte $00,$10,$00,$30,$10,$10,$38,$00 ; character 9
byte $00,$04,$00,$04,$04,$04,$04,$38 ; character 10
byte $00,$40,$40,$58,$60,$50,$4c,$00 ; character 11
byte $00,$30,$10,$10,$10,$10,$38,$00 ; character 12
byte $00,$00,$68,$54,$54,$54,$54,$00 ; character 13
byte $00,$00,$78,$44,$44,$44,$44,$00 ; character 14
byte $00,$00,$38,$44,$44,$44,$38,$00 ; character 15
byte $00,$00,$78,$44,$44,$78,$40,$40 ; character 16
byte $00,$00,$3c,$44,$44,$3c,$04,$04 ; character 17
byte $00,$00,$78,$44,$40,$40,$40,$00 ; character 18
byte $00,$00,$3c,$40,$38,$04,$78,$00 ; character 19
byte $00,$10,$7c,$10,$10,$10,$0c,$00 ; character 20
byte $00,$00,$44,$44,$44,$44,$3c,$00 ; character 21
byte $00,$00,$44,$44,$44,$28,$10,$00 ; character 22
byte $00,$00,$44,$54,$54,$54,$28,$00 ; character 23
byte $00,$00,$44,$28,$10,$28,$44,$00 ; character 24
byte $00,$00,$44,$44,$44,$3c,$08,$70 ; character 25
byte $00,$00,$7c,$08,$10,$20,$7c,$00 ; character 26
byte $38,$20,$20,$20,$20,$20,$38,$00 ; character 27
byte $08,$14,$10,$38,$10,$24,$78,$00 ; character 28
byte $38,$08,$08,$08,$08,$08,$38,$00 ; character 29
byte $00,$10,$38,$7c,$10,$10,$10,$10 ; character 30
byte $00,$10,$30,$7f,$30,$10,$00,$00 ; character 31
byte $00,$00,$00,$00,$00,$00,$00,$00 ; character 32
byte $10,$10,$10,$10,$00,$00,$10,$00 ; character 33
byte $24,$24,$24,$00,$00,$00,$00,$00 ; character 34
byte $28,$28,$7c,$28,$7c,$28,$28,$00 ; character 35
byte $10,$3c,$40,$38,$04,$78,$10,$00 ; character 36
byte $44,$44,$08,$10,$20,$44,$44,$00 ; character 37
byte $30,$48,$30,$20,$54,$48,$34,$00 ; character 38
byte $04,$08,$10,$00,$00,$00,$00,$00 ; character 39
byte $08,$10,$20,$20,$20,$10,$08,$00 ; character 40
byte $20,$10,$08,$08,$08,$10,$20,$00 ; character 41
byte $00,$44,$28,$7c,$28,$44,$00,$00 ; character 42
byte $00,$10,$10,$7c,$10,$10,$00,$00 ; character 43
byte $00,$00,$00,$00,$00,$10,$10,$20 ; character 44
byte $00,$00,$00,$7c,$00,$00,$00,$00 ; character 45
byte $00,$00,$00,$00,$00,$00,$10,$00 ; character 46
byte $00,$02,$04,$08,$10,$20,$40,$00 ; character 47
byte $38,$44,$4c,$54,$64,$44,$38,$00 ; character 48
byte $10,$30,$10,$10,$10,$10,$38,$00 ; character 49
byte $38,$44,$04,$18,$20,$40,$7c,$00 ; character 50
byte $38,$44,$04,$18,$04,$44,$38,$00 ; character 51
byte $08,$18,$28,$48,$7c,$08,$08,$00 ; character 52
byte $7c,$40,$78,$04,$04,$44,$38,$00 ; character 53
byte $38,$44,$40,$78,$44,$44,$38,$00 ; character 54
byte $7c,$44,$08,$10,$10,$10,$10,$00 ; character 55
byte $38,$44,$44,$38,$44,$44,$38,$00 ; character 56
byte $38,$44,$44,$3c,$04,$44,$38,$00 ; character 57
byte $00,$00,$10,$00,$00,$10,$00,$00 ; character 58
byte $00,$00,$10,$00,$00,$10,$10,$20 ; character 59
byte $0c,$10,$20,$40,$20,$10,$0c,$00 ; character 60
byte $00,$00,$7c,$00,$7c,$00,$00,$00 ; character 61
byte $60,$10,$08,$04,$08,$10,$60,$00 ; character 62
byte $38,$44,$04,$08,$10,$00,$10,$00 ; character 63
byte $00,$00,$00,$ff,$ff,$00,$00,$00 ; character 64
byte $10,$28,$44,$7c,$44,$44,$44,$00 ; character 65
byte $78,$44,$44,$78,$44,$44,$78,$00 ; character 66
byte $38,$44,$40,$40,$40,$44,$38,$00 ; character 67
byte $70,$48,$44,$44,$44,$48,$70,$00 ; character 68
byte $7c,$40,$40,$78,$40,$40,$7c,$00 ; character 69
byte $7c,$40,$40,$70,$40,$40,$40,$00 ; character 70
byte $38,$44,$40,$4c,$44,$44,$38,$00 ; character 71
byte $44,$44,$44,$7c,$44,$44,$44,$00 ; character 72
byte $38,$10,$10,$10,$10,$10,$38,$00 ; character 73
byte $1c,$08,$08,$08,$08,$48,$30,$00 ; character 74
byte $44,$48,$50,$60,$50,$48,$44,$00 ; character 75
byte $40,$40,$40,$40,$40,$40,$7c,$00 ; character 76
byte $44,$6c,$54,$44,$44,$44,$44,$00 ; character 77
byte $44,$44,$64,$54,$4c,$44,$44,$00 ; character 78
byte $38,$44,$44,$44,$44,$44,$38,$00 ; character 79
byte $78,$44,$44,$78,$40,$40,$40,$00 ; character 80
byte $38,$44,$44,$44,$44,$38,$0c,$00 ; character 81
byte $78,$44,$44,$78,$50,$48,$44,$00 ; character 82
byte $38,$44,$40,$38,$04,$44,$38,$00 ; character 83
byte $7c,$10,$10,$10,$10,$10,$10,$00 ; character 84
byte $44,$44,$44,$44,$44,$44,$38,$00 ; character 85
byte $44,$44,$44,$44,$44,$28,$10,$00 ; character 86
byte $44,$44,$44,$44,$54,$6c,$44,$00 ; character 87
byte $44,$44,$28,$10,$28,$44,$44,$00 ; character 88
byte $44,$44,$44,$28,$10,$10,$10,$00 ; character 89
byte $7c,$04,$08,$10,$20,$40,$7c,$00 ; character 90
byte $18,$18,$18,$ff,$ff,$18,$18,$18 ; character 91
byte $c0,$c0,$30,$30,$c0,$c0,$30,$30 ; character 92
byte $18,$18,$18,$18,$18,$18,$18,$18 ; character 93
byte $33,$33,$cc,$cc,$33,$33,$cc,$cc ; character 94
byte $33,$99,$cc,$66,$33,$99,$cc,$66 ; character 95
byte $00,$00,$00,$00,$00,$00,$00,$00 ; character 96
byte $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 ; character 97
byte $00,$00,$00,$00,$ff,$ff,$ff,$ff ; character 98
byte $ff,$00,$00,$00,$00,$00,$00,$00 ; character 99
byte $00,$00,$00,$00,$00,$00,$00,$ff ; character 100
byte $c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0 ; character 101
byte $cc,$cc,$33,$33,$cc,$cc,$33,$33 ; character 102
byte $03,$03,$03,$03,$03,$03,$03,$03 ; character 103
byte $00,$00,$00,$00,$cc,$cc,$33,$33 ; character 104
byte $cc,$99,$33,$66,$cc,$99,$33,$66 ; character 105
byte $03,$03,$03,$03,$03,$03,$03,$03 ; character 106
byte $18,$18,$18,$1f,$1f,$18,$18,$18 ; character 107
byte $00,$00,$00,$00,$0f,$0f,$0f,$0f ; character 108
byte $18,$18,$18,$1f,$1f,$00,$00,$00 ; character 109
byte $00,$00,$00,$f8,$f8,$18,$18,$18 ; character 110
byte $00,$00,$00,$00,$00,$00,$ff,$ff ; character 111
byte $00,$00,$00,$1f,$1f,$18,$18,$18 ; character 112
byte $18,$18,$18,$ff,$ff,$00,$00,$00 ; character 113
byte $00,$00,$00,$ff,$ff,$18,$18,$18 ; character 114
byte $18,$18,$18,$f8,$f8,$18,$18,$18 ; character 115
byte $c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0 ; character 116
byte $e0,$e0,$e0,$e0,$e0,$e0,$e0,$e0 ; character 117
byte $07,$07,$07,$07,$07,$07,$07,$07 ; character 118
byte $ff,$ff,$00,$00,$00,$00,$00,$00 ; character 119
byte $ff,$ff,$ff,$00,$00,$00,$00,$00 ; character 120
byte $00,$00,$00,$00,$00,$ff,$ff,$ff ; character 121
byte $00,$02,$04,$48,$50,$60,$40,$00 ; character 122
byte $00,$00,$00,$00,$f0,$f0,$f0,$f0 ; character 123
byte $0f,$0f,$0f,$0f,$00,$00,$00,$00 ; character 124
byte $18,$18,$18,$f8,$f8,$00,$00,$00 ; character 125
byte $f0,$f0,$f0,$f0,$00,$00,$00,$00 ; character 126
byte $f0,$f0,$f0,$f0,$0f,$0f,$0f,$0f ; character 127
byte $c6,$ba,$a2,$aa,$a2,$be,$c6,$fe ; character 128
byte $fe,$fe,$c6,$fa,$c2,$ba,$c2,$fe ; character 129
byte $fe,$be,$be,$86,$ba,$ba,$86,$fe ; character 130
byte $fe,$fe,$c2,$be,$be,$be,$c2,$fe ; character 131
byte $fe,$fa,$fa,$c2,$ba,$ba,$c2,$fe ; character 132
byte $fe,$fe,$c6,$ba,$82,$be,$c6,$fe ; character 133
byte $fe,$f2,$ee,$c2,$ee,$ee,$ee,$fe ; character 134
byte $fe,$fe,$c2,$ba,$ba,$c2,$fa,$86 ; character 135
byte $fe,$be,$be,$86,$ba,$ba,$ba,$fe ; character 136
byte $fe,$ee,$fe,$ce,$ee,$ee,$c6,$fe ; character 137
byte $fe,$fa,$fe,$fa,$fa,$fa,$fa,$c6 ; character 138
byte $fe,$be,$be,$a6,$9e,$ae,$b2,$fe ; character 139
byte $fe,$ce,$ee,$ee,$ee,$ee,$c6,$fe ; character 140
byte $fe,$fe,$96,$aa,$aa,$aa,$aa,$fe ; character 141
byte $fe,$fe,$86,$ba,$ba,$ba,$ba,$fe ; character 142
byte $fe,$fe,$c6,$ba,$ba,$ba,$c6,$fe ; character 143
byte $fe,$fe,$86,$ba,$ba,$86,$be,$be ; character 144
byte $fe,$fe,$c2,$ba,$ba,$c2,$fa,$fa ; character 145
byte $fe,$fe,$86,$ba,$be,$be,$be,$fe ; character 146
byte $fe,$fe,$c2,$be,$c6,$fa,$86,$fe ; character 147
byte $fe,$ee,$82,$ee,$ee,$ee,$f2,$fe ; character 148
byte $fe,$fe,$ba,$ba,$ba,$ba,$c2,$fe ; character 149
byte $fe,$fe,$ba,$ba,$ba,$d6,$ee,$fe ; character 150
byte $fe,$fe,$ba,$aa,$aa,$aa,$d6,$fe ; character 151
byte $fe,$fe,$ba,$d6,$ee,$d6,$ba,$fe ; character 152
byte $fe,$fe,$ba,$ba,$ba,$c2,$f6,$8e ; character 153
byte $fe,$fe,$82,$f6,$ee,$de,$82,$fe ; character 154
byte $c6,$de,$de,$de,$de,$de,$c6,$fe ; character 155
byte $f6,$ea,$ee,$c6,$ee,$da,$86,$fe ; character 156
byte $c6,$f6,$f6,$f6,$f6,$f6,$c6,$fe ; character 157
byte $fe,$ee,$c6,$82,$ee,$ee,$ee,$ee ; character 158
byte $fe,$ee,$ce,$80,$ce,$ee,$fe,$fe ; character 159
byte $fe,$fe,$fe,$fe,$fe,$fe,$fe,$fe ; character 160
byte $ee,$ee,$ee,$ee,$fe,$fe,$ee,$fe ; character 161
byte $da,$da,$da,$fe,$fe,$fe,$fe,$fe ; character 162
byte $d6,$d6,$82,$d6,$82,$d6,$d6,$fe ; character 163
byte $ee,$c2,$be,$c6,$fa,$86,$ee,$fe ; character 164
byte $ba,$ba,$f6,$ee,$de,$ba,$ba,$fe ; character 165
byte $ce,$b6,$ce,$de,$aa,$b6,$ca,$fe ; character 166
byte $fa,$f6,$ee,$fe,$fe,$fe,$fe,$fe ; character 167
byte $f6,$ee,$de,$de,$de,$ee,$f6,$fe ; character 168
byte $de,$ee,$f6,$f6,$f6,$ee,$de,$fe ; character 169
byte $fe,$ba,$d6,$82,$d6,$ba,$fe,$fe ; character 170
byte $fe,$ee,$ee,$82,$ee,$ee,$fe,$fe ; character 171
byte $fe,$fe,$fe,$fe,$fe,$ee,$ee,$de ; character 172
byte $fe,$fe,$fe,$82,$fe,$fe,$fe,$fe ; character 173
byte $fe,$fe,$fe,$fe,$fe,$e6,$e6,$fe ; character 174
byte $fe,$fc,$fa,$f6,$ee,$de,$be,$fe ; character 175
byte $c6,$ba,$b2,$aa,$9a,$ba,$c6,$fe ; character 176
byte $ee,$ce,$ee,$ee,$ee,$ee,$c6,$fe ; character 177
byte $c6,$ba,$fa,$e6,$de,$be,$82,$fe ; character 178
byte $c6,$ba,$fa,$e6,$fa,$ba,$c6,$fe ; character 179
byte $f6,$e6,$d6,$b6,$82,$f6,$f6,$fe ; character 180
byte $82,$be,$86,$fa,$fa,$ba,$c6,$fe ; character 181
byte $c6,$ba,$be,$86,$ba,$ba,$c6,$fe ; character 182
byte $82,$ba,$f6,$ee,$ee,$ee,$ee,$fe ; character 183
byte $c6,$ba,$ba,$c6,$ba,$ba,$c6,$fe ; character 184
byte $c6,$ba,$ba,$c2,$fa,$ba,$c6,$fe ; character 185
byte $fe,$fe,$ee,$fe,$fe,$ee,$fe,$fe ; character 186
byte $fe,$fe,$ee,$fe,$fe,$ee,$ee,$de ; character 187
byte $f2,$ee,$de,$be,$de,$ee,$f2,$fe ; character 188
byte $fe,$fe,$82,$fe,$82,$fe,$fe,$fe ; character 189
byte $9e,$ee,$f6,$fa,$f6,$ee,$9e,$fe ; character 190
byte $c6,$ba,$fa,$f6,$ee,$fe,$ee,$fe ; character 191
byte $fe,$fe,$fe,$00,$00,$fe,$fe,$fe ; character 192
byte $ee,$d6,$ba,$82,$ba,$ba,$ba,$fe ; character 193
byte $86,$ba,$ba,$86,$ba,$ba,$86,$fe ; character 194
byte $c6,$ba,$be,$be,$be,$ba,$c6,$fe ; character 195
byte $8e,$b6,$ba,$ba,$ba,$b6,$8e,$fe ; character 196
byte $82,$be,$be,$86,$be,$be,$82,$fe ; character 197
byte $82,$be,$be,$8e,$be,$be,$be,$fe ; character 198
byte $c6,$ba,$be,$b2,$ba,$ba,$c6,$fe ; character 199
byte $ba,$ba,$ba,$82,$ba,$ba,$ba,$fe ; character 200
byte $c6,$ee,$ee,$ee,$ee,$ee,$c6,$fe ; character 201
byte $e2,$f6,$f6,$f6,$f6,$b6,$ce,$fe ; character 202
byte $ba,$b6,$ae,$9e,$ae,$b6,$ba,$fe ; character 203
byte $be,$be,$be,$be,$be,$be,$82,$fe ; character 204
byte $ba,$92,$aa,$ba,$ba,$ba,$ba,$fe ; character 205
byte $ba,$ba,$9a,$aa,$b2,$ba,$ba,$fe ; character 206
byte $c6,$ba,$ba,$ba,$ba,$ba,$c6,$fe ; character 207
byte $86,$ba,$ba,$86,$be,$be,$be,$fe ; character 208
byte $c6,$ba,$ba,$ba,$ba,$c6,$f2,$fe ; character 209
byte $86,$ba,$ba,$86,$ae,$b6,$ba,$fe ; character 210
byte $c6,$ba,$be,$c6,$fa,$ba,$c6,$fe ; character 211
byte $82,$ee,$ee,$ee,$ee,$ee,$ee,$fe ; character 212
byte $ba,$ba,$ba,$ba,$ba,$ba,$c6,$fe ; character 213
byte $ba,$ba,$ba,$ba,$ba,$d6,$ee,$fe ; character 214
byte $ba,$ba,$ba,$ba,$aa,$92,$ba,$fe ; character 215
byte $ba,$ba,$d6,$ee,$d6,$ba,$ba,$fe ; character 216
byte $ba,$ba,$ba,$d6,$ee,$ee,$ee,$fe ; character 217
byte $82,$fa,$f6,$ee,$de,$be,$82,$fe ; character 218
byte $e6,$e6,$e6,$00,$00,$e6,$e6,$e6 ; character 219
byte $3e,$3e,$ce,$ce,$3e,$3e,$ce,$ce ; character 220
byte $e6,$e6,$e6,$e6,$e6,$e6,$e6,$e6 ; character 221
byte $cc,$cc,$32,$32,$cc,$cc,$32,$32 ; character 222
byte $cc,$66,$32,$98,$cc,$66,$32,$98 ; character 223
byte $fe,$fe,$fe,$fe,$fe,$fe,$fe,$fe ; character 224
byte $0e,$0e,$0e,$0e,$0e,$0e,$0e,$0e ; character 225
byte $fe,$fe,$fe,$fe,$00,$00,$00,$00 ; character 226
byte $00,$fe,$fe,$fe,$fe,$fe,$fe,$fe ; character 227
byte $fe,$fe,$fe,$fe,$fe,$fe,$fe,$00 ; character 228
byte $3e,$3e,$3e,$3e,$3e,$3e,$3e,$3e ; character 229
byte $32,$32,$cc,$cc,$32,$32,$cc,$cc ; character 230
byte $fc,$fc,$fc,$fc,$fc,$fc,$fc,$fc ; character 231
byte $fe,$fe,$fe,$fe,$32,$32,$cc,$cc ; character 232
byte $fe,$66,$cc,$98,$32,$66,$cc,$98 ; character 233
byte $fe,$fc,$fc,$fc,$fc,$fc,$fc,$fc ; character 234
byte $e6,$e6,$e6,$e0,$e0,$e6,$e6,$e6 ; character 235
byte $fe,$fe,$fe,$fe,$f0,$f0,$f0,$f0 ; character 236
byte $e6,$e6,$e6,$e0,$e0,$fe,$fe,$fe ; character 237
byte $fe,$fe,$fe,$06,$06,$e6,$e6,$e6 ; character 238
byte $fe,$fe,$fe,$fe,$fe,$fe,$00,$00 ; character 239
byte $fe,$fe,$fe,$e0,$e0,$e6,$e6,$e6 ; character 240
byte $e6,$e6,$e6,$00,$00,$fe,$fe,$fe ; character 241
byte $fe,$fe,$fe,$00,$00,$e6,$e6,$e6 ; character 242
byte $e6,$e6,$e6,$06,$06,$e6,$e6,$e6 ; character 243
byte $3e,$3e,$3e,$3e,$3e,$3e,$3e,$3e ; character 244
byte $1e,$1e,$1e,$1e,$1e,$1e,$1e,$1e ; character 245
byte $f8,$f8,$f8,$f8,$f8,$f8,$f8,$f8 ; character 246
byte $00,$00,$fe,$fe,$fe,$fe,$fe,$fe ; character 247
byte $00,$00,$00,$fe,$fe,$fe,$fe,$fe ; character 248
byte $fe,$fe,$fe,$fe,$fe,$00,$00,$00 ; character 249
byte $fe,$fc,$f8,$92,$86,$8e,$9e,$fe ; character 250
byte $fe,$fe,$fe,$fe,$0e,$0e,$0e,$0e ; character 251
byte $f0,$f0,$f0,$f0,$fe,$fe,$fe,$fe ; character 252
byte $e6,$e6,$e6,$06,$06,$fe,$fe,$fe ; character 253
byte $0e,$0e,$0e,$0e,$fe,$fe,$fe,$fe ; character 254
byte $0e,$0e,$0e,$0e,$f0,$f0,$f0,$f0 ; character 255
|
Transynther/x86/_processed/NC/_zr_/i7-7700_9_0x48_notsx.log_21829_157.asm
|
ljhsiun2/medusa
| 9 |
18368
|
<filename>Transynther/x86/_processed/NC/_zr_/i7-7700_9_0x48_notsx.log_21829_157.asm<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r15
push %r8
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x17cc2, %rcx
nop
nop
nop
nop
cmp %r15, %r15
vmovups (%rcx), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $1, %xmm6, %rbx
nop
nop
nop
nop
nop
and %r15, %r15
lea addresses_normal_ht+0x4102, %rbx
nop
cmp $35879, %r8
and $0xffffffffffffffc0, %rbx
vmovaps (%rbx), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $1, %xmm1, %rax
nop
xor $41217, %rbx
lea addresses_WT_ht+0x1cea8, %r12
nop
nop
cmp %r9, %r9
mov (%r12), %ecx
nop
nop
nop
nop
nop
and %rax, %rax
lea addresses_normal_ht+0x193c2, %rsi
lea addresses_A_ht+0x9f02, %rdi
clflush (%rsi)
nop
nop
nop
nop
and %r15, %r15
mov $107, %rcx
rep movsl
nop
nop
xor %rcx, %rcx
lea addresses_UC_ht+0x4c2, %rsi
lea addresses_normal_ht+0x3a9a, %rdi
nop
nop
nop
nop
add %r15, %r15
mov $53, %rcx
rep movsw
nop
nop
nop
nop
add %rax, %rax
lea addresses_normal_ht+0xacc2, %rcx
nop
nop
nop
nop
inc %rdi
movw $0x6162, (%rcx)
nop
nop
nop
nop
nop
cmp $40627, %rsi
lea addresses_normal_ht+0x1cac2, %r12
nop
nop
nop
nop
cmp %r9, %r9
movups (%r12), %xmm5
vpextrq $0, %xmm5, %rdi
nop
nop
nop
dec %rsi
lea addresses_UC_ht+0x1a5d6, %rbx
nop
inc %r15
mov $0x6162636465666768, %r12
movq %r12, %xmm5
movups %xmm5, (%rbx)
nop
nop
nop
nop
cmp $26545, %rcx
lea addresses_D_ht+0x28c2, %r12
nop
nop
nop
dec %r8
mov $0x6162636465666768, %rcx
movq %rcx, %xmm0
movups %xmm0, (%r12)
nop
nop
nop
nop
nop
add %rdi, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r8
pop %r15
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r8
push %r9
push %rbx
push %rdi
push %rdx
// Store
lea addresses_WC+0x722, %r9
sub $6397, %rdi
movb $0x51, (%r9)
// Exception!!!
nop
nop
nop
mov (0), %r9
nop
nop
nop
xor $11556, %r8
// Store
lea addresses_normal+0x1f47a, %rdi
nop
sub %rbx, %rbx
movb $0x51, (%rdi)
nop
nop
nop
dec %r12
// Faulty Load
mov $0x46906d0000000cc2, %rbx
nop
nop
nop
add $51634, %r9
mov (%rbx), %r12d
lea oracles, %rbx
and $0xff, %r12
shlq $12, %r12
mov (%rbx,%r12,1), %r12
pop %rdx
pop %rdi
pop %rbx
pop %r9
pop %r8
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_NC', 'congruent': 0}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WC', 'congruent': 3}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal', 'congruent': 2}, 'OP': 'STOR'}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_NC', 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WC_ht', 'congruent': 11}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 32, 'type': 'addresses_normal_ht', 'congruent': 3}}
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WT_ht', 'congruent': 1}}
{'dst': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}}
{'dst': {'same': False, 'congruent': 3, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_UC_ht'}}
{'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_normal_ht', 'congruent': 11}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 7}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_UC_ht', 'congruent': 2}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_D_ht', 'congruent': 10}, 'OP': 'STOR'}
{'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
*/
|
alloy4fun_models/trashltl/models/16/8Ri2MPYmhx9LeGGfb.als
|
Kaixi26/org.alloytools.alloy
| 0 |
1827
|
<reponame>Kaixi26/org.alloytools.alloy
open main
pred id8Ri2MPYmhx9LeGGfb_prop17 {
all f: File | always f in Trash releases f' in File
}
pred __repair { id8Ri2MPYmhx9LeGGfb_prop17 }
check __repair { id8Ri2MPYmhx9LeGGfb_prop17 <=> prop17o }
|
src/sys/streams/util-streams-pipes.ads
|
My-Colaborations/ada-util
| 0 |
1840
|
-----------------------------------------------------------------------
-- util-streams-pipes -- Pipe stream to or from a process
-- Copyright (C) 2011, 2013, 2015, 2016, 2017, 2018, 2019 <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.
-----------------------------------------------------------------------
with Ada.Finalization;
with Util.Processes;
-- == Pipes ==
-- The `Util.Streams.Pipes` package defines a pipe stream to or from a process.
-- It allows to launch an external program while getting the program standard output or
-- providing the program standard input. The `Pipe_Stream` type represents the input or
-- output stream for the external program. This is a portable interface that works on
-- Unix and Windows.
--
-- The process is created and launched by the `Open` operation. The pipe allows
-- to read or write to the process through the `Read` and `Write` operation.
-- It is very close to the *popen* operation provided by the C stdio library.
-- First, create the pipe instance:
--
-- with Util.Streams.Pipes;
-- ...
-- Pipe : aliased Util.Streams.Pipes.Pipe_Stream;
--
-- The pipe instance can be associated with only one process at a time.
-- The process is launched by using the `Open` command and by specifying the command
-- to execute as well as the pipe redirection mode:
--
-- * `READ` to read the process standard output,
-- * `WRITE` to write the process standard input.
--
-- For example to run the `ls -l` command and read its output, we could run it by using:
--
-- Pipe.Open (Command => "ls -l", Mode => Util.Processes.READ);
--
-- The `Pipe_Stream` is not buffered and a buffer can be configured easily by using the
-- `Input_Buffer_Stream` type and connecting the buffer to the pipe so that it reads
-- the pipe to fill the buffer. The initialization of the buffer is the following:
--
-- with Util.Streams.Buffered;
-- ...
-- Buffer : Util.Streams.Buffered.Input_Buffer_Stream;
-- ...
-- Buffer.Initialize (Input => Pipe'Access, Size => 1024);
--
-- And to read the process output, one can use the following:
--
-- Content : Ada.Strings.Unbounded.Unbounded_String;
-- ...
-- Buffer.Read (Into => Content);
--
-- The pipe object should be closed when reading or writing to it is finished.
-- By closing the pipe, the caller will wait for the termination of the process.
-- The process exit status can be obtained by using the `Get_Exit_Status` function.
--
-- Pipe.Close;
-- if Pipe.Get_Exit_Status /= 0 then
-- Ada.Text_IO.Put_Line ("Command exited with status "
-- & Integer'Image (Pipe.Get_Exit_Status));
-- end if;
--
-- You will note that the `Pipe_Stream` is a limited type and thus cannot be copied.
-- When leaving the scope of the `Pipe_Stream` instance, the application will wait for
-- the process to terminate.
--
-- Before opening the pipe, it is possible to have some control on the process that
-- will be created to configure:
--
-- * The shell that will be used to launch the process,
-- * The process working directory,
-- * Redirect the process output to a file,
-- * Redirect the process error to a file,
-- * Redirect the process input from a file.
--
-- All these operations must be made before calling the `Open` procedure.
package Util.Streams.Pipes is
use Util.Processes;
subtype Pipe_Mode is Util.Processes.Pipe_Mode range READ .. READ_WRITE;
-- -----------------------
-- Pipe stream
-- -----------------------
-- The <b>Pipe_Stream</b> is an output/input stream that reads or writes
-- to or from a process.
type Pipe_Stream is limited new Output_Stream and Input_Stream with private;
-- Set the shell executable path to use to launch a command. The default on Unix is
-- the /bin/sh command. Argument splitting is done by the /bin/sh -c command.
-- When setting an empty shell command, the argument splitting is done by the
-- <tt>Spawn</tt> procedure.
procedure Set_Shell (Stream : in out Pipe_Stream;
Shell : in String);
-- Before launching the process, redirect the input stream of the process
-- to the specified file.
-- Raises <b>Invalid_State</b> if the process is running.
procedure Set_Input_Stream (Stream : in out Pipe_Stream;
File : in String);
-- Set the output stream of the process.
-- Raises <b>Invalid_State</b> if the process is running.
procedure Set_Output_Stream (Stream : in out Pipe_Stream;
File : in String;
Append : in Boolean := False);
-- Set the error stream of the process.
-- Raises <b>Invalid_State</b> if the process is running.
procedure Set_Error_Stream (Stream : in out Pipe_Stream;
File : in String;
Append : in Boolean := False);
-- Set the working directory that the process will use once it is created.
-- The directory must exist or the <b>Invalid_Directory</b> exception will be raised.
procedure Set_Working_Directory (Stream : in out Pipe_Stream;
Path : in String);
-- Closes the given file descriptor in the child process before executing the command.
procedure Add_Close (Stream : in out Pipe_Stream;
Fd : in Util.Processes.File_Type);
-- Open a pipe to read or write to an external process. The pipe is created and the
-- command is executed with the input and output streams redirected through the pipe.
procedure Open (Stream : in out Pipe_Stream;
Command : in String;
Mode : in Pipe_Mode := READ);
-- Close the pipe and wait for the external process to terminate.
overriding
procedure Close (Stream : in out Pipe_Stream);
-- Get the process exit status.
function Get_Exit_Status (Stream : in Pipe_Stream) return Integer;
-- Returns True if the process is running.
function Is_Running (Stream : in Pipe_Stream) return Boolean;
-- Write the buffer array to the output stream.
overriding
procedure Write (Stream : in out Pipe_Stream;
Buffer : in Ada.Streams.Stream_Element_Array);
-- Read into the buffer as many bytes as possible and return in
-- <b>last</b> the position of the last byte read.
overriding
procedure Read (Stream : in out Pipe_Stream;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
private
type Pipe_Stream is limited new Ada.Finalization.Limited_Controlled
and Output_Stream and Input_Stream with record
Proc : Util.Processes.Process;
end record;
-- Flush the stream and release the buffer.
overriding
procedure Finalize (Object : in out Pipe_Stream);
end Util.Streams.Pipes;
|
programs/oeis/152/A152623.asm
|
neoneye/loda
| 22 |
4188
|
; A152623: Decimal expansion of 3/2.
; 1,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
mul $0,4
mov $1,5
bin $1,$0
mov $0,$1
|
src/main/resources/project-templates/aws_web_server_blocks/src/@_project_name_@-web_blocks.ads
|
WinterAlexander/Ada-IntelliJ
| 17 |
29636
|
<gh_stars>10-100
with AWS.Status;
with AWS.Templates;
with AWS.Services.Web_Block.Context;
package @[email protected]_Blocks is
use AWS;
use AWS.Services;
procedure Widget_Counter
(Request : in Status.Data;
Context : not null access Web_Block.Context.Object;
Translations : in out Templates.Translate_Set);
end @[email protected]_Blocks;
|
src/preprocessor/parser/CPreprocessor.g4
|
flosacca/c-compiler
| 0 |
4964
|
grammar CPreprocessor;
macro
: line (NL line)* EOF
;
line
: defineStat // 定义宏
| undefStat // 取消宏
| includeStat // 包含头文件
| ifdefStat // ifdef
| ifndefStat // ifndef
| elseStat // else
| endifStat // endif
| text // 普通文本
| // 空行
;
defineStat
: WS? '#define' WS macroID (WS restOfLine)?
;
undefStat
: WS? '#undef' WS macroID WS?;
includeStat
: WS? '#include' WS '"' WS? filename WS? '"' WS? # includeCur
| WS? '#include' WS '<' WS? filename WS? '>' WS? # includeSys
;
filename: ID '.h'?;
ifdefStat
: WS? '#ifdef' WS macroID WS?;
ifndefStat
: WS? '#ifndef' WS macroID WS?;
elseStat
: WS? '#else' WS?;
endifStat
: WS? '#endif' WS?;
text: .*?;
macroID: (ID | OP)+;
restOfLine: (WS? (ID | OP | DOUBLE_QUOTE)+ WS?)+;
ID: [A-Za-z0-9_]+;
OP: (~('a'..'z' | 'A'..'Z' | '0'..'9' | '\t' | '\r' | '\n' | ' ' | '_' | '"'))+;
DOUBLE_QUOTE: '"';
NL : '\r'? '\n' | '\r';
WS : (' ' | '\t')+; // whitespace
|
data/pokemon/base_stats/zapdos.asm
|
AtmaBuster/pokeplat-gen2
| 6 |
95376
|
<reponame>AtmaBuster/pokeplat-gen2
db 0 ; species ID placeholder
db 90, 90, 85, 100, 125, 90
; hp atk def spd sat sdf
db ELECTRIC, FLYING ; type
db 3 ; catch rate
db 216 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_UNKNOWN ; gender ratio
db 80 ; step cycles to hatch
INCBIN "gfx/pokemon/zapdos/front.dimensions"
db GROWTH_SLOW ; growth rate
dn EGG_NONE, EGG_NONE ; egg groups
db 35 ; happiness
; tm/hm learnset
tmhm ROAR, TOXIC, HIDDEN_POWER, SUNNY_DAY, HYPER_BEAM, LIGHT_SCREEN, PROTECT, RAIN_DANCE, FRUSTRATION, THUNDERBOLT, THUNDER, RETURN, DOUBLE_TEAM, SHOCK_WAVE, SANDSTORM, AERIAL_ACE, FACADE, SECRET_POWER, REST, STEEL_WING, ROOST, CHARGE_BEAM, ENDURE, GIGA_IMPACT, FLASH, THUNDER_WAVE, SLEEP_TALK, NATURAL_GIFT, SWAGGER, PLUCK, U_TURN, SUBSTITUTE, FLY, DEFOG, ROCK_SMASH, AIR_CUTTER, ANCIENTPOWER, HEAT_WAVE, MUD_SLAP, OMINOUS_WIND, SIGNAL_BEAM, SNORE, SWIFT, TWISTER
; end
|
programs/oeis/134/A134499.asm
|
neoneye/loda
| 22 |
89673
|
; A134499: a(n) = Fibonacci(7*n+1).
; 1,21,610,17711,514229,14930352,433494437,12586269025,365435296162,10610209857723,308061521170129,8944394323791464,259695496911122585,7540113804746346429,218922995834555169026,6356306993006846248183
mul $0,7
seq $0,71 ; a(n) = Fibonacci(n) - 1.
add $0,1
|
mips/24-1.asm
|
ping58972/Computer-Organization-Architecture
| 0 |
18397
|
## MIPS Assignment #4
## Ch24-1.asm
## String Length
.data
prompt: .asciiz "\n\n(Exit if input nothing!)\nInput some string for count:"
strL_prompt: .asciiz "The length of the string is:"
str_space: .space 1024
new_line: .asciiz "\n"
.text
.globl main
main:
#Initialize
li $t0, 0
la $s1, str_space
move $t1, $s1
#prompt user to input string
li $v0, 4
la $a0, prompt
syscall
li $v0, 8
li $a1, 24
move $a0, $t1
move $t2, $a0
syscall
#if input nothing => exit
la $a0, new_line
lb $a0, ($a0)
lb $t1, ($t1)
beq $t1, $a0, done
#loop for count string
loop:
lbu $t3, 0($t2)
nop
beq $t3, $0, result
addiu $t0, $t0, 1
addiu $t2, $t2, 1
j loop
#print the result and loop for enter again.
result:
li $v0, 4
la $a0, strL_prompt
syscall
li $v0, 1
#don't count the '\n' in string.
subiu $t0, $t0, 1
move $a0, $t0
syscall
j main
#finish if user enter nothing.
done:
li $v0, 10 # Exit the program.
syscall
|
a51test/(F4)CPL_A.a51
|
Aimini/51cpu
| 0 |
82245
|
<gh_stars>0
MOV A, #0xF1
START:
CPL A
SJMP START
|
cat.asm
|
joeofportland/project4final
| 0 |
241499
|
_cat: file format elf32-i386
Disassembly of section .text:
00000000 <cat>:
char buf[512];
void
cat(int fd)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 28 sub $0x28,%esp
int n;
while((n = read(fd, buf, sizeof(buf))) > 0)
6: eb 1b jmp 23 <cat+0x23>
write(1, buf, n);
8: 8b 45 f4 mov -0xc(%ebp),%eax
b: 89 44 24 08 mov %eax,0x8(%esp)
f: c7 44 24 04 e0 0b 00 movl $0xbe0,0x4(%esp)
16: 00
17: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1e: e8 82 03 00 00 call 3a5 <write>
void
cat(int fd)
{
int n;
while((n = read(fd, buf, sizeof(buf))) > 0)
23: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp)
2a: 00
2b: c7 44 24 04 e0 0b 00 movl $0xbe0,0x4(%esp)
32: 00
33: 8b 45 08 mov 0x8(%ebp),%eax
36: 89 04 24 mov %eax,(%esp)
39: e8 5f 03 00 00 call 39d <read>
3e: 89 45 f4 mov %eax,-0xc(%ebp)
41: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
45: 7f c1 jg 8 <cat+0x8>
write(1, buf, n);
if(n < 0){
47: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
4b: 79 19 jns 66 <cat+0x66>
printf(1, "cat: read error\n");
4d: c7 44 24 04 19 09 00 movl $0x919,0x4(%esp)
54: 00
55: c7 04 24 01 00 00 00 movl $0x1,(%esp)
5c: e8 ec 04 00 00 call 54d <printf>
exit();
61: e8 1f 03 00 00 call 385 <exit>
}
}
66: c9 leave
67: c3 ret
00000068 <main>:
int
main(int argc, char *argv[])
{
68: 55 push %ebp
69: 89 e5 mov %esp,%ebp
6b: 83 e4 f0 and $0xfffffff0,%esp
6e: 83 ec 20 sub $0x20,%esp
int fd, i;
if(argc <= 1){
71: 83 7d 08 01 cmpl $0x1,0x8(%ebp)
75: 7f 11 jg 88 <main+0x20>
cat(0);
77: c7 04 24 00 00 00 00 movl $0x0,(%esp)
7e: e8 7d ff ff ff call 0 <cat>
exit();
83: e8 fd 02 00 00 call 385 <exit>
}
for(i = 1; i < argc; i++){
88: c7 44 24 1c 01 00 00 movl $0x1,0x1c(%esp)
8f: 00
90: eb 79 jmp 10b <main+0xa3>
if((fd = open(argv[i], 0)) < 0){
92: 8b 44 24 1c mov 0x1c(%esp),%eax
96: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
9d: 8b 45 0c mov 0xc(%ebp),%eax
a0: 01 d0 add %edx,%eax
a2: 8b 00 mov (%eax),%eax
a4: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
ab: 00
ac: 89 04 24 mov %eax,(%esp)
af: e8 11 03 00 00 call 3c5 <open>
b4: 89 44 24 18 mov %eax,0x18(%esp)
b8: 83 7c 24 18 00 cmpl $0x0,0x18(%esp)
bd: 79 2f jns ee <main+0x86>
printf(1, "cat: cannot open %s\n", argv[i]);
bf: 8b 44 24 1c mov 0x1c(%esp),%eax
c3: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
ca: 8b 45 0c mov 0xc(%ebp),%eax
cd: 01 d0 add %edx,%eax
cf: 8b 00 mov (%eax),%eax
d1: 89 44 24 08 mov %eax,0x8(%esp)
d5: c7 44 24 04 2a 09 00 movl $0x92a,0x4(%esp)
dc: 00
dd: c7 04 24 01 00 00 00 movl $0x1,(%esp)
e4: e8 64 04 00 00 call 54d <printf>
exit();
e9: e8 97 02 00 00 call 385 <exit>
}
cat(fd);
ee: 8b 44 24 18 mov 0x18(%esp),%eax
f2: 89 04 24 mov %eax,(%esp)
f5: e8 06 ff ff ff call 0 <cat>
close(fd);
fa: 8b 44 24 18 mov 0x18(%esp),%eax
fe: 89 04 24 mov %eax,(%esp)
101: e8 a7 02 00 00 call 3ad <close>
if(argc <= 1){
cat(0);
exit();
}
for(i = 1; i < argc; i++){
106: 83 44 24 1c 01 addl $0x1,0x1c(%esp)
10b: 8b 44 24 1c mov 0x1c(%esp),%eax
10f: 3b 45 08 cmp 0x8(%ebp),%eax
112: 0f 8c 7a ff ff ff jl 92 <main+0x2a>
exit();
}
cat(fd);
close(fd);
}
exit();
118: e8 68 02 00 00 call 385 <exit>
0000011d <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
11d: 55 push %ebp
11e: 89 e5 mov %esp,%ebp
120: 57 push %edi
121: 53 push %ebx
asm volatile("cld; rep stosb" :
122: 8b 4d 08 mov 0x8(%ebp),%ecx
125: 8b 55 10 mov 0x10(%ebp),%edx
128: 8b 45 0c mov 0xc(%ebp),%eax
12b: 89 cb mov %ecx,%ebx
12d: 89 df mov %ebx,%edi
12f: 89 d1 mov %edx,%ecx
131: fc cld
132: f3 aa rep stos %al,%es:(%edi)
134: 89 ca mov %ecx,%edx
136: 89 fb mov %edi,%ebx
138: 89 5d 08 mov %ebx,0x8(%ebp)
13b: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
13e: 5b pop %ebx
13f: 5f pop %edi
140: 5d pop %ebp
141: c3 ret
00000142 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
142: 55 push %ebp
143: 89 e5 mov %esp,%ebp
145: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
148: 8b 45 08 mov 0x8(%ebp),%eax
14b: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
14e: 90 nop
14f: 8b 45 08 mov 0x8(%ebp),%eax
152: 8d 50 01 lea 0x1(%eax),%edx
155: 89 55 08 mov %edx,0x8(%ebp)
158: 8b 55 0c mov 0xc(%ebp),%edx
15b: 8d 4a 01 lea 0x1(%edx),%ecx
15e: 89 4d 0c mov %ecx,0xc(%ebp)
161: 0f b6 12 movzbl (%edx),%edx
164: 88 10 mov %dl,(%eax)
166: 0f b6 00 movzbl (%eax),%eax
169: 84 c0 test %al,%al
16b: 75 e2 jne 14f <strcpy+0xd>
;
return os;
16d: 8b 45 fc mov -0x4(%ebp),%eax
}
170: c9 leave
171: c3 ret
00000172 <strcmp>:
int
strcmp(const char *p, const char *q)
{
172: 55 push %ebp
173: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
175: eb 08 jmp 17f <strcmp+0xd>
p++, q++;
177: 83 45 08 01 addl $0x1,0x8(%ebp)
17b: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
17f: 8b 45 08 mov 0x8(%ebp),%eax
182: 0f b6 00 movzbl (%eax),%eax
185: 84 c0 test %al,%al
187: 74 10 je 199 <strcmp+0x27>
189: 8b 45 08 mov 0x8(%ebp),%eax
18c: 0f b6 10 movzbl (%eax),%edx
18f: 8b 45 0c mov 0xc(%ebp),%eax
192: 0f b6 00 movzbl (%eax),%eax
195: 38 c2 cmp %al,%dl
197: 74 de je 177 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
199: 8b 45 08 mov 0x8(%ebp),%eax
19c: 0f b6 00 movzbl (%eax),%eax
19f: 0f b6 d0 movzbl %al,%edx
1a2: 8b 45 0c mov 0xc(%ebp),%eax
1a5: 0f b6 00 movzbl (%eax),%eax
1a8: 0f b6 c0 movzbl %al,%eax
1ab: 29 c2 sub %eax,%edx
1ad: 89 d0 mov %edx,%eax
}
1af: 5d pop %ebp
1b0: c3 ret
000001b1 <strlen>:
uint
strlen(char *s)
{
1b1: 55 push %ebp
1b2: 89 e5 mov %esp,%ebp
1b4: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
1b7: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
1be: eb 04 jmp 1c4 <strlen+0x13>
1c0: 83 45 fc 01 addl $0x1,-0x4(%ebp)
1c4: 8b 55 fc mov -0x4(%ebp),%edx
1c7: 8b 45 08 mov 0x8(%ebp),%eax
1ca: 01 d0 add %edx,%eax
1cc: 0f b6 00 movzbl (%eax),%eax
1cf: 84 c0 test %al,%al
1d1: 75 ed jne 1c0 <strlen+0xf>
;
return n;
1d3: 8b 45 fc mov -0x4(%ebp),%eax
}
1d6: c9 leave
1d7: c3 ret
000001d8 <memset>:
void*
memset(void *dst, int c, uint n)
{
1d8: 55 push %ebp
1d9: 89 e5 mov %esp,%ebp
1db: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
1de: 8b 45 10 mov 0x10(%ebp),%eax
1e1: 89 44 24 08 mov %eax,0x8(%esp)
1e5: 8b 45 0c mov 0xc(%ebp),%eax
1e8: 89 44 24 04 mov %eax,0x4(%esp)
1ec: 8b 45 08 mov 0x8(%ebp),%eax
1ef: 89 04 24 mov %eax,(%esp)
1f2: e8 26 ff ff ff call 11d <stosb>
return dst;
1f7: 8b 45 08 mov 0x8(%ebp),%eax
}
1fa: c9 leave
1fb: c3 ret
000001fc <strchr>:
char*
strchr(const char *s, char c)
{
1fc: 55 push %ebp
1fd: 89 e5 mov %esp,%ebp
1ff: 83 ec 04 sub $0x4,%esp
202: 8b 45 0c mov 0xc(%ebp),%eax
205: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
208: eb 14 jmp 21e <strchr+0x22>
if(*s == c)
20a: 8b 45 08 mov 0x8(%ebp),%eax
20d: 0f b6 00 movzbl (%eax),%eax
210: 3a 45 fc cmp -0x4(%ebp),%al
213: 75 05 jne 21a <strchr+0x1e>
return (char*)s;
215: 8b 45 08 mov 0x8(%ebp),%eax
218: eb 13 jmp 22d <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
21a: 83 45 08 01 addl $0x1,0x8(%ebp)
21e: 8b 45 08 mov 0x8(%ebp),%eax
221: 0f b6 00 movzbl (%eax),%eax
224: 84 c0 test %al,%al
226: 75 e2 jne 20a <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
228: b8 00 00 00 00 mov $0x0,%eax
}
22d: c9 leave
22e: c3 ret
0000022f <gets>:
char*
gets(char *buf, int max)
{
22f: 55 push %ebp
230: 89 e5 mov %esp,%ebp
232: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
235: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
23c: eb 4c jmp 28a <gets+0x5b>
cc = read(0, &c, 1);
23e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
245: 00
246: 8d 45 ef lea -0x11(%ebp),%eax
249: 89 44 24 04 mov %eax,0x4(%esp)
24d: c7 04 24 00 00 00 00 movl $0x0,(%esp)
254: e8 44 01 00 00 call 39d <read>
259: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
25c: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
260: 7f 02 jg 264 <gets+0x35>
break;
262: eb 31 jmp 295 <gets+0x66>
buf[i++] = c;
264: 8b 45 f4 mov -0xc(%ebp),%eax
267: 8d 50 01 lea 0x1(%eax),%edx
26a: 89 55 f4 mov %edx,-0xc(%ebp)
26d: 89 c2 mov %eax,%edx
26f: 8b 45 08 mov 0x8(%ebp),%eax
272: 01 c2 add %eax,%edx
274: 0f b6 45 ef movzbl -0x11(%ebp),%eax
278: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
27a: 0f b6 45 ef movzbl -0x11(%ebp),%eax
27e: 3c 0a cmp $0xa,%al
280: 74 13 je 295 <gets+0x66>
282: 0f b6 45 ef movzbl -0x11(%ebp),%eax
286: 3c 0d cmp $0xd,%al
288: 74 0b je 295 <gets+0x66>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
28a: 8b 45 f4 mov -0xc(%ebp),%eax
28d: 83 c0 01 add $0x1,%eax
290: 3b 45 0c cmp 0xc(%ebp),%eax
293: 7c a9 jl 23e <gets+0xf>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
295: 8b 55 f4 mov -0xc(%ebp),%edx
298: 8b 45 08 mov 0x8(%ebp),%eax
29b: 01 d0 add %edx,%eax
29d: c6 00 00 movb $0x0,(%eax)
return buf;
2a0: 8b 45 08 mov 0x8(%ebp),%eax
}
2a3: c9 leave
2a4: c3 ret
000002a5 <stat>:
int
stat(char *n, struct stat *st)
{
2a5: 55 push %ebp
2a6: 89 e5 mov %esp,%ebp
2a8: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
2ab: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2b2: 00
2b3: 8b 45 08 mov 0x8(%ebp),%eax
2b6: 89 04 24 mov %eax,(%esp)
2b9: e8 07 01 00 00 call 3c5 <open>
2be: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
2c1: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2c5: 79 07 jns 2ce <stat+0x29>
return -1;
2c7: b8 ff ff ff ff mov $0xffffffff,%eax
2cc: eb 23 jmp 2f1 <stat+0x4c>
r = fstat(fd, st);
2ce: 8b 45 0c mov 0xc(%ebp),%eax
2d1: 89 44 24 04 mov %eax,0x4(%esp)
2d5: 8b 45 f4 mov -0xc(%ebp),%eax
2d8: 89 04 24 mov %eax,(%esp)
2db: e8 fd 00 00 00 call 3dd <fstat>
2e0: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
2e3: 8b 45 f4 mov -0xc(%ebp),%eax
2e6: 89 04 24 mov %eax,(%esp)
2e9: e8 bf 00 00 00 call 3ad <close>
return r;
2ee: 8b 45 f0 mov -0x10(%ebp),%eax
}
2f1: c9 leave
2f2: c3 ret
000002f3 <atoi>:
int
atoi(const char *s)
{
2f3: 55 push %ebp
2f4: 89 e5 mov %esp,%ebp
2f6: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
2f9: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
300: eb 25 jmp 327 <atoi+0x34>
n = n*10 + *s++ - '0';
302: 8b 55 fc mov -0x4(%ebp),%edx
305: 89 d0 mov %edx,%eax
307: c1 e0 02 shl $0x2,%eax
30a: 01 d0 add %edx,%eax
30c: 01 c0 add %eax,%eax
30e: 89 c1 mov %eax,%ecx
310: 8b 45 08 mov 0x8(%ebp),%eax
313: 8d 50 01 lea 0x1(%eax),%edx
316: 89 55 08 mov %edx,0x8(%ebp)
319: 0f b6 00 movzbl (%eax),%eax
31c: 0f be c0 movsbl %al,%eax
31f: 01 c8 add %ecx,%eax
321: 83 e8 30 sub $0x30,%eax
324: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
327: 8b 45 08 mov 0x8(%ebp),%eax
32a: 0f b6 00 movzbl (%eax),%eax
32d: 3c 2f cmp $0x2f,%al
32f: 7e 0a jle 33b <atoi+0x48>
331: 8b 45 08 mov 0x8(%ebp),%eax
334: 0f b6 00 movzbl (%eax),%eax
337: 3c 39 cmp $0x39,%al
339: 7e c7 jle 302 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
33b: 8b 45 fc mov -0x4(%ebp),%eax
}
33e: c9 leave
33f: c3 ret
00000340 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
340: 55 push %ebp
341: 89 e5 mov %esp,%ebp
343: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
346: 8b 45 08 mov 0x8(%ebp),%eax
349: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
34c: 8b 45 0c mov 0xc(%ebp),%eax
34f: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
352: eb 17 jmp 36b <memmove+0x2b>
*dst++ = *src++;
354: 8b 45 fc mov -0x4(%ebp),%eax
357: 8d 50 01 lea 0x1(%eax),%edx
35a: 89 55 fc mov %edx,-0x4(%ebp)
35d: 8b 55 f8 mov -0x8(%ebp),%edx
360: 8d 4a 01 lea 0x1(%edx),%ecx
363: 89 4d f8 mov %ecx,-0x8(%ebp)
366: 0f b6 12 movzbl (%edx),%edx
369: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
36b: 8b 45 10 mov 0x10(%ebp),%eax
36e: 8d 50 ff lea -0x1(%eax),%edx
371: 89 55 10 mov %edx,0x10(%ebp)
374: 85 c0 test %eax,%eax
376: 7f dc jg 354 <memmove+0x14>
*dst++ = *src++;
return vdst;
378: 8b 45 08 mov 0x8(%ebp),%eax
}
37b: c9 leave
37c: c3 ret
0000037d <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
37d: b8 01 00 00 00 mov $0x1,%eax
382: cd 40 int $0x40
384: c3 ret
00000385 <exit>:
SYSCALL(exit)
385: b8 02 00 00 00 mov $0x2,%eax
38a: cd 40 int $0x40
38c: c3 ret
0000038d <wait>:
SYSCALL(wait)
38d: b8 03 00 00 00 mov $0x3,%eax
392: cd 40 int $0x40
394: c3 ret
00000395 <pipe>:
SYSCALL(pipe)
395: b8 04 00 00 00 mov $0x4,%eax
39a: cd 40 int $0x40
39c: c3 ret
0000039d <read>:
SYSCALL(read)
39d: b8 05 00 00 00 mov $0x5,%eax
3a2: cd 40 int $0x40
3a4: c3 ret
000003a5 <write>:
SYSCALL(write)
3a5: b8 10 00 00 00 mov $0x10,%eax
3aa: cd 40 int $0x40
3ac: c3 ret
000003ad <close>:
SYSCALL(close)
3ad: b8 15 00 00 00 mov $0x15,%eax
3b2: cd 40 int $0x40
3b4: c3 ret
000003b5 <kill>:
SYSCALL(kill)
3b5: b8 06 00 00 00 mov $0x6,%eax
3ba: cd 40 int $0x40
3bc: c3 ret
000003bd <exec>:
SYSCALL(exec)
3bd: b8 07 00 00 00 mov $0x7,%eax
3c2: cd 40 int $0x40
3c4: c3 ret
000003c5 <open>:
SYSCALL(open)
3c5: b8 0f 00 00 00 mov $0xf,%eax
3ca: cd 40 int $0x40
3cc: c3 ret
000003cd <mknod>:
SYSCALL(mknod)
3cd: b8 11 00 00 00 mov $0x11,%eax
3d2: cd 40 int $0x40
3d4: c3 ret
000003d5 <unlink>:
SYSCALL(unlink)
3d5: b8 12 00 00 00 mov $0x12,%eax
3da: cd 40 int $0x40
3dc: c3 ret
000003dd <fstat>:
SYSCALL(fstat)
3dd: b8 08 00 00 00 mov $0x8,%eax
3e2: cd 40 int $0x40
3e4: c3 ret
000003e5 <link>:
SYSCALL(link)
3e5: b8 13 00 00 00 mov $0x13,%eax
3ea: cd 40 int $0x40
3ec: c3 ret
000003ed <mkdir>:
SYSCALL(mkdir)
3ed: b8 14 00 00 00 mov $0x14,%eax
3f2: cd 40 int $0x40
3f4: c3 ret
000003f5 <chdir>:
SYSCALL(chdir)
3f5: b8 09 00 00 00 mov $0x9,%eax
3fa: cd 40 int $0x40
3fc: c3 ret
000003fd <dup>:
SYSCALL(dup)
3fd: b8 0a 00 00 00 mov $0xa,%eax
402: cd 40 int $0x40
404: c3 ret
00000405 <getpid>:
SYSCALL(getpid)
405: b8 0b 00 00 00 mov $0xb,%eax
40a: cd 40 int $0x40
40c: c3 ret
0000040d <sbrk>:
SYSCALL(sbrk)
40d: b8 0c 00 00 00 mov $0xc,%eax
412: cd 40 int $0x40
414: c3 ret
00000415 <sleep>:
SYSCALL(sleep)
415: b8 0d 00 00 00 mov $0xd,%eax
41a: cd 40 int $0x40
41c: c3 ret
0000041d <uptime>:
SYSCALL(uptime)
41d: b8 0e 00 00 00 mov $0xe,%eax
422: cd 40 int $0x40
424: c3 ret
00000425 <date>:
SYSCALL(date)
425: b8 16 00 00 00 mov $0x16,%eax
42a: cd 40 int $0x40
42c: c3 ret
0000042d <timem>:
SYSCALL(timem)
42d: b8 17 00 00 00 mov $0x17,%eax
432: cd 40 int $0x40
434: c3 ret
00000435 <getuid>:
SYSCALL(getuid)
435: b8 18 00 00 00 mov $0x18,%eax
43a: cd 40 int $0x40
43c: c3 ret
0000043d <getgid>:
SYSCALL(getgid)
43d: b8 19 00 00 00 mov $0x19,%eax
442: cd 40 int $0x40
444: c3 ret
00000445 <getppid>:
SYSCALL(getppid)
445: b8 1a 00 00 00 mov $0x1a,%eax
44a: cd 40 int $0x40
44c: c3 ret
0000044d <setuid>:
SYSCALL(setuid)
44d: b8 1b 00 00 00 mov $0x1b,%eax
452: cd 40 int $0x40
454: c3 ret
00000455 <setgid>:
SYSCALL(setgid)
455: b8 1c 00 00 00 mov $0x1c,%eax
45a: cd 40 int $0x40
45c: c3 ret
0000045d <getprocs>:
SYSCALL(getprocs)
45d: b8 1d 00 00 00 mov $0x1d,%eax
462: cd 40 int $0x40
464: c3 ret
00000465 <setpriority>:
SYSCALL(setpriority)
465: b8 1e 00 00 00 mov $0x1e,%eax
46a: cd 40 int $0x40
46c: c3 ret
0000046d <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
46d: 55 push %ebp
46e: 89 e5 mov %esp,%ebp
470: 83 ec 18 sub $0x18,%esp
473: 8b 45 0c mov 0xc(%ebp),%eax
476: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
479: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
480: 00
481: 8d 45 f4 lea -0xc(%ebp),%eax
484: 89 44 24 04 mov %eax,0x4(%esp)
488: 8b 45 08 mov 0x8(%ebp),%eax
48b: 89 04 24 mov %eax,(%esp)
48e: e8 12 ff ff ff call 3a5 <write>
}
493: c9 leave
494: c3 ret
00000495 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
495: 55 push %ebp
496: 89 e5 mov %esp,%ebp
498: 56 push %esi
499: 53 push %ebx
49a: 83 ec 30 sub $0x30,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
49d: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
4a4: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
4a8: 74 17 je 4c1 <printint+0x2c>
4aa: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
4ae: 79 11 jns 4c1 <printint+0x2c>
neg = 1;
4b0: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
4b7: 8b 45 0c mov 0xc(%ebp),%eax
4ba: f7 d8 neg %eax
4bc: 89 45 ec mov %eax,-0x14(%ebp)
4bf: eb 06 jmp 4c7 <printint+0x32>
} else {
x = xx;
4c1: 8b 45 0c mov 0xc(%ebp),%eax
4c4: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
4c7: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
4ce: 8b 4d f4 mov -0xc(%ebp),%ecx
4d1: 8d 41 01 lea 0x1(%ecx),%eax
4d4: 89 45 f4 mov %eax,-0xc(%ebp)
4d7: 8b 5d 10 mov 0x10(%ebp),%ebx
4da: 8b 45 ec mov -0x14(%ebp),%eax
4dd: ba 00 00 00 00 mov $0x0,%edx
4e2: f7 f3 div %ebx
4e4: 89 d0 mov %edx,%eax
4e6: 0f b6 80 ac 0b 00 00 movzbl 0xbac(%eax),%eax
4ed: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
4f1: 8b 75 10 mov 0x10(%ebp),%esi
4f4: 8b 45 ec mov -0x14(%ebp),%eax
4f7: ba 00 00 00 00 mov $0x0,%edx
4fc: f7 f6 div %esi
4fe: 89 45 ec mov %eax,-0x14(%ebp)
501: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
505: 75 c7 jne 4ce <printint+0x39>
if(neg)
507: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
50b: 74 10 je 51d <printint+0x88>
buf[i++] = '-';
50d: 8b 45 f4 mov -0xc(%ebp),%eax
510: 8d 50 01 lea 0x1(%eax),%edx
513: 89 55 f4 mov %edx,-0xc(%ebp)
516: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
51b: eb 1f jmp 53c <printint+0xa7>
51d: eb 1d jmp 53c <printint+0xa7>
putc(fd, buf[i]);
51f: 8d 55 dc lea -0x24(%ebp),%edx
522: 8b 45 f4 mov -0xc(%ebp),%eax
525: 01 d0 add %edx,%eax
527: 0f b6 00 movzbl (%eax),%eax
52a: 0f be c0 movsbl %al,%eax
52d: 89 44 24 04 mov %eax,0x4(%esp)
531: 8b 45 08 mov 0x8(%ebp),%eax
534: 89 04 24 mov %eax,(%esp)
537: e8 31 ff ff ff call 46d <putc>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
53c: 83 6d f4 01 subl $0x1,-0xc(%ebp)
540: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
544: 79 d9 jns 51f <printint+0x8a>
putc(fd, buf[i]);
}
546: 83 c4 30 add $0x30,%esp
549: 5b pop %ebx
54a: 5e pop %esi
54b: 5d pop %ebp
54c: c3 ret
0000054d <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
54d: 55 push %ebp
54e: 89 e5 mov %esp,%ebp
550: 83 ec 38 sub $0x38,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
553: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
55a: 8d 45 0c lea 0xc(%ebp),%eax
55d: 83 c0 04 add $0x4,%eax
560: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
563: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
56a: e9 7c 01 00 00 jmp 6eb <printf+0x19e>
c = fmt[i] & 0xff;
56f: 8b 55 0c mov 0xc(%ebp),%edx
572: 8b 45 f0 mov -0x10(%ebp),%eax
575: 01 d0 add %edx,%eax
577: 0f b6 00 movzbl (%eax),%eax
57a: 0f be c0 movsbl %al,%eax
57d: 25 ff 00 00 00 and $0xff,%eax
582: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
585: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
589: 75 2c jne 5b7 <printf+0x6a>
if(c == '%'){
58b: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
58f: 75 0c jne 59d <printf+0x50>
state = '%';
591: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
598: e9 4a 01 00 00 jmp 6e7 <printf+0x19a>
} else {
putc(fd, c);
59d: 8b 45 e4 mov -0x1c(%ebp),%eax
5a0: 0f be c0 movsbl %al,%eax
5a3: 89 44 24 04 mov %eax,0x4(%esp)
5a7: 8b 45 08 mov 0x8(%ebp),%eax
5aa: 89 04 24 mov %eax,(%esp)
5ad: e8 bb fe ff ff call 46d <putc>
5b2: e9 30 01 00 00 jmp 6e7 <printf+0x19a>
}
} else if(state == '%'){
5b7: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
5bb: 0f 85 26 01 00 00 jne 6e7 <printf+0x19a>
if(c == 'd'){
5c1: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
5c5: 75 2d jne 5f4 <printf+0xa7>
printint(fd, *ap, 10, 1);
5c7: 8b 45 e8 mov -0x18(%ebp),%eax
5ca: 8b 00 mov (%eax),%eax
5cc: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
5d3: 00
5d4: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
5db: 00
5dc: 89 44 24 04 mov %eax,0x4(%esp)
5e0: 8b 45 08 mov 0x8(%ebp),%eax
5e3: 89 04 24 mov %eax,(%esp)
5e6: e8 aa fe ff ff call 495 <printint>
ap++;
5eb: 83 45 e8 04 addl $0x4,-0x18(%ebp)
5ef: e9 ec 00 00 00 jmp 6e0 <printf+0x193>
} else if(c == 'x' || c == 'p'){
5f4: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
5f8: 74 06 je 600 <printf+0xb3>
5fa: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
5fe: 75 2d jne 62d <printf+0xe0>
printint(fd, *ap, 16, 0);
600: 8b 45 e8 mov -0x18(%ebp),%eax
603: 8b 00 mov (%eax),%eax
605: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
60c: 00
60d: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
614: 00
615: 89 44 24 04 mov %eax,0x4(%esp)
619: 8b 45 08 mov 0x8(%ebp),%eax
61c: 89 04 24 mov %eax,(%esp)
61f: e8 71 fe ff ff call 495 <printint>
ap++;
624: 83 45 e8 04 addl $0x4,-0x18(%ebp)
628: e9 b3 00 00 00 jmp 6e0 <printf+0x193>
} else if(c == 's'){
62d: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
631: 75 45 jne 678 <printf+0x12b>
s = (char*)*ap;
633: 8b 45 e8 mov -0x18(%ebp),%eax
636: 8b 00 mov (%eax),%eax
638: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
63b: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
63f: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
643: 75 09 jne 64e <printf+0x101>
s = "(null)";
645: c7 45 f4 3f 09 00 00 movl $0x93f,-0xc(%ebp)
while(*s != 0){
64c: eb 1e jmp 66c <printf+0x11f>
64e: eb 1c jmp 66c <printf+0x11f>
putc(fd, *s);
650: 8b 45 f4 mov -0xc(%ebp),%eax
653: 0f b6 00 movzbl (%eax),%eax
656: 0f be c0 movsbl %al,%eax
659: 89 44 24 04 mov %eax,0x4(%esp)
65d: 8b 45 08 mov 0x8(%ebp),%eax
660: 89 04 24 mov %eax,(%esp)
663: e8 05 fe ff ff call 46d <putc>
s++;
668: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
66c: 8b 45 f4 mov -0xc(%ebp),%eax
66f: 0f b6 00 movzbl (%eax),%eax
672: 84 c0 test %al,%al
674: 75 da jne 650 <printf+0x103>
676: eb 68 jmp 6e0 <printf+0x193>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
678: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
67c: 75 1d jne 69b <printf+0x14e>
putc(fd, *ap);
67e: 8b 45 e8 mov -0x18(%ebp),%eax
681: 8b 00 mov (%eax),%eax
683: 0f be c0 movsbl %al,%eax
686: 89 44 24 04 mov %eax,0x4(%esp)
68a: 8b 45 08 mov 0x8(%ebp),%eax
68d: 89 04 24 mov %eax,(%esp)
690: e8 d8 fd ff ff call 46d <putc>
ap++;
695: 83 45 e8 04 addl $0x4,-0x18(%ebp)
699: eb 45 jmp 6e0 <printf+0x193>
} else if(c == '%'){
69b: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
69f: 75 17 jne 6b8 <printf+0x16b>
putc(fd, c);
6a1: 8b 45 e4 mov -0x1c(%ebp),%eax
6a4: 0f be c0 movsbl %al,%eax
6a7: 89 44 24 04 mov %eax,0x4(%esp)
6ab: 8b 45 08 mov 0x8(%ebp),%eax
6ae: 89 04 24 mov %eax,(%esp)
6b1: e8 b7 fd ff ff call 46d <putc>
6b6: eb 28 jmp 6e0 <printf+0x193>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
6b8: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp)
6bf: 00
6c0: 8b 45 08 mov 0x8(%ebp),%eax
6c3: 89 04 24 mov %eax,(%esp)
6c6: e8 a2 fd ff ff call 46d <putc>
putc(fd, c);
6cb: 8b 45 e4 mov -0x1c(%ebp),%eax
6ce: 0f be c0 movsbl %al,%eax
6d1: 89 44 24 04 mov %eax,0x4(%esp)
6d5: 8b 45 08 mov 0x8(%ebp),%eax
6d8: 89 04 24 mov %eax,(%esp)
6db: e8 8d fd ff ff call 46d <putc>
}
state = 0;
6e0: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
6e7: 83 45 f0 01 addl $0x1,-0x10(%ebp)
6eb: 8b 55 0c mov 0xc(%ebp),%edx
6ee: 8b 45 f0 mov -0x10(%ebp),%eax
6f1: 01 d0 add %edx,%eax
6f3: 0f b6 00 movzbl (%eax),%eax
6f6: 84 c0 test %al,%al
6f8: 0f 85 71 fe ff ff jne 56f <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
6fe: c9 leave
6ff: c3 ret
00000700 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
700: 55 push %ebp
701: 89 e5 mov %esp,%ebp
703: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
706: 8b 45 08 mov 0x8(%ebp),%eax
709: 83 e8 08 sub $0x8,%eax
70c: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
70f: a1 c8 0b 00 00 mov 0xbc8,%eax
714: 89 45 fc mov %eax,-0x4(%ebp)
717: eb 24 jmp 73d <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
719: 8b 45 fc mov -0x4(%ebp),%eax
71c: 8b 00 mov (%eax),%eax
71e: 3b 45 fc cmp -0x4(%ebp),%eax
721: 77 12 ja 735 <free+0x35>
723: 8b 45 f8 mov -0x8(%ebp),%eax
726: 3b 45 fc cmp -0x4(%ebp),%eax
729: 77 24 ja 74f <free+0x4f>
72b: 8b 45 fc mov -0x4(%ebp),%eax
72e: 8b 00 mov (%eax),%eax
730: 3b 45 f8 cmp -0x8(%ebp),%eax
733: 77 1a ja 74f <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
735: 8b 45 fc mov -0x4(%ebp),%eax
738: 8b 00 mov (%eax),%eax
73a: 89 45 fc mov %eax,-0x4(%ebp)
73d: 8b 45 f8 mov -0x8(%ebp),%eax
740: 3b 45 fc cmp -0x4(%ebp),%eax
743: 76 d4 jbe 719 <free+0x19>
745: 8b 45 fc mov -0x4(%ebp),%eax
748: 8b 00 mov (%eax),%eax
74a: 3b 45 f8 cmp -0x8(%ebp),%eax
74d: 76 ca jbe 719 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
74f: 8b 45 f8 mov -0x8(%ebp),%eax
752: 8b 40 04 mov 0x4(%eax),%eax
755: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
75c: 8b 45 f8 mov -0x8(%ebp),%eax
75f: 01 c2 add %eax,%edx
761: 8b 45 fc mov -0x4(%ebp),%eax
764: 8b 00 mov (%eax),%eax
766: 39 c2 cmp %eax,%edx
768: 75 24 jne 78e <free+0x8e>
bp->s.size += p->s.ptr->s.size;
76a: 8b 45 f8 mov -0x8(%ebp),%eax
76d: 8b 50 04 mov 0x4(%eax),%edx
770: 8b 45 fc mov -0x4(%ebp),%eax
773: 8b 00 mov (%eax),%eax
775: 8b 40 04 mov 0x4(%eax),%eax
778: 01 c2 add %eax,%edx
77a: 8b 45 f8 mov -0x8(%ebp),%eax
77d: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
780: 8b 45 fc mov -0x4(%ebp),%eax
783: 8b 00 mov (%eax),%eax
785: 8b 10 mov (%eax),%edx
787: 8b 45 f8 mov -0x8(%ebp),%eax
78a: 89 10 mov %edx,(%eax)
78c: eb 0a jmp 798 <free+0x98>
} else
bp->s.ptr = p->s.ptr;
78e: 8b 45 fc mov -0x4(%ebp),%eax
791: 8b 10 mov (%eax),%edx
793: 8b 45 f8 mov -0x8(%ebp),%eax
796: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
798: 8b 45 fc mov -0x4(%ebp),%eax
79b: 8b 40 04 mov 0x4(%eax),%eax
79e: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
7a5: 8b 45 fc mov -0x4(%ebp),%eax
7a8: 01 d0 add %edx,%eax
7aa: 3b 45 f8 cmp -0x8(%ebp),%eax
7ad: 75 20 jne 7cf <free+0xcf>
p->s.size += bp->s.size;
7af: 8b 45 fc mov -0x4(%ebp),%eax
7b2: 8b 50 04 mov 0x4(%eax),%edx
7b5: 8b 45 f8 mov -0x8(%ebp),%eax
7b8: 8b 40 04 mov 0x4(%eax),%eax
7bb: 01 c2 add %eax,%edx
7bd: 8b 45 fc mov -0x4(%ebp),%eax
7c0: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
7c3: 8b 45 f8 mov -0x8(%ebp),%eax
7c6: 8b 10 mov (%eax),%edx
7c8: 8b 45 fc mov -0x4(%ebp),%eax
7cb: 89 10 mov %edx,(%eax)
7cd: eb 08 jmp 7d7 <free+0xd7>
} else
p->s.ptr = bp;
7cf: 8b 45 fc mov -0x4(%ebp),%eax
7d2: 8b 55 f8 mov -0x8(%ebp),%edx
7d5: 89 10 mov %edx,(%eax)
freep = p;
7d7: 8b 45 fc mov -0x4(%ebp),%eax
7da: a3 c8 0b 00 00 mov %eax,0xbc8
}
7df: c9 leave
7e0: c3 ret
000007e1 <morecore>:
static Header*
morecore(uint nu)
{
7e1: 55 push %ebp
7e2: 89 e5 mov %esp,%ebp
7e4: 83 ec 28 sub $0x28,%esp
char *p;
Header *hp;
if(nu < 4096)
7e7: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
7ee: 77 07 ja 7f7 <morecore+0x16>
nu = 4096;
7f0: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
7f7: 8b 45 08 mov 0x8(%ebp),%eax
7fa: c1 e0 03 shl $0x3,%eax
7fd: 89 04 24 mov %eax,(%esp)
800: e8 08 fc ff ff call 40d <sbrk>
805: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
808: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
80c: 75 07 jne 815 <morecore+0x34>
return 0;
80e: b8 00 00 00 00 mov $0x0,%eax
813: eb 22 jmp 837 <morecore+0x56>
hp = (Header*)p;
815: 8b 45 f4 mov -0xc(%ebp),%eax
818: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
81b: 8b 45 f0 mov -0x10(%ebp),%eax
81e: 8b 55 08 mov 0x8(%ebp),%edx
821: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
824: 8b 45 f0 mov -0x10(%ebp),%eax
827: 83 c0 08 add $0x8,%eax
82a: 89 04 24 mov %eax,(%esp)
82d: e8 ce fe ff ff call 700 <free>
return freep;
832: a1 c8 0b 00 00 mov 0xbc8,%eax
}
837: c9 leave
838: c3 ret
00000839 <malloc>:
void*
malloc(uint nbytes)
{
839: 55 push %ebp
83a: 89 e5 mov %esp,%ebp
83c: 83 ec 28 sub $0x28,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
83f: 8b 45 08 mov 0x8(%ebp),%eax
842: 83 c0 07 add $0x7,%eax
845: c1 e8 03 shr $0x3,%eax
848: 83 c0 01 add $0x1,%eax
84b: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
84e: a1 c8 0b 00 00 mov 0xbc8,%eax
853: 89 45 f0 mov %eax,-0x10(%ebp)
856: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
85a: 75 23 jne 87f <malloc+0x46>
base.s.ptr = freep = prevp = &base;
85c: c7 45 f0 c0 0b 00 00 movl $0xbc0,-0x10(%ebp)
863: 8b 45 f0 mov -0x10(%ebp),%eax
866: a3 c8 0b 00 00 mov %eax,0xbc8
86b: a1 c8 0b 00 00 mov 0xbc8,%eax
870: a3 c0 0b 00 00 mov %eax,0xbc0
base.s.size = 0;
875: c7 05 c4 0b 00 00 00 movl $0x0,0xbc4
87c: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
87f: 8b 45 f0 mov -0x10(%ebp),%eax
882: 8b 00 mov (%eax),%eax
884: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
887: 8b 45 f4 mov -0xc(%ebp),%eax
88a: 8b 40 04 mov 0x4(%eax),%eax
88d: 3b 45 ec cmp -0x14(%ebp),%eax
890: 72 4d jb 8df <malloc+0xa6>
if(p->s.size == nunits)
892: 8b 45 f4 mov -0xc(%ebp),%eax
895: 8b 40 04 mov 0x4(%eax),%eax
898: 3b 45 ec cmp -0x14(%ebp),%eax
89b: 75 0c jne 8a9 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
89d: 8b 45 f4 mov -0xc(%ebp),%eax
8a0: 8b 10 mov (%eax),%edx
8a2: 8b 45 f0 mov -0x10(%ebp),%eax
8a5: 89 10 mov %edx,(%eax)
8a7: eb 26 jmp 8cf <malloc+0x96>
else {
p->s.size -= nunits;
8a9: 8b 45 f4 mov -0xc(%ebp),%eax
8ac: 8b 40 04 mov 0x4(%eax),%eax
8af: 2b 45 ec sub -0x14(%ebp),%eax
8b2: 89 c2 mov %eax,%edx
8b4: 8b 45 f4 mov -0xc(%ebp),%eax
8b7: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
8ba: 8b 45 f4 mov -0xc(%ebp),%eax
8bd: 8b 40 04 mov 0x4(%eax),%eax
8c0: c1 e0 03 shl $0x3,%eax
8c3: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
8c6: 8b 45 f4 mov -0xc(%ebp),%eax
8c9: 8b 55 ec mov -0x14(%ebp),%edx
8cc: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
8cf: 8b 45 f0 mov -0x10(%ebp),%eax
8d2: a3 c8 0b 00 00 mov %eax,0xbc8
return (void*)(p + 1);
8d7: 8b 45 f4 mov -0xc(%ebp),%eax
8da: 83 c0 08 add $0x8,%eax
8dd: eb 38 jmp 917 <malloc+0xde>
}
if(p == freep)
8df: a1 c8 0b 00 00 mov 0xbc8,%eax
8e4: 39 45 f4 cmp %eax,-0xc(%ebp)
8e7: 75 1b jne 904 <malloc+0xcb>
if((p = morecore(nunits)) == 0)
8e9: 8b 45 ec mov -0x14(%ebp),%eax
8ec: 89 04 24 mov %eax,(%esp)
8ef: e8 ed fe ff ff call 7e1 <morecore>
8f4: 89 45 f4 mov %eax,-0xc(%ebp)
8f7: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
8fb: 75 07 jne 904 <malloc+0xcb>
return 0;
8fd: b8 00 00 00 00 mov $0x0,%eax
902: eb 13 jmp 917 <malloc+0xde>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
904: 8b 45 f4 mov -0xc(%ebp),%eax
907: 89 45 f0 mov %eax,-0x10(%ebp)
90a: 8b 45 f4 mov -0xc(%ebp),%eax
90d: 8b 00 mov (%eax),%eax
90f: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
912: e9 70 ff ff ff jmp 887 <malloc+0x4e>
}
917: c9 leave
918: c3 ret
|
programs/oeis/196/A196305.asm
|
neoneye/loda
| 22 |
177048
|
<filename>programs/oeis/196/A196305.asm
; A196305: a(n) = 15*2^n - 1.
; 14,29,59,119,239,479,959,1919,3839,7679,15359,30719,61439,122879,245759,491519,983039,1966079,3932159,7864319,15728639,31457279,62914559,125829119,251658239,503316479,1006632959,2013265919,4026531839,8053063679,16106127359,32212254719,64424509439,128849018879,257698037759,515396075519,1030792151039,2061584302079,4123168604159,8246337208319,16492674416639,32985348833279,65970697666559,131941395333119,263882790666239,527765581332479,1055531162664959,2111062325329919,4222124650659839,8444249301319679,16888498602639359,33776997205278719,67553994410557439,135107988821114879,270215977642229759,540431955284459519,1080863910568919039,2161727821137838079,4323455642275676159,8646911284551352319,17293822569102704639,34587645138205409279,69175290276410818559,138350580552821637119,276701161105643274239,553402322211286548479,1106804644422573096959,2213609288845146193919,4427218577690292387839,8854437155380584775679,17708874310761169551359,35417748621522339102719,70835497243044678205439,141670994486089356410879,283341988972178712821759,566683977944357425643519,1133367955888714851287039,2266735911777429702574079,4533471823554859405148159,9066943647109718810296319,18133887294219437620592639,36267774588438875241185279,72535549176877750482370559,145071098353755500964741119,290142196707511001929482239,580284393415022003858964479,1160568786830044007717928959,2321137573660088015435857919,4642275147320176030871715839,9284550294640352061743431679,18569100589280704123486863359,37138201178561408246973726719,74276402357122816493947453439,148552804714245632987894906879,297105609428491265975789813759,594211218856982531951579627519,1188422437713965063903159255039,2376844875427930127806318510079,4753689750855860255612637020159,9507379501711720511225274040319
mov $1,2
pow $1,$0
mul $1,15
sub $1,1
mov $0,$1
|
programs/oeis/346/A346178.asm
|
neoneye/loda
| 22 |
4651
|
; A346178: Expansion of (1-2*x)/(1-10*x).
; 1,8,80,800,8000,80000,800000,8000000,80000000,800000000,8000000000,80000000000,800000000000,8000000000000,80000000000000,800000000000000,8000000000000000,80000000000000000,800000000000000000,8000000000000000000,80000000000000000000
mov $1,10
pow $1,$0
mul $1,6
add $1,5
mul $1,2
div $1,15
mov $0,$1
|
kernel/usb/uhci.asm
|
ssebs/xos
| 15 |
84522
|
<reponame>ssebs/xos<filename>kernel/usb/uhci.asm
;; xOS32
;; Copyright (C) 2016-2017 by <NAME>.
use32
; UHCI I/O Port Registers
UHCI_COMMAND = 0x00 ; word
UHCI_STATUS = 0x02 ; word
UHCI_INTERRUPT = 0x04 ; word
UHCI_FRAME = 0x06 ; word
UHCI_FRAMELIST = 0x08 ; dword
UHCI_SOF_MODIFY = 0x0C ; byte
UHCI_PORT1 = 0x10 ; word
UHCI_PORT2 = 0x12 ; word
; UHCI Command Register Bitfield
UHCI_COMMAND_RUN = 0x0001
UHCI_COMMAND_HOST_RESET = 0x0002
UHCI_COMMAND_GLOBAL_RESET = 0x0004
UHCI_COMMAND_GLOBAL_RESUME = 0x0010
UHCI_COMMAND_MAX64 = 0x0080
; UHCI Status Register Bitfield
UHCI_STATUS_INTERRUPT = 0x0001
UHCI_STATUS_ERROR_INTERRUPT = 0x0002
UHCI_STATUS_ERROR_HOST = 0x0008
UHCI_STATUS_ERROR_PROCESS = 0x0010
UHCI_STATUS_HALTED = 0x0020
; UHCI Port Registers Bitfield
UHCI_PORT_PLUG = 0x0001
UHCI_PORT_PLUG_CHANGE = 0x0002
UHCI_PORT_ENABLE = 0x0004
UHCI_PORT_ENABLE_CHANGE = 0x0008
UHCI_PORT_LOW_SPEED = 0x0100
UHCI_PORT_RESET = 0x0200
; Packet Types
UHCI_PACKET_SETUP = 0x2D
UHCI_PACKET_IN = 0x69
UHCI_PACKET_OUT = 0xE1
UHCI_DESCRIPTORS_SIZE = 8 ; 32 KB of descriptors is much, much more than enough!
align 4
uhci_pci_list dd 0
uhci_pci_count dd 0
uhci_framelist dd 0
; uhci_init:
; Detects and initializes UHCI controllers
uhci_init:
; generate a list of PCI devices
mov ah, 0x0C
mov al, 0x03
mov bl, 0x00
call pci_generate_list
; no UHCI?
cmp ecx, 0
je .done
mov [uhci_pci_list], eax
mov [uhci_pci_count], ecx
mov esi, .starting
call kprint
mov eax, [uhci_pci_count]
call int_to_string
call kprint
mov esi, .starting2
call kprint
mov eax, 0
mov ecx, UHCI_DESCRIPTORS_SIZE
mov dl, PAGE_PRESENT or PAGE_WRITEABLE or PAGE_NO_CACHE
call vmm_alloc
mov [uhci_framelist], eax
.loop:
mov ecx, [.controller]
cmp ecx, [uhci_pci_count]
jge .done
call uhci_init_controller
inc [.controller]
jmp .loop
.done:
ret
align 4
.controller dd 0
.starting db "usb-uhci: found ",0
.starting2 db " UHCI controllers, initializing in order...",10,0
; uhci_init_controller:
; Initializes a single UHCI controller
; In\ ECX = Zero-based controller number
; Out\ Nothing
uhci_init_controller:
mov [.controller], ecx
shl ecx, 2 ; mul 4
add ecx, [uhci_pci_list]
mov al, [ecx+PCI_DEVICE_BUS]
mov [.bus], al
mov al, [ecx+PCI_DEVICE_SLOT]
mov [.slot], al
mov al, [ecx+PCI_DEVICE_FUNCTION]
mov [.function], al
mov esi, .starting
call kprint
mov al, [.bus]
call hex_byte_to_string
call kprint
mov esi, .colon
call kprint
mov al, [.slot]
call hex_byte_to_string
call kprint
mov esi, .colon
call kprint
mov al, [.function]
call hex_byte_to_string
call kprint
mov esi, newline
call kprint
; read I/O port
mov al, [.bus]
mov ah, [.slot]
mov bl, [.function]
mov bh, PCI_BAR4
call pci_read_dword
and ax, 0xFFFC
mov [.io], ax
mov esi, .io_msg
call kprint
mov ax, [.io]
call hex_word_to_string
call kprint
mov esi, newline
call kprint
; enable I/O ports and DMA, disable interrupt line
mov al, [.bus]
mov ah, [.slot]
mov bl, [.function]
mov bh, PCI_STATUS_COMMAND
call pci_read_dword
or eax, 0x405
mov edx, eax
mov al, [.bus]
mov ah, [.slot]
mov bl, [.function]
mov bh, PCI_STATUS_COMMAND
call pci_write_dword
; allocate memory for the device addresses
mov ecx, USB_MAX_ADDRESSES
call kmalloc
mov [.memory], eax
; register the controller...
mov al, [.bus]
mov ah, [.slot]
mov bl, [.function]
mov cl, USB_UHCI
movzx edx, [.io]
mov esi, [.memory]
call usb_register
; usb controller is now in eax
call usb_reset_controller
ret
align 4
.controller dd 0
.memory dd 0
.io dw 0
.bus db 0
.slot db 0
.function db 0
.starting db "usb-uhci: initialize UHCI controller on PCI slot ",0
.colon db ":",0
.io_msg db "usb-uhci: base I/O port is 0x",0
; uhci_reset_controller:
; Resets an UHCI controller
; In\ EAX = Pointer to controller information
; Out\ Nothing
uhci_reset_controller:
mov [.controller], eax
mov edx, [eax+USB_CONTROLLER_BASE]
mov [.io], dx ; I/O port
; global reset
mov dx, [.io]
mov ax, UHCI_COMMAND_GLOBAL_RESET
out dx, ax
call iowait
mov eax, 2
call pit_sleep
mov dx, [.io]
xor ax, ax
out dx, ax
call iowait
; host controller reset
mov dx, [.io]
mov ax, UHCI_COMMAND_HOST_RESET
out dx, ax
call iowait
.wait_host_reset:
in ax, dx
test ax, UHCI_COMMAND_HOST_RESET
jnz .wait_host_reset
mov dx, [.io]
xor ax, ax
out dx, ax
call iowait
; global resume
mov dx, [.io]
in ax, dx
or ax, UHCI_COMMAND_GLOBAL_RESUME
out dx, ax
call iowait
mov eax, 5
call pit_sleep
mov dx, [.io]
in ax, dx
and ax, not UHCI_COMMAND_GLOBAL_RESUME
out dx, ax
call iowait
; start of frame modify
mov dx, [.io]
add dx, UHCI_SOF_MODIFY
mov al, 64
out dx, al
call iowait
; port reset
mov dx, [.io]
add dx, UHCI_PORT1
in ax, dx
or ax, UHCI_PORT_RESET or UHCI_PORT_ENABLE
and ax, not (3 shl 10)
and ax, not (1 shl 12)
and ax, not (1 shl 8)
;and ax, not (1 shl 7)
and ax, not (3 shl 4)
and ax, not 1
out dx, ax
call iowait
mov dx, [.io]
add dx, UHCI_PORT2
in ax, dx
or ax, UHCI_PORT_RESET or UHCI_PORT_ENABLE
and ax, not (3 shl 10)
and ax, not (1 shl 12)
and ax, not (1 shl 8)
;and ax, not (1 shl 7)
and ax, not (3 shl 4)
and ax, not 1
out dx, ax
call iowait
mov eax, 5
call pit_sleep
; end of reset --
; -- enable ports
mov dx, [.io]
add dx, UHCI_PORT1
in ax, dx
or ax, UHCI_PORT_ENABLE
and ax, not UHCI_PORT_RESET
and ax, not (3 shl 10)
and ax, not (1 shl 12)
and ax, not (1 shl 8)
;and ax, not (1 shl 7)
and ax, not (3 shl 4)
and ax, not 1
out dx, ax
call iowait
mov dx, [.io]
add dx, UHCI_PORT2
mov ax, UHCI_PORT_ENABLE
in ax, dx
or ax, UHCI_PORT_ENABLE
and ax, not UHCI_PORT_RESET
and ax, not (3 shl 10)
and ax, not (1 shl 12)
and ax, not (1 shl 8)
;and ax, not (1 shl 7)
and ax, not (3 shl 4)
and ax, not 1
out dx, ax
call iowait
mov eax, 5
call pit_sleep
mov dx, [.io]
add dx, UHCI_STATUS
mov ax, 0x3F
out dx, ax
call iowait
ret
align 4
.controller dd 0
.io dw 0
; uhci_setup:
; Sends a setup packet
; In\ EAX = Pointer to controller information
; In\ BL = Device address
; In\ BH = Endpoint
; In\ ESI = Setup packet data
; In\ EDI = Data stage, if present
; In\ ECX = Size of data stage, zero if not present, bit 31 is direction
; Bit 31 = 0: host to device
; Bit 31 = 1: device to host
; Out\ EAX = 0 on success
uhci_setup:
mov [.controller], eax
mov [.packet], esi
mov [.data], edi
mov [.data_size], ecx
and bl, 0x7F
mov [.address], bl
and bh, 0x0F
mov [.endpoint], bh
mov eax, [.controller]
mov edx, [eax+USB_CONTROLLER_BASE]
mov [.io], dx ; I/O port
; physical addresses for DMA
mov eax, [.packet]
call virtual_to_physical
mov [.packet], eax
cmp [.data_size], 0 ; no data stage?
je .skip_data
mov eax, [.data]
call virtual_to_physical
mov [.data], eax
.skip_data:
; construct the descriptors
mov eax, [uhci_framelist]
mov [.framelist], eax
call virtual_to_physical
mov [.framelist_phys], eax
; construct the frame list
mov edi, [.framelist]
mov eax, [.framelist_phys]
add eax, 64 ; first queue head
or eax, 2 ; select QH
stosd
mov eax, 1 ; terminate
stosd
; construct the first QH
mov edi, [.framelist]
add edi, 64
mov eax, 1 ; invalid pointer
stosd
mov eax, [.framelist_phys]
add eax, 128 ; first TD
stosd
mov eax, 0
stosd
stosd
stosd
stosd
; construct the first TD
mov edi, [.framelist]
add edi, 128
mov eax, [.framelist_phys] ; second TD
add eax, 128+64
stosd
; 3 error limit, active, low speed
mov eax, (3 shl 27) or (1 shl 23) or (1 shl 26)
stosd
; max data transfer
mov eax, 7
shl eax, 21
movzx ebx, [.address]
shl ebx, 8
or eax, ebx
movzx ebx, [.endpoint]
shl ebx, 15
or eax, ebx
or eax, UHCI_PACKET_SETUP
stosd
mov eax, [.packet] ; data buffer
stosd
mov eax, 0
stosd
stosd
stosd
stosd
; if there is a data packet, construct a packet for it
cmp [.data_size], 0
je .no_data
; data packet is IN or OUT token?
test [.data_size], 0x80000000
jnz .data_in
.data_out:
; Status is opposite direction of data
mov [.data_token], UHCI_PACKET_OUT
mov [.status_token], UHCI_PACKET_IN
jmp .continue_descriptors
.data_in:
mov [.data_token], UHCI_PACKET_IN
mov [.status_token], UHCI_PACKET_OUT
.continue_descriptors:
; construct second TD
mov edi, [.framelist]
add edi, 128+64
mov eax, [.framelist_phys]
add eax, 256 ; third TD
stosd
mov eax, (3 shl 27) or (1 shl 23) or (1 shl 26)
stosd
mov eax, [.data_size]
and eax, 0x7FFFFFFF
dec eax
shl eax, 21
movzx ebx, [.address]
shl ebx, 8
or eax, ebx
movzx ebx, [.endpoint]
shl ebx, 15
or eax, ebx
or eax, [.data_token]
or eax, 1 shl 19 ; data 1
stosd
mov eax, [.data] ; data buffer
stosd
mov eax, 0
stosd
stosd
stosd
stosd
; construct third TD
mov edi, [.framelist]
add edi, 256
mov eax, 1 ; invalid pointer
stosd
mov eax, (3 shl 27) or (1 shl 23) or (1 shl 24) or (1 shl 26) ; ioc
stosd
mov eax, 0x7FF
shl eax, 21
movzx ebx, [.address]
shl ebx, 8
or eax, ebx
movzx ebx, [.endpoint]
shl ebx, 15
or eax, ebx
or eax, [.status_token]
stosd
mov eax, 0 ; buffer..
stosd
;mov eax, 0
stosd
stosd
stosd
stosd
jmp .send_packet
.no_data:
mov edi, [.framelist]
add edi, 128+64
mov eax, 1 ; invalid pointer
stosd
mov eax, (3 shl 27) or (1 shl 23) or (1 shl 24) or (1 shl 26)
stosd
mov eax, 0x7FF
shl eax, 21
movzx ebx, [.address]
shl ebx, 8
or eax, ebx
movzx ebx, [.endpoint]
shl ebx, 15
or eax, ebx
or eax, UHCI_PACKET_IN
stosd
mov eax, 0 ; buffer..
stosd
;mov eax, 0
stosd
stosd
stosd
stosd
.send_packet:
;wbinvd
; tell the uhci about the frame list
mov dx, [.io]
in ax, dx
and ax, not UHCI_COMMAND_RUN
out dx, ax
;call iowait
mov dx, [.io]
add dx, UHCI_FRAMELIST
mov eax, [.framelist_phys]
out dx, eax
mov dx, [.io]
add dx, UHCI_FRAME
mov ax, 0
out dx, ax
call iowait
mov dx, [.io]
in ax, dx
or ax, UHCI_COMMAND_RUN
out dx, ax
;call iowait
.wait:
mov dx, [.io]
add dx, UHCI_STATUS
in ax, dx
test ax, UHCI_STATUS_ERROR_INTERRUPT
jnz .interrupt
test ax, UHCI_STATUS_ERROR_PROCESS
jnz .process
test ax, UHCI_STATUS_ERROR_HOST
jnz .host
test ax, UHCI_STATUS_HALTED
jnz .finish
test ax, UHCI_STATUS_INTERRUPT
jnz .finish
jmp .wait
.interrupt:
mov dx, [.io]
in ax, dx
and ax, not UHCI_COMMAND_RUN
out dx, ax
;call iowait
; clear status
mov dx, [.io]
add dx, UHCI_STATUS
mov ax, 0x3F
out dx, ax
;call iowait
;mov esi, .interrupt_msg
;call kprint
mov eax, -1
ret
.host:
mov dx, [.io]
in ax, dx
and ax, not UHCI_COMMAND_RUN
out dx, ax
;call iowait
; clear status
mov dx, [.io]
add dx, UHCI_STATUS
mov ax, 0x3F
out dx, ax
;call iowait
;mov esi, .host_msg
;call kprint
mov eax, -1
ret
.process:
mov dx, [.io]
in ax, dx
and ax, not UHCI_COMMAND_RUN
out dx, ax
;call iowait
; clear status
mov dx, [.io]
add dx, UHCI_STATUS
mov ax, 0x3F
out dx, ax
;call iowait
;mov esi, .process_msg
;call kprint
mov eax, -1
ret
.finish:
mov dx, [.io]
in ax, dx
and ax, not UHCI_COMMAND_RUN
out dx, ax
;call iowait
; clear status
mov dx, [.io]
add dx, UHCI_STATUS
mov ax, 0x3F
out dx, ax
;call iowait
mov eax, 0
ret
align 4
.controller dd 0
.packet dd 0
.data dd 0
.data_size dd 0
.data_token dd 0
.status_token dd 0
.io dw 0
.address db 0
.endpoint db 0
align 4
.framelist dd 0
.framelist_phys dd 0
.interrupt_msg db "usb-uhci: interrupt error in setup packet.",10,0
.host_msg db "usb-uhci: host error in setup packet.",10,0
.process_msg db "usb-uhci: process error in setup packet.",10,0
; uhci_interrupt:
; Sends/receives an interrupt packet
; In\ EAX = Pointer to controller information
; In\ BL = Device address
; In\ BH = Endpoint
; In\ ESI = Interrupt packet
; In\ ECX = Bits 0-30: Size of interrupt packet, bit 31: direction
; Bit 31 = 0: host to device
; Bit 31 = 1: device to host
; Out\ EAX = 0 on success
uhci_interrupt:
mov [.controller], eax
mov [.packet], esi
mov [.size], ecx
and bl, 0x7F
mov [.address], bl
and bh, 0x0F
mov [.endpoint], bh
; if there is no data to be transferred, ignore the request
;mov ecx, [.size]
;and ecx, 0x7FFFFFFF
;cmp ecx, 0
;je .finish2
mov eax, [.controller]
mov edx, [eax+USB_CONTROLLER_BASE]
mov [.io], dx ; I/O port
; physical addresses for the DMA to be happy...
mov eax, [.packet]
call virtual_to_physical
mov [.packet], eax
mov eax, [uhci_framelist]
mov [.framelist], eax
call virtual_to_physical
mov [.framelist_phys], eax
; construct the frame list
mov edi, [.framelist]
mov eax, [.framelist_phys] ; pointer to first TD
add eax, 32
stosd
mov eax, 1 ; terminate list
stosd
; construct the first and only TD
mov edi, [.framelist]
add edi, 32
mov eax, 1 ; link pointer invalid
stosd
; 1 error limit, active, low speed, IOC
mov eax, (1 shl 27) or (1 shl 23) or (1 shl 26) or (1 shl 24)
stosd
; data size and direction
mov eax, [.size]
dec eax
and eax, 7 ; maximum size of interrupt packet for low-speed device
shl eax, 21
movzx ebx, [.address]
shl ebx, 8
or eax, ebx
movzx ebx, [.endpoint]
shl ebx, 15
or eax, ebx
;or eax, 1 shl 19 ; data 1
test [.size], 0x80000000 ; device to host?
jnz .in_packet
.out_packet:
or eax, UHCI_PACKET_OUT
jmp .buffer_dword
.in_packet:
or eax, UHCI_PACKET_IN
.buffer_dword:
stosd
; actual data buffer
mov eax, [.packet]
stosd
mov eax, 0 ; pad out remaining space...
stosd
stosd
stosd
stosd
.send_packet:
;wbinvd
; tell the uhci about the frame list
mov dx, [.io]
in ax, dx
and ax, not UHCI_COMMAND_RUN
out dx, ax
;call iowait
mov dx, [.io]
add dx, UHCI_FRAMELIST
mov eax, [.framelist_phys]
out dx, eax
mov dx, [.io]
add dx, UHCI_FRAME
mov ax, 0
out dx, ax
call iowait
mov dx, [.io]
in ax, dx
or ax, UHCI_COMMAND_RUN
out dx, ax
;call iowait
.wait:
mov dx, [.io]
add dx, UHCI_STATUS
in ax, dx
test ax, UHCI_STATUS_ERROR_INTERRUPT
jnz .interrupt
test ax, UHCI_STATUS_ERROR_PROCESS
jnz .process
test ax, UHCI_STATUS_ERROR_HOST
jnz .host
test ax, UHCI_STATUS_HALTED
jnz .finish
test ax, UHCI_STATUS_INTERRUPT
jnz .finish
jmp .wait
.interrupt:
mov dx, [.io]
in ax, dx
and ax, not UHCI_COMMAND_RUN
out dx, ax
;call iowait
; clear status
mov dx, [.io]
add dx, UHCI_STATUS
mov ax, 0x3F
out dx, ax
;call iowait
;mov esi, .interrupt_msg
;call kprint
mov eax, -1
ret
.host:
mov dx, [.io]
in ax, dx
and ax, not UHCI_COMMAND_RUN
out dx, ax
;call iowait
; clear status
mov dx, [.io]
add dx, UHCI_STATUS
mov ax, 0x3F
out dx, ax
;call iowait
;mov esi, .host_msg
;call kprint
mov eax, -1
ret
.process:
mov dx, [.io]
in ax, dx
and ax, not UHCI_COMMAND_RUN
out dx, ax
;call iowait
; clear status
mov dx, [.io]
add dx, UHCI_STATUS
mov ax, 0x3F
out dx, ax
;call iowait
;mov esi, .process_msg
;call kprint
mov eax, -1
ret
.finish:
mov dx, [.io]
in ax, dx
and ax, not UHCI_COMMAND_RUN
out dx, ax
;call iowait
; clear status
mov dx, [.io]
add dx, UHCI_STATUS
mov ax, 0x3F
out dx, ax
;call iowait
.finish2:
mov eax, 0
ret
align 4
.controller dd 0
.packet dd 0
.size dd 0
.io dw 0
.address db 0
.endpoint db 0
align 4
.framelist dd 0
.framelist_phys dd 0
.interrupt_msg db "usb-uhci: interrupt error in interrupt packet.",10,0
.host_msg db "usb-uhci: host error in interrupt packet.",10,0
.process_msg db "usb-uhci: process error in interrupt packet.",10,0
|
alloy4fun_models/trashltl/models/17/6iXdf9QFAHt9rderz.als
|
Kaixi26/org.alloytools.alloy
| 0 |
1915
|
<reponame>Kaixi26/org.alloytools.alloy
open main
pred id6iXdf9QFAHt9rderz_prop18 {
always all f:Protected | f in Trash releases f not in Protected
}
pred __repair { id6iXdf9QFAHt9rderz_prop18 }
check __repair { id6iXdf9QFAHt9rderz_prop18 <=> prop18o }
|
gcc-gcc-7_3_0-release/gcc/ada/sem_dist.adb
|
best08618/asylo
| 7 |
17927
|
<filename>gcc-gcc-7_3_0-release/gcc/ada/sem_dist.adb
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ D I S T --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Atree; use Atree;
with Casing; use Casing;
with Einfo; use Einfo;
with Errout; use Errout;
with Exp_Dist; use Exp_Dist;
with Exp_Tss; use Exp_Tss;
with Nlists; use Nlists;
with Nmake; use Nmake;
with Namet; use Namet;
with Opt; use Opt;
with Rtsfind; use Rtsfind;
with Sem; use Sem;
with Sem_Aux; use Sem_Aux;
with Sem_Disp; use Sem_Disp;
with Sem_Eval; use Sem_Eval;
with Sem_Res; use Sem_Res;
with Sem_Util; use Sem_Util;
with Sinfo; use Sinfo;
with Stand; use Stand;
with Stringt; use Stringt;
with Tbuild; use Tbuild;
with Uintp; use Uintp;
package body Sem_Dist is
-----------------------
-- Local Subprograms --
-----------------------
procedure RAS_E_Dereference (Pref : Node_Id);
-- Handles explicit dereference of Remote Access to Subprograms
function Full_Qualified_Name (E : Entity_Id) return String_Id;
-- returns the full qualified name of the entity in lower case
-------------------------
-- Add_Stub_Constructs --
-------------------------
procedure Add_Stub_Constructs (N : Node_Id) is
U : constant Node_Id := Unit (N);
Spec : Entity_Id := Empty;
Exp : Node_Id := U;
-- Unit that will be expanded
begin
pragma Assert (Distribution_Stub_Mode /= No_Stubs);
if Nkind (U) = N_Package_Declaration then
Spec := Defining_Entity (Specification (U));
elsif Nkind (U) = N_Package_Body then
Spec := Corresponding_Spec (U);
else pragma Assert (Nkind (U) = N_Package_Instantiation);
Exp := Instance_Spec (U);
Spec := Defining_Entity (Specification (Exp));
end if;
pragma Assert (Is_Shared_Passive (Spec)
or else Is_Remote_Call_Interface (Spec));
if Distribution_Stub_Mode = Generate_Caller_Stub_Body then
if Is_Shared_Passive (Spec) then
null;
elsif Nkind (U) = N_Package_Body then
Error_Msg_N
("Specification file expected from command line", U);
else
Expand_Calling_Stubs_Bodies (Exp);
end if;
else
if Is_Shared_Passive (Spec) then
Build_Passive_Partition_Stub (Exp);
else
Expand_Receiving_Stubs_Bodies (Exp);
end if;
end if;
end Add_Stub_Constructs;
---------------------------------------
-- Build_RAS_Primitive_Specification --
---------------------------------------
function Build_RAS_Primitive_Specification
(Subp_Spec : Node_Id;
Remote_Object_Type : Node_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (Subp_Spec);
Primitive_Spec : constant Node_Id :=
Copy_Specification (Loc,
Spec => Subp_Spec,
New_Name => Name_uCall);
Subtype_Mark_For_Self : Node_Id;
begin
if No (Parameter_Specifications (Primitive_Spec)) then
Set_Parameter_Specifications (Primitive_Spec, New_List);
end if;
if Nkind (Remote_Object_Type) in N_Entity then
Subtype_Mark_For_Self :=
New_Occurrence_Of (Remote_Object_Type, Loc);
else
Subtype_Mark_For_Self := Remote_Object_Type;
end if;
Prepend_To (
Parameter_Specifications (Primitive_Spec),
Make_Parameter_Specification (Loc,
Defining_Identifier =>
Make_Defining_Identifier (Loc, Name_uS),
Parameter_Type =>
Make_Access_Definition (Loc,
Subtype_Mark =>
Subtype_Mark_For_Self)));
-- Trick later semantic analysis into considering this operation as a
-- primitive (dispatching) operation of tagged type Obj_Type.
Set_Comes_From_Source (
Defining_Unit_Name (Primitive_Spec), True);
return Primitive_Spec;
end Build_RAS_Primitive_Specification;
-------------------------
-- Full_Qualified_Name --
-------------------------
function Full_Qualified_Name (E : Entity_Id) return String_Id is
Ent : Entity_Id := E;
Parent_Name : String_Id := No_String;
begin
-- Deals properly with child units
if Nkind (Ent) = N_Defining_Program_Unit_Name then
Ent := Defining_Identifier (Ent);
end if;
-- Compute recursively the qualification (only "Standard" has no scope)
if Present (Scope (Scope (Ent))) then
Parent_Name := Full_Qualified_Name (Scope (Ent));
end if;
-- Every entity should have a name except some expanded blocks. Do not
-- bother about those.
if Chars (Ent) = No_Name then
return Parent_Name;
end if;
-- Add a period between Name and qualification
if Parent_Name /= No_String then
Start_String (Parent_Name);
Store_String_Char (Get_Char_Code ('.'));
else
Start_String;
end if;
-- Generates the entity name in upper case
Get_Name_String (Chars (Ent));
Set_Casing (All_Lower_Case);
Store_String_Chars (Name_Buffer (1 .. Name_Len));
return End_String;
end Full_Qualified_Name;
------------------
-- Get_PCS_Name --
------------------
function Get_PCS_Name return PCS_Names is
begin
return
Chars (Entity (Expression (Parent (RTE (RE_DSA_Implementation)))));
end Get_PCS_Name;
---------------------
-- Get_PCS_Version --
---------------------
function Get_PCS_Version return Int is
PCS_Version_Entity : Entity_Id;
PCS_Version : Int;
begin
if RTE_Available (RE_PCS_Version) then
PCS_Version_Entity := RTE (RE_PCS_Version);
pragma Assert (Ekind (PCS_Version_Entity) = E_Named_Integer);
PCS_Version :=
UI_To_Int (Expr_Value (Constant_Value (PCS_Version_Entity)));
else
-- Case of System.Partition_Interface.PCS_Version not found:
-- return a null version.
PCS_Version := 0;
end if;
return PCS_Version;
end Get_PCS_Version;
------------------------
-- Is_All_Remote_Call --
------------------------
function Is_All_Remote_Call (N : Node_Id) return Boolean is
Par : Node_Id;
begin
if Nkind (N) in N_Subprogram_Call
and then Nkind (Name (N)) in N_Has_Entity
and then Is_Remote_Call_Interface (Entity (Name (N)))
and then Has_All_Calls_Remote (Scope (Entity (Name (N))))
and then Comes_From_Source (N)
then
Par := Parent (Entity (Name (N)));
while Present (Par)
and then (Nkind (Par) /= N_Package_Specification
or else Is_Wrapper_Package (Defining_Entity (Par)))
loop
Par := Parent (Par);
end loop;
if Present (Par) then
return
not Scope_Within_Or_Same (Current_Scope, Defining_Entity (Par));
else
return False;
end if;
else
return False;
end if;
end Is_All_Remote_Call;
---------------------------------
-- Is_RACW_Stub_Type_Operation --
---------------------------------
function Is_RACW_Stub_Type_Operation (Op : Entity_Id) return Boolean is
Typ : Entity_Id;
begin
case Ekind (Op) is
when E_Function
| E_Procedure
=>
Typ := Find_Dispatching_Type (Op);
return
Present (Typ)
and then Is_RACW_Stub_Type (Typ)
and then not Is_Internal (Op);
when others =>
return False;
end case;
end Is_RACW_Stub_Type_Operation;
---------------------------------
-- Is_Valid_Remote_Object_Type --
---------------------------------
function Is_Valid_Remote_Object_Type (E : Entity_Id) return Boolean is
P : constant Node_Id := Parent (E);
begin
pragma Assert (Is_Tagged_Type (E));
-- Simple case: a limited private type
if Nkind (P) = N_Private_Type_Declaration
and then Is_Limited_Record (E)
then
return True;
-- AI05-0060 (Binding Interpretation): A limited interface is a legal
-- ancestor for the designated type of an RACW type.
elsif Is_Limited_Record (E) and then Is_Limited_Interface (E) then
return True;
-- A generic tagged limited type is a valid candidate. Limitedness will
-- be checked again on the actual at instantiation point.
elsif Nkind (P) = N_Formal_Type_Declaration
and then Ekind (E) = E_Record_Type_With_Private
and then Is_Generic_Type (E)
and then Is_Limited_Record (E)
then
return True;
-- A private extension declaration is a valid candidate if its parent
-- type is.
elsif Nkind (P) = N_Private_Extension_Declaration then
return Is_Valid_Remote_Object_Type (Etype (E));
else
return False;
end if;
end Is_Valid_Remote_Object_Type;
------------------------------------
-- Package_Specification_Of_Scope --
------------------------------------
function Package_Specification_Of_Scope (E : Entity_Id) return Node_Id is
N : Node_Id;
begin
N := Parent (E);
while Nkind (N) /= N_Package_Specification loop
N := Parent (N);
end loop;
return N;
end Package_Specification_Of_Scope;
--------------------------
-- Process_Partition_ID --
--------------------------
procedure Process_Partition_Id (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Ety : Entity_Id;
Get_Pt_Id : Node_Id;
Get_Pt_Id_Call : Node_Id;
Prefix_String : String_Id;
Typ : constant Entity_Id := Etype (N);
begin
-- In case prefix is not a library unit entity, get the entity
-- of library unit.
Ety := Entity (Prefix (N));
while (Present (Scope (Ety))
and then Scope (Ety) /= Standard_Standard)
and not Is_Child_Unit (Ety)
loop
Ety := Scope (Ety);
end loop;
-- Retrieve the proper function to call
if Is_Remote_Call_Interface (Ety) then
Get_Pt_Id := New_Occurrence_Of
(RTE (RE_Get_Active_Partition_Id), Loc);
elsif Is_Shared_Passive (Ety) then
Get_Pt_Id := New_Occurrence_Of
(RTE (RE_Get_Passive_Partition_Id), Loc);
else
Get_Pt_Id := New_Occurrence_Of
(RTE (RE_Get_Local_Partition_Id), Loc);
end if;
-- Get and store the String_Id corresponding to the name of the
-- library unit whose Partition_Id is needed.
Get_Library_Unit_Name_String (Unit_Declaration_Node (Ety));
Prefix_String := String_From_Name_Buffer;
-- Build the function call which will replace the attribute
if Is_Remote_Call_Interface (Ety) or else Is_Shared_Passive (Ety) then
Get_Pt_Id_Call :=
Make_Function_Call (Loc,
Name => Get_Pt_Id,
Parameter_Associations =>
New_List (Make_String_Literal (Loc, Prefix_String)));
else
Get_Pt_Id_Call := Make_Function_Call (Loc, Get_Pt_Id);
end if;
-- Replace the attribute node by a conversion of the function call
-- to the target type.
Rewrite (N, Convert_To (Typ, Get_Pt_Id_Call));
Analyze_And_Resolve (N, Typ);
end Process_Partition_Id;
----------------------------------
-- Process_Remote_AST_Attribute --
----------------------------------
procedure Process_Remote_AST_Attribute
(N : Node_Id;
New_Type : Entity_Id)
is
Loc : constant Source_Ptr := Sloc (N);
Remote_Subp : Entity_Id;
Tick_Access_Conv_Call : Node_Id;
Remote_Subp_Decl : Node_Id;
RS_Pkg_Specif : Node_Id;
RS_Pkg_E : Entity_Id;
RAS_Type : Entity_Id := New_Type;
Async_E : Entity_Id;
All_Calls_Remote_E : Entity_Id;
Attribute_Subp : Entity_Id;
begin
-- Check if we have to expand the access attribute
Remote_Subp := Entity (Prefix (N));
if not Expander_Active or else Get_PCS_Name = Name_No_DSA then
return;
end if;
if Ekind (RAS_Type) /= E_Record_Type then
RAS_Type := Equivalent_Type (RAS_Type);
end if;
Attribute_Subp := TSS (RAS_Type, TSS_RAS_Access);
pragma Assert (Present (Attribute_Subp));
Remote_Subp_Decl := Unit_Declaration_Node (Remote_Subp);
if Nkind (Remote_Subp_Decl) = N_Subprogram_Body then
Remote_Subp := Corresponding_Spec (Remote_Subp_Decl);
Remote_Subp_Decl := Unit_Declaration_Node (Remote_Subp);
end if;
RS_Pkg_Specif := Parent (Remote_Subp_Decl);
RS_Pkg_E := Defining_Entity (RS_Pkg_Specif);
Async_E :=
Boolean_Literals (Ekind (Remote_Subp) = E_Procedure
and then Is_Asynchronous (Remote_Subp));
All_Calls_Remote_E :=
Boolean_Literals (Has_All_Calls_Remote (RS_Pkg_E));
Tick_Access_Conv_Call :=
Make_Function_Call (Loc,
Name => New_Occurrence_Of (Attribute_Subp, Loc),
Parameter_Associations =>
New_List (
Make_String_Literal (Loc,
Strval => Full_Qualified_Name (RS_Pkg_E)),
Build_Subprogram_Id (Loc, Remote_Subp),
New_Occurrence_Of (Async_E, Loc),
New_Occurrence_Of (All_Calls_Remote_E, Loc)));
Rewrite (N, Tick_Access_Conv_Call);
Analyze_And_Resolve (N, RAS_Type);
end Process_Remote_AST_Attribute;
------------------------------------
-- Process_Remote_AST_Declaration --
------------------------------------
procedure Process_Remote_AST_Declaration (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
User_Type : constant Node_Id := Defining_Identifier (N);
Scop : constant Entity_Id := Scope (User_Type);
Is_RCI : constant Boolean := Is_Remote_Call_Interface (Scop);
Is_RT : constant Boolean := Is_Remote_Types (Scop);
Type_Def : constant Node_Id := Type_Definition (N);
Parameter : Node_Id;
Is_Degenerate : Boolean;
-- True iff this RAS has an access formal parameter (see
-- Exp_Dist.Add_RAS_Dereference_TSS for details).
Subpkg : constant Entity_Id := Make_Temporary (Loc, 'S');
Subpkg_Decl : Node_Id;
Subpkg_Body : Node_Id;
Vis_Decls : constant List_Id := New_List;
Priv_Decls : constant List_Id := New_List;
Obj_Type : constant Entity_Id :=
Make_Defining_Identifier (Loc,
New_External_Name (Chars (User_Type), 'R'));
Full_Obj_Type : constant Entity_Id :=
Make_Defining_Identifier (Loc, Chars (Obj_Type));
RACW_Type : constant Entity_Id :=
Make_Defining_Identifier (Loc,
New_External_Name (Chars (User_Type), 'P'));
Fat_Type : constant Entity_Id :=
Make_Defining_Identifier (Loc, Chars (User_Type));
Fat_Type_Decl : Node_Id;
begin
Is_Degenerate := False;
Parameter := First (Parameter_Specifications (Type_Def));
while Present (Parameter) loop
if Nkind (Parameter_Type (Parameter)) = N_Access_Definition then
Error_Msg_N
("formal parameter& has anonymous access type??",
Defining_Identifier (Parameter));
Is_Degenerate := True;
exit;
end if;
Next (Parameter);
end loop;
if Is_Degenerate then
Error_Msg_NE
("remote access-to-subprogram type& can only be null??",
Defining_Identifier (Parameter), User_Type);
-- The only legal value for a RAS with a formal parameter of an
-- anonymous access type is null, because it cannot be subtype-
-- conformant with any legal remote subprogram declaration. In this
-- case, we cannot generate a corresponding primitive operation.
end if;
if Get_PCS_Name = Name_No_DSA then
return;
end if;
-- The tagged private type, primitive operation and RACW type associated
-- with a RAS need to all be declared in a subpackage of the one that
-- contains the RAS declaration, because the primitive of the object
-- type, and the associated primitive of the stub type, need to be
-- dispatching operations of these types, and the profile of the RAS
-- might contain tagged types declared in the same scope.
Append_To (Vis_Decls,
Make_Private_Type_Declaration (Loc,
Defining_Identifier => Obj_Type,
Abstract_Present => True,
Tagged_Present => True,
Limited_Present => True));
Append_To (Priv_Decls,
Make_Full_Type_Declaration (Loc,
Defining_Identifier => Full_Obj_Type,
Type_Definition =>
Make_Record_Definition (Loc,
Abstract_Present => True,
Tagged_Present => True,
Limited_Present => True,
Null_Present => True,
Component_List => Empty)));
-- Trick semantic analysis into swapping the public and full view when
-- freezing the public view.
Set_Comes_From_Source (Full_Obj_Type, True);
if not Is_Degenerate then
Append_To (Vis_Decls,
Make_Abstract_Subprogram_Declaration (Loc,
Specification => Build_RAS_Primitive_Specification (
Subp_Spec => Type_Def,
Remote_Object_Type => Obj_Type)));
end if;
Append_To (Vis_Decls,
Make_Full_Type_Declaration (Loc,
Defining_Identifier => RACW_Type,
Type_Definition =>
Make_Access_To_Object_Definition (Loc,
All_Present => True,
Subtype_Indication =>
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Obj_Type, Loc),
Attribute_Name => Name_Class))));
Set_Is_Remote_Call_Interface (RACW_Type, Is_RCI);
Set_Is_Remote_Types (RACW_Type, Is_RT);
Subpkg_Decl :=
Make_Package_Declaration (Loc,
Make_Package_Specification (Loc,
Defining_Unit_Name => Subpkg,
Visible_Declarations => Vis_Decls,
Private_Declarations => Priv_Decls,
End_Label => New_Occurrence_Of (Subpkg, Loc)));
Set_Is_Remote_Call_Interface (Subpkg, Is_RCI);
Set_Is_Remote_Types (Subpkg, Is_RT);
Insert_After_And_Analyze (N, Subpkg_Decl);
-- Generate package body to receive RACW calling stubs
-- Note: Analyze_Declarations has an absolute requirement that the
-- declaration list be non-empty, so provide dummy null statement here.
Subpkg_Body :=
Make_Package_Body (Loc,
Defining_Unit_Name => Make_Defining_Identifier (Loc, Chars (Subpkg)),
Declarations => New_List (Make_Null_Statement (Loc)));
Insert_After_And_Analyze (Subpkg_Decl, Subpkg_Body);
-- Many parts of the analyzer and expander expect
-- that the fat pointer type used to implement remote
-- access to subprogram types be a record.
-- Note: The structure of this type must be kept consistent
-- with the code generated by Remote_AST_Null_Value for the
-- corresponding 'null' expression.
Fat_Type_Decl := Make_Full_Type_Declaration (Loc,
Defining_Identifier => Fat_Type,
Type_Definition =>
Make_Record_Definition (Loc,
Component_List =>
Make_Component_List (Loc,
Component_Items => New_List (
Make_Component_Declaration (Loc,
Defining_Identifier =>
Make_Defining_Identifier (Loc, Name_Ras),
Component_Definition =>
Make_Component_Definition (Loc,
Aliased_Present => False,
Subtype_Indication =>
New_Occurrence_Of (RACW_Type, Loc)))))));
Set_Equivalent_Type (User_Type, Fat_Type);
-- Set Fat_Type's Etype early so that we can use its
-- Corresponding_Remote_Type attribute, whose presence indicates that
-- this is the record type used to implement a RAS.
Set_Ekind (Fat_Type, E_Record_Type);
Set_Corresponding_Remote_Type (Fat_Type, User_Type);
Insert_After_And_Analyze (Subpkg_Body, Fat_Type_Decl);
-- The reason we suppress the initialization procedure is that we know
-- that no initialization is required (even if Initialize_Scalars mode
-- is active), and there are order of elaboration problems if we do try
-- to generate an init proc for this created record type.
Set_Suppress_Initialization (Fat_Type);
if Expander_Active then
Add_RAST_Features (Parent (User_Type));
end if;
end Process_Remote_AST_Declaration;
-----------------------
-- RAS_E_Dereference --
-----------------------
procedure RAS_E_Dereference (Pref : Node_Id) is
Loc : constant Source_Ptr := Sloc (Pref);
Call_Node : Node_Id;
New_Type : constant Entity_Id := Etype (Pref);
Explicit_Deref : constant Node_Id := Parent (Pref);
Deref_Subp_Call : constant Node_Id := Parent (Explicit_Deref);
Deref_Proc : Entity_Id;
Params : List_Id;
begin
if Nkind (Deref_Subp_Call) = N_Procedure_Call_Statement then
Params := Parameter_Associations (Deref_Subp_Call);
if Present (Params) then
Prepend (Pref, Params);
else
Params := New_List (Pref);
end if;
elsif Nkind (Deref_Subp_Call) = N_Indexed_Component then
Params := Expressions (Deref_Subp_Call);
if Present (Params) then
Prepend (Pref, Params);
else
Params := New_List (Pref);
end if;
else
-- Context is not a call
return;
end if;
if not Expander_Active or else Get_PCS_Name = Name_No_DSA then
return;
end if;
Deref_Proc := TSS (New_Type, TSS_RAS_Dereference);
pragma Assert (Present (Deref_Proc));
if Ekind (Deref_Proc) = E_Function then
Call_Node :=
Make_Function_Call (Loc,
Name => New_Occurrence_Of (Deref_Proc, Loc),
Parameter_Associations => Params);
else
Call_Node :=
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (Deref_Proc, Loc),
Parameter_Associations => Params);
end if;
Rewrite (Deref_Subp_Call, Call_Node);
Analyze (Deref_Subp_Call);
end RAS_E_Dereference;
------------------------------
-- Remote_AST_E_Dereference --
------------------------------
function Remote_AST_E_Dereference (P : Node_Id) return Boolean is
ET : constant Entity_Id := Etype (P);
begin
-- Perform the changes only on original dereferences, and only if
-- we are generating code.
if Comes_From_Source (P)
and then Is_Record_Type (ET)
and then (Is_Remote_Call_Interface (ET)
or else Is_Remote_Types (ET))
and then Present (Corresponding_Remote_Type (ET))
and then Nkind_In (Parent (Parent (P)), N_Procedure_Call_Statement,
N_Indexed_Component)
and then Expander_Active
then
RAS_E_Dereference (P);
return True;
else
return False;
end if;
end Remote_AST_E_Dereference;
------------------------------
-- Remote_AST_I_Dereference --
------------------------------
function Remote_AST_I_Dereference (P : Node_Id) return Boolean is
ET : constant Entity_Id := Etype (P);
Deref : Node_Id;
begin
if Comes_From_Source (P)
and then (Is_Remote_Call_Interface (ET)
or else Is_Remote_Types (ET))
and then Present (Corresponding_Remote_Type (ET))
and then Ekind (Entity (P)) /= E_Function
then
Deref :=
Make_Explicit_Dereference (Sloc (P),
Prefix => Relocate_Node (P));
Rewrite (P, Deref);
Set_Etype (P, ET);
RAS_E_Dereference (Prefix (P));
return True;
end if;
return False;
end Remote_AST_I_Dereference;
---------------------------
-- Remote_AST_Null_Value --
---------------------------
function Remote_AST_Null_Value
(N : Node_Id;
Typ : Entity_Id) return Boolean
is
Loc : constant Source_Ptr := Sloc (N);
Target_Type : Entity_Id;
begin
if not Expander_Active or else Get_PCS_Name = Name_No_DSA then
return False;
elsif Ekind (Typ) = E_Access_Subprogram_Type
and then (Is_Remote_Call_Interface (Typ)
or else Is_Remote_Types (Typ))
and then Comes_From_Source (N)
and then Expander_Active
then
-- Any null that comes from source and is of the RAS type must
-- be expanded, except if expansion is not active (nothing
-- gets expanded into the equivalent record type).
Target_Type := Equivalent_Type (Typ);
elsif Ekind (Typ) = E_Record_Type
and then Present (Corresponding_Remote_Type (Typ))
then
-- This is a record type representing a RAS type, this must be
-- expanded.
Target_Type := Typ;
else
-- We do not have to handle this case
return False;
end if;
Rewrite (N,
Make_Aggregate (Loc,
Component_Associations => New_List (
Make_Component_Association (Loc,
Choices => New_List (Make_Identifier (Loc, Name_Ras)),
Expression => Make_Null (Loc)))));
Analyze_And_Resolve (N, Target_Type);
return True;
end Remote_AST_Null_Value;
end Sem_Dist;
|
hmi_sdk/hmi_sdk/Tools/ffmpeg-2.6.2/libavcodec/x86/mpegvideoencdsp.asm
|
APCVSRepo/android_packet
| 4 |
90285
|
<reponame>APCVSRepo/android_packet<gh_stars>1-10
;*****************************************************************************
;* SIMD-optimized MPEG encoding functions
;*****************************************************************************
;* Copyright (c) 2000, 2001 <NAME>
;* Copyright (c) 2002-2004 <NAME> <<EMAIL>>
;*
;* This file is part of FFmpeg.
;*
;* FFmpeg is free software; you can redistribute it and/or
;* modify it under the terms of the GNU Lesser General Public
;* License as published by the Free Software Foundation; either
;* version 2.1 of the License, or (at your option) any later version.
;*
;* FFmpeg is distributed in the hope that it will be useful,
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;* Lesser General Public License for more details.
;*
;* You should have received a copy of the GNU Lesser General Public
;* License along with FFmpeg; if not, write to the Free Software
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;*****************************************************************************
%include "libavutil/x86/x86util.asm"
SECTION_RODATA
cextern pw_1
SECTION .text
; int ff_pix_sum16_mmx(uint8_t *pix, int line_size)
; %1 = number of loops
; %2 = number of GPRs used
%macro PIX_SUM16 3
cglobal pix_sum16, 2, %2, 6
movsxdifnidn r1, r1d
mov r2, %1
%if mmsize == 16
lea r3, [r1*3]
%endif
%if notcpuflag(xop)
pxor m5, m5
%endif
pxor m4, m4
.loop:
%if cpuflag(xop)
vphaddubq m0, [r0]
vphaddubq m1, [r0+r1]
vphaddubq m2, [r0+r1*2]
vphaddubq m3, [r0+r3]
%else
mova m0, [r0]
%if mmsize == 8
mova m1, [r0+8]
%if cpuflag(mmxext)
mova m2, [r0+r1]
mova m3, [r0+r1+8]
%endif
%else ; sse2
mova m1, [r0+r1]
mova m2, [r0+r1*2]
mova m3, [r0+r3]
%endif
%if cpuflag(mmxext)
psadbw m0, m5
psadbw m1, m5
psadbw m2, m5
psadbw m3, m5
%else ; mmx
punpckhbw m2, m0, m5
punpcklbw m0, m5
punpckhbw m3, m1, m5
punpcklbw m1, m5
%endif ; cpuflag(mmxext)
%endif ; cpuflag(xop)
paddw m1, m0
paddw m3, m2
paddw m3, m1
paddw m4, m3
%if cpuflag(mmxext)
lea r0, [r0+r1*%3]
%else
add r0, r1
%endif
dec r2
jne .loop
%if mmsize == 16
pshufd m0, m4, q0032
paddd m4, m0
%elif notcpuflag(mmxext)
HADDW m4, m5
%endif
movd eax, m4
RET
%endmacro
%if ARCH_X86_32
INIT_MMX mmx
PIX_SUM16 16, 3, 0
INIT_MMX mmxext
PIX_SUM16 8, 4, 2
%endif
INIT_XMM sse2
PIX_SUM16 4, 4, 4
%if HAVE_XOP_EXTERNAL
INIT_XMM xop
PIX_SUM16 4, 4, 4
%endif
; int ff_pix_norm1_mmx(uint8_t *pix, int line_size)
; %1 = number of xmm registers used
; %2 = number of loops
%macro PIX_NORM1 2
cglobal pix_norm1, 2, 3, %1
movsxdifnidn r1, r1d
mov r2, %2
pxor m0, m0
pxor m5, m5
.loop:
mova m2, [r0+0]
%if mmsize == 8
mova m3, [r0+8]
%else
mova m3, [r0+r1]
%endif
punpckhbw m1, m2, m0
punpcklbw m2, m0
punpckhbw m4, m3, m0
punpcklbw m3, m0
pmaddwd m1, m1
pmaddwd m2, m2
pmaddwd m3, m3
pmaddwd m4, m4
paddd m2, m1
paddd m4, m3
paddd m5, m2
paddd m5, m4
%if mmsize == 8
add r0, r1
%else
lea r0, [r0+r1*2]
%endif
dec r2
jne .loop
HADDD m5, m1
movd eax, m5
RET
%endmacro
INIT_MMX mmx
PIX_NORM1 0, 16
INIT_XMM sse2
PIX_NORM1 6, 8
|
masm/8_offset.asm
|
oceanwavechina/assembly
| 0 |
13712
|
<gh_stars>0
; 这段代码是演示如何使用常量偏移地址进行内存数据访问
; 这个使用的场景是两个数组长度相等时比较有用
assume cs:code,ds:data
; 定义数据段,开辟空间
data segment
db 'BaSiC' ; 相当于 db 75h,6eh,49h,58h, 要把这个转为大写
db 'iNfoR' ; 把这个转为小写
data ends
code segment
start:
mov ax, data ;
mov dx, ax ; 以上两句是设置数据段基地址
mov bx, 0 ; 数据指针重置, 到此,数据区的指针就设置完了
mov cx, 5 ; 循环5次
s:
mov al, 0[bx] ; 这个等同于 [bx+0]
add al, 11011111B ; 从低到高有效位,第5位为0时是大写
mov [bx], al ; 转化好了就返回数据段中,覆盖掉内存中原来的值
mov al, 5[bx] ; 处理第二个数组
or al, 00100000B
mov 5[bx], al
inc bx ; 移动到数组中下一个位置
loop s
mov ax, 4c00h
int 21h
code ends
end start
|
boards/stm32f0disco/stm32gd-board.ads
|
ekoeppen/STM32_Generic_Ada_Drivers
| 1 |
7832
|
with STM32GD.GPIO; use STM32GD.GPIO;
with STM32GD.GPIO.Pin;
with STM32GD.USART;
with STM32GD.USART.Peripheral;
with STM32GD.RTC;
with STM32GD.Clock;
with STM32GD.Clock.Tree;
with Drivers.Text_IO;
package STM32GD.Board is
package CLOCKS is new STM32GD.Clock.Tree;
package GPIO renames STM32GD.GPIO;
package SCLK is new GPIO.Pin (Pin => GPIO.Pin_5, Port => GPIO.Port_A, Mode => GPIO.Mode_AF);
package MISO is new GPIO.Pin (Pin => GPIO.Pin_6, Port => GPIO.Port_A, Mode => GPIO.Mode_AF);
package MOSI is new GPIO.Pin (Pin => GPIO.Pin_7, Port => GPIO.Port_A, Mode => GPIO.Mode_AF);
package CSN is new GPIO.Pin (Pin => GPIO.Pin_4, Port => GPIO.Port_A, Mode => GPIO.Mode_Out);
package BUTTON is new GPIO.Pin (Pin => GPIO.Pin_0, Port => GPIO.Port_A);
package LED is new GPIO.Pin (Pin => GPIO.Pin_8, Port => GPIO.Port_C, Mode => GPIO.Mode_Out);
package LED2 is new GPIO.Pin (Pin => GPIO.Pin_9, Port => GPIO.Port_C, Mode => GPIO.Mode_Out);
package TX is new GPIO.Pin (Pin => GPIO.Pin_9, Port => GPIO.Port_A, Pull_Resistor => GPIO.Pull_Up, Mode => GPIO.Mode_AF, Alternate_Function => 1);
package RX is new GPIO.Pin (Pin => GPIO.Pin_10, Port => GPIO.Port_A, Pull_Resistor => GPIO.Pull_Up, Mode => GPIO.Mode_AF, Alternate_Function => 1);
package USART is new STM32GD.USART.Peripheral (USART => STM32GD.USART.USART_1, Speed => 115200, RX_DMA_Buffer_Size => 64,
Clock_Tree => CLOCKS, Clock => STM32GD.Clock.PCLK);
package RTC is new STM32GD.RTC (Clock_Tree => STM32GD.Board.Clocks, Clock => STM32GD.Clock.LSI);
package Text_IO is new Drivers.Text_IO (USART => STM32GD.Board.USART);
procedure Init;
end STM32GD.Board;
|
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_2378.asm
|
ljhsiun2/medusa
| 9 |
178009
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r13
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x122d8, %r13
nop
nop
nop
nop
and $11159, %rsi
and $0xffffffffffffffc0, %r13
movntdqa (%r13), %xmm7
vpextrq $0, %xmm7, %r10
nop
nop
nop
and $10393, %r12
lea addresses_D_ht+0x6e2a, %rsi
lea addresses_UC_ht+0x1c234, %rdi
clflush (%rdi)
nop
inc %rdx
mov $51, %rcx
rep movsb
nop
nop
nop
nop
add $21749, %r13
lea addresses_D_ht+0x1b768, %rsi
lea addresses_D_ht+0x10f9c, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
inc %r8
mov $6, %rcx
rep movsl
nop
nop
xor %rcx, %rcx
lea addresses_WT_ht+0x187d8, %rsi
lea addresses_D_ht+0x16438, %rdi
nop
nop
nop
sub $17180, %rdx
mov $92, %rcx
rep movsl
nop
nop
nop
sub $23317, %r8
lea addresses_A_ht+0x18690, %r12
nop
add $36713, %r13
mov $0x6162636465666768, %rsi
movq %rsi, %xmm7
vmovups %ymm7, (%r12)
nop
nop
lfence
lea addresses_A_ht+0x4d50, %rsi
lea addresses_normal_ht+0x1e214, %rdi
clflush (%rdi)
nop
cmp %r8, %r8
mov $30, %rcx
rep movsq
sub %r13, %r13
lea addresses_normal_ht+0x19c58, %r13
nop
nop
nop
nop
sub %r8, %r8
movw $0x6162, (%r13)
nop
nop
nop
nop
nop
dec %r13
lea addresses_normal_ht+0xbf58, %r13
nop
nop
nop
nop
add %r12, %r12
movl $0x61626364, (%r13)
nop
nop
nop
nop
inc %rcx
lea addresses_normal_ht+0x18ed8, %rsi
lea addresses_A_ht+0x67a0, %rdi
nop
nop
nop
and %rdx, %rdx
mov $24, %rcx
rep movsb
nop
sub $10142, %r13
lea addresses_A_ht+0x16ed8, %r10
nop
nop
nop
cmp %rsi, %rsi
and $0xffffffffffffffc0, %r10
movntdqa (%r10), %xmm4
vpextrq $0, %xmm4, %r8
nop
nop
nop
nop
sub %rdi, %rdi
lea addresses_WT_ht+0x9e80, %rsi
lea addresses_D_ht+0x1340, %rdi
add $51971, %r13
mov $58, %rcx
rep movsq
nop
nop
nop
nop
add %r10, %r10
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r13
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r14
push %r8
push %r9
push %rbp
push %rdi
push %rdx
// Store
lea addresses_PSE+0xc758, %r9
nop
nop
nop
nop
dec %rdx
mov $0x5152535455565758, %rbp
movq %rbp, (%r9)
sub %rdi, %rdi
// Store
lea addresses_D+0xed8, %rbp
nop
nop
cmp $6022, %r10
mov $0x5152535455565758, %r8
movq %r8, %xmm5
movups %xmm5, (%rbp)
nop
sub $57985, %r9
// Faulty Load
lea addresses_UC+0x1ded8, %r9
add %r10, %r10
movups (%r9), %xmm1
vpextrq $0, %xmm1, %r8
lea oracles, %r9
and $0xff, %r8
shlq $12, %r8
mov (%r9,%r8,1), %r8
pop %rdx
pop %rdi
pop %rbp
pop %r9
pop %r8
pop %r14
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_UC', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_PSE', 'same': False, 'size': 8, 'congruent': 7, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_D', 'same': False, 'size': 16, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_UC', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 16, 'congruent': 9, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 32, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 2, 'congruent': 7, 'NT': True, 'AVXalign': True}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_normal_ht', 'same': True, 'size': 4, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_A_ht', 'same': False, 'size': 16, 'congruent': 11, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': True}, 'dst': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM'}
{'37': 21829}
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
*/
|
alloy4fun_models/trainstlt/models/2/HPFEFFafMGiKbrgiR.als
|
Kaixi26/org.alloytools.alloy
| 0 |
4024
|
open main
pred idHPFEFFafMGiKbrgiR_prop3 {
always ~pos.pos in iden and (always all t : Train | lone t.pos)
}
pred __repair { idHPFEFFafMGiKbrgiR_prop3 }
check __repair { idHPFEFFafMGiKbrgiR_prop3 <=> prop3o }
|
oeis/312/A312507.asm
|
neoneye/loda-programs
| 11 |
242301
|
<filename>oeis/312/A312507.asm
; A312507: Coordination sequence Gal.6.245.1 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
; Submitted by <NAME>
; 1,4,8,14,18,22,28,32,36,42,46,50,54,58,64,68,72,78,82,86,92,96,100,104,108,114,118,122,128,132,136,142,146,150,154,158,164,168,172,178,182,186,192,196,200,204,208,214,218,222
mov $1,1
mov $4,$0
mov $5,$0
lpb $0
mov $0,3
mul $0,$4
mov $2,$4
mod $2,11
add $0,$2
div $0,11
mov $1,$0
lpe
mov $3,$5
mul $3,4
add $1,$3
add $0,$1
|
programs/oeis/016/A016924.asm
|
neoneye/loda
| 22 |
244027
|
; A016924: a(n) = (6*n + 1)^4.
; 1,2401,28561,130321,390625,923521,1874161,3418801,5764801,9150625,13845841,20151121,28398241,38950081,52200625,68574961,88529281,112550881,141158161,174900625,214358881,260144641,312900721,373301041,442050625,519885601,607573201,705911761,815730721,937890625,1073283121,1222830961,1387488001,1568239201,1766100625,1982119441,2217373921,2472973441,2750058481,3049800625,3373402561,3722098081,4097152081,4499860561,4931550625,5393580481,5887339441,6414247921,6975757441,7573350625,8208541201,8882874001,9597924961,10355301121,11156640625,12003612721,12897917761,13841287201,14835483601,15882300625,16983563041,18141126721,19356878641,20632736881,21970650625,23372600161,24840596881,26376683281,27982932961,29661450625,31414372081,33243864241,35152125121,37141383841,39213900625,41371966801,43617904801,45954068161,48382841521,50906640625,53527912321,56249134561,59072816401,62001498001,65037750625,68184176641,71443409521,74818113841,78310985281,81924750625,85662167761,89526025681,93519144481,97644375361,101904600625,106302733681,110841719041,115524532321,120354180241,125333700625
mul $0,6
mov $1,1
add $1,$0
pow $1,4
mov $0,$1
|
8085_programming/YT/sum_of_dig_8bit.asm
|
SayanGhoshBDA/code-backup
| 16 |
94021
|
<filename>8085_programming/YT/sum_of_dig_8bit.asm
LXI H,2060
MOV A,M
ANI 0F
MOV C,A
MOV A,M
ANI F0
RLC
RLC
RLC
RLC
ADD C
STA 2070
HLT
# ORG 2060H
# DB 5FH
|
oeis/279/A279020.asm
|
neoneye/loda-programs
| 11 |
170782
|
<reponame>neoneye/loda-programs
; A279020: a(n) = unreduced numerator in Sum_{k=1..n} (-1)^(k-1)/k^k.
; Submitted by <NAME>
; 0,1,3,85,21652,67690148,3158065145088,2600806474859606784,43634288683151793919033344,16904817514490272003065681518985216,169048175123324778807714958980684133171200000,48231417258392463006590622244366007983063473271603200000,430036161037513649606447909421326177816432194528157598355764019200000,130247248112760771998187349871411962569460146886959847360320203084990342863257600000,1447308310039145950186558990089114905010252885787635582959021846075641962367954296672303552921600000
mov $2,1
lpb $0
mov $1,$0
sub $0,1
pow $1,$1
mul $3,$1
div $3,-1
add $3,$2
mul $2,$1
lpe
mov $0,$3
|
oeis/228/A228832.asm
|
neoneye/loda-programs
| 11 |
167988
|
; A228832: Triangle defined by T(n,k) = binomial(n*k, k^2), for n>=0, k=0..n, as read by rows.
; Submitted by <NAME>
; 1,1,1,1,2,1,1,3,15,1,1,4,70,220,1,1,5,210,5005,4845,1,1,6,495,48620,735471,142506,1,1,7,1001,293930,30421755,183579396,5245786,1,1,8,1820,1307504,601080390,40225345056,69668534468,231917400,1,1,9,3060,4686825,7307872110,3169870830126,96926348578605,37387265592825,11969016345,1,1,10,4845,14307150,62852101650,126410606437752,36052387482172425,385439532530137800,26958221130508525,706252528630,1,1,11,7315,38567100,416714805914,3085851035479212,5516694892996182896,782835210292031251300
lpb $0
add $1,1
sub $0,$1
lpe
mul $1,$0
pow $0,2
bin $1,$0
mov $0,$1
|
week_7/dataset/Assembly/056597.asm
|
Dumebi35/DumebiCSC102
| 0 |
103852
|
<reponame>Dumebi35/DumebiCSC102<gh_stars>0
Title Chapt 7 (7.8.1) Ex 4: Room Schedule
; Using a room schedule record, query a bit-mapped field
; called roomstatus. Extract the individual subfields
; from roomstatus.
; -------------- Field Format------------------
; Bit
; Position Usage
; 0-1 Type of room (0,1,2,3)
; 2-7 Number of seats (0-63)
; 8-12 Department ID (0-31)
; 13 Overhead Projector (0,1)
; 14 Blackboard (0,1)
; 15 P.A. System (0,1)
.Model small
.Stack 100h
.data
RoomStatus dw 0110011101011101b
RoomType db ?
NumSeats db ?
DeptID db ?
Projector db ?
BlackBoard db ?
PASystem db ?
typeCheck db 03h ; to AND the room status
SeatsOffset db 02h ; Seats begins 2 bits from beginning
SeatCheck dw 3Fh ; To AND the number of seats
DeptOffset db 06h ; Department ID begins 8 bits from
;beginning
DeptCheck dw 07h ; to AND the Department ID
ProjectorOffs db 05h ; 13 bits to the projector position
ProjectorCheck dw 01h ; Value to test projector
BlackBOffset db 01h
BlackboardCk dw 01h
.Code
Main Proc
mov ax, @data ; initialize the data segment so the
;program
mov ds, ax ; can find the variables
mov ax, RoomStatus ; Load the Room status info into ax
ExtractType:
push ax ; Save the ax register for next step
and al, TypeCheck ; Extract the room type
mov Roomtype, al ; and save the result in the variable
pop ax ; restore ax to original value
ExtractSeats:
mov cl, SeatsOffset ; cx contains number of bits from bit 0
shr ax, cl ; move the seats information into al
push ax ; save ax for the next step
and ax, SeatCheck ; AND al with 00111111b to clear high
;bits
mov NumSeats, al ; place the value into NumSeats
pop ax ; restore ax to it's original value
ExtractDept:
mov cl, DeptOffset ; cx contains the number of bits from 0
;the department begins
shr ax, cl ; move the department ID into al
push ax
and ax, DeptCheck ; AND al with 00000111b to extract Dept
;ID
mov DeptID, al ; store the value of Dept ID in the
;variable
pop ax
ExtractProjector:
mov cl, ProjectorOffs ; bits from start of string to Projector
;position
shr ax, cl ; move projector into position
push ax ; save ax for the next step
and ax, ProjectorCheck ; extract the projector bit
mov Projector, al ; and save the value
pop ax ; restore ax
ExtractBlackBoard:
shr ax, 1 ; move the blackboard value into
;position
push ax
and ax, Blackboardck ; Extract the blackboard value
mov Blackboard, al ; and save in the variable
pop ax
ExtractPA:
shr ax, 1 ; move the PA bit into position
mov PASystem, al ; and store it in the variable
Exit:
mov ax, 4C00h ;load the terminate function
Int 21h ;and end the program
Main Endp
End Main
|
savefile/maps/3B31_LostWoodsSubB_Fun.asm
|
stranck/fools2018-1
| 35 |
241965
|
<filename>savefile/maps/3B31_LostWoodsSubB_Fun.asm
SECTION "Map_3B31_Fun", ROM0[$B800]
Map_3B31_Fun_Header:
hdr_tileset 0
hdr_dimensions 7, 7
hdr_pointers_a Map_3B31_Fun_Blocks, Map_3B31_Fun_TextPointers
hdr_pointers_b Map_3B31_Fun_Script, Map_3B31_Fun_Objects
hdr_pointers_c Map_3B31_Fun_InitScript, Map_3B31_Fun_RAMScript
hdr_palette $06
hdr_music MUSIC_DUNGEON2, AUDIO_3
hdr_connection NORTH, $0000, 0, 0
hdr_connection SOUTH, $3B22, 7, 1
hdr_connection WEST, $3A3E, 0, 0
hdr_connection EAST, $0000, 0, 0
Map_3B31_Fun_Objects:
hdr_border $0f
hdr_warp_count 0
hdr_sign_count 1
hdr_signpost 4, 9, $02
hdr_object_count 1
hdr_object SPRITE_GIRL, 7, 6, STAY, NONE, $01
Map_3B31_Fun_RAMScript:
rs_write_1 $c770, $7a
rs_write_1 $c77d, $7a
rs_end
Map_3B31_Fun_Blocks:
db $0b,$0b,$0b,$0b,$0b,$0b,$0b
db $0b,$62,$6c,$6c,$6c,$63,$0b
db $0b,$6d,$7a,$7a,$7a,$6e,$0b
db $0b,$6d,$7a,$7a,$7a,$6e,$0b
db $0b,$6d,$41,$7a,$7a,$6e,$0b
db $0b,$50,$52,$7a,$52,$4f,$0b
db $0b,$0b,$0f,$7a,$0f,$0b,$0b
Map_3B31_Fun_TextPointers:
dw Map_3B31_Fun_TX1
dw Map_3B31_Fun_TX2
Map_3B31_Fun_InitScript:
ld a, 4
ld [$c109], a
ret
Map_3B31_Fun_ChangeDirFlag:
db 32
Map_3B31_Fun_Script:
ld a, [Map_3B31_Fun_ChangeDirFlag]
and a
ret z
ld a, 4
ld [$c109], a
ld hl, Map_3B31_Fun_ChangeDirFlag
dec [hl]
ret
Map_3B31_Fun_TX1:
TX_ASM
jp EnhancedTextOnly
text "This place was just filled"
next "with treasure, but I got"
cont "here first."
para "What a bummer!"
next "Haha! At least you tried!"
done
Map_3B31_Fun_TX2:
TX_ASM
jp EnhancedTextOnly
text "A random pillar. There's a"
next "piece of paper attached."
para "It looks like a scoreboard,"
next "counting wins between two"
cont "people in a best-of-25"
cont "match."
para "The match was never finished,"
next "but it came close, with 24"
cont "wins on one side."
para "That doesn't make any sense."
next "Welcome to Fidei."
done
|
Transynther/x86/_processed/US/_ht_st_zr_un_/i3-7100_9_0x84_notsx.log_21829_2767.asm
|
ljhsiun2/medusa
| 9 |
164860
|
<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r14
push %r9
push %rdi
lea addresses_normal_ht+0x181bd, %r13
nop
nop
dec %r9
mov (%r13), %r14
nop
nop
nop
nop
and $64889, %rdi
pop %rdi
pop %r9
pop %r14
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r14
push %r15
push %r8
push %rbp
push %rbx
push %rdi
// Load
lea addresses_D+0xf9bd, %rbx
and %r8, %r8
mov (%rbx), %r15d
nop
nop
nop
xor $22515, %r8
// Store
lea addresses_D+0x723d, %rbp
nop
nop
xor %r11, %r11
movl $0x51525354, (%rbp)
nop
nop
nop
cmp %rbp, %rbp
// Store
mov $0x9ee, %rbp
nop
nop
nop
inc %rdi
mov $0x5152535455565758, %r14
movq %r14, %xmm4
vmovups %ymm4, (%rbp)
xor %r11, %r11
// Store
lea addresses_A+0x19dbd, %rbp
nop
nop
nop
nop
nop
add $16404, %r14
mov $0x5152535455565758, %r15
movq %r15, (%rbp)
nop
nop
dec %rdi
// Store
lea addresses_D+0x1b39d, %r15
nop
cmp $22494, %rbp
movb $0x51, (%r15)
nop
nop
nop
cmp $45819, %r8
// Faulty Load
lea addresses_US+0xb9bd, %rbx
xor %r15, %r15
mov (%rbx), %r14
lea oracles, %rbx
and $0xff, %r14
shlq $12, %r14
mov (%rbx,%r14,1), %r14
pop %rdi
pop %rbx
pop %rbp
pop %r8
pop %r15
pop %r14
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_US', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D', 'same': False, 'size': 4, 'congruent': 11, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D', 'same': False, 'size': 4, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_P', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_A', 'same': False, 'size': 8, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_D', 'same': False, 'size': 1, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_US', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 8, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'60': 253, '1a': 3, '44': 1215, '67': 523, '9f': 91, '6d': 6, '50': 1677, '3c': 752, '36': 1, '46': 119, '00': 17183, 'c0': 6}
9f 00 00 50 00 00 00 67 00 00 67 00 00 00 00 00 00 00 44 00 00 50 00 00 9f 00 00 00 00 50 44 00 00 00 00 00 44 50 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 44 00 00 00 00 00 00 00 67 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 44 00 50 00 00 00 00 00 00 00 00 9f 44 00 00 00 00 00 00 00 00 00 00 00 44 44 00 00 00 00 00 00 44 44 00 00 00 00 44 00 00 00 00 00 00 00 00 00 44 00 50 00 00 00 00 44 00 46 50 00 00 00 67 00 50 00 3c 44 00 00 00 50 44 00 3c 00 00 3c 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 50 00 00 00 50 00 00 3c 00 00 00 00 00 00 00 00 00 00 00 44 00 00 67 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 44 00 50 00 00 00 00 9f 00 44 50 00 00 00 00 44 00 00 3c 00 3c 00 3c 00 00 00 00 3c 00 00 00 00 00 00 00 00 00 00 3c 50 00 00 00 00 00 3c 00 00 3c 00 00 00 00 00 00 00 00 00 50 00 50 3c 00 00 00 00 60 00 00 00 00 00 00 50 00 00 50 00 00 00 00 00 00 50 00 00 00 00 00 50 00 00 46 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 50 00 00 00 50 00 00 00 00 3c 00 00 3c 44 00 00 00 50 00 00 3c 00 00 00 00 00 00 00 3c 00 00 00 00 00 00 00 00 00 00 3c 00 00 50 00 50 00 00 00 50 00 00 00 50 00 00 00 00 50 50 00 00 00 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 44 00 00 00 67 44 00 00 00 00 00 00 00 9f 00 00 44 50 00 00 44 00 50 00 00 46 00 44 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 3c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50 00 50 00 00 00 00 00 00 50 00 00 3c 50 00 00 00 3c 00 00 00 50 3c 46 00 50 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 50 00 00 60 50 00 00 44 44 44 00 00 00 00 00 00 00 00 00 00 00 00 00 50 3c 00 00 00 3c 00 00 00 50 00 00 00 00 00 00 3c 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50 44 00 00 44 00 00 00 00 00 00 00 00 00 00 60 00 00 00 00 00 00 44 00 00 44 44 44 00 00 00 00 00 00 00 50 50 00 00 50 00 50 00 00 00 50 00 00 00 00 3c 00 00 00 00 00 3c 00 00 00 00 00 00 00 00 00 00 00 3c 50 00 00 00 3c 00 00 00 00 00 00 3c 00 00 00 00 00 00 3c 00 00 00 50 00 00 00 00 00 44 00 00 44 00 00 00 00 00 44 00 44 44 00 44 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 60 00 00 00 00 00 00 00 60 00 60 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 60 00 00 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50 3c 44 00 00 44 00 00 00 00 00 6d 6d 00 00 00 00 44 00 44 00 00 00 00 6d 00 00 44 00 00 00 00 00 50 00 00 00 50 00 3c 00 00 00 00 00 50 44 44 00 00 00 00 00 67 00 67 67 46 44 00 00 50 44 44 00 00 00 00 00 00 00 44 00 00 00 00 00 00 67 00 00 44 00 00 00 00 50 67 44 44 50 50 44 00 67 00 67 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 46 67 6d 00 00 00 00 00 00 00 00 44 67 00 00 44 00 44 46 00 00 44 00 00 00 00 00 00 00 00 50 00 00 00 44 00 00 00 00 00 67 44 00 00 00 00 3c 67 44 00 00 00 00 00 00 00 00 00 1a 00 00 44 00 00 00 00 00 00 00 00 44 00 50 00 00 00 00
*/
|
src/pilas.adb
|
alvaromb/Compilemon
| 1 |
20155
|
<gh_stars>1-10
with Ada.Unchecked_Deallocation;
package body pilas is
type Component is record
Cim : Tipus_Element;
Resta : Pila;
end record;
procedure Allibera_Memoria is
new Ada.Unchecked_Deallocation
(Object => Component,
Name => Pila);
procedure Pila_Buida
(P : out Pila) is
begin
P := null;
end Pila_Buida;
function Es_Buida
(P : Pila) return Boolean is
begin
return P = null;
end Es_Buida;
procedure Cim
(P : in Pila;
Element : out Tipus_Element) is
begin
pragma Assert
(P /= null, "Intent d'accedir a cim de pila buida");
Element := P.all.Cim;
end Cim;
procedure Empilar
(P : in out Pila;
Element : in Tipus_Element) is
begin
P := new Component'(Cim => Element, Resta => P);
exception
when Storage_Error => raise Memoria_Agotada;
end Empilar;
procedure Desempilar
(P : in out Pila) is
Antic : Pila;
begin
pragma Assert
(P /= null, "Intent de desempilar una pila buida");
Antic := P;
P := P.all.Resta;
Allibera_Memoria(Antic);
end Desempilar;
procedure Destruir
(P : in out Pila) is
Antic : Pila;
begin
while P /= null loop
Antic := P;
P := P.all.Resta;
Allibera_Memoria(Antic);
end loop;
end Destruir;
end pilas;
|
3-mid/impact/source/3d/collision/shapes/impact-d3-shape-concave-triangle_mesh.adb
|
charlie5/lace
| 20 |
24751
|
with impact.d3.collision.Proxy;
with impact.d3.Matrix;
with impact.d3.Vector;
with impact.d3.Transform;
with impact.d3.aabb_Util;
-- #include "impact.d3.Shape.concave.triangle_mesh.h"
-- #include "LinearMath/impact.d3.Vector.h"
-- #include "LinearMath/impact.d3.Quaternion.h"
-- #include "impact.d3.striding_Mesh.h"
-- #include "LinearMath/btAabbUtil2.h"
-- #include "BulletCollision/CollisionShapes/impact.d3.collision.Margin.h"
package body impact.d3.Shape.concave.triangle_mesh
is
function to_triangle_mesh_Shape (meshInterface : access impact.d3.striding_Mesh.Item'Class) return Item'Class
is
Self : Item := (impact.d3.Shape.concave.item with
m_meshInterface => meshInterface.all'Access,
others => <>);
begin
Self.setShapeType (impact.d3.collision.Proxy.TRIANGLE_MESH_SHAPE_PROXYTYPE);
if meshInterface.hasPremadeAabb then
meshInterface.getPremadeAabb (Self.m_localAabbMin, Self.m_localAabbMax);
else
Self.recalcLocalAabb;
end if;
return Self;
end to_triangle_mesh_Shape;
overriding procedure destruct (Self : in out Item)
is
pragma Unreferenced (Self);
begin
return;
end destruct;
overriding procedure getAabb (Self : in Item; t : in Transform_3d;
aabbMin, aabbMax : out math.Vector_3)
is
use linear_Algebra_3d, impact.d3.Vector, impact.d3.Matrix, impact.d3.Transform,
math.Vectors;
localHalfExtents : constant math.Vector_3 := 0.5 * (Self.m_localAabbMax - Self.m_localAabbMin)
+ (Self.getMargin, Self.getMargin, Self.getMargin);
localCenter : constant math.Vector_3 := 0.5 * (Self.m_localAabbMax + Self.m_localAabbMin);
abs_b : constant math.Matrix_3x3 := absolute (getBasis (t));
center : constant math.Vector_3 := t * localCenter;
extent : constant math.Vector_3 := (dot (getRow (abs_b, 1), localHalfExtents),
dot (getRow (abs_b, 2), localHalfExtents),
dot (getRow (abs_b, 3), localHalfExtents));
begin
aabbMin := center - extent;
aabbMax := center + extent;
end getAabb;
overriding procedure setLocalScaling (Self : in out Item; scaling : in math.Vector_3)
is
begin
Self.m_meshInterface.setScaling (scaling);
Self.recalcLocalAabb;
end setLocalScaling;
overriding function getLocalScaling (Self : in Item) return math.Vector_3
is
begin
return Self.m_meshInterface.getScaling;
end getLocalScaling;
overriding procedure calculateLocalInertia (Self : in Item; mass : in math.Real;
inertia : out math.Vector_3)
is
pragma Unreferenced (Self, mass);
begin
-- moving concave objects not supported
pragma Assert (False);
inertia := (0.0, 0.0, 0.0);
end calculateLocalInertia;
overriding function getName (Self : in Item) return String
is
pragma Unreferenced (Self);
begin
return "TRIANGLEMESH";
end getName;
overriding procedure processAllTriangles (Self : in Item; callback : access impact.d3.triangle_Callback.Item'Class;
aabbMin, aabbMax : in math.Vector_3)
is
type FilteredCallback is new impact.d3.triangle_Callback.btInternalTriangleIndexCallback with
record
m_callback : access impact.d3.triangle_Callback.Item'Class;
m_aabbMin,
m_aabbMax : math.Vector_3;
end record;
overriding procedure internalProcessTriangleIndex (Self : in out FilteredCallback; triangle : access math.Matrix_3x3;
partId : in Integer;
triangleIndex : in Integer)
is
begin
if impact.d3.aabb_Util.TestTriangleAgainstAabb2 (triangle.all, Self.m_aabbMin, Self.m_aabbMax) then
-- check aabb in triangle-space, before doing this
Self.m_callback.processTriangle (triangle, partId, triangleIndex);
end if;
end internalProcessTriangleIndex;
function to_FilteredCallback (callback : access impact.d3.triangle_Callback.Item'Class;
aabbMin, aabbMax : in math.Vector_3 ) return FilteredCallback
is
Self : FilteredCallback;
begin
Self.m_callback := callback;
Self.m_aabbMin := aabbMin;
Self.m_aabbMax := aabbMax;
return Self;
end to_FilteredCallback;
filterCallback : aliased FilteredCallback := to_FilteredCallback (callback, aabbMin, aabbMax);
begin
Self.m_meshInterface.InternalProcessAllTriangles (filterCallback'Access, aabbMin, aabbMax);
end processAllTriangles;
--- SupportVertexCallback
--
function to_SupportVertexCallback (supportVecWorld : in math.Vector_3;
trans : in Transform_3d) return SupportVertexCallback
is
use impact.d3.Transform, math.Vectors;
Self : SupportVertexCallback;
begin
Self.m_supportVertexLocal := (0.0, 0.0, 0.0);
Self.m_worldTrans := trans;
Self.m_maxDot := -BT_LARGE_FLOAT;
Self.m_supportVecLocal := supportVecWorld * getBasis (Self.m_worldTrans);
return Self;
end to_SupportVertexCallback;
overriding procedure processTriangle (Self : in out SupportVertexCallback; triangle : access math.Matrix_3x3;
partId : in Integer;
triangleIndex : in Integer )
is
pragma Unreferenced (partId, triangleIndex);
use impact.d3.Vector, impact.d3.Matrix;
the_dot : math.Real;
begin
for i in 1 .. 3
loop
the_dot := dot (Self.m_supportVecLocal, getRow (triangle.all, i));
if the_dot > Self.m_maxDot then
Self.m_maxDot := the_dot;
Self.m_supportVertexLocal := getRow (triangle.all, i);
end if;
end loop;
end processTriangle;
function GetSupportVertexWorldSpace (Self : in SupportVertexCallback) return math.Vector_3
is
use linear_Algebra_3d, impact.d3.Transform;
begin
return Self.m_worldTrans * Self.m_supportVertexLocal;
end GetSupportVertexWorldSpace;
function GetSupportVertexLocal (Self : in SupportVertexCallback) return math.Vector_3
is
use impact.d3.Transform;
begin
return Self.m_supportVertexLocal;
end GetSupportVertexLocal;
function localGetSupportingVertex (Self : in Item; vec : in math.Vector_3) return math.Vector_3
is
use math.Vectors;
supportVertex : math.Vector_3;
ident : constant Transform_3d := impact.d3.Transform.getIdentity;
supportCallback : aliased SupportVertexCallback := to_SupportVertexCallback (vec, ident);
aabbMax : constant math.Vector_3 := (BT_LARGE_FLOAT, BT_LARGE_FLOAT, BT_LARGE_FLOAT);
begin
Self.processAllTriangles (supportCallback'Access, -aabbMax, aabbMax);
supportVertex := supportCallback.GetSupportVertexLocal;
return supportVertex;
end localGetSupportingVertex;
procedure recalcLocalAabb (Self : in out Item)
is
vec,
tmp : math.Vector_3;
begin
for i in 1 .. 3
loop
vec := (0.0, 0.0, 0.0);
vec (i) := 1.0;
tmp := Self.localGetSupportingVertex (vec);
Self.m_localAabbMax (i) := tmp (i) + Self.getMargin;
vec (i) := -1.0;
tmp := Self.localGetSupportingVertex (vec);
Self.m_localAabbMin (i) := tmp (i) - Self.getMargin;
end loop;
end recalcLocalAabb;
function getMeshInterface (Self : in Item) return access impact.d3.striding_Mesh.item'Class
is
begin
return Self.m_meshInterface;
end getMeshInterface;
function getLocalAabbMin (Self : in Item) return math.Vector_3
is
begin
return Self.m_localAabbMin;
end getLocalAabbMin;
function getLocalAabbMax (Self : in Item) return math.Vector_3
is
begin
return Self.m_localAabbMax;
end getLocalAabbMax;
end impact.d3.Shape.concave.triangle_mesh;
|
programs/oeis/327/A327936.asm
|
neoneye/loda
| 22 |
91389
|
; A327936: Multiplicative with a(p^e) = p if e >= p, otherwise 1.
; 1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,2,1,1,3,2,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,2,1,3,1,2,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,2,3,1,1,2,1,1,1,2,1,1,1,2,1,1,1,2,1,1,1,2
add $0,1
mov $1,1
mov $2,2
mov $3,$0
mov $4,$0
lpb $3
mov $5,$4
mov $6,0
lpb $5
add $6,1
mov $7,$0
div $0,$2
mod $7,$2
cmp $7,0
sub $5,$7
lpe
div $6,$2
cmp $6,0
cmp $6,0
mov $7,$2
pow $7,$6
mul $1,$7
add $2,1
div $3,3
lpe
mov $0,$1
|
programs/oeis/186/A186351.asm
|
karttu/loda
| 1 |
22491
|
; A186351: 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 odd numbers and the triangular numbers. Complement of A186350.
; 2,4,6,9,13,17,21,26,32,38,44,51,59,67,75,84,94,104,114,125,137,149,161,174,188,202,216,231,247,263,279,296,314,332,350,369,389,409,429,450,472,494,516,539,563,587,611,636,662,688,714,741,769,797,825,854,884,914,944,975,1007,1039,1071,1104,1138,1172,1206,1241,1277,1313,1349,1386,1424,1462,1500
mov $1,$0
add $0,7
mul $1,$0
div $1,4
add $1,2
|
PIM/TD3_Sous_Programmes/base_valide.adb
|
Hathoute/ENSEEIHT
| 1 |
1994
|
<filename>PIM/TD3_Sous_Programmes/base_valide.adb<gh_stars>1-10
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Lire_Entier is
Base_MAX : constant Integer := 10 + 26; -- 10 chiffres ('0'..'9') + 26 lettres ('A'..'Z')
-- Est-ce que la base est valide ?
function Est_Base_Valide(Base : in Integer) return Boolean is
begin
return 2 <= Base and Base <= Base_MAX;
--return True;
end Est_Base_Valide;
-- Transformer indice en nombre entierdans base10
function Indice_En_Base10(Indice: Character) return Integer is
begin
if Indice >= '0' and Indice <= '9' then
return Character'Pos(Indice) - Character'Pos('0');
else
return 10 + Character'Pos(Indice) - Character'Pos('A');
end if;
end Indice_En_Base10;
function Nombre_En_Indice(Nombre: Integer) return Character is
begin
if Nombre < 10 then
return Character'Val(Nombre + Character'Pos('0'));
else
return Character'Val(Nombre - 10 + Character'Pos('A'));
end if;
end Nombre_En_Indice;
-- Lire un entier au clavier dans la base considérée.
procedure Lire (
Nombre: out Integer ; -- l'entier lu au clavier
Base: in Integer := 10 -- la base à utiliser
) with
Pre => Est_Base_Valide (Base)
is
NbrEnBase: String(1 .. 10);
Iteration: Integer;
begin
Get_Line(NbrEnBase, Iteration);
Nombre := 0;
for char of NbrEnBase loop
Iteration := Iteration - 1;
Nombre := Nombre + Indice_En_Base10(char) * Base**Iteration;
exit when Iteration = 0;
end loop;
end Lire;
-- Écrire un entier dans une base donnée.
procedure Ecrire (
Nombre: in Integer ; -- l'entier à écrire
Base : in Integer -- la base à utliser
) with
Pre => Est_Base_Valide (Base)
and Nombre >= 0
is
begin
if Nombre < Base then
Put(Nombre_En_Indice(Nombre));
return;
end if;
Ecrire(Nombre/Base, Base);
Put(Nombre_En_Indice(Nombre mod Base));
end Ecrire;
Base_Lecture: Integer; -- la base de l'entier lu
Base_Ecriture: Integer; -- la base de l'entier écrit
Un_Entier: Integer; -- un entier lu au clavier
begin
-- Demander la base de lecture
Put ("Base de l'entier lu : ");
Get (Base_Lecture);
Skip_Line;
-- Demander un entier
Put ("Un entier (base ");
Put (Base_Lecture, 1);
Put (") : ");
if Est_Base_Valide(Base_Lecture) then
Lire (Un_Entier, Base_Lecture);
else
Skip_Line;
Un_Entier := 0;
end if;
-- Afficher l'entier lu en base 10
Put ("L'entier lu est (base 10) : ");
Put (Un_Entier, 1);
New_Line;
-- Demander la base d'écriture
Put ("Base pour écrire l'entier : ");
Get (Base_Ecriture);
Skip_Line;
-- Afficher l'entier lu dans la base d'écriture
if Est_Base_Valide(Base_Lecture) then
Put ("L'entier en base ");
Put (Base_Ecriture, 1);
Put (" est ");
Ecrire (Un_Entier, Base_Ecriture);
New_Line;
end if;
-- Remarque : on aurait pu utiliser les sous-programme Lire pour lire
-- les bases et Ecrire pour les écrire en base 10. Nous utilisons les
-- Get et Put d'Ada pour faciliter le test du programme.
end Lire_Entier;
|
Codes/Chapter05/P09/P05-09.asm
|
ar-ekt/Dandamudi-Assembly-Solutions
| 8 |
172720
|
global _start
extern ExitProcess
%INCLUDE "lib.h"
section .data
nwln db 10, 0
inMSG db "enter a string less than 100 characters long:", 0
outMSG db "leading and duplicate blanks removed:", 0
section .bss
inBuffer resb 102
tempBuffer resb 102
section .code
_start:
puts inMSG
puts nwln
fgets inBuffer, 102
push inBuffer
push tempBuffer
call strcpy
push tempBuffer
push inBuffer
call clean_string
puts outMSG
puts nwln
puts inBuffer
puts nwln
push 0
call ExitProcess
;-------------proc clean_string------------;
; ;
; removes all leading and duplicate blanks ;
; *removes only the space characters* ;
; ;
;------------------------------------------;
%define str1 DWORD [EBP+12]
%define str2 DWORD [EBP+8]
clean_string:
enter 0, 0
push EAX ;preserving the values of EAX, EBX, and DX
push EBX
push DX
mov EAX, str1
mov EBX, str2
xor DX, DX ;using DL as a flag for duplicates, and DH to hold temp characters
leading_blanks:
mov DH, [EAX]
cmp DH, 32 ;ascii 32 is the space character
je continue
mov [EBX], DH
inc EBX
inc EAX
jmp duplicates
continue:
inc EAX
jmp leading_blanks
duplicates:
mov DH, [EAX]
cmp DH, 0
je end
cmp DH, 32
je space
cmp DL, 1
je insert_space
mov [EBX], DH
inc EBX
inc EAX
jmp duplicates
space:
cmp DL, 1
je skip
mov DL, 1
skip:
inc EAX
jmp duplicates
insert_space:
mov DL, 0
mov [EBX], BYTE 32
inc EBX
mov [EBX], DH
inc EBX
inc EAX
jmp duplicates
end:
cmp DL, 1
je last_space
mov [EBX], BYTE 0
jmp finish
last_space:
mov [EBX], BYTE 32
inc EBX
mov [EBX], BYTE 0
finish:
pop DX
pop EBX
pop EAX
leave
ret 8
;proc strcpy -> copy the string from src to dest
strcpy:
enter 0, 0
pusha
mov EBX, [EBP+8]
mov EAX, [EBP+12]
xor ESI, ESI
char_loop:
mov DL, [EAX+ESI]
cmp DL, 0
je finish_copy
mov [EBX,ESI], DL
inc ESI
jmp char_loop
finish_copy:
mov [EBX+ESI], byte 0
popa
leave
ret 8
|
Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0xca.log_21829_804.asm
|
ljhsiun2/medusa
| 9 |
241826
|
<filename>Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0xca.log_21829_804.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r15
push %r8
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0xca5c, %r15
nop
nop
nop
nop
and $23025, %rcx
movb (%r15), %r8b
nop
cmp %r15, %r15
lea addresses_WT_ht+0xff5c, %rcx
nop
dec %r8
mov (%rcx), %r13w
nop
nop
nop
nop
nop
xor %rcx, %rcx
lea addresses_WT_ht+0x19e5c, %rsi
lea addresses_UC_ht+0xb6dc, %rdi
nop
nop
nop
xor $13442, %r8
mov $9, %rcx
rep movsw
nop
nop
nop
nop
cmp %r13, %r13
lea addresses_normal_ht+0x1065c, %rdi
nop
nop
inc %rax
mov (%rdi), %r13
add $38274, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r8
pop %r15
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r15
push %rbp
push %rdx
// Store
lea addresses_A+0xb65c, %r12
dec %rdx
movb $0x51, (%r12)
nop
nop
nop
nop
nop
add $55947, %r12
// Store
mov $0x43ea920000000f5c, %rdx
nop
nop
nop
nop
sub %rbp, %rbp
mov $0x5152535455565758, %r10
movq %r10, (%rdx)
cmp %r11, %r11
// Faulty Load
lea addresses_WT+0x825c, %rbp
nop
nop
nop
sub %r10, %r10
mov (%rbp), %r15
lea oracles, %r11
and $0xff, %r15
shlq $12, %r15
mov (%r11,%r15,1), %r15
pop %rdx
pop %rbp
pop %r15
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': True, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': True, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_A'}}
{'OP': 'STOR', 'dst': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_NC'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 8, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 7, 'AVXalign': True, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_UC_ht'}}
{'src': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 8, 'NT': True, 'type': 'addresses_normal_ht'}, '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
*/
|
Data/BinaryTree/Heap.agda
|
Lolirofle/stuff-in-agda
| 6 |
7439
|
open import Data.Boolean
open import Type
module Data.BinaryTree.Heap {ℓ} {T : Type{ℓ}} (_≤?_ : T → T → Bool) where
import Lvl
open import Data hiding (empty)
open import Data.BinaryTree
BinaryHeap = BinaryTree (Unit{Lvl.𝟎}) (T)
private variable ℓᵣ : Lvl.Level
private variable R : Type{ℓᵣ}
open import Data.Option
open import Data.Tuple as Tuple using (_⨯_ ; _,_)
open import Functional as Fn using (_∘_ ; _∘₂_ ; _$_)
merge : BinaryHeap → BinaryHeap → BinaryHeap
merge (Leaf <>) (Leaf <>) = Leaf <>
merge x@(Node _ _ _) (Leaf <>) = x
merge (Leaf <>) y@(Node _ _ _) = y
merge x@(Node xa xl xr) y@(Node ya yl yr) with (xa ≤? ya) | (\_ → merge y xr) | (\_ → merge x yr)
... | 𝑇 | 𝑇-branch | _ = Node xa (𝑇-branch(<>{Lvl.𝟎})) xl
... | 𝐹 | _ | 𝐹-branch = Node ya (𝐹-branch(<>{Lvl.𝟎})) yl
insert : T → BinaryHeap → BinaryHeap
insert a = merge(singleton a)
pop : BinaryHeap → Option(T ⨯ BinaryHeap)
pop (Leaf <>) = None
pop (Node a l r) = Some(a , merge l r)
{-# TERMINATING #-}
foldOrdered : (T → R → R) → R → BinaryHeap → R
foldOrdered(_▫_) id (Leaf <>) = id
foldOrdered(_▫_) id (Node a l r) = a ▫ foldOrdered(_▫_) id (merge l r)
filterFold : (T → R → Option(R)) → R → BinaryHeap → (R ⨯ BinaryHeap)
filterFold (_▫_) r₀ (Leaf <>) = (r₀ , Leaf <>)
filterFold (_▫_) r₀ (Node a l r)
with (r₁ , il) ← filterFold (_▫_) r₀ l
with (r₂ , ir) ← filterFold (_▫_) r₁ r
with (a ▫ r₂)
... | Some r₃ = (r₃ , merge il ir)
... | None = (r₂ , Node a il ir)
filter : (T → Bool) → BinaryHeap → BinaryHeap
filter f = Tuple.right ∘ filterFold (\{a <> → (\{𝐹 → None ; 𝑇 → Some <>}) $ f(a)}) (<>{Lvl.𝟎})
open import Data.List
import Data.List.Functions as List
separate : (T → Bool) → BinaryHeap → (List(T) ⨯ BinaryHeap)
separate f = filterFold (\a l → (\{𝐹 → None ; 𝑇 → Some(a ⊰ l)}) $ f(a)) ∅
update : (T → Bool) → (T → T) → BinaryHeap → BinaryHeap
update p f a with (as , b) ← separate p a = List.foldᵣ insert b (List.map f as)
|
source/runtime/pb_support-io.ads
|
mgrojo/protobuf
| 12 |
29234
|
-- MIT License
--
-- Copyright (c) 2020 <NAME>
--
-- Permission is hereby granted, free of charge, to any person obtaining a
-- copy of this software and associated documentation files (the "Software"),
-- to deal in the Software without restriction, including without limitation
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
with Ada.Streams;
with Interfaces;
with League.Strings;
with League.Stream_Element_Vectors;
with League.String_Vectors;
with PB_Support.Boolean_Vectors;
with PB_Support.IEEE_Float_32_Vectors;
with PB_Support.IEEE_Float_64_Vectors;
with PB_Support.Integer_32_Vectors;
with PB_Support.Integer_64_Vectors;
with PB_Support.Internal;
with PB_Support.Stream_Element_Vector_Vectors;
with PB_Support.Unsigned_32_Vectors;
with PB_Support.Unsigned_64_Vectors;
with PB_Support.Vectors;
package PB_Support.IO is
pragma Preelaborate;
subtype Key is PB_Support.Key;
function Read_Key
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Result : access Key) return Boolean;
function Read_Length
(Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Ada.Streams.Stream_Element_Count;
function Read_Array_Length
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item_Size : Ada.Streams.Stream_Element_Count)
return Natural;
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out League.Strings.Universal_String);
procedure Read_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out League.String_Vectors.Universal_String_Vector);
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out League.Stream_Element_Vectors.Stream_Element_Vector);
procedure Read_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Stream_Element_Vector_Vectors.Vector);
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Boolean);
procedure Read_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Boolean_Vectors.Vector);
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.IEEE_Float_64);
procedure Read_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.IEEE_Float_64_Vectors.Vector);
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.IEEE_Float_32);
procedure Read_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.IEEE_Float_32_Vectors.Vector);
procedure Read_Varint
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Integer_64);
procedure Read_Varint_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Integer_64_Vectors.Vector);
procedure Read_Varint
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Unsigned_64);
procedure Read_Varint_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Unsigned_64_Vectors.Vector);
procedure Read_Varint
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Integer_32);
procedure Read_Varint_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Integer_32_Vectors.Vector);
procedure Read_Varint
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Unsigned_32);
procedure Read_Varint_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Unsigned_32_Vectors.Vector);
procedure Read_Zigzag
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Integer_32);
procedure Read_Zigzag_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out PB_Support.Integer_32_Vectors.Vector);
procedure Read_Zigzag
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Integer_64);
procedure Read_Zigzag_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out PB_Support.Integer_64_Vectors.Vector);
procedure Read_Fixed
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Integer_64) renames Read_Varint;
procedure Read_Fixed_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Integer_64_Vectors.Vector);
procedure Read_Fixed
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Unsigned_64) renames Read_Varint;
procedure Read_Fixed_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Unsigned_64_Vectors.Vector);
procedure Read_Fixed
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Integer_32) renames Read_Varint;
procedure Read_Fixed_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Integer_32_Vectors.Vector);
procedure Read_Fixed
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Unsigned_32) renames Read_Varint;
procedure Read_Fixed_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Unsigned_32_Vectors.Vector);
procedure Unknown_Field
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type);
generic
type Element is (<>);
type Integer_Element is range <>;
with package Vectors is new PB_Support.Vectors (Element);
package Enum_IO is
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Element);
procedure Read_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out Vectors.Vector);
procedure Write
(Stream : in out Internal.Stream;
Field : Field_Number;
Value : Element);
procedure Write
(Stream : in out Internal.Stream;
Field : Field_Number;
Value : Vectors.Vector);
procedure Write_Packed
(Stream : in out Internal.Stream;
Field : Field_Number;
Value : Vectors.Vector);
procedure Write_Option
(Stream : in out Internal.Stream;
Field : Field_Number;
Value : Element;
Default : Element);
end Enum_IO;
generic
type Element is private;
type Vector is private;
with procedure Append
(Self : in out Vector;
Value : Element);
package Message_IO is
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Element);
procedure Read_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out Vector);
end Message_IO;
end PB_Support.IO;
|
regtests/util-concurrent-tests.adb
|
RREE/ada-util
| 60 |
20597
|
<reponame>RREE/ada-util
-----------------------------------------------------------------------
-- util-concurrent-tests -- Unit tests for concurrency package
-- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2019 <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.
-----------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Strings.Unbounded;
with Ada.Finalization;
with Util.Concurrent.Counters;
with Util.Test_Caller;
with Util.Measures;
with Util.Log.Loggers;
with Util.Concurrent.Copies;
with Util.Concurrent.Pools;
with Util.Concurrent.Fifos;
with Util.Concurrent.Arrays;
with Util.Concurrent.Sequence_Queues;
package body Util.Concurrent.Tests is
use Util.Tests;
use Util.Concurrent.Counters;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Concurrent.Tests");
type Connection is new Ada.Finalization.Controlled with record
Name : Ada.Strings.Unbounded.Unbounded_String;
Value : Natural := 0;
end record;
function "=" (Left, Right : in Connection) return Boolean;
overriding
procedure Finalize (C : in out Connection);
function "=" (Left, Right : in Connection) return Boolean is
begin
return Left.Value = Right.Value;
end "=";
package Connection_Pool is new Util.Concurrent.Pools (Connection);
package Connection_Fifo is new Util.Concurrent.Fifos (Connection, 7);
package Connection_Arrays is new Util.Concurrent.Arrays (Connection);
package Connection_Sequences is
new Util.Concurrent.Sequence_Queues (Connection, Natural, 13);
package Caller is new Util.Test_Caller (Test, "Concurrent");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Concurrent.Counter.Increment",
Test_Increment'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Counter.Decrement",
Test_Decrement'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Counter.Decrement + Test",
Test_Decrement_And_Test'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Copies.Get + Set",
Test_Copy'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Pools.Get_Instance",
Test_Pool'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Pools (concurrent test)",
Test_Concurrent_Pool'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Fifos",
Test_Fifo'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Fifos (concurrent test)",
Test_Concurrent_Fifo'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Arrays",
Test_Array'Access);
Caller.Add_Test (Suite, "Test Util.Concurrent.Sequence_Queues",
Test_Concurrent_Sequences'Access);
end Add_Tests;
overriding
procedure Finalize (C : in out Connection) is
begin
null;
end Finalize;
-- ------------------------------
-- Test concurrent pool
-- ------------------------------
procedure Test_Pool (T : in out Test) is
use Ada.Strings.Unbounded;
P : Connection_Pool.Pool;
C : Connection;
begin
-- Set the pool capacity.
P.Set_Size (Capacity => 10);
-- Insert the objects.
for I in 1 .. 10 loop
C.Name := To_Unbounded_String (Integer'Image (I));
P.Release (C);
end loop;
-- Use the pool and verify the objects.
declare
C : array (1 .. 10) of Connection;
begin
for J in 1 .. 3 loop
-- Get each object and verify that it matches our instance.
for I in reverse 1 .. 10 loop
P.Get_Instance (C (I));
Assert_Equals (T, Integer'Image (I), To_String (C (I).Name), "Invalid pool object");
end loop;
-- Put the object back in the pool.
for I in 1 .. 10 loop
P.Release (C (I));
end loop;
end loop;
end;
declare
S : Util.Measures.Stamp;
begin
for I in 1 .. 1_000 loop
P.Get_Instance (C);
P.Release (C);
end loop;
Util.Measures.Report (S, "Pool Get_Instance+Release", 1000);
end;
end Test_Pool;
-- ------------------------------
-- Test concurrent pool
-- ------------------------------
procedure Test_Concurrent_Pool (T : in out Test) is
use Ada.Strings.Unbounded;
Count_By_Task : constant Natural := 10_001;
Task_Count : constant Natural := 17;
Capacity : constant Natural := 5;
P : Connection_Pool.Pool;
C : Connection;
S : Util.Measures.Stamp;
begin
-- Set the pool capacity.
P.Set_Size (Capacity => Capacity);
-- Insert the objects.
for I in 1 .. Capacity loop
C.Name := To_Unbounded_String (Integer'Image (I));
P.Release (C);
end loop;
declare
-- A task that picks an object from the pool, increment the value and puts
-- back the object in the pool.
task type Worker is
entry Start (Count : in Natural);
end Worker;
task body Worker is
Cnt : Natural;
begin
accept Start (Count : in Natural) do
Cnt := Count;
end Start;
-- Get an object from the pool, increment the value and put it back in the pool.
for I in 1 .. Cnt loop
declare
C : Connection;
begin
P.Get_Instance (C);
C.Value := C.Value + 1;
P.Release (C);
end;
end loop;
exception
when E : others =>
Log.Error ("Exception raised", E);
Ada.Text_IO.Put_Line ("Exception raised.");
end Worker;
type Worker_Array is array (1 .. Task_Count) of Worker;
Tasks : Worker_Array;
begin
for I in Tasks'Range loop
Tasks (I).Start (Count_By_Task);
end loop;
-- Leaving the Worker task scope means we are waiting for our tasks to finish.
end;
Util.Measures.Report (S, "Executed Get+Release "
& Natural'Image (Count_By_Task * Task_Count));
declare
Total : Natural := 0;
begin
for I in 1 .. Capacity loop
P.Get_Instance (C);
Total := Total + C.Value;
end loop;
Assert_Equals (T, Count_By_Task * Task_Count, Total, "Invalid computation");
end;
end Test_Concurrent_Pool;
procedure Test_Increment (T : in out Test) is
C : Counter;
begin
Increment (C);
Assert_Equals (T, Value (C), 1, "Increment failed");
end Test_Increment;
procedure Test_Decrement (T : in out Test) is
C : Counter;
begin
Increment (C);
Decrement (C);
Assert_Equals (T, Value (C), 0, "Increment + Decrement failed");
end Test_Decrement;
procedure Test_Decrement_And_Test (T : in out Test) is
C : Counter;
Is_Zero : Boolean;
begin
Increment (C);
Assert_Equals (T, Value (C), 1, "Increment failed");
Decrement (C, Is_Zero);
Assert_Equals (T, Value (C), 0, "Decrement failed");
T.Assert (Is_Zero, "Counter should be zero");
Increment (C);
Increment (C);
Decrement (C, Is_Zero);
T.Assert (not Is_Zero, "Counter should not be zero");
end Test_Decrement_And_Test;
procedure Test_Copy (T : in out Test) is
type Data is record
C : Natural := 0;
L : Long_Long_Integer := 1;
B : Boolean := False;
F : Float := 1.0;
S : String (1 .. 10) := (others => ' ');
end record;
package Data_Atomic is new Util.Concurrent.Copies (Data);
D : Data_Atomic.Atomic;
V : Data;
V2 : Data;
begin
V.C := 1;
V.B := True;
V.S := "0123456789";
D.Set (V);
V2 := D.Get;
Assert_Equals (T, 1, V2.C, "Invalid Data.C");
Assert_Equals (T, "0123456789", V2.S, "Invalid Data.S");
-- Concurrent test:
-- o increment the long long integer
-- o rotate the string by 1 position
declare
Count_By_Task : constant Natural := 100_001;
Task_Count : constant Natural := 17;
-- A task that increments the shared counter <b>Unsafe</b> and <b>Counter</b> by
-- the specified amount.
task type Worker is
entry Start (Count : in Natural);
end Worker;
task body Worker is
Cnt : Natural;
Val : Data;
C : Character;
begin
accept Start (Count : in Natural) do
Cnt := Count;
end Start;
-- Increment the two counters as many times as necessary.
for I in 1 .. Cnt loop
Val := D.Get;
-- Val := V;
Val.L := Val.L + 1;
C := Val.S (1);
Val.S (1 .. 9) := Val.S (2 .. 10);
Val.S (10) := C;
D.Set (Val);
-- V := Val;
Val.S (1 .. 9) := Val.S (2 .. 10);
Val.S (10) := C;
end loop;
exception
when others =>
Ada.Text_IO.Put_Line ("Exception raised.");
end Worker;
type Worker_Array is array (1 .. Task_Count) of Worker;
Tasks : Worker_Array;
begin
for I in Tasks'Range loop
Tasks (I).Start (Count_By_Task);
end loop;
-- Leaving the Worker task scope means we are waiting for our tasks to finish.
end;
-- We can't predict the exact value for string after the rotation passes.
-- At least, we must have one of the following values (when using an unprotected
-- copy, the string value contains garbage).
T.Assert (D.Get.S = "0123456789" or D.Get.S = "1234567890" or
D.Get.S = "2345678901" or D.Get.S = "3456789012" or
D.Get.S = "4567890123" or D.Get.S = "5678901234" or
D.Get.S = "6789012345" or D.Get.S = "7890123456" or
D.Get.S = "8901234567" or D.Get.S = "9012345678",
"Invalid result: " & D.Get.S);
end Test_Copy;
-- ------------------------------
-- Test fifo
-- ------------------------------
procedure Test_Fifo (T : in out Test) is
Q : Connection_Fifo.Fifo;
Val : Connection;
Res : Connection;
Cnt : Natural;
begin
for I in 1 .. 100 loop
Cnt := I mod 8;
for J in 1 .. Cnt loop
Val.Name := Ada.Strings.Unbounded.To_Unbounded_String (Natural'Image (I));
Val.Value := I * J;
Q.Enqueue (Val);
Util.Tests.Assert_Equals (T, J, Q.Get_Count, "Invalid queue size");
end loop;
for J in 1 .. Cnt loop
Q.Dequeue (Res);
Util.Tests.Assert_Equals (T, I * J, Res.Value, "Invalid dequeue at "
& Natural'Image (I) & " - " & Natural'Image (J));
Util.Tests.Assert_Equals (T, Natural'Image (I), Val.Name, "Invalid dequeue at "
& Natural'Image (I) & " - " & Natural'Image (J));
end loop;
declare
S : Util.Measures.Stamp;
begin
for J in 1 .. 7 loop
Q.Enqueue (Val);
end loop;
Util.Measures.Report (S, "Enqueue 7 elements ");
end;
declare
S : Util.Measures.Stamp;
begin
for J in 1 .. 7 loop
Q.Dequeue (Val);
end loop;
Util.Measures.Report (S, "Dequeue 7 elements ");
end;
end loop;
for I in 1 .. 100 loop
Q.Set_Size (I);
end loop;
end Test_Fifo;
-- Test concurrent aspects of fifo.
procedure Test_Concurrent_Fifo (T : in out Test) is
Count_By_Task : constant Natural := 60_001;
Task_Count : constant Natural := 17;
Q : Connection_Fifo.Fifo;
S : Util.Measures.Stamp;
begin
Q.Set_Size (23);
declare
-- A task that adds elements in the shared queue.
task type Producer is
entry Start (Count : in Natural);
end Producer;
-- A task that consumes the elements.
task type Consumer is
entry Start (Count : in Natural);
entry Get (Result : out Long_Long_Integer);
end Consumer;
task body Producer is
Cnt : Natural;
begin
accept Start (Count : in Natural) do
Cnt := Count;
end Start;
-- Send Cnt values in the queue.
for I in 1 .. Cnt loop
declare
C : Connection;
begin
C.Value := I;
Q.Enqueue (C);
end;
end loop;
exception
when E : others =>
Log.Error ("Exception raised", E);
Ada.Text_IO.Put_Line ("Exception raised.");
end Producer;
task body Consumer is
Cnt : Natural;
Tot : Long_Long_Integer := 0;
begin
accept Start (Count : in Natural) do
Cnt := Count;
end Start;
-- Get an object from the pool, increment the value and put it back in the pool.
for I in 1 .. Cnt loop
declare
C : Connection;
begin
Q.Dequeue (C);
-- if C.Value /= I then
-- Ada.Text_IO.Put_Line ("Value: " & Natural'Image (C.Value)
-- & " instead of " & Natural'Image (I));
-- end if;
Tot := Tot + Long_Long_Integer (C.Value);
end;
end loop;
-- Ada.Text_IO.Put_Line ("Total: " & Natural'Image (Tot));
accept Get (Result : out Long_Long_Integer) do
Result := Tot;
end Get;
exception
when E : others =>
Log.Error ("Exception raised", E);
Ada.Text_IO.Put_Line ("Exception raised.");
end Consumer;
type Worker_Array is array (1 .. Task_Count) of Producer;
type Consummer_Array is array (1 .. Task_Count) of Consumer;
Producers : Worker_Array;
Consumers : Consummer_Array;
Value : Long_Long_Integer;
Total : Long_Long_Integer := 0;
Expect : Long_Long_Integer;
begin
for I in Producers'Range loop
Producers (I).Start (Count_By_Task);
end loop;
for I in Consumers'Range loop
Consumers (I).Start (Count_By_Task);
end loop;
for I in Consumers'Range loop
Consumers (I).Get (Value);
Total := Total + Value;
end loop;
Expect := Long_Long_Integer ((Count_By_Task * (Count_By_Task + 1)) / 2);
Expect := Expect * Long_Long_Integer (Task_Count);
Assert_Equals (T, Expect, Total, "Invalid computation");
end;
Util.Measures.Report (S, "Executed Queue+Dequeue "
& Natural'Image (Count_By_Task * Task_Count)
& " task count: " & Natural'Image (Task_Count));
end Test_Concurrent_Fifo;
-- ------------------------------
-- Test concurrent arrays.
-- ------------------------------
procedure Test_Array (T : in out Test) is
procedure Sum_All (C : in Connection);
List : Connection_Arrays.Vector;
L : Connection_Arrays.Ref;
Val : Connection;
Sum : Natural;
procedure Sum_All (C : in Connection) is
begin
Sum := Sum + C.Value;
end Sum_All;
begin
L := List.Get;
T.Assert (L.Is_Empty, "List should be empty");
Val.Value := 1;
List.Append (Val);
T.Assert (L.Is_Empty, "List should be empty");
L := List.Get;
T.Assert (not L.Is_Empty, "List should not be empty");
Sum := 0;
L.Iterate (Sum_All'Access);
Util.Tests.Assert_Equals (T, 1, Sum, "List iterate failed");
for I in 1 .. 100 loop
Val.Value := I;
List.Append (Val);
end loop;
-- The list refered to by 'L' should not change.
Sum := 0;
L.Iterate (Sum_All'Access);
Util.Tests.Assert_Equals (T, 1, Sum, "List iterate failed");
-- After getting the list again, we should see the new elements.
L := List.Get;
Sum := 0;
L.Iterate (Sum_All'Access);
Util.Tests.Assert_Equals (T, 5051, Sum, "List iterate failed");
Sum := 0;
L.Reverse_Iterate (Sum_All'Access);
Util.Tests.Assert_Equals (T, 5051, Sum, "List reverse iterate failed");
-- Remove last value.
Val.Value := 100;
List.Remove (Val);
L := List.Get;
Sum := 0;
L.Iterate (Sum_All'Access);
Util.Tests.Assert_Equals (T, 5051 - 100, Sum, "List iterate failed");
-- Remove first value.
Val.Value := 1;
List.Remove (Val);
L := List.Get;
Sum := 0;
L.Iterate (Sum_All'Access);
Util.Tests.Assert_Equals (T, 5051 - 100 - 1, Sum, "List iterate failed");
-- Remove middle value.
Val.Value := 50;
List.Remove (Val);
L := List.Get;
Sum := 0;
L.Iterate (Sum_All'Access);
Util.Tests.Assert_Equals (T, 5051 - 100 - 1 - 50, Sum, "List iterate failed");
end Test_Array;
-- ------------------------------
-- Test concurrent aspects of sequences.
-- ------------------------------
procedure Test_Concurrent_Sequences (T : in out Test) is
Count_By_Task : constant Natural := 60_001;
Task_Count : constant Natural := 8;
Pool_Count : constant Natural := 23;
Last_Sequence : constant Natural := 1_000;
Q : Connection_Sequences.Queue;
F : Connection_Pool.Pool;
S : Util.Measures.Stamp;
Seq_Error : Boolean := True;
First_Error : Natural := 0;
Expect_Seq : Natural := 0;
begin
Q.Set_Size (Pool_Count * 2);
F.Set_Size (Pool_Count);
declare
-- A task that picks elements and work on them.
task type Worker is
entry Start;
end Worker;
task body Worker is
begin
accept Start do
null;
end Start;
-- Send Cnt values in the queue.
loop
declare
C : Connection;
begin
F.Get_Instance (C, 3.0);
Q.Enqueue (C, C.Value);
exit when C.Value = Last_Sequence;
end;
end loop;
exception
when Connection_Pool.Timeout =>
null;
when E : others =>
Log.Error ("Exception raised", E);
Ada.Text_IO.Put_Line ("Exception raised.");
end Worker;
type Worker_Array is array (1 .. Task_Count) of Worker;
Producers : Worker_Array;
C : Connection;
Seq : Natural;
Avail : Natural;
Next : Natural := 0;
begin
for I in Producers'Range loop
Producers (I).Start;
end loop;
Seq_Error := False;
while Next < Last_Sequence loop
F.Get_Available (Avail);
if Avail /= Pool_Count and Next - Expect_Seq <= Pool_Count then
C.Value := Next;
F.Release (C);
Next := Next + 1;
else
Q.Dequeue (C, Seq, 3.0);
if Seq /= Expect_Seq then
if First_Error = 0 then
Ada.Text_IO.Put_Line ("Got" & Natural'Image (Seq) & " expecting"
& Natural'Image (Expect_Seq));
First_Error := Seq;
end if;
Seq_Error := True;
end if;
Expect_Seq := Seq + 1;
end if;
end loop;
loop
Q.Dequeue (C, Seq);
if Seq /= Expect_Seq then
if First_Error = 0 then
First_Error := Seq;
end if;
Seq_Error := True;
end if;
Expect_Seq := Seq + 1;
exit when Expect_Seq = Last_Sequence - 1;
end loop;
exception
when Connection_Sequences.Timeout =>
Seq_Error := True;
First_Error := Expect_Seq + 1_000_000;
end;
Util.Measures.Report (S, "Executed Queue+Dequeue "
& Natural'Image (Count_By_Task * Task_Count)
& " task count: " & Natural'Image (Task_Count));
T.Assert (not Seq_Error, "Incorrect sequences " & Natural'Image (First_Error)
& " Expect_Seq=" & Natural'Image (Expect_Seq));
end Test_Concurrent_Sequences;
end Util.Concurrent.Tests;
|
programs/oeis/102/A102390.asm
|
neoneye/loda
| 22 |
241030
|
; A102390: An odious count.
; 0,1,2,0,3,0,0,4,5,0,0,6,0,7,8,0,9,0,0,10,0,11,12,0,0,13,14,0,15,0,0,16,17,0,0,18,0,19,20,0,0,21,22,0,23,0,0,24,0,25,26,0,27,0,0,28,29,0,0,30,0,31,32,0,33,0,0,34,0,35,36,0,0,37,38,0,39,0,0,40,0,41,42,0,43,0,0,44
seq $0,102394 ; A wicked odious sequence.
add $0,1
div $0,2
|
programs/oeis/158/A158224.asm
|
karttu/loda
| 1 |
104569
|
; A158224: a(n) = 196*n^2 - 2*n.
; 194,780,1758,3128,4890,7044,9590,12528,15858,19580,23694,28200,33098,38388,44070,50144,56610,63468,70718,78360,86394,94820,103638,112848,122450,132444,142830,153608,164778,176340,188294,200640,213378,226508,240030,253944,268250,282948,298038,313520,329394,345660,362318,379368,396810,414644,432870,451488,470498,489900,509694,529880,550458,571428,592790,614544,636690,659228,682158,705480,729194,753300,777798,802688,827970,853644,879710,906168,933018,960260,987894,1015920,1044338,1073148,1102350,1131944,1161930,1192308,1223078,1254240,1285794,1317740,1350078,1382808,1415930,1449444,1483350,1517648,1552338,1587420,1622894,1658760,1695018,1731668,1768710,1806144,1843970,1882188,1920798,1959800,1999194,2038980,2079158,2119728,2160690,2202044,2243790,2285928,2328458,2371380,2414694,2458400,2502498,2546988,2591870,2637144,2682810,2728868,2775318,2822160,2869394,2917020,2965038,3013448,3062250,3111444,3161030,3211008,3261378,3312140,3363294,3414840,3466778,3519108,3571830,3624944,3678450,3732348,3786638,3841320,3896394,3951860,4007718,4063968,4120610,4177644,4235070,4292888,4351098,4409700,4468694,4528080,4587858,4648028,4708590,4769544,4830890,4892628,4954758,5017280,5080194,5143500,5207198,5271288,5335770,5400644,5465910,5531568,5597618,5664060,5730894,5798120,5865738,5933748,6002150,6070944,6140130,6209708,6279678,6350040,6420794,6491940,6563478,6635408,6707730,6780444,6853550,6927048,7000938,7075220,7149894,7224960,7300418,7376268,7452510,7529144,7606170,7683588,7761398,7839600,7918194,7997180,8076558,8156328,8236490,8317044,8397990,8479328,8561058,8643180,8725694,8808600,8891898,8975588,9059670,9144144,9229010,9314268,9399918,9485960,9572394,9659220,9746438,9834048,9922050,10010444,10099230,10188408,10277978,10367940,10458294,10549040,10640178,10731708,10823630,10915944,11008650,11101748,11195238,11289120,11383394,11478060,11573118,11668568,11764410,11860644,11957270,12054288,12151698,12249500
mul $0,98
mov $1,98
add $1,$0
bin $1,2
div $1,49
mul $1,2
|
programs/oeis/130/A130766.asm
|
jmorken/loda
| 1 |
174928
|
; A130766: 3n+2 sandwiched by tripled 3n+1 .
; 1,1,1,2,4,4,4,5,7,7,7,8,10,10,10,11,13,13,13,14,16,16,16,17,19,19,19,20,22,22,22,23,25,25,25,26,28,28,28,29,31,31,31,32,34,34,34,35,37,37,37,38,40,40,40,41,43,43,43,44,46,46,46,47,49,49,49,50,52,52,52,53,55,55,55,56,58,58,58,59,61,61,61,62,64,64,64,65,67,67,67,68,70,70,70,71,73,73,73,74,76,76,76,77,79,79,79,80,82,82,82,83,85,85,85,86,88,88,88,89,91,91,91,92,94,94,94,95,97,97,97,98,100,100,100,101,103,103,103,104,106,106,106,107,109,109,109,110,112,112,112,113,115,115,115,116,118,118,118,119,121,121,121,122,124,124,124,125,127,127,127,128,130,130,130,131,133,133,133,134,136,136,136,137,139,139,139,140,142,142,142,143,145,145,145,146,148,148,148,149,151,151,151,152,154,154,154,155,157,157,157,158,160,160,160,161,163,163,163,164,166,166,166,167,169,169,169,170,172,172,172,173,175,175,175,176,178,178,178,179,181,181,181,182,184,184,184,185,187,187
mul $0,2
mov $1,1
mov $2,$0
lpb $0
sub $0,1
trn $2,5
add $1,$2
trn $2,3
sub $1,$2
lpe
|
programs/oeis/083/A083884.asm
|
neoneye/loda
| 22 |
94299
|
; A083884: a(n) = (3^(2*n) + 1) / 2.
; 1,5,41,365,3281,29525,265721,2391485,21523361,193710245,1743392201,15690529805,141214768241,1270932914165,11438396227481,102945566047325,926510094425921,8338590849833285,75047317648499561,675425858836496045,6078832729528464401,54709494565756179605,492385451091805616441,4431469059826250547965,39883221538436254931681,358948993845926294385125,3230540944613336649466121,29074868501520029845195085,261673816513680268606755761,2355064348623122417460801845,21195579137608101757147216601,190760212238472915814324949405,1716841910146256242328924544641,15451577191316306180960320901765,139064194721846755628642888115881,1251577752496620800657785993042925,11264199772469587205920073937386321,101377797952226284853280665436476885,912400181570036563679525988928291961
mov $1,9
pow $1,$0
div $1,2
add $1,1
mov $0,$1
|
oeis/001/A001520.asm
|
neoneye/loda-programs
| 11 |
173656
|
<filename>oeis/001/A001520.asm
; A001520: a(n) = (6*n+1)*(6*n+3)*(6*n+5).
; 15,693,3315,9177,19575,35805,59163,90945,132447,184965,249795,328233,421575,531117,658155,803985,969903,1157205,1367187,1601145,1860375,2146173,2459835,2802657,3175935,3580965,4019043,4491465,4999527,5544525,6127755,6750513,7414095,8119797,8868915,9662745,10502583,11389725,12325467,13311105,14347935,15437253,16580355,17778537,19033095,20345325,21716523,23147985,24641007,26196885,27816915,29502393,31254615,33074877,34964475,36924705,38956863,41062245,43242147,45497865,47830695,50241933,52732875
mul $0,6
seq $0,96382 ; Consider a Pythagorean triangle with sides a=u^2-v^2, b=2uv, c=u^2+v^2. The sequence is the area of the triangle when v=2, u=3,4,5,...
div $0,2
|
src/babel-strategies-default.ads
|
stcarrez/babel
| 1 |
13749
|
-----------------------------------------------------------------------
-- babel-strategies -- Strategies to backup files
-- Copyright (C) 2014 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.
-----------------------------------------------------------------------
pragma Ada_2012;
with Babel.Files.Queues;
package Babel.Strategies.Default is
type Default_Strategy_Type is new Babel.Strategies.Strategy_Type with private;
-- Returns true if there is a directory that must be processed by the current strategy.
overriding
function Has_Directory (Strategy : in Default_Strategy_Type) return Boolean;
-- Get the next directory that must be processed by the strategy.
overriding
procedure Peek_Directory (Strategy : in out Default_Strategy_Type;
Directory : out Babel.Files.Directory_Type);
overriding
procedure Execute (Strategy : in out Default_Strategy_Type);
-- Scan the directory
overriding
procedure Scan (Strategy : in out Default_Strategy_Type;
Directory : in Babel.Files.Directory_Type;
Container : in out Babel.Files.File_Container'Class);
-- Set the file queue that the strategy must use.
procedure Set_Queue (Strategy : in out Default_Strategy_Type;
Queue : in Babel.Files.Queues.File_Queue_Access);
-- overriding
-- procedure Add_File (Into : in out Default_Strategy_Type;
-- Path : in String;
-- Element : in Babel.Files.File);
--
-- overriding
-- procedure Add_Directory (Into : in out Default_Strategy_Type;
-- Path : in String;
-- Name : in String);
private
type Default_Strategy_Type is new Babel.Strategies.Strategy_Type with record
Queue : Babel.Files.Queues.File_Queue_Access;
end record;
end Babel.Strategies.Default;
|
EE321_PreLab/lab1.asm
|
eminkartci/MicroController-Assembly
| 1 |
22177
|
0: CP 110 100
1: CP 50 100
2: LT 50 101
3: BZJ 20 50
4: CP 110 101
5: BZJi 20 0
6: CP 51 110
7: LT 51 102
8: BZJ 21 51
9: CP 110 102
10: BZJi 21 0
20: 5
21: 10
100: 30
101: 31
102: 33
|
oeis/345/A345939.asm
|
neoneye/loda-programs
| 11 |
383
|
; A345939: a(n) = (n-1) / gcd(n-1, uphi(n)), where uphi is unitary totient (or unitary phi) function, A047994.
; Submitted by <NAME>
; 0,1,1,1,1,5,1,1,1,9,1,11,1,13,7,1,1,17,1,19,5,21,1,23,1,25,1,3,1,29,1,1,8,33,17,35,1,37,19,39,1,41,1,43,11,45,1,47,1,49,25,17,1,53,27,55,14,57,1,59,1,61,31,1,4,13,1,67,17,23,1,71,1,73,37,25,19,77,1,79,1,81,1,83,21,85,43,87,1,89,5,91,23,93,47,95,1,97,49,11
mov $2,$0
seq $0,47994 ; Unitary totient (or unitary phi) function uphi(n).
mov $1,$0
gcd $1,$2
div $2,$1
mov $0,$2
|
oeis/331/A331151.asm
|
neoneye/loda-programs
| 11 |
92171
|
<filename>oeis/331/A331151.asm<gh_stars>10-100
; A331151: Triangle read by rows: T(n,k) (n>=k>=1) = ceiling((n/k)*floor(n/k)).
; Submitted by <NAME>
; 1,4,1,9,2,1,16,4,2,1,25,5,2,2,1,36,9,4,2,2,1,49,11,5,2,2,2,1,64,16,6,4,2,2,2,1,81,18,9,5,2,2,2,2,1,100,25,10,5,4,2,2,2,2,1,121,28,11,6,5,2,2,2,2,2,1,144,36,16,9,5,4,2,2,2,2,2,1,169,39,18,10,6,5,2,2,2,2,2,2,1
lpb $0
add $1,1
sub $0,$1
lpe
add $0,1
add $1,1
mov $2,$1
div $1,$0
mul $2,$1
sub $2,1
div $2,$0
mov $0,$2
add $0,1
|
drivers/chebyshev.ads
|
sciencylab/lagrangian-solver
| 0 |
24362
|
with Numerics;
use Numerics;
package Chebyshev is
function Chebyshev_Gauss_Lobatto (N : in Nat;
L : in Real := 0.0;
R : in Real := 1.0) return Real_Vector;
function Derivative_Matrix (N : in Nat;
L : in Real := 0.0;
R : in Real := 1.0) return Real_Matrix;
procedure CGL (D : out Real_Matrix;
X : out Real_Vector;
N : in Nat;
L : in Real := 0.0;
R : in Real := 1.0);
function CGL_Transform (F : in Real_Vector) return Real_Vector;
function Interpolate (A : in Real_Vector;
X : in Real;
L : in Real := 0.0;
R : in Real := 1.0) return Real;
end Chebyshev;
|
software/lib/generic_pid_controller.adb
|
TUM-EI-RCS/StratoX
| 12 |
4022
|
package body Generic_PID_Controller with SPARK_Mode => On is
procedure initialize( Pid : out Pid_Object;
Kp : PID_Coefficient_Type;
Ki : PID_Coefficient_Type;
Kd : PID_Coefficient_Type;
I_Limit_Low : PID_Data_Type := PID_INTEGRAL_LIMIT_LOW;
I_Limit_High : PID_Data_Type := PID_INTEGRAL_LIMIT_HIGH;
Output_Limit_Low : PID_Output_Type := PID_OUTPUT_LIMIT_LOW;
Output_Limit_High : PID_Output_Type := PID_OUTPUT_LIMIT_HIGH )
is
begin
Pid.Previous_Error := PID_Data_Type( 0.0 );
Pid.Integral := PID_Data_Type( 0.0 );
Pid.Kp := Kp;
Pid.Ki := Ki;
Pid.Kd := Kd;
Pid.I_Limit_Low := I_Limit_Low;
Pid.I_Limit_High := I_Limit_High;
Pid.Output_Limit_Low := Output_Limit_Low;
Pid.Output_Limit_High := Output_Limit_High;
end initialize;
procedure reset (Pid : out Pid_Object) is
begin
Pid.Previous_Error := PID_Data_Type( 0.0 );
Pid.Integral := PID_Data_Type( 0.0 );
end reset;
-- step
procedure step ( Pid : in out Pid_Object;
error : PID_Data_Type;
dt : Time_Type;
result : out PID_Output_Type)
is
derivate : Base_Unit_Type := 0.0;
output : Base_Unit_Type := 0.0;
tmp_integral : Base_Unit_Type := 0.0;
begin
-- Intetgral Part
tmp_integral := Base_Unit_Type(Pid.Integral) + Base_Unit_Type(error) * Base_Unit_Type(dt);
if tmp_integral in Base_Unit_Type(Pid.I_Limit_Low) .. Base_Unit_Type(Pid.I_Limit_High) then
Pid.Integral := PID_Integral_Type( tmp_integral );
else
if tmp_integral < Base_Unit_Type(Pid.I_Limit_Low) then
Pid.Integral := Pid.I_Limit_Low;
else
Pid.Integral := Pid.I_Limit_High;
end if;
end if;
-- Derivate Part
derivate := Base_Unit_Type(error - Pid.Previous_Error) / Base_Unit_Type( dt );
Pid.Previous_Error := error;
-- Calculate Output with Gains
output := Base_Unit_Type( Pid.Kp ) * Base_Unit_Type( error ) +
Base_Unit_Type( Pid.Ki ) * Base_Unit_Type( Pid.Integral ) +
Base_Unit_Type( Pid.Kd ) * derivate;
-- Saturate Output
if output < Base_Unit_Type( Pid.Output_Limit_Low ) then
output := Base_Unit_Type( Pid.Output_Limit_Low );
elsif output > Base_Unit_Type(Pid.Output_Limit_High) then
output := Base_Unit_Type( Pid.Output_Limit_High );
end if;
result := PID_Output_Type( output );
end step;
end Generic_PID_Controller;
|
library/fmGUI_ManageFunctions/fmGUI_CustomFunctions_ParamsForFunction.applescript
|
NYHTC/applescript-fm-helper
| 1 |
1763
|
<filename>library/fmGUI_ManageFunctions/fmGUI_CustomFunctions_ParamsForFunction.applescript
-- fmGUI_CustomFunctions_ParamsForFunction({functionName:null})
-- <NAME>, NYHTC
-- return a list of params for a specified function
(*
HISTORY:
1.2 - 2017-06-28 ( eshagdar ): convert params to a record.
1.1 -
1.0 - created
REQUIRES:
fmGUI_ManageDb_GoToTab
*)
on run
fmGUI_CustomFunctions_ParamsForFunction({functionName:"_Access_canView"})
end run
--------------------
-- START OF CODE
--------------------
on fmGUI_CustomFunctions_ParamsForFunction(prefs)
-- version 1.2
set defaultPrefs to {functionName:null}
set prefs to prefs & defaultPrefs
try
fmGUI_CustomFunctions_Open({})
tell application "System Events"
tell application process "FileMaker Pro Advanced"
set rawParams to value of static text 2 of (first row of table 1 of scroll area 1 of window 1 whose (value of static text 1) is functionName of prefs)
end tell
end tell
set parsedParams to parseChars({rawParams, " ; "})
return parsedParams
on error errMsg number errNum
error "Couldn't get custom function parameters - " & errMsg number errNum
end try
end fmGUI_CustomFunctions_ParamsForFunction
--------------------
-- END OF CODE
--------------------
on fmGUI_CustomFunctions_Open(prefs)
tell application "htcLib" to fmGUI_CustomFunctions_Open(prefs)
end fmGUI_CustomFunctions_Open
on parseChars(prefs)
tell application "htcLib" to parseChars(prefs)
end parseChars
|
src/zmq-utilities-stream_element_array_image.adb
|
persan/zeromq-Ada
| 33 |
15740
|
<reponame>persan/zeromq-Ada
-------------------------------------------------------------------------------
-- --
-- 0MQ Ada-binding --
-- --
-- ZMQ.Utilities.Stream_Element_Array_Image --
-- --
-- B o d y --
-- --
-- Copyright (C) 2020-2030, <EMAIL> --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files --
-- (the "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, sublicense, and / or sell copies of the Software, and to --
-- permit persons to whom the Software is furnished to do so, subject to --
-- the following conditions : --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, --
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL --
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR --
-- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, --
-- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR --
-- OTHER DEALINGS IN THE SOFTWARE. --
-------------------------------------------------------------------------------
function ZMQ.Utilities.Stream_Element_Array_Image
(Item : Ada.Streams.Stream_Element_Array)
return String
is
use Ada.Streams;
Cursor : Natural;
type Map_String is array (Stream_Element (0) ..
Stream_Element (15)) of Character;
Hex : constant Map_String := "0123456789ABCDEF";
begin
return Ret : String (1 .. Item'Length * 3 - 1) do
Cursor := Ret'First;
for I in Item'Range loop
Ret (Cursor) := Hex (Item (I) / 16);
Cursor := Cursor + 1;
Ret (Cursor) := Hex (Item (I) mod 16);
Cursor := Cursor + 1;
if I < Item'Last then
Ret (Cursor) := ' ';
Cursor := Cursor + 1;
end if;
end loop;
end return;
end ZMQ.Utilities.Stream_Element_Array_Image;
|
tools/scitools/conf/understand/ada/ada12/a-intsig.ads
|
brucegua/moocos
| 1 |
3062
|
<filename>tools/scitools/conf/understand/ada/ada12/a-intsig.ads<gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- A D A . I N T E R R U P T S . S I G N A L --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2009, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This package encapsulates the procedures for generating interrupts
-- by user programs and avoids importing low level children of System
-- (e.g. System.Interrupt_Management.Operations), or defining an interface
-- to complex system calls.
package Ada.Interrupts.Signal is
procedure Generate_Interrupt (Interrupt : Interrupt_ID);
-- Generate interrupt at the process level
end Ada.Interrupts.Signal;
|
Transynther/x86/_processed/NONE/_zr_/i9-9900K_12_0xa0.log_21829_430.asm
|
ljhsiun2/medusa
| 9 |
240337
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r8
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x150af, %rsi
lea addresses_D_ht+0x1225f, %rdi
nop
nop
nop
dec %rbp
mov $41, %rcx
rep movsl
nop
nop
nop
nop
nop
sub $23175, %r8
lea addresses_D_ht+0xc12f, %rcx
nop
nop
nop
nop
and %r10, %r10
mov (%rcx), %esi
nop
nop
nop
nop
xor $12337, %r10
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %rbp
push %rbx
push %rdx
push %rsi
// Faulty Load
lea addresses_UC+0x972f, %rsi
nop
nop
nop
xor %rbx, %rbx
mov (%rsi), %r11w
lea oracles, %rbp
and $0xff, %r11
shlq $12, %r11
mov (%rbp,%r11,1), %r11
pop %rsi
pop %rdx
pop %rbx
pop %rbp
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': True, 'same': True, 'congruent': 0, 'type': 'addresses_UC', 'AVXalign': True, 'size': 1}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_UC', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 5, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_D_ht'}}
{'src': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 4}, '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
*/
|
src/System/IO/Transducers/Strict.agda
|
ilya-fiveisky/agda-system-io
| 10 |
5052
|
<reponame>ilya-fiveisky/agda-system-io
open import Coinduction using ( ∞ ; ♭ ; ♯_ )
open import Data.Bool using ( Bool ; true ; false )
open import Data.Empty using ( ⊥ ; ⊥-elim )
open import Data.Unit using ( ⊤ ; tt )
open import System.IO.Transducers.Lazy using
( _⇒_ ; inp ; out ; done ; choice ) renaming
( ⟦_⟧ to ⟦_⟧' ; _⟫_ to _⟫'_
; _[&]_ to _[&]'_ ; _⟨&⟩_ to _⟨&⟩'_ ; assoc to assoc' )
open import System.IO.Transducers.Session using ( Session ; I ; Σ ; Γ ; _/_ ; IsΣ ; ⟨_⟩ ; _&_ ; ¿ ; _⊕_ )
open import System.IO.Transducers.Trace using ( Trace ; [] ; _∷_ )
module System.IO.Transducers.Strict where
infixr 4 _⇛_
infixr 6 _⟫_
infixr 8 _[&]_ _⟨&⟩_
-- Strict tranducers are ones which perform input before any output
data Strict : ∀ {S T} → (S ⇒ T) → Set₁ where
inp : ∀ {A V F T} P → (Strict (inp {A} {V} {F} {T} P))
done : ∀ {S} → (Strict (done {S}))
-- Slightly annoyingly, _≡_ has different cardinalities
-- in different versions of the standard library.
-- Until 1.4 of agda-stdlib is more widely distributed,
-- we define a specialized version of _≡_ here.
data _≡_ (S : Session) : Session → Set₁ where
refl : S ≡ S
-- S ⇛ T is the type of strict transducers regarded as functions
_⇛_ : Session → Session → Set₁
I ⇛ T = I ≡ T
Σ V F ⇛ T = ∀ a → (♭ F a) ⇒ T
-- Identity transducer
id : ∀ {S} → S ⇛ S
id {I} = refl
id {Σ V F} = λ a → out a done
-- Inclusion of strict in lazy transducers
ι : ∀ {S T} → (S ⇛ T) → (S ⇒ T)
ι {I} refl = done
ι {Σ V F} P = inp (♯ P)
-- Composition
_⟫_ : ∀ {S T U} → (S ⇛ T) → (T ⇛ U) → (S ⇛ U)
_⟫_ {I} refl refl = refl
_⟫_ {Σ V F} {I} P refl = P
_⟫_ {Σ V F} {Σ W G} P Q = λ a → (P a ⟫' ι Q)
-- & on transducers
_[&]_ : ∀ {S T U V} → (S ⇛ T) → (U ⇛ V) → ((S & U) ⇛ (T & V))
_[&]_ {I} refl Q = Q
_[&]_ {Σ V F} P Q = λ a → (P a [&]' ι Q)
-- Associativity of &
assoc : ∀ {S T U} → ((S & (T & U)) ⇛ ((S & T) & U))
assoc {I} {T} {U} = id {T & U}
assoc {Σ V F} {T} {U} = λ a → out a (assoc' {♭ F a})
-- Mediating morphism for &
_⟨&⟩_ : ∀ {S T U} → (S ⇛ T) → (S ⇛ U) → (S ⇛ T & U)
_⟨&⟩_ {I} refl refl = refl
_⟨&⟩_ {Σ V F} P Q = λ a → (P a ⟨&⟩' Q a)
|
Dot6502MiniConsole/SamplePrograms/ball.asm
|
terjew/Dot6502
| 4 |
166653
|
<gh_stars>1-10
RAND = $FE
VSYNC = $FD
SCREEN_W = 32
SCREEN_H = 32
BALL_COL = 2
width = $00
height = $01
xpos_tmp = $02
ypos_tmp = $03
xdir = $04
ydir = $05
pixel_addr = $06
pixel_msb = $07
width_1 = $08 //width minus 1
height_1 = $09 //height minus 1
*=$1800
setup LDX #SCREEN_W
STX width
DEX
STX width_1
LDY #SCREEN_H
STY height
DEY
STY height_1
LDA #$80
STA xdir
STA ydir
LDA #0 //pixel_addr should initially be set to start of framebuffer = 00 02 = $0200
STA pixel_addr
LDA #2
STA pixel_msb
randx LDA RAND //find random x starting position
CMP width_1
BMI xok
JMP randx
xok TAX
randy LDA RAND //find random y starting position
CMP height_1
BMI yok
JMP randy
yok TAY
//main loop
xmove LDA xdir //increase or decrease x
BEQ xneg
INX
JMP ymove
xneg DEX
ymove LDA ydir //increase or decrease y
BEQ yneg
INY
JMP calc_xdir
yneg DEY
calc_xdir TXA //flip if x hit 0 or width - 1
BEQ flipx
CMP width_1
BEQ flipx
JMP calc_ydir
flipx LDA xdir
CLC
ADC #$80
STA xdir
calc_ydir TYA //flip if y hit 0 or height - 1
BEQ flipy
CMP height_1
BEQ flipy
JMP drawball
flipy LDA ydir
CLC
ADC #$80
STA ydir
drawball STX xpos_tmp //draw the ball to the screenbuffer
STY ypos_tmp
LDY #0
LDA #0 //color 0 (black)
STA (pixel_addr),Y //zero out the previous ball pos
JSR calcrow
LDY #0
LDA #BALL_COL
STA (pixel_addr),Y //set ball pixel to ball color
ASL VSYNC //trigger VSYNC by shifting the value in that address
LDX xpos_tmp
LDY ypos_tmp
JMP xmove
calcrow LDA #0 //pixel_addr should initially be set to start of framebuffer = 00 02 = $0200
STA pixel_addr
LDA #2
STA pixel_msb
LDY ypos_tmp //if y is 0, skip the multiply loop
BEQ addx
multloop CLC
LDA pixel_addr
ADC width //add width to LSB
STA pixel_addr
LDA pixel_msb
ADC #0 //add carry to MSB
STA pixel_msb
DEY
BNE multloop //loop until Y is 0
addx CLC
LDA pixel_addr
ADC xpos_tmp //add xpos to LSB
STA pixel_addr
LDA pixel_msb
ADC #0 //add carry to MSB
STA pixel_msb
RTS
|
Cubical/Categories/Limits.agda
|
FernandoLarrain/cubical
| 1 |
7703
|
<gh_stars>1-10
{-# OPTIONS --safe #-}
module Cubical.Categories.Limits where
open import Cubical.Categories.Limits.Limits public
open import Cubical.Categories.Limits.BinProduct public
open import Cubical.Categories.Limits.BinCoproduct public
open import Cubical.Categories.Limits.Initial public
open import Cubical.Categories.Limits.Terminal public
open import Cubical.Categories.Limits.Pullback public
|
Transynther/x86/_processed/NC/_zr_/i9-9900K_12_0xa0.log_21829_815.asm
|
ljhsiun2/medusa
| 9 |
96962
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r15
push %r9
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x1bf20, %rsi
lea addresses_D_ht+0x1e7bc, %rdi
nop
nop
nop
nop
cmp $27095, %r15
mov $81, %rcx
rep movsl
nop
sub %r11, %r11
lea addresses_WC_ht+0x1b23c, %r9
nop
nop
nop
add %r12, %r12
movw $0x6162, (%r9)
nop
nop
nop
nop
nop
cmp %rcx, %rcx
lea addresses_UC_ht+0x13aa3, %rsi
nop
nop
nop
nop
dec %rcx
mov $0x6162636465666768, %r15
movq %r15, (%rsi)
nop
xor %rsi, %rsi
lea addresses_A_ht+0xde3c, %rsi
lea addresses_WC_ht+0x1d72c, %rdi
nop
nop
nop
nop
cmp $27900, %rdx
mov $125, %rcx
rep movsb
sub %r12, %r12
lea addresses_A_ht+0xca3c, %r9
nop
nop
nop
nop
add $17338, %r11
mov $0x6162636465666768, %rdi
movq %rdi, (%r9)
dec %r9
lea addresses_normal_ht+0x13e88, %r11
clflush (%r11)
inc %rcx
vmovups (%r11), %ymm6
vextracti128 $1, %ymm6, %xmm6
vpextrq $1, %xmm6, %r15
nop
nop
nop
cmp $1312, %rcx
lea addresses_WT_ht+0xca3c, %rsi
lea addresses_A_ht+0x1c63c, %rdi
nop
nop
nop
nop
nop
and $24258, %r12
mov $83, %rcx
rep movsb
nop
nop
nop
dec %r12
lea addresses_WC_ht+0x1ba3c, %rsi
nop
nop
nop
inc %r15
movb $0x61, (%rsi)
nop
nop
sub $5966, %rdi
lea addresses_D_ht+0xb83c, %rdi
xor $57600, %r9
mov $0x6162636465666768, %rdx
movq %rdx, %xmm2
vmovups %ymm2, (%rdi)
nop
sub $19517, %r9
lea addresses_A_ht+0x1403c, %rsi
lea addresses_WC_ht+0x823c, %rdi
nop
nop
nop
nop
and $34706, %r11
mov $65, %rcx
rep movsw
nop
nop
dec %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r14
push %r9
push %rax
push %rcx
// Faulty Load
mov $0x66a235000000023c, %r14
nop
nop
nop
add $22141, %rcx
mov (%r14), %eax
lea oracles, %r9
and $0xff, %rax
shlq $12, %rax
mov (%r9,%rax,1), %rax
pop %rcx
pop %rax
pop %r9
pop %r14
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_D_ht'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 2}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 8}}
{'src': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': True, 'congruent': 0, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 8}}
{'src': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 11, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_A_ht'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_WC_ht', 'AVXalign': True, 'size': 1}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32}}
{'src': {'same': False, 'congruent': 9, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_WC_ht'}}
{'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
*/
|
src/kernel.asm
|
travisbale/CardinalOS
| 0 |
242387
|
<filename>src/kernel.asm<gh_stars>0
BITS 32
global _start
extern kernel_main
PROT_MODE_DATA_SEG equ 0x10 ; Kernel data segment selector
_start:
; Setup the protected mode segment registers
mov ax, PROT_MODE_DATA_SEG
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
; Enable the A20 line using the Fast A20 Gate
in al, 0x92
or al, 0x2
out 0x92, al
call kernel_main
; kernel_main should never return but if it does, just loop
jmp $
; Align the assembly to 16 bytes so the C code is properly aligned
times 512 - ($ - $$) db 0
|
src/asf-validators.ads
|
jquorning/ada-asf
| 12 |
13268
|
<reponame>jquorning/ada-asf
-----------------------------------------------------------------------
-- asf-validators -- ASF Validators
-- Copyright (C) 2010 <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.
-----------------------------------------------------------------------
with EL.Objects;
with ASF.Components.Base;
with ASF.Contexts.Faces;
-- = Validators =
-- The validators participate in the validation of submitted values during
-- the request validation phase. They are responsible for checking whether the
-- input parameter complies with the validation rules associated with the input
-- field. The validator is expected to raise an exception and an error message
-- is then associated with the faulty input field.
--
-- The validator is described in the XHTML file by using one of the following
-- JSF core components:
--
-- | Component | Validation type |
-- |------------------------|-----------------------------------------------------|
-- | f:validateLength | The input field must have a minimun/maximum length |
-- | f:validateLongRange | The input field must be a number in the given range |
-- | f:validator | An Ada registered or custom validator is used |
-- | f:validateRegex | The input field must match the regular expression |
--
-- A validator instance must implement the `ASF.Validators.Validator` interface.
-- It only needs to implement the `Validate` procedure which gets the UI
-- component, the faces request context and the submitted value. It must verify
-- the value according to the validator's rule and the UI component. When the
-- value is incorrect, it must set an error message in the UI component so that
-- some user friendly message is reported. In case of error, it must also
-- raise the `Invalid_Value` exception.
--
-- @include asf-validators-texts.ads
-- @include asf-validators-numbers.ads
--
package ASF.Validators is
Invalid_Value : exception;
-- ------------------------------
-- Validator
-- ------------------------------
-- The <b>Validator</b> implements a procedure to verify the validity of
-- an input parameter. The <b>validate</b> procedure is called after the
-- converter. The validator instance must be registered in
-- the component factory (See <b>ASF.Factory.Component_Factory</b>).
-- Unlike the Java implementation, the instance will be shared by multiple
-- views and requests. The validator is also responsible for adding the necessary
-- error message in the faces context.
type Validator is limited interface;
type Validator_Access is access all Validator'Class;
-- Verify that the value matches the validation rules defined by the validator.
-- If some error are found, the procedure should create a <b>FacesMessage</b>
-- describing the problem and add that message to the current faces context.
-- The procedure can examine the state and modify the component tree.
-- It must raise the <b>Invalid_Value</b> exception if the value is not valid.
procedure Validate (Valid : in Validator;
Context : in out ASF.Contexts.Faces.Faces_Context'Class;
Component : in out ASF.Components.Base.UIComponent'Class;
Value : in EL.Objects.Object) is abstract;
end ASF.Validators;
|
agda/Cardinality/Finite/SplitEnumerable/Inductive.agda
|
oisdk/combinatorics-paper
| 4 |
10435
|
{-# OPTIONS --cubical --safe #-}
module Cardinality.Finite.SplitEnumerable.Inductive where
open import Data.List public
open import Data.List.Membership
open import Prelude
ℰ! : Type a → Type a
ℰ! A = Σ[ xs ⦂ List A ] ((x : A) → x ∈ xs)
|
src/semantica-declsc3a.adb
|
alvaromb/Compilemon
| 1 |
947
|
package body Semantica.Declsc3a is
-- Taula Procediments
procedure Nouproc
(Tp : in out T_Procs;
Idp : out Num_Proc) is
begin
Posa(Tp, Info_Proc_Nul, Idp);
end Nouproc;
function Consulta
(Tp : in T_Procs;
Idp : in Num_Proc) return Info_Proc is
begin
return Tp.Tp(Idp);
end Consulta;
-- Taula Variables
function Consulta
(Tv : in T_Vars;
Idv : in Num_Var) return Info_Var is
begin
return Tv.Tv(Idv);
end Consulta;
procedure Modif_Descripcio
(Tv : in out T_Vars;
Idv : in Num_Var;
Iv : in Info_Var) is
begin
Tv.Tv(Idv) := Iv;
end Modif_Descripcio;
procedure Novavar
(Tv : in out T_Vars;
Idpr : in Num_Proc;
Idv : out Num_Var) is
Ip : Info_Proc := Info_Proc_Nul;
Iv : Info_Var := Info_Var_Nul;
Numvar : Integer := Integer (Tv.Nv) + 1;
Nomvar : String := "_var" &
Integer'Image(Numvar);
Idn : Id_Nom;
begin
Nomvar(Nomvar'First + 4) := '_' ;
Posa_Id(Tn, Idn, Nomvar);
Ip:=Consulta(Tp, Idpr);
Iv:=(Id => Idn,
Np => Idpr,
Ocup => Integer'Size / 8,
Desp => 0,
Tsub => Tsent,
Param => False,
Const => False,
Valconst => 0);
Ip.Ocup_Var := Ip.Ocup_Var + Iv.Ocup;
Posa(Tv, Iv, Idv);
Modif_Descripcio(Tp, Idpr, Ip);
end Novavar;
procedure Novaconst
(Tv : in out T_Vars;
Vc : in Valor;
Tsub : in Tipussubjacent;
Idpr : in Num_Proc;
Idc : out Num_Var) is
Idn : Id_Nom;
E : Boolean;
Iv : Info_Var;
D : Descrip;
Ocup : Despl;
Nconst : Num_Var := Tv.Nv + 1;
Nomconst : String := "_cnt" & Nconst'img;
begin
Nomconst(Nomconst'First + 4) := '_';
if Tsub=Tsarr then
Ocup:=16*Integer'Size;
Nomconst(2..4):="str";
else
Ocup:=Integer'Size/8;
end if;
Posa_Id(Tn, Idn, Nomconst);
Iv:=(Id => Idn,
Np => Idpr,
Ocup => Integer'Size / 8,
Desp => 0,
Tsub => Tsub,
Param => False,
Const => True,
Valconst => Vc);
Posa(Tv, Iv, Idc);
D:=(Dconst,
Id_Nul,
Vc,
Nconst);
Posa(Ts, Idn, D, E);
end Novaconst;
function Nova_Etiq return Num_Etiq is
begin
Ne := Ne + 1;
return Ne;
end Nova_Etiq;
function Etiqueta
(Idpr : in num_Proc) return String is
Nomproc : String := Cons_Nom
(Tn, Consulta(Tp, Idpr).Idn);
begin
return "_" & Trim(Nomproc, Both);
end Etiqueta;
function Etiqueta
(N : in Integer) return String is
Text : String := "_etq" & Integer'Image (N);
begin
Text(Text'First+4):='_';
return Trim(Text, Both);
end Etiqueta;
function Etiqueta
(Ipr : in Info_Proc) return String is
begin
case Ipr.Tp is
when Intern =>
return "_etq_" & Trim(Ipr.Etiq'Img, Both);
when Extern =>
return "_" &
Trim(Cons_Nom(Tn, Ipr.Etiq_Extern), Both);
end case;
end Etiqueta;
--Fitxers
procedure Crea_Fitxer
(Nom_Fitxer : in String) is
begin
Create(F3as, Out_File, Nom_Fitxer&".c3as");
Create(F3at, Out_File, Nom_Fitxer&".c3at");
end Crea_Fitxer;
procedure Obrir_Fitxer
(Nom_Fitxer : in String) is
begin
Open(F3as, In_File, Nom_Fitxer&".c3as");
end Obrir_Fitxer;
procedure Tanca_Fitxer is
begin
Close(F3as);
end Tanca_Fitxer;
procedure Llegir_Fitxer
(Instruccio : out c3a) is
begin
Read(F3as, Instruccio);
end Llegir_Fitxer;
procedure Escriure_Fitxer
(Instruccio : in c3a) is
begin
-- Escriptura a arxiu binari
Write(F3as, Instruccio);
-- Escriptura a arxiu de text
Put(F3at, Instruccio.Instr'Img & Ascii.Ht);
if Instruccio.Instr <= Branc_Inc then
-- 1 operand
case Instruccio.Camp1.Tc is
when Proc =>
Put_Line(F3at, Instruccio.Camp1.Idp'Img);
when Var =>
Put_Line(F3at, Instruccio.Camp1.Idv'Img);
when Const =>
Put_Line(F3at, Instruccio.Camp1.Idc'Img);
when Etiq =>
Put_Line(F3at, Instruccio.Camp1.Ide'Img);
when others =>
null;
end case;
elsif Instruccio.Instr <= Paramc then
-- 2 operands
case Instruccio.Camp1.Tc is
when Proc =>
Put(F3at, Instruccio.Camp1.Idp'Img &
Ascii.Ht);
when Var =>
Put(F3at, Instruccio.Camp1.Idv'Img &
Ascii.Ht);
when Const =>
Put(F3at, Instruccio.Camp1.Idc'Img &
Ascii.Ht);
when Etiq =>
Put(F3at, Instruccio.Camp1.Ide'Img &
Ascii.Ht);
when others =>
null;
end case;
case Instruccio.Camp2.Tc is
when Proc =>
Put_Line(F3at, Instruccio.Camp2.Idp'Img);
when Var =>
Put_Line(F3at, Instruccio.Camp2.Idv'Img);
when Const =>
Put_Line(F3at, Instruccio.Camp2.Idc'Img);
when Etiq =>
Put_Line(F3at, Instruccio.Camp1.Ide'Img);
when others =>
null;
end case;
else
-- 3 operands
case Instruccio.Camp1.Tc is
when Proc =>
Put(F3at, Instruccio.Camp1.Idp'Img &
Ascii.Ht);
when Var =>
Put(F3at, Instruccio.Camp1.Idv'Img &
Ascii.Ht);
when Const =>
Put(F3at, Instruccio.Camp1.Idc'Img &
Ascii.Ht);
when Etiq =>
Put(F3at, Instruccio.Camp1.Ide'Img &
Ascii.Ht);
when others =>
null;
end case;
case Instruccio.Camp2.Tc is
when Proc =>
Put(F3at, Instruccio.Camp2.Idp'Img &
Ascii.Ht);
when Var =>
Put(F3at, Instruccio.Camp2.Idv'Img &
Ascii.Ht);
when Const =>
Put(F3at, Instruccio.Camp2.Idc'Img &
Ascii.Ht);
when Etiq =>
Put(F3at, Instruccio.Camp1.Ide'Img &
Ascii.Ht);
when others =>
null;
end case;
case Instruccio.Camp3.Tc is
when Proc =>
Put_Line(F3at, Instruccio.Camp3.Idp'Img);
when Var =>
Put_Line(F3at, Instruccio.Camp3.Idv'Img);
when Const =>
Put_Line(F3at, Instruccio.Camp3.Idc'Img);
when Etiq =>
Put_Line(F3at, Instruccio.Camp3.Ide'Img);
when others =>
null;
end case;
end if;
end Escriure_Fitxer;
function Fi_Fitxer return Boolean is
begin
return End_Of_File(F3as);
end Fi_Fitxer;
end Semantica.Declsc3a;
|
Appl/Startup/CommonStartup/CMain/cmainStartupPrimary.asm
|
steakknife/pcgeos
| 504 |
22750
|
COMMENT @----------------------------------------------------------------------
Copyright (c) GeoWorks 1988 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Startup
FILE: cmainStartupApplication.asm
REVISION HISTORY:
Name Date Description
---- ---- -----------
atw 2/89 Initial version
DESCRIPTION:
This file contains a Startup application
$Id: cmainStartupApplication.asm,v 1.1 97/04/04 16:52:16 newdeal Exp $
------------------------------------------------------------------------------@
;##############################################################################
; Initialized data
;##############################################################################
; Turn off all artwork on the primary, since it no longer is displayed
;
_PRIMARY_ARTWORK = 0
;------------------------------------------------------------------------------
; Variables
;------------------------------------------------------------------------------
idata segment
StartupPrimaryClass
idata ends
;##############################################################################
; Code
;##############################################################################
if _PRIMARY_ARTWORK
if _NEW_DEAL
include cmainNewDealBitmap.asm
else
include cmainGlobalPCBitmap.asm
endif
endif
CommonCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
StartupPrimaryVisOpen
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Change the primary into a transparent window
CALLED BY: MSG_VIS_OPEN
PASS: *ds:si = StartupPrimaryClass object
ds:di = StartupPrimaryClass instance data
ds:bx = StartupPrimaryClass object (same as *ds:si)
es = segment of StartupPrimaryClass
ax = message #
RETURN: bp = 0 if top window, else window for object to open on
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
joon 10/01/98 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
StartupPrimaryVisOpen method dynamic StartupPrimaryClass,
MSG_VIS_OPEN
mov di, offset StartupPrimaryClass
call ObjCallSuperNoLock
mov ax, MSG_VIS_QUERY_WINDOW
call ObjCallInstanceNoLock
jcxz done
mov si, WIT_COLOR
clr ax, bx
mov ah, mask WCF_TRANSPARENT
mov di, cx
call WinSetInfo
done:
ret
StartupPrimaryVisOpen endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
StartupPrimaryVisDraw
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draw background bitmap
CALLED BY: MSG_VIS_DRAW
PASS: *ds:si = StartupPrimaryClass object
bp = gstate
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
joon 9/29/98 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if _PRIMARY_ARTWORK
StartupPrimaryVisDraw method dynamic StartupPrimaryClass,
MSG_VIS_DRAW
uses ax, cx, dx, si, bp, ds, es
.enter
call StartupPrimaryDrawBackgroundBitmap
call StartupPrimaryDrawEverythingElse
.leave
mov di, offset StartupPrimaryClass
GOTO ObjCallSuperNoLock
StartupPrimaryVisDraw endm
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
StartupPrimaryDrawEverythingElse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draw everything else
CALLED BY: StartupPrimaryVisDraw
PASS: bp = gstate
RETURN: bp = gstate
DESTROYED: everything
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
joon 9/29/98 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if _PRIMARY_ARTWORK
DELTA = -6
StartupPrimaryDrawEverythingElse proc near
mov cl, GST_PTR
mov bx, cs
mov si, offset chooseUIGString
call GrLoadGString ; si = GString
mov di, bp ; di = GState
clr ax, bx
mov dx, GSRT_COMPLETE
call GrDrawGString
mov dl, GSKT_LEAVE_DATA
call GrDestroyGString
ret
StartupPrimaryDrawEverythingElse endp
chooseUIGString label char
; Sans 24 point Bold Black
GSSetFont FID_DTC_URW_SANS, 24, 0
GSSetTextStyle <mask TS_BOLD>, <0>
GSSetTextColorIndex C_BLACK
GSDrawTextOptr 99, 109+DELTA, WhichDesktopString
GSDrawTextOptr 270, 210+DELTA, GlobalPCDesktopString
GSDrawTextOptr 270, 305+DELTA, StandardDesktopString
; Sans 24 point Bold Yellow
GSSetTextColor 250, 214, 62
GSDrawTextOptr 97, 107+DELTA, WhichDesktopString
GSDrawTextOptr 268, 208+DELTA, GlobalPCDesktopString
GSDrawTextOptr 268, 303+DELTA, StandardDesktopString
; Sans 18 point Normal Yellow
GSSetFont FID_DTC_URW_SANS, 18, 0
GSSetTextStyle <0>, <mask TS_BOLD>
GSDrawTextOptr 29, 418+DELTA, HelpString
GSDrawTextOptr 552, 418+DELTA, ShutDownString
; Sans 10 point Normal Yellow
if not _NEW_DEAL
GSSetFont FID_DTC_URW_SANS, 10, 0
GSDrawTextOptr 420, 50, TrademarkString
endif
; Sans 18 point Normal Light Gray
GSSetTextColorIndex C_LIGHT_GRAY
GSSetFont FID_DTC_URW_SANS, 18, 0
GSDrawTextOptr 98, 135+DELTA, YourDesktopString
GSDrawTextOptr 93, 153+DELTA, ItHelpsYouString
GSDrawTextOptr 268, 234+DELTA, ForEasyAccessString
GSDrawTextOptr 268, 252+DELTA, DocumentsAndProgramsString
GSDrawTextOptr 268, 329+DELTA, ForAdvancedAccessString
GSDrawTextOptr 268, 347+DELTA, DocumentsAndProgramsString
endif ; if _PRIMARY_ARTWORK
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
StartupPrimaryDrawBackgrounBitmap
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draw background bitmap
CALLED BY: StartupPrimaryVisDraw
PASS: bp = gstate
RETURN: bp = gstate
DESTROYED: everything
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
joon 9/29/98 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if _PRIMARY_ARTWORK
StartupPrimaryDrawBackgroundBitmap proc near
; calculate size of CBitmap block we need to draw
mov bx, handle ChooseUIBitmapHeaderResource
mov ax, MGIT_SIZE
call MemGetInfo
mov cx, ax ; cx = size of bitmap header block
call MemLock
mov ds, ax
mov dx, ds:[CB_simple].B_width
call MemUnlock
mov ax, SCANLINES_PER_RESOURCE
mul dx ; ax = size of bitmap data in a block
; allocate a block to hold the CBitmap we are going to draw
push cx
add ax, cx
mov cx, ALLOC_DYNAMIC_LOCK
call MemAlloc
mov es, ax
pop cx ; cx = size of bitmap header block
jc done
push bx
mov bx, handle ChooseUIBitmapHeaderResource
call MemLock
mov ds, ax
clr si, di
; copy the bitmap header into our CBitmap block
push cx
shr cx, 1
rep movsw
adc cx, cx
rep movsb
pop cx
mov es:[CB_startScan], 0 ; first scan is 0
mov es:[CB_numScans], 0 ; number of scans initially is 0
segmov ds, es
clr si ; ds:si = CBitmap
clr ax, bx ; draw at (0,0)
mov dx, cs
mov cx, offset StartupPrimaryDrawBackgroundBitmapCB
mov di, bp ; di = gstate
call GrDrawBitmap
pop bx
call MemFree
mov bx, handle ChooseUIBitmapHeaderResource
call MemUnlock
done:
ret
StartupPrimaryDrawBackgroundBitmap endp
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
StartupPrimaryDrawBackgroundBitmapCB
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draw background bitmap
CALLED BY: MSG_VIS_DRAW
PASS: ds:si = CBitmap
RETURN: ds:si = CBitmap
carry set if nothing more to draw
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
joon 9/29/98 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if _PRIMARY_ARTWORK
StartupPrimaryDrawBackgroundBitmapCB proc far
uses ax,bx,cx,dx,si,di,bp,ds,es
.enter
clr dx
mov ax, ds:[si].CB_startScan
add ax, ds:[si].CB_numScans
mov ds:[si].CB_startScan, ax
mov bx, SCANLINES_PER_RESOURCE
mov ds:[si].CB_numScans, bx
div bx
cmp ax, length chooseUIBitmapResourceTable
jae stopDrawing
mov bx, ax
add bx, bx
mov bx, cs:[chooseUIBitmapResourceTable][bx]
mov ax, SCANLINES_PER_RESOURCE
mul ds:[si].CB_simple.B_width
mov cx, ax
call MemLock
segmov es, ds
mov di, ds:[si].CB_data
mov ds, ax
clr si
shr cx, 1
rep movsw
adc cx, cx
rep movsb
call MemUnlock
clc
done:
.leave
ret
stopDrawing:
stc
jmp done
StartupPrimaryDrawBackgroundBitmapCB endp
endif
if _PRIMARY_ARTWORK
chooseUIBitmapResourceTable hptr \
ChooseUIBitmap00Resource,
ChooseUIBitmap01Resource,
ChooseUIBitmap02Resource,
ChooseUIBitmap03Resource,
ChooseUIBitmap04Resource,
ChooseUIBitmap05Resource,
ChooseUIBitmap06Resource,
ChooseUIBitmap07Resource,
ChooseUIBitmap08Resource,
ChooseUIBitmap09Resource,
ChooseUIBitmap0AResource,
ChooseUIBitmap0BResource,
ChooseUIBitmap0CResource,
ChooseUIBitmap0DResource,
ChooseUIBitmap0EResource,
ChooseUIBitmap0FResource,
ChooseUIBitmap10Resource,
ChooseUIBitmap11Resource,
ChooseUIBitmap12Resource,
ChooseUIBitmap13Resource,
ChooseUIBitmap14Resource,
ChooseUIBitmap15Resource,
ChooseUIBitmap16Resource,
ChooseUIBitmap17Resource,
ChooseUIBitmap18Resource,
ChooseUIBitmap19Resource,
ChooseUIBitmap1AResource,
ChooseUIBitmap1BResource,
ChooseUIBitmap1CResource,
ChooseUIBitmap1DResource,
ChooseUIBitmap1EResource,
ChooseUIBitmap1FResource,
ChooseUIBitmap20Resource,
ChooseUIBitmap21Resource,
ChooseUIBitmap22Resource,
ChooseUIBitmap23Resource,
ChooseUIBitmap24Resource,
ChooseUIBitmap25Resource,
ChooseUIBitmap26Resource,
ChooseUIBitmap27Resource,
ChooseUIBitmap28Resource,
ChooseUIBitmap29Resource,
ChooseUIBitmap2AResource,
ChooseUIBitmap2BResource
endif
CommonCode ends
|
Add Immediate/immadd.asm
|
adi-075/8085-microproccesor-programs
| 2 |
18452
|
<filename>Add Immediate/immadd.asm
;WAP to add 02H and 03H
jmp start
;03+02=05
;code
start: nop
MVI A, 03H ; Immediately move data to accumulator
ADI 02H ; Add Immediately
hlt
|
Transynther/x86/_processed/NC/_st_zr_un_sm_/i7-7700_9_0x48.log_21829_433.asm
|
ljhsiun2/medusa
| 9 |
5326
|
<reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r8
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x100b6, %rsi
lea addresses_D_ht+0xeef6, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
xor $65218, %r8
mov $88, %rcx
rep movsq
dec %rbx
lea addresses_UC_ht+0x1df76, %rsi
lea addresses_normal_ht+0x193c6, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
inc %r11
mov $113, %rcx
rep movsb
nop
nop
nop
cmp $20477, %rdi
lea addresses_D_ht+0xc616, %rcx
nop
xor %rsi, %rsi
movw $0x6162, (%rcx)
nop
nop
nop
nop
xor $44396, %rdi
lea addresses_WT_ht+0x1b7a6, %rsi
lea addresses_A_ht+0x569e, %rdi
clflush (%rsi)
nop
add $34482, %r8
mov $20, %rcx
rep movsl
nop
nop
nop
nop
nop
cmp $39128, %r11
lea addresses_A_ht+0x1036, %rdi
nop
nop
nop
sub %rcx, %rcx
mov (%rdi), %r11w
nop
nop
nop
xor %rbx, %rbx
lea addresses_normal_ht+0x12eb6, %rbx
clflush (%rbx)
nop
inc %r9
mov (%rbx), %cx
xor $38768, %r11
lea addresses_D_ht+0x17816, %r8
nop
nop
nop
nop
nop
add $19508, %r9
movups (%r8), %xmm7
vpextrq $1, %xmm7, %r11
nop
nop
nop
add %rdi, %rdi
lea addresses_normal_ht+0x71b6, %rsi
nop
nop
nop
nop
nop
dec %rbx
mov (%rsi), %r11w
nop
nop
sub $14852, %r9
lea addresses_UC_ht+0xc3b6, %rsi
lea addresses_normal_ht+0x1d9b6, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
xor $27861, %r11
mov $27, %rcx
rep movsq
nop
nop
nop
nop
nop
xor $16862, %r8
lea addresses_WT_ht+0x145e6, %rsi
nop
nop
nop
nop
add $64558, %rbx
mov (%rsi), %r8d
nop
nop
nop
sub %r8, %r8
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r8
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r13
push %r14
push %r9
push %rax
push %rbp
// Store
mov $0x5b6e8500000009b6, %rbp
cmp %r13, %r13
mov $0x5152535455565758, %r9
movq %r9, (%rbp)
// Exception!!!
nop
nop
nop
nop
mov (0), %r13
nop
nop
nop
nop
inc %r9
// Faulty Load
mov $0x5b6e8500000009b6, %r12
nop
nop
nop
nop
nop
xor $35759, %rax
vmovups (%r12), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $0, %xmm0, %r9
lea oracles, %r11
and $0xff, %r9
shlq $12, %r9
mov (%r11,%r9,1), %r9
pop %rbp
pop %rax
pop %r9
pop %r14
pop %r13
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 2, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 6, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': True, 'congruent': 8, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 5, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 9, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 4, 'size': 4, 'same': False, 'NT': False}}
{'58': 20008, '5f': 1666, '00': 155}
58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 5f 58 58 58 58 58 5f 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 5f 58 58 5f 5f 5f 5f 58 58 58 58 58 58 58 58 5f 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 5f 58 58 58 58 58 58 58 00 58 58 58 58 58 58 58 5f 58 58 58 58 58 5f 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 5f 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 00 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 5f 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 00 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 5f 58 58 58 5f 58 58 58 58 58 58 58 58 5f 58 58 58 58 5f 5f 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 5f 58 58 58 5f 5f 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 00 58 58 58 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 5f 00 58 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 5f 58 58 58 58 5f 58 5f 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5f 58 58 58 58 58 58 58 58
*/
|
libsrc/adt/linkedlist/adt_ListAdd.asm
|
ahjelm/z88dk
| 640 |
86816
|
; int adt_ListAdd(struct adt_List *list, void *item)
; 02.2003, 06.2005 aralbrec
; CALLER linkage for function pointers
SECTION code_clib
PUBLIC adt_ListAdd
PUBLIC _adt_ListAdd
EXTERN asm_adt_ListAdd
.adt_ListAdd
._adt_ListAdd
pop hl
pop bc
pop de
push de
push bc
push hl
jp asm_adt_ListAdd
|
Task/SHA-1/Ada/sha-1.ada
|
mullikine/RosettaCodeData
| 1 |
14822
|
<reponame>mullikine/RosettaCodeData
with Ada.Text_IO;
with GNAT.SHA1;
procedure Main is
begin
Ada.Text_IO.Put_Line ("SHA1 (""Rosetta Code"") = " &
GNAT.SHA1.Digest ("Rosetta Code"));
end Main;
|
src/main/java/edu/uiowa/smt/parser/antlr/Smt.g4
|
mudathirmahgoub/pdl
| 0 |
7676
|
grammar Smt;
// parser rules
model : '(' 'model' sortDeclaration* functionDefinition* ')' ;
sortDeclaration : '(' 'declare-sort' sortName arity ')' ;
functionDefinition : '(' 'define-fun' functionName '(' argument* ')' ('(' sort ')'| sort)
expression ')' ;
argument : '(' argumentName sort ')' ;
sort : sortName | tupleSort | setSort ;
setSort : 'Set' '(' sort ')' ;
tupleSort : 'Tuple' sort+ ;
sortName : Identifier ;
arity : Integer ;
functionName : Identifier ;
argumentName : Identifier ;
expression : constant
| variable
| unaryExpression
| binaryExpression
| ternaryExpression
| multiArityExpression
| '(' expression ')';
unaryExpression : UnaryOperator expression ;
binaryExpression : BinaryOperator expression expression ;
ternaryExpression : TernaryOperator expression expression expression ;
multiArityExpression : MultiArityOperator expression+ ;
variable : Identifier;
constant : boolConstant
| integerConstant
| uninterpretedConstant
| emptySet ;
boolConstant : True | False;
integerConstant : '-' Integer | Integer ;
uninterpretedConstant : (AtomPrefix | UninterpretedIntPrefix) Integer;
emptySet : 'as' 'emptyset' '(' 'Set' '(' sort ')' ')' ;
getValue : '(' ('(' expression expression ')' )+ ')';
// lexer rules
True: 'true' ;
False: 'false' ;
UnaryOperator : 'not' | 'singleton' | 'complement' | 'transpose' | 'tclosure' ;
BinaryOperator : '=' | '>' | '>=' | '<' | '<='
| '+' | '-' | '*' | '/' | 'mod'
| 'or' | 'and' | '=>'
| 'union' | 'intersection' | 'setminus' | 'member' | 'subset'
| 'join' | 'product' ;
TernaryOperator : 'ite' ;
MultiArityOperator : 'mkTuple' | 'insert' | 'distinct' ;
AtomPrefix : '@uc_Atom_';
UninterpretedIntPrefix : '@uc_UninterpretedInt_' ;
Identifier : IdentifierLetter (IdentifierLetter | Digit)* ;
IdentifierLetter : 'a'..'z'|'A'..'Z'|'_' ;
Integer : Digit+ ;
Digit : '0'..'9' ;
Comment : ';' ~( '\r' | '\n' )* -> skip ;
Whitespace : [ \t\r\n]+ -> skip ;
|
server/src/parser/pony.g4
|
Fepelus/pony-language-server
| 0 |
1963
|
// ANTLR v4 grammar
grammar pony;
// Parser
module
: STRING? use* class_def*
;
use
: 'use' (identifier '=')? (STRING | use_ffi) ('if' infix)?
;
use_ffi
: '@' (identifier | STRING) typeargs ('(' | LPAREN_NEW) params? ')' '?'?
;
class_def
: ('type' | 'interface' | 'trait' | 'primitive' | 'struct' | 'class' | 'actor') ('\\' identifier (',' identifier)* '\\')? '@'? cap? identifier typeparams? ('is' type)? STRING? members
;
members
: field* method*
;
field
: ('var' | 'let' | 'embed') identifier ':' type ('=' infix)? STRING?
;
method
: ('fun' | 'be' | 'new') ('\\' identifier (',' identifier)* '\\')? (cap | '@')? identifier typeparams? ('(' | LPAREN_NEW) params? ')' (':' type)? '?'? STRING? ('=>' rawseq)?
;
annotatedrawseq
: ('\\' identifier (',' identifier)* '\\')? (exprseq | jump)
;
rawseq
: exprseq
| jump
;
exprseq
: assignment (semiexpr | nosemi)?
;
nextexprseq
: nextassignment (semiexpr | nosemi)?
;
nosemi
: nextexprseq
| jump
;
semiexpr
: ';' (exprseq | jump)
;
jump
: ('return' | 'break' | 'continue' | 'error' | 'compile_intrinsic' | 'compile_error') rawseq?
;
nextassignment
: nextinfix ('=' assignment)?
;
assignment
: infix ('=' assignment)?
;
nextinfix
: nextterm antlr_0*
;
infix
: term antlr_1*
;
isop
: ('is' | 'isnt') term
;
binop
: ('and' | 'or' | 'xor' | '+' | '-' | '*' | '/' | '%' | '+~' | '-~' | '*~' | '/~' | '%~' | '<<' | '>>' | '<<~' | '>>~' | '==' | '!=' | '<' | '<=' | '>=' | '>' | '==~' | '!=~' | '<~' | '<=~' | '>=~' | '>~') '?'? term
;
nextterm
: 'if' ('\\' identifier (',' identifier)* '\\')? rawseq 'then' rawseq (elseif | ('else' annotatedrawseq))? 'end'
| 'ifdef' ('\\' identifier (',' identifier)* '\\')? infix 'then' rawseq (elseifdef | ('else' annotatedrawseq))? 'end'
| 'iftype' ('\\' identifier (',' identifier)* '\\')? iftype (elseiftype | ('else' annotatedrawseq))? 'end'
| 'match' ('\\' identifier (',' identifier)* '\\')? rawseq caseexpr* ('else' annotatedrawseq)? 'end'
| 'while' ('\\' identifier (',' identifier)* '\\')? rawseq 'do' rawseq ('else' annotatedrawseq)? 'end'
| 'repeat' ('\\' identifier (',' identifier)* '\\')? rawseq 'until' annotatedrawseq ('else' annotatedrawseq)? 'end'
| 'for' ('\\' identifier (',' identifier)* '\\')? idseq 'in' rawseq 'do' rawseq ('else' annotatedrawseq)? 'end'
| 'with' ('\\' identifier (',' identifier)* '\\')? (withelem (',' withelem)*) 'do' rawseq ('else' annotatedrawseq)? 'end'
| 'try' ('\\' identifier (',' identifier)* '\\')? rawseq ('else' annotatedrawseq)? ('then' annotatedrawseq)? 'end'
| 'recover' ('\\' identifier (',' identifier)* '\\')? cap? rawseq 'end'
| 'consume' cap? term
| nextpattern
| '#' postfix
;
term
: 'if' ('\\' identifier (',' identifier)* '\\')? rawseq 'then' rawseq (elseif | ('else' annotatedrawseq))? 'end'
| 'ifdef' ('\\' identifier (',' identifier)* '\\')? infix 'then' rawseq (elseifdef | ('else' annotatedrawseq))? 'end'
| 'iftype' ('\\' identifier (',' identifier)* '\\')? iftype (elseiftype | ('else' annotatedrawseq))? 'end'
| 'match' ('\\' identifier (',' identifier)* '\\')? rawseq caseexpr* ('else' annotatedrawseq)? 'end'
| 'while' ('\\' identifier (',' identifier)* '\\')? rawseq 'do' rawseq ('else' annotatedrawseq)? 'end'
| 'repeat' ('\\' identifier (',' identifier)* '\\')? rawseq 'until' annotatedrawseq ('else' annotatedrawseq)? 'end'
| 'for' ('\\' identifier (',' identifier)* '\\')? idseq 'in' rawseq 'do' rawseq ('else' annotatedrawseq)? 'end'
| 'with' ('\\' identifier (',' identifier)* '\\')? (withelem (',' withelem)*) 'do' rawseq ('else' annotatedrawseq)? 'end'
| 'try' ('\\' identifier (',' identifier)* '\\')? rawseq ('else' annotatedrawseq)? ('then' annotatedrawseq)? 'end'
| 'recover' ('\\' identifier (',' identifier)* '\\')? cap? rawseq 'end'
| 'consume' cap? term
| pattern
| '#' postfix
;
withelem
: idseq '=' rawseq
;
caseexpr
: '|' ('\\' identifier (',' identifier)* '\\')? pattern? ('if' rawseq)? ('=>' rawseq)?
;
elseiftype
: 'elseif' ('\\' identifier (',' identifier)* '\\')? iftype (elseiftype | ('else' annotatedrawseq))?
;
iftype
: type '<:' type 'then' rawseq
;
elseifdef
: 'elseif' ('\\' identifier (',' identifier)* '\\')? infix 'then' rawseq (elseifdef | ('else' annotatedrawseq))?
;
elseif
: 'elseif' ('\\' identifier (',' identifier)* '\\')? rawseq 'then' rawseq (elseif | ('else' annotatedrawseq))?
;
idseq
: identifier
| ('(' | LPAREN_NEW) idseq_in_seq (',' idseq_in_seq)* ')'
;
idseq_in_seq
: identifier
| ('(' | LPAREN_NEW) idseq_in_seq (',' idseq_in_seq)* ')'
;
nextpattern
: ('var' | 'let' | 'embed') identifier (':' type)?
| nextparampattern
;
pattern
: ('var' | 'let' | 'embed') identifier (':' type)?
| parampattern
;
nextparampattern
: ('not' | 'addressof' | MINUS_NEW | MINUS_TILDE_NEW | 'digestof') parampattern
| nextpostfix
;
parampattern
: ('not' | 'addressof' | '-' | '-~' | MINUS_NEW | MINUS_TILDE_NEW | 'digestof') parampattern
| postfix
;
nextpostfix
: nextatom antlr_2*
;
postfix
: atom antlr_3*
;
call
: '(' positional? named? ')' '?'?
;
chain
: '.>' identifier
;
tilde
: '~' identifier
;
dot
: '.' identifier
;
nextatom
: identifier
| 'this'
| literal
| LPAREN_NEW rawseq tuple? ')'
| LSQUARE_NEW ('as' type ':')? rawseq? ']'
| 'object' ('\\' identifier (',' identifier)* '\\')? cap? ('is' type)? members 'end'
| '{' ('\\' identifier (',' identifier)* '\\')? cap? identifier? typeparams? ('(' | LPAREN_NEW) lambdaparams? ')' lambdacaptures? (':' type)? '?'? '=>' rawseq '}' cap?
| '@{' ('\\' identifier (',' identifier)* '\\')? cap? identifier? typeparams? ('(' | LPAREN_NEW) lambdaparams? ')' lambdacaptures? (':' type)? '?'? '=>' rawseq '}' cap?
| '@' (identifier | STRING) typeargs? ('(' | LPAREN_NEW) positional? named? ')' '?'?
| '__loc'
;
atom
: identifier
| 'this'
| literal
| ('(' | LPAREN_NEW) rawseq tuple? ')'
| ('[' | LSQUARE_NEW) ('as' type ':')? rawseq? ']'
| 'object' ('\\' identifier (',' identifier)* '\\')? cap? ('is' type)? members 'end'
| '{' ('\\' identifier (',' identifier)* '\\')? cap? identifier? typeparams? ('(' | LPAREN_NEW) lambdaparams? ')' lambdacaptures? (':' type)? '?'? '=>' rawseq '}' cap?
| '@{' ('\\' identifier (',' identifier)* '\\')? cap? identifier? typeparams? ('(' | LPAREN_NEW) lambdaparams? ')' lambdacaptures? (':' type)? '?'? '=>' rawseq '}' cap?
| '@' (identifier | STRING) typeargs? ('(' | LPAREN_NEW) positional? named? ')' '?'?
| '__loc'
;
tuple
: ',' rawseq (',' rawseq)*
;
lambdacaptures
: ('(' | LPAREN_NEW) (lambdacapture | 'this') (',' (lambdacapture | 'this'))* ')'
;
lambdacapture
: identifier (':' type)? ('=' infix)?
;
lambdaparams
: lambdaparam (',' lambdaparam)*
;
lambdaparam
: identifier (':' type)? ('=' infix)?
;
positional
: rawseq (',' rawseq)*
;
named
: 'where' namedarg (',' namedarg)*
;
namedarg
: identifier '=' rawseq
;
type
: atomtype ('->' type)?
;
atomtype
: 'this'
| cap
| ('(' | LPAREN_NEW) infixtype tupletype? ')'
| nominal
| lambdatype
| barelambdatype
;
barelambdatype
: '@{' cap? identifier? typeparams? ('(' | LPAREN_NEW) (type (',' type)*)? ')' (':' type)? '?'? '}' (cap | gencap)? ('^' | '!')?
;
lambdatype
: '{' cap? identifier? typeparams? ('(' | LPAREN_NEW) (type (',' type)*)? ')' (':' type)? '?'? '}' (cap | gencap)? ('^' | '!')?
;
tupletype
: ',' infixtype (',' infixtype)*
;
infixtype
: type antlr_4*
;
isecttype
: '&' type
;
uniontype
: '|' type
;
nominal
: identifier ('.' identifier)? typeargs? (cap | gencap)? ('^' | '!')?
;
gencap
: '#read'
| '#send'
| '#share'
| '#alias'
| '#any'
;
cap
: 'iso'
| 'trn'
| 'ref'
| 'val'
| 'box'
| 'tag'
;
typeargs
: '[' typearg (',' typearg)* ']'
;
typeparams
: ('[' | LSQUARE_NEW) typeparam (',' typeparam)* ']'
;
params
: (param | '...') (',' (param | '...'))*
;
typeparam
: identifier (':' type)? ('=' typearg)?
;
typearg
: type
| literal
| '#' postfix
;
literal
: 'true'
| 'false'
| INT
| FLOAT
| STRING
;
param
: identifier ':' type ('=' infix)?
;
antlr_0
: binop
| isop
| 'as' type
;
antlr_1
: binop
| isop
| 'as' type
;
antlr_2
: dot
| tilde
| chain
| typeargs
| call
;
antlr_3
: dot
| tilde
| chain
| typeargs
| call
;
antlr_4
: uniontype
| isecttype
;
// Rules of the form antlr_* are only present to avoid a bug in the
// interpreter
/* Precedence
Value:
1. postfix
2. unop
3. binop
4. =
5. seq
6. ,
Type:
1. ->
2. & |
3. ,
*/
identifier
: ID
;
// Lexer
ID
: LETTER (LETTER | DIGIT | '_' | '\'')*
| '_' (LETTER | DIGIT | '_' | '\'')*
;
INT
: DIGIT (DIGIT | '_')*
| '0' 'x' (HEX | '_')+
| '0' 'b' (BINARY | '_')+
| '\'' CHAR_CHAR* '\''
;
FLOAT
: DIGIT (DIGIT | '_')* ('.' DIGIT (DIGIT | '_')*)? EXP?
;
STRING
: '"' STRING_CHAR* '"'
| '"""' (('"' | '""') ? ~'"')* '"""' '"'*
;
LPAREN_NEW
: NEWLINE '('
;
LSQUARE_NEW
: NEWLINE '['
;
MINUS_NEW
: NEWLINE '-'
;
MINUS_TILDE_NEW
: NEWLINE '-~'
;
LINECOMMENT
: '//' ~('\n')* -> channel(HIDDEN)
;
NESTEDCOMMENT
: '/*' (NESTEDCOMMENT | '/' ~'*' | ~('*' | '/') | ('*'+ ~('*' | '/')))* '*'+ '/' -> channel(HIDDEN)
;
WS
: (' ' | '\t' | '\r')+ -> channel(HIDDEN)
;
NEWLINE
: '\n' (' ' | '\t' | '\r')* -> channel(HIDDEN)
;
fragment
CHAR_CHAR
: '\\' '\'' | CHAR_ESC
| ~('\'' | '\\')
;
fragment
STRING_CHAR
: '\\' '"' | ESC
| ~('"' | '\\')
;
fragment
EXP
: ('e' | 'E') ('+' | '-')? (DIGIT | '_')+
;
fragment
LETTER
: 'a'..'z' | 'A'..'Z'
;
fragment
BINARY
: '0'..'1'
;
fragment
DIGIT
: '0'..'9'
;
fragment
HEX
: DIGIT | 'a'..'f' | 'A'..'F'
;
fragment
ESC
: CHAR_ESC
| UNICODE_ESC
| UNICODE2_ESC
;
fragment
CHAR_ESC
: '\\' ('a' | 'b' | 'e' | 'f' | 'n' | 'r' | 't' | 'v' | '\\' | '0')
| HEX_ESC
;
fragment
HEX_ESC
: '\\' 'x' HEX HEX
;
fragment
UNICODE_ESC
: '\\' 'u' HEX HEX HEX HEX
;
fragment
UNICODE2_ESC
: '\\' 'U' HEX HEX HEX HEX HEX HEX
;
|
artwork/esqueleto/esqueleto_camina.asm
|
fjpena/sword-of-ianna-zx
| 67 |
16742
|
; ASM source file created by SevenuP v1.21
; SevenuP (C) Copyright 2002-2007 by <NAME>, aka Metalbrain
;GRAPHIC DATA:
;Pixel Size: ( 24, 32)
;Char Size: ( 3, 4)
;Frames: 6
;Sort Priorities: X char, Char line, Y char, Frame number
;Data Outputted: Gfx
;Interleave: Sprite
;Mask: No
esqueleto_camina:
DEFB 0, 0, 0, 0, 30, 0, 0, 63
DEFB 0, 0,114, 0, 0, 82, 0, 0
DEFB 13, 0, 0, 31, 0, 0, 10, 0
DEFB 0,192, 0, 1,142, 64, 1,117
DEFB 0, 3, 4, 64, 2,117, 0, 6
DEFB 4, 8, 4, 48, 80, 0, 1,200
DEFB 4, 7,144, 4, 31,160, 4,127
DEFB 0, 3, 28, 0, 3, 0, 0, 8
DEFB 36, 0, 0, 34,128, 0, 33, 64
DEFB 0, 80,128, 0, 34, 0, 0, 4
DEFB 0, 0, 72, 0, 0, 64, 0, 0
DEFB 133, 0, 1,128, 0, 0,120, 0
DEFB 0, 0, 0, 0, 0, 0, 0, 1
DEFB 224, 0, 3,240, 0, 7, 32, 0
DEFB 5, 32, 0, 0,208, 0, 1,240
DEFB 0, 6,160, 0, 6, 2, 0, 8
DEFB 115, 0, 11,167, 0, 8, 39, 0
DEFB 11,175, 0, 16, 47, 0, 14,158
DEFB 0, 1, 28, 0, 0,209, 0, 2
DEFB 202, 0, 0, 20, 0, 0,192, 0
DEFB 2, 0, 0, 2, 16, 0, 4, 8
DEFB 0, 4, 4, 0, 10, 0, 0, 20
DEFB 2, 0, 32, 4, 0, 64, 8, 1
DEFB 128, 16, 0,192, 42, 0, 56, 0
DEFB 0, 0, 0, 0, 0, 0, 0, 0
DEFB 0, 0, 30, 32, 0, 63, 48, 0
DEFB 114, 56, 0, 82, 56, 0, 13,120
DEFB 0,223,120, 0,202,120, 0, 0
DEFB 240, 0, 76,224, 0, 84,192, 2
DEFB 68, 0, 4, 65,128, 2, 61,136
DEFB 0, 0, 16, 0, 1, 40, 0,224
DEFB 80, 0,116,160, 1,180, 0, 0
DEFB 136, 0, 0, 96, 0, 0, 52, 0
DEFB 0, 26, 0, 2, 9, 0, 3,244
DEFB 0, 1, 9, 0, 1, 2, 0, 2
DEFB 4, 0, 2, 8, 0, 0, 21, 0
DEFB 0, 0, 0, 0, 1,224, 0, 3
DEFB 240, 0, 7, 32, 0, 5, 32, 0
DEFB 0,208, 0, 1,240, 0, 24,160
DEFB 0, 24, 8, 0, 0,228, 0, 23
DEFB 80, 0, 16, 68, 0, 39, 80, 0
DEFB 32, 66, 0, 19, 14, 0, 8, 62
DEFB 0, 0,252, 0, 6,120, 0, 22
DEFB 1, 0, 0,234, 0, 0, 69, 0
DEFB 7, 0, 0, 0,224, 0, 0, 24
DEFB 0, 0, 20, 0, 2, 24, 0, 4
DEFB 32, 0, 0, 64, 0, 1,128, 0
DEFB 0, 96, 0, 8, 16, 0, 21, 0
DEFB 0, 0, 0, 0, 0, 0, 0, 30
DEFB 0, 0, 63, 0, 0,114, 0, 0
DEFB 82, 0, 0, 13, 4, 0, 31, 2
DEFB 1,138, 4, 1,128, 66, 2, 14
DEFB 165, 2,117, 74, 4, 4, 5, 4
DEFB 117, 74, 8, 4, 36, 16, 53, 80
DEFB 8, 0, 0, 4, 7,224, 3,127
DEFB 192, 11, 31,128, 0, 6, 0, 0
DEFB 32, 0, 0, 12, 0, 0, 3, 64
DEFB 0, 32,160, 0, 64, 64, 0, 0
DEFB 128, 1, 1, 0, 2, 1, 0, 20
DEFB 2, 0, 8, 5,224, 5, 0, 0
DEFB 0, 0, 0, 0, 0, 0, 0, 0
DEFB 0, 0, 1,228, 0, 3,242, 0
DEFB 7, 37, 0, 5, 34, 0, 0,213
DEFB 0, 25,242, 0, 24,161, 0, 32
DEFB 10, 0, 64,225, 0,143, 82, 1
DEFB 0, 68, 2, 15, 82, 1, 0, 69
DEFB 0,135, 16, 2,192, 0, 0,223
DEFB 248, 0, 15,240, 0, 3,192, 0
DEFB 0, 0, 0, 1,128, 0, 0, 96
DEFB 0, 0, 16, 0, 16, 40, 0, 10
DEFB 144, 0, 16, 32, 0, 0, 64, 0
DEFB 16, 64, 0, 0,128, 0, 1,248
|
RecPyPortugues/src/lexrParsr/RecPyParser.g4
|
robertocsa/TCC_CComp_UERJ
| 0 |
7126
|
/*
Author: <NAME>
Completion of Course Work (in portuguese: TCC - Trabalho de Conclusao de Curso)
Advisor: Prof. Dsc. <NAME> (Ciências da Computação - UERJ)
*/
parser grammar RecPyParser;
options {tokenVocab=RecPyLexer;}
@header{
// import javax.swing.JOptionPane;
package lexrParsr;
}
@members{
//public boolean isDef_LT(){
//JOptionPane.showMessageDialog(null,"Debug: entrou na linha 17");
// return (_input.LT(1).getText().toUpperCase().equals("DEF"));
//}
public enum TipoTrad {
TAIL_RECURSIVE,
NON_TAIL_RECURSIVE,
ITERATIVE
}
// Antes de realizar testes na linha de comando (CMD), configurar a linha abaixo conforme o tipo de algoritmo a testar:
// Fazer isso tanto no LEXER quanto no PARSER
private TipoTrad tipoTraduc=TipoTrad.NON_TAIL_RECURSIVE;
public void setTipoTraduc(TipoTrad tipoTrd_){
tipoTraduc=tipoTrd_;
}
public boolean isTailRecursive(){
return tipoTraduc==TipoTrad.TAIL_RECURSIVE;
}
public boolean isNonTailRecursive(){
return tipoTraduc==TipoTrad.NON_TAIL_RECURSIVE;
}
public boolean isIterative(){
return tipoTraduc==TipoTrad.ITERATIVE;
}
}
/*
* parser rules
*/
start: ( (defTailRecursive)|(defNonTailRecursive)|(defIterative) ) EOF;
defTailRecursive:
( {isTailRecursive()}?
(def_blk)
(((if_expr)
(interm)*?)
(return_expr))
((else_)*
(interm)*?)
((return_tr)
(interm)*?)
(empty_line)*
);
defNonTailRecursive:
( {isNonTailRecursive()}?
(def_blk)
(((if_expr)
(interm)*?)
(return_expr))
((else_)*
(interm)*?)
((return_ntr)
(interm)*?)
(empty_line)*
);
defIterative:
( {isIterative()}?
(def_blk)
(start_while_blk)
(end_while_blk)
(empty_line)*
);
def_blk: (DEF_BLK interm*);
start_while_blk: ( START_WHILE_BLK interm*);
end_while_blk: (END_WHILE_BLK interm*);
if_expr: IF_EXPR;
else_: ELSE_;
return_expr: RETURN_EXPR;
return_tr: ( {isTailRecursive()}? RETURN_TR);
return_ntr: ({isNonTailRecursive()}? RETURN_NTR);
print: PRINT;
comment: COMMENT;
attribution: (ATTRIBUTION);
simpl_blk: SIMPL_BLK;
empty_line:EMPTY_LINE;
interm: INTERM;
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/atomic6_7.adb
|
best08618/asylo
| 7 |
25638
|
<reponame>best08618/asylo<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/atomic6_7.adb
-- { dg-do compile }
-- { dg-options "-fdump-tree-gimple" }
with Atomic6_Pkg; use Atomic6_Pkg;
procedure Atomic6_7 is
My_Atomic : R;
Temp : Integer;
begin
My_Atomic.Counter1 := Counter2;
My_Atomic.Timer1 := Timer2;
My_Atomic.Counter1 := Int(My_Atomic.Timer1);
My_Atomic.Timer1 := Integer(My_Atomic.Counter1);
Temp := Integer(My_Atomic.Counter1);
My_Atomic.Counter1 := Int(Temp);
Temp := My_Atomic.Timer1;
My_Atomic.Timer1 := Temp;
end;
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&my_atomic.counter1" 2 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&atomic6_pkg__counter2" 1 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&my_atomic.timer1" 2 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&atomic6_pkg__timer2" 1 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&temp" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*ptr" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&my_atomic.counter1" 3 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&atomic6_pkg__counter2" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&my_atomic.timer1" 3 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&atomic6_pkg__timer2" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&temp" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*ptr" 0 "gimple"} }
|
JustCppConsole/assemblyCommand.asm
|
ChenPeleg/AsmCourse
| 1 |
85898
|
.386
.model flat,c
.data
.code
mainasm proc
;push ebp
;mov ebp, ESP
;mov eax, ebp
mov eax,10001
ret
mainasm endp
end
|
dino/lcs/etc/AA.asm
|
zengfr/arcade_game_romhacking_sourcecode_top_secret_data
| 6 |
1285
|
copyright zengfr site:http://github.com/zengfr/romhack
00042A move.l D1, (A0)+
00042C dbra D0, $42a
004D3C move.l D0, (A4)+
004D3E move.l D0, (A4)+
0844CE move.w D0, ($aa,A6)
0844D2 move.w D0, ($b0,A6)
0849DA addi.w #$1, ($aa,A6)
0849E0 cmpi.w #$2, ($aa,A6) [etc+AA]
0849EA move.w #$0, ($aa,A6)
0849F0 tst.w D0
086DD0 move.w (A0,D1.w), ($aa,A6)
086DD6 rts [etc+AA]
0888FA move.l ($a0,A6), ($a8,A6) [etc+A0, etc+A2]
088900 move.l (A0), ($ac,A6) [etc+A8, etc+AA]
0889A0 movea.l ($a8,A6), A0 [etc+B0]
0889A4 move.l (A0)+, D0 [etc+A8, etc+AA]
091FF0 move.l #$0, ($aa,A6) [etc+A0]
091FF8 move.w #$1e, ($b6,A6)
0921FA move.l #$0, ($aa,A6) [etc+A0]
092202 rts
092266 move.b #$1, ($aa,A6) [etc+A9]
09226C rts [etc+AA]
09226E subq.b #1, ($aa,A6)
092272 bne $922c0 [etc+AA]
092274 move.b ($a9,A6), ($aa,A6)
09227A movea.l ($a4,A6), A0 [etc+AA]
0AAACA move.l (A0), D2
0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAACE move.w D0, ($2,A0)
0AAAD2 cmp.l (A0), D0
0AAAD4 bne $aaafc
0AAAD8 move.l D2, (A0)+
0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAE6 move.l (A0), D2
0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAF4 move.l D2, (A0)+
0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
copyright zengfr site:http://github.com/zengfr/romhack
|
test/macroerr.asm
|
bitwiseworks/nasm-os2
| 1 |
93703
|
%include "macroerr.inc"
%macro bluttan 1
mov eax,%1
blej %1
%endmacro
bluttan ptr
blej ptr
dd ptr, ptr
ptr:
|
src/common/sp-terminal.ads
|
pyjarrett/septum
| 236 |
24019
|
<gh_stars>100-1000
-------------------------------------------------------------------------------
-- Copyright 2021, The Septum Developers (see AUTHORS file)
-- 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.Strings.Unbounded;
with ANSI;
with System;
with Trendy_Terminal.IO;
with Trendy_Terminal.VT100;
package SP.Terminal is
-- Functions for operations to the terminal. This hides the usage of Ada.Text_IO and may silently ignore
-- capabilities if the terminal does not support them, such as if coloring text or line clearing is added.
--
-- This module also hides dependencies on unbounded IO.
procedure Put (C : Character) renames Trendy_Terminal.IO.Put;
procedure Put (Str : String) renames Trendy_Terminal.IO.Put;
procedure Put (Str : Ada.Strings.Unbounded.Unbounded_String) renames Trendy_Terminal.IO.Put;
procedure Put_Line (Str : String) renames Trendy_Terminal.IO.Put_Line;
procedure Put_Line (Str : Ada.Strings.Unbounded.Unbounded_String) renames Trendy_Terminal.IO.Put_Line;
procedure New_Line (Spacing : Positive := 1) renames Trendy_Terminal.IO.New_Line;
procedure Set_Col (Spacing : Positive) renames Trendy_Terminal.IO.Set_Col;
procedure Beginning_Of_Line renames Trendy_Terminal.VT100.Beginning_Of_Line;
procedure Clear_Line renames Trendy_Terminal.VT100.Clear_Line;
function Colorize (S : String; Color : ANSI.Colors) return String;
function Colorize (US : Ada.Strings.Unbounded.Unbounded_String; Color : ANSI.Colors)
return Ada.Strings.Unbounded.Unbounded_String;
-- I'm not convinced that these aren't useful. I haven't figured out how best to deal with the really long and
-- verbose terminology of Ada.Strings.Unbounded.Unbounded_String.
-- function "&" (A : String; B : Unbounded_String) return Unbounded_String renames Ada.Strings.Unbounded."&";
-- function "&" (Ada : Unbounded_String; B : String) return Unbounded_String renames Ada.Strings.Unbounded."&";
type FILE_Ptr is new System.Address;
stdin : FILE_Ptr;
pragma Import (C, stdin, "stdin");
-- stdio.h
procedure clearerr (Stream : FILE_Ptr);
pragma Import (C, clearerr, "clearerr");
protected type Cancellation_Gate is
entry Closed;
procedure Finish;
procedure Cancel;
function Is_Cancelled return Boolean;
function Is_Finished return Boolean;
private
Cancelled : Boolean := False;
Finished : Boolean := False;
end Cancellation_Gate;
task type Terminal_Cancellation_Monitor(Gate : not null access Cancellation_Gate) is
entry Cancel;
entry Stop;
end;
end SP.Terminal;
|
awa/plugins/awa-mail/src/awa-mail-clients-files.adb
|
fuzzysloth/ada-awa
| 0 |
20676
|
-----------------------------------------------------------------------
-- awa-mail-clients-files -- Mail client dump/file implementation
-- Copyright (C) 2012 <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.
-----------------------------------------------------------------------
with Ada.Text_IO;
with Ada.IO_Exceptions;
with Util.Files;
with Util.Strings;
with Util.Log.Loggers;
package body AWA.Mail.Clients.Files is
use Ada.Strings.Unbounded;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Mail.Clients.Files");
-- ------------------------------
-- Set the <tt>From</tt> part of the message.
-- ------------------------------
overriding
procedure Set_From (Message : in out File_Mail_Message;
Name : in String;
Address : in String) is
begin
Message.From := To_Unbounded_String ("From: " & Name & " <" & Address & ">");
end Set_From;
-- ------------------------------
-- Add a recipient for the message.
-- ------------------------------
overriding
procedure Add_Recipient (Message : in out File_Mail_Message;
Kind : in Recipient_Type;
Name : in String;
Address : in String) is
Email : constant String := Name & " <" & Address & ">";
begin
case Kind is
when TO =>
if Length (Message.To) = 0 then
Append (Message.To, "To: ");
else
Append (Message.To, ", ");
end if;
Append (Message.To, Email);
when CC =>
if Length (Message.Cc) = 0 then
Append (Message.Cc, "Cc: ");
else
Append (Message.Cc, ", ");
end if;
Append (Message.Cc, Email);
when BCC =>
if Length (Message.Bcc) = 0 then
Append (Message.Bcc, "Bcc: ");
else
Append (Message.Bcc, ", ");
end if;
Append (Message.Bcc, Email);
end case;
end Add_Recipient;
-- ------------------------------
-- Set the subject of the message.
-- ------------------------------
overriding
procedure Set_Subject (Message : in out File_Mail_Message;
Subject : in String) is
begin
Message.Subject := To_Unbounded_String (Subject);
end Set_Subject;
-- ------------------------------
-- Set the body of the message.
-- ------------------------------
overriding
procedure Set_Body (Message : in out File_Mail_Message;
Content : in String) is
begin
Message.Message := To_Unbounded_String (Content);
end Set_Body;
-- ------------------------------
-- Send the email message.
-- ------------------------------
overriding
procedure Send (Message : in out File_Mail_Message) is
N : Natural;
Output : Ada.Text_IO.File_Type;
begin
Util.Concurrent.Counters.Increment (Message.Manager.Index, N);
declare
Path : constant String := Util.Files.Compose (To_String (Message.Manager.Path),
"msg-" & Util.Strings.Image (N));
begin
Log.Info ("Sending dumb mail to {0}", Path);
Ada.Text_IO.Create (File => Output,
Mode => Ada.Text_IO.Out_File,
Name => Path);
Ada.Text_IO.Put_Line (Output, To_String (Message.From));
if Length (Message.To) > 0 then
Ada.Text_IO.Put_Line (Output, To_String (Message.To));
end if;
if Length (Message.Cc) > 0 then
Ada.Text_IO.Put_Line (Output, To_String (Message.Cc));
end if;
if Length (Message.Bcc) > 0 then
Ada.Text_IO.Put_Line (Output, To_String (Message.Bcc));
end if;
Ada.Text_IO.Put (Output, "Subject: ");
Ada.Text_IO.Put_Line (Output, To_String (Message.Subject));
Ada.Text_IO.Put_Line (Output, To_String (Message.Message));
Ada.Text_IO.Close (Output);
exception
when Ada.IO_Exceptions.Name_Error =>
Log.Error ("Cannot create mail file {0}", Path);
end;
end Send;
-- ------------------------------
-- Create a file based mail manager and configure it according to the properties.
-- ------------------------------
function Create_Manager (Props : in Util.Properties.Manager'Class) return Mail_Manager_Access is
Result : constant File_Mail_Manager_Access := new File_Mail_Manager;
begin
Result.Self := Result;
Result.Path := To_Unbounded_String (Props.Get (NAME & ".maildir", "mail"));
return Result.all'Access;
end Create_Manager;
-- ------------------------------
-- Create a new mail message.
-- ------------------------------
overriding
function Create_Message (Manager : in File_Mail_Manager) return Mail_Message_Access is
Result : constant File_Mail_Message_Access := new File_Mail_Message;
begin
Result.Manager := Manager.Self;
return Result.all'Access;
end Create_Message;
end AWA.Mail.Clients.Files;
|
src/util-serialize-io.adb
|
Letractively/ada-util
| 0 |
6985
|
-----------------------------------------------------------------------
-- util-serialize-io -- IO Drivers for serialization
-- Copyright (C) 2010, 2011 <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.
-----------------------------------------------------------------------
with Util.Streams.Files;
with Ada.Streams;
with Ada.Streams.Stream_IO;
with Ada.Exceptions;
with Ada.IO_Exceptions;
package body Util.Serialize.IO is
-- use Util.Log;
use type Util.Log.Loggers.Logger_Access;
-- The logger'
Log : aliased constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Serialize.IO",
Util.Log.WARN_LEVEL);
-- ------------------------------
-- Read the file and parse it using the JSON parser.
-- ------------------------------
procedure Parse (Handler : in out Parser;
File : in String) is
Stream : aliased Util.Streams.Files.File_Stream;
Buffer : Util.Streams.Buffered.Buffered_Stream;
begin
if Handler.Error_Logger = null then
Handler.Error_Logger := Log'Access;
end if;
Handler.Error_Logger.Info ("Reading file {0}", File);
Handler.File := Ada.Strings.Unbounded.To_Unbounded_String (File);
Buffer.Initialize (Output => null,
Input => Stream'Unchecked_Access,
Size => 1024);
Stream.Open (Mode => Ada.Streams.Stream_IO.In_File, Name => File);
Context_Stack.Clear (Handler.Stack);
Parser'Class (Handler).Parse (Buffer);
exception
when Util.Serialize.Mappers.Field_Fatal_Error =>
null;
when Ada.IO_Exceptions.Name_Error =>
Parser'Class (Handler).Error ("File '" & File & "' does not exist.");
when E : others =>
Parser'Class (Handler).Error ("Exception " & Ada.Exceptions.Exception_Name (E));
end Parse;
-- ------------------------------
-- Parse the content string.
-- ------------------------------
procedure Parse_String (Handler : in out Parser;
Content : in String) is
Stream : aliased Util.Streams.Buffered.Buffered_Stream;
begin
if Handler.Error_Logger = null then
Handler.Error_Logger := Log'Access;
end if;
Handler.File := Ada.Strings.Unbounded.To_Unbounded_String ("<inline>");
Stream.Initialize (Content => Content);
Context_Stack.Clear (Handler.Stack);
Parser'Class (Handler).Parse (Stream);
exception
when Util.Serialize.Mappers.Field_Fatal_Error =>
null;
when E : others =>
Parser'Class (Handler).Error ("Exception " & Ada.Exceptions.Exception_Name (E));
end Parse_String;
-- ------------------------------
-- Returns true if the <b>Parse</b> operation detected at least one error.
-- ------------------------------
function Has_Error (Handler : in Parser) return Boolean is
begin
return Handler.Error_Flag;
end Has_Error;
-- ------------------------------
-- Set the error logger to report messages while parsing and reading the input file.
-- ------------------------------
procedure Set_Logger (Handler : in out Parser;
Logger : in Util.Log.Loggers.Logger_Access) is
begin
Handler.Error_Logger := Logger;
end Set_Logger;
-- ------------------------------
-- Push the current context when entering in an element.
-- ------------------------------
procedure Push (Handler : in out Parser) is
use type Util.Serialize.Mappers.Mapper_Access;
begin
Context_Stack.Push (Handler.Stack);
end Push;
-- ------------------------------
-- Pop the context and restore the previous context when leaving an element
-- ------------------------------
procedure Pop (Handler : in out Parser) is
begin
Context_Stack.Pop (Handler.Stack);
end Pop;
function Find_Mapper (Handler : in Parser;
Name : in String) return Util.Serialize.Mappers.Mapper_Access is
pragma Unreferenced (Handler, Name);
begin
return null;
end Find_Mapper;
-- ------------------------------
-- Start a new object associated with the given name. This is called when
-- the '{' is reached. The reader must be updated so that the next
-- <b>Set_Member</b> procedure will associate the name/value pair on the
-- new object.
-- ------------------------------
procedure Start_Object (Handler : in out Parser;
Name : in String) is
use type Util.Serialize.Mappers.Mapper_Access;
Current : constant Element_Context_Access := Context_Stack.Current (Handler.Stack);
Next : Element_Context_Access;
Pos : Positive;
begin
Log.Debug ("Start object {0}", Name);
Context_Stack.Push (Handler.Stack);
Next := Context_Stack.Current (Handler.Stack);
if Current /= null then
Pos := 1;
-- Notify we are entering in the given node for each active mapping.
for I in Current.Active_Nodes'Range loop
declare
Node : constant Mappers.Mapper_Access := Current.Active_Nodes (I);
Child : Mappers.Mapper_Access;
begin
exit when Node = null;
Child := Node.Find_Mapper (Name => Name);
if Child = null and then Node.Is_Wildcard then
Child := Node;
end if;
if Child /= null then
Log.Debug ("{0} is matching {1}", Name, Child.Get_Name);
Child.Start_Object (Handler, Name);
Next.Active_Nodes (Pos) := Child;
Pos := Pos + 1;
end if;
end;
end loop;
while Pos <= Next.Active_Nodes'Last loop
Next.Active_Nodes (Pos) := null;
Pos := Pos + 1;
end loop;
else
Next.Active_Nodes (1) := Handler.Mapping_Tree.Find_Mapper (Name);
end if;
end Start_Object;
-- ------------------------------
-- Finish an object associated with the given name. The reader must be
-- updated to be associated with the previous object.
-- ------------------------------
procedure Finish_Object (Handler : in out Parser;
Name : in String) is
use type Util.Serialize.Mappers.Mapper_Access;
begin
Log.Debug ("Finish object {0}", Name);
declare
Current : constant Element_Context_Access := Context_Stack.Current (Handler.Stack);
begin
if Current /= null then
-- Notify we are leaving the given node for each active mapping.
for I in Current.Active_Nodes'Range loop
declare
Node : constant Mappers.Mapper_Access := Current.Active_Nodes (I);
begin
exit when Node = null;
Node.Finish_Object (Handler, Name);
end;
end loop;
end if;
end;
Handler.Pop;
end Finish_Object;
procedure Start_Array (Handler : in out Parser;
Name : in String) is
pragma Unreferenced (Name);
begin
Handler.Push;
end Start_Array;
procedure Finish_Array (Handler : in out Parser;
Name : in String) is
pragma Unreferenced (Name);
begin
Handler.Pop;
end Finish_Array;
-- -----------------------
-- Set the name/value pair on the current object. For each active mapping,
-- find whether a rule matches our name and execute it.
-- -----------------------
procedure Set_Member (Handler : in out Parser;
Name : in String;
Value : in Util.Beans.Objects.Object;
Attribute : in Boolean := False) is
use Util.Serialize.Mappers;
Current : constant Element_Context_Access := Context_Stack.Current (Handler.Stack);
begin
Log.Debug ("Set member {0}", Name);
if Current /= null then
-- Look each active mapping node.
for I in Current.Active_Nodes'Range loop
declare
Node : constant Mapper_Access := Current.Active_Nodes (I);
begin
exit when Node = null;
Node.Set_Member (Name => Name,
Value => Value,
Attribute => Attribute,
Context => Handler);
exception
when E : Util.Serialize.Mappers.Field_Error =>
Parser'Class (Handler).Error (Message => Ada.Exceptions.Exception_Message (E));
when E : Util.Serialize.Mappers.Field_Fatal_Error =>
Parser'Class (Handler).Error (Message => Ada.Exceptions.Exception_Message (E));
raise;
-- For other exception, report an error with the field name and value.
when E : others =>
Parser'Class (Handler).Error (Message => "Cannot set field '" & Name & "' to '"
& Util.Beans.Objects.To_String (Value) & "': "
& Ada.Exceptions.Exception_Message (E));
raise;
end;
end loop;
end if;
end Set_Member;
-- ------------------------------
-- Get the current location (file and line) to report an error message.
-- ------------------------------
function Get_Location (Handler : in Parser) return String is
begin
return Ada.Strings.Unbounded.To_String (Handler.File);
end Get_Location;
-- ------------------------------
-- Report an error while parsing the input stream. The error message will be reported
-- on the logger associated with the parser. The parser will be set as in error so that
-- the <b>Has_Error</b> function will return True after parsing the whole file.
-- ------------------------------
procedure Error (Handler : in out Parser;
Message : in String) is
begin
Handler.Error_Logger.Error ("{0}: {1}",
Parser'Class (Handler).Get_Location,
Message);
Handler.Error_Flag := True;
end Error;
procedure Add_Mapping (Handler : in out Parser;
Path : in String;
Mapper : in Util.Serialize.Mappers.Mapper_Access) is
begin
Handler.Mapping_Tree.Add_Mapping (Path, Mapper);
end Add_Mapping;
-- ------------------------------
-- Dump the mapping tree on the logger using the INFO log level.
-- ------------------------------
procedure Dump (Handler : in Parser'Class;
Logger : in Util.Log.Loggers.Logger'Class) is
begin
Util.Serialize.Mappers.Dump (Handler.Mapping_Tree, Logger, "Mapping ");
end Dump;
end Util.Serialize.IO;
|
oeis/120/A120757.asm
|
neoneye/loda-programs
| 11 |
100490
|
; A120757: Expansion of x^2*(2+x)/(1-3*x-4*x^2-x^3).
; Submitted by <NAME>
; 0,2,7,29,117,474,1919,7770,31460,127379,515747,2088217,8455018,34233669,138609296,561217582,2272323599,9200450421,37251863241,150829715006,610697048403,2472661868474,10011603514040,40536155064419
lpb $0
sub $0,1
add $4,1
add $1,$4
add $4,$2
mov $2,$1
add $3,$1
mov $1,$4
add $2,$4
sub $3,1
add $4,$3
mov $3,$2
lpe
mov $0,$2
|
programs/oeis/264/A264749.asm
|
karttu/loda
| 0 |
21728
|
<gh_stars>0
; A264749: a(n) = floor(n/BL(n)) where BL(n) = A070939(n) is the binary length of n.
; 0,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,6,6,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8,8,9,9,9,9,9,9,10,10,10,10,9,9,9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,11,12,12,12,12,12,12,12,13,13,13,13,13,13,13,14,14,14,14,14,14,14,15,15,15,15,15,15,15,16,16,16,16,16,16,16,17,17,17,17,17,17,17,18,18,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,31,31
add $0,1
mul $0,2
sub $0,2
lpb $0,1
mov $1,$0
add $0,1
mov $2,1
trn $2,$1
add $0,$2
log $0,2
mul $0,2
add $1,3
add $3,1
mul $3,2
sub $1,$3
mov $4,$0
trn $0,21
div $1,$4
lpe
|
Task/Statistics-Basic/Ada/statistics-basic-2.ada
|
LaudateCorpus1/RosettaCodeData
| 1 |
5060
|
<filename>Task/Statistics-Basic/Ada/statistics-basic-2.ada<gh_stars>1-10
with Ada.Text_IO, Ada.Command_Line, Ada.Numerics.Float_Random,
Ada.Numerics.Generic_Elementary_Functions;
procedure Long_Basic_Stat is
package FRG renames Ada.Numerics.Float_Random;
package TIO renames Ada.Text_IO;
type Counter is range 0 .. 2**63-1;
type Result_Array is array(Natural range <>) of Counter;
type High_Precision is digits 15;
package FIO is new TIO.Float_IO(Float);
procedure Put_Histogram(R: Result_Array; Scale, Full: Counter) is
begin
for I in R'Range loop
FIO.Put(Float'Max(0.0, Float(I)/10.0 - 0.05),
Fore => 1, Aft => 2, Exp => 0); TIO.Put("..");
FIO.Put(Float'Min(1.0, Float(I)/10.0 + 0.05),
Fore => 1, Aft => 2, Exp => 0); TIO.Put(": ");
for J in 1 .. (R(I)* Scale)/Full loop
Ada.Text_IO.Put("X");
end loop;
Ada.Text_IO.New_Line;
end loop;
end Put_Histogram;
procedure Put_Mean_Et_Al(Sample_Size: Counter;
Val_Sum, Square_Sum: Float) is
Mean: constant Float := Val_Sum / Float(Sample_Size);
package Math is new Ada.Numerics.Generic_Elementary_Functions(Float);
begin
TIO.Put("Mean: ");
FIO.Put(Mean, Fore => 1, Aft => 5, Exp => 0);
TIO.Put(", Standard Deviation: ");
FIO.Put(Math.Sqrt(abs(Square_Sum / Float(Sample_Size)
- (Mean * Mean))), Fore => 1, Aft => 5, Exp => 0);
TIO.New_Line;
end Put_Mean_Et_Al;
N: Counter := Counter'Value(Ada.Command_Line.Argument(1));
Gen: FRG.Generator;
Results: Result_Array(0 .. 10) := (others => 0);
X: Float;
Val_Sum, Squ_Sum: High_Precision := 0.0;
begin
FRG.Reset(Gen);
for Outer in 1 .. 1000 loop
for I in 1 .. N/1000 loop
X := FRG.Random(Gen);
Val_Sum := Val_Sum + High_Precision(X);
Squ_Sum := Squ_Sum + High_Precision(X)*High_Precision(X);
declare
Index: Integer := Integer(X*10.0);
begin
Results(Index) := Results(Index) + 1;
end;
end loop;
if Outer mod 50 = 0 then
TIO.New_Line(1);
TIO.Put_Line(Integer'Image(Outer/10) &"% done; current results:");
Put_Mean_Et_Al(Sample_Size => (Counter(Outer)*N)/1000,
Val_Sum => Float(Val_Sum),
Square_Sum => Float(Squ_Sum));
else
Ada.Text_IO.Put(".");
end if;
end loop;
TIO.New_Line(4);
TIO.Put_Line("After sampling" & Counter'Image(N) & " random numnbers: ");
Put_Histogram(Results, Scale => 600, Full => N);
TIO.New_Line;
Put_Mean_Et_Al(Sample_Size => N,
Val_Sum => Float(Val_Sum), Square_Sum => Float(Squ_Sum));
end Long_Basic_Stat;
|
src/parser/evaql/evaql_parser.g4
|
YT0828/eva
| 0 |
7292
|
<gh_stars>0
parser grammar evaql_parser;
options {
tokenVocab=evaql_lexer;
}
// Top Level Description
root
: sqlStatements? MINUSMINUS? EOF
;
sqlStatements
: (sqlStatement MINUSMINUS? SEMI | emptyStatement)*
(sqlStatement (MINUSMINUS? SEMI)? | emptyStatement)
;
sqlStatement
: ddlStatement | dmlStatement | utilityStatement
;
emptyStatement
: SEMI
;
ddlStatement
: createDatabase | createTable | createIndex | createUdf
| dropDatabase | dropTable | dropIndex | renameTable | truncateTable
;
dmlStatement
: selectStatement | insertStatement | updateStatement
| deleteStatement | loadStatement | uploadStatement
;
utilityStatement
: simpleDescribeStatement | helpStatement
;
// Data Definition Language
// Create statements
createDatabase
: CREATE DATABASE
ifNotExists? uid
;
createIndex
: CREATE
INDEX uid indexType?
ON tableName indexColumnNames
;
createTable
: CREATE TABLE
ifNotExists?
tableName createDefinitions #columnCreateTable
;
// Rename statements
renameTable
: RENAME TABLE
oldtableName
TO newtableName
;
//Truncate statements
truncateTable
: TRUNCATE TABLE
tableName
;
// Create UDFs
createUdf
: CREATE UDF
ifNotExists?
udfName
INPUT createDefinitions
OUTPUT createDefinitions
TYPE udfType
IMPL udfImpl
;
// details
udfName
: uid
;
udfType
: uid
;
udfImpl
: stringLiteral
;
indexType
: USING (BTREE | HASH)
;
createDefinitions
: '(' createDefinition (',' createDefinition)* ')'
;
createDefinition
: uid columnDefinition #columnDeclaration
| indexColumnDefinition #indexDeclaration
;
columnDefinition
: dataType columnConstraint*
;
columnConstraint
: nullNotnull #nullColumnConstraint
| DEFAULT defaultValue #defaultColumnConstraint
| PRIMARY? KEY #primaryKeyColumnConstraint
| UNIQUE KEY? #uniqueKeyColumnConstraint
;
indexColumnDefinition
: INDEX uid? indexType?
indexColumnNames #simpleIndexDeclaration
;
// Drop statements
dropDatabase
: DROP DATABASE ifExists? uid
;
dropIndex
: DROP INDEX
uid ON tableName
;
dropTable
: DROP TABLE ifExists?
tables
;
// Data Manipulation Language
// Primary DML Statements
deleteStatement
: singleDeleteStatement
;
insertStatement
: INSERT
INTO? tableName
(
('(' columns=uidList ')')? insertStatementValue
)
;
selectStatement
: querySpecification #simpleSelect
| left=selectStatement UNION unionAll=ALL? right=selectStatement #unionSelect
;
updateStatement
: singleUpdateStatement
;
loadStatement
: LOAD DATA
INFILE fileName
INTO tableName
;
uploadStatement
: UPLOAD
PATH fileName
BLOB videoBlob
;
fileName
: stringLiteral
;
videoBlob
: stringLiteral
;
// details
insertStatementValue
: selectStatement
| insertFormat=(VALUES | VALUE)
'(' expressionsWithDefaults ')'
(',' '(' expressionsWithDefaults ')')*
;
updatedElement
: fullColumnName '=' (expression | DEFAULT)
;
// Detailed DML Statements
singleDeleteStatement
: DELETE
FROM tableName
(WHERE expression)?
orderByClause? (LIMIT decimalLiteral)?
;
singleUpdateStatement
: UPDATE tableName (AS? uid)?
SET updatedElement (',' updatedElement)*
(WHERE expression)? orderByClause? limitClause?
;
// details
orderByClause
: ORDER BY orderByExpression (',' orderByExpression)*
;
orderByExpression
: expression order=(ASC | DESC)?
;
tableSources
: tableSource (',' tableSource)*
;
tableSource
: tableSourceItemWithSample joinPart* #tableSourceBase
;
tableSourceItemWithSample
: tableSourceItem sampleClause?
;
tableSourceItem
: tableName #atomTableItem
| (
selectStatement |
LR_BRACKET selectStatement RR_BRACKET
) #subqueryTableItem
;
sampleClause
: SAMPLE decimalLiteral
;
joinPart
: JOIN tableSourceItemWithSample
(
ON expression
| USING '(' uidList ')'
)? #innerJoin
;
// Select Statement's Details
queryExpression
: '(' querySpecification ')'
| '(' queryExpression ')'
;
querySpecification
: SELECT selectElements
fromClause orderByClause? limitClause?
errorBoundsExpression? confidenceLevelExpression?
;
// details
selectElements
: (star='*' | selectElement ) (',' selectElement)*
;
selectElement
: fullId '.' '*' #selectStarElement
| fullColumnName (AS? uid)? #selectColumnElement
| functionCall (AS? uid)? #selectFunctionElement
| (LOCAL_ID VAR_ASSIGN)? expression (AS? uid)? #selectExpressionElement
;
fromClause
: FROM tableSources
(WHERE whereExpr=expression)?
(
GROUP BY
groupByItem (',' groupByItem)*
)?
(HAVING havingExpr=expression)?
;
groupByItem
: expression order=(ASC | DESC)?
;
limitClause
: LIMIT
(
(offset=decimalLiteral ',')? limit=decimalLiteral
| limit=decimalLiteral OFFSET offset=decimalLiteral
)
;
errorBoundsExpression
: ERROR_BOUNDS REAL_LITERAL
;
confidenceLevelExpression
: CONFIDENCE_LEVEL REAL_LITERAL
;
// Other administrative statements
shutdownStatement
: SHUTDOWN
;
// Utility Statements
simpleDescribeStatement
: DESCRIBE tableName
;
helpStatement
: HELP STRING_LITERAL
;
// Common Clauses
// DB Objects
fullId
: uid (DOT_ID | '.' uid)?
;
tableName
: fullId
;
oldtableName
: fullId
;
newtableName
: fullId
;
fullColumnName
: uid (dottedId dottedId? )?
;
indexColumnName
: uid ('(' decimalLiteral ')')? sortType=(ASC | DESC)?
;
userName
: STRING_USER_NAME | ID;
uuidSet
: decimalLiteral '-' decimalLiteral '-' decimalLiteral
'-' decimalLiteral '-' decimalLiteral
(':' decimalLiteral '-' decimalLiteral)+
;
uid
: simpleId
//| DOUBLE_QUOTE_ID
| REVERSE_QUOTE_ID
;
simpleId
: ID
;
dottedId
: DOT_ID
| '.' uid
;
// Literals
decimalLiteral
: DECIMAL_LITERAL | ZERO_DECIMAL | ONE_DECIMAL | TWO_DECIMAL | ANYDIM
;
stringLiteral
: STRING_LITERAL
;
booleanLiteral
: TRUE | FALSE;
nullNotnull
: NOT? (NULL_LITERAL | NULL_SPEC_LITERAL)
;
arrayLiteral
: LR_SQ_BRACKET constant (',' constant)* RR_SQ_BRACKET
| LR_SQ_BRACKET RR_SQ_BRACKET
;
constant
: stringLiteral | decimalLiteral
| '-' decimalLiteral
| booleanLiteral
| REAL_LITERAL
| NOT? nullLiteral=(NULL_LITERAL | NULL_SPEC_LITERAL)
| arrayLiteral
;
// Data Types
arrayType
: INT8 | UINT8 | INT16 | INT32 | INT64
| UNICODE | BOOL
| FLOAT32 | FLOAT64 | DECIMAL
| STR | DATETIME | ANYTYPE
;
dataType
: BOOLEAN #simpleDataType
| TEXT lengthOneDimension? #dimensionDataType
| INTEGER UNSIGNED? #integerDataType
| FLOAT lengthTwoDimension? UNSIGNED? #dimensionDataType
| NDARRAY arrayType? lengthDimensionList? #arrayDataType
| ANYTYPE #anyDataType
;
lengthOneDimension
: '(' decimalLiteral ')'
;
lengthTwoDimension
: '(' decimalLiteral ',' decimalLiteral ')'
;
lengthDimensionList
: '(' ( decimalLiteral ',')* decimalLiteral ')'
;
// Common Lists
uidList
: uid (',' uid)*
;
tables
: tableName (',' tableName)*
;
indexColumnNames
: '(' indexColumnName (',' indexColumnName)* ')'
;
expressions
: expression (',' expression)*
;
expressionsWithDefaults
: expressionOrDefault (',' expressionOrDefault)*
;
// Common Expressions
defaultValue
: NULL_LITERAL
| constant
;
expressionOrDefault
: expression | DEFAULT
;
ifExists
: IF EXISTS;
ifNotExists
: IF NOT EXISTS;
// Functions
functionCall
: udfFunction #udfFunctionCall
| aggregateWindowedFunction #aggregateFunctionCall
;
udfFunction
: simpleId '(' functionArgs ')' dottedId?
;
aggregateWindowedFunction
: (AVG | MAX | MIN | SUM)
'(' aggregator=(ALL | DISTINCT)? functionArg ')'
| COUNT '(' (starArg='*' | aggregator=ALL? functionArg) ')'
;
functionArgs
: (constant | fullColumnName | functionCall | expression)
(
','
(constant | fullColumnName | functionCall | expression)
)*
;
functionArg
: constant | fullColumnName | functionCall | expression
;
// Expressions, predicates
// Simplified approach for expression
expression
: notOperator=(NOT | '!') expression #notExpression
| expression logicalOperator expression #logicalExpression
| predicate IS NOT? testValue=(TRUE | FALSE | UNKNOWN) #isExpression
| predicate #predicateExpression
;
predicate
: predicate NOT? IN '(' (selectStatement | expressions) ')' #inPredicate
| predicate IS nullNotnull #isNullPredicate
| left=predicate comparisonOperator right=predicate #binaryComparisonPredicate
| predicate comparisonOperator
quantifier=(ALL | ANY | SOME) '(' selectStatement ')' #subqueryComparisonPredicate
| predicate NOT? LIKE predicate (STRING_LITERAL)? #likePredicate
| (LOCAL_ID VAR_ASSIGN)? expressionAtom #expressionAtomPredicate
;
// Add in ASTVisitor nullNotnull in constant
expressionAtom
: constant #constantExpressionAtom
| fullColumnName #fullColumnNameExpressionAtom
| functionCall #functionCallExpressionAtom
| unaryOperator expressionAtom #unaryExpressionAtom
| '(' expression (',' expression)* ')' #nestedExpressionAtom
| '(' selectStatement ')' #subqueryExpessionAtom
| left=expressionAtom bitOperator right=expressionAtom #bitExpressionAtom
| left=expressionAtom mathOperator right=expressionAtom #mathExpressionAtom
;
unaryOperator
: '!' | '~' | '+' | '-' | NOT
;
comparisonOperator
: '=' | '>' | '<' | '<' '=' | '>' '='
| '<' '>' | '!' '=' | '<' '=' '>'
| '@' '>' | '<' '@'
;
logicalOperator
: AND | '&' '&' | XOR | OR | '|' '|'
;
bitOperator
: '<' '<' | '>' '>' | '&' | '^' | '|'
;
mathOperator
: '*' | '/' | '%' | DIV | MOD | '+' | '-' | '--'
;
|
src/ui/bases-recruitui.adb
|
thindil/steamsky
| 80 |
18217
|
<reponame>thindil/steamsky
-- Copyright (c) 2020-2021 <NAME> <<EMAIL>>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Ada.Containers.Generic_Array_Sort;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with CArgv; use CArgv;
with Tcl; use Tcl;
with Tcl.Ada; use Tcl.Ada;
with Tcl.Tk.Ada; use Tcl.Tk.Ada;
with Tcl.Tk.Ada.Grid;
with Tcl.Tk.Ada.Widgets; use Tcl.Tk.Ada.Widgets;
with Tcl.Tk.Ada.Widgets.Canvas; use Tcl.Tk.Ada.Widgets.Canvas;
with Tcl.Tk.Ada.Widgets.Menu; use Tcl.Tk.Ada.Widgets.Menu;
with Tcl.Tk.Ada.Widgets.Toplevel.MainWindow;
use Tcl.Tk.Ada.Widgets.Toplevel.MainWindow;
with Tcl.Tk.Ada.Widgets.TtkButton; use Tcl.Tk.Ada.Widgets.TtkButton;
with Tcl.Tk.Ada.Widgets.TtkButton.TtkRadioButton;
use Tcl.Tk.Ada.Widgets.TtkButton.TtkRadioButton;
with Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox;
use Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox;
with Tcl.Tk.Ada.Widgets.TtkFrame; use Tcl.Tk.Ada.Widgets.TtkFrame;
with Tcl.Tk.Ada.Widgets.TtkLabel; use Tcl.Tk.Ada.Widgets.TtkLabel;
with Tcl.Tk.Ada.Widgets.TtkProgressBar; use Tcl.Tk.Ada.Widgets.TtkProgressBar;
with Tcl.Tk.Ada.Widgets.TtkScale; use Tcl.Tk.Ada.Widgets.TtkScale;
with Tcl.Tk.Ada.Widgets.TtkScrollbar; use Tcl.Tk.Ada.Widgets.TtkScrollbar;
with Tcl.Tk.Ada.Winfo; use Tcl.Tk.Ada.Winfo;
with Tcl.Tklib.Ada.Autoscroll; use Tcl.Tklib.Ada.Autoscroll;
with Tcl.Tklib.Ada.Tooltip; use Tcl.Tklib.Ada.Tooltip;
with Bases.Trade; use Bases.Trade;
with Config; use Config;
with CoreUI; use CoreUI;
with Dialogs; use Dialogs;
with Maps; use Maps;
with Maps.UI; use Maps.UI;
with Ships.Crew; use Ships.Crew;
with Table; use Table;
with Utils.UI; use Utils.UI;
package body Bases.RecruitUI is
-- ****iv* RecruitUI/RecruitUI.RecruitTable
-- FUNCTION
-- Table with info about the available recruits
-- SOURCE
RecruitTable: Table_Widget (6);
-- ****
-- ****iv* RecruitUI/RecruitUI.Modules_Indexes
-- FUNCTION
-- Indexes of the available recruits in base
-- SOURCE
Recruits_Indexes: Positive_Container.Vector;
-- ****
-- ****if* RecruitUI/RecruitUI.Get_Highest_Attribute
-- FUNCTION
-- Get the highest attribute's name of the selected recruit
-- PARAMETERS
-- BaseIndex - The index of the base in which the recruit's attributes
-- will be check
-- MemberIndex - The index of the recruit which attributes will be check
-- RESULT
-- The name of the attribute with the highest level of the selected recruit
-- HISTORY
-- 6.5 - Added
-- SOURCE
function Get_Highest_Attribute
(BaseIndex, MemberIndex: Positive) return Unbounded_String is
-- ****
use Tiny_String;
HighestLevel, HighestIndex: Positive := 1;
begin
Get_Highest_Attribute_Level_Loop :
for I in Sky_Bases(BaseIndex).Recruits(MemberIndex).Attributes'Range loop
if Sky_Bases(BaseIndex).Recruits(MemberIndex).Attributes(I).Level >
HighestLevel then
HighestLevel :=
Sky_Bases(BaseIndex).Recruits(MemberIndex).Attributes(I).Level;
HighestIndex := I;
end if;
end loop Get_Highest_Attribute_Level_Loop;
return
To_Unbounded_String
(To_String
(AttributesData_Container.Element(Attributes_List, HighestIndex)
.Name));
end Get_Highest_Attribute;
-- ****if* RecruitUI/RecruitUI.Get_Highest_Skill
-- FUNCTION
-- Get the highest skill's name of the selected recruit
-- PARAMETERS
-- BaseIndex - The index of the base in which the recruit's skills will
-- be check
-- MemberIndex - The index of the recruit which skills will be check
-- RESULT
-- The name of the skill with the highest level of the selected recruit
-- HISTORY
-- 6.5 - Added
-- SOURCE
function Get_Highest_Skill
(BaseIndex, MemberIndex: Positive) return Unbounded_String is
-- ****
use Tiny_String;
HighestLevel, HighestIndex: Positive := 1;
begin
Get_Highest_Skill_Level_Loop :
for Skill of Sky_Bases(BaseIndex).Recruits(MemberIndex).Skills loop
if Skill.Level > HighestLevel then
HighestLevel := Skill.Level;
HighestIndex := Skill.Index;
end if;
end loop Get_Highest_Skill_Level_Loop;
return
To_Unbounded_String
(To_String
(SkillsData_Container.Element(Skills_List, HighestIndex).Name));
end Get_Highest_Skill;
-- ****o* RecruitUI/RecruitUI.Show_Recruit_Command
-- FUNCTION
-- Show the selected base available recruits
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowRecruit
-- SOURCE
function Show_Recruit_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Recruit_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData);
RecruitFrame: Ttk_Frame :=
Get_Widget(Main_Paned & ".recruitframe", Interp);
BaseIndex: constant Positive :=
SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex;
Page: constant Positive :=
(if Argc = 2 then Positive'Value(CArgv.Arg(Argv, 1)) else 1);
Start_Row: constant Positive :=
((Page - 1) * Game_Settings.Lists_Limit) + 1;
Current_Row: Positive := 1;
begin
if Winfo_Get(RecruitFrame, "exists") = "0" then
RecruitFrame := Create(Widget_Image(RecruitFrame));
RecruitTable :=
CreateTable
(Parent => Widget_Image(RecruitFrame),
Headers =>
(To_Unbounded_String("Name"), To_Unbounded_String("Gender"),
To_Unbounded_String("Faction"),
To_Unbounded_String("Base cost"),
To_Unbounded_String("Highest stat"),
To_Unbounded_String("Highest skill")),
Command => "SortRecruits",
Tooltip => "Press mouse button to sort the recruits.");
Bind
(RecruitFrame, "<Configure>",
"{ResizeCanvas " & RecruitTable.Canvas & " %w %h}");
elsif Winfo_Get(RecruitFrame, "ismapped") = "1" and
(Argc = 1 or Sky_Bases(BaseIndex).Recruits.Length = 0) then
Tcl.Tk.Ada.Grid.Grid_Remove(Close_Button);
Entry_Configure(GameMenu, "Help", "-command {ShowHelp general}");
ShowSkyMap(True);
return TCL_OK;
end if;
Entry_Configure(GameMenu, "Help", "-command {ShowHelp crew}");
Tcl.Tk.Ada.Grid.Grid(Close_Button, "-row 0 -column 1");
if Recruits_Indexes.Length /= Sky_Bases(BaseIndex).Recruits.Length then
Recruits_Indexes.Clear;
for I in Sky_Bases(BaseIndex).Recruits.Iterate loop
Recruits_Indexes.Append(Recruit_Container.To_Index(I));
end loop;
end if;
ClearTable(RecruitTable);
Load_Recruits_Loop :
for I of Recruits_Indexes loop
if Current_Row < Start_Row then
Current_Row := Current_Row + 1;
goto End_Of_Loop;
end if;
AddButton
(RecruitTable, To_String(Sky_Bases(BaseIndex).Recruits(I).Name),
"Show available options for recruit",
"ShowRecruitMenu" & Positive'Image(I), 1);
AddButton
(RecruitTable,
(if Sky_Bases(BaseIndex).Recruits(I).Gender = 'F' then "Female"
else "Male"),
"Show available options for recruit",
"ShowRecruitMenu" & Positive'Image(I), 2);
AddButton
(RecruitTable,
To_String
(Factions_List(Sky_Bases(BaseIndex).Recruits(I).Faction).Name),
"Show available options for recruit",
"ShowRecruitMenu" & Positive'Image(I), 3);
AddButton
(RecruitTable,
Positive'Image(Sky_Bases(BaseIndex).Recruits(I).Price),
"Show available options for recruit",
"ShowRecruitMenu" & Positive'Image(I), 4);
AddButton
(RecruitTable, To_String(Get_Highest_Attribute(BaseIndex, I)),
"Show available options for recruit",
"ShowRecruitMenu" & Positive'Image(I), 5);
AddButton
(RecruitTable, To_String(Get_Highest_Skill(BaseIndex, I)),
"Show available options for recruit",
"ShowRecruitMenu" & Positive'Image(I), 6, True);
exit Load_Recruits_Loop when RecruitTable.Row =
Game_Settings.Lists_Limit + 1;
<<End_Of_Loop>>
end loop Load_Recruits_Loop;
if Page > 1 then
if RecruitTable.Row < Game_Settings.Lists_Limit + 1 then
AddPagination
(RecruitTable, "ShowRecruit" & Positive'Image(Page - 1), "");
else
AddPagination
(RecruitTable, "ShowRecruit" & Positive'Image(Page - 1),
"ShowRecruit" & Positive'Image(Page + 1));
end if;
elsif RecruitTable.Row = Game_Settings.Lists_Limit + 1 then
AddPagination
(RecruitTable, "", "ShowRecruit" & Positive'Image(Page + 1));
end if;
UpdateTable(RecruitTable);
configure
(RecruitTable.Canvas,
"-scrollregion [list " & BBox(RecruitTable.Canvas, "all") & "]");
Show_Screen("recruitframe");
return TCL_OK;
end Show_Recruit_Command;
-- ****iv* RecruitUI/RecruitUI.RecruitIndex
-- FUNCTION
-- The index of currently selected recruit
-- SOURCE
RecruitIndex: Positive;
-- ****
-- ****o* RecruitUI/RecruitUI.Show_Recruit_Menu_Command
-- FUNCTION
-- Show menu with actions for the selected recruit
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowRecruitMenu recruitindex
-- RecruitIndex is a index of the recruit which menu will be shown
-- SOURCE
function Show_Recruit_Menu_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Recruit_Menu_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc);
RecruitMenu: Tk_Menu := Get_Widget(".recruitmenu", Interp);
begin
RecruitIndex := Positive'Value(CArgv.Arg(Argv, 1));
if Winfo_Get(RecruitMenu, "exists") = "0" then
RecruitMenu := Create(".recruitmenu", "-tearoff false");
end if;
Delete(RecruitMenu, "0", "end");
Menu.Add
(RecruitMenu, "command",
"-label {Show recruit details} -command {ShowRecruitInfo}");
Menu.Add
(RecruitMenu, "command",
"-label {Start negotiations} -command {Negotiate}");
Tk_Popup
(RecruitMenu, Winfo_Get(Get_Main_Window(Interp), "pointerx"),
Winfo_Get(Get_Main_Window(Interp), "pointery"));
return TCL_OK;
end Show_Recruit_Menu_Command;
-- ****o* RecruitUI/RecruitUI.Show_Recruit_Info_Command
-- FUNCTION
-- Show information about the selected recruit
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowRecruitInfoCommand
-- SOURCE
function Show_Recruit_Info_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Recruit_Info_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc, Argv);
use Tiny_String;
RecruitInfo: Unbounded_String;
BaseIndex: constant Positive :=
SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex;
Recruit: constant Recruit_Data :=
Sky_Bases(BaseIndex).Recruits(RecruitIndex);
RecruitDialog: constant Ttk_Frame :=
Create_Dialog(".recruitdialog", To_String(Recruit.Name));
YScroll: constant Ttk_Scrollbar :=
Create
(RecruitDialog & ".yscroll",
"-orient vertical -command [list " & RecruitDialog &
".canvas yview]");
RecruitCanvas: constant Tk_Canvas :=
Create
(RecruitDialog & ".canvas",
"-yscrollcommand [list " & YScroll & " set]");
CloseButton, InfoButton, Button: Ttk_Button;
Height, NewHeight: Positive := 1;
Width, NewWidth: Positive := 1;
ProgressBar: Ttk_ProgressBar;
TabButton: Ttk_RadioButton;
Frame: Ttk_Frame := Create(RecruitDialog & ".buttonbox");
RecruitLabel: Ttk_Label;
ProgressFrame: Ttk_Frame;
TabNames: constant array(1 .. 4) of Unbounded_String :=
(To_Unbounded_String("General"), To_Unbounded_String("Attributes"),
To_Unbounded_String("Skills"), To_Unbounded_String("Inventory"));
begin
Tcl_SetVar(Interp, "newtab", To_Lower(To_String(TabNames(1))));
for I in TabNames'Range loop
TabButton :=
Create
(Frame & "." & To_Lower(To_String(TabNames(I))),
" -text " & To_String(TabNames(I)) &
" -style Radio.Toolbutton -value " &
To_Lower(To_String(TabNames(I))) &
" -variable newtab -command ShowRecruitTab");
Tcl.Tk.Ada.Grid.Grid
(TabButton, "-column" & Natural'Image(I - 1) & " -row 0");
Bind
(TabButton, "<Escape>",
"{" & RecruitDialog & ".buttonbox2.button invoke;break}");
end loop;
Height := Positive'Value(Winfo_Get(TabButton, "reqheight"));
Bind
(TabButton, "<Tab>",
"{focus " & RecruitDialog & ".buttonbox2.hirebutton;break}");
Tcl.Tk.Ada.Grid.Grid(Frame, "-pady {5 0} -columnspan 2");
Tcl.Tk.Ada.Grid.Grid(RecruitCanvas, "-sticky nwes -pady 5 -padx 5");
Tcl.Tk.Ada.Grid.Grid
(YScroll, " -sticky ns -pady 5 -padx {0 5} -row 1 -column 1");
Frame := Create(RecruitDialog & ".buttonbox2");
Button :=
Create
(RecruitDialog & ".buttonbox2.hirebutton",
"-text Negotiate -command {CloseDialog " & RecruitDialog &
";Negotiate}");
Tcl.Tk.Ada.Grid.Grid(Button);
CloseButton :=
Create
(RecruitDialog & ".buttonbox2.button",
"-text Close -command {CloseDialog " & RecruitDialog & "}");
Tcl.Tk.Ada.Grid.Grid(CloseButton, "-row 0 -column 1");
Tcl.Tk.Ada.Grid.Grid(Frame, "-pady {0 5}");
Focus(CloseButton);
Autoscroll(YScroll);
-- General info about the selected recruit
Frame := Create(RecruitCanvas & ".general");
if not Factions_List(Recruit.Faction).Flags.Contains
(To_Unbounded_String("nogender")) then
RecruitInfo :=
(if Recruit.Gender = 'M' then To_Unbounded_String("Gender: Male")
else To_Unbounded_String("Gender: Female"));
end if;
Append
(RecruitInfo,
LF & "Faction: " & Factions_List(Recruit.Faction).Name & LF &
"Home base: " & Sky_Bases(Recruit.Home_Base).Name);
RecruitLabel :=
Create
(Frame & ".label",
"-text {" & To_String(RecruitInfo) & "} -wraplength 400");
Tcl.Tk.Ada.Grid.Grid(RecruitLabel, "-sticky w");
Height := Height + Positive'Value(Winfo_Get(RecruitLabel, "reqheight"));
Width := Positive'Value(Winfo_Get(RecruitLabel, "reqwidth"));
Tcl.Tk.Ada.Grid.Grid(Frame);
-- Statistics of the selected recruit
Frame := Create(RecruitCanvas & ".attributes");
Show_Recruit_Stats_Loop :
for I in Recruit.Attributes'Range loop
ProgressFrame :=
Create(Frame & ".statinfo" & Trim(Positive'Image(I), Left));
RecruitLabel :=
Create
(ProgressFrame & ".label",
"-text {" &
To_String
(AttributesData_Container.Element(Attributes_List, I).Name) &
": " & GetAttributeLevelName(Recruit.Attributes(I).Level) & "}");
Tcl.Tk.Ada.Grid.Grid(RecruitLabel);
InfoButton :=
Create
(ProgressFrame & ".button",
"-text ""[format %c 0xf05a]"" -style Header.Toolbutton -command {ShowCrewStatsInfo" &
Positive'Image(I) & " .recruitdialog}");
Tcl.Tklib.Ada.Tooltip.Add
(InfoButton,
"Show detailed information about the selected attribute.");
Tcl.Tk.Ada.Grid.Grid(InfoButton, "-column 1 -row 0");
NewHeight :=
NewHeight + Positive'Value(Winfo_Get(InfoButton, "reqheight"));
Tcl.Tk.Ada.Grid.Grid(ProgressFrame);
ProgressBar :=
Create
(Frame & ".level" & Trim(Positive'Image(I), Left),
"-value" & Positive'Image(Recruit.Attributes(I).Level * 2) &
" -length 200");
Tcl.Tklib.Ada.Tooltip.Add
(ProgressBar, "The current level of the attribute.");
Tcl.Tk.Ada.Grid.Grid(ProgressBar);
NewHeight :=
NewHeight + Positive'Value(Winfo_Get(ProgressBar, "reqheight"));
end loop Show_Recruit_Stats_Loop;
if NewHeight > Height then
Height := NewHeight;
end if;
-- Skills of the selected recruit
Frame := Create(RecruitCanvas & ".skills");
NewHeight := 1;
Show_Recruit_Skills_Loop :
for I in Recruit.Skills.Iterate loop
ProgressFrame :=
Create
(Frame & ".skillinfo" &
Trim(Positive'Image(Skills_Container.To_Index(I)), Left));
RecruitLabel :=
Create
(ProgressFrame & ".label" &
Trim(Positive'Image(Skills_Container.To_Index(I)), Left),
"-text {" &
To_String
(SkillsData_Container.Element
(Skills_List, Recruit.Skills(I).Index)
.Name) &
": " & GetSkillLevelName(Recruit.Skills(I).Level) & "}");
Tcl.Tk.Ada.Grid.Grid(RecruitLabel);
declare
ToolQuality: Positive := 100;
begin
Tool_Quality_Loop :
for Quality of SkillsData_Container.Element
(Skills_List, Skills_Container.To_Index(I))
.Tools_Quality loop
if Recruit.Skills(I).Level <= Quality.Level then
ToolQuality := Quality.Quality;
exit Tool_Quality_Loop;
end if;
end loop Tool_Quality_Loop;
InfoButton :=
Create
(ProgressFrame & ".button",
"-text ""[format %c 0xf05a]"" -style Header.Toolbutton -command {ShowCrewSkillInfo" &
Positive'Image(Recruit.Skills(I).Index) &
Positive'Image(ToolQuality) & " .recruitdialog}");
end;
Tcl.Tklib.Ada.Tooltip.Add
(InfoButton, "Show detailed information about the selected skill.");
Tcl.Tk.Ada.Grid.Grid(InfoButton, "-column 1 -row 0");
NewHeight :=
NewHeight + Positive'Value(Winfo_Get(InfoButton, "reqheight"));
Tcl.Tk.Ada.Grid.Grid(ProgressFrame);
ProgressBar :=
Create
(Frame & ".level" &
Trim(Positive'Image(Skills_Container.To_Index(I)), Left),
"-value" & Positive'Image(Recruit.Skills(I).Level) &
" -length 200");
Tcl.Tklib.Ada.Tooltip.Add
(ProgressBar, "The current level of the skill.");
Tcl.Tk.Ada.Grid.Grid(ProgressBar);
NewHeight :=
NewHeight + Positive'Value(Winfo_Get(ProgressBar, "reqheight"));
end loop Show_Recruit_Skills_Loop;
if NewHeight > Height then
Height := NewHeight;
end if;
-- Equipment of the selected recruit
Frame := Create(RecruitCanvas & ".inventory");
NewHeight := 1;
RecruitInfo := Null_Unbounded_String;
Show_Recruit_Equipment_Loop :
for Item of Recruit.Inventory loop
Append(RecruitInfo, Items_List(Item).Name & LF);
end loop Show_Recruit_Equipment_Loop;
RecruitLabel :=
Create
(Frame & ".label",
"-text {" & To_String(RecruitInfo) & "} -wraplength 400");
Tcl.Tk.Ada.Grid.Grid(RecruitLabel, "-sticky w");
NewHeight := Positive'Value(Winfo_Get(RecruitLabel, "reqheight"));
if NewHeight > Height then
Height := NewHeight;
end if;
NewWidth := Positive'Value(Winfo_Get(RecruitLabel, "reqwidth"));
if NewWidth > Width then
Width := NewWidth;
end if;
if Height > 500 then
Height := 500;
end if;
if Width < 350 then
Width := 350;
end if;
Frame := Get_Widget(RecruitCanvas & ".general");
declare
XPos: constant Natural :=
(Positive'Value(Winfo_Get(RecruitCanvas, "reqwidth")) -
Positive'Value(Winfo_Get(Frame, "reqwidth"))) /
4;
begin
Canvas_Create
(RecruitCanvas, "window",
Trim(Natural'Image(XPos), Left) & " 0 -anchor nw -window " &
Frame & " -tag info");
end;
Tcl_Eval(Interp, "update");
configure
(RecruitCanvas,
"-scrollregion [list " & BBox(RecruitCanvas, "all") & "] -width" &
Positive'Image(Width) & " -height" & Positive'Image(Height));
Bind
(CloseButton, "<Tab>",
"{focus " & RecruitDialog & ".buttonbox.general;break}");
Bind(RecruitDialog, "<Escape>", "{" & CloseButton & " invoke;break}");
Bind(CloseButton, "<Escape>", "{" & CloseButton & " invoke;break}");
Show_Dialog(Dialog => RecruitDialog, Relative_Y => 0.2);
return TCL_OK;
end Show_Recruit_Info_Command;
-- ****o* RecruitUI/RecruitUI.Negotiate_Hire_Command
-- FUNCTION
-- Show information about the selected recruit
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- NegotiateHire
-- SOURCE
function Negotiate_Hire_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Negotiate_Hire_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc, Argv);
DialogName: constant String := ".negotiatedialog";
MoneyIndex2: constant Natural :=
FindItem(Player_Ship.Cargo, Money_Index);
BaseIndex: constant Positive :=
SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex;
Recruit: constant Recruit_Data :=
Sky_Bases(BaseIndex).Recruits(RecruitIndex);
Cost: Integer;
Scale: Ttk_Scale := Get_Widget(DialogName & ".daily", Interp);
DailyPayment: constant Natural :=
Natural(Float'Value(cget(Scale, "-value")));
ContractBox: constant Ttk_ComboBox :=
Get_Widget(DialogName & ".contract", Interp);
ContractLength: constant Natural := Natural'Value(Current(ContractBox));
TradePayment: Natural;
Label: Ttk_Label := Get_Widget(DialogName & ".cost", Interp);
HireButton: constant Ttk_Button :=
Get_Widget(DialogName & ".buttonbox.hirebutton", Interp);
begin
Scale.Name := New_String(DialogName & ".percent");
TradePayment := Natural(Float'Value(cget(Scale, "-value")));
Cost :=
Recruit.Price - ((DailyPayment - Recruit.Payment) * 50) -
(TradePayment * 5_000);
Cost :=
(case ContractLength is
when 1 => Cost - Integer(Float(Recruit.Price) * 0.1),
when 2 => Cost - Integer(Float(Recruit.Price) * 0.5),
when 3 => Cost - Integer(Float(Recruit.Price) * 0.75),
when 4 => Cost - Integer(Float(Recruit.Price) * 0.9),
when others => Cost);
if Cost < 1 then
Cost := 1;
end if;
Count_Price(Cost, FindMember(Talk));
configure
(Label,
"-text {Hire for" & Natural'Image(Cost) & " " &
To_String(Money_Name) & "}");
Label.Name := New_String(DialogName & ".dailylbl");
configure
(Label, "-text {Daily payment:" & Natural'Image(DailyPayment) & "}");
Label.Name := New_String(DialogName & ".percentlbl");
configure
(Label,
"-text {Percent of profit from trades: " &
Natural'Image(TradePayment) & "}");
if MoneyIndex2 > 0
and then Player_Ship.Cargo(MoneyIndex2).Amount < Cost then
configure(HireButton, "-state disabled");
else
configure(HireButton, "-state !disabled");
end if;
return TCL_OK;
end Negotiate_Hire_Command;
-- ****o* RecruitUI/RecruitUI.Hire_Command
-- FUNCTION
-- Hire the selected recruit
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- Hire
-- SOURCE
function Hire_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Hire_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(Argc, Argv);
DialogName: constant String := ".negotiatedialog";
Cost, ContractLength2: Integer;
BaseIndex: constant Positive :=
SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex;
Recruit: constant Recruit_Data :=
Sky_Bases(BaseIndex).Recruits(RecruitIndex);
Scale: Ttk_Scale := Get_Widget(DialogName & ".daily", Interp);
DailyPayment: constant Natural :=
Natural(Float'Value(cget(Scale, "-value")));
ContractBox: constant Ttk_ComboBox :=
Get_Widget(DialogName & ".contract", Interp);
ContractLength: constant Natural := Natural'Value(Current(ContractBox));
TradePayment: Natural;
begin
Scale.Name := New_String(DialogName & ".percent");
TradePayment := Natural(Float'Value(cget(Scale, "-value")));
Cost :=
Recruit.Price - ((DailyPayment - Recruit.Payment) * 50) -
(TradePayment * 5_000);
case ContractLength is
when 1 =>
Cost := Cost - Integer(Float(Recruit.Price) * 0.1);
ContractLength2 := 100;
when 2 =>
Cost := Cost - Integer(Float(Recruit.Price) * 0.5);
ContractLength2 := 30;
when 3 =>
Cost := Cost - Integer(Float(Recruit.Price) * 0.75);
ContractLength2 := 20;
when 4 =>
Cost := Cost - Integer(Float(Recruit.Price) * 0.9);
ContractLength2 := 10;
when others =>
ContractLength2 := -1;
end case;
if Cost < 1 then
Cost := 1;
end if;
HireRecruit
(RecruitIndex, Cost, DailyPayment, TradePayment, ContractLength2);
Update_Messages;
Tcl_Eval(Interp, "CloseDialog " & DialogName);
return
Show_Recruit_Command
(ClientData, Interp, 2, CArgv.Empty & "ShowRecruit" & "1");
end Hire_Command;
-- ****o* RecruitUI/RecruitUI.Show_Recruit_Tab_Command
-- FUNCTION
-- Show the selected information about the selected recruit
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowMemberTab
-- SOURCE
function Show_Recruit_Tab_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Recruit_Tab_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc, Argv);
RecruitCanvas: constant Tk_Canvas :=
Get_Widget(".recruitdialog.canvas", Interp);
Frame: constant Ttk_Frame :=
Get_Widget(RecruitCanvas & "." & Tcl_GetVar(Interp, "newtab"));
XPos: constant Natural :=
(Positive'Value(Winfo_Get(RecruitCanvas, "reqwidth")) -
Positive'Value(Winfo_Get(Frame, "reqwidth"))) /
2;
begin
Delete(RecruitCanvas, "info");
Canvas_Create
(RecruitCanvas, "window",
Trim(Positive'Image(XPos), Left) & " 0 -anchor nw -window " & Frame &
" -tag info");
Tcl_Eval(Interp, "update");
configure
(RecruitCanvas,
"-scrollregion [list " & BBox(RecruitCanvas, "all") & "]");
return TCL_OK;
end Show_Recruit_Tab_Command;
-- ****o* RecruitUI/RecruitUI.Negotiate_Command
-- FUNCTION
-- Show negotation UI to the player
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- Negotiate
-- SOURCE
function Negotiate_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Negotiate_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc, Argv);
BaseIndex: constant Positive :=
SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex;
Recruit: constant Recruit_Data :=
Sky_Bases(BaseIndex).Recruits(RecruitIndex);
NegotiateDialog: constant Ttk_Frame :=
Create_Dialog
(".negotiatedialog", "Negotiate with " & To_String(Recruit.Name));
CloseButton, HireButton: Ttk_Button;
Frame: constant Ttk_Frame := Create(NegotiateDialog & ".buttonbox");
Label: Ttk_Label;
Scale: Ttk_Scale;
ContractBox: constant Ttk_ComboBox :=
Create
(NegotiateDialog & ".contract",
"-state readonly -values [list {Pernament} {100 days} {30 days} {20 days} {10 days}]");
MoneyIndex2: constant Natural :=
FindItem(Player_Ship.Cargo, Money_Index);
Cost: Positive;
begin
Label :=
Create
(NegotiateDialog & ".dailylbl",
"-text {Daily payment:" & Natural'Image(Recruit.Payment) & "}");
Tcl.Tk.Ada.Grid.Grid(Label, "-pady {5 0}");
Scale :=
Create
(NegotiateDialog & ".daily",
"-from 0 -command NegotiateHire -length 250");
Tcl.Tk.Ada.Grid.Grid(Scale);
configure
(Scale,
"-to" & Natural'Image(Recruit.Payment * 2) & " -value" &
Natural'Image(Recruit.Payment));
Label :=
Create
(NegotiateDialog & ".percentlbl",
"-text {Percent of profit from trades: 0}");
Tcl.Tk.Ada.Grid.Grid(Label, "-padx 5");
Scale :=
Create
(NegotiateDialog & ".percent",
"-from 0 -to 10 -command NegotiateHire -length 250");
Tcl.Tk.Ada.Grid.Grid(Scale);
configure(Scale, "-value 0");
Label :=
Create(NegotiateDialog & ".contractlbl", "-text {Contract time:}");
Tcl.Tk.Ada.Grid.Grid(Label);
Tcl.Tk.Ada.Grid.Grid(ContractBox);
Bind(ContractBox, "<<ComboboxSelected>>", "{NegotiateHire}");
Current(ContractBox, "0");
HireButton :=
Create
(NegotiateDialog & ".buttonbox.hirebutton",
"-text Hire -command {Hire}");
Label := Create(NegotiateDialog & ".money");
Tcl.Tk.Ada.Grid.Grid(Label);
Cost := Recruit.Price;
Count_Price(Cost, FindMember(Talk));
if MoneyIndex2 > 0 then
configure
(Label,
"-text {You have" &
Natural'Image(Player_Ship.Cargo(MoneyIndex2).Amount) & " " &
To_String(Money_Name) & ".}");
if Player_Ship.Cargo(MoneyIndex2).Amount < Cost then
configure(HireButton, "-state disabled");
else
configure(HireButton, "-state !disabled");
end if;
else
configure
(Label, "-text {You don't have enough money to recruit anyone}");
configure(HireButton, "-state disabled");
end if;
Label := Create(NegotiateDialog & ".cost");
Tcl.Tk.Ada.Grid.Grid(Label);
configure
(Label,
"-text {Hire for" & Positive'Image(Cost) & " " &
To_String(Money_Name) & "}");
Tcl.Tk.Ada.Grid.Grid(HireButton);
CloseButton :=
Create
(NegotiateDialog & ".buttonbox.button",
"-text Close -command {CloseDialog " & NegotiateDialog & "}");
Tcl.Tk.Ada.Grid.Grid(CloseButton, "-row 0 -column 1");
Tcl.Tk.Ada.Grid.Grid(Frame, "-pady {0 5}");
Focus(CloseButton);
Bind(CloseButton, "<Tab>", "{focus " & HireButton & ";break}");
Bind(HireButton, "<Tab>", "{focus " & CloseButton & ";break}");
Bind(NegotiateDialog, "<Escape>", "{" & CloseButton & " invoke;break}");
Bind(CloseButton, "<Escape>", "{" & CloseButton & " invoke;break}");
Show_Dialog(Dialog => NegotiateDialog, Relative_Y => 0.2);
return TCL_OK;
end Negotiate_Command;
-- ****it* RecruitUI/RecruitUI.Recruits_Sort_Orders
-- FUNCTION
-- Sorting orders for the list of available recruits in base
-- OPTIONS
-- NAMEASC - Sort recruits by name ascending
-- NAMEDESC - Sort recruits by name descending
-- GENDERASC - Sort recruits by gender ascending
-- GENDERDESC - Sort recruits by gender descending
-- FACTIONASC - Sort recruits by faction ascending
-- FACTIONDESC - Sort recruits by faction descending
-- PRICEASC - Sort recruits by price ascending
-- PRICEDESC - Sort recruits by price descending
-- ATTRIBUTEASC - Sort recruits by attribute ascending
-- ATTRIBUTEDESC - Sort recruits by attribute descending
-- SKILLASC - Sort recruits by skill ascending
-- SKILLDESC - Sort recruits by skill descending
-- NONE - No sorting recruits (default)
-- HISTORY
-- 6.4 - Added
-- SOURCE
type Recruits_Sort_Orders is
(NAMEASC, NAMEDESC, GENDERASC, GENDERDESC, FACTIONDESC, FACTIONASC,
PRICEASC, PRICEDESC, ATTRIBUTEASC, ATTRIBUTEDESC, SKILLASC, SKILLDESC,
NONE) with
Default_Value => NONE;
-- ****
-- ****id* RecruitUI/RecruitUI.Default_Recruits_Sort_Order
-- FUNCTION
-- Default sorting order for the available recruits in base
-- HISTORY
-- 6.4 - Added
-- SOURCE
Default_Recruits_Sort_Order: constant Recruits_Sort_Orders := NONE;
-- ****
-- ****iv* RecruitUI/RecruitUI.Recruits_Sort_Order
-- FUNCTION
-- The current sorting order for the available recruits in base
-- HISTORY
-- 6.4 - Added
-- SOURCE
Recruits_Sort_Order: Recruits_Sort_Orders := Default_Recruits_Sort_Order;
-- ****
-- ****o* RecruitUI/RecruitUI.Sort_Recruits_Command
-- FUNCTION
-- Sort the list of available recruits in base
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- SortRecruits x
-- X is X axis coordinate where the player clicked the mouse button
-- SOURCE
function Sort_Recruits_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Sort_Recruits_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(Argc);
Column: constant Positive :=
Get_Column_Number(RecruitTable, Natural'Value(CArgv.Arg(Argv, 1)));
type Local_Module_Data is record
Name: Unbounded_String;
Gender: Character;
Faction: Unbounded_String;
Price: Positive;
Attribute: Unbounded_String;
Skill: Unbounded_String;
Id: Positive;
end record;
type Recruits_Array is array(Positive range <>) of Local_Module_Data;
BaseIndex: constant Positive :=
SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex;
Local_Recruits: Recruits_Array
(1 .. Positive(Sky_Bases(BaseIndex).Recruits.Length));
function "<"(Left, Right: Local_Module_Data) return Boolean is
begin
if Recruits_Sort_Order = NAMEASC and then Left.Name < Right.Name then
return True;
end if;
if Recruits_Sort_Order = NAMEDESC and then Left.Name > Right.Name then
return True;
end if;
if Recruits_Sort_Order = GENDERASC
and then Left.Gender < Right.Gender then
return True;
end if;
if Recruits_Sort_Order = GENDERDESC
and then Left.Gender > Right.Gender then
return True;
end if;
if Recruits_Sort_Order = FACTIONASC
and then Left.Faction < Right.Faction then
return True;
end if;
if Recruits_Sort_Order = FACTIONDESC
and then Left.Faction > Right.Faction then
return True;
end if;
if Recruits_Sort_Order = PRICEASC
and then Left.Price < Right.Price then
return True;
end if;
if Recruits_Sort_Order = PRICEDESC
and then Left.Price > Right.Price then
return True;
end if;
if Recruits_Sort_Order = ATTRIBUTEASC
and then Left.Attribute < Right.Attribute then
return True;
end if;
if Recruits_Sort_Order = ATTRIBUTEDESC
and then Left.Attribute > Right.Attribute then
return True;
end if;
if Recruits_Sort_Order = SKILLASC
and then Left.Skill < Right.Skill then
return True;
end if;
if Recruits_Sort_Order = SKILLDESC
and then Left.Skill > Right.Skill then
return True;
end if;
return False;
end "<";
procedure Sort_Recruits is new Ada.Containers.Generic_Array_Sort
(Index_Type => Positive, Element_Type => Local_Module_Data,
Array_Type => Recruits_Array);
begin
case Column is
when 1 =>
if Recruits_Sort_Order = NAMEASC then
Recruits_Sort_Order := NAMEDESC;
else
Recruits_Sort_Order := NAMEASC;
end if;
when 2 =>
if Recruits_Sort_Order = GENDERASC then
Recruits_Sort_Order := GENDERDESC;
else
Recruits_Sort_Order := GENDERASC;
end if;
when 3 =>
if Recruits_Sort_Order = FACTIONASC then
Recruits_Sort_Order := FACTIONDESC;
else
Recruits_Sort_Order := FACTIONASC;
end if;
when 4 =>
if Recruits_Sort_Order = PRICEASC then
Recruits_Sort_Order := PRICEDESC;
else
Recruits_Sort_Order := PRICEASC;
end if;
when 5 =>
if Recruits_Sort_Order = ATTRIBUTEASC then
Recruits_Sort_Order := ATTRIBUTEDESC;
else
Recruits_Sort_Order := ATTRIBUTEASC;
end if;
when 6 =>
if Recruits_Sort_Order = SKILLASC then
Recruits_Sort_Order := SKILLDESC;
else
Recruits_Sort_Order := SKILLASC;
end if;
when others =>
null;
end case;
if Recruits_Sort_Order = NONE then
return TCL_OK;
end if;
for I in Sky_Bases(BaseIndex).Recruits.Iterate loop
Local_Recruits(Recruit_Container.To_Index(I)) :=
(Name => Sky_Bases(BaseIndex).Recruits(I).Name,
Gender => Sky_Bases(BaseIndex).Recruits(I).Gender,
Faction => Sky_Bases(BaseIndex).Recruits(I).Faction,
Price => Sky_Bases(BaseIndex).Recruits(I).Price,
Attribute =>
Get_Highest_Attribute(BaseIndex, Recruit_Container.To_Index(I)),
Skill =>
Get_Highest_Skill(BaseIndex, Recruit_Container.To_Index(I)),
Id => Recruit_Container.To_Index(I));
end loop;
Sort_Recruits(Local_Recruits);
Recruits_Indexes.Clear;
for Recruit of Local_Recruits loop
Recruits_Indexes.Append(Recruit.Id);
end loop;
return
Show_Recruit_Command
(ClientData, Interp, 2, CArgv.Empty & "ShowRecruits" & "1");
end Sort_Recruits_Command;
procedure AddCommands is
begin
Add_Command("ShowRecruit", Show_Recruit_Command'Access);
Add_Command("ShowRecruitMenu", Show_Recruit_Menu_Command'Access);
Add_Command("ShowRecruitInfo", Show_Recruit_Info_Command'Access);
Add_Command("NegotiateHire", Negotiate_Hire_Command'Access);
Add_Command("Hire", Hire_Command'Access);
Add_Command("ShowRecruitTab", Show_Recruit_Tab_Command'Access);
Add_Command("Negotiate", Negotiate_Command'Access);
Add_Command("SortRecruits", Sort_Recruits_Command'Access);
end AddCommands;
end Bases.RecruitUI;
|
src/test/resources/samples/langs/AppleScript/Time Of Day.applescript
|
JavascriptID/sourcerer-app
| 8,271 |
2491
|
(*
Speaks the date and time of day
Copyright 2008 Apple Inc. All rights reserved.
You may incorporate this Apple sample code into your program(s) without
restriction. This Apple sample code has been provided "AS IS" and the
responsibility for its operation is yours. You are not permitted to
redistribute this Apple sample code as "Apple sample code" after having
made changes. If you're going to redistribute the code, we require
that you make it clear that the code was descended from Apple sample
code, but that you've made changes.
*)
on isVoiceOverRunning()
set isRunning to false
tell application "System Events"
set isRunning to (name of processes) contains "VoiceOver"
end tell
return isRunning
end isVoiceOverRunning
on isVoiceOverRunningWithAppleScript()
if isVoiceOverRunning() then
set isRunningWithAppleScript to true
-- is AppleScript enabled on VoiceOver --
tell application "VoiceOver"
try
set x to bounds of vo cursor
on error
set isRunningWithAppleScript to false
end try
end tell
return isRunningWithAppleScript
end if
return false
end isVoiceOverRunningWithAppleScript
set currentDate to current date
set amPM to "AM"
set currentHour to (currentDate's hours)
set currentMinutes to currentDate's minutes
if (currentHour > 12 and currentHour < 24) then
set amPM to "PM"
else
set amPM to "AM"
end if
-- make minutes below 10 sound nice
if currentMinutes < 10 then
set currentMinutes to ("0" & currentMinutes) as text
end if
-- ensure 0:nn gets set to 12:nn AM
if currentHour is equal to 0 then
set currentHour to 12
end if
-- readjust for 12 hour time
if (currentHour > 12) then
set currentHour to (currentHour - 12)
end if
set currentTime to ((currentDate's month) as text) & " " & ((currentDate's day) as text) & ", " & (currentHour as text) & ":" & ((currentMinutes) as text) & " " & amPM as text
if isVoiceOverRunningWithAppleScript() then
tell application "VoiceOver"
output currentTime
end tell
else
say currentTime
delay 2
end if
|
Toggle Night Shift.applescript
|
ravicious/toggle-night-shift
| 13 |
968
|
tell application "System Preferences"
activate
reveal anchor "displaysNightShiftTab" of pane id "com.apple.preference.displays"
delay 1
end tell
tell application "System Events"
tell process "System Preferences"
click checkbox 1 of tab group 1 of window 1
end tell
end tell
tell application "System Preferences"
quit
end tell
|
Transynther/x86/_processed/AVXALIGN/_ht_zr_/i9-9900K_12_0xca.log_21829_8.asm
|
ljhsiun2/medusa
| 9 |
243945
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r14
push %r15
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0x301b, %r13
nop
nop
xor %rdx, %rdx
mov (%r13), %rcx
nop
cmp $17576, %rdi
lea addresses_WC_ht+0xcf0f, %rsi
lea addresses_UC_ht+0x1e70f, %rdi
clflush (%rdi)
nop
nop
nop
nop
cmp $14921, %r8
mov $18, %rcx
rep movsq
cmp $30289, %rcx
lea addresses_WC_ht+0xc08f, %r8
nop
and $14510, %r15
movups (%r8), %xmm3
vpextrq $0, %xmm3, %rdi
nop
nop
nop
sub $25372, %r15
lea addresses_A_ht+0x1b187, %rdx
nop
nop
nop
nop
dec %r13
and $0xffffffffffffffc0, %rdx
movaps (%rdx), %xmm0
vpextrq $1, %xmm0, %rdi
nop
nop
nop
nop
add $250, %rdi
lea addresses_normal_ht+0x1618f, %r15
nop
cmp $36367, %rdx
mov $0x6162636465666768, %rsi
movq %rsi, (%r15)
nop
nop
nop
nop
and %rsi, %rsi
lea addresses_WC_ht+0x8f0f, %rsi
lea addresses_UC_ht+0x10ecf, %rdi
nop
nop
nop
nop
inc %r14
mov $57, %rcx
rep movsw
nop
nop
nop
dec %r14
lea addresses_WT_ht+0x1563f, %rsi
lea addresses_A_ht+0x140f, %rdi
sub %r8, %r8
mov $3, %rcx
rep movsw
nop
nop
nop
nop
cmp $2337, %r15
lea addresses_UC_ht+0xd3bb, %rcx
dec %r15
mov (%rcx), %r14
add %rcx, %rcx
lea addresses_UC_ht+0x1bcd3, %r15
nop
sub %rsi, %rsi
movl $0x61626364, (%r15)
nop
nop
dec %r14
lea addresses_UC_ht+0x9c0f, %rsi
add $12481, %r15
movb (%rsi), %r8b
and $34809, %rdi
lea addresses_UC_ht+0x4d5f, %rdx
add $63388, %rsi
movl $0x61626364, (%rdx)
nop
add %rcx, %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r15
pop %r14
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r14
push %rdx
push %rsi
// Faulty Load
lea addresses_normal+0x1f70f, %r11
nop
nop
nop
nop
nop
add $4609, %r10
movaps (%r11), %xmm7
vpextrq $1, %xmm7, %rsi
lea oracles, %rdx
and $0xff, %rsi
shlq $12, %rsi
mov (%rdx,%rsi,1), %rsi
pop %rsi
pop %rdx
pop %r14
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_normal', 'same': True, 'AVXalign': True, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 10}, 'dst': {'same': True, 'type': 'addresses_UC_ht', 'congruent': 8}}
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_WC_ht', 'same': True, 'AVXalign': False, 'congruent': 5}}
{'OP': 'LOAD', 'src': {'size': 16, 'NT': True, 'type': 'addresses_A_ht', 'same': True, 'AVXalign': True, 'congruent': 2}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 11}, 'dst': {'same': True, 'type': 'addresses_UC_ht', 'congruent': 5}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 4}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 8}}
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': True, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': True, 'congruent': 1}}
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': True, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 4}}
{'45': 3762, '00': 18067}
45 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 45 00 00 00 45 00 00 00 45 00 00 00 00 00 00 00 00 45 00 00 00 45 00 00 00 00 00 00 45 00 00 00 00 00 00 00 00 45 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 45 00 00 00 00 00 00 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 00 45 00 00 00 45 00 00 00 45 00 00 00 00 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 00 45 45 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 00 45 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 45 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 45 00 00 00 00 00 00 00 00 45 00 00 00 00 45 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 00 00 00 45 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 00 45 00 00 00 45 00 00 00 00 45 00 00 00 00 00 00 00 45 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 45 00 00 00 45 00 00 00 45 00 00 00 00 00 00 00 00 00 00 45 00 00 00 45 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 00 45 00 00 00 00 00 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 45 00 00 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 00 00 00 00 45 00 00 00 00 00 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 45 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 00 00 00 45 00 00 45 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 45 00 00 00 45 00 00 00 45 00 00 00 00 00 45 00 00 00 00 00 00 00 45 00 00 00 45 00 00 00 45 00 45 00 00 45 00 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 00 00 45 00 00 00 45 00 00 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 00 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00 00 00 45 00 00
*/
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/alignment8.adb
|
best08618/asylo
| 7 |
14716
|
-- { dg-do run }
with System;
procedure Alignment8 is
type R is record
I : Integer;
F : Long_Long_Integer;
end record;
for R'Alignment use 8;
procedure Q (A : System.Address) is
F : Long_Long_Integer;
for F'Address use A;
begin
F := 0;
end;
V : R;
begin
Q (V.F'Address);
end;
|
programs/oeis/044/A044179.asm
|
karttu/loda
| 1 |
168241
|
; A044179: Numbers n such that string 5,6 occurs in the base 7 representation of n but not of n-1.
; 41,90,139,188,237,286,335,384,433,482,531,580,629,678,727,776,825,874,923,972,1021,1070,1119,1168,1217,1266,1315,1364,1413,1462,1511,1560,1609,1658,1707,1756,1805,1854,1903,1952,2001
mov $1,$0
mul $1,49
add $1,41
|
internal/mini-mini-lob.agda
|
JasonGross/lob
| 19 |
1373
|
<reponame>JasonGross/lob
{-# OPTIONS --without-K #-}
infixr 1 _‘→’_
record ⊤ : Set where
constructor tt
data ⊥ : Set where
mutual
data Type : Set where
_‘→’_ : Type → Type → Type
‘□’ : Type → Type
‘⊤’ : Type
‘⊥’ : Type
data □ : Type → Set where
Lӧb : ∀ {X} → □ (‘□’ X ‘→’ X) → □ X
‘tt’ : □ ‘⊤’
mutual
⌞_⌟ : Type → Set
⌞ A ‘→’ B ⌟ = ⌞ A ⌟ → ⌞ B ⌟
⌞ ‘□’ T ⌟ = □ T
⌞ ‘⊤’ ⌟ = ⊤
⌞ ‘⊥’ ⌟ = ⊥
⌞_⌟t : ∀ {T : Type} → □ T → ⌞ T ⌟
⌞ (Lӧb □‘X’→X) ⌟t = ⌞ □‘X’→X ⌟t (Lӧb □‘X’→X)
⌞ ‘tt’ ⌟t = tt
¬_ : Set → Set
¬ T = T → ⊥
‘¬’_ : Type → Type
‘¬’ T = T ‘→’ ‘⊥’
lӧb : ∀ {‘X’} → □ (‘□’ ‘X’ ‘→’ ‘X’) → ⌞ ‘X’ ⌟
lӧb f = ⌞ Lӧb f ⌟t
incompleteness : ¬ □ (‘¬’ (‘□’ ‘⊥’))
incompleteness = lӧb
soundness : ¬ □ ‘⊥’
soundness x = ⌞ x ⌟t
non-emptyness : □ ‘⊤’
non-emptyness = ‘tt’
|
oeis/099/A099099.asm
|
neoneye/loda-programs
| 11 |
103507
|
; A099099: Quadrisection of a generalized Padovan sequence.
; Submitted by <NAME>
; 1,1,1,2,6,16,37,80,172,377,839,1874,4175,9274,20577,45665,101393,225193,500162,1110790,2466760,5477917,12164896,27015092,59993817,133231279,295872778,657057431,1459155634,3240410561,7196122817
mov $2,2
mov $4,1
lpb $0
sub $0,1
add $1,$2
sub $1,1
add $2,$4
sub $2,1
add $4,$3
add $3,$1
lpe
mov $0,$2
sub $0,1
|
Validation/pyFrame3DD-master/gcc-master/gcc/ada/libgnat/s-parame__vxworks.adb
|
djamal2727/Main-Bearing-Analytical-Model
| 0 |
7774
|
<filename>Validation/pyFrame3DD-master/gcc-master/gcc/ada/libgnat/s-parame__vxworks.adb
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . P A R A M E T E R S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Version used on all VxWorks targets
package body System.Parameters is
-------------------------
-- Adjust_Storage_Size --
-------------------------
function Adjust_Storage_Size (Size : Size_Type) return Size_Type is
begin
if Size = Unspecified_Size then
return Default_Stack_Size;
elsif Size < Minimum_Stack_Size then
return Minimum_Stack_Size;
else
return Size;
end if;
end Adjust_Storage_Size;
------------------------
-- Default_Stack_Size --
------------------------
function Default_Stack_Size return Size_Type is
Default_Stack_Size : Integer;
pragma Import (C, Default_Stack_Size, "__gl_default_stack_size");
begin
if Default_Stack_Size = -1 then
if Stack_Check_Limits then
return 32 * 1024;
-- Extra stack to allow for 12K exception area.
else
return 20 * 1024;
end if;
else
return Size_Type (Default_Stack_Size);
end if;
end Default_Stack_Size;
------------------------
-- Minimum_Stack_Size --
------------------------
function Minimum_Stack_Size return Size_Type is
begin
return 8 * 1024;
end Minimum_Stack_Size;
end System.Parameters;
|
LibraBFT/Impl/Properties/VotesOnceDirect.agda
|
haroldcarr/bft-consensus-agda
| 0 |
15542
|
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
{-# OPTIONS --allow-unsolved-metas #-}
-- This module proves the two "VotesOnce" proof obligations for our fake handler
open import Optics.All
open import LibraBFT.Prelude
open import LibraBFT.Lemmas
open import LibraBFT.Base.PKCS
import LibraBFT.Concrete.Properties.VotesOnce as VO
open import LibraBFT.Impl.Consensus.Types hiding (EpochConfigFor)
open import LibraBFT.Impl.Util.Crypto
open import LibraBFT.Impl.Handle.Properties sha256 sha256-cr
open import LibraBFT.Impl.Properties.Aux
open import LibraBFT.Concrete.System impl-sps-avp
open import LibraBFT.Concrete.System.Parameters
open EpochConfig
open import LibraBFT.Yasm.Yasm (ℓ+1 0ℓ) EpochConfig epochId authorsN ConcSysParms NodeId-PK-OK
open Structural impl-sps-avp
open import LibraBFT.Impl.Properties.VotesOnce
-- In this module, we (will) prove the two implementation obligations for the VotesOnce rule. Note
-- that it is not yet 100% clear that the obligations are the best definitions to use. See comments
-- in Concrete.VotesOnce. We will want to prove these obligations for the fake/simple
-- implementation (or some variant on it) and streamline the proof before we proceed to tacke more
-- ambitious properties.
module LibraBFT.Impl.Properties.VotesOnceDirect where
oldVoteRound≤lvr : ∀ {e pid pk v}{pre : SystemState e}
→ (r : ReachableSystemState pre)
→ initialised pre pid ≡ initd
→ Meta-Honest-PK pk → (sig : WithVerSig pk v)
→ MsgWithSig∈ pk (ver-signature sig) (msgPool pre)
→ ValidSenderForPK (availEpochs pre) v pid pk
→ (₋epEC (peerStates pre pid)) ^∙ epEpoch ≡ (v ^∙ vEpoch)
→ v ^∙ vRound ≤ (₋epEC (peerStates pre pid)) ^∙ epLastVotedRound
oldVoteRound≤lvr (step-s r (step-epoch _)) pidIn pkH sig msv vspk ep≡ = {!!}
oldVoteRound≤lvr {pid = pid'} {pre = pre} (step-s r (step-peer {pid = pid} cheat@(step-cheat f c)))
pidIn pkH sig msv vspk ep≡
with ¬cheatForgeNew cheat refl unit pkH msv
...| msb4
rewrite cheatStepDNMPeerStates₁ {pid = pid} {pid' = pid'} cheat unit
= oldVoteRound≤lvr r pidIn pkH sig msb4 vspk ep≡
oldVoteRound≤lvr {pid = pid'} {pre = pre}
step@(step-s r (step-peer {pid = pid} stHon@(step-honest stPeer)))
pidIn pkH sig msv vspk ep≡
with newMsg⊎msgSentB4 r stHon pkH (msgSigned msv) (msg⊆ msv) (msg∈pool msv)
...| inj₂ msb4 rewrite msgSameSig msv
with pid ≟ pid'
...| no imp = oldVoteRound≤lvr r pidIn pkH sig msb4 vspk ep≡
...| yes refl = let ep≡st = noEpochChangeYet r refl stPeer
lvr≤ = lastVoteRound-mono r refl stPeer ep≡st
ep≡v = trans ep≡st ep≡
in ≤-trans (oldVoteRound≤lvr r pidIn pkH sig msb4 vspk ep≡v) lvr≤
oldVoteRound≤lvr {pid = pid'} {pre = pre}
step@(step-s r (step-peer {pid = pid} stHon@(step-honest stPeer)))
pidIn pkH sig msv vspk ep≡
| inj₁ (m∈outs , vspkN , newV)
with sameHonestSig⇒sameVoteData pkH (msgSigned msv) sig (msgSameSig msv)
...| inj₁ hb = ⊥-elim (PerState.meta-sha256-cr pre step hb)
...| inj₂ refl
with sameEpoch⇒sameEC vspk vspkN refl
-- Both peers are allowed to sign for the same PK in the same epoch,
-- so they are the same peer
...| refl
with NodeId-PK-OK-injective (vp-ec vspk) (vp-sender-ok vspk) (vp-sender-ok vspkN)
...| refl rewrite eventProcessorPostSt r stPeer refl
= let nvr = newVoteSameEpochGreaterRound r stPeer (msg⊆ msv) m∈outs (msgSigned msv) newV
in ≡⇒≤ ((proj₂ ∘ proj₂) nvr)
votesOnce₁ : VO.ImplObligation₁
votesOnce₁ {pid' = pid'} r (step-msg {_ , P m} _ psI) {v' = v'} {m' = m'}
pkH v⊂m (here refl) sv ¬msb vspkv v'⊂m' m'∈pool sv' ep≡ r≡
with v⊂m
...| vote∈vm = let m'mwsb = mkMsgWithSig∈ m' v' v'⊂m' pid' m'∈pool sv' refl
vspkv' = ValidSenderForPK⇒ep≡ sv sv' ep≡ vspkv
rv'<rv = oldVoteRound≤lvr r psI pkH sv' m'mwsb vspkv' ep≡
in ⊥-elim (<⇒≢ (s≤s rv'<rv) (sym r≡))
...| vote∈qc vs∈qc v≈rbld (inV qc∈m) rewrite cong ₋vSignature v≈rbld
= ⊥-elim (¬msb (qcVotesSentB4 r psI refl qc∈m refl vs∈qc))
votesOnce₂ : VO.ImplObligation₂
votesOnce₂ {pk = pk} {st} r (step-msg {_ , P m} _ psI) hpk v⊂m m∈outs sig vnew
vpk v'⊂m' m'∈outs sig' v'new vpk' es≡ rnds≡
with m∈outs | m'∈outs
...| here refl | here refl
with v⊂m | v'⊂m'
...| vote∈vm | vote∈vm = refl
...| vote∈vm | vote∈qc vs∈qc' v≈rbld' (inV qc∈m')
rewrite cong ₋vSignature v≈rbld'
= ⊥-elim (v'new (qcVotesSentB4 r psI refl qc∈m' refl vs∈qc'))
...| vote∈qc vs∈qc v≈rbld (inV qc∈m) | _
rewrite cong ₋vSignature v≈rbld
= ⊥-elim (vnew (qcVotesSentB4 r psI refl qc∈m refl vs∈qc))
|
server/src/test/antlr4/org/eclipse/usecase/UseCasePreprocessor.g4
|
Nurkambay/che-che4z-lsp-for-cobol
| 0 |
2218
|
/*
* Copyright (c) 2020 Broadcom.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Broadcom, Inc. - initial API and implementation
*
*/
grammar UseCasePreprocessor;
startRule
: .*? ((copybookStatement | variableStatement | paragraphStatement | sectionStatement | subroutineStatement | constantStatement | errorStatement | multiTokenError | NEWLINE)+ .*?)+ EOF
;
multiTokenError
: MULTITOKENSTART multiToken diagnostic* MULTITOKENSTOP
;
multiToken
: (word | copybookStatement | variableStatement | paragraphStatement | sectionStatement | subroutineStatement | constantStatement | errorStatement | multiTokenError | TEXT)+
;
errorStatement
: START (STRINGLITERAL | word | TEXT | NUMBERLITERAL)? diagnostic* STOP
;
copybookStatement
: (copybookUsage | copybookDefinition) diagnostic* STOP
;
copybookUsage
: COPYBOOKUSAGE cpyIdentifier
;
copybookDefinition
: COPYBOOKDEFINITION cpyIdentifier
;
variableStatement
: (variableUsage | variableDefinition) diagnostic* STOP
;
variableUsage
: VARIABLEUSAGE word
;
variableDefinition
: VARIABLEDEFINITION word
;
constantStatement
: constantUsage diagnostic* STOP
;
constantUsage
: CONSTANTUSAGE word
;
paragraphStatement
: (paragraphUsage | paragraphDefinition) diagnostic* STOP
;
sectionStatement
: (sectionUsage | sectionDefinition) diagnostic* STOP
;
paragraphUsage
: PARAGRPHUSAGE word
;
paragraphDefinition
: PARAGRPHDEFINITION word
;
sectionUsage
: SECTIONUSAGE word
;
sectionDefinition
: SECTIONDEFINITION word
;
subroutineStatement
: subroutineUsage diagnostic* STOP
;
subroutineUsage
: SUBROUTINEUSAGE STRINGLITERAL replacement?
;
diagnostic
: DIAGNOSTICSTART identifier
;
word
: identifier replacement?
;
replacement
: REPLACEMENTSTART identifier
;
identifier
: IDENTIFIER | NUMBERLITERAL
;
cpyIdentifier
: cpyName replacement?
;
cpyName
: IDENTIFIER | COPYBOOKNAME | QUOTED_COPYBOOKNAME | STRINGLITERAL | NUMBERLITERAL
;
START : '{';
STOP : '}';
VARIABLEDEFINITION : START '$*';
VARIABLEUSAGE : START '$';
CONSTANTUSAGE : START '&';
PARAGRPHDEFINITION : START '#*';
PARAGRPHUSAGE : START '#';
SECTIONDEFINITION : START '@*';
SECTIONUSAGE : START '@';
COPYBOOKDEFINITION : START '~*';
COPYBOOKUSAGE : START '~';
SUBROUTINEUSAGE : START '%';
DIAGNOSTICSTART : '|';
REPLACEMENTSTART : '^';
MULTITOKENSTART : START '_';
MULTITOKENSTOP : '_' STOP;
NUMBERLITERAL : [\-+0-9.,]+;
STRINGLITERAL : ['"] .*? ['"\n];
IDENTIFIER : [a-zA-Z0-9:]+ ([-_]+ [a-zA-Z0-9:]+)*;
COPYBOOKNAME : [a-zA-Z0-9#@$]+ ([-_]+ [a-zA-Z0-9#@$]+)*;
QUOTED_COPYBOOKNAME : '\'' COPYBOOKNAME '\'';
// whitespace, line breaks, comments, ...
NEWLINE : '\r'? '\n' -> channel(HIDDEN);
WS : [ \t\f]+ -> channel(HIDDEN);
TEXT : ~('\n' | '\r');
SEPARATOR : ', ' -> channel(HIDDEN);
// case insensitive chars
fragment A:('a'|'A');
fragment B:('b'|'B');
fragment C:('c'|'C');
fragment D:('d'|'D');
fragment E:('e'|'E');
fragment F:('f'|'F');
fragment G:('g'|'G');
fragment H:('h'|'H');
fragment I:('i'|'I');
fragment J:('j'|'J');
fragment K:('k'|'K');
fragment L:('l'|'L');
fragment M:('m'|'M');
fragment N:('n'|'N');
fragment O:('o'|'O');
fragment P:('p'|'P');
fragment Q:('q'|'Q');
fragment R:('r'|'R');
fragment S:('s'|'S');
fragment T:('t'|'T');
fragment U:('u'|'U');
fragment V:('v'|'V');
fragment W:('w'|'W');
fragment X:('x'|'X');
fragment Y:('y'|'Y');
fragment Z:('z'|'Z');
|
programs/oeis/090/A090040.asm
|
karttu/loda
| 0 |
16195
|
<reponame>karttu/loda
; A090040: (3*6^n + 2^n)/4.
; 1,5,28,164,976,5840,35008,209984,1259776,7558400,45349888,272098304,1632587776,9795522560,58773127168,352638746624,2115832446976,12694994616320,76169967566848,457019805138944,2742118830309376
mov $1,6
mov $2,$0
mov $3,3
lpb $2,1
add $4,5
lpb $4,1
mul $1,2
mul $3,6
sub $4,$4
lpe
add $1,$3
sub $2,1
lpe
sub $1,6
div $1,6
add $1,1
|
uuids-version_1.adb
|
annexi-strayline/ASAP-UUIDs
| 0 |
23049
|
<gh_stars>0
------------------------------------------------------------------------------
-- --
-- Common UUID Handling Package --
-- - RFC 4122 Implementation - --
-- --
-- Version 1.0 --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Version 1 (Time-based) UUID Generation Package --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2018, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contibutors: --
-- * <NAME> (ANNEXI-STRAYLINE) --
-- --
-- First release review and refinement --
-- * <NAME> (ANNEXI-STRAYLINE) --
-- --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of ANNEXI-STRAYLINE nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANNEXI-STRAYLINE --
-- 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. --
-- --
------------------------------------------------------------------------------
with System;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Arithmetic;
with Ada.Exceptions; use Ada;
with Hex.Modular_Codec;
package body UUIDs.Version_1 is
type Bitfield_4 is mod 2**4 with Size => 4;
type Bitfield_6 is mod 2**6 with Size => 6;
type Bitfield_12 is mod 2**12 with Size => 12;
type Bitfield_14 is mod 2**14 with Size => 14;
type Bitfield_60 is mod 2**60 with Size => 60;
--
-- State Management Utilities
--
package Node_ID_Hex_Codec is new Hex.Modular_Codec (Bitfield_48, 48);
-----------------
-- Format_Time --
-----------------
-- Takes a 60-bit UUID Version 1 timestamp (RFC 4122, Section 4.1.4), and
-- breaks it out into the UUID standard fields, in a portable way which is
-- machine-endian independent.
procedure Format_Time (From_Timestamp: in Timestamp;
Time_High : out Bitfield_12;
Time_Low : out Bitfield_32;
Time_Mid : out Bitfield_16)
with Inline => True
is
begin
-- To extract the high 12 bits of the total time field
-- (Total_100_Nano_Seconds) mask everything other than the first 12 bits
-- and shift the bitfield 60 by 48 bits
-- to get the 12 most significant bits into Time_High
Time_High := (Bitfield_12((From_Timestamp and
16#fff0_0000_0000_000#) / 2**48));
Time_Mid := (Bitfield_16((From_Timestamp and
16#000f_fff0_0000_000#) / 2**32));
Time_Low := (Bitfield_32((From_Timestamp and
16#0000_000f_ffff_fff#)));
end Format_Time;
-----------------------
-- Extract_Timestamp --
-----------------------
-- Extract the UUID Version 1 timestamp (RFC 4122, Section 4.1.4) from the
-- current State (itself just a Version 1 UUID)
function Extract_Timestamp (State: Version_1_State)
return Timestamp
with Inline => True
is
-- Extract the last time stamp to later compare with the current
-- time generated according to RFC 4122
begin
return UUID_timestamp: Timestamp := 0 do
-- Mask the first 4 bits containing the version number, leaving
-- the high bits of the timestamp, then shift left by 48 bits,
-- putting it at the most significant 12 bits of the timestamp.
UUID_timestamp :=
Timestamp (State.Last_ID.time_hi_and_version and 16#0fff#) * 2**48;
-- Insert the time_mid in the last time stamp by shifting left
-- 32 bits, and dropping it in with an or operation
UUID_timestamp := (Timestamp (State.Last_ID.time_mid) * 2**32)
or UUID_timestamp;
-- The low bits get dropped in as-is
UUID_timestamp := UUID_timestamp + Timestamp (State.Last_ID.time_low);
end return;
end Extract_Timestamp;
--
-- Implementation of Specification
--
---------------------
-- Standard_Source --
---------------------
-- Generates a 60-bit unsigned modular timestamp value as specified in
-- RFC 4122, Section 4.1.4:
-- "The timestamp is a 60-bit value. For UUID version 1, this is represented
-- by Coordinated Universal Time (UTC) as a count of 100-nanosecond
-- intervals since 00:00:00.00, 15 October 1582 (the date of Gregorian
-- reform to the Christian calendar)."
function Standard_Source return Timestamp is
-- Generate a current timestamp from the system clock
use Ada.Calendar.Arithmetic;
Old_1901 : Time;
Days_1901_Now : Day_Count;
Seconds : Duration;
Leap_Seconds : Leap_Seconds_Count;
Total_Days : Timestamp;
Total_Seconds : Timestamp;
Now : Time := Clock;
Days_1582_1901 : constant := 116225;
begin
Old_1901:= Time_Of (Year => 1901,
Month => 1,
Day => 1,
Hour => 0,
Minute => 0,
Second => 0);
-- At the time of writing, the Ada 2012 Reference Manual states this is
-- the earliest possible time which may be represented by a value of type
-- Time. We need to use this as a base point, from which we will add on
-- the days from 1582/01/01:00:00:00.00 until 1900/12/31:00:00:00.00 UTC
-- Get the time difference from now to Jan 1st 1901
Difference (Left => Now,
Right => Old_1901,
Days => Days_1901_Now,
Seconds => Seconds,
Leap_Seconds => Leap_Seconds);
-- Though the Ada RM doesn't specifically state that Clock should be in
-- UTC, it does suggest as much. For most uses, this will likely be true.
-- RFC 4122 does not require the time to be UTC, but rather that it is
-- consistent. Implementations may want to audit UUID generation to ensure
-- that clock is set correctly, if this is a cause for concern.
-- Get the current time as a 60-bit count of 100-nanosecond intervals
-- since 00:00:00.00, 15 October 1582
Total_Days := Timestamp (Days_1901_Now + Days_1582_1901);
-- Add all the seconds
Total_Seconds := (Total_Days * 24 * 60 * 60) +
Timestamp (Seconds) + Timestamp (Leap_Seconds);
-- Multiply to get 100 ns (10_000_000 100 ns intervals/s) and return
return (Total_Seconds * 10_000_000);
end Standard_Source;
---------------
-- New_State --
---------------
function New_State
(Node_ID : Node_ID_Hex;
Initial_Clock_Sequence: Clock_Sequence;
Initial_Timestamp : Timestamp := Standard_Source;
Fail_Active : Boolean := False)
return Version_1_State
is
Node_48_Bits: Bitfield_48;
Time_High : Bitfield_12;
Time_Low : Bitfield_32;
Time_Mid : Bitfield_16;
Clock_Low : Bitfield_8;
Clock_High : Bitfield_6;
begin
-- Convert node_id_hex to 48 bits. This may be needed for handling an
-- exception, and so is placed out here
if not Hex.Valid_Hex_String (Node_Id) then
raise Constraint_Error with "Node ID is not a valid hexadecimal";
end if;
Node_48_Bits := Node_ID_Hex_Codec.Decode (Node_ID);
return State: Version_1_State do
-- Period start set to the current (initial) clock sequence
State.Period_Start := Initial_Clock_Sequence;
-- Masking everything other that the 6 most significant bits of
-- clock_sequence for clock_seq_high and shift richt2e by 8 bits
-- to keep only the 6 bits
Clock_High
:= Bitfield_6
((Initial_Clock_Sequence and 2#1111_1100_0000_00#) / 2**8);
Clock_Low
:= Bitfield_8
((Initial_Clock_Sequence and 2#0000_0011_1111_11#));
State.Last_ID.clock_seq_low := Bitfield_8 (Clock_Low);
-- Insert the variant number into the clock_seq_hi_and_reserved part
State.Last_ID.clock_seq_hi_and_reserved
:= Bitfield_8 (Clock_High) or 2#1000_0000#;
-----
-- The above statements should not possibly result in an exception,
-- whereas the below very well may. If Fail_Active is enabled, we can
-- catch this and at least return a valid state, with a zeroed timestamp
-- Get the current time as a 60-bit count of 100-nanosecond intervals
-- since 00:00:00.00, 15 October 1582, and set it as the "Previous
-- TS" for the state
State.Base_TS := Initial_Timestamp;
-- Set-up the value for "Last_ID"
State.Last_ID.node := Node_48_Bits;
-- Split our 60-bit full timestamp into the requisite individual
-- bitfields for insertion into the actual UUID
Format_Time (From_Timestamp => State.Base_TS,
Time_High => Time_High,
Time_Mid => Time_Mid,
Time_Low => Time_Low);
State.Last_ID.time_low := Time_Low;
State.Last_ID.time_mid := Time_Mid;
State.Last_ID.time_hi_and_version
:= (Bitfield_16 (Time_High)) or 16#1000#;
-- RFC 4122 states that the high bit is set.
exception
when others =>
if Fail_Active then
State.Last_ID.time_low := 0;
State.Last_ID.time_mid := 0;
State.Last_ID.time_hi_and_version := 16#1000#;
else
raise;
end if;
end return;
exception
when others =>
if Fail_Active then
return Version_1_State'
(Last_ID => (node => Node_48_Bits,
others => <>),
others => <>);
else
raise;
end if;
end New_State;
---------------------
-- Extract_Node_ID --
---------------------
function Extract_Node_ID (State: Version_1_State) return Node_ID_Hex is
begin
return Node_ID: Node_ID_Hex do
Node_ID_Hex_Codec.Encode (Value => State.Last_ID.node,
Buffer => Node_ID);
end return;
end Extract_Node_ID;
-----------------------
-- Generic_Generator --
-----------------------
function Generic_Generator (State : in out Version_1_State;
Overrun: in Sequence_Overrun)
return UUID
is
UUID_Last_Node_ID : Bitfield_48;
UUID_Last_Timestamp: Timestamp;
Current_Timestamp : Timestamp;
Time_High : Bitfield_12;
Time_Low : Bitfield_32;
Time_Mid : Bitfield_16;
This_Sequence : Clock_Sequence;
Clock_Low : Bitfield_8;
Clock_High : Bitfield_6;
Overrun_Decision : Sequence_Overrun := Overrun;
begin
-- From the last UUID generator state read the values of:
-- timestamp, clock sequence, and node ID
UUID_Last_Node_ID := State.Last_ID.node;
UUID_Last_Timestamp := Extract_Timestamp (State);
-- Get the current time as a 60-bit count of 100-nanosecond intervals
-- since 00:00:00.00, 15 October 1582
-- Get current node ID
-- Extracting the last clock sequence from State, to be the assumed
-- current sequence, unless we absolutely need to increment it
This_Sequence := Extract_Sequence (State.Last_ID);
-- An interesting problem occurs when generating Version 1 UUIDs on
-- typical server hardware: the generation rate is very high, but the
-- system clock tick is often not very fine-grain.
--
-- We will attempt to be smart about this by synthesizing clock ticks,
-- and backing off said synthesis when we find that we have outrun the
-- system clock, at which point we will fall back to clock sequence
-- incrementation.
--
-- We achieve this by recording the last valid "Base" timestamp in the
-- state, which lets us detect an actual system clock advancement.
--
-- Note that for new or restored states, the "Base timestamp" is zero,
-- and so we are assured that we will see a "new clock tick" this time.
-- If the state was restored from an "advanced" state, then the "last"
-- timestamp will be in the future, which simulates a clock overrun
-- condition, and causes us to increment the clock sequence until the
-- clock catches-up. This is conformant with RFC 4122.
Current_Timestamp := Timestamp_Source;
-- First-off, we take a look at
if Current_Timestamp = State.Base_TS then
-- This means the system clock has not advanced since last time we
-- generated an ID. So we will therefore simply synthesize a clock
-- tick, and skip to the end
Current_Timestamp := UUID_Last_Timestamp + 1;
-- It also marks a new clock sequence period for the state
State.Period_Start := This_Sequence;
else
-- Otherwise, we now that we have a new clock tick. We need to decide
-- if we can use it (and update State.Base_TS), or otherwise it means
-- we have overrun the system clock, and we need to wait for it to
-- catch up by incrementing the clock sequence. This leaves a
-- possibility that we will need to implement an explicit delay and
-- retry. We will put all the logic into a loop, so that we can
-- appropriately handle a clock sequence overrun, should it happen.
-- Note that for newly Restored states, the initial Base_TS is always
-- zero, which works out perfectly by ensuring only the clock sequence
-- increments until the system clock catches up
loop
if Current_Timestamp > UUID_Last_Timestamp then
-- This means we have a new valid (advanced) timestamp, and
-- we can safely use this and commit it as the new Base_TS
State.Base_TS := Current_Timestamp;
-- Also marks a new clock sequence period
State.Period_Start := This_Sequence;
exit;
else
-- Assume last timestamp
Current_Timestamp := UUID_Last_Timestamp;
-- This is the classic use-case for clock sequence
-- incrementation. We are unable to increment the last used
-- timestamp, and so we must make the UUID unique by changing the
-- clock sequence.
if (This_Sequence + 1) = State.Period_Start then
-- We have an clock sequence overrun!
case Overrun_Decision is
when Delay_or_Error =>
delay (System.Tick * 2);
-- This is the only delay, so next iteration, we need
-- to act as if we are configured for Error on overrun
Overrun_Decision := Error;
when Delay_Until =>
delay System.Tick;
when Error =>
raise Generation_Failed with
"Clock sequence overrun";
end case;
else
-- Clock sequence is OK for increment
This_Sequence := This_Sequence + 1;
exit;
end if;
end if;
-- If we get here, it means we are trying again (after a delay)
Current_Timestamp := Timestamp_Source;
end loop;
end if;
-- Finally, we have a valid timestamp and clock sequence with which to
-- generate our new UUID
-- Format a UUID from the current timestamp, clock sequence, and node
Format_Time (From_Timestamp => Current_Timestamp,
Time_High => Time_High,
Time_Mid => Time_Mid,
Time_Low => Time_Low);
return Generated_UUID: UUID do
-- Format time
Generated_UUID.time_low := Time_Low;
Generated_UUID.time_mid := Time_Mid;
Generated_UUID.time_hi_and_version := (Bitfield_16 (Time_High)) or
16#1000#;
-- Masking everything other that the 6 most significant bits of
-- clock_sequence for clock_seq_high and shift left by 8 bits
-- to keep only the 6 bits
Clock_High
:= Bitfield_6
((This_Sequence and 2#11_1111_0000_0000#) / 2**8);
Clock_Low
:= Bitfield_8
(This_Sequence and 2#00_0000_1111_1111#);
Generated_UUID.clock_seq_low
:= Bitfield_8 (Clock_Low);
-- Insert the variant number into the clock_seq_hi_and_reserved part
Generated_UUID.clock_seq_hi_and_reserved
:= Bitfield_8 (Clock_High) or 2#1000_0000#;
-- Copy in the node ID
Generated_UUID.node := UUID_Last_Node_ID;
-- Save the id to the State
State.Last_ID := Generated_UUID;
end return;
exception
when e: others =>
raise Generation_Failed with
"Generation raised an exception: " &
Exceptions.Exception_Information (e);
end Generic_Generator;
---------------------
-- Local_Generator --
---------------------
package body Local_Generator is
State: Version_1_State;
function Generate_Actual is new Generic_Generator
(Timestamp_Source);
--------------
-- Generate --
--------------
function Generate (Overrun: Sequence_Overrun := Default_Overrun)
return UUID is (Generate_Actual (State => State,
Overrun => Overrun));
------------------
-- Export_State --
------------------
function Export_State (Advance: Duration := 0.0) return Version_1_State
is
UUID_Last_timestamp : Timestamp;
Time_High : Bitfield_12;
Time_Low : Bitfield_32;
Time_Mid : Bitfield_16;
begin
-- Check for a default Advance of 0.0
if Advance = 0.0 then
return State;
end if;
UUID_Last_Timestamp := Extract_Timestamp (State);
-- Add the advance nanoseconds (10,000,000 100ns/s)
UUID_Last_Timestamp
:= UUID_Last_Timestamp + Timestamp (Advance * 10_000_000);
return Advanced_State: Version_1_State := State do
-- We copy out the current State, only updating the advance
-- timestamp, and clearing the Base_TS;
Format_Time (From_Timestamp => UUID_Last_timestamp,
Time_High => Time_High,
Time_Mid => Time_Mid ,
Time_Low => Time_Low);
Advanced_State.Last_ID.time_low := Time_Low;
Advanced_State.Last_ID.time_mid := Time_Mid;
-- Insert the version number of 1 into the time_hi_and_version part
Advanced_State.Last_ID.time_hi_and_version
:= Bitfield_16 (Time_High) or 16#1000#;
Advanced_State.Base_TS := 0;
end return;
end Export_State;
------------------
-- Import_State --
------------------
procedure Import_State (New_State: Version_1_State) is
begin
State := New_State;
end Import_State;
end Local_Generator;
----------------------
-- Global_Generator --
----------------------
package body Global_Generator is
package Generator is new Local_Generator
(Default_Overrun => Default_Overrun,
Timestamp_Source => Timestamp_Source);
-- Protected body from which to call The Local Generator
-- Global Lock
protected Protected_Generator is
procedure Generate (ID: out UUID; Overrun: in Sequence_Overrun);
function Export_State (Advance: duration) return Version_1_State;
procedure Import_State (New_State: Version_1_State);
end Protected_Generator;
protected body Protected_Generator is
procedure Generate (ID: out UUID; Overrun: in Sequence_Overrun) is
begin
ID := Generator.Generate (Overrun);
end Generate;
function Export_State (Advance: duration) return Version_1_State is
begin
return Generator.Export_State (Advance);
end Export_State;
procedure Import_State (New_State: Version_1_State) is
begin
Generator.Import_State (New_State);
end Import_State;
end Protected_Generator;
--------------
-- Generate --
--------------
function Generate (Overrun: Sequence_Overrun := Default_Overrun)
return UUID
is
begin
return ID: UUID do
Protected_Generator.Generate (ID => ID, Overrun => Overrun);
end return;
end Generate;
------------------
-- Export_State --
------------------
function Export_State (Advance: Duration := 0.0) return Version_1_State is
begin
return ID: Version_1_State do
ID := Protected_Generator.Export_State(Advance);
end return;
end Export_State;
------------------
-- Import_State --
------------------
procedure Import_State (New_State: Version_1_State) is
begin
Protected_Generator.Import_State(New_State);
end Import_State;
end Global_Generator;
end UUIDs.Version_1;
|
test/test.adb
|
mgrojo/AdaID
| 0 |
3993
|
<reponame>mgrojo/AdaID
-- File: test.adb
-- Description: Test suite for AdaID
-- Author: <NAME>
-- License: http://www.gnu.org/licenses/gpl.txt
with AUnit.Test_Suites; use AUnit.Test_Suites;
with AUnit.Run;
with AUnit.Reporter.Text;
with AdaID_Tests;
procedure Test is
function Suite return Access_Test_Suite is
Result : constant Access_Test_Suite := new Test_Suite;
begin
Add_Test(Result, new AdaID_Tests.UUID_Test);
return Result;
end Suite;
procedure Run is new AUnit.Run.Test_Runner(Suite);
Reporter : AUnit.Reporter.Text.Text_Reporter;
begin
Run(Reporter);
end;
|
Numbers/Modulo/ZModule.agda
|
Smaug123/agdaproofs
| 4 |
56
|
<filename>Numbers/Modulo/ZModule.agda
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Groups.Definition
open import Groups.Abelian.Definition
open import Groups.FiniteGroups.Definition
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Numbers.Naturals.Order.Lemmas
open import Setoids.Setoids
open import Sets.FinSet.Definition
open import Sets.FinSet.Lemmas
open import Functions
open import Semirings.Definition
open import Numbers.Modulo.Definition
open import Numbers.Modulo.Addition
open import Orders.Total.Definition
open import Numbers.Modulo.ModuloFunction
open import Numbers.Integers.Definition
open import Numbers.Modulo.Group
open import Modules.Definition
open import Numbers.Integers.RingStructure.Ring
module Numbers.Modulo.ZModule {n : ℕ} (pr : 0 <N n) where
timesNat : ℕ → ℤn n pr → ℤn n pr
timesNat 0 b = record { x = 0 ; xLess = pr }
timesNat (succ x) b = _+n_ pr b (timesNat x b)
times : ℤ → ℤn n pr → ℤn n pr
times (nonneg x) b = timesNat x b
times (negSucc x) b = Group.inverse (ℤnGroup n pr) (timesNat (succ x) b)
dotDistributesLeft : (r : ℤ) → (x y : ℤn n pr) → times r ((_ +n x) y) ≡ (_ +n times r x) (times r y)
dotDistributesLeft (nonneg zero) x y = equalityCommutative (Group.identRight (ℤnGroup n pr))
dotDistributesLeft (nonneg (succ r)) x y rewrite dotDistributesLeft (nonneg r) x y = equalityZn (transitivity (equalityCommutative (modExtracts pr _ _)) (transitivity (applyEquality (mod n pr) (transitivity (transitivity (equalityCommutative (Semiring.+Associative ℕSemiring (ℤn.x x) _ _)) (applyEquality (ℤn.x x +N_) (transitivity (Semiring.commutative ℕSemiring (ℤn.x y) _) (transitivity (equalityCommutative (Semiring.+Associative ℕSemiring _ (ℤn.x (timesNat r y)) (ℤn.x y))) (applyEquality (ℤn.x (timesNat r x) +N_) (Semiring.commutative ℕSemiring (ℤn.x (timesNat r y)) (ℤn.x y))))))) (Semiring.+Associative ℕSemiring (ℤn.x x) _ _))) (modExtracts pr _ _)))
dotDistributesLeft (negSucc r) x y = {!!}
ZnZModule : Module ℤRing (ℤnAbGroup n pr) times
Module.dotWellDefined (ZnZModule) refl refl = refl
Module.dotDistributesLeft (ZnZModule) {r} {x} {y} = dotDistributesLeft r x y
Module.dotDistributesRight (ZnZModule) = {!!}
Module.dotAssociative (ZnZModule) = {!!}
Module.dotIdentity (ZnZModule) {record { x = x ; xLess = xLess }} = {!!}
|
randomly-solved-programs/compare two statements.asm
|
informramiz/Assembly-Language-Programs
| 0 |
163603
|
<filename>randomly-solved-programs/compare two statements.asm
.MODEL SMALL
.STACK 100H
.CODE
MAIN PROC
MOV AH,2
CMP AL,BL
JNBE ELSE_
MOV DL,AL
JMP DISPLAY
ELSE_:
MOV DL,BL
JMP DISPLAY
DISPLAY:
INT 21H
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN
|
alloy4fun_models/trashltl/models/5/av7mfzGDt7X8iyZna.als
|
Kaixi26/org.alloytools.alloy
| 0 |
5172
|
open main
pred idav7mfzGDt7X8iyZna_prop6 {
all f:File | f in Trash and always f in Trash
}
pred __repair { idav7mfzGDt7X8iyZna_prop6 }
check __repair { idav7mfzGDt7X8iyZna_prop6 <=> prop6o }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.