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 |
|---|---|---|---|---|
3-mid/opengl/private/gl/source/gl-safe.ads | charlie5/lace | 20 | 20163 | <reponame>charlie5/lace
with
Interfaces.C.Pointers;
package GL.safe
--
-- Provides types, constants and functions specific to the openGL 'Safety Critical' profile.
--
is
---------
-- Types
--
-- GLubyte_Pointer
--
package GLubyte_Pointers is new C.Pointers (Index => C.size_t,
Element => GLubyte,
Element_Array => GLubyte_array,
Default_Terminator => 0);
subtype GLubyte_Pointer is GLubyte_Pointers.Pointer;
-- GLint_Pointer
--
package GLint_Pointers is new C.Pointers (Index => C.size_t,
Element => GLint,
Element_Array => GLint_array,
Default_Terminator => 0);
subtype GLint_Pointer is GLint_Pointers.Pointer;
-- GLfloat_Pointer
--
package GLfloat_Pointers is new C.Pointers (Index => C.size_t,
Element => GLfloat,
Element_Array => GLfloat_array,
Default_Terminator => 0.0);
subtype GLfloat_Pointer is GLfloat_Pointers.Pointer;
-- GLvoid_Pointer
--
package GLvoid_Pointers is new C.Pointers (Index => C.size_t,
Element => GLvoid,
Element_Array => GLvoid_array,
Default_Terminator => 0);
subtype GLvoid_Pointer is GLvoid_Pointers.Pointer;
-- GLvoid_Pointer_Pointer
--
type GLvoid_Pointer_array is array (C.size_t range <>) of aliased GLvoid_Pointer;
package GLvoid_Pointer_Pointers is new C.Pointers (Index => C.size_t,
Element => GLvoid_Pointer,
Element_Array => GLvoid_Pointer_array,
Default_Terminator => null);
subtype GLvoid_Pointer_Pointer is GLvoid_Pointer_Pointers.Pointer;
-------------
-- Constants
--
GL_ADD : constant := 16#0104#;
GL_ALPHA_TEST : constant := 16#0BC0#;
GL_ALPHA_TEST_FUNC : constant := 16#0BC1#;
GL_ALPHA_TEST_REF : constant := 16#0BC2#;
GL_AMBIENT : constant := 16#1200#;
GL_AMBIENT_AND_DIFFUSE : constant := 16#1602#;
GL_BLEND_DST : constant := 16#0BE0#;
GL_BLEND_SRC : constant := 16#0BE1#;
GL_CLIENT_ACTIVE_TEXTURE : constant := 16#84E1#;
GL_COLOR : constant := 16#1800#;
GL_COLOR_ARRAY : constant := 16#8076#;
GL_COLOR_ARRAY_POINTER : constant := 16#8090#;
GL_COLOR_ARRAY_SIZE : constant := 16#8081#;
GL_COLOR_ARRAY_STRIDE : constant := 16#8083#;
GL_COLOR_ARRAY_TYPE : constant := 16#8082#;
GL_COLOR_INDEX : constant := 16#1900#;
GL_COLOR_INDEX8_EXT : constant := 16#80E5#;
GL_COLOR_MATERIAL : constant := 16#0B57#;
GL_COLOR_TABLE_ALPHA_SIZE : constant := 16#80DD#;
GL_COLOR_TABLE_BLUE_SIZE : constant := 16#80DC#;
GL_COLOR_TABLE_FORMAT : constant := 16#80D8#;
GL_COLOR_TABLE_GREEN_SIZE : constant := 16#80DB#;
GL_COLOR_TABLE_INTENSITY_SIZE : constant := 16#80DF#;
GL_COLOR_TABLE_LUMINANCE_SIZE : constant := 16#80DE#;
GL_COLOR_TABLE_RED_Size : constant := 16#80DA#;
GL_COLOR_TABLE_WIDTH : constant := 16#80D9#;
GL_COMPILE : constant := 16#1300#;
GL_CURRENT_COLOR : constant := 16#0B00#;
GL_CURRENT_NORMAL : constant := 16#0B02#;
GL_CURRENT_RASTER_COLOR : constant := 16#0B04#;
GL_CURRENT_RASTER_TEXTURE_COORDS : constant := 16#0B06#;
GL_CURRENT_TEXTURE_COORDS : constant := 16#0B03#;
GL_DECAL : constant := 16#2101#;
GL_DIFFUSE : constant := 16#1201#;
GL_EMISSION : constant := 16#1600#;
GL_EXT_paletted_texture : constant := 1;
GL_FLAT : constant := 16#1D00#;
GL_LIGHT0 : constant := 16#4000#;
GL_LIGHT1 : constant := 16#4001#;
GL_LIGHTING : constant := 16#0B50#;
GL_LIGHT_MODEL_AMBIENT : constant := 16#0B53#;
GL_LINE_SMOOTH : constant := 16#0B20#;
GL_LINE_SMOOTH_HINT : constant := 16#0C52#;
GL_LINE_STIPPLE : constant := 16#0B24#;
GL_LINE_STIPPLE_PATTERN : constant := 16#0B25#;
GL_LINE_STIPPLE_REPEAT : constant := 16#0B26#;
GL_LIST_BASE : constant := 16#0B32#;
GL_MATRIX_MODE : constant := 16#0BA0#;
GL_MAX_ELEMENTS_INDICES : constant := 16#80E9#;
GL_MAX_ELEMENTS_VERTICES : constant := 16#80E8#;
GL_MAX_LIGHTS : constant := 16#0D31#;
GL_MAX_LIST_NESTING : constant := 16#0B31#;
GL_MAX_MODELVIEW_STACK_DEPTH : constant := 16#0D36#;
GL_MAX_PROJECTION_STACK_DEPTH : constant := 16#0D38#;
GL_MAX_TEXTURE_UNITS : constant := 16#84E2#;
GL_MODELVIEW : constant := 16#1700#;
GL_MODELVIEW_MATRIX : constant := 16#0BA6#;
GL_MODELVIEW_STACK_DEPTH : constant := 16#0BA3#;
GL_MODULATE : constant := 16#2100#;
GL_NORMALIZE : constant := 16#0BA1#;
GL_NORMAL_ARRAY : constant := 16#8075#;
GL_NORMAL_ARRAY_POINTER : constant := 16#808F#;
GL_NORMAL_ARRAY_STRIDE : constant := 16#807F#;
GL_NORMAL_ARRAY_TYPE : constant := 16#807E#;
GL_OES_single_precision : constant := 1;
GL_OSC_VERSION_1_0 : constant := 1;
GL_PERSPECTIVE_CORRECTION_HINT : constant := 16#0C50#;
GL_POINT_SIZE : constant := 16#0B11#;
GL_POINT_SMOOTH : constant := 16#0B10#;
GL_POINT_SMOOTH_HINT : constant := 16#0C51#;
GL_POLYGON_SMOOTH_HINT : constant := 16#0C53#;
GL_POLYGON_STIPPLE : constant := 16#0B42#;
GL_POSITION : constant := 16#1203#;
GL_PROJECTION : constant := 16#1701#;
GL_PROJECTION_MATRIX : constant := 16#0BA7#;
GL_PROJECTION_STACK_DEPTH : constant := 16#0BA4#;
GL_RESCALE_NORMAL : constant := 16#803A#;
GL_SHADE_MODEL : constant := 16#0B54#;
GL_SHININESS : constant := 16#1601#;
GL_SMOOTH : constant := 16#1D01#;
GL_SMOOTH_LINE_WIDTH_GRANULARITY : constant := 16#0B23#;
GL_SMOOTH_LINE_WIDTH_RANGE : constant := 16#0B22#;
GL_SMOOTH_POINT_SIZE_GRANULARITY : constant := 16#0B13#;
GL_SMOOTH_POINT_SIZE_RANGE : constant := 16#0B12#;
GL_SPECULAR : constant := 16#1202#;
GL_STACK_OVERFLOW : constant := 16#0503#;
GL_STACK_UNDERFLOW : constant := 16#0504#;
GL_TEXTURE_COORD_ARRAY : constant := 16#8078#;
GL_TEXTURE_COORD_ARRAY_POINTER : constant := 16#8092#;
GL_TEXTURE_COORD_ARRAY_SIZE : constant := 16#8088#;
GL_TEXTURE_COORD_ARRAY_STRIDE : constant := 16#808A#;
GL_TEXTURE_COORD_ARRAY_TYPE : constant := 16#8089#;
GL_TEXTURE_ENV : constant := 16#2300#;
GL_TEXTURE_ENV_COLOR : constant := 16#2201#;
GL_TEXTURE_ENV_MODE : constant := 16#2200#;
GL_VERTEX_ARRAY : constant := 16#8074#;
GL_VERTEX_ARRAY_POINTER : constant := 16#808E#;
GL_VERTEX_ARRAY_SIZE : constant := 16#807A#;
GL_VERTEX_ARRAY_STRIDE : constant := 16#807C#;
GL_VERTEX_ARRAY_TYPE : constant := 16#807B#;
--------------
-- Functions
--
procedure glAlphaFunc (Func : in GLenum;
Ref : in GLclampf);
procedure glBegin (Mode : in GLenum);
procedure glBitmap (Width : in GLsizei;
Height : in GLsizei;
xOrig : in GLfloat;
yOrig : in GLfloat;
xMove : in GLfloat;
yMove : in GLfloat;
Bitmap : in GLubyte_Pointer);
procedure glCallLists (N : in GLsizei;
the_Type : in GLenum;
Lists : in GLvoid_Pointer);
procedure glClientActiveTexture (Texture : in GLenum);
procedure glColor4f (Red : in GLfloat;
Green : in GLfloat;
Blue : in GLfloat;
Alpha : in GLfloat);
procedure glColor4fv (V : in GLfloat_Pointer);
procedure glColor4ub (Red : in GLubyte;
Green : in GLubyte;
Blue : in GLubyte;
Alpha : in GLubyte);
procedure glColorPointer (Size : in GLint;
the_Type : in GLenum;
Stride : in GLsizei;
Ptr : in GLvoid_Pointer);
procedure glCopyPixels (X : in GLint;
Y : in GLint;
Width : in GLsizei;
Height : in GLsizei;
the_Type : in GLenum);
procedure glDisableClientState (Cap : in GLenum);
procedure glDrawPixels (Width : in GLsizei;
Height : in GLsizei;
Format : in GLenum;
the_Type : in GLenum;
Pixels : in GLvoid_Pointer);
procedure glEnableClientState (Cap : in GLenum);
procedure glEnd;
procedure glEndList;
procedure glFrustumf (Left : in GLfloat;
Right : in GLfloat;
Bottom : in GLfloat;
Top : in GLfloat;
near_Val : in GLfloat;
far_Val : in GLfloat);
function glGenLists (the_Range : in GLsizei) return GLuint;
procedure glGetLightfv (Light : in GLenum;
pName : in GLenum;
Params : in GLfloat_Pointer);
procedure glGetMaterialfv (Face : in GLenum;
pName : in GLenum;
Params : in GLfloat_Pointer);
procedure glGetPointerv (pName : in GLenum;
Params : in GLvoid_Pointer_Pointer);
procedure glGetPolygonStipple (Mask : in GLubyte_Pointer);
procedure glGetTexEnvfv (Target : in GLenum;
pName : in GLenum;
Params : in GLfloat_Pointer);
procedure glGetTexEnviv (Target : in GLenum;
pName : in GLenum;
Params : in GLint_Pointer);
procedure glLightModelfv (pName : in GLenum;
Params : in GLfloat_Pointer);
procedure glLightfv (Light : in GLenum;
pName : in GLenum;
Params : in GLfloat_Pointer);
procedure glLineStipple (Factor : in GLint;
Pattern : in GLushort);
procedure glListBase (Base : in GLuint);
procedure glLoadIdentity;
procedure glLoadMatrixf (M : in GLfloat_Pointer);
procedure glMaterialf (Face : in GLenum;
pName : in GLenum;
Param : in GLfloat);
procedure glMaterialfv (Face : in GLenum;
pName : in GLenum;
Params : in GLfloat_Pointer);
procedure glMatrixMode (Mode : in GLenum);
procedure glMultMatrixf (M : in GLfloat_Pointer);
procedure glMultiTexCoord2f (Target : in GLenum;
S : in GLfloat;
T : in GLfloat);
procedure glMultiTexCoord2fv (Target : in GLenum;
V : in GLfloat_Pointer);
procedure glNewList (List : in GLuint;
Mode : in GLenum);
procedure glNormal3f (nX : in GLfloat;
nY : in GLfloat;
nZ : in GLfloat);
procedure glNormal3fv (V : in GLfloat_Pointer);
procedure glNormalPointer (the_Type : in GLenum;
Stride : in GLsizei;
Ptr : in GLvoid_Pointer);
procedure glOrthof (Left : in GLfloat;
Right : in GLfloat;
Bottom : in GLfloat;
Top : in GLfloat;
Near : in GLfloat;
Far : in GLfloat);
procedure glPointSize (Size : in GLfloat);
procedure glPolygonStipple (Mask : in GLubyte_Pointer);
procedure glPopMatrix;
procedure glPushMatrix;
procedure glRasterPos3f (X : in GLfloat;
Y : in GLfloat;
Z : in GLfloat);
procedure glRotatef (Angle : in GLfloat;
X : in GLfloat;
Y : in GLfloat;
Z : in GLfloat);
procedure glScalef (X : in GLfloat;
Y : in GLfloat;
Z : in GLfloat);
procedure glShadeModel (Mode : in GLenum);
procedure glTexCoordPointer (Size : in GLint;
the_Type : in GLenum;
Stride : in GLsizei;
Ptr : in GLvoid_Pointer);
procedure glTexEnvfv (Target : in GLenum;
pName : in GLenum;
Params : in GLfloat_Pointer);
procedure glTexEnvi (Target : in GLenum;
pName : in GLenum;
Param : in GLint);
procedure glTranslatef (X : in GLfloat;
Y : in GLfloat;
Z : in GLfloat);
procedure glVertex2f (X : in GLfloat;
Y : in GLfloat);
procedure glVertex2fv (V : in GLfloat_Pointer);
procedure glVertex3f (X : in GLfloat;
Y : in GLfloat;
Z : in GLfloat);
procedure glVertex3fv (V : in GLfloat_Pointer);
procedure glVertexPointer (Size : in GLint;
the_Type : in GLenum;
Stride : in GLsizei;
Ptr : in GLvoid_Pointer);
private
pragma Import (StdCall, glAlphaFunc, "glAlphaFunc");
pragma Import (StdCall, glBegin, "glBegin");
pragma Import (StdCall, glBitmap, "glBitmap");
pragma Import (StdCall, glCallLists, "glCallLists");
pragma Import (StdCall, glClientActiveTexture, "glClientActiveTexture");
pragma Import (StdCall, glColor4f, "glColor4f");
pragma Import (StdCall, glColor4fv, "glColor4fv");
pragma Import (StdCall, glColor4ub, "glColor4ub");
pragma Import (StdCall, glColorPointer, "glColorPointer");
pragma Import (StdCall, glCopyPixels, "glCopyPixels");
pragma Import (StdCall, glDisableClientState, "glDisableClientState");
pragma Import (StdCall, glDrawPixels, "glDrawPixels");
pragma Import (StdCall, glEnableClientState, "glEnableClientState");
pragma Import (StdCall, glEnd, "glEnd");
pragma Import (StdCall, glEndList, "glEndList");
pragma Import (StdCall, glFrustumf, "glFrustumf");
pragma Import (StdCall, glGenLists, "glGenLists");
pragma Import (StdCall, glGetLightfv, "glGetLightfv");
pragma Import (StdCall, glGetMaterialfv, "glGetMaterialfv");
pragma Import (StdCall, glGetPointerv, "glGetPointerv");
pragma Import (StdCall, glGetPolygonStipple, "glGetPolygonStipple");
pragma Import (StdCall, glGetTexEnvfv, "glGetTexEnvfv");
pragma Import (StdCall, glGetTexEnviv, "glGetTexEnviv");
pragma Import (StdCall, glLightModelfv, "glLightModelfv");
pragma Import (StdCall, glLightfv, "glLightfv");
pragma Import (StdCall, glLineStipple, "glLineStipple");
pragma Import (StdCall, glListBase, "glListBase");
pragma Import (StdCall, glLoadIdentity, "glLoadIdentity");
pragma Import (StdCall, glLoadMatrixf, "glLoadMatrixf");
pragma Import (StdCall, glMaterialf, "glMaterialf");
pragma Import (StdCall, glMaterialfv, "glMaterialfv");
pragma Import (StdCall, glMatrixMode, "glMatrixMode");
pragma Import (StdCall, glMultMatrixf, "glMultMatrixf");
pragma Import (StdCall, glMultiTexCoord2f, "glMultiTexCoord2f");
pragma Import (StdCall, glMultiTexCoord2fv, "glMultiTexCoord2fv");
pragma Import (StdCall, glNewList, "glNewList");
pragma Import (StdCall, glNormal3f, "glNormal3f");
pragma Import (StdCall, glNormal3fv, "glNormal3fv");
pragma Import (StdCall, glNormalPointer, "glNormalPointer");
pragma Import (StdCall, glOrthof, "glOrthof");
pragma Import (StdCall, glPointSize, "glPointSize");
pragma Import (StdCall, glPolygonStipple, "glPolygonStipple");
pragma Import (StdCall, glPopMatrix, "glPopMatrix");
pragma Import (StdCall, glPushMatrix, "glPushMatrix");
pragma Import (StdCall, glRasterPos3f, "glRasterPos3f");
pragma Import (StdCall, glRotatef, "glRotatef");
pragma Import (StdCall, glScalef, "glScalef");
pragma Import (StdCall, glShadeModel, "glShadeModel");
pragma Import (StdCall, glTexCoordPointer, "glTexCoordPointer");
pragma Import (StdCall, glTexEnvfv, "glTexEnvfv");
pragma Import (StdCall, glTexEnvi, "glTexEnvi");
pragma Import (StdCall, glTranslatef, "glTranslatef");
pragma Import (StdCall, glVertex2f, "glVertex2f");
pragma Import (StdCall, glVertex2fv, "glVertex2fv");
pragma Import (StdCall, glVertex3f, "glVertex3f");
pragma Import (StdCall, glVertex3fv, "glVertex3fv");
pragma Import (StdCall, glVertexPointer, "glVertexPointer");
end GL.safe;
-- TODO: Bind these missing functions, if needed.
--
-- GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *table);
-- GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
-- GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *table);
-- GLAPI void APIENTRY glGetColorTableParameterivEXT
-- (GLenum target, GLenum pname, GLint *params);
|
Transynther/x86/_processed/P/_zr_/i7-7700_9_0x48.log_21829_1351.asm | ljhsiun2/medusa | 9 | 95731 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r13
push %r15
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x1578b, %rsi
lea addresses_normal_ht+0x1db0b, %rdi
nop
nop
nop
nop
mfence
mov $26, %rcx
rep movsl
nop
nop
nop
inc %r11
lea addresses_normal_ht+0x1b94b, %rsi
lea addresses_normal_ht+0x1d5cb, %rdi
nop
nop
nop
nop
nop
and $36107, %r11
mov $32, %rcx
rep movsw
nop
inc %rsi
lea addresses_WT_ht+0x770b, %rsi
nop
nop
nop
nop
inc %rax
mov (%rsi), %r15
dec %rax
lea addresses_A_ht+0x1132b, %r15
nop
nop
nop
nop
nop
sub $47637, %r13
movb (%r15), %al
nop
nop
nop
add $28478, %rsi
lea addresses_A_ht+0x19b0b, %rcx
nop
nop
nop
sub $54452, %r15
movb $0x61, (%rcx)
xor %rax, %rax
lea addresses_UC_ht+0x1278b, %r13
nop
nop
nop
inc %rdi
vmovups (%r13), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $1, %xmm6, %rsi
nop
nop
inc %r13
lea addresses_normal_ht+0x570b, %rsi
lea addresses_D_ht+0x17d3b, %rdi
clflush (%rsi)
clflush (%rdi)
xor %r10, %r10
mov $36, %rcx
rep movsl
nop
nop
nop
nop
nop
dec %rcx
lea addresses_UC_ht+0x1530b, %rsi
lea addresses_D_ht+0xa72b, %rdi
inc %r15
mov $8, %rcx
rep movsq
add $56920, %rcx
lea addresses_UC_ht+0x1e6de, %rcx
nop
nop
nop
nop
and $16638, %r15
mov (%rcx), %r13w
nop
add $58448, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r15
pop %r13
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r14
push %r9
push %rcx
push %rdi
// Faulty Load
mov $0xb0b, %rdi
nop
nop
sub $15044, %rcx
mov (%rdi), %r9
lea oracles, %r11
and $0xff, %r9
shlq $12, %r9
mov (%r11,%r9,1), %r9
pop %rdi
pop %rcx
pop %r9
pop %r14
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 8, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': True, 'congruent': 5, 'size': 1, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 10, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 7, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': True}}
{'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
*/
|
methods/mintGametoken.asm | caffeinum/pravda-contracts | 3 | 103408 | push 10000
push "mintGametoken"
push xF5AB1676D87235E4B5B1830C00A5BC783B9A58D2DC9AFE23D5FA387F1C80736E
push 2
pcall
|
Working Disassembly/General/Sprites/Sandworm/Map - Sandworm.asm | TeamASM-Blur/Sonic-3-Blue-Balls-Edition | 5 | 9610 | ; Sandworm mappings
dc.w word_186D22-Map_Sandworm
dc.w word_186D2A-Map_Sandworm
dc.w word_186D32-Map_Sandworm
dc.w word_186D3A-Map_Sandworm
dc.w word_186D42-Map_Sandworm
dc.w word_186D4A-Map_Sandworm
dc.w word_186D52-Map_Sandworm
dc.w word_186D5A-Map_Sandworm
dc.w word_186D62-Map_Sandworm
word_186D22: dc.w 1 ; DATA XREF: ROM:00186D10o
dc.b $F4, 6, 0, 0, $FF, $F8
word_186D2A: dc.w 1 ; DATA XREF: ROM:00186D10o
dc.b $F8, 5, 0, 6, $FF, $F8
word_186D32: dc.w 1 ; DATA XREF: ROM:00186D10o
dc.b $F4, 6, 0, $A, $FF, $F8
word_186D3A: dc.w 1 ; DATA XREF: ROM:00186D10o
dc.b $FC, 4, 0, $10, $FF, $F8
word_186D42: dc.w 1 ; DATA XREF: ROM:00186D10o
dc.b $FC, 4, 8, $10, $FF, $F8
word_186D4A: dc.w 1 ; DATA XREF: ROM:00186D10o
dc.b $F0, 3, 0, $12, $FF, $FC
word_186D52: dc.w 1 ; DATA XREF: ROM:00186D10o
dc.b $F0, 3, 8, $12, $FF, $FC
word_186D5A: dc.w 1 ; DATA XREF: ROM:00186D10o
dc.b $F0, 3, 0, $16, $FF, $FC
word_186D62: dc.w 1 ; DATA XREF: ROM:00186D10o
dc.b $F0, 3, 0, $1A, $FF, $FC
|
Library/Spreadsheet/UI/uiChooseFunction.asm | steakknife/pcgeos | 504 | 88410 | <reponame>steakknife/pcgeos
COMMENT @-----------------------------------------------------------------------
Copyright (c) Geoworks 1991 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: uiChooseFunction.asm
AUTHOR: Cheng, 7/92
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Cheng 7/92 Initial revision
DESCRIPTION:
$Id: uiChooseFunction.asm,v 1.1 97/04/07 11:12:05 newdeal Exp $
-------------------------------------------------------------------------------@
;---------------------------------------------------
SpreadsheetClassStructures segment resource
SSChooseFuncControlClass ;declare the class record
SpreadsheetClassStructures ends
;---------------------------------------------------
ChooseFuncControlCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SSCFGetInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get GenControl info for the SSChooseFuncControl
CALLED BY: MSG_GEN_CONTROL_GET_INFO
PASS: *ds:si - instance data
ds:di - *ds:si
es - seg addr of SSChooseFuncControlClass
ax - the message
cx:dx - GenControlBuildInfo structure to fill in
RETURN: cx:dx - filled in
DESTROYED: bx, si, di, ds, es (method handler)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cheng 7/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SSCFGetInfo method dynamic SSChooseFuncControlClass, \
MSG_GEN_CONTROL_GET_INFO
mov si, offset SSCF_dupInfo
mov es, cx
mov di, dx ;es:di = dest
segmov ds, cs
mov cx, size GenControlBuildInfo
rep movsb
ret
SSCFGetInfo endm
SSCF_dupInfo GenControlBuildInfo <
mask GCBF_SUSPEND_ON_APPLY, ; GCBI_flags
SSCF_IniFileKey, ; GCBI_initFileKey
SSCF_gcnList, ; GCBI_gcnList
length SSCF_gcnList, ; GCBI_gcnCount
SSCF_notifyTypeList, ; GCBI_notificationList
length SSCF_notifyTypeList, ; GCBI_notificationCount
SSCFName, ; GCBI_controllerName
handle SSChooseFuncControlUI, ; GCBI_dupBlock
SSCF_childList, ; GCBI_childList
length SSCF_childList, ; GCBI_childCount
SSCF_featuresList, ; GCBI_featuresList
length SSCF_featuresList, ; GCBI_featuresCount
SSCF_DEFAULT_FEATURES, ; GCBI_features
0, ; GCBI_toolBlock
0, ; GCBI_toolList
0, ; GCBI_toolCount
0, ; GCBI_toolFeaturesList
0, ; GCBI_toolFeaturesCount
0, ; GCBI_toolFeatures
SSCF_helpContext> ; GCBI_helpContext
if FULL_EXECUTE_IN_PLACE
SpreadsheetControlInfoXIP segment resource
endif
SSCF_helpContext char "dbInsFunc", 0
SSCF_IniFileKey char "ssChooseFunc", 0
SSCF_gcnList GCNListType \
<MANUFACTURER_ID_GEOWORKS, GAGCNLT_APP_TARGET_NOTIFY_SPREADSHEET_NAME_CHANGE>
SSCF_notifyTypeList NotificationType \
<MANUFACTURER_ID_GEOWORKS, GWNT_SPREADSHEET_NAME_CHANGE>
;---
SSCF_childList GenControlChildInfo \
<offset ChooseFuncTop, mask SSCFF_CHOOSE or \
mask SSCFF_FUNCTION_TYPE, 0>,
<offset ChooseFuncBottom, mask SSCFF_DESCRIPTION or \
mask SSCFF_ARGUMENT_LIST, 0>,
<offset ChooseArgOption, mask SSCFF_PASTE_ARGUMENTS, mask GCCF_IS_DIRECTLY_A_FEATURE>
; Careful, this table is in the *opposite* order as the record which
; it corresponds to.
SSCF_featuresList GenControlFeaturesInfo \
<offset ChooseFuncList, ChooseFuncName, 0>,
<offset ChooseTypeList, ChooseTypeName, 0>,
<offset ChooseArgOption, ArgOptionName, 0>,
<offset ChooseArguments, ChooseArgName, 0>,
<offset ChooseDescription, ChooseDescName, 0>
if FULL_EXECUTE_IN_PLACE
SpreadsheetControlInfoXIP ends
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SSCFUpdateUI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Update UI for SSChooseFuncControl
CALLED BY: MSG_GEN_CONTROL_UPDATE_UI
PASS: *ds:si - instance data
ds:di - *ds:si
es - seg addr of SSChooseFuncControlClass
ax - the message
RETURN: none
DESTROYED: ax, bx, cx, dx, bp, si (method handler)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cheng 7/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SSCFUpdateUI method dynamic SSChooseFuncControlClass, \
MSG_GEN_CONTROL_UPDATE_UI
mov ax, ds:[di].SSCFCI_types ; ax <- FunctionType
mov bx, ss:[bp].GCUUIP_childBlock
FALL_THRU ForceUpdate
SSCFUpdateUI endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ForceUpdate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Update the UI for the Choose Function controller
CALLED BY: SSCFUpdateUI(), SSCFChangeType()
PASS: bx - handle of child block
*ds:si - controller
ax - FunctionType to display
RETURN: none
DESTROYED: ax, cx, si, di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 9/26/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ForceUpdate proc far
.enter
push si ; controller
mov_tr cx, ax ; FunctionType
clr dx
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
mov si, offset ChooseTypeList
call SSCFObjMessageSend
mov_tr ax, cx ; FunctionType
call ParserGetNumberOfFunctions ; cx <- num functions
mov ax, MSG_GEN_DYNAMIC_LIST_INITIALIZE
mov si, offset ChooseFuncList ;^lbx:si <- OD of list
call SSCFObjMessageSend
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
clr cx, dx ;cx <- select 1st, not indeter
call SSCFObjMessageSend
pop si
mov ax, MSG_SSCF_CHANGE_FUNCTION
mov bx, ds:[LMBH_handle]
call SSCFObjMessageSend
.leave
ret
ForceUpdate endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SSCFChooseFunc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Handle "ChooseFunc" being pressed
CALLED BY: MSG_SSCF_SORT
PASS: *ds:si - instance data
ds:di - *ds:si
es - seg addr of SSChooseFuncControlClass
ax - the message
RETURN:
DESTROYED: cx, dx, bp, bx, si, (method handler)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cheng 7/92 Initial version
witt 11/93/93 Added DBCS stack overflow check (paranoid)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SSCFChooseFunc method dynamic SSChooseFuncControlClass, \
MSG_SSCF_CHOOSE_FUNCTION
;
; Release the focus (so the edit bar or whatever can get it)
; (Don't do in Redwood, should avoid on all keyboard-only systems.)
;
if not KEYBOARD_ONLY_UI
mov ax, MSG_META_RELEASE_FOCUS_EXCL
call ObjCallInstanceNoLock
mov ax, MSG_META_ENSURE_ACTIVE_FT
call GenCallApplication
endif
push ds:[di].SSCFCI_types
push si
call SSCGetChildBlockAndFeatures
mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION
mov si, offset ChooseFuncList ;^lbx:si <- OD of list
call SSCFObjMessageCall ; ax <- cur selection, carry if none
pop si
pop dx
LONG jc done ;branch if none selected
sub sp, MAX_FUNCTION_NAME_SIZE+MAX_FUNCTION_ARGS_SIZE
DBCS< EC< call ECCHECKSTACK ; paranoid > >
segmov es, ss
mov di, sp ;es:di <- buffer
;
; Get the function name
;
push ax
mov cx, ax ;cx <- index
mov ax, dx ;ax <- FunctionType
call ParserGetFunctionMoniker ;cx <- length
pop ax
;
; Get the arguments if necessary
;
push di
add di, cx ;es:di <- ptr past name
DBCS < add di, cx ;es:di <- ptr past name >
push ax
call SSCGetChildBlockAndFeatures
test ax, mask SSCFF_PASTE_ARGUMENTS
pop ax
jz noArgs ;branch if no such feature
push ax, cx, dx, si
mov si, offset ChooseArgOption
mov ax, MSG_GEN_BOOLEAN_GROUP_GET_SELECTED_BOOLEANS
call SSCFObjMessageCall
tst ax ;any selected?
pop ax, cx, dx, si
jnz getArgs ;branch if none selected
noArgs:
;
; Not pasting arguments -- add "()" to the function name
; cx = length
;
mov ax, '('
LocalPutChar esdi, ax
mov ax, ')'
LocalPutChar esdi, ax
clr ax ;ax <- NULL
LocalPutChar esdi, ax ;NULL terminate
add cx, 2 ;cx <- 2 more chars (w/o NULL)
afterArgs:
pop di
;
; allocate a block of memory for the string and copy the string over
;
pushdw dssi
SBCS< segmov ds, es >
DBCS< segmov ds, es, ax >
mov si, di ;ds:si <- string
mov ax, cx ;ax <- # bytes
DBCS < shl ax, 1 ;ax <- # bytes (DBCS) >
push cx ;save string length
mov cx, mask HF_SWAPABLE or (mask HAF_LOCK shl 8)
call MemAlloc ;ax <- seg; bx <- handle
mov es, ax
clr di ;es:di <- dest
pop cx ;cx <- # of chars
push cx
LocalCopyNString ;copy me jesus
call MemUnlock
mov dx, bx ;dx <- handle of string
pop cx ;cx <- length of string
popdw dssi ;*ds:si <- controller
;
; cx = length, dx = mem handle
;
mov bp, 0x00ff ;bp.low <- offset; bp.high <- md
mov ax, MSG_SPREADSHEET_REPLACE_TEXT_SELECTION
clr bx, di
call GenControlOutputActionRegs
add sp, MAX_FUNCTION_NAME_SIZE+MAX_FUNCTION_ARGS_SIZE
done:
ret
;
; Get the arguments for the function
; es:di - ptr to buffer
; cx - # chars so far (length)
; dx - FunctionType
; ax - index
;
getArgs:
push cx
mov cx, ax ;cx <- index
mov ax, dx ;ax <- FunctionType
call ParserGetFunctionArgs ;cx <- length of args
pop ax ;ax <- length of function
add cx, ax ;cx <- length
jmp afterArgs
SSCFChooseFunc endm
COMMENT @-----------------------------------------------------------------------
FUNCTION: SSCFRequestMoniker
DESCRIPTION:
CALLED BY: INTERNAL ()
PASS: cx:dx GenDynamicList OD
bp - entry #
RETURN:
DESTROYED:
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Cheng 6/92 Initial version
-------------------------------------------------------------------------------@
SSCFRequestMoniker method dynamic SSChooseFuncControlClass,
MSG_SSCF_REQUEST_FUNCTION_MONIKER
.enter
sub sp, MAX_FUNCTION_NAME_SIZE
mov bx, cx ; bx:si <- OD
mov si, dx
;
; get a copy of the name of the function into a buffer
;
mov ax, ds:[di].SSCFCI_types ;ax <- FunctionType
segmov es, ss
mov di, sp ; es:di <- buffer
call ParserGetNumberOfFunctions ; cx <- num functions
cmp bp, cx ; is it a valid entry #?
jae done
mov cx, bp
call ParserGetFunctionMoniker ; fill buffer with name
;
; send message to the list object
;
mov ax, MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_TEXT
mov cx, es
mov dx, di ; cx:dx <- printer name
call SSCFObjMessageSend ; call the list
done:
add sp, MAX_FUNCTION_NAME_SIZE
.leave
ret
SSCFRequestMoniker endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SSCFChangeType
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Change the type of function displayed
CALLED BY: MSG_SSCF_CHANGE_TYPE
PASS: *ds:si - instance data
ds:di - *ds:si
es - seg addr of SSChooseFuncControlClass
ax - the message
cx - FunctionType to match
RETURN: none
DESTROYED: bx, si, di, ds, es (method handler)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 9/26/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SSCFChangeType method dynamic SSChooseFuncControlClass,
MSG_SSCF_CHANGE_TYPE
mov ds:[di].SSCFCI_types, cx
call SSCGetChildBlockAndFeatures
mov ax, cx ;ax <- FunctionType
GOTO ForceUpdate
SSCFChangeType endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SSCFChangeFunction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Change the function that is selected
CALLED BY: MSG_SSCF_CHANGE_FUNCTION
PASS: *ds:si - instance data
ds:di - *ds:si
cx - index of the function in the list
ax - message number (unused)
es - seg addr of SSChooseFuncControlClass (unused)
RETURN: none
DESTROYED: bx, bp, si, di, ds, es (method handler)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
Under DBCS this routine takes 600 bytes of space,
which is now allocated in global memory (witt, 12/93).
If we can't allocate memory, return and let caller trip.
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 9/27/92 Initial version
witt 11/19/93 DBCS allocates memory for format buffer.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SSCFChangeFunction method dynamic SSChooseFuncControlClass,
MSG_SSCF_CHANGE_FUNCTION
if DBCS_PCGEOS
mov bp, ds:[di].SSCFCI_types ;ax <- type(s) to match
mov dx, cx ;dx <- index
mov ax, MAX_FUNCTION_ARGS_SIZE+MAX_FUNCTION_NAME_SIZE
mov cx, ALLOC_DYNAMIC_LOCK
call MemAlloc
LONG jc quit ;punt on error
push bx ;save handle
mov es, ax ;es:di <- ptr to buffer
clr di
mov cx, dx ;cx <- item #
push bp ;save type(s) to match
else
sub sp, MAX_FUNCTION_ARGS_SIZE+MAX_FUNCTION_NAME_SIZE
mov ax, ds:[di].SSCFCI_types ;ax <- type(s) to match
mov di, sp
segmov es, ss ;es:di <- ptr to buffer
mov dx, cx ;dx <- index
push ax ;save type(s) to match
endif
DBCS< EC< call ECCheckStack ; should always be done? > >
;
; ds:si - object handle
; es:di - buffer ptr
; dx - index
; cx - index
; ax,bp - trashed
; DBCS< <on stack> - handle to buffer >
; <on stack> - type(s) to match
;
call SSCGetChildBlockAndFeatures ; IN ds:si/ OUT ax,bx
test ax, mask SSCFF_PASTE_ARGUMENTS
pop ax ;get back type(s)
jz noArgs
;
; Get the argument name
;
push ax, dx
push di ;save start of buffer
call ParserGetFunctionMoniker ;cx <- length (w/o NULL)
push cx
DBCS < shl cx, 1 ;cx <- 2 bytes per (DBCS)>
add di, cx ;es:di <- ptr beyond name
;
; Get the arguments
;
mov cx, dx ;cx <- index
call ParserGetFunctionArgs ;cx <- length of args
pop ax ;ax <- length of function name
add cx, ax ;cx <- length of both
pop di ;restore start of buffer
;
; Set the text
;
push si
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
mov si, offset ChooseArguments
mov dx, es
mov bp, di ;dx:bp <- ptr to text
call SSCFObjMessageCall
pop si
pop ax, dx ;restore type(s) & index
noArgs:
;
; Display the description if appropriate
;
push ax
call SSCGetChildBlockAndFeatures
test ax, mask SSCFF_DESCRIPTION
pop ax
jz noDesc
DBCS< clr di ;es:di <- ptr to buffer >
mov cx, dx ;cx <- index
call ParserGetFunctionDescription ;cx <- length
mov si, offset ChooseDescription
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
mov dx, es
mov bp, di ;dx:bp <- ptr to text
call SSCFObjMessageCall
noDesc:
SBCS< add sp, MAX_FUNCTION_ARGS_SIZE+MAX_FUNCTION_NAME_SIZE >
DBCS< pop bx >
DBCS< call MemFree >
DBCS <quit: >
ret
SSCFChangeFunction endm
SSCFObjMessageSend proc near
uses di
.enter
mov di, mask MF_FIXUP_DS
call ObjMessage
.leave
ret
SSCFObjMessageSend endp
SSCFObjMessageCall proc near
uses di
.enter
mov di, mask MF_FIXUP_DS or mask MF_CALL
call ObjMessage
.leave
ret
SSCFObjMessageCall endp
ChooseFuncControlCode ends
|
arch/ARM/cortex_m/src/cm7/cortex_m_svd-nvic.ads | rocher/Ada_Drivers_Library | 192 | 1301 | -- This spec has been automatically generated from cm7.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package Cortex_M_SVD.NVIC is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Interrupt Set-Enable Registers
-- Interrupt Set-Enable Registers
type NVIC_ISER_Registers is array (0 .. 7) of HAL.UInt32
with Volatile;
-- Interrupt Clear-Enable Registers
-- Interrupt Clear-Enable Registers
type NVIC_ICER_Registers is array (0 .. 7) of HAL.UInt32
with Volatile;
-- Interrupt Set-Pending Registers
-- Interrupt Set-Pending Registers
type NVIC_ISPR_Registers is array (0 .. 7) of HAL.UInt32
with Volatile;
-- Interrupt Clear-Pending Registers
-- Interrupt Clear-Pending Registers
type NVIC_ICPR_Registers is array (0 .. 7) of HAL.UInt32
with Volatile;
-- Interrupt Active Bit Register
-- Interrupt Active Bit Register
type NVIC_IABR_Registers is array (0 .. 7) of HAL.UInt32
with Volatile;
-- Interrupt Priority Register
-- Interrupt Priority Register
type NVIC_IPR_Registers is array (0 .. 59) of HAL.UInt32
with Volatile;
subtype STIR_INTID_Field is HAL.UInt9;
-- Software Trigger Interrupt Register
type STIR_Register is record
-- Write-only. Interrupt ID of the interrupt to trigger, in the range
-- 0-239.
INTID : STIR_INTID_Field := 16#0#;
-- unspecified
Reserved_9_31 : HAL.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for STIR_Register use record
INTID at 0 range 0 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
type NVIC_Peripheral is record
-- Interrupt Set-Enable Registers
NVIC_ISER : aliased NVIC_ISER_Registers;
-- Interrupt Clear-Enable Registers
NVIC_ICER : aliased NVIC_ICER_Registers;
-- Interrupt Set-Pending Registers
NVIC_ISPR : aliased NVIC_ISPR_Registers;
-- Interrupt Clear-Pending Registers
NVIC_ICPR : aliased NVIC_ICPR_Registers;
-- Interrupt Active Bit Register
NVIC_IABR : aliased NVIC_IABR_Registers;
-- Interrupt Priority Register
NVIC_IPR : aliased NVIC_IPR_Registers;
-- Software Trigger Interrupt Register
STIR : aliased STIR_Register;
end record
with Volatile;
for NVIC_Peripheral use record
NVIC_ISER at 16#0# range 0 .. 255;
NVIC_ICER at 16#80# range 0 .. 255;
NVIC_ISPR at 16#100# range 0 .. 255;
NVIC_ICPR at 16#180# range 0 .. 255;
NVIC_IABR at 16#200# range 0 .. 255;
NVIC_IPR at 16#300# range 0 .. 1919;
STIR at 16#E00# range 0 .. 31;
end record;
NVIC_Periph : aliased NVIC_Peripheral
with Import, Address => NVIC_Base;
end Cortex_M_SVD.NVIC;
|
parser/ddl/DDLLexer.g4 | liupangzi/gpa | 6 | 2463 | // antlr -Dlanguage=Go DDLLexer.g4 -o . -package ddlparser
lexer grammar DDLLexer;
channels {
INLINE_COMMENT_CHANNEL
}
AUTO_INCREMENT
: [aA][uU][tT][oO]'_'[iI][nN][cC][rR][eE][mM][eE][nN][tT]
;
BIGINT
: [bB][iI][gG][iI][nN][tT]
;
BINARY
: [bB][iI][nN][aA][rR][yY]
;
BIT
: [bB][iI][tT]
;
BLOB
: [bB][lL][oO][bB]
;
BTREE
: [bB][tT][rR][eE][eE]
;
BOOLEAN
: [bB][oO][oO][lL][eE][aA][nN]
;
BOOL
: [bB][oO][oO][lL]
;
CHARACTER
: [cC][hH][aA][rR][aA][cC][tT][eE][rR]
;
CHARSET
: [cC][hH][aA][rR][sS][eE][tT]
;
CHAR
: [cC][hH][aA][rR]
;
COLLATE
: [cC][oO][lL][lL][aA][tT][eE]
;
COMMENT
: [cC][oO][mM][mM][eE][nN][tT]
;
CONSTRAINT
: [cC][oO][nN][sS][tT][rR][aA][iI][nN][tT]
;
CREATE
: [cC][rR][eE][aA][tT][eE]
;
CURRENT_TIMESTAMP
: [cC][uU][rR][rR][eE][nN][tT]'_'[tT][iI][mM][eE][sS][tT][aA][mM][pP]
;
DATETIME
: [dD][aA][tT][eE][tT][iI][mM][eE]
;
DATE
: [dD][aA][tT][eE]
;
DECIMAL
: [dD][eE][cC][iI][mM][aA][lL]
;
DEC
: [dD][eE][cC]
;
DEFAULT
: [dD][eE][fF][aA][uU][lL][tT]
;
DOUBLE
: [dD][oO][uU][bB][lL][eE]
;
ENGINE
: [eE][nN][gG][iI][nN][eE]
;
ENUM
: [eE][nN][uU][mM]
;
EXISTS
: [eE][xX][iI][sS][tT][sS]
;
FALSE
: [fF][aA][lL][sS][eE]
;
FIXED
: [fF][iI][xX][eE][dD]
;
FLOAT
: [fF][lL][oO][aA][tT]
;
HASH
: [hH][aA][sS][hH]
;
INDEX
: [iI][nN][dD][eE][xX]
;
IF
: [iI][fF]
;
INTEGER
: [iI][nN][tT][eE][gG][eE][rR]
;
INT
: [iI][nN][tT]
;
JSON
: [jJ][sS][oO][nN]
;
KEY_BLOCK_SIZE
: [kK][eE][yY]'_'[bB][lL][oO][cC][kK]'_'[sS][iI][zZ][eE]
;
KEY
: [kK][eE][yY]
;
LOCALTIMESTAMP
: [lL][oO][cC][aA][lL][tT][iI][mM][eE][sS][tT][aA][mM][pP]
;
LOCALTIME
: [lL][oO][cC][aA][lL][tT][iI][mM][eE]
;
LONGBLOB
: [lL][oO][nN][gG][bB][lL][oO][bB]
;
LONGTEXT
: [lL][oO][nN][gG][tT][eE][xX][tT]
;
MEDIUMBLOB
: [mM][eE][dD][iI][uU][mM][bB][lL][oO][bB]
;
MEDIUMINT
: [mM][eE][dD][iI][uU][mM][iI][nN][tT]
;
MEDIUMTEXT
: [mM][eE][dD][iI][uU][mM][tT][eE][xX][tT]
;
NATIONAL
: [nN][aA][tT][iI][oO][nN][aA][lL]
;
NCHAR
: [nN][cC][hH][aA][rR]
;
NOT
: [nN][oO][tT]
;
NOW
: [nN][oO][wW]
;
NULL
: [nN][uU][lL][lL]
;
NUMERIC
: [nN][uU][mM][eE][rR][iI][cC]
;
NVARCHAR
: [nN][vV][aA][rR][cC][hH][aA][rR]
;
ON
: [oO][nN]
;
PARSER
: [pP][aA][rR][sS][eE][rR]
;
PRECISION
: [pP][rR][eE][cC][iI][sS][iI][oO][nN]
;
PRIMARY
: [pP][rR][iI][mM][aA][rR][yY]
;
REAL
: [rR][eE][aA][lL]
;
SERIAL
: [sS][eE][rR][iI][aA][lL]
;
SET
: [sS][eE][tT]
;
SIGNED
: [sS][iI][gG][nN][eE][dD]
;
SMALLINT
: [sS][mM][aA][lL][lL][iI][nN][tT]
;
TABLE
: [tT][aA][bB][lL][eE]
;
TEMPORARY
: [tT][eE][mM][pP][oO][rR][aA][rR][yY]
;
TEXT
: [tT][eE][xX][tT]
;
TIMESTAMP
: [tT][iI][mM][eE][sS][tT][aA][mM][pP]
;
TIME
: [tT][iI][mM][eE]
;
TINYBLOB
: [tT][iI][nN][yY][bB][lL][oO][bB]
;
TINYINT
: [tT][iI][nN][yY][iI][nN][tT]
;
TINYTEXT
: [tT][iI][nN][yY][tT][eE][xX][tT]
;
TRUE
: [tT][rR][uU][eE]
;
UNIQUE
: [uU][nN][iI][qQ][uU][eE]
;
UNSIGNED
: [uU][nN][sS][iI][gG][nN][eE][dD]
;
UPDATE
: [uU][pP][dD][aA][tT][eE]
;
USING
: [uU][sS][iI][nN][gG]
;
VALUE
: [vV][aA][lL][uU][eE]
;
VARBINARY
: [vV][aA][rR][bB][iI][nN][aA][rR][yY]
;
VARCHAR
: [vV][aA][rR][cC][hH][aA][rR]
;
VARYING
: [vV][aA][rR][yY][iI][nN][gG]
;
WITH
: [wW][iI][tT][hH]
;
YEAR
: [yY][eE][aA][rR]
;
ZEROFILL
: [zZ][eE][rR][oO][fF][iI][lL][lL]
;
Equal
: '='
;
Semicolon
: ';'
;
Comma
: ','
;
LeftParenthesis
: '('
;
RightParenthesis
: ')'
;
Tilde
: '~'
;
Exclamation
: '!'
;
Plus
: '+'
;
Minus
: '-'
;
Integer
: (Plus | Minus)? [1-9] DECIMAL_DIGIT*
| (Plus | Minus)? DECIMAL_DIGIT
;
Number
: (Plus | Minus)? [1-9] DECIMAL_DIGIT* ( '.' DECIMAL_DIGIT+ )?
| (Plus | Minus)? DECIMAL_DIGIT ( '.' DECIMAL_DIGIT+ )?
;
FilesizeLiteral
: DECIMAL_DIGIT+ ('K'|'M'|'G'|'T')
;
Literal
: DQUOTA_STRING
| SQUOTA_STRING
;
PlaceholderString
: '{' RawString '}'
;
BackQuotedString
: '`' ( '\\'. | ~('`'|'\\'))* '`'
;
RawString
: (SINGLE_CHAR | DECIMAL_DIGIT)+
;
fragment DECIMAL_DIGIT
: [0-9]
;
fragment SINGLE_CHAR
: [a-zA-Z]
| '_'
| '-'
;
fragment DQUOTA_STRING
: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"'
;
fragment SQUOTA_STRING
: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\''
;
SPACE
: [ \t\r\n]+ -> channel(HIDDEN)
;
BLOCK_COMMENT
: '/*' .*? '*/' -> channel(HIDDEN)
;
LINE_COMMENT
: (
('-- ' | '#') ~[\r\n]* ('\r'? '\n' | EOF)
| '--' ('\r'? '\n' | EOF)
) -> channel(INLINE_COMMENT_CHANNEL);
|
programs/oeis/008/A008013.asm | jmorken/loda | 1 | 80745 | <filename>programs/oeis/008/A008013.asm
; A008013: Coordination sequence occurring in Zeolite Codes AFG, CAN, LIO, LOS.
; 1,4,10,20,34,54,78,104,134,168,210,256,302,352,406,470,538,604,674,748,834,924,1010,1100,1194,1302,1414,1520,1630,1744,1874,2008,2134,2264,2398,2550,2706,2852,3002,3156,3330,3508,3674,3844,4018,4214,4414,4600,4790,4984,5202,5424,5630,5840,6054,6294,6538,6764,6994,7228,7490,7756,8002,8252,8506,8790,9078,9344,9614,9888,10194,10504,10790,11080,11374,11702,12034,12340,12650,12964,13314,13668,13994,14324,14658,15030,15406,15752,16102,16456,16850,17248,17614,17984,18358,18774,19194,19580,19970,20364,20802,21244,21650,22060,22474,22934,23398,23824,24254,24688,25170,25656,26102,26552,27006,27510,28018,28484,28954,29428,29954,30484,30970,31460,31954,32502,33054,33560,34070,34584,35154,35728,36254,36784,37318,37910,38506,39052,39602,40156,40770,41388,41954,42524,43098,43734,44374,44960,45550,46144,46802,47464,48070,48680,49294,49974,50658,51284,51914,52548,53250,53956,54602,55252,55906,56630,57358,58024,58694,59368,60114,60864,61550,62240,62934,63702,64474,65180,65890,66604,67394,68188,68914,69644,70378,71190,72006,72752,73502,74256,75090,75928,76694,77464,78238,79094,79954,80740,81530,82324,83202,84084,84890,85700,86514,87414,88318,89144,89974,90808,91730,92656,93502,94352,95206,96150,97098,97964,98834,99708,100674,101644,102530,103420,104314,105302,106294,107200,108110,109024,110034,111048,111974,112904,113838,114870,115906,116852,117802,118756,119810,120868,121834,122804,123778,124854,125934,126920,127910,128904
mov $1,1
mov $4,$0
lpb $0
mov $1,$0
add $3,2
cal $1,8363 ; a(n) = floor(n/5)*ceiling(n/5).
mov $0,0
mul $1,$3
add $1,2
lpe
mov $5,$4
mul $5,$4
mov $2,$5
mul $2,2
add $1,$2
|
kernel/gdt/gdt.asm | sudoamin/mars-os | 3 | 6216 | ; Global Descriptor Table
; https://wiki.osdev.org/Global_Descriptor_Table
gdt_init:
; load GDT (reloading)
mov rax, GDT_PTR
lgdt [rax]
ret
section .data
GDT:
dq 0
dq 0x0020980000000000 ; ring 0, code segment
dq 0x0020F80000000000 ; ring 3, code segment, DPL=11=3
; P=1 DPL=11 W=1
dq 0x0000F20000000000 ; ring 3, data segment
TSS_DESC:
dw TSS_LEN - 1 ; first two bytes are the lower 16 bits of TSS limit
dw 0 ; base address of TSS (assign the address in the code)
db 0 ; the lower 24 bits of base address
db 0x89 ; the attribute field: P=1, DPL=00, TYPE=01001 specifes this is 64-bit TSS
db 0
db 0
dq 0
GDT_LEN: equ $-GDT
GDT_PTR:
dw GDT_LEN - 1
dq GDT
|
src/arkanoid.asm | c64lib/ctm-viewer | 0 | 23816 | #import "common/lib/mem.asm"
#import "common/lib/invoke.asm"
#import "chipset/lib/mos6510.asm"
#import "chipset/lib/cia.asm"
#import "chipset/lib/vic2.asm"
#import "arkanoid-meta.asm"
.filenamespace c64lib
.segmentdef Code [start=$0810]
.file [name="./arkanoid.prg", segments="Code", modify="BasicUpstart", _start=$0810]
.segment Code
#import "_common.asm"
charset:
.import binary "arkanoid-charset.bin"
endCharset:
charsetColours:
.import binary "arkanoid-colours.bin"
endCharsetColours:
charsetScreenColours:
.import binary "arkanoid-screen-colours.bin"
endCharsetScreenColours:
.print "Charset size = " + (endCharset - charset)
.print "Colour RAM size = " + (endCharsetColours - charsetColours)
.print "Screen colours size = " + (endCharsetScreenColours - charsetScreenColours) |
assembly_code/chp4_03.asm | harismuneer/Bit-Manipulation-and-Subroutines-8086_Assembly | 65 | 103303 | <reponame>harismuneer/Bit-Manipulation-and-Subroutines-8086_Assembly<gh_stars>10-100
[org 0x0100]
jmp start
_bits: dw 0,0
start: mov ax, 0xABCD
mov cx, 0
mov bx, 1000000000000000b
mov dx, 1000100000000000b
mov si, 0
mov di, 0
mov bp, 0
loop1: test bx,ax
jnz save1
jz save0
l1: shr bx,4
test bx,ax
jnz save1
jz save0
l2: mov bp,0
shl bx,3
jmp swap
l3: inc cx
cmp cx,4
jz update ;After the nibbles in ah are swapped, the masks in bx and dx are updated
cmp cx,8
jz end
jmp loop1
update: mov bx, 0000000010000000b
mov dx, 0000000010001000b
jmp loop1
save1: mov word [_bits + si], 1
add si,2
inc bp
cmp bp,2
jz l2
jmp l1
save0: mov word [_bits + si], 0
add si,2
inc bp
cmp bp,2
jz l2
jmp l1
swap: mov si,0
mov di, [_bits]
cmp di, [_bits + 2]
jz l4 ;If the bits are same then do nothing
xor ax,dx
l4: shr dx,1
jmp l3
end: mov ax, 0x4c00
int 21h
;--------------------------------------------------------------
;Alternate Solution:
;[org 0x0100]
; start: mov ax, ABCD
; mov bx, 1111000011110000b
; mov dx, 0000111100001111b
; and bx,ax
; and dx,ax
; shr bx,4
; shl dx,4
; or bx,dx
; mov ax,bx
; end: mov ax, 0x4c00
; int 21h
;--------------------------------------------------------------
;--------------------------------------------------------------
;Alternate Solution:
;[org 0x0100]
; start: mov ax, ABCD
; ror/rol al,4 ;Both rotate left or rotate right can be used
; ror/rol ah,4
; end: mov ax, 0x4c00
; int 21h
;-------------------------------------------------------------- |
src/lists.adb | argvsc47/Lists_Ada_Package | 5 | 19689 | <filename>src/lists.adb
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
with Unchecked_Deallocation;
package body lists is
procedure Free is new Unchecked_Deallocation(Element,P_List);
function Create_List(Elements: Tab_Of_List_Type) return List is
L :List := (First_Element => null);
begin
for i in Elements'Range loop --add every number of the array into the list
L.Append(Elements(i));
end loop;
return L;
end Create_List;
procedure Append(Self: in out List; Data: T_Data) is
aux: P_List := Self.First_Element;
begin
if aux = null then --return a new list if its empty
Self.First_Element := new Element'(info => Data,
suiv => null);
else --go to the last element (next element = null) and add a new wlement with the new data
while aux.all.suiv /= null loop
aux := aux.all.suiv;
end loop;
aux.all.suiv := new Element'(info => Data,
suiv => null);
end if;
end Append;
function Length(Self:in List) return Natural is
len: Natural := 0;
aux: P_List := Self.First_Element;
begin
if aux /= null then
len := len + 1;
while aux.all.suiv /= null loop
aux:= aux.all.suiv;
len := len + 1;
end loop;
end if;
return len;
end Length;
function get(Self:in List; Index: Integer) return T_Data is
begin
return Self.get_pointer(Index => Index).all.info;
end get;
function Image(Self: in out List) return String is
aux: P_List := Self.First_Element;
img: Unbounded_String;
index : Integer := 1;
begin
img := To_Unbounded_String("[");
if aux /= null then
while aux.all.suiv /= null loop
img := img & To_Unbounded_String(Data_Image(aux.all.info) & ", ");
aux := aux.all.suiv;
end loop;
img := img & To_Unbounded_String(Data_Image(aux.all.info));
end if;
img := img & "]";
return To_String(img);
end Image;
procedure Set(Self:in out List; Index :Integer; New_Value: T_Data) is
begin
Self.get_pointer(Index => Index).all.info := New_Value;
end Set;
procedure Remove_Element(Self: in out List; Element: T_Data) is
pre, aux, rec: P_List;
begin
if Self.First_Element = null then
raise Element_not_in_the_list;
elsif Self.First_Element.all.info = Element then
rec:= Self.First_Element;
Self.First_Element := Self.First_Element.all.suiv;
Free(rec);
else
pre:= Self.First_Element;
aux:=Self.First_Element.all.suiv;
while aux /= null and then aux.all.info /= Element loop
pre:= aux;
aux:= aux.all.suiv;
end loop;
if aux /= null then
rec := aux;
pre.all.suiv:= aux.all.suiv;
Free(rec);
end if;
end if;
end Remove_Element;
procedure Remove_Nth_Element(Self: in out List; Index: Integer) is
aux : P_List := Self.First_Element;
rec : P_List := null;
begin
if aux = null or Index > Self.Length then --the list is null
raise Get_Index_Value_Outside_the_list;
elsif Index = 1 then --its the firs element on the list
Delete_Object(aux.all.info);
Self.First_Element := aux.all.suiv;
Free(aux);
elsif Index = Self.Length then --its the last element on the list
aux := Self.get_pointer(Index => Index - 1);
Delete_Object(aux.all.suiv.all.info);
Free(aux.all.suiv);
aux.all.suiv := null;
else -- its one element of the list, not ht efirst not the last
aux := Self.get_pointer(Index - 1);
rec := aux.all.suiv;
aux.all.suiv := rec.all.suiv;
Delete_Object(rec.all.info);
Free(rec);
end if;
end Remove_Nth_Element;
function get_pointer(Self: in List; Index: Integer) return P_List is
aux : P_List := Self.First_Element;
begin
if Index > Self.Length then
raise Get_Index_Value_Outside_the_list;
elsif Index < 0 then
raise Get_Index_value_negative_not_implemented_yet;
end if;
for i in 2..Index loop
aux:= aux.all.suiv;
end loop;
return aux;
end get_pointer;
procedure Empty(Self: in out List) is
--empties all the list and frees the memory mostly used to instance in a list which contains lists
rec : P_List := null;
aux : P_List := Self.First_Element;
begin
for i in 1..Self.Length loop
rec := aux;
aux := aux.all.suiv;
Delete_Object(rec.all.info);
Free (rec);
end loop;
end Empty;
function "+"(L,R : List) return List is
--appends the second list to the first and returns the whole list
res: List := (First_Element => null);
aux: P_List := L.First_Element;
begin
for i in 1..L.Length loop
res.Append(L.get(i));
end loop;
for i in 1..R.Length loop
res.Append(R.get(i));
end loop;
return res;
end "+";
function "="(L,R: List) return Boolean is
res: Boolean := False;
auxL:P_List := L.First_Element;
auxR: P_List := R.First_Element;
begin
if L.Length = R.Length then
res := True;
while res and auxL /= null loop
res := auxL.all.info = auxR.all.info;
auxL := auxL.all.suiv;
auxR := auxR.all.suiv;
end loop;
end if;
return res;
end "=";
function Index(Self: in List; Element : T_Data) return Integer is
aux: P_List := Self.First_Element;
Index : Integer := 1;
begin
while aux /= null and then aux.all.info /= Element loop
aux := aux.all.suiv;
index := Index + 1;
end loop;
if aux = null then
raise Element_not_in_the_list;
end if;
return Index;
end Index;
end lists;
|
src/main/antlr/me/andrz/brace/antlr/BraceExpansion.g4 | AndersDJohnson/brace-expansion-java | 3 | 3135 | /*
* https://github.com/antlr/grammars-v4
* http://bkiers.blogspot.com/2011/03/5-building-ast.html
* https://wincent.com/wiki/ANTLR_lexers_in_depth
* https://theantlrguy.atlassian.net/wiki/display/ANTLR4/Wildcard+Operator+and+Nongreedy+Subrules
* https://theantlrguy.atlassian.net/wiki/display/ANTLR4/Lexer+Rules
* http://www.gregbugaj.com/?p=251
*/
grammar BraceExpansion;
root : ot ( brace ot )* ;
ot : ( ESC | CM | H | D | T )* ;
str : ( ESC | H | D | T )* ;
brace :
rangeNum
| rangeChar
| LB sub ( CM sub )* RB
;
sub : str ( brace str )* ;
rangeNum : integer '..' integer ( '..' integer )? ;
rangeChar : T '..' T ( '..' integer )? ;
integer : H? D+ ;
ESC: '\\\\' | '\\' . ;
T : ~[{},\\0-9\-] ;
LB : '{' ;
RB : '}' ;
CM : ',' ;
D : [0-9] ;
H : '-' ;
|
programs/oeis/004/A004775.asm | jmorken/loda | 1 | 98805 | <reponame>jmorken/loda
; A004775: Numbers k such that the binary expansion of k does not end in 011.
; 0,1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,20,21,22,23,24,25,26,28,29,30,31,32,33,34,36,37,38,39,40,41,42,44,45,46,47,48,49,50,52,53,54,55,56,57,58,60,61,62,63,64,65,66,68,69,70,71,72,73,74,76,77,78,79,80,81,82,84,85,86,87,88,89,90,92,93,94,95,96,97,98,100,101,102,103,104,105,106,108,109,110,111,112,113,114,116,117,118,119,120,121,122,124,125,126,127,128,129,130,132,133,134,135,136,137,138,140,141,142,143,144,145,146,148,149,150,151,152,153,154,156,157,158,159,160,161,162,164,165,166,167,168,169,170,172,173,174,175,176,177,178,180,181,182,183,184,185,186,188,189,190,191,192,193,194,196,197,198,199,200,201,202,204,205,206,207,208,209,210,212,213,214,215,216,217,218,220,221,222,223,224,225,226,228,229,230,231,232,233,234,236,237,238,239,240,241,242,244,245,246,247,248,249,250,252,253,254,255,256,257,258,260,261,262,263,264,265,266,268,269,270,271,272,273,274,276,277,278,279,280,281,282,284
mov $1,$0
sub $0,4
div $0,7
add $1,$0
|
Transynther/x86/_processed/NONE/_xt_sm_/i9-9900K_12_0xa0_notsx.log_21829_687.asm | ljhsiun2/medusa | 9 | 100902 | <reponame>ljhsiun2/medusa<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r14
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x13351, %rbp
nop
nop
nop
nop
add %r11, %r11
mov (%rbp), %esi
nop
nop
and %rbp, %rbp
lea addresses_D_ht+0x1b551, %rsi
lea addresses_UC_ht+0x1e637, %rdi
dec %rbp
mov $6, %rcx
rep movsq
nop
nop
nop
nop
xor %r11, %r11
lea addresses_D_ht+0xe453, %rsi
lea addresses_WT_ht+0xe131, %rdi
clflush (%rsi)
clflush (%rdi)
xor %r14, %r14
mov $69, %rcx
rep movsl
nop
add %rdi, %rdi
lea addresses_A_ht+0x93d1, %r14
nop
nop
nop
nop
sub $8063, %r10
mov $0x6162636465666768, %rcx
movq %rcx, %xmm6
vmovups %ymm6, (%r14)
nop
nop
nop
nop
nop
add $21629, %r10
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r14
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r14
push %r15
push %rbp
push %rcx
push %rdi
// Store
lea addresses_A+0x93a5, %r10
nop
nop
nop
nop
dec %r15
movl $0x51525354, (%r10)
mfence
// Store
lea addresses_D+0x1cfa9, %rbp
nop
nop
nop
nop
and $22610, %rdi
mov $0x5152535455565758, %r10
movq %r10, %xmm5
vmovups %ymm5, (%rbp)
nop
nop
nop
nop
dec %r10
// Load
lea addresses_WC+0x11aa1, %rbp
nop
nop
nop
nop
nop
inc %rdi
mov (%rbp), %r12
and $8638, %r12
// Load
mov $0x52293b0000000ed1, %r10
nop
nop
cmp $25646, %r12
movntdqa (%r10), %xmm0
vpextrq $1, %xmm0, %rcx
nop
cmp %rcx, %rcx
// Store
lea addresses_UC+0xd011, %r10
nop
nop
nop
nop
nop
dec %r12
mov $0x5152535455565758, %r14
movq %r14, (%r10)
nop
nop
nop
sub $46208, %rcx
// Store
lea addresses_PSE+0x1ab51, %rbp
nop
nop
nop
nop
sub %rcx, %rcx
movl $0x51525354, (%rbp)
nop
nop
nop
dec %rbp
// Store
lea addresses_normal+0x6951, %r12
nop
nop
nop
and %rcx, %rcx
mov $0x5152535455565758, %r14
movq %r14, %xmm3
movups %xmm3, (%r12)
nop
nop
nop
nop
inc %r12
// Faulty Load
lea addresses_PSE+0x1ab51, %r15
nop
nop
nop
nop
nop
xor %r12, %r12
mov (%r15), %ebp
lea oracles, %r15
and $0xff, %rbp
shlq $12, %rbp
mov (%r15,%rbp,1), %rbp
pop %rdi
pop %rcx
pop %rbp
pop %r15
pop %r14
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': False, 'size': 4, 'NT': True, 'same': False, 'congruent': 1}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 3}}
{'src': {'type': 'addresses_WC', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 2}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 16, 'NT': True, 'same': False, 'congruent': 7}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 4, 'NT': True, 'same': True, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 7}}
[Faulty Load]
{'src': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 4, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WC_ht', 'AVXalign': True, 'size': 4, 'NT': False, 'same': False, 'congruent': 11}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'congruent': 8, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}}
{'src': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 6}}
{'54': 21829}
54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54
*/
|
color/ghost_marowak_anim.asm | etdv-thevoid/pokemon-rgb-enhanced | 1 | 171078 | ; Hook for color/ghost_marowak_anim.asm
CopyMonPicFromBGToSpriteVRAM:
; Copy enemy palette to sprite palette 4
ld a,2
ld [rSVBK],a
ld hl,W2_BgPaletteData + 1*8 ; bg palette 1 (enemy)
ld de,W2_SprPaletteData+ 4*8 ; spr palette 4
ld bc,8
call CopyData
; Ghost/marowak palette fade effect uses OBP1
ld a,1
ld [W2_UseOBP1],a
ld [W2_ForceOBPUpdate],a
xor a
ld [rSVBK],a
jp CopyMonPicFromBGToSpriteVRAM_orig
|
src/FairTermination-IS.agda | boystrange/FairSubtypingAgda | 4 | 1203 | <reponame>boystrange/FairSubtypingAgda
-- MIT License
-- Copyright (c) 2021 <NAME> and <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.
{-# OPTIONS --guardedness #-}
open import Data.Empty using (⊥-elim)
open import Data.Unit using (⊤)
open import Data.Product
open import Data.Sum
open import Data.Vec using ([]; _∷_)
open import Data.List as List
import Data.Fin as Fin
open import Data.Nat
open import Relation.Nullary using (¬_; yes; no)
open import Relation.Binary.Definitions
open import Relation.Unary using (_∈_; _∉_; _⊆_; Satisfiable)
open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (ε; _◅_)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong; inspect)
open import Common
open import is-lib.InfSys
module FairTermination-IS {𝕋 : Set} (message : Message 𝕋) where
open import SessionType message
open import Trace message
open import Transitions message
open import HasTrace message
open import TraceSet message
U : Set
U = SessionType
data RuleNames : Set where
nil inp out : RuleNames
data CoRuleNames : Set where
inp out : CoRuleNames
nil-r : FinMetaRule U
nil-r .Ctx = ⊤
nil-r .comp _ =
[] ,
----
nil
inp-r : MetaRule U
inp-r .Ctx = Continuation
inp-r .Pos _ = 𝕋
inp-r .prems f p = f p .force
inp-r .conclu f = inp f
out-r : MetaRule U
out-r .Ctx = Continuation
out-r .Pos _ = 𝕋
out-r .prems f p = f p .force
out-r .conclu f = out f
inp-co-r : FinMetaRule U
inp-co-r .Ctx = Σ[ (f , x) ∈ Continuation × 𝕋 ] x ∈ dom f
inp-co-r .comp ((f , x) , _) =
f x .force ∷ [] ,
--------------------
inp f
out-co-r : FinMetaRule U
out-co-r .Ctx = Σ[ (f , x) ∈ Continuation × 𝕋 ] x ∈ dom f
out-co-r .comp ((f , x) , _) =
f x .force ∷ [] ,
--------------------
out f
WeakTerminationS : SessionType → Set
WeakTerminationS T = ∀{φ} → φ ∈ ⟦ T ⟧ → ∃[ ψ ] (φ ++ ψ ∈ Maximal ⟦ T ⟧)
WeakTerminationIS : IS U
Names WeakTerminationIS = RuleNames
rules WeakTerminationIS nil = from nil-r
rules WeakTerminationIS inp = inp-r
rules WeakTerminationIS out = out-r
WeakTerminationCOIS : IS U
WeakTerminationCOIS .Names = CoRuleNames
WeakTerminationCOIS .rules inp = from inp-co-r
WeakTerminationCOIS .rules out = from out-co-r
WeakTermination : SessionType → Set
WeakTermination = FCoInd⟦ WeakTerminationIS , WeakTerminationCOIS ⟧
WeakTerminationI : SessionType → Set
WeakTerminationI = Ind⟦ WeakTerminationIS ∪ WeakTerminationCOIS ⟧
{- Soundness -}
lemma-inp : ∀{f φ x} → φ ∈ Maximal ⟦ f x .force ⟧ → I x ∷ φ ∈ Maximal ⟦ inp f ⟧
lemma-inp (maximal wit F) =
maximal (inp-has-trace wit) λ { (some le) (_ , def , step inp tr) → cong (_ ∷_) (F le (_ , def , tr))}
lemma-out : ∀{f φ x} → φ ∈ Maximal ⟦ f x .force ⟧ → O x ∷ φ ∈ Maximal ⟦ out f ⟧
lemma-out (maximal wit F) =
maximal (out-has-trace wit) λ { (some le) (_ , def , step (out _) tr) → cong (_ ∷_) (F le (_ , def , tr))}
lemma-end : ∀{f} → (∀{x} → x ∉ dom f) → [] ∈ Maximal ⟦ inp f ⟧
lemma-end no-x = maximal (_ , inp , refl)
λ { {[]} none _ → refl
; {O _ ∷ _} none (_ , _ , step () _)
; {I _ ∷ _} none (_ , def , step inp tr) → ⊥-elim (no-x (transitions+defined->defined tr def))}
lemma-win : ∀{f} → (∀{x} → x ∉ dom f) → [] ∈ Maximal ⟦ out f ⟧
lemma-win no-x = maximal (_ , out , refl)
λ { {[]} none _ → refl
; {I _ ∷ _} none (_ , _ , step () _)
; {O _ ∷ _} none (_ , def , step (out ok) _) → ⊥-elim (no-x ok)}
may-terminate : ∀{T} → Defined T → WeakTerminationI T → Satisfiable (Maximal ⟦ T ⟧)
may-terminate _ (fold (inj₁ inp , f , refl , pr)) with Empty? f
... | inj₁ e = _ , lemma-end λ x → e _ x
... | inj₂ (p , def) =
let tr , max = may-terminate def (pr p) in
I p ∷ tr , lemma-inp max
may-terminate _ (fold (inj₁ out , f , refl , pr)) with Empty? f
... | inj₁ e = _ , lemma-win λ x → e _ x
... | inj₂ (p , def) =
let tr , max = may-terminate def (pr p) in
O p ∷ tr , lemma-out max
may-terminate _ (fold (inj₂ inp , ((_ , x) , def) , refl , pr)) =
let tr , max = may-terminate def (pr Fin.zero) in
I x ∷ tr , lemma-inp max
may-terminate _ (fold (inj₂ out , ((_ , x) , def) , refl , pr)) =
let tr , max = may-terminate def (pr Fin.zero) in
O x ∷ tr , lemma-out max
wt-sound : WeakTermination ⊆ WeakTerminationS
wt-sound wt (_ , def , refl) = may-terminate def (fcoind-to-ind wt)
wt-sound wt (_ , def , step t tr) with wt .CoInd⟦_⟧.unfold
wt-sound wt (_ , def , step (inp {_} {p}) tr) | inp , _ , refl , pr =
let tr' , max = wt-sound (pr p) (_ , def , tr) in
tr' , lemma-inp max
wt-sound wt (_ , def , step (out {_} {p} fx) tr) | out , _ , refl , pr =
let tr' , max = wt-sound (pr p) (_ , def , tr) in
tr' , lemma-out max
{- Boundedness -}
undefined→terminates : ∀{T} → ¬ Defined T → WeakTerminationI T
undefined→terminates {nil} _ = apply-ind (inj₁ nil) _ λ ()
undefined→terminates {inp f} und = ⊥-elim (und inp)
undefined→terminates {out f} und = ⊥-elim (und out)
input-maximal→terminates : ∀{f x} → [] ∈ Maximal ⟦ inp f ⟧ → WeakTerminationI (f x .force)
input-maximal→terminates {f} {x} (maximal (_ , inp , refl) F) with x ∈? f
... | no nfx = undefined→terminates nfx
... | yes fx with F none (_ , fx , step inp refl)
... | ()
output-maximal→terminates : ∀{f x} → [] ∈ Maximal ⟦ out f ⟧ → WeakTerminationI (f x .force)
output-maximal→terminates {f} {x} (maximal (_ , out , refl) F) with x ∈? f
... | no nfx = undefined→terminates nfx
... | yes fx with F none (_ , fx , step (out fx) refl)
... | ()
bounded-lemma : ∀{T ϕ} → ϕ ∈ Maximal ⟦ T ⟧ → WeakTerminationI T
bounded-lemma {nil} (maximal _ _) = apply-ind (inj₁ nil) _ λ ()
bounded-lemma {inp f} c[]@(maximal (_ , def , refl) F) =
apply-ind (inj₁ inp) _ λ p → input-maximal→terminates {f} {p} c[]
bounded-lemma {inp f} cϕ@(maximal (_ , def , step inp tr) F) =
apply-ind (inj₂ inp) (_ , (transitions+defined->defined tr def)) λ{Fin.zero → bounded-lemma (input-maximal cϕ)}
bounded-lemma {out f} c[]@(maximal (_ , def , refl) F) =
apply-ind (inj₁ out) _ λ p → output-maximal→terminates {f} {p} c[]
bounded-lemma {out f} cϕ@(maximal (_ , def , step (out x) tr) F) =
apply-ind (inj₂ out) (_ , x) λ{Fin.zero → bounded-lemma (output-maximal cϕ)}
wtS-bounded : WeakTerminationS ⊆ WeakTerminationI
wtS-bounded {nil} _ = apply-ind (inj₁ nil) _ λ ()
wtS-bounded {inp f} s with s (_ , inp , refl)
... | _ , max = bounded-lemma max
wtS-bounded {out f} s with s (_ , out , refl)
... | _ , max = bounded-lemma max
{- Consistency -}
lemma-input-maximal : ∀{f x} → WeakTerminationS (inp f) → WeakTerminationS (f x .force)
lemma-input-maximal {f} {x} spec tφ with x ∈? f
... | no nfx = ⊥-elim (nfx (has-trace->defined tφ))
... | yes fx with spec (inp-has-trace tφ)
... | _ , cψ = _ , input-maximal cψ
lemma-output-maximal : ∀{f x} → WeakTerminationS (out f) → WeakTerminationS (f x .force)
lemma-output-maximal {f} {x} spec tφ with x ∈? f
... | no nfx = ⊥-elim (nfx (has-trace->defined tφ))
... | yes fx with spec (out-has-trace tφ)
... | _ , cψ = _ , output-maximal cψ
wtS-cons : WeakTerminationS ⊆ ISF[ WeakTerminationIS ] WeakTerminationS
wtS-cons {nil} spec = nil , _ , refl , λ ()
wtS-cons {inp f} spec =
inp , f , refl , λ p → lemma-input-maximal {f} {p} spec
wtS-cons {out f} spec =
out , f , refl , λ p → lemma-output-maximal {f} {p} spec
{- Completeness -}
wt-complete : WeakTerminationS ⊆ WeakTermination
wt-complete =
bounded-coind[ WeakTerminationIS , WeakTerminationCOIS ] WeakTerminationS wtS-bounded wtS-cons
|
samples/encodes.adb | RREE/ada-util | 60 | 726 | -----------------------------------------------------------------------
-- encodes -- Encodes strings
-- 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 Ada.Text_IO;
with Ada.Command_Line;
with Util.Encoders;
procedure Encodes is
use Util.Encoders;
Encode : Boolean := True;
Count : constant Natural := Ada.Command_Line.Argument_Count;
begin
if Count <= 1 then
Ada.Text_IO.Put_Line ("Usage: encodes {encoder} [-d|-e] string...");
Ada.Text_IO.Put_Line ("Encoders: " & Util.Encoders.BASE_64 & ", "
& Util.Encoders.BASE_64_URL & ", "
& Util.Encoders.BASE_16 & ", "
& Util.Encoders.HASH_SHA1);
return;
end if;
declare
Name : constant String := Ada.Command_Line.Argument (1);
C : constant Encoder := Util.Encoders.Create (Name);
D : constant Decoder := Util.Encoders.Create (Name);
begin
for I in 2 .. Count loop
declare
S : constant String := Ada.Command_Line.Argument (I);
begin
if S = "-d" then
Encode := False;
elsif S = "-e" then
Encode := True;
elsif Encode then
Ada.Text_IO.Put_Line ("Encodes " & Name & ": " & C.Encode (S));
else
Ada.Text_IO.Put_Line ("Decodes " & Name & ": " & D.Decode (S));
end if;
end;
end loop;
end;
end Encodes;
|
utils/launch_in_iterm.applescript | asfaltboy/SublimePythonTestRunner | 13 | 2158 | -- Updated launcher for iTerm 3 beta
set test_cmd to system attribute "TEST_CMD"
tell application "iTerm"
activate
if (count of windows) = 0 then
set t to (create window with default profile)
else
set t to current window
end if
tell t
tell current session
write text test_cmd
end tell
end tell
end tell
-- legacy iTerm2 code:
-- set test_cmd to system attribute "TEST_CMD"
-- tell application "iTerm"
-- activate
-- (* set t to (make new terminal) *)
-- -- make a new terminal
-- -- set myterm to (current terminal)
-- set myterm to (make new terminal)
-- -- talk to the new terminal
-- tell myterm
-- -- make a new session
-- set mysession to launch session "Default"
-- -- set mysession to (make new session at the end of sessions)
-- -- select mysession
-- -- talk to the session
-- tell mysession
-- -- execute a command
-- -- exec command test_cmd
-- write text test_cmd
-- end tell -- we are done talking to the session
-- end tell
-- end tell |
grammar/StaticScriptParser.g4 | linvs/test | 428 | 2909 | <gh_stars>100-1000
parser grammar StaticScriptParser;
options {
language = Cpp;
tokenVocab = StaticScriptLexer;
}
module
: statements? EOF
;
statements
: statement+
;
statement
: emptyStatement
| declarationStatement
| compoundStatement
| expressionStatement
| selectionStatement
| iterationStatement
| jumpStatement
;
emptyStatement
: SemiColon
;
declarationStatement
: declaration
;
declaration
: variableDeclaration
| functionDeclaration
;
variableDeclaration
: variableDeclarators SemiColon
;
variableDeclarators
: variableModifier variableDeclarator (Comma variableDeclarator)*
;
variableModifier
: Let
| Const
;
variableDeclarator
: Identifier typeAnnotation? variableInitializer?
;
variableInitializer
: Assign expression
;
typeAnnotation
: Colon type
;
type
: arrayType
| basicType
;
arrayType
: basicType (OpenBracket CloseBracket)+
;
basicType
: Boolean
| Integer
| Number
| String
;
functionDeclaration
: Function Identifier OpenParen parameterList? CloseParen typeAnnotation? functionBody
;
parameterList
: Identifier typeAnnotation (Comma Identifier typeAnnotation)*
;
functionBody
: compoundStatement
;
compoundStatement
: OpenBrace statements? CloseBrace
;
expressionStatement
: expression SemiColon
;
expression
: base=expression (OpenBracket index+=expression CloseBracket)+ # ArraySubscriptExpr
| callExpression # CallExpr
| expression uop=(PlusPlus | MinusMinus) # PostfixUnaryExpr
| <assoc=right> uop=(Not | BitNot | Plus | Minus | PlusPlus | MinusMinus) expression # PrefixUnaryExpr
| expression bop=(Multiply | Divide | Modulus) expression # BinaryExpr
| expression bop=(Plus | Minus) expression # BinaryExpr
| expression bop=(ShiftLeft | ArithmeticShiftRight | LogicalShiftRight) expression # BinaryExpr
| expression bop=(LessThan | GreaterThan | LessThanEquals | GreaterThanEquals) expression # BinaryExpr
| expression bop=(Equals | NotEquals) expression # BinaryExpr
| expression bop=BitAnd expression # BinaryExpr
| expression bop=BitXOr expression # BinaryExpr
| expression bop=BitOr expression # BinaryExpr
| expression bop=And expression # BinaryExpr
| expression bop=Or expression # BinaryExpr
| <assoc=right> expression bop=(Assign | PlusAssign | MinusAssign | MultiplyAssign | DivideAssign | ModulusAssign | ShiftLeftAssign | ArithmeticShiftRightAssign | LogicalShiftRightAssign | BitAndAssign | BitXorAssign | BitOrAssign | AndAssign | OrAssign) expression # BinaryExpr
| Identifier # IdentifierExpr
| literal # LiteralExpr
| OpenParen expression CloseParen # ParenExpr
;
callExpression
: Identifier OpenParen argumentList? CloseParen
;
argumentList
: expressionList
;
literal
: BooleanLiteral
| DecimalIntegerLiteral
| HexIntegerLiteral
| OctalIntegerLiteral
| BinaryIntegerLiteral
| FloatLiteral
| StringLiteral
| arrayLiteral
;
arrayLiteral
: OpenBracket expressionList? CloseBracket
;
expressionList
: expression (Comma expression)*
;
selectionStatement
: ifStatement
;
ifStatement
: If OpenParen ifCondition=expression CloseParen thenBody=statement (Else elseBody=statement)?
;
iterationStatement
: whileStatement
| forStatement
;
whileStatement
: While OpenParen whileCondition=expression CloseParen whileBody=statement
;
forStatement
: For OpenParen forInit? SemiColon forCondition=expression? SemiColon forUpdate=expressionList? CloseParen forBody=statement
;
forInit
: variableDeclarators
| expressionList
;
jumpStatement
: continueStatement
| breakStatement
| returnStatement
;
continueStatement
: Continue SemiColon
;
breakStatement
: Break SemiColon
;
returnStatement
: Return returnExpr=expression? SemiColon
; |
week6/gmp-5.0.5/mpn/copyd.asm | csMOOC/Stanford.Cryptography | 1 | 162526 | dnl AMD64 mpn_copyd -- copy limb vector, decrementing.
dnl Copyright 2003, 2005, 2007, 2011, 2012 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C cycles/limb
C AMD K8,K9 1
C AMD K10 1
C AMD bd1 1.36
C AMD bobcat 1.71
C Intel P4 2-3
C Intel core2 1
C Intel NHM 1
C Intel SBR 1
C Intel atom 2
C VIA nano 2
IFSTD(`define(`rp',`%rdi')')
IFSTD(`define(`up',`%rsi')')
IFSTD(`define(`n', `%rdx')')
IFDOS(`define(`rp',`%rcx')')
IFDOS(`define(`up',`%rdx')')
IFDOS(`define(`n', `%r8')')
ABI_SUPPORT(DOS64)
ABI_SUPPORT(STD64)
ASM_START()
TEXT
ALIGN(64)
PROLOGUE(mpn_copyd)
lea -8(up,n,8), up
lea (rp,n,8), rp
sub $4, n
jc L(end)
nop
L(top): mov (up), %rax
mov -8(up), %r9
lea -32(rp), rp
mov -16(up), %r10
mov -24(up), %r11
lea -32(up), up
mov %rax, 24(rp)
mov %r9, 16(rp)
sub $4, n
mov %r10, 8(rp)
mov %r11, (rp)
jnc L(top)
L(end): shr R32(n)
jnc 1f
mov (up), %rax
mov %rax, -8(rp)
lea -8(rp), rp
lea -8(up), up
1: shr R32(n)
jnc 1f
mov (up), %rax
mov -8(up), %r9
mov %rax, -8(rp)
mov %r9, -16(rp)
1: ret
EPILOGUE()
|
data/wild/maps/RockTunnelB1F.asm | opiter09/ASM-Machina | 1 | 8097 | <reponame>opiter09/ASM-Machina
RockTunnelB1FWildMons:
def_grass_wildmons 15 ; encounter rate
db 26, GOLBAT
db 27, CUBONE
db 27, GRAVELER
db 28, MACHOKE
db 26, GRAVELER
db 28, GOLBAT
db 27, MACHOP
db 27, ONIX
db 29, ONIX
db 31, DUGTRIO
end_grass_wildmons
def_water_wildmons 0 ; encounter rate
end_water_wildmons
|
programs/oeis/091/A091435.asm | neoneye/loda | 22 | 176336 | <filename>programs/oeis/091/A091435.asm
; A091435: Array T(n,k) = n*(n+k), read by antidiagonals.
; 0,1,0,4,2,0,9,6,3,0,16,12,8,4,0,25,20,15,10,5,0,36,30,24,18,12,6,0,49,42,35,28,21,14,7,0,64,56,48,40,32,24,16,8,0,81,72,63,54,45,36,27,18,9,0,100,90,80,70,60,50,40,30,20,10,0,121,110,99,88,77,66,55,44,33,22,11,0,144,132,120,108,96,84,72,60,48,36,24,12,0,169,156,143,130,117,104,91,78,65
lpb $0
add $1,1
sub $0,$1
mov $2,$1
mul $2,$0
trn $0,1
lpe
sub $1,$2
mov $0,$1
|
tests/nonsmoke/functional/CompileTests/experimental_ada_tests/tests/entry_body_declaration.adb | ouankou/rose | 488 | 29330 | procedure Entry_Body_Declaration is
protected Obj is
entry Start;
private
Is_Set : Boolean := False;
end Obj;
protected body Obj is
entry Start when Is_Set is
begin
null;
end;
end Obj;
begin
null;
end Entry_Body_Declaration;
|
programs/oeis/252/A252233.asm | jmorken/loda | 1 | 89450 | ; A252233: Characteristic function for the integers that are the product of an odd number of primes each with multiplicity one.
; 0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,1,1,0,0,1,1,0,1,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,1,0,1,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,0,0,1,0,1,0,1,0,0,1,0,0,1,1,0,0,0,0,1,0,1,1,0,0,0,1,0,0,0,1,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,0,1,1,1,0,1,0,0,0,0,1,1,0,1,0,0,0,0,1,0,0,0,0
cal $0,8683 ; Möbius (or Moebius) function mu(n). mu(1) = 1; mu(n) = (-1)^k if n is the product of k different primes; otherwise mu(n) = 0.
trn $1,$0
|
dependently-typed-programming-in-agda_norell-chapman/Sort.agda | neosimsim/merkdas | 1 | 14880 | module Sort (A : Set)(_<_ : A → A → Set) where |
test/Succeed/Issue3597.agda | cruhland/agda | 1,989 | 7011 | -- <NAME>, AIM XXIX, 2019-03-18, issue #3597
-- Eta-expansion of record metas disregards freezing.
-- Meta occurs check is then insufficient, leading to cyclic assignment.
{-# OPTIONS --allow-unsolved-metas #-}
-- {-# OPTIONS -v tc.meta:40 #-}
-- {-# OPTIONS -v tc.meta.assign:100 #-}
-- {-# OPTIONS -v tc.meta.eta:100 #-}
postulate P : (A : Set) → (a : A) → Set
record R : Set₁ where
constructor c
-- no-eta-equality -- WORKS without eta
field
A : Set
a : A
p : P A a → P A a
C : R
C = {!!}
module M = R C
test : P {!!} M.a → P {!!} M.a
test x = M.p x
-- WAS: cyclic assignment
-- C = _5
-- _7 := _5 .A
-- _9 := _5 .A
-- _5 := c _10 _11 _12
-- _10 := C .A
-- NOW: frozed metas are eta-expanded to records of frozen metas
|
src/ships-movement.ads | thindil/steamsky | 80 | 16652 | -- Copyright 2017-2021 <NAME>
--
-- This file is part of Steam Sky.
--
-- Steam Sky 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.
--
-- Steam Sky 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 Steam Sky. If not, see <http://www.gnu.org/licenses/>.
-- ****h* Ships/SMovement
-- FUNCTION
-- Provides code related to ships movement
-- SOURCE
package Ships.Movement is
-- ****
-- ****f* SMovement/SMovement.MoveShip
-- FUNCTION
-- Move player ship
-- PARAMETERS
-- X - Amount of X coordinate fields to move player ship
-- Y - Amount of Y coordinate fields to move player ship
-- Message - If ship cannot be moved, here will be reason of why
-- RESULT
-- State after move (or not, then return 0) player ship and parameter
-- Message
-- SOURCE
function MoveShip
(X, Y: Integer; Message: in out Unbounded_String) return Natural with
Test_Case => (Name => "Test_MoveShip", Mode => Robustness);
-- ****
-- ****f* SMovement/SMovement.DockShip
-- FUNCTION
-- Dock/Undock ship at base
-- PARAMETERS
-- Docking - If true, ship docks to the base, otherwise false
-- Escape - If true, the player is trying to escape from the base
-- without paying. Default value is False
-- RESULT
-- Empty string if operation was succesfull, otherwise message what goes
-- wrong
-- SOURCE
function DockShip
(Docking: Boolean; Escape: Boolean := False) return String with
Test_Case => (Name => "Test_DockShip", Mode => Robustness);
-- ****
-- ****f* SMovement/SMovement.ChangeShipSpeed
-- FUNCTION
-- Change speed of ship
-- PARAMETERS
-- SpeedValue - New speed for the ship
-- RESULT
-- Empty string if speed was changed, otherwise message what goes wrong
-- SOURCE
function ChangeShipSpeed(SpeedValue: Ship_Speed) return String with
Test_Case => (Name => "Test_ChangeShipSpeed", Mode => Robustness);
-- ****
-- ****f* SMovement/SMovement.RealSpeed
-- FUNCTION
-- Count real ship speed in meters per minute
-- PARAMETERS
-- Ship - Ship which real speed will be counted
-- InfoOnly - If true and ship is docked to the base, count max speed
-- of the ship. Default is false
-- RESULT
-- The real speed of the selected ship or 0 if the ship can't move
-- SOURCE
function RealSpeed
(Ship: Ship_Record; InfoOnly: Boolean := False) return Natural with
Test_Case => (Name => "Test_RealSpeed", Mode => Robustness);
-- ****
-- ****f* SMovement/SMovement.CountFuelNeeded
-- FUNCTION
-- Count amount of fuel needed by player ship to travel
-- RESULT
-- Amount of fuel needed by player ship to travel
-- SOURCE
function CountFuelNeeded return Integer with
Test_Case => (Name => "Test_CountFuelNeeded", Mode => Robustness);
-- ****
-- ****f* SMovement/SMovement.WaitInPlace
-- FUNCTION
-- Use fuel when ship wait in place
-- PARAMETERS
-- Minutes - Amount of passed in-game minutes
-- SOURCE
procedure WaitInPlace(Minutes: Positive) with
Test_Case => (Name => "Test_WaitInPlace", Mode => Robustness);
-- ****
end Ships.Movement;
|
kernel/arch/x86_64/boot.asm | Skipper1931/tinuk | 2 | 14657 | <gh_stars>1-10
DEFAULT REL
SECTION .text
GLOBAL _start
GLOBAL _hang
EXTERN kmain
EXTERN bootboot
EXTERN fb
EXTERN _binary_kernel_drivers_vesa_font_bin_start
EXTERN environment
_start:
mov rax, 1
cpuid ; Call CPUID to get (among other things) the local APIC id for the core
shr ebx, 24 ; Shift the APIC id into BX
cmp bx, [bootboot + 0xC] ; bootboot.bspid
jne _hang ; If we're not the boot CPU, hang
mov rdi, bootboot ; Load pointer to bootboot struct as first param to kmain()
mov rsi, fb ; Load pointer to VESA framebuffer as second param to kmain()
mov rdx, _binary_kernel_drivers_vesa_font_bin_start ; Load pointer to PSF header as third param to kmain()
mov rcx, environment ; Load pointer to environment string as fourth param to kmain()
call kmain
_hang:
cli
hlt
jmp _hang
|
oeis/267/A267540.asm | neoneye/loda-programs | 11 | 245366 | ; A267540: Primes p such that p (mod 3) = p (mod 5).
; Submitted by <NAME>(w2)
; 2,17,31,47,61,107,137,151,167,181,197,211,227,241,257,271,317,331,347,421,467,541,557,571,587,601,617,631,647,661,677,691,751,797,811,827,857,887,947,977,991,1021,1051,1097,1171,1187,1201,1217,1231,1277,1291
mov $2,332202
mov $6,1
lpb $2
add $1,5
mov $3,$6
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
mov $5,$1
add $1,10
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
sub $2,18
mod $5,2
add $5,$1
mov $6,$5
lpe
mov $0,$6
add $0,1
|
asm/masm32/dpack/hidethis/hidethis.asm | dindoliboon/archive | 4 | 162971 | ; #########################################################################
.386
.model flat, stdcall
option casemap :none ; case sensitive
; #########################################################################
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\shell32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\shell32.lib
.data
szShellTray db "Shell_TrayWnd", 0
.data?
hCtl dd ?
; #########################################################################
.code
start:
; #########################################################################
invoke FindWindow, addr szShellTray, NULL
.if eax
mov hCtl, eax
invoke IsWindowVisible, hCtl
.if eax == 0
invoke EnableWindow, hCtl, TRUE
invoke ShowWindow, hCtl, SW_RESTORE
.else
invoke EnableWindow, hCtl, FALSE
invoke ShowWindow, hCtl, SW_HIDE
.endif
.endif
invoke ExitProcess, 0
; #########################################################################
end start
|
src/asm/lib/kernel/rxHandler.asm | EduardoCulau/MIPS_uC | 0 | 23372 | #Handler para o RX.
.eqv ENTER_KEY 0x0D
.text
#Handler da intr do CryptoMessager1
RX_Handler:
#Salva $ra na pilha
addiu $sp, $sp, -28
sw $ra, 0($sp)
sw $s0, 4($sp)
sw $s1, 8($sp)
sw $s2, 12($sp)
sw $s3, 16($sp)
sw $s4, 20($sp)
sw $s5, 24($sp)
#Pega o end do RX e TX.
la $t0, rxAddrArray
la $t1, txAddrArray
lw $s0, 0 ($t0) #End de dados para dar o load.
lw $s1, 0 ($t1) #End de dados para dar store.
la $s2, pegouEnter #end da variavel.
la $s3, systring #End da string de sistema.
li $s4, ENTER_KEY #Valor em hexa do enter.
la $s5, indexString #End do indexador da systring.
#Pega o dado do RX.
lw $t0, 0($s0)
#Verificar se pode sobrescrever na string, ou seja, se o Read ja pegou os dados(enter) da ultima vez.
lw $t1, 0($s2) #'t1' = pegouEnter
beq $t1, $zero, RXH.return # if(pegouEnter){
#Verificar o contador. Se esse for o ultimo byte devemos colocar o '\0'.
lw $s0, 0($s5) #'t2' = indexString
addiu $t9, $zero, SYSTRING_SIZE
addiu $t9, $t9, -1
slt $t9, $s0, $t9 #indexString < (systring_size-1)
bne $t9, $zero, RXH.notLastByte #if( indexString < (systring_size-1) )
#Eh o ultimo byte logo temos de forçar o enter, mesmo que a pes soa nao tenha digitado enter.
addu $t0, $zero, $s4 #'t0' = ENTER
RXH.notLastByte:
#Envira o byte para o TX.
waitReadyTX($s1) #Espera o tx ficar pronto.
sw $t0, 0 ($s1) #Enviou o dado.
#Gerar o endereco da string para colocar o char. systring+counter.
addu $a1, $s3, $s0 #systring[indexString]
#Verificar se eh um enter, assim finalizando a string.
bne $t0, $s4, RXH.notEnter #if('t0' == Enter)
#Coloca '\0' na string.
addu $a0, $zero, $zero #'\0'
jal storeByte
#Zera o indexer, zera o pegouEnter (avisando a read que aconteceu um enter) e retorna.
sw $zero, 0($s5) #indexString = 0;
sw $zero, 0($s2) #pegouEnter = 0;
j RXH.return
RXH.notEnter:
#Coloca char que veio do RX na string.
addu $a0, $zero, $t0
jal storeByte
#Incrementa o indexador.
addiu $s0, $s0, 1
sw $s0, 0($s5) #indexString++;
RXH.return:
#Recupera $ra da pilha
lw $ra, 0($sp)
lw $s0, 4($sp)
lw $s1, 8($sp)
lw $s2, 12($sp)
lw $s3, 16($sp)
lw $s4, 20($sp)
lw $s5, 24($sp)
addiu $sp, $sp, 28
jr $ra #Retorna
.data
#Contador para acessar a systring.
indexString: .word 0
|
programs/oeis/100/A100170.asm | karttu/loda | 0 | 168603 | ; A100170: Structured pentagonal hexacontahedral numbers (vertex structure 10).
; 1,92,444,1228,2615,4776,7882,12104,17613,24580,33176,43572,55939,70448,87270,106576,128537,153324,181108,212060,246351,284152,325634,370968,420325,473876,531792,594244,661403,733440,810526,892832,980529,1073788,1172780,1277676,1388647,1505864,1629498,1759720,1896701,2040612,2191624,2349908,2515635,2688976,2870102,3059184,3256393,3461900,3675876,3898492,4129919,4370328,4619890,4878776,5147157,5425204,5713088,6010980,6319051,6637472,6966414,7306048,7656545,8018076,8390812,8774924,9170583,9577960,9997226,10428552,10872109,11328068,11796600,12277876,12772067,13279344,13799878,14333840,14881401,15442732,16018004,16607388,17211055,17829176,18461922,19109464,19771973,20449620,21142576,21851012,22575099,23315008,24070910,24842976,25631377,26436284,27257868,28096300,28951751,29824392,30714394,31621928,32547165,33490276,34451432,35430804,36428563,37444880,38479926,39533872,40606889,41699148,42810820,43942076,45093087,46264024,47455058,48666360,49898101,51150452,52423584,53717668,55032875,56369376,57727342,59106944,60508353,61931740,63377276,64845132,66335479,67848488,69384330,70943176,72525197,74130564,75759448,77412020,79088451,80788912,82513574,84262608,86036185,87834476,89657652,91505884,93379343,95278200,97202626,99152792,101128869,103131028,105159440,107214276,109295707,111403904,113539038,115701280,117890801,120107772,122352364,124624748,126925095,129253576,131610362,133995624,136409533,138852260,141323976,143824852,146355059,148914768,151504150,154123376,156772617,159452044,162161828,164902140,167673151,170475032,173307954,176172088,179067605,181994676,184953472,187944164,190966923,194021920,197109326,200229312,203382049,206567708,209786460,213038476,216323927,219642984,222995818,226382600,229803501,233258692,236748344,240272628,243831715,247425776,251054982,254719504,258419513,262155180,265926676,269734172,273577839,277457848,281374370,285327576,289317637,293344724,297409008,301510660,305649851,309826752,314041534,318294368,322585425,326914876,331282892,335689644,340135303,344620040,349144026,353707432,358310429,362953188,367635880,372358676,377121747,381925264,386769398,391654320,396580201,401547212,406555524,411605308,416696735,421829976,427005202,432222584,437482293,442784500
mov $1,4
mov $2,$0
mov $7,$0
lpb $2,1
mov $0,5
add $5,3
lpb $0,1
sub $0,1
add $1,$5
add $4,$5
lpe
add $1,$4
sub $2,1
lpe
sub $1,3
mov $3,5
mov $8,$7
lpb $3,1
add $1,$8
sub $3,1
lpe
mov $6,$7
lpb $6,1
sub $6,1
add $9,$8
lpe
mov $3,30
mov $8,$9
lpb $3,1
add $1,$8
sub $3,1
lpe
mov $6,$7
mov $9,0
lpb $6,1
sub $6,1
add $9,$8
lpe
mov $3,26
mov $8,$9
lpb $3,1
add $1,$8
sub $3,1
lpe
|
kernel/tmr.asm | iocoder/upcr | 0 | 246805 | ;###############################################################################
;# File name: KERNEL/TMR.ASM
;# DESCRIPTION: KERNEL TIMER MANAGEMENT
;# AUTHOR: <NAME>.
;###############################################################################
;#
;# UPCR OPERATING SYSTEM FOR X86_64 ARCHITECTURE
;# COPYRIGHT (C) 2021 <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.
;#
;###############################################################################
;###############################################################################
;# INCLUDES #
;###############################################################################
;# COMMON DEFINITIONS USED BY KERNEL
INCLUDE "kernel/macro.inc"
;###############################################################################
;# GLOBALS #
;###############################################################################
;# GLOBAL SYMBOLS
PUBLIC KTMRINIT
PUBLIC KTMRSETUP
PUBLIC KTMRINTR
;###############################################################################
;# TEXT SECTION #
;###############################################################################
;# TEXT SECTION
SEGMENT ".text"
;#-----------------------------------------------------------------------------#
;# KTMRINIT() #
;#-----------------------------------------------------------------------------#
KTMRINIT: ;# PRINT INIT MSG
LEA RDI, [RIP+KTMRNAME]
CALL KCONMOD
LEA RDI, [RIP+KTMRMSG]
CALL KCONSTR
MOV RDI, '\n'
CALL KCONCHR
;# DONE
XOR RAX, RAX
RET
;#-----------------------------------------------------------------------------#
;# KTMRSETUP() #
;#-----------------------------------------------------------------------------#
KTMRSETUP: ;# SCHEDULE TSC INTERRUPT
;#CALL KTSCUS
;# SCHEDULE LAPIC INTERRUPT
;#CALL KLATUS
;# SCHEDULE RTC INTERRUPT
;#CALL KRTCUS
;# SCHEDULE HPET INTERRUPT
;#CALL KHPTUS
;# SCHEDULE PIT INTERRUPT
;#MOV RDI, 0xFFFF
;#CALL KPITUS
;# DONE
XOR RAX, RAX
RET
;#-----------------------------------------------------------------------------#
;# KTMRSYNC() #
;#-----------------------------------------------------------------------------#
KTMRINTR: ;# TSC INTERRUPT
;#CALL KTSCUS
;# LAPIC INTERRUPT
;#CALL KLATUS
;# RTC INTERRUPT
;#CALL KRTCUS
;# HPET INTERRUPT
;#CALL KHPTUS
;# PIT INTERRUPT
;#MOV RDI, 0xFFFF
;#CALL KPITUS
;# DONE
XOR RAX, RAX
RET
;###############################################################################
;# DATA SECTION #
;###############################################################################
;# DATA SECTION
SEGMENT ".data"
;#-----------------------------------------------------------------------------#
;# LOGGING STRINGS #
;#-----------------------------------------------------------------------------#
;# TMR HEADING AND ASCII STRINGS
KTMRNAME: DB "KERNEL TMR\0"
KTMRMSG: DB "TSC IS SELECTED TO BE THE MAIN TIMER.\0"
|
Transynther/x86/_processed/NONE/_zr_xt_/i7-8650U_0xd2_notsx.log_15605_1677.asm | ljhsiun2/medusa | 9 | 165946 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r15
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x1e1bb, %r9
xor $1384, %r11
movl $0x61626364, (%r9)
nop
nop
nop
nop
nop
sub %r15, %r15
lea addresses_WC_ht+0x5893, %rsi
lea addresses_WC_ht+0x8ffb, %rdi
nop
nop
nop
nop
nop
add $41618, %r9
mov $24, %rcx
rep movsq
and $44935, %r9
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r14
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
// Load
lea addresses_A+0x13acf, %rax
nop
nop
sub $23717, %rdx
mov (%rax), %cx
cmp $16430, %rdx
// REPMOV
lea addresses_UC+0x441b, %rsi
lea addresses_WC+0x13b51, %rdi
nop
cmp %r14, %r14
mov $42, %rcx
rep movsw
nop
nop
nop
nop
xor %rcx, %rcx
// Load
lea addresses_PSE+0x7bbb, %rax
clflush (%rax)
nop
nop
nop
nop
cmp $7555, %rcx
mov (%rax), %esi
nop
nop
nop
cmp %r13, %r13
// Faulty Load
lea addresses_A+0x67bb, %rdx
nop
nop
sub %rcx, %rcx
vmovups (%rdx), %ymm6
vextracti128 $1, %ymm6, %xmm6
vpextrq $0, %xmm6, %rax
lea oracles, %r14
and $0xff, %rax
shlq $12, %rax
mov (%r14,%rax,1), %rax
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r14
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WC', 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 10, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}}
{'00': 1, '35': 15604}
00 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35
*/
|
dyncode_zx_romcall_stdstack.asm | imneme/spectrum-dyncode | 1 | 80487 | <reponame>imneme/spectrum-dyncode
SECTION data_compiler
_sp_for_basic:
defw 0
SECTION code_compiler
GLOBAL _dyncode_zx_romcall_stdstack
GLOBAL _zx_romcall_stdstack
GLOBAL _find_sp_for_basic
GLOBAL _jump_hl
SYSVAR_RAMTOP equ $5CB2
;;; _dyncode_zx_romcall_stdstack runs arbitary code that has been
;;; pushed onto the stack, falling through into _zx_romcall_stdstack
;;; (described below) which does the heavy lifting.
;;;
;;; On entry: stack has: .... code .... start, return addr <- TOS
;;; On exit: IX,IY unchanged + whatever the routine leaves in the registers
_dyncode_zx_romcall_stdstack:
ld hl, 2 ; load HL to stack beyond retaddr
add hl, sp ; this is where the dynamic code is
;; fall through
;;; _zx_romcall_stdstack runs code pointed to by HL, preserving the caller's
;;; IX and IY. The code is run with IY and HL' as they were when the program
;;; was started, and also with the stack in its normal below-RAMTOP position,
;;; as various ROM routines would expect. This is the surest way to call into
;;; the ROM if you do not expect errors via RST 8, or are happy for those
;;; errors to terminate the program.
;;;
;;; On entry: HL = Routine to call
;;; BC,BC',DE',AF' = (Optionally) any arguments to the call.
;;; On exit: IX,IY unchanged + whatever the routine leaves in the registers
;;;
;;; Note: The code you call cannot expect to find its arguments on the
;;; stack, because the stack has moved. Stack restoration is
;;; via self-modifying code.
_zx_romcall_stdstack:
push iy ; save ix and iy
push ix
ld (restore_stack+1), sp ; modify later code to restore stack
ex de, hl ; stash routine-to-call in DE for now
ld hl, (_sp_for_basic) ; swizzle the stack to the below-
´ ld a, h ; RAMTOP one, if we don't know where
or l ; that is, figure it out
call z, _find_sp_for_basic ;
ld sp, hl ; install new stack pointer
ex de, hl ; recover routine-to-call back to HL
exx ; time to set regs to make ROM happy
pop hl ; HL' and IY were stored by CRT code
pop iy ; on this stack, so we grab their
push iy ; values while leaving them in place
push hl ;
exx ; that done, switch back from alt regs
call _jump_hl ; call the routine we're supposed to
restore_stack:
ld sp, 0 ; correct SP value via self-mod
pop ix ; restore caller's ix and iy
pop iy
ret
;;; _find_sp_for_basic attempts to determine the correct stack-pointer to use
;;; to call BASIC routines that might expect it to be in the normal position.
;;;
;;; On entry: carry must be clear
;;; On exit: HL=Correct pointer value, also written to _sp_for_basic for
;;; the future.
;;; Smashed: A
;;;
;;; Note: The task would be trivial if the library exported
;;; __sp_or_ret, but since it doesn't, we have to get creative
;;; and search for where it pushed IY to find the right value.
_find_sp_for_basic:
ld hl, (SYSVAR_RAMTOP)
sbc hl, sp
jr nc, sp_under_ramtop
find_loop:
ld a, (hl)
dec hl
cp $5c
jr nz, find_loop
ld a, (hl)
dec hl
cp $3a
jr nz, find_loop
dec hl
ld (_sp_for_basic), hl
ret
sp_under_ramtop:
ld hl, sp
ret
|
src/numbers.ads | python36/d0xfa | 0 | 6371 | <gh_stars>0
with interfaces;
with ada.unchecked_conversion;
with ada.numerics.generic_elementary_functions;
with ada.text_io;
with ada.strings.fixed;
package numbers is
function uint32_to_integer is
new ada.unchecked_conversion(source => interfaces.unsigned_32, target => integer);
subtype byte is interfaces.unsigned_8;
subtype word is interfaces.unsigned_16;
function integer_to_word is
new ada.unchecked_conversion(source => integer, target => word);
use type byte;
use type word;
function words_add (a, b : word) return word;
function words_sub (a, b : word) return word;
function words_mul (a, b : word) return word;
function words_div (a, b : word) return word;
function words_pow (a, b : word) return word;
function words_mod (a, b : word) return word;
function words_or (a, b : word) return word;
function words_and (a, b : word) return word;
function words_xor (a, b : word) return word;
function words_sl (a, b : word) return word;
function words_sr (a, b : word) return word;
function sl (value : byte; amount : natural) return byte renames interfaces.shift_left;
function sr (value : byte; amount : natural) return byte renames interfaces.shift_right;
function sl (value : word; amount : natural) return word renames interfaces.shift_left;
function sr (value : word; amount : natural) return word renames interfaces.shift_right;
procedure inc (p_i : in out integer);
procedure dec (p_i : in out integer);
procedure inc (p_i : in out word);
procedure dec (p_i : in out word);
procedure inc (p_i : in out byte);
procedure dec (p_i : in out byte);
procedure incd (p_i : in out byte);
procedure incd (p_i : in out word);
function incd (p_i : word) return word;
procedure decd (p_i : in out word);
function swpb (w : word) return word;
procedure swpb (w : in out word);
function word_to_integer (w : word) return integer;
function validate_word (str : string) return boolean;
function value (str : string) return word;
procedure void (w : word);
function to_positive (b : boolean; v : positive := 1) return positive;
function to_natural (b : boolean; v : natural := 1) return natural;
function to_word (b : boolean; v : word := 1) return word;
function image (w : word; base : positive; fix_size : boolean := true) return string;
function hex (w : word; fix_size : boolean := true) return string;
function bin (w : word; fix_size : boolean := true) return string;
function odd (w : word) return boolean;
function even (w : word) return boolean;
private
package natural_io is new ada.text_io.integer_io(natural);
package word_func is new ada.numerics.generic_elementary_functions(long_float);
function get_max_image_length (base : positive; val : word := word'last) return positive;
end numbers; |
programs/oeis/157/A157668.asm | karttu/loda | 1 | 101277 | <filename>programs/oeis/157/A157668.asm<gh_stars>1-10
; A157668: a(n) = 729*n^2 - 442*n + 67.
; 354,2099,5302,9963,16082,23659,32694,43187,55138,68547,83414,99739,117522,136763,157462,179619,203234,228307,254838,282827,312274,343179,375542,409363,444642,481379,519574,559227,600338,642907,686934,732419,779362,827763,877622,928939,981714,1035947,1091638,1148787,1207394,1267459,1328982,1391963,1456402,1522299,1589654,1658467,1728738,1800467,1873654,1948299,2024402,2101963,2180982,2261459,2343394,2426787,2511638,2597947,2685714,2774939,2865622,2957763,3051362,3146419,3242934,3340907,3440338,3541227,3643574,3747379,3852642,3959363,4067542,4177179,4288274,4400827,4514838,4630307,4747234,4865619,4985462,5106763,5229522,5353739,5479414,5606547,5735138,5865187,5996694,6129659,6264082,6399963,6537302,6676099,6816354,6958067,7101238,7245867,7391954,7539499,7688502,7838963,7990882,8144259,8299094,8455387,8613138,8772347,8933014,9095139,9258722,9423763,9590262,9758219,9927634,10098507,10270838,10444627,10619874,10796579,10974742,11154363,11335442,11517979,11701974,11887427,12074338,12262707,12452534,12643819,12836562,13030763,13226422,13423539,13622114,13822147,14023638,14226587,14430994,14636859,14844182,15052963,15263202,15474899,15688054,15902667,16118738,16336267,16555254,16775699,16997602,17220963,17445782,17672059,17899794,18128987,18359638,18591747,18825314,19060339,19296822,19534763,19774162,20015019,20257334,20501107,20746338,20993027,21241174,21490779,21741842,21994363,22248342,22503779,22760674,23019027,23278838,23540107,23802834,24067019,24332662,24599763,24868322,25138339,25409814,25682747,25957138,26232987,26510294,26789059,27069282,27350963,27634102,27918699,28204754,28492267,28781238,29071667,29363554,29656899,29951702,30247963,30545682,30844859,31145494,31447587,31751138,32056147,32362614,32670539,32979922,33290763,33603062,33916819,34232034,34548707,34866838,35186427,35507474,35829979,36153942,36479363,36806242,37134579,37464374,37795627,38128338,38462507,38798134,39135219,39473762,39813763,40155222,40498139,40842514,41188347,41535638,41884387,42234594,42586259,42939382,43293963,43650002,44007499,44366454,44726867,45088738,45452067
mov $4,$0
add $0,1
mov $3,9
mov $5,9
mul $5,$0
sub $5,3
mul $3,$5
add $3,4
mul $3,$5
mov $1,$3
add $1,6
mov $2,$4
mul $2,8
add $1,$2
|
third_party/webrtc/src/chromium/src/third_party/libjpeg_turbo/simd/jimmxred.asm | bopopescu/webrtc-streaming-node | 27 | 92149 | ;
; jimmxred.asm - reduced-size IDCT (MMX)
;
; Copyright 2009 Pierre Ossman <<EMAIL>> for Cendio AB
;
; Based on
; x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
; This file should be assembled with NASM (Netwide Assembler),
; can *not* be assembled with Microsoft's MASM or any compatible
; assembler (including Borland's Turbo Assembler).
; NASM is available from http://nasm.sourceforge.net/ or
; http://sourceforge.net/project/showfiles.php?group_id=6208
;
; This file contains inverse-DCT routines that produce reduced-size
; output: either 4x4 or 2x2 pixels from an 8x8 DCT block.
; The following code is based directly on the IJG's original jidctred.c;
; see the jidctred.c for more details.
;
; [TAB8]
%include "jsimdext.inc"
%include "jdct.inc"
; --------------------------------------------------------------------------
%define CONST_BITS 13
%define PASS1_BITS 2
%define DESCALE_P1_4 (CONST_BITS-PASS1_BITS+1)
%define DESCALE_P2_4 (CONST_BITS+PASS1_BITS+3+1)
%define DESCALE_P1_2 (CONST_BITS-PASS1_BITS+2)
%define DESCALE_P2_2 (CONST_BITS+PASS1_BITS+3+2)
%if CONST_BITS == 13
F_0_211 equ 1730 ; FIX(0.211164243)
F_0_509 equ 4176 ; FIX(0.509795579)
F_0_601 equ 4926 ; FIX(0.601344887)
F_0_720 equ 5906 ; FIX(0.720959822)
F_0_765 equ 6270 ; FIX(0.765366865)
F_0_850 equ 6967 ; FIX(0.850430095)
F_0_899 equ 7373 ; FIX(0.899976223)
F_1_061 equ 8697 ; FIX(1.061594337)
F_1_272 equ 10426 ; FIX(1.272758580)
F_1_451 equ 11893 ; FIX(1.451774981)
F_1_847 equ 15137 ; FIX(1.847759065)
F_2_172 equ 17799 ; FIX(2.172734803)
F_2_562 equ 20995 ; FIX(2.562915447)
F_3_624 equ 29692 ; FIX(3.624509785)
%else
; NASM cannot do compile-time arithmetic on floating-point constants.
%define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n))
F_0_211 equ DESCALE( 226735879,30-CONST_BITS) ; FIX(0.211164243)
F_0_509 equ DESCALE( 547388834,30-CONST_BITS) ; FIX(0.509795579)
F_0_601 equ DESCALE( 645689155,30-CONST_BITS) ; FIX(0.601344887)
F_0_720 equ DESCALE( 774124714,30-CONST_BITS) ; FIX(0.720959822)
F_0_765 equ DESCALE( 821806413,30-CONST_BITS) ; FIX(0.765366865)
F_0_850 equ DESCALE( 913142361,30-CONST_BITS) ; FIX(0.850430095)
F_0_899 equ DESCALE( 966342111,30-CONST_BITS) ; FIX(0.899976223)
F_1_061 equ DESCALE(1139878239,30-CONST_BITS) ; FIX(1.061594337)
F_1_272 equ DESCALE(1366614119,30-CONST_BITS) ; FIX(1.272758580)
F_1_451 equ DESCALE(1558831516,30-CONST_BITS) ; FIX(1.451774981)
F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065)
F_2_172 equ DESCALE(2332956230,30-CONST_BITS) ; FIX(2.172734803)
F_2_562 equ DESCALE(2751909506,30-CONST_BITS) ; FIX(2.562915447)
F_3_624 equ DESCALE(3891787747,30-CONST_BITS) ; FIX(3.624509785)
%endif
; --------------------------------------------------------------------------
SECTION SEG_CONST
alignz 16
global EXTN(jconst_idct_red_mmx) PRIVATE
EXTN(jconst_idct_red_mmx):
PW_F184_MF076 times 2 dw F_1_847,-F_0_765
PW_F256_F089 times 2 dw F_2_562, F_0_899
PW_F106_MF217 times 2 dw F_1_061,-F_2_172
PW_MF060_MF050 times 2 dw -F_0_601,-F_0_509
PW_F145_MF021 times 2 dw F_1_451,-F_0_211
PW_F362_MF127 times 2 dw F_3_624,-F_1_272
PW_F085_MF072 times 2 dw F_0_850,-F_0_720
PD_DESCALE_P1_4 times 2 dd 1 << (DESCALE_P1_4-1)
PD_DESCALE_P2_4 times 2 dd 1 << (DESCALE_P2_4-1)
PD_DESCALE_P1_2 times 2 dd 1 << (DESCALE_P1_2-1)
PD_DESCALE_P2_2 times 2 dd 1 << (DESCALE_P2_2-1)
PB_CENTERJSAMP times 8 db CENTERJSAMPLE
alignz 16
; --------------------------------------------------------------------------
SECTION SEG_TEXT
BITS 32
;
; Perform dequantization and inverse DCT on one block of coefficients,
; producing a reduced-size 4x4 output block.
;
; GLOBAL(void)
; jsimd_idct_4x4_mmx (void * dct_table, JCOEFPTR coef_block,
; JSAMPARRAY output_buf, JDIMENSION output_col)
;
%define dct_table(b) (b)+8 ; void * dct_table
%define coef_block(b) (b)+12 ; JCOEFPTR coef_block
%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf
%define output_col(b) (b)+20 ; JDIMENSION output_col
%define original_ebp ebp+0
%define wk(i) ebp-(WK_NUM-(i))*SIZEOF_MMWORD ; mmword wk[WK_NUM]
%define WK_NUM 2
%define workspace wk(0)-DCTSIZE2*SIZEOF_JCOEF
; JCOEF workspace[DCTSIZE2]
align 16
global EXTN(jsimd_idct_4x4_mmx) PRIVATE
EXTN(jsimd_idct_4x4_mmx):
push ebp
mov eax,esp ; eax = original ebp
sub esp, byte 4
and esp, byte (-SIZEOF_MMWORD) ; align to 64 bits
mov [esp],eax
mov ebp,esp ; ebp = aligned ebp
lea esp, [workspace]
pushpic ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
get_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input, store into work array.
; mov eax, [original_ebp]
mov edx, POINTER [dct_table(eax)] ; quantptr
mov esi, JCOEFPTR [coef_block(eax)] ; inptr
lea edi, [workspace] ; JCOEF * wsptr
mov ecx, DCTSIZE/4 ; ctr
alignx 16,7
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_4X4_MMX
mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
jnz short .columnDCT
movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
movq mm1, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
por mm0, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
por mm1, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
por mm0, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
por mm1, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
por mm0,mm1
packsswb mm0,mm0
movd eax,mm0
test eax,eax
jnz short .columnDCT
; -- AC terms all zero
movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
pmullw mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
psllw mm0,PASS1_BITS
movq mm2,mm0 ; mm0=in0=(00 01 02 03)
punpcklwd mm0,mm0 ; mm0=(00 00 01 01)
punpckhwd mm2,mm2 ; mm2=(02 02 03 03)
movq mm1,mm0
punpckldq mm0,mm0 ; mm0=(00 00 00 00)
punpckhdq mm1,mm1 ; mm1=(01 01 01 01)
movq mm3,mm2
punpckldq mm2,mm2 ; mm2=(02 02 02 02)
punpckhdq mm3,mm3 ; mm3=(03 03 03 03)
movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0
movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm1
movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm2
movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3
jmp near .nextcolumn
alignx 16,7
%endif
.columnDCT:
; -- Odd part
movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
movq mm1, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
pmullw mm0, MMWORD [MMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
pmullw mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
movq mm2, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
pmullw mm2, MMWORD [MMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
pmullw mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
movq mm4,mm0
movq mm5,mm0
punpcklwd mm4,mm1
punpckhwd mm5,mm1
movq mm0,mm4
movq mm1,mm5
pmaddwd mm4,[GOTOFF(ebx,PW_F256_F089)] ; mm4=(tmp2L)
pmaddwd mm5,[GOTOFF(ebx,PW_F256_F089)] ; mm5=(tmp2H)
pmaddwd mm0,[GOTOFF(ebx,PW_F106_MF217)] ; mm0=(tmp0L)
pmaddwd mm1,[GOTOFF(ebx,PW_F106_MF217)] ; mm1=(tmp0H)
movq mm6,mm2
movq mm7,mm2
punpcklwd mm6,mm3
punpckhwd mm7,mm3
movq mm2,mm6
movq mm3,mm7
pmaddwd mm6,[GOTOFF(ebx,PW_MF060_MF050)] ; mm6=(tmp2L)
pmaddwd mm7,[GOTOFF(ebx,PW_MF060_MF050)] ; mm7=(tmp2H)
pmaddwd mm2,[GOTOFF(ebx,PW_F145_MF021)] ; mm2=(tmp0L)
pmaddwd mm3,[GOTOFF(ebx,PW_F145_MF021)] ; mm3=(tmp0H)
paddd mm6,mm4 ; mm6=tmp2L
paddd mm7,mm5 ; mm7=tmp2H
paddd mm2,mm0 ; mm2=tmp0L
paddd mm3,mm1 ; mm3=tmp0H
movq MMWORD [wk(0)], mm2 ; wk(0)=tmp0L
movq MMWORD [wk(1)], mm3 ; wk(1)=tmp0H
; -- Even part
movq mm4, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
movq mm5, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
movq mm0, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
pmullw mm4, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
pmullw mm5, MMWORD [MMBLOCK(2,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
pmullw mm0, MMWORD [MMBLOCK(6,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
pxor mm1,mm1
pxor mm2,mm2
punpcklwd mm1,mm4 ; mm1=tmp0L
punpckhwd mm2,mm4 ; mm2=tmp0H
psrad mm1,(16-CONST_BITS-1) ; psrad mm1,16 & pslld mm1,CONST_BITS+1
psrad mm2,(16-CONST_BITS-1) ; psrad mm2,16 & pslld mm2,CONST_BITS+1
movq mm3,mm5 ; mm5=in2=z2
punpcklwd mm5,mm0 ; mm0=in6=z3
punpckhwd mm3,mm0
pmaddwd mm5,[GOTOFF(ebx,PW_F184_MF076)] ; mm5=tmp2L
pmaddwd mm3,[GOTOFF(ebx,PW_F184_MF076)] ; mm3=tmp2H
movq mm4,mm1
movq mm0,mm2
paddd mm1,mm5 ; mm1=tmp10L
paddd mm2,mm3 ; mm2=tmp10H
psubd mm4,mm5 ; mm4=tmp12L
psubd mm0,mm3 ; mm0=tmp12H
; -- Final output stage
movq mm5,mm1
movq mm3,mm2
paddd mm1,mm6 ; mm1=data0L
paddd mm2,mm7 ; mm2=data0H
psubd mm5,mm6 ; mm5=data3L
psubd mm3,mm7 ; mm3=data3H
movq mm6,[GOTOFF(ebx,PD_DESCALE_P1_4)] ; mm6=[PD_DESCALE_P1_4]
paddd mm1,mm6
paddd mm2,mm6
psrad mm1,DESCALE_P1_4
psrad mm2,DESCALE_P1_4
paddd mm5,mm6
paddd mm3,mm6
psrad mm5,DESCALE_P1_4
psrad mm3,DESCALE_P1_4
packssdw mm1,mm2 ; mm1=data0=(00 01 02 03)
packssdw mm5,mm3 ; mm5=data3=(30 31 32 33)
movq mm7, MMWORD [wk(0)] ; mm7=tmp0L
movq mm6, MMWORD [wk(1)] ; mm6=tmp0H
movq mm2,mm4
movq mm3,mm0
paddd mm4,mm7 ; mm4=data1L
paddd mm0,mm6 ; mm0=data1H
psubd mm2,mm7 ; mm2=data2L
psubd mm3,mm6 ; mm3=data2H
movq mm7,[GOTOFF(ebx,PD_DESCALE_P1_4)] ; mm7=[PD_DESCALE_P1_4]
paddd mm4,mm7
paddd mm0,mm7
psrad mm4,DESCALE_P1_4
psrad mm0,DESCALE_P1_4
paddd mm2,mm7
paddd mm3,mm7
psrad mm2,DESCALE_P1_4
psrad mm3,DESCALE_P1_4
packssdw mm4,mm0 ; mm4=data1=(10 11 12 13)
packssdw mm2,mm3 ; mm2=data2=(20 21 22 23)
movq mm6,mm1 ; transpose coefficients(phase 1)
punpcklwd mm1,mm4 ; mm1=(00 10 01 11)
punpckhwd mm6,mm4 ; mm6=(02 12 03 13)
movq mm7,mm2 ; transpose coefficients(phase 1)
punpcklwd mm2,mm5 ; mm2=(20 30 21 31)
punpckhwd mm7,mm5 ; mm7=(22 32 23 33)
movq mm0,mm1 ; transpose coefficients(phase 2)
punpckldq mm1,mm2 ; mm1=(00 10 20 30)
punpckhdq mm0,mm2 ; mm0=(01 11 21 31)
movq mm3,mm6 ; transpose coefficients(phase 2)
punpckldq mm6,mm7 ; mm6=(02 12 22 32)
punpckhdq mm3,mm7 ; mm3=(03 13 23 33)
movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm1
movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm0
movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm6
movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3
.nextcolumn:
add esi, byte 4*SIZEOF_JCOEF ; coef_block
add edx, byte 4*SIZEOF_ISLOW_MULT_TYPE ; quantptr
add edi, byte 4*DCTSIZE*SIZEOF_JCOEF ; wsptr
dec ecx ; ctr
jnz near .columnloop
; ---- Pass 2: process rows from work array, store into output array.
mov eax, [original_ebp]
lea esi, [workspace] ; JCOEF * wsptr
mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
mov eax, JDIMENSION [output_col(eax)]
; -- Odd part
movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
movq mm1, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
movq mm2, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
movq mm4,mm0
movq mm5,mm0
punpcklwd mm4,mm1
punpckhwd mm5,mm1
movq mm0,mm4
movq mm1,mm5
pmaddwd mm4,[GOTOFF(ebx,PW_F256_F089)] ; mm4=(tmp2L)
pmaddwd mm5,[GOTOFF(ebx,PW_F256_F089)] ; mm5=(tmp2H)
pmaddwd mm0,[GOTOFF(ebx,PW_F106_MF217)] ; mm0=(tmp0L)
pmaddwd mm1,[GOTOFF(ebx,PW_F106_MF217)] ; mm1=(tmp0H)
movq mm6,mm2
movq mm7,mm2
punpcklwd mm6,mm3
punpckhwd mm7,mm3
movq mm2,mm6
movq mm3,mm7
pmaddwd mm6,[GOTOFF(ebx,PW_MF060_MF050)] ; mm6=(tmp2L)
pmaddwd mm7,[GOTOFF(ebx,PW_MF060_MF050)] ; mm7=(tmp2H)
pmaddwd mm2,[GOTOFF(ebx,PW_F145_MF021)] ; mm2=(tmp0L)
pmaddwd mm3,[GOTOFF(ebx,PW_F145_MF021)] ; mm3=(tmp0H)
paddd mm6,mm4 ; mm6=tmp2L
paddd mm7,mm5 ; mm7=tmp2H
paddd mm2,mm0 ; mm2=tmp0L
paddd mm3,mm1 ; mm3=tmp0H
movq MMWORD [wk(0)], mm2 ; wk(0)=tmp0L
movq MMWORD [wk(1)], mm3 ; wk(1)=tmp0H
; -- Even part
movq mm4, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
movq mm5, MMWORD [MMBLOCK(2,0,esi,SIZEOF_JCOEF)]
movq mm0, MMWORD [MMBLOCK(6,0,esi,SIZEOF_JCOEF)]
pxor mm1,mm1
pxor mm2,mm2
punpcklwd mm1,mm4 ; mm1=tmp0L
punpckhwd mm2,mm4 ; mm2=tmp0H
psrad mm1,(16-CONST_BITS-1) ; psrad mm1,16 & pslld mm1,CONST_BITS+1
psrad mm2,(16-CONST_BITS-1) ; psrad mm2,16 & pslld mm2,CONST_BITS+1
movq mm3,mm5 ; mm5=in2=z2
punpcklwd mm5,mm0 ; mm0=in6=z3
punpckhwd mm3,mm0
pmaddwd mm5,[GOTOFF(ebx,PW_F184_MF076)] ; mm5=tmp2L
pmaddwd mm3,[GOTOFF(ebx,PW_F184_MF076)] ; mm3=tmp2H
movq mm4,mm1
movq mm0,mm2
paddd mm1,mm5 ; mm1=tmp10L
paddd mm2,mm3 ; mm2=tmp10H
psubd mm4,mm5 ; mm4=tmp12L
psubd mm0,mm3 ; mm0=tmp12H
; -- Final output stage
movq mm5,mm1
movq mm3,mm2
paddd mm1,mm6 ; mm1=data0L
paddd mm2,mm7 ; mm2=data0H
psubd mm5,mm6 ; mm5=data3L
psubd mm3,mm7 ; mm3=data3H
movq mm6,[GOTOFF(ebx,PD_DESCALE_P2_4)] ; mm6=[PD_DESCALE_P2_4]
paddd mm1,mm6
paddd mm2,mm6
psrad mm1,DESCALE_P2_4
psrad mm2,DESCALE_P2_4
paddd mm5,mm6
paddd mm3,mm6
psrad mm5,DESCALE_P2_4
psrad mm3,DESCALE_P2_4
packssdw mm1,mm2 ; mm1=data0=(00 10 20 30)
packssdw mm5,mm3 ; mm5=data3=(03 13 23 33)
movq mm7, MMWORD [wk(0)] ; mm7=tmp0L
movq mm6, MMWORD [wk(1)] ; mm6=tmp0H
movq mm2,mm4
movq mm3,mm0
paddd mm4,mm7 ; mm4=data1L
paddd mm0,mm6 ; mm0=data1H
psubd mm2,mm7 ; mm2=data2L
psubd mm3,mm6 ; mm3=data2H
movq mm7,[GOTOFF(ebx,PD_DESCALE_P2_4)] ; mm7=[PD_DESCALE_P2_4]
paddd mm4,mm7
paddd mm0,mm7
psrad mm4,DESCALE_P2_4
psrad mm0,DESCALE_P2_4
paddd mm2,mm7
paddd mm3,mm7
psrad mm2,DESCALE_P2_4
psrad mm3,DESCALE_P2_4
packssdw mm4,mm0 ; mm4=data1=(01 11 21 31)
packssdw mm2,mm3 ; mm2=data2=(02 12 22 32)
movq mm6,[GOTOFF(ebx,PB_CENTERJSAMP)] ; mm6=[PB_CENTERJSAMP]
packsswb mm1,mm2 ; mm1=(00 10 20 30 02 12 22 32)
packsswb mm4,mm5 ; mm4=(01 11 21 31 03 13 23 33)
paddb mm1,mm6
paddb mm4,mm6
movq mm7,mm1 ; transpose coefficients(phase 1)
punpcklbw mm1,mm4 ; mm1=(00 01 10 11 20 21 30 31)
punpckhbw mm7,mm4 ; mm7=(02 03 12 13 22 23 32 33)
movq mm0,mm1 ; transpose coefficients(phase 2)
punpcklwd mm1,mm7 ; mm1=(00 01 02 03 10 11 12 13)
punpckhwd mm0,mm7 ; mm0=(20 21 22 23 30 31 32 33)
mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
mov esi, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
movd DWORD [edx+eax*SIZEOF_JSAMPLE], mm1
movd DWORD [esi+eax*SIZEOF_JSAMPLE], mm0
psrlq mm1,4*BYTE_BIT
psrlq mm0,4*BYTE_BIT
mov edx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
mov esi, JSAMPROW [edi+3*SIZEOF_JSAMPROW]
movd DWORD [edx+eax*SIZEOF_JSAMPLE], mm1
movd DWORD [esi+eax*SIZEOF_JSAMPLE], mm0
emms ; empty MMX state
pop edi
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
poppic ebx
mov esp,ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
ret
; --------------------------------------------------------------------------
;
; Perform dequantization and inverse DCT on one block of coefficients,
; producing a reduced-size 2x2 output block.
;
; GLOBAL(void)
; jsimd_idct_2x2_mmx (void * dct_table, JCOEFPTR coef_block,
; JSAMPARRAY output_buf, JDIMENSION output_col)
;
%define dct_table(b) (b)+8 ; void * dct_table
%define coef_block(b) (b)+12 ; JCOEFPTR coef_block
%define output_buf(b) (b)+16 ; JSAMPARRAY output_buf
%define output_col(b) (b)+20 ; JDIMENSION output_col
align 16
global EXTN(jsimd_idct_2x2_mmx) PRIVATE
EXTN(jsimd_idct_2x2_mmx):
push ebp
mov ebp,esp
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
get_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input.
mov edx, POINTER [dct_table(ebp)] ; quantptr
mov esi, JCOEFPTR [coef_block(ebp)] ; inptr
; | input: | result: |
; | 00 01 ** 03 ** 05 ** 07 | |
; | 10 11 ** 13 ** 15 ** 17 | |
; | ** ** ** ** ** ** ** ** | |
; | 30 31 ** 33 ** 35 ** 37 | A0 A1 A3 A5 A7 |
; | ** ** ** ** ** ** ** ** | B0 B1 B3 B5 B7 |
; | 50 51 ** 53 ** 55 ** 57 | |
; | ** ** ** ** ** ** ** ** | |
; | 70 71 ** 73 ** 75 ** 77 | |
; -- Odd part
movq mm0, MMWORD [MMBLOCK(1,0,esi,SIZEOF_JCOEF)]
movq mm1, MMWORD [MMBLOCK(3,0,esi,SIZEOF_JCOEF)]
pmullw mm0, MMWORD [MMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
pmullw mm1, MMWORD [MMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
movq mm2, MMWORD [MMBLOCK(5,0,esi,SIZEOF_JCOEF)]
movq mm3, MMWORD [MMBLOCK(7,0,esi,SIZEOF_JCOEF)]
pmullw mm2, MMWORD [MMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
pmullw mm3, MMWORD [MMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
; mm0=(10 11 ** 13), mm1=(30 31 ** 33)
; mm2=(50 51 ** 53), mm3=(70 71 ** 73)
pcmpeqd mm7,mm7
pslld mm7,WORD_BIT ; mm7={0x0000 0xFFFF 0x0000 0xFFFF}
movq mm4,mm0 ; mm4=(10 11 ** 13)
movq mm5,mm2 ; mm5=(50 51 ** 53)
punpcklwd mm4,mm1 ; mm4=(10 30 11 31)
punpcklwd mm5,mm3 ; mm5=(50 70 51 71)
pmaddwd mm4,[GOTOFF(ebx,PW_F362_MF127)]
pmaddwd mm5,[GOTOFF(ebx,PW_F085_MF072)]
psrld mm0,WORD_BIT ; mm0=(11 -- 13 --)
pand mm1,mm7 ; mm1=(-- 31 -- 33)
psrld mm2,WORD_BIT ; mm2=(51 -- 53 --)
pand mm3,mm7 ; mm3=(-- 71 -- 73)
por mm0,mm1 ; mm0=(11 31 13 33)
por mm2,mm3 ; mm2=(51 71 53 73)
pmaddwd mm0,[GOTOFF(ebx,PW_F362_MF127)]
pmaddwd mm2,[GOTOFF(ebx,PW_F085_MF072)]
paddd mm4,mm5 ; mm4=tmp0[col0 col1]
movq mm6, MMWORD [MMBLOCK(1,1,esi,SIZEOF_JCOEF)]
movq mm1, MMWORD [MMBLOCK(3,1,esi,SIZEOF_JCOEF)]
pmullw mm6, MMWORD [MMBLOCK(1,1,edx,SIZEOF_ISLOW_MULT_TYPE)]
pmullw mm1, MMWORD [MMBLOCK(3,1,edx,SIZEOF_ISLOW_MULT_TYPE)]
movq mm3, MMWORD [MMBLOCK(5,1,esi,SIZEOF_JCOEF)]
movq mm5, MMWORD [MMBLOCK(7,1,esi,SIZEOF_JCOEF)]
pmullw mm3, MMWORD [MMBLOCK(5,1,edx,SIZEOF_ISLOW_MULT_TYPE)]
pmullw mm5, MMWORD [MMBLOCK(7,1,edx,SIZEOF_ISLOW_MULT_TYPE)]
; mm6=(** 15 ** 17), mm1=(** 35 ** 37)
; mm3=(** 55 ** 57), mm5=(** 75 ** 77)
psrld mm6,WORD_BIT ; mm6=(15 -- 17 --)
pand mm1,mm7 ; mm1=(-- 35 -- 37)
psrld mm3,WORD_BIT ; mm3=(55 -- 57 --)
pand mm5,mm7 ; mm5=(-- 75 -- 77)
por mm6,mm1 ; mm6=(15 35 17 37)
por mm3,mm5 ; mm3=(55 75 57 77)
pmaddwd mm6,[GOTOFF(ebx,PW_F362_MF127)]
pmaddwd mm3,[GOTOFF(ebx,PW_F085_MF072)]
paddd mm0,mm2 ; mm0=tmp0[col1 col3]
paddd mm6,mm3 ; mm6=tmp0[col5 col7]
; -- Even part
movq mm1, MMWORD [MMBLOCK(0,0,esi,SIZEOF_JCOEF)]
movq mm5, MMWORD [MMBLOCK(0,1,esi,SIZEOF_JCOEF)]
pmullw mm1, MMWORD [MMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
pmullw mm5, MMWORD [MMBLOCK(0,1,edx,SIZEOF_ISLOW_MULT_TYPE)]
; mm1=(00 01 ** 03), mm5=(** 05 ** 07)
movq mm2,mm1 ; mm2=(00 01 ** 03)
pslld mm1,WORD_BIT ; mm1=(-- 00 -- **)
psrad mm1,(WORD_BIT-CONST_BITS-2) ; mm1=tmp10[col0 ****]
pand mm2,mm7 ; mm2=(-- 01 -- 03)
pand mm5,mm7 ; mm5=(-- 05 -- 07)
psrad mm2,(WORD_BIT-CONST_BITS-2) ; mm2=tmp10[col1 col3]
psrad mm5,(WORD_BIT-CONST_BITS-2) ; mm5=tmp10[col5 col7]
; -- Final output stage
movq mm3,mm1
paddd mm1,mm4 ; mm1=data0[col0 ****]=(A0 **)
psubd mm3,mm4 ; mm3=data1[col0 ****]=(B0 **)
punpckldq mm1,mm3 ; mm1=(A0 B0)
movq mm7,[GOTOFF(ebx,PD_DESCALE_P1_2)] ; mm7=[PD_DESCALE_P1_2]
movq mm4,mm2
movq mm3,mm5
paddd mm2,mm0 ; mm2=data0[col1 col3]=(A1 A3)
paddd mm5,mm6 ; mm5=data0[col5 col7]=(A5 A7)
psubd mm4,mm0 ; mm4=data1[col1 col3]=(B1 B3)
psubd mm3,mm6 ; mm3=data1[col5 col7]=(B5 B7)
paddd mm1,mm7
psrad mm1,DESCALE_P1_2
paddd mm2,mm7
paddd mm5,mm7
psrad mm2,DESCALE_P1_2
psrad mm5,DESCALE_P1_2
paddd mm4,mm7
paddd mm3,mm7
psrad mm4,DESCALE_P1_2
psrad mm3,DESCALE_P1_2
; ---- Pass 2: process rows, store into output array.
mov edi, JSAMPARRAY [output_buf(ebp)] ; (JSAMPROW *)
mov eax, JDIMENSION [output_col(ebp)]
; | input:| result:|
; | A0 B0 | |
; | A1 B1 | C0 C1 |
; | A3 B3 | D0 D1 |
; | A5 B5 | |
; | A7 B7 | |
; -- Odd part
packssdw mm2,mm4 ; mm2=(A1 A3 B1 B3)
packssdw mm5,mm3 ; mm5=(A5 A7 B5 B7)
pmaddwd mm2,[GOTOFF(ebx,PW_F362_MF127)]
pmaddwd mm5,[GOTOFF(ebx,PW_F085_MF072)]
paddd mm2,mm5 ; mm2=tmp0[row0 row1]
; -- Even part
pslld mm1,(CONST_BITS+2) ; mm1=tmp10[row0 row1]
; -- Final output stage
movq mm0,[GOTOFF(ebx,PD_DESCALE_P2_2)] ; mm0=[PD_DESCALE_P2_2]
movq mm6,mm1
paddd mm1,mm2 ; mm1=data0[row0 row1]=(C0 C1)
psubd mm6,mm2 ; mm6=data1[row0 row1]=(D0 D1)
paddd mm1,mm0
paddd mm6,mm0
psrad mm1,DESCALE_P2_2
psrad mm6,DESCALE_P2_2
movq mm7,mm1 ; transpose coefficients
punpckldq mm1,mm6 ; mm1=(C0 D0)
punpckhdq mm7,mm6 ; mm7=(C1 D1)
packssdw mm1,mm7 ; mm1=(C0 D0 C1 D1)
packsswb mm1,mm1 ; mm1=(C0 D0 C1 D1 C0 D0 C1 D1)
paddb mm1,[GOTOFF(ebx,PB_CENTERJSAMP)]
movd ecx,mm1
movd ebx,mm1 ; ebx=(C0 D0 C1 D1)
shr ecx,2*BYTE_BIT ; ecx=(C1 D1 -- --)
mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
mov esi, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
mov WORD [edx+eax*SIZEOF_JSAMPLE], bx
mov WORD [esi+eax*SIZEOF_JSAMPLE], cx
emms ; empty MMX state
pop edi
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
pop ebx
pop ebp
ret
; For some reason, the OS X linker does not honor the request to align the
; segment unless we do this.
align 16
|
game.asm | celerizer/Party_F | 0 | 9653 | ; =============================================================================
; <NAME> (working title)
; =============================================================================
processor f8
; =============================================================================
; Constants
; =============================================================================
; -----------------------------------------------------------------------------
; BIOS Calls
; -----------------------------------------------------------------------------
clrscrn = $00D0 ; uses r31
delay = $008F
pushk = $0107 ; used to allow more subroutine stack space
popk = $011E
drawchar = $0679
; -----------------------------------------------------------------------------
; Color Definitions
; -----------------------------------------------------------------------------
DRAWCHAR_CLEAR = $00
DRAWCHAR_BLUE = $40
DRAWCHAR_RED = $80
DRAWCHAR_GREEN = $C0
; =============================================================================
; Program Code
; =============================================================================
; -----------------------------------------------------------------------------
; Game Entrypoint
; -----------------------------------------------------------------------------
org $800
cartridgeStart:
.byte $55, $55 ; cartridge header
cartridgeEntry:
lis 0 ; init the h/w
outs 1
outs 4
outs 5
outs 0
lisu 4 ; r32 = complement flag
lisl 0
lr S, A
li $c6 ; set to three color, grey background
lr 3, A ; clear screen to grey
pi clrscrn ;
jmp board_load
; -----------------------------------------------------------------------------
; Game Loop
; -----------------------------------------------------------------------------
mainLoop:
jmp rng_update
; -----------------------------------------------------------------------------
; Random Number Generation
; -----------------------------------------------------------------------------
; Not really random, more like a very fast timer
; -----------------------------------------------------------------------------
RNG_MIN = 1
RNG_MAX = 9
rng_reset:
li RNG_MIN
br rng_update2
rng_update:
lisu 4 ; RNG seed is stored in r33
lisl 1
lr A, S
inc
ci RNG_MAX + 1 ; Only allow values 1-9 (add 10?)
bnz rng_update2 ; If RNG exceeds maximum, set back to minimum and return
br rng_reset
rng_update2:
lr S, A ; Write the incremented seed back to r33
ai DRAWCHAR_BLUE ; Add blue color to result in r0 for drawchar
lr 0, A
li 80
lr 1, A
li 80
lr 2, A
pi drawchar
jmp input
; -----------------------------------------------------------------------------
; Input
; -----------------------------------------------------------------------------
input:
clr
outs 0
outs 1
ins 1
com
bnz pressed
jmp mainLoop
pressed:
dci sfx_roll
pi playSong
jmp mainLoop
; -----------------------------------------------------------------------------
; Board Loading
; -----------------------------------------------------------------------------
; modifies: r5, DC0, DC1
; jumps to the multiblit code, which modifies r1-4
; -----------------------------------------------------------------------------
board_return:
jmp mainLoop
board_load:
; TODO: is messing with isar necessary?
lisu 0
lisl 1
dci board
board_load_space:
; all spaces have these dimensions
lis 5
lr 3, A
lis 4
lr 4, A
; load space type into r5. if it's -1, return
lm
ci $FF
bz board_return
lr 5, A
; load space position
lm
lr 1, A
lm
lr 2, A
; swap board data iterator into DC1 and load a gfx pointer
xdc
dci gfx_space_blue
pi multiblit
; get our position in board data back from DC1
xdc
br board_load_space
; =============================================================================
; Dependencies
; =============================================================================
include "multiblit.asm"
include "playsong.asm"
; =============================================================================
; Game Data
; =============================================================================
; -----------------------------------------------------------------------------
; Graphics Data
; -----------------------------------------------------------------------------
gfx_space_blue:
.byte $EA
.byte $EA
.byte $A2
.byte $A3
.byte $03
gfx_space_red:
.byte $D5
.byte $D5
.byte $51
.byte $53
.byte $03
gfx_player_piece:
.byte %00100000
.byte %01110000
.byte %00100000
.byte %00100000
.byte %01110000
; -----------------------------------------------------------------------------
; Music Data
; -----------------------------------------------------------------------------
sfx_roll:
.byte 5, 69, 6, 89, 7, 108, 7, 116, 0
; -----------------------------------------------------------------------------
; Board Data
; -----------------------------------------------------------------------------
; .byte space_type, space_x, space_y
; -----------------------------------------------------------------------------
board:
.byte $01, $10, $10
.byte $01, $20, $10
.byte $01, $30, $10
.byte $FF
; -----------------------------------------------------------------------------
; Padding
; -----------------------------------------------------------------------------
org $ff0
signature:
.byte " end"
|
calcmain.asm | DynamicApproach/SchoolThings | 0 | 85357 | <gh_stars>0
.data
infix: .space 256
postfix: .space 256
prefix: .space 256
output: .space 256
beginMsg: .asciiz "Enter infix expression:\nRemember to use closed paren and a num between 0-9\n\nInput: "
infixExpression: .asciiz "Infix expression: "
postfixExpression: .asciiz "Postfix expression: "
postfixlen: .asciiz "Postfix length: "
s1: .asciiz "S1: "
resultIs: .asciiz "result is: "
numb: .asciiz "Found a Number: "
plus: .asciiz "Found a plus: "
minus: .asciiz "Found a minus: "
s0: .asciiz "S0: "
firstNumber: .asciiz "first num is: "
secondNumber: .asciiz "second num is: "
result: .asciiz "\nEvaluation: "
currentpointernum: .asciiz "Current index: "
preorder: .asciiz "Preorder: "
p: .word 0 # my pointer to dynamic memory.
x: .word 0
current2: .space 256
current3: .space 256
spacer: .asciiz "===========================================\n"
.text
.globl main
main:
# Get the infix expression
# print beginning
li $v0, 4
la $a0, beginMsg
syscall
li $v0, 8 # get input
la $a0, infix # $a0 = buffer
la $a1, 256 # $a1 = maximum number of characters to read
syscall
#************************************** INPUTS **************************************
# Print infix
li $v0, 4
la $a0, infixExpression # $a0 = address of null-terminated string to print
syscall
li $v0, 4
la $a0, infix # print infix
syscall
li $v0, 4
la $a0, spacer
syscall
# print character for a newline
li $v0, 11
li $a0, '\n'
syscall
##############################################
la $t1, infix # $t1 = infix
li $s0,0 # $s0 = length
findlength:
lb $t2,($t1) # $t2 = character
addi $t1,$t1,1 # increment $t1
addi $s0,$s0,1 # increment $s0
bne $t2, 0, findlength #
#addi $s0, -2 # because offset by 2 more actual is 2 less I COMMENTED OUT THIS
#************************************** POSTFIX EVAL **************************************
li $t5,-1 # Postfix top offset
la $t2, postfix # $t2 = postfix
la $t1, infix # $t1 = infix
addi $t1,$t1,-1 # Set initial address of infix to -1 because we add one at start of scan
li,$s1,0 # s1 = counter
#addi $s0, $s0, -1 #WE HAVE ALTERED THIS AS WELL
addi $sp,$sp,1
scanInfix:
addi $s1,$s1,1 # increment counter
addi $t1,$t1,1 # increment infix
lb $t4,($t1) # get next character
# checks
beq $t4,'0',number
beq $t4,'1',number
beq $t4,'2',number
beq $t4,'3',number
beq $t4,'4',number
beq $t4,'5',number
beq $t4,'6',number
beq $t4,'7',number
beq $t4,'8',number
beq $t4,'9',number
beq $t4, '+', addsub
beq $t4, '-', addsub
beq $t4, '(', openp
beq $t4, ')', closep
go:
bne $s1,$s0,scanInfix # if not end of infix, go to scanInfix
li $v0, 4
la $a0, postfixExpression
syscall
# TODO: take postfix and evaluate HERE
# then print postfix = x
# MOVED TO postfix len
##############################################
# finding length of postfix
li $s0,0 # $s0 = length
la $t2, postfix # $t2 = postfix
postfixlength:
lb $t1,($t2) # $t1 = next character
addi $t2,$t2,1 # increment postfix stack
addi $s0,$s0,1 # increment length
bne $t1, 0, postfixlength # if not end of postfix, go to postfixlength
#addi $s0, -1 # because offset by 1 more actual is 1 less I COMMENTED OUT THIS
li,$s1,0 # counter
# print string
li $v0, 4
# print postfix
la $a0, postfix
syscall
# print character for a newline
li $v0, 11
li $a0, '\n'
syscall
addi $s0,$s0,-1
# print string
li $v0, 4
la $a0, postfixlen
syscall
# s0 = length of postfix
li $v0, 1
move $a0, $s0 # PRINT s0
syscall
la $s3, output # $s3 = output
la $s5, current2
la $s6, current3
li $s2, 0
la $s2, postfix # $s2 = postfix
# goto loop2
addi $s2, $s2, -1 # add 1 at start of loop
li $s1, 0 # counter
j loop2
##############################################
continue:
li $v0, 4 # print string
la $a0, postfix # print postfix
syscall
# print result
li $v0, 4
la $a0, result
syscall
#************************************** POSTFIX HELPERS **************************************
openp:
sub $sp,$sp,1 # decrement pointer
sb $t4,0($sp) # store open paren
j go
closep:
loop:
lb $t4, 0($sp) # get next character
beq $t4, '-', append # if minus, go to append to store
beq $t4, '+', append # if plus, go to append to store
beq $t4, '(',incloop # if open paren, increment loop
incloop:
addi $sp,$sp,1
j go
addsub:
sub $sp,$sp,1 # decrement pointer
sb $t4,0($sp) # push operator
j go
number:
addi $t5,$t5,1 # increment value location
add $t8,$t5,$t2 # t8 = value location
sb $t4,($t8) # store value
j go
append:
addi $t5,$t5,1 # increment value location
add $t8,$t5,$t2 # t8 = value location
sb $t4,($t8) # store value
addi $sp,$sp,1 # increment pointer
j loop
#################################
#************************************** Stack EVAL**************************************
loop2:
# When the expression is ended, the number left is the final answer
# iterate postfix expression, add numbers , operators pull numbers off - operate and store back on, final num is result
addi $s2,$s2,1 # increment postfix ------- Starting at [s2][1][-][]
addi $s1,$s1,1 # increment counter
lb $t0, 0($s2) # get next character loop2
# print current thing in
# if null terminator, exit loop and go print
beq $t0, 0, finish
beq $t0, '0', num
beq $t0, '1', num
beq $t0, '2', num
beq $t0, '3', num
beq $t0, '4', num
beq $t0, '5', num
beq $t0, '6', num
beq $t0, '7', num
beq $t0, '8', num
beq $t0, '9', num
beq $t0, '+', operatoradd
beq $t0, '-', operatorsub
j loop2
next:
beq $s1,$s0, finish
bne $s1,$s0,loop2 # if not end of postfix, go to loop2
# ..b) If the element is an operator, pop operands for the operator from the stack.
# Evaluate based on the operator and push the result back to the stack
# replace second word with result
##############################################
operatoradd:
lb $t8, ($s2) # add op to temp
sb $t8, 0($s6) # store temp in stack
addi $s6, $s6, 1 # increment new stack
li $v0, 11
li $a0, '\n'
syscall
addi $s3,$s3,-1 # pointing at empty space [num1][num2][pointr]
lb $t5,0($s3) # get first from output stack
addi $t5, $t5, -48 # $t5 holds second number
addi $s3,$s3,-1 # add 1 to get next num
lb $t6,0($s3) # get second num from output stack
addi $t6, $t6, -48
add $t7,$t6,$t5 # subtract
addi $t7, $t7, 48
sb $t7,0($s3) # sub and store in output stack
addi $s3,$s3,1 # [res][pointr][]
j next
##############################################
operatorsub:
lb $t8, ($s2) # add op to temp
sb $t8, 0($s6) # store temp in stack
addi $s6, $s6, 1 # increment new stack
#####
addi $s3,$s3,-1 # pointing at empty space [num1][num2][pointr]
lb $t5,0($s3) # get first from output stack
addi $t5, $t5, -48
# $t6 holds second number
addi $s3,$s3,-1 # add 1 to get next num
lb $t6,0($s3) # get second num from output stack
addi $t6, $t6, -48
sub $t7,$t6,$t5 # subtract
addi $t7, $t7, 48
sb $t7,0($s3) # sub and store in output stack
addi $s3,$s3,1 # [res][pointr][]
j next
##############################################
num:
lb $t8, ($s2) # add num to temp
sb $t8,0($s5) # store temp in stack
addi $s5, $s5, 1 # increment new stack
sb $t0,0($s3) # store value
addi $s3,$s3,1 # [VALUE][pointr][]
j next
#************************************** Finish and print all **************************************
finish:
# print result, includes a '\n'
li $v0, 4
la $a0, result
syscall
li $v0, 1
addi $s3,$s3, -1 # [pointr][][] move pointer back from empty space
lb $t8, 0($s3) # print infix result
addi $t8, $t8, -48
move $a0, $t8
syscall
li $v0, 11
li $a0, '\n'
syscall
li $v0, 4
la $a0, preorder
syscall
li $v0, 4
la $a0, current3
syscall
li $v0, 4
la $a0, current2
syscall
li $v0, 4
la $a0, spacer
syscall
li $v0, 10
syscall |
Transynther/x86/_processed/NC/_zr_/i9-9900K_12_0xa0_notsx.log_21829_268.asm | ljhsiun2/medusa | 9 | 81718 | <gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r15
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x9b68, %r8
nop
nop
nop
nop
nop
sub %r12, %r12
and $0xffffffffffffffc0, %r8
vmovaps (%r8), %ymm2
vextracti128 $0, %ymm2, %xmm2
vpextrq $1, %xmm2, %r15
nop
cmp $14552, %rax
lea addresses_WC_ht+0x3d10, %rcx
clflush (%rcx)
nop
nop
nop
nop
add $36929, %r15
movl $0x61626364, (%rcx)
nop
nop
cmp %r12, %r12
lea addresses_normal_ht+0xef90, %rax
nop
nop
nop
nop
dec %r14
movl $0x61626364, (%rax)
nop
nop
nop
nop
nop
add %r14, %r14
lea addresses_WT_ht+0x12410, %r15
nop
nop
xor %rax, %rax
and $0xffffffffffffffc0, %r15
vmovntdqa (%r15), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $0, %xmm0, %rbx
nop
cmp $57280, %rcx
lea addresses_A_ht+0x2f84, %rbx
nop
nop
nop
nop
cmp %r14, %r14
movw $0x6162, (%rbx)
nop
xor $18714, %r8
lea addresses_WT_ht+0xae68, %rcx
inc %rax
mov $0x6162636465666768, %rbx
movq %rbx, %xmm6
vmovups %ymm6, (%rcx)
nop
nop
nop
nop
lfence
lea addresses_UC_ht+0x2948, %rcx
xor %rbx, %rbx
vmovups (%rcx), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $1, %xmm3, %r8
nop
nop
nop
nop
and $34395, %rax
lea addresses_A_ht+0x19610, %rsi
lea addresses_normal_ht+0x1a590, %rdi
and %r12, %r12
mov $74, %rcx
rep movsl
nop
nop
sub $50439, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r15
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %rbp
push %rbx
push %rcx
push %rdi
// Faulty Load
mov $0x5b3fc60000000410, %r12
nop
nop
nop
sub %rbx, %rbx
vmovups (%r12), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $0, %xmm5, %rbp
lea oracles, %rcx
and $0xff, %rbp
shlq $12, %rbp
mov (%rcx,%rbp,1), %rbp
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_D_ht', 'AVXalign': True, 'size': 32, 'NT': False, 'same': False, 'congruent': 2}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 4, 'NT': True, 'same': False, 'congruent': 6}}
{'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32, 'NT': True, 'same': False, 'congruent': 10}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 2}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': True, 'congruent': 0}}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 3}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': True}}
{'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
*/
|
programs/oeis/004/A004641.asm | neoneye/loda | 22 | 6684 | ; A004641: Fixed under 0 -> 10, 1 -> 100.
; 1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1
mov $3,2
mov $4,$0
lpb $3
mov $0,$4
sub $3,1
add $0,$3
trn $0,1
seq $0,184117 ; Lower s-Wythoff sequence, where s(n) = 2n + 1.
add $0,2
mov $2,$3
mov $5,$0
sub $5,1
mul $2,$5
add $1,$2
lpe
min $4,1
mul $4,$5
sub $1,$4
sub $1,1
mov $0,$1
|
src/decls-d_arbre.adb | alvaromb/Compilemon | 1 | 9193 | <filename>src/decls-d_arbre.adb<gh_stars>1-10
package body Decls.D_Arbre is
procedure Abuit
(P : out Pnode) is
begin
P := Null;
end Abuit;
procedure Creanode_Programa
(P : out Atribut;
A : in Atribut) is
begin
P := A;
Arbre := P.A;
end Creanode_Programa;
procedure Creanode
(P : out Atribut;
Fe,Fd : in Atribut;
Tn : in Tipusnode) is
Paux : Pnode;
begin
Paux := new Node(Tn);
Paux.Fe1 := Fe.A;
Paux.Fd1 := Fd.A;
P := (Nodearbre, 0, 0, Paux);
end Creanode;
procedure Creanode
(P : out Atribut;
Fe,Fc,Fd : in Atribut;
Tn : in Tipusnode) is
Paux : Pnode;
begin
Paux := new Node(Tn);
Paux.Fe2 := Fe.A;
Paux.Fd2 := Fd.A;
Paux.Fc2 := Fc.A;
P := (Nodearbre, 0, 0, Paux);
end Creanode;
procedure Creanode
(P : out Atribut;
Fe, Fd : in Atribut;
Op : in Operacio;
Tn : in Tipusnode) is
Paux : Pnode;
begin
Paux := new Node(Tn);
Paux.Fe3 := Fe.A;
Paux.Fd3 := Fd.A;
Paux.Op3 := Op;
P := (Nodearbre, 0, 0, Paux);
end Creanode;
procedure Creanode
(P : out Atribut;
F : in Atribut;
Op : in Operacio;
Tn : in Tipusnode) is
Paux : Pnode;
begin
Paux := new Node(Tn);
Paux.F4 := F.A;
Paux.Op4 := Op;
P := (Nodearbre, 0, 0, Paux);
end Creanode;
procedure Creanode
(P : out Atribut;
Fe, Fce, Fc, Fd : in Atribut;
Tn : in Tipusnode) is
Paux : Pnode;
begin
Paux := new Node(Tn);
Paux.Fe5 := Fe.A;
Paux.Fc5 := Fce.A;
Paux.Fd5 := Fc.A;
Paux.Fid5 := Fd.A;
P := (Nodearbre, 0, 0, Paux);
end Creanode;
procedure Creanode
(P : out Atribut;
F : in Atribut;
Tn : in Tipusnode) is
Paux : Pnode;
begin
Paux := new Node(Tn);
Paux.F6 := F.A;
P := (Nodearbre, 0, 0, Paux);
end Creanode;
procedure Creanode_Id
(P : out Atribut;
Id : in Atribut;
Tn : in Tipusnode) is
Paux : Pnode;
begin
Paux := new Node(Tn);
Paux.Id12 := Id.Idn;
Paux.L1 := Id.Lin;
Paux.C1 := Id.Col;
P := (Nodearbre, 0, 0, Paux);
end Creanode_Id;
procedure Creanode_Val
(P : out Atribut;
A : in Atribut;
Tn : in Tipusnode;
S : in Valor) is
Paux : Pnode;
begin
Paux := new Node(Tn);
If S = 0 Then
Paux.Val := A.Val*(-1);
Else
Paux.Val := A.Val;
end If;
Paux.Tconst := A.T;
Paux.L2 := A.Lin;
Paux.C2 := A.Col;
P := (Nodearbre, 0, 0, Paux);
end Creanode_Val;
procedure Creanode_Mode
(P : out Atribut;
M : in Mmode;
Tn : in Tipusnode) is
Paux : Pnode;
begin
Paux := new Node(Tn);
Paux.M12 := M;
P := (Nodearbre, 0, 0, Paux);
end Creanode_Mode;
procedure Creanode
(P : out Atribut;
Tn : in Tipusnode) is
Paux : Pnode;
begin
Paux := new Node(Tn);
P := (Nodearbre, 0, 0, Paux);
end Creanode;
procedure Remunta
(P : out Atribut;
A : in Atribut) is
begin
P := A;
end Remunta;
procedure Cons_Tnode
(P : in Pnode;
Tn : out Tipusnode) is
begin
Tn := P.Tipus;
end Cons_Tnode;
end Decls.D_Arbre;
|
alloy4fun_models/trashltl/models/17/HodSqRYc2N6TvJvzv.als | Kaixi26/org.alloytools.alloy | 0 | 773 | open main
pred idHodSqRYc2N6TvJvzv_prop18 {
all f : File | f in Protected until f in Trash
}
pred __repair { idHodSqRYc2N6TvJvzv_prop18 }
check __repair { idHodSqRYc2N6TvJvzv_prop18 <=> prop18o } |
programs/oeis/180/A180142.asm | neoneye/loda | 22 | 84465 | ; A180142: Eight rooks and one berserker on a 3 X 3 chessboard. G.f.: (1 + x - x^2)/(1 - 3*x - 3*x^2).
; 1,4,14,54,204,774,2934,11124,42174,159894,606204,2298294,8713494,33035364,125246574,474845814,1800277164,6825368934,25876938294,98106921684,371951579934,1410175504854,5346381254364,20269670277654,76848154596054,291353474621124
seq $0,108306 ; Expansion of (3*x+1)/(1-3*x-3*x^2).
add $0,1
mul $0,2
div $0,3
|
libsrc/video/vdm/stdio/VDM_CAPS.asm | UnivEngineer/z88dk | 1 | 104632 | <reponame>UnivEngineer/z88dk
PUBLIC VDM_CAPS
PUBLIC VDM_CAPS_MASK
INCLUDE "ioctl.def"
defc VDM_CAPS = CAP_GENCON_UNDERLINE
defc VDM_CAPS_MASK = @00001000
|
P2/labyrinthos.asm | Snake52996/Buaa-CO-2020Autumn | 2 | 87894 | <reponame>Snake52996/Buaa-CO-2020Autumn
.data
map:.space 196
visited:.space 196
.macro getElement(%array,%x,%y,%col,%val)
multu %x,%col
mflo $t8
addu $t8,$t8,%y
sll $t8,$t8,2
lw %val,%array($t8)
.end_macro
.macro setElement(%array,%x,%y,%col,%val)
multu %x,%col
mflo $t8
addu $t8,$t8,%y
sll $t8,$t8,2
sw %val,%array($t8)
.end_macro
.macro readInteger(%val)
li $v0,5
syscall
add %val,$v0,$zero
.end_macro
.macro printInteger(%val)
li $v0,1
add $a0,%val,$zero
syscall
.end_macro
.macro readMatrix(%array,%row,%col)
li $t0,0
readMatrixOuterLoop:
li $t1,0
readMatrixInnerLoop:
readInteger($t2)
setElement(%array,$t0,$t1,%col,$t2)
addi $t1,$t1,1
blt $t1,%col,readMatrixInnerLoop
addi $t0,$t0,1
blt $t0,%row,readMatrixOuterLoop
.end_macro
.macro saveValue(%value)
addi $sp,$sp,-4
sw %value,4($sp)
.end_macro
.macro loadValue(%value)
addi $sp,$sp,4
lw %value,0($sp)
.end_macro
.text
readInteger($s0)
readInteger($s1)
readMatrix(map,$s0,$s1)
readInteger($t0)
readInteger($t1)
readInteger($s2)
readInteger($s3)
addi $t0,$t0,-1
addi $t1,$t1,-1
addi $s2,$s2,-1
addi $s3,$s3,-1
li $s4,0
jal dfs
j result
dfs:
bne $t0,$s2,dfsEdgeFail
bne $t1,$s3,dfsEdgeFail
addi $s4,$s4,1
j dfs_return
dfsEdgeFail:
li $t2,1
setElement(visited,$t0,$t1,$s1,$t2)
beqz $t0,dfsUpFail
addi $t2,$t0,-1
getElement(map,$t2,$t1,$s1,$t3)
bnez $t3,dfsUpFail
getElement(visited,$t2,$t1,$s1,$t3)
bnez $t3,dfsUpFail
saveValue($ra)
addi $t0,$t0,-1
jal dfs
addi $t0,$t0,1
loadValue($ra)
dfsUpFail:
addi $t2,$s0,-1
beq $t0,$t2,dfsDownFail
addi $t2,$t0,1
getElement(map,$t2,$t1,$s1,$t3)
bnez $t3,dfsDownFail
getElement(visited,$t2,$t1,$s1,$t3)
bnez $t3,dfsDownFail
saveValue($ra)
addi $t0,$t0,1
jal dfs
addi $t0,$t0,-1
loadValue($ra)
dfsDownFail:
beqz $t1,dfsLeftFail
addi $t2,$t1,-1
getElement(map,$t0,$t2,$s1,$t3)
bnez $t3,dfsLeftFail
getElement(visited,$t0,$t2,$s1,$t3)
bnez $t3,dfsLeftFail
saveValue($ra)
addi $t1,$t1,-1
jal dfs
addi $t1,$t1,1
loadValue($ra)
dfsLeftFail:
addi $t2,$s1,-1
beq $t1,$t2,dfsRightFail
addi $t2,$t1,1
getElement(map,$t0,$t2,$s1,$t3)
bnez $t3,dfsRightFail
getElement(visited,$t0,$t2,$s1,$t3)
bnez $t3,dfsRightFail
saveValue($ra)
addi $t1,$t1,1
jal dfs
addi $t1,$t1,-1
loadValue($ra)
dfsRightFail:
dfs_return:
setElement(visited,$t0,$t1,$s1,$zero)
jr $ra
result:
printInteger($s4)
li $v0,10
syscall
|
oeis/022/A022924.asm | neoneye/loda-programs | 11 | 166842 | ; A022924: Number of 3^m between 2^n and 2^(n+1).
; Submitted by <NAME>
; 0,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1
mov $3,2
mov $5,$0
lpb $3
sub $3,1
add $0,$3
sub $0,1
mov $2,$3
mov $4,$0
max $4,0
seq $4,206805 ; Position of 2^n when {2^j} and {3^k} are jointly ranked; complement of A206807.
mul $2,$4
add $1,$2
lpe
min $5,1
mul $5,$4
sub $1,$5
mov $0,$1
sub $0,1
|
unittests/ASM/TwoByte/0F_76.asm | woachk/FEX | 0 | 167324 | %ifdef CONFIG
{
"RegData": {
"MM0": ["0x00000000FFFFFFFF", "0x0"],
"MM1": ["0x00000000FFFFFFFF", "0x0"],
"MM2": ["0x61626364FFFFFFFF", "0x0"]
},
"MemoryRegions": {
"0x100000000": "4096"
}
}
%endif
mov rdx, 0xe0000000
mov rax, 0x71727374FFFFFFFF
mov [rdx + 8 * 0], rax
mov rax, 0x41424344FFFFFFFF
mov [rdx + 8 * 1], rax
mov rax, 0x61626364FFFFFFFF
mov [rdx + 8 * 2], rax
mov rax, 0x51525354FFFFFFFF
mov [rdx + 8 * 3], rax
movq mm0, [rdx]
pcmpeqd mm0, [rdx + 8 * 2]
movq mm1, [rdx]
movq mm2, [rdx + 8 * 2]
pcmpeqd mm1, mm2
hlt
|
3-mid/impact/source/3d/dynamics/joints/impact-d3-solver_constraint.adb | charlie5/lace | 20 | 15582 | <gh_stars>10-100
with lace.fast_Pool;
package body impact.d3.solver_Constraint
is
package Pool is new lace.fast_Pool (Item, View, 20_000);
function new_solver_Constraint return View
is
Self : constant View := Pool.new_Item;
begin
-- Self.all := null_Constraint;
return Self;
end new_solver_Constraint;
procedure free (Self : in out View)
is
begin
Pool.free (Self);
end free;
end impact.d3.solver_Constraint;
|
oeis/021/A021547.asm | neoneye/loda-programs | 11 | 165234 | <reponame>neoneye/loda-programs
; A021547: Decimal expansion of 1/543.
; Submitted by Jon Maiga
; 0,0,1,8,4,1,6,2,0,6,2,6,1,5,1,0,1,2,8,9,1,3,4,4,3,8,3,0,5,7,0,9,0,2,3,9,4,1,0,6,8,1,3,9,9,6,3,1,6,7,5,8,7,4,7,6,9,7,9,7,4,2,1,7,3,1,1,2,3,3,8,8,5,8,1,9,5,2,1,1,7,8,6,3,7,2,0,0,7,3,6,6,4,8,2,5,0,4,6
seq $0,83811 ; Numbers n such that 2n+1 is the digit reversal of n+1.
div $0,2172
mod $0,10
|
calc-sr2.asm | cotarr/calc-pi-x86-64-asm | 0 | 2334 | ;-------------------------------------------------------------
;
; SINGLE THREAD FLOATING POINT MULTI-PRECISION CALCULATOR
;
; Calculation of Roots and Powers
;
; File: calc-sr2.asm
; Module: calc.asm, calc.o
; Exec: calc-pi
;
; Created 12/13/2014
; Last Edit 05/12/2015
;
;--------------------------------------------------------------
; MIT License
;
; Copyright 2014-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.
;-------------------------------------------------------------
; Function_calc_sr2:
;-------------------------------------------------------------
;
; Rewrite for use with Newton Raphson reciprocal functions.
;
;--------------------------------------------------------
;
; Calculate Square Root of 2
;
; Input: none
;
; During calculation:
; Reg0 - holds next/last guess (not preserved)
;
; After calculation:
; XReg - Square root 2
; Reg0 - not preserved.
;
;-----------------------------------------
;
; Method: Iterative approximations
;
; X(i) = last guess X(i+1) = next guess A = input number
;
; X(i+1) = [ (A / X(i) ) + (X(i)) ] / 2
;
; First guess will be setup in REG0
; A:
; Move REG0 (guess) to ACC
; B:
; Calculate 1/ACC (Reciprocal)
; C:
; Move 2.000... to OPR
; D:
; Multiply OPR * (1/ACC)
; E:
; Move REG0 (guess) to OPR
; F:
; FP_Add (OPR+ACC) = ACC
; G:
; Divide by 2 by decrement exponent
; H:
; Check if Reg0 = ACC
; I:
; Move ACC --> REG0 (to be next guess)
;
;-------------
;
; To reduce time, accuracy is reduced early in the calc
;
;-------------
Function_calc_sr2:
; Preserve registers
;
push rax ; Working REgister
push rbx ; Used to command progress display tool
push rcx ; loop vairiable
push rdx ; Counter matching words
push rsi ; Variable handle
push rdi ; Variable handle
push rbp ; Pointer index
;
;
mov rax, .Msg1
call StrOut
;
;^^^^^^^^^^^^^^^^^^^^^^ Watch Progress ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
mov rbx, 1 ; print iteration counter
mov rax, 0x04000000 ; set skip counter from rbx
call ShowCalcProgress ; initialize
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;
; First make a guess, 1 is as good as any
; Place first guess into Reg0
;
mov rax, 1
mov rsi, HAND_REG0
call FP_Load64BitNumber
;
; Move a copy of the guess to the ACC register
;
mov rsi, HAND_REG0
mov rdi, HAND_ACC
call CopyVariable
;
; Reduce accuracy for the calculation
;
mov rax, 8 ; initial accuracy
mov rbx, rax ; New value in RBX
cmp rbx, MINIMUM_WORD ; Below minimum ?
jge .skip1 ; No, don't adjust
mov rbx, MINIMUM_WORD ; Else, yes, reset to minimum
.skip1:
mov rax, [D_Flt_Word] ; Maximum mantissa size
cmp rax, rbx ; Over maximum size?
jge .skip2 ; No don't adjust
mov rbx, rax ; Else, yes, reset to maximum
.skip2:
mov rax, rbx ; rax input to function
call Set_No_Word_Temp ; Set accuracy
;
; Initialize loop counter
;
mov r8, 0 ; loop counter
;
;-----------------------------
;
; M A I N L O O P
;
;-----------------------------
;
.loop:
;
inc r8 ; increment loop counter
;
; For debugging, exit if counter over limit
;
cmp r8, 200
jl .limitOK
mov rax, .Msg_Error1
call StrOut
mov rax, 0
jmp FatalError
.limitOK:
;
; Calculate reciprocal of guess Guess (first time outside loop)
;
call FP_Reciprocal ; ACC = 1/Guess = 1/Reg0
;
; This is alternate way to calculate reciprocal using
; floatig point division.
;
; mov rax, 1
; mov rsi, HAND_OPR
; call FP_Load64BitNumber ; OPR = 1
; call FP_Division ; ACC = 1/ACC = 1/Guess
;
;
; Multiply 2 * (1/guess)
;
mov rax, 2
mov rsi, HAND_OPR
call FP_Load64BitNumber ; OPR = 2 (for root 2)
;
call FP_Multiplication ; ACC = OPR*ACC = 2 * (1/guess)
;
; Add to last guess
;
mov rsi, HAND_REG0
mov rdi, HAND_OPR
call CopyVariable ; OPR is last guess
;
; Add last guess + new guess
;
call FP_Addition ; ACC = (last guess) + (new guess)
;
; Divide by two by decrement exponent
;
mov rbx, FP_Acc+EXP_WORD_OFST
DEC QWORD [rbx] ; ACC = average --> (last+new)/2
;
;^^^^^^^^^^^^^^^^^^^^^^ Watch Progress ^^^^^^^^^^^^^^^^^^^
; -Print-- Inc/Rset -Format-
mov rax, (0x01110101 | 0x00000804 | 0x20000000 )
call ShowCalcProgress
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;
; Skip first few iterations
;
cmp r8, 4 ; Don't do first few terms, will false done
jl .skip01
;
; Check if done and adjust accuracy if needed.
mov rbx, FP_Acc ; Next guess Xn
mov rdx, FP_Reg0 ; Last guess Xn-1
mov rbp, MAN_MSW_OFST ; Point at MSWord
mov rcx, 0 ; Initialize word Counter
;
; This counts in rcx how many words match
;
.loop_ck:
mov rax, [rbx+rbp] ; Get word from ACC
cmp rax, [rdx+rbp] ; Compare to Reg0
jne .endloop ; Not equal, exit to stop counting
sub rbp, BYTE_PER_WORD ; point at next word
inc rcx ; Increment count of bytes same
mov rax, [LSWOfst] ; Get lower limit index
cmp rbp, rax ; Check if done (checked last word?)
jge .loop_ck ; No, keep checking, else done
.endloop:
;
; Check if at full accuracy, if yes, full accuracy, then check for exit
;
mov rax, [No_Word] ; Get program accuracy
cmp rax, [D_Flt_Word] ; Compare reduced accuracy
jne .skip01 ; Not full accuracy, don't exit
;
; Exit check, if matching enough word and if at full accuracy
mov rax, [No_Word] ; Get word count
sub rax, GUARDWORDS ; Subtract guard words
add rax, 1 ; Option to match guard word (see below)
;----------------------------------------
; at 1,000,000 digits and 3 guard words
;
; #1 with add rax,1 greater than 1 guard word
; 36 term 258 Seconds 00:04:18 (with add rbx,1)
; 2 - (sr2*sr2) = 2.0856 E-1000032
; 33: 32765 No_Word: 51909
; 34: 51906 No_Word: 51909
; 35: 51906 No_Word: 51909
; Then done
;
; #2 without add,rax,1 (all mantissa match)
; 33 term 156 Seconds 00:02:36 (without)
; 2 - (sr2*sr2) = +2.0856 E-1000032
; 31: 16381 No_Word: 32768
; 32: 32763 No_Word: 51909
; 33: 32765 No_Word: 51909
; Then done
;
; Set guard word from 3to 4 and repeat,
; also did same Add,1 in FP_Reciprocal
; Repeat test:
;
; #1 with add rax,1 greater than 1 guard word
; 34 term 155 Seconds 00:02:35
;
; #2 without add,rax,1 (all mantissa match)
; 34 term 155 Seconds 00:02:35
;
; Conclusion, for Newton Raphson approximations
; it is necessary to have 4 guard words.
;---------------------------------------------
;
;
;----------------------------------------
cmp rcx, rax ; Compare number of bytes the same
jl .skip01 ; Do another iteration?
jmp .done ; End calculation, enough words match
;
; Adjust accuracy, rcx = mumber of words the same
;
.skip01:
mov rax, [No_Word] ; Get current mantissa size
shr rax, 1 ; Divide by 2, wait until half of words match
cmp rcx, rax ; Are matching words more than half of words
jl .skip02 ; No don't adjust accuracy
;
mov rbx, [No_Word] ; Get accuracy
shl rbx, 1 ; Increase X 2
mov rax, [D_Flt_Word] ; Maximum mantissa size
cmp rax, rbx ; Over maximum size?
jge .skip_sa2 ; No don't adjust
mov rbx, rax ; Else, yes, reset to maximum
.skip_sa2:
mov rax, rbx ; For call
call Set_No_Word_Temp
;
; Move result back to Reg0 to become next n+1 guess
;
.skip02:
mov rsi, HAND_ACC
mov rdi, HAND_REG0
call CopyVariable ; Reg0 = next guess
; Debug Code
%IFDEF xcv
;
; Debug printing
;
mov rax, .Msg4
call StrOut
mov rax, r8
call PrintWordB10
mov AL, ' '
call CharOut
mov rax, .Msg2
call StrOut
mov rax, rcx
call PrintWordB10
mov AL, ' '
call CharOut
mov rax, .Msg3
call StrOut
mov rax, [No_Word]
call PrintWordB10
call CROut
%ENDIF
;
; Loop back and perform another iteration
;
jmp .loop
;
;------------------------
; Loop exit to here
;------------------------
;
.done:
;
; Copy result back to XREG
;
mov rsi, HAND_ACC
mov rdi, HAND_XREG
call CopyVariable
;
mov rsi, HAND_REG0
call ClearVariable
;
.exit:
;
;^^^^^^^^^^^^^^^^^^^^^^ Watch Progress ^^^^^^^^^^^^^^^^^^^
; -Print-- Inc/Rset -Format-
mov rax, (0x000F0303 | 0x00000000 | 0x30000000 )
call ShowCalcProgress
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;
; Restore Registers
;
pop rbp
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
ret
;
.Msg1: db "Calculating Square Root of 2", 0xD, 0xA, 0
.Msg_Error1: db "Function_calc_sr2: Error: loop counter exceed limit.", 0xD, 0xA, 0
; for debug printing
.Msg2: db "rcx: ", 0
.Msg3: db "No_Word: ", 0
.Msg4: db "r8: ", 0
|
prot.asm | Klaus073/Assembly-language | 0 | 14363 | <gh_stars>0
SECTION .DATA
happ: dq 0
basic_first: dq 123
basic_last: dq 456
SECTION .TEXT
GLOBAL _basic_encrypt
GLOBAL _basic_decrypt
GLOBAL _basic_encrypt_char
GLOBAL _basic_decrypt_char
_basic_encrypt:
mov rax,rdi ;[rbp+16]
add rax, [basic_first]
add rax,[basic_last]
ret
_basic_decrypt:
mov rax,rdi ;[rbp+16]
sub rax, [basic_first]
sub rax,[basic_last]
ret
_basic_encrypt_char:
mov rax,rdi ;[rbp+16]
add rax, [basic_first]
add rax,[basic_last]
_basic_decrypt_char:
mov rax,rdi ;[rbp+16]
sub rax, [basic_first]
sub rax,[basic_last]
ret
|
libsrc/gfx/narrow/xordrawb.asm | Frodevan/z88dk | 4 | 175369 | <reponame>Frodevan/z88dk<gh_stars>1-10
;
; Z88 Graphics Functions - Small C+ stubs
;
; Written around the Interlogic Standard Library
;
;
; ----- void __CALLEE__ xordrawb(int x, int y, int h, int v)
;
; $Id: xordrawb.asm $
;
IF !__CPU_INTEL__ & !__CPU_GBZ80__
SECTION code_graphics
PUBLIC xordrawb
PUBLIC _xordrawb
EXTERN xordrawb_callee
EXTERN ASMDISP_XORDRAWB_CALLEE
.xordrawb
._xordrawb
push ix
ld ix,2
add ix,sp
ld c,(ix+2)
ld b,(ix+4)
ld l,(ix+6)
ld h,(ix+8)
pop ix
jp xordrawb_callee + ASMDISP_XORDRAWB_CALLEE
ENDIF
|
src/main/lang/BulletLang.g4 | cjburkey01/BulletLang | 3 | 3455 | <reponame>cjburkey01/BulletLang<gh_stars>1-10
grammar BulletLang;
// IGNORED
COMMENT : (('//' .*? '\n')
| ('/*' .*? '*/'))
-> skip
;
// STRINGS
SMART_STRING : '@"' .*? '"' ;
STRING : '"' (~'\n')*? '"';
// IGNORED
WHITESPACE : [ \n\t\r]+
-> skip
;
// NUMBERS
fragment DIGIT : [0-9] ;
INTEGER : DIGIT+ ;
FLOAT : INTEGER? '.' INTEGER+ ;
// SYMBOLS
SEMI_COLON : ';' ;
COMMA : ',' ;
LEFT_PAR : '(' ;
RIGHT_PAR : ')' ;
LEFT_D_BRACE : '${' ;
LEFT_BRACE : '{' ;
RIGHT_BRACE : '}' ;
EQUALS : '=' ;
STATIC : '@@' ;
LOCAL : '@' ;
// Level 1 operators
TIMES : '*' ;
DIV : '/' ;
// Level 2 operators
ADD : '+' ;
SUB : '-' ;
// Level 3 operators
GT : '>' ;
LT : '<' ;
GTE : '>=' ;
LTE : '<=' ;
EQ : '==' ;
NEQ : '!=' ;
// Level 4 operators
AND : '&&' ;
OR : '||' ;
// KEYWORDS
RETURN : 'return' ;
OF : 'of' ;
DEF : 'def' ;
LET : 'let' ;
TRUE : 'true' ;
FALSE : 'false' ;
CLASS : 'class' ;
IF : 'if' ;
ELSE : 'else' ;
// NAMES
IDENTIFIER : [A-Za-z_] [A-Za-z_0-9]* ;
// RULES
classInner : variableDec # VariableDecClass
| functionDec # FunctionDecClass
| classDec # ClassDecClass
;
classScope : classScope classInner
| classInner
;
classDec : CLASS IDENTIFIER typeDec? LEFT_BRACE classScope? RIGHT_BRACE ;
arguments : arguments COMMA expression
| expression
;
reference : IDENTIFIER LEFT_PAR arguments? RIGHT_PAR // Definitely a Function Reference
| IDENTIFIER arguments // Definitely a Function Reference
| instType IDENTIFIER // Definitely a Variable Reference
| IDENTIFIER // Variable/Function Reference
;
expression : reference # ReferenceExpression
| LEFT_PAR expression RIGHT_PAR # ParExpression
| op=SUB expression # UnOpExpression
| expression op=(TIMES | DIV) expression # BinOpExpression
| expression op=(ADD | SUB) expression # BinOpExpression
| expression op=(GT | LT | GTE | LTE | EQ | NEQ) expression # BinOpExpression
| expression op=(AND | OR) expression # BinOpExpression
| INTEGER # IntegerExpression
| (TRUE | FALSE) # BooleanExpression
| FLOAT # FloatExpression
| SMART_STRING # StringExpression
| STRING # StringExpression
;
returnVal : RETURN expression SEMI_COLON
| expression
;
typeDec : OF IDENTIFIER ;
parameter : IDENTIFIER typeDec ;
parameters : parameters COMMA parameter
| parameter
;
functionDec : DEF IDENTIFIER? (LEFT_PAR parameters? RIGHT_PAR)? typeDec? LEFT_BRACE scope? RIGHT_BRACE ;
instType : STATIC | LOCAL ;
variableDec : LET instType? IDENTIFIER typeDec? EQUALS expression ;
elseRaw : ELSE expression? LEFT_BRACE scope? RIGHT_BRACE ;
ifRaw : IF expression LEFT_BRACE scope? RIGHT_BRACE elseRaw* ;
statement : expression SEMI_COLON # ExpressionStatement
| variableDec SEMI_COLON # VariableDecStatement
| functionDec # FunctionDecStatement
| classDec # ClassDecStatement
| returnVal # ReturnStatement
| ifRaw # IfStatement
;
scope : scope statement
| statement
;
program : scope? ;
rawExpr : expression EOF ;
|
Transynther/x86/_processed/AVXALIGN/_ht_zr_/i7-7700_9_0xca.log_21829_714.asm | ljhsiun2/medusa | 9 | 84239 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r15
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x150e8, %rdx
nop
nop
nop
inc %r12
vmovups (%rdx), %ymm7
vextracti128 $0, %ymm7, %xmm7
vpextrq $0, %xmm7, %r8
nop
nop
nop
nop
xor $2828, %r15
lea addresses_D_ht+0xdc68, %rsi
lea addresses_UC_ht+0x1b638, %rdi
nop
nop
nop
sub %r10, %r10
mov $45, %rcx
rep movsq
nop
nop
add $47315, %r10
lea addresses_WT_ht+0x402, %r8
nop
nop
xor %r10, %r10
movb (%r8), %dl
cmp $61495, %r8
lea addresses_WT_ht+0x16cb3, %rsi
lea addresses_D_ht+0x18034, %rdi
nop
nop
nop
nop
nop
inc %rdx
mov $106, %rcx
rep movsq
sub %rdx, %rdx
lea addresses_UC_ht+0x1b268, %rdi
add $13084, %r15
movl $0x61626364, (%rdi)
nop
nop
nop
sub $5486, %r8
lea addresses_WC_ht+0xc868, %rcx
nop
nop
nop
add %rdx, %rdx
and $0xffffffffffffffc0, %rcx
vmovntdqa (%rcx), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $0, %xmm5, %rsi
nop
nop
nop
add $30255, %r12
lea addresses_WC_ht+0x1b77c, %rsi
lea addresses_WT_ht+0x15468, %rdi
nop
sub %r12, %r12
mov $61, %rcx
rep movsl
nop
nop
nop
add $58104, %rdi
lea addresses_D_ht+0x182e8, %rsi
lea addresses_UC_ht+0xe091, %rdi
nop
nop
nop
nop
sub %r8, %r8
mov $88, %rcx
rep movsw
nop
nop
sub %r15, %r15
lea addresses_WC_ht+0xa758, %rsi
lea addresses_normal_ht+0x1c68, %rdi
clflush (%rsi)
nop
nop
nop
and $61453, %r8
mov $9, %rcx
rep movsw
sub %r12, %r12
lea addresses_WT_ht+0x18f68, %r10
nop
nop
nop
sub $26704, %r15
mov (%r10), %cx
nop
nop
nop
nop
nop
lfence
lea addresses_WT_ht+0x88e8, %r15
nop
sub %rcx, %rcx
movups (%r15), %xmm7
vpextrq $0, %xmm7, %rdi
nop
nop
nop
and %r10, %r10
lea addresses_WC_ht+0xe132, %rsi
lea addresses_D_ht+0x9258, %rdi
nop
nop
nop
nop
and $65308, %r12
mov $65, %rcx
rep movsb
nop
nop
nop
and $27501, %rdx
lea addresses_D_ht+0x4c68, %rdx
nop
and %r10, %r10
mov (%rdx), %r15w
nop
nop
nop
nop
inc %rdi
lea addresses_WC_ht+0x14168, %rsi
lea addresses_A_ht+0x1ab48, %rdi
clflush (%rsi)
nop
nop
nop
inc %r12
mov $70, %rcx
rep movsl
nop
nop
nop
nop
nop
add $38993, %r8
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r15
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r14
push %r8
push %rax
push %rbp
push %rbx
// Store
lea addresses_UC+0x6068, %rax
nop
cmp $52710, %r14
movb $0x51, (%rax)
nop
nop
and $41731, %r10
// Load
lea addresses_RW+0x1b38c, %r14
nop
nop
nop
nop
cmp %r8, %r8
mov (%r14), %bp
nop
nop
sub $39124, %rbx
// Store
lea addresses_PSE+0xa084, %r8
sub $48828, %r11
movl $0x51525354, (%r8)
nop
nop
nop
and $35584, %r11
// Faulty Load
lea addresses_D+0x1a468, %rbp
inc %r11
vmovaps (%rbp), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $0, %xmm3, %r14
lea oracles, %rax
and $0xff, %r14
shlq $12, %r14
mov (%rax,%r14,1), %r14
pop %rbx
pop %rbp
pop %rax
pop %r8
pop %r14
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_UC'}}
{'src': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_PSE'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': True, 'same': True, 'size': 32, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_UC_ht'}}
{'src': {'congruent': 1, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 0, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_D_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': True, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_UC_ht'}}
{'src': {'congruent': 9, 'AVXalign': False, 'same': True, 'size': 32, 'NT': True, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 5, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_UC_ht'}}
{'src': {'congruent': 4, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}}
{'src': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 1, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}}
{'src': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_A_ht'}}
{'46': 98, '48': 21496, '00': 223, '49': 12}
00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 46 48 00 48 00 48 46 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 46 48 46 48 46 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
*/
|
Projetos/tools/Z01-Simulator-GUI/temp/rom_in.nasm | juanjorgegarcia/Z01 | 2 | 98063 | <reponame>juanjorgegarcia/Z01<gh_stars>1-10
; Inicialização para VM
leaw $256,%A
movw %A,%D
leaw $SP,%A
movw %D,(%A)
; 0 - PUSH constant 0
leaw $0,%A
movw %A,%D
leaw $SP,%A
movw (%A),%A
movw %D,(%A)
leaw $SP,%A
movw (%A),%D
incw %D
movw %D,(%A)
; 1 - POP local 0
leaw $SP,%A
movw (%A),%D
decw %D
movw %D,(%A)
leaw $0,%A
movw %A,%D
leaw $LCL,%A
addw (%A),%D,%D
leaw $R15,%A
movw %D,(%A)
leaw $SP,%A
movw (%A),%A
movw (%A),%D
leaw $R15,%A
movw (%A),%A
movw %D,(%A)
; Label (marcador)
program..LOOP_START:
; 2 - PUSH argument 0
leaw $0,%A
movw %A,%D
leaw $ARG,%A
addw (%A),%D,%A
movw (%A),%D
leaw $SP,%A
movw (%A),%A
movw %D,(%A)
leaw $SP,%A
movw (%A),%D
incw %D
movw %D,(%A)
; 3 - PUSH local 0
leaw $0,%A
movw %A,%D
leaw $LCL,%A
addw (%A),%D,%A
movw (%A),%D
leaw $SP,%A
movw (%A),%A
movw %D,(%A)
leaw $SP,%A
movw (%A),%D
incw %D
movw %D,(%A)
; 4 - ADD
leaw $SP,%A
movw (%A),%D
decw %D
movw %D,(%A)
movw (%A),%A
movw (%A),%D
leaw $SP,%A
subw (%A),$1,%A
addw (%A),%D,%D
movw %D,(%A)
; 5 - POP local 0
leaw $SP,%A
movw (%A),%D
decw %D
movw %D,(%A)
leaw $0,%A
movw %A,%D
leaw $LCL,%A
addw (%A),%D,%D
leaw $R15,%A
movw %D,(%A)
leaw $SP,%A
movw (%A),%A
movw (%A),%D
leaw $R15,%A
movw (%A),%A
movw %D,(%A)
; 6 - PUSH argument 0
leaw $0,%A
movw %A,%D
leaw $ARG,%A
addw (%A),%D,%A
movw (%A),%D
leaw $SP,%A
movw (%A),%A
movw %D,(%A)
leaw $SP,%A
movw (%A),%D
incw %D
movw %D,(%A)
; 7 - PUSH constant 1
leaw $1,%A
movw %A,%D
leaw $SP,%A
movw (%A),%A
movw %D,(%A)
leaw $SP,%A
movw (%A),%D
incw %D
movw %D,(%A)
; 8 - SUB
leaw $SP,%A
movw (%A),%D
decw %D
movw %D,(%A)
movw (%A),%A
movw (%A),%D
leaw $SP,%A
subw (%A),$1,%A
subw (%A),%D,%D
movw %D,(%A)
; 9 - POP argument 0
leaw $SP,%A
movw (%A),%D
decw %D
movw %D,(%A)
leaw $0,%A
movw %A,%D
leaw $ARG,%A
addw (%A),%D,%D
leaw $R15,%A
movw %D,(%A)
leaw $SP,%A
movw (%A),%A
movw (%A),%D
leaw $R15,%A
movw (%A),%A
movw %D,(%A)
; 10 - PUSH argument 0
leaw $0,%A
movw %A,%D
leaw $ARG,%A
addw (%A),%D,%A
movw (%A),%D
leaw $SP,%A
movw (%A),%A
movw %D,(%A)
leaw $SP,%A
movw (%A),%D
incw %D
movw %D,(%A)
; 11 - Goto Condicional
leaw $SP,%A
movw (%A),%D
decw %D
movw %D,(%A)
movw (%A),%A
movw (%A),%D
leaw $program..LOOP_START,%A
jne %D
nop
; 12 - PUSH local 0
leaw $0,%A
movw %A,%D
leaw $LCL,%A
addw (%A),%D,%A
movw (%A),%D
leaw $SP,%A
movw (%A),%A
movw %D,(%A)
leaw $SP,%A
movw (%A),%D
incw %D
movw %D,(%A)
; End
|
assembly files/INTERRUPT.asm | majidsh97/avr | 2 | 175014 | #ifndef _INTERRUPT_ASM_
#define _INTERRUPT_ASM_
RESET:
JMP START
EXT_INT0:RETI
EXT_INT1 :RETI
EXT_INT2 :RETI
TIM2_COMP :RETI
TIM2_OVF :RETI
TIM1_CAPT :RETI
TIM1_COMPA :RETI
TIM1_COMPB :
RETI
TIM1_OVF :
INC I
CPI I,20
IF(MYI,BREQ)
LDI I,0
CPI FLAG,FRUN
IF(SHOWSEC,BREQ)
MLCMD CURSORSEC;LCS(0,CURSORSEC)
MDISREG S
END(SHOWSEC)
INC S
CPI S,60
IF(MYS,BREQ)
LDI S,0
INC M
CPI FLAG,FRUN
IF(SHOWMIN,BREQ)
MLCMD CURSORMIN;LCS(0,CURSORMIN)
MDISREG M
END(SHOWMIN)
PUSH TMP
LDS TMP,MINALARM
CP M,TMP
IF(MINALARMEQ,BREQ)
PUSH ARG2 ;ANOTHER TEMP :|
LDS ARG2,HOURALARM
LDS TMP,HOUR
CP TMP,ARG2
IF(HOURALARMEQ,BREQ)
LDI ARG2,1<<BUZZER;--------------------ACTIVE BUZZER
OUT PORTB,ARG2
END(HOURALARMEQ)
POP ARG2
END(MINALARMEQ)
POP TMP
CPI M,60
IF(MYM,BREQ)
LDI M,0
PUSH TMP
LDS TMP,HOUR
INC TMP
CPI FLAG,FRUN
IF(SHOWHOUR,BREQ)
MLCMD CURSORHOUR;LCS(0,CURSORHOUR)
MDISREG TMP
END(SHOWHOUR)
STS HOUR,TMP
CPI TMP,24
IF(HOURLOW24,BREQ)
LDI TMP,0
STS HOUR,TMP
LDS TMP,DAY
INC TMP
CPI FLAG,FALARM
IF(SHOWDAY,BRNE)
MLCMD CURSORDAY;LCS(1,CURSORDAY)
MDISREG TMP
END(SHOWDAY)
CPI TMP,31
STS DAY,TMP
IF(DAYLOW31,BREQ)
LDI TMP,0
STS DAY,TMP
LDS TMP,MONTH
INC TMP
CPI FLAG,FALARM
IF(SHOWMONTH,BRNE)
MLCMD CURSORMONTH;LCS(1,CURSORMONTH)
MDISREG TMP
END(SHOWMONTH)
STS MONTH,TMP
CPI TMP,12
IF(MONTHLOW12,BREQ)
LDI TMP,0
STS MONTH,TMP
LDS TMP,YEAR
INC TMP
CPI FLAG,FALARM
IF(SHOWYEAR,BRNE)
MLCMD CURSORYEAR;LCS(1,CURSORYEAR)
MDISREG TMP
END(SHOWYEAR)
STS YEAR,TMP
END(MONTHLOW12)
END(DAYLOW31)
END(HOURLOW24)
POP TMP
END(MYM)
END(MYS)
END(MYI)RETI
TIM0_COMP :
RETI
TIM0_OVF :
RETI
SPI_STC :RETI
USART_RXC :RETI
USART_UDRE :RETI
USART_TXC :RETI
ADC_INTERRUPT :RETI
EE_RDY :RETI
ANA_COMP :RETI
TWI :RETI
SPM_RDY:RETI
#endif
|
libmikeos/src.io/io_read_memory32.asm | mynameispyo/InpyoOS | 0 | 23007 |
; @@@ unsigned long io_read_memory32(unsigned long *offset, unsigned short segment);
; for far pointer capable system, this function shold be :
; unsigned long io_read_memory32(unsigned long *offset_and_segment);
section .text
use16
global _io_read_memory32
_io_read_memory32:
mov bx, sp
push es
les bx, [ss:bx + 2]
mov eax, [es:bx]
push eax
pop ax
pop dx ; not BX register, don't confuse!
pop es
ret
|
Transynther/x86/_processed/US/_zr_/i7-7700_9_0xca_notsx.log_8_687.asm | ljhsiun2/medusa | 9 | 13081 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r13
push %r15
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0xf05a, %rsi
lea addresses_WC_ht+0xa212, %rdi
clflush (%rdi)
nop
nop
nop
inc %r13
mov $76, %rcx
rep movsl
nop
nop
dec %rcx
lea addresses_UC_ht+0x5dd2, %rsi
lea addresses_WT_ht+0xd1d2, %rdi
nop
nop
xor %rbp, %rbp
mov $99, %rcx
rep movsl
nop
nop
nop
nop
nop
and %rsi, %rsi
lea addresses_A_ht+0x10bd2, %rdi
nop
nop
nop
nop
and $36070, %r11
mov $0x6162636465666768, %rsi
movq %rsi, %xmm4
vmovups %ymm4, (%rdi)
nop
nop
nop
nop
nop
and $61365, %rsi
lea addresses_normal_ht+0x1e1b2, %rdi
clflush (%rdi)
add $28618, %r15
mov (%rdi), %r13w
nop
and %r11, %r11
lea addresses_WC_ht+0x7cd2, %r13
xor %r11, %r11
movw $0x6162, (%r13)
nop
nop
lfence
lea addresses_normal_ht+0x75d2, %rsi
lea addresses_A_ht+0x131a2, %rdi
nop
nop
nop
dec %rbp
mov $89, %rcx
rep movsw
nop
add %rsi, %rsi
lea addresses_normal_ht+0x972, %rcx
nop
nop
nop
add %rdi, %rdi
movw $0x6162, (%rcx)
nop
nop
cmp %rdi, %rdi
lea addresses_WT_ht+0x1982e, %rsi
nop
nop
sub $43988, %r11
vmovups (%rsi), %ymm6
vextracti128 $1, %ymm6, %xmm6
vpextrq $1, %xmm6, %rbp
nop
nop
nop
nop
nop
add $41451, %r13
lea addresses_A_ht+0x159d2, %r15
and %r11, %r11
movb $0x61, (%r15)
nop
lfence
lea addresses_WT_ht+0x128de, %rsi
lea addresses_normal_ht+0x1d7ec, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
xor %r10, %r10
mov $1, %rcx
rep movsw
nop
nop
nop
nop
cmp %r15, %r15
lea addresses_WC_ht+0x2392, %rcx
add $35471, %r11
mov $0x6162636465666768, %r15
movq %r15, %xmm6
movups %xmm6, (%rcx)
nop
nop
nop
nop
sub $36786, %r13
lea addresses_WC_ht+0x5d32, %rsi
clflush (%rsi)
and %r13, %r13
mov (%rsi), %r15
nop
cmp $42860, %r11
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r15
pop %r13
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r14
push %r9
push %rax
push %rsi
// Faulty Load
lea addresses_US+0x135d2, %rsi
nop
nop
nop
cmp $54247, %rax
movb (%rsi), %r14b
lea oracles, %r9
and $0xff, %r14
shlq $12, %r14
mov (%r9,%r14,1), %r14
pop %rsi
pop %rax
pop %r9
pop %r14
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 0, 'same': False, 'type': 'addresses_US'}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': True, 'type': 'addresses_US'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 2, 'same': True, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 9, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 5, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'}
{'dst': {'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 5, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 2, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 9, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'STOR'}
{'src': {'congruent': 2, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 4, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'00': 8}
00 00 00 00 00 00 00 00
*/
|
Transynther/x86/_processed/AVXALIGN/_st_sm_/i3-7100_9_0xca_notsx.log_34_244.asm | ljhsiun2/medusa | 9 | 102896 | <filename>Transynther/x86/_processed/AVXALIGN/_st_sm_/i3-7100_9_0xca_notsx.log_34_244.asm<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r15
push %r8
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x1685, %rsi
lea addresses_D_ht+0x18885, %rdi
nop
nop
nop
inc %rbp
mov $64, %rcx
rep movsb
nop
nop
inc %r15
lea addresses_D_ht+0x1c6de, %r8
nop
xor $28778, %rbp
mov (%r8), %r15
nop
nop
nop
and %rsi, %rsi
lea addresses_WC_ht+0x9705, %rsi
lea addresses_A_ht+0x1984d, %rdi
nop
nop
sub $63048, %r12
mov $92, %rcx
rep movsw
nop
nop
nop
nop
add %rsi, %rsi
lea addresses_WT_ht+0x19085, %rcx
nop
cmp %rbp, %rbp
movl $0x61626364, (%rcx)
nop
nop
nop
cmp $6033, %r8
lea addresses_D_ht+0xa285, %rsi
nop
nop
nop
add $33745, %r8
mov $0x6162636465666768, %rbp
movq %rbp, %xmm0
vmovups %ymm0, (%rsi)
nop
nop
nop
nop
xor %rcx, %rcx
lea addresses_normal_ht+0x11885, %r15
nop
nop
nop
nop
cmp %r8, %r8
mov $0x6162636465666768, %rcx
movq %rcx, (%r15)
nop
nop
cmp $37913, %r8
lea addresses_WC_ht+0xe085, %r8
nop
nop
nop
nop
nop
sub $15749, %rcx
and $0xffffffffffffffc0, %r8
vmovntdqa (%r8), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $1, %xmm5, %rbp
nop
add %rcx, %rcx
lea addresses_D_ht+0xd92f, %r8
nop
nop
nop
nop
inc %r12
mov (%r8), %r15w
dec %rcx
lea addresses_normal_ht+0x19395, %rcx
nop
and %rbp, %rbp
movups (%rcx), %xmm6
vpextrq $1, %xmm6, %r12
nop
nop
nop
xor %r15, %r15
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r15
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r14
push %rax
push %rbp
push %rcx
push %rdi
// Store
mov $0x7b82190000000845, %r13
nop
nop
sub $23291, %rbp
mov $0x5152535455565758, %rax
movq %rax, %xmm3
movups %xmm3, (%r13)
and %r10, %r10
// Load
lea addresses_RW+0x14e5, %rcx
nop
nop
nop
nop
and %r14, %r14
vmovups (%rcx), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $1, %xmm2, %rax
nop
nop
and $3812, %r13
// Store
lea addresses_US+0xa3e1, %rdi
nop
nop
nop
nop
sub %r13, %r13
mov $0x5152535455565758, %r14
movq %r14, (%rdi)
nop
nop
nop
nop
nop
and $31760, %rax
// Store
lea addresses_PSE+0x1ef25, %rax
nop
nop
sub %r14, %r14
mov $0x5152535455565758, %rdi
movq %rdi, %xmm4
vmovups %ymm4, (%rax)
nop
nop
nop
nop
add %rcx, %rcx
// Store
lea addresses_D+0x16885, %r14
nop
nop
nop
nop
nop
cmp %rdi, %rdi
mov $0x5152535455565758, %r10
movq %r10, %xmm6
vmovups %ymm6, (%r14)
nop
nop
nop
inc %rdi
// Faulty Load
lea addresses_D+0x16885, %rax
nop
nop
nop
nop
nop
xor %rdi, %rdi
mov (%rax), %rbp
lea oracles, %rax
and $0xff, %rbp
shlq $12, %rbp
mov (%rax,%rbp,1), %rbp
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r14
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_NC', 'size': 16, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_RW', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_US', 'size': 8, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_PSE', 'size': 32, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 32, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 8, 'AVXalign': True}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}}
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 11, 'NT': False, 'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 11, 'NT': True, 'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'58': 34}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
programs/oeis/026/A026200.asm | jmorken/loda | 1 | 6546 | <gh_stars>1-10
; A026200: a(n) = (s(n) + 2)/3, where s(n) is the n-th number congruent to 1 mod 3 in A026166.
; 1,2,4,6,3,8,10,12,5,14,16,18,7,20,22,24,9,26,28,30,11,32,34,36,13,38,40,42,15,44,46,48,17,50,52,54,19,56,58,60,21,62,64,66,23,68,70,72,25,74,76,78,27,80,82,84,29,86,88,90,31,92,94,96,33,98,100,102,35,104,106,108,37,110,112,114,39,116,118,120,41,122,124,126,43,128,130,132,45,134,136,138,47,140,142,144,49,146,148,150,51,152,154,156,53,158,160,162,55,164,166,168,57,170,172,174,59,176,178,180,61,182,184,186,63,188,190,192,65,194,196,198,67,200,202,204,69,206,208,210,71,212,214,216,73,218,220,222,75,224,226,228,77,230,232,234,79,236,238,240,81,242,244,246,83,248,250,252,85,254,256,258,87,260,262,264,89,266,268,270,91,272,274,276,93,278,280,282,95,284,286,288,97,290,292,294,99,296,298,300,101,302,304,306,103,308,310,312,105,314,316,318,107,320,322,324,109,326,328,330,111,332,334,336,113,338,340,342,115,344,346,348,117,350,352,354,119,356,358,360,121,362,364,366,123,368,370,372,125,374
mov $1,$0
add $1,$0
mov $3,$0
mod $0,4
sub $3,1
add $3,$0
lpb $0
mov $0,$2
add $1,$3
mul $1,2
lpe
div $1,4
add $1,1
|
data/mapObjects/ceruleanhouse1.asm | etdv-thevoid/pokemon-rgb-enhanced | 1 | 176517 | <filename>data/mapObjects/ceruleanhouse1.asm<gh_stars>1-10
CeruleanHouse1Object:
db $a ; border block
db $2 ; warps
db $7, $2, $1, $ff
db $7, $3, $1, $ff
db $0 ; signs
db $2 ; objects
object SPRITE_OLD_MEDIUM_WOMAN, $5, $4, STAY, LEFT, $1 ; person
object SPRITE_GAMBLER, $1, $2, STAY, NONE, $2 ; person
; warp-to
EVENT_DISP CERULEAN_HOUSE_1_WIDTH, $7, $2
EVENT_DISP CERULEAN_HOUSE_1_WIDTH, $7, $3
|
oeis/229/A229080.asm | neoneye/loda-programs | 11 | 13476 | ; A229080: Primes of the form T(k) + S(k) + 1 where T(k) is the k-th triangular number and S(k) is the k-th square number.
; Submitted by <NAME>
; 3,41,101,127,223,443,673,877,1277,1553,2543,2927,3061,4241,4733,4903,5431,6971,7177,8933,9883,10627,11927,12743,13873,17551,19211,20593,21661,26203,31177,33377,36583,40427,51431,58313,60101,60703,67523,68161,75377,81551,83663,92381,95383,101531,104677,108677,118583,124561,135151,146173,150893,154723,157627,162527,177677,187091,190283,191353,194581,203321,204427,207763,213383,216791,217933,227177,230693,231871,246241,261043,264811,276277,286673,290621,308041,340103,353081,363343,375251,393473
mov $2,332202
lpb $2
mov $3,$6
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,3
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
sub $2,18
sub $5,1
add $5,$1
mov $6,$5
lpe
mov $0,$5
add $0,1
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/controlled6_pkg-iterators.adb | best08618/asylo | 7 | 19786 | package body Controlled6_Pkg.Iterators is
function Find return Iterator_Type is
Iterator : Iterator_Type;
begin
return Iterator;
end Find;
function Current (Iterator : in Iterator_Type) return T is begin
return Iterator.Current.Item;
end Current;
procedure Find_Next (Iterator : in out Iterator_Type) is begin
Iterator.Current := null;
end Find_Next;
function Is_Null (Iterator : in Iterator_Type) return Boolean is begin
return Iterator.Current = null;
end Is_Null;
end Controlled6_Pkg.Iterators;
|
Application Support/BBEdit/Packages/dStyle.bbpackage/Contents/Scripts/Editor action/Move line up.applescript | bhdicaire/bbeditSetup | 0 | 4599 | <filename>Application Support/BBEdit/Packages/dStyle.bbpackage/Contents/Scripts/Editor action/Move line up.applescript<gh_stars>0
tell application "BBEdit"
local x, myline, oldCount
set x to startLine of selection
if x = 1 then
beep
return
end if
tell text 1 of window 1
set oldCount to count of lines
set myline to contents of line x
delete line x
if x = 2 then
if length of line 1 = 0 then
make line at beginning with data "
"
end if
make line at beginning with data myline
else
if length of line (x - 2) = 0 then
make line at line (x - 2) with data "
"
make line at line (x - 1) with data myline
else
make line at line (x - 2) with data myline
end if
end if
select insertion point before line (x - 1)
end tell
end tell |
Funcion.asm | wolfghost9898/Calculadora-Assembler | 3 | 82649 | ;##############################################################################
;########################## PEDIR LOS COEFICIENTES ###################
;##############################################################################
almacenarCoeficientes macro
LOCAL salir
;############################ COEFICIENTE 4 ########################################
mostrarCadena msgCoeficiente4
ingresarCadena valor
verificarCoeficienteS coeficiente4
cmp bx,1d
je salir
;############################ COEFICIENTE 3 ########################################
mostrarCadena msgCoeficiente3
ingresarCadena valor
verificarCoeficienteS coeficiente3
cmp bx,1d
je salir
;############################ COEFICIENTE 2 ########################################
mostrarCadena msgCoeficiente2
ingresarCadena valor
verificarCoeficienteS coeficiente2
cmp bx,1d
je salir
;############################ COEFICIENTE 1 ########################################
mostrarCadena msgCoeficiente1
ingresarCadena valor
verificarCoeficienteS coeficiente1
cmp bx,1d
je salir
;############################ COEFICIENTE 0 ########################################
mostrarCadena msgCoeficiente0
ingresarCadena valor
verificarCoeficienteS coeficiente0
cmp bx,1d
je salir
salir:
endm
;##############################################################################
;########################## CONTROLAR ESCALAS ORIGINAL ###################
;##############################################################################
controlEscalaOriginal macro
LOCAL escala4,salto,escala3,escala2
cmp [coeficiente4 + 1],0d
jne escala4
cmp [coeficiente3 + 1],0d
jne escala3
cmp [coeficiente2 + 1],0d
jne escala2
mov escala,1d
mov limiteSuperior,108d
mov limiteSuperiorN,-108d
mov terminarTemp,0d
jmp salto
escala4:
mov escala,15d
mov limiteSuperior,1200d
mov limiteSuperiorN,-1200d
mov terminarTemp,2d
jmp salto
escala3:
mov escala,20d
mov limiteSuperior,1000d
mov limiteSuperiorN,-1000d
mov terminarTemp,1d
jmp salto
escala2:
mov escala,20d
mov limiteSuperior,2025d
mov limiteSuperiorN,-2025d
mov terminarTemp,0d
jmp salto
salto:
endm
;##############################################################################
;########################## CONTROLAR ESCALAS DERIVADA ###################
;##############################################################################
controlEscalaDerivada macro
LOCAL escala4,salto,escala3,escala2
cmp [coeficiente3D + 1],0d
jne escala3
cmp [coeficiente2D + 1],0d
jne escala2
mov escala,1d
mov limiteSuperior,108d
mov limiteSuperiorN,-108d
mov terminarTemp,0d
jmp salto
escala3:
mov escala,20d
mov limiteSuperior,1200d
mov limiteSuperiorN,-1200d
mov terminarTemp,1d
jmp salto
escala2:
mov escala,20d
mov limiteSuperior,2025d
mov limiteSuperiorN,-2025d
mov terminarTemp,0d
jmp salto
salto:
endm
;##############################################################################
;########################## CONTROLAR ESCALAS INTEGRAL ###################
;##############################################################################
controlEscalaIntegral macro
LOCAL escala4,salto,escala3,escala2
cmp [coeficiente5I + 1],0d
jne escala4
cmp [coeficiente4I + 1],0d
jne escala4
cmp [coeficiente3I + 1],0d
jne escala3
cmp [coeficiente2I + 1],0d
jne escala2
mov escala,1d
mov limiteSuperior,108d
mov limiteSuperiorN,-108d
mov terminarTemp,0d
jmp salto
escala4:
mov escala,15d
mov limiteSuperior,1200d
mov limiteSuperiorN,-1200d
mov terminarTemp,2d
jmp salto
escala3:
mov escala,20d
mov limiteSuperior,1000d
mov limiteSuperiorN,-1000d
mov terminarTemp,1d
jmp salto
escala2:
mov escala,20d
mov limiteSuperior,2025d
mov limiteSuperiorN,-2025d
mov terminarTemp,0d
jmp salto
salto:
endm
;##############################################################################
;########################## VERIFICAR LOS COEFICIENTES INGRESADOS(SIGNO) ###################
;##############################################################################
verificarCoeficienteS macro coeficiente
LOCAL positivo,salir,negativo
lea SI, valor + 2
mov dl, [SI + 0]
cmp dl,'+'
je positivo
cmp dl,'-'
je negativo
mov [coeficiente + 0],0d
mov bx,0d
verificarCoeficienteN coeficiente
jmp salir
positivo:
mov [coeficiente + 0],0d
mov bx,1d
verificarCoeficienteN coeficiente
jmp salir
negativo:
mov [coeficiente + 0],1d
mov bx,1d
verificarCoeficienteN coeficiente
jmp salir
salir:
endm
;##############################################################################
;########################## VERIFICAR LOS COEFICIENTES INGRESADOS(NUMERO) ###################
;##############################################################################
verificarCoeficienteN macro coeficiente
LOCAL salir,fin
lea SI, valor + 2
mov dl, [SI + bx]
cmp dl,'0'
jl salir
cmp dl,'9'
jg salir
sub dl,48d
mov [coeficiente + 1],dl
mov bx,0d
jmp fin
salir:
mov bx,1d
fin:
endm
;##############################################################################
;########################## VERIFICAR LOS LIMITES INGRESADOR(SIGNO) ###################
;##############################################################################
verificarLimiteS macro limite
LOCAL positivo,salir,negativo
lea SI, valor + 2
mov dl, [SI + 0]
cmp dl,'+'
je positivo
cmp dl,'-'
je negativo
mov [limite + 0],0d
mov bx,0d
verificarLimiteN limite
jmp salir
positivo:
mov [limite + 0],0d
mov bx,1d
verificarLimiteN limite
jmp salir
negativo:
mov [limite + 0],1d
mov bx,1d
verificarLimiteN limite
jmp salir
salir:
endm
;##############################################################################
;########################## VERIFICAR LOS LIMITES INGRESADOS(NUMERO) ###################
;##############################################################################
verificarLimiteN macro limite
LOCAL salir,fin
lea SI, valor + 2
mov dl, [SI + bx]
cmp dl,'0'
jl salir
cmp dl,'9'
jg salir
;Decena
sub dl,48d
mov al,dl
xor ah,ah
mov cl,10d
mul cl
inc bx
;Unidad
xor dx,dx
mov dl, [SI + bx]
cmp dl,'0'
jl salir
cmp dl,'9'
jg salir
sub dl,48d
add dl,al
mov [limite + 1],dl
mov bx,0d
jmp fin
salir:
mov bx,1d
fin:
endm
;##############################################################################
;########################## COMPARA QUE EL LIMITE INFERIOR SEA MENOR AL LIMITE SUPERIOR ###################
;##############################################################################
compararLimites macro
LOCAL compararNegativo,fin,error,comparar
xor bx,bx
cmp [xInicial + 0],1d
je compararNegativo
cmp [xFinal + 0],1d
je error
mov bl,[xInicial + 1]
cmp bl,[xFinal + 1]
jg error
mov bx,0d
jmp fin
compararNegativo:
cmp [xFinal + 0],1d
je comparar
mov bx,0d
jmp fin
comparar:
mov bl,[xInicial + 1]
cmp bl,[xFinal + 1]
jl error
mov bx,0d
jmp fin
error:
mov bx,1d
fin:
endm
;##############################################################################
;########################## GRAFICAR FUNCION ORIGINAL ###################
;##############################################################################
;##############################################################################
;########################## GRAFICAR EJES ###################
;##############################################################################
graficarEjes macro
LOCAL ejeX,ejeY
mov ax,13h
int 10h
mov cx,0000h
mov dx,0000h
xor cx,cx
mov dx,100d
ejeX:
mov ah,0ch
mov al,12
int 10h
inc cx
cmp cx,320d
jle ejeX
mov cx,160
xor dx,dx
ejeY:
mov ah,0ch
mov al,12
int 10h
inc dx
cmp dx,200d
jle ejeY
endm
;##############################################################################
;########################## GRAFICAR ORIGINAL ###################
;##############################################################################
graphOriginal macro
LOCAL ciclo,salir,yNegativo,saltoY,xNegativo,saltoX,coorN,saltoCoor,salto,cero,saltoPrimero
graficarEjes
convertirNumero tempI,xInicial
convertirNumero tempF,xFinal
mov firstValorX,0d
mov bl,tempI
ciclo:
mov temp2,bl
cmp bl,tempF
jg salir
push bx
cmp bl,0d
jl xNegativo
ejeXPositivo bl
jmp saltoX
xNegativo:
ejeXNegativo bl
saltoX:
mov temporalY,0d
mov bl,temp2
analizarCoeficiente coeficiente4,4d
cmp dx,-1d
je cero
mov bl,temp2
analizarCoeficiente coeficiente3,3d
cmp dx,-1d
je cero
mov bl,temp2
analizarCoeficiente coeficiente2,2d
mov bl,temp2
analizarCoeficiente coeficiente1,1d
mov bl,temp2
analizarCoeficiente coeficiente0,0d
mov bx,limiteSuperior
cmp temporalY,bx
jge cero
mov bx,limiteSuperiorN
cmp temporalY,bx
jle cero
mov ax,temporalY
cmp al,0d
jl coorN
escalaY 0d
pop cx
cmp dl,0d
jle salto
jmp saltoCoor
coorN:
neg ax
escalaY 1d
pop cx
cmp dx,200d
jge salto
saltoCoor:
mov lastValor,dx
mov lastValorX,cx
cmp firstValorX,0d
jne saltoPrimero
mov firstValorX,cx
mov firstValor,dx
saltoPrimero:
mov ah,0ch
mov al,9
int 10h
jmp salto
cero:
pop cx
salto:
pop bx
inc bx
jmp ciclo
salir:
terminarGrafica firstValorX,firstValor
terminarGrafica lastValorX,lastValor
; esperar por tecla
mov ah,10h
int 16h
mov ax,3h
int 10h
endm
;##############################################################################
;########################## TERMINA LA GRAFICA ###################
;##############################################################################
terminarGrafica macro posX,posY
LOCAl salto,incrementar,decrementar
cmp terminarTemp,0d
je salto
xor bx,bx
mov cx,posX
mov bx,posY
cmp terminarTemp,2d
je decrementar
cmp bx,100d
jle decrementar
incrementar:
cmp bx,200d
jg salto
mov dx,bx
mov ah,0ch
mov al,9
int 10h
inc bx
inc bx
inc bx
inc bx
inc bx
inc bx
inc bx
jmp incrementar
jmp salto
decrementar:
cmp bx,0d
jl salto
mov dx,bx
mov ah,0ch
mov al,9
int 10h
dec bx
dec bx
dec bx
dec bx
dec bx
dec bx
dec bx
jmp decrementar
salto:
endm
;##############################################################################
;########################## GRAFICAR DERIVADA ###################
;##############################################################################
graphDerivada macro
LOCAL ciclo,salir,yNegativo,saltoY,xNegativo,saltoX,coorN,saltoCoor,salto,cero,saltoPrimero
graficarEjes
convertirNumero tempI,xInicial
convertirNumero tempF,xFinal
mov firstValorX,0d
mov lastValorX,0d
mov bl,tempI
ciclo:
mov temp2,bl
cmp bl,tempF
jg salir
push bx
cmp bl,0d
jl xNegativo
ejeXPositivo bl
jmp saltoX
xNegativo:
ejeXNegativo bl
saltoX:
mov temporalY,0d
mov bl,temp2
analizarCoeficiente coeficiente3D,3d
cmp dx,-1d
je cero
mov bl,temp2
analizarCoeficiente coeficiente2D,2d
cmp dx,-1d
je cero
mov bl,temp2
analizarCoeficiente coeficiente1D,1d
cmp dx,-1d
je cero
mov bl,temp2
analizarCoeficiente coeficiente0D,0d
cmp dx,-1d
je cero
mov bx,limiteSuperior
cmp temporalY,bx
jge cero
mov bx,limiteSuperiorN
cmp temporalY,bx
jle cero
mov ax,temporalY
cmp al,0d
jl coorN
escalaY 0d
pop cx
cmp dl,0d
jle salto
jmp saltoCoor
coorN:
neg ax
escalaY 1d
pop cx
cmp dx,200d
jge salto
saltoCoor:
mov lastValor,dx
mov lastValorX,cx
cmp firstValorX,0d
jne saltoPrimero
mov firstValorX,cx
mov firstValor,dx
saltoPrimero:
mov ah,0ch
mov al,9
int 10h
jmp salto
cero:
pop cx
salto:
pop bx
inc bx
jmp ciclo
salir:
terminarGrafica firstValorX,firstValor
terminarGrafica lastValorX,lastValor
; esperar por tecla
mov ah,10h
int 16h
mov ax,3h
int 10h
endm
;##############################################################################
;########################## GRAFICAR INTEGRAL ###################
;##############################################################################
graphIntegral macro
LOCAL ciclo,salir,yNegativo,saltoY,xNegativo,saltoX,coorN,saltoCoor,salto,cero,saltoPrimero
graficarEjes
convertirNumero tempI,xInicial
convertirNumero tempF,xFinal
mov firstValorX,0d
mov lastValorX,0d
mov bl,tempI
ciclo:
mov temp2,bl
cmp bl,tempF
jg salir
push bx
cmp bl,0d
jl xNegativo
ejeXPositivo bl
jmp saltoX
xNegativo:
ejeXNegativo bl
saltoX:
mov temporalY,0d
mov bl,temp2
analizarCoeficienteIntegral coeficiente5I,5d
cmp dx,-1d
je cero
mov bl,temp2
analizarCoeficienteIntegral coeficiente4I,4d
cmp dx,-1d
je cero
mov bl,temp2
analizarCoeficienteIntegral coeficiente3I,3d
cmp dx,-1d
je cero
mov bl,temp2
analizarCoeficienteIntegral coeficiente2I,2d
cmp dx,-1d
je cero
mov bl,temp2
analizarCoeficienteIntegral coeficiente1I,1d
cmp dx,-1d
je cero
mov bl,temp2
analizarCoeficiente coeficiente0I,0d
cmp dx,-1d
je cero
mov bx,limiteSuperior
cmp temporalY,bx
jge cero
mov bx,limiteSuperiorN
cmp temporalY,bx
jle cero
mov ax,temporalY
cmp al,0d
jl coorN
escalaY 0d
pop cx
cmp dl,0d
jle salto
jmp saltoCoor
coorN:
neg ax
escalaY 1d
pop cx
cmp dx,200d
jge salto
saltoCoor:
mov lastValor,dx
mov lastValorX,cx
cmp firstValorX,0d
jne saltoPrimero
mov firstValorX,cx
mov firstValor,dx
saltoPrimero:
mov ah,0ch
mov al,9
int 10h
jmp salto
cero:
pop cx
salto:
pop bx
inc bx
jmp ciclo
salir:
terminarGrafica firstValorX,firstValor
terminarGrafica lastValorX,lastValor
; esperar por tecla
mov ah,10h
int 16h
mov ax,3h
int 10h
endm
;##############################################################################
;########################## Analizar Coeficiente ###################
;##############################################################################
analizarCoeficiente macro coeficiente,exponente
LOCAL yNegativo,saltoY,negar,saltoN,salto
xor ax,ax
negarNumero
xor bh,bh
xor dx,dx
potencia exponente,bx
cmp dx,0d
je salto
cmp terminarTemp,0d
je saltoY
mov dx,-1d
jmp saltoY
salto:
xor bx,bx
mov bx,ax
mov cx,exponente
mov temp3,0d
cmp cx,0d
je saltoN
cmp cx,2d
je saltoN
cmp cx,4d
je saltoN
cmp temp2,0
jl negar
jmp saltoN
negar:
mov temp3,1d
saltoN:
xor ax,ax
mov al,[coeficiente + 1]
cmp [coeficiente + 0],1d
je yNegativo
ejeYPositivo
jmp saltoY
yNegativo:
ejeYNegativo
saltoY:
endm
;##############################################################################
;########################## Analizar Coeficiente Integral ###################
;##############################################################################
analizarCoeficienteIntegral macro coeficiente,exponente
LOCAL yNegativo,saltoY,negar,saltoN,salto
xor ax,ax
negarNumero
xor bh,bh
xor dx,dx
potencia exponente,bx
cmp dx,0d
je salto
cmp terminarTemp,0d
je saltoY
mov dx,-1d
jmp saltoY
salto:
xor bx,bx
mov bx,ax
mov cx,exponente
mov temp3,0d
cmp cx,0d
je saltoN
cmp cx,2d
je saltoN
cmp cx,4d
je saltoN
cmp temp2,0
jl negar
jmp saltoN
negar:
mov temp3,1d
saltoN:
xor ax,ax
xor cx,cx
mov al,[coeficiente + 1]
mov cl,[coeficiente + 2]
div cl
xor ah,ah
cmp [coeficiente + 0],1d
je yNegativo
ejeYPositivo
jmp saltoY
yNegativo:
ejeYNegativo
saltoY:
endm
;##############################################################################
;########################## GRAFICAR EJE X + ###################
;##############################################################################
ejeXPositivo macro numero
xor ax,ax
mov al,numero
xor ah,ah
mov cx,160d
mul cx
mov cx,99d
div cx
xor ah,ah
add ax,160d
mov cx,ax
push cx
endm
;##############################################################################
;########################## GRAFICAR EJE X - ###################
;##############################################################################
ejeXNegativo macro numero
xor ax,ax
mov al,numero
neg al
xor ah,ah
mov cx,160d
mul cx
mov cx,99d
div cx
xor ah,ah
mov bx,ax
mov ax,160d
sub ax,bx
mov cx,ax
push cx
endm
;##############################################################################
;########################## GRAFICAR EJE Y + ###################
;##############################################################################
ejeYPositivo macro
LOCAL negativo,salto,fin
mul bx
cmp dx,0d
jne fin
cmp temp3,1d
je negativo
add temporalY,ax
jmp salto
negativo:
sub temporalY,ax
jmp salto
fin:
mov dx,-1
salto:
endm
;##############################################################################
;########################## GRAFICAR EJE Y + ###################
;##############################################################################
ejeYNegativo macro
LOCAL negativo,salto,fin
mul bx
cmp dx,0d
jne fin
cmp temp3,1d
je negativo
sub temporalY,ax
jmp salto
negativo:
add temporalY,ax
jmp salto
fin:
mov dx,-1
salto:
endm
;##############################################################################
;########################## ESCALA Y ###################
;##############################################################################
escalaY macro signo
LOCAL positivo,salto,error
xor cx,cx
xor dx,dx
mov cx,escala
div cx
xor ah,ah
mov bx,signo
cmp bx,0d
je positivo
mov dx,ax
add dx,100d
jmp salto
positivo:
mov dx,100d
sub dx,ax
jmp salto
error:
xor dx,dx
salto:
endm
;##############################################################################
;########################## CONVERTIR NUMERO ###################
;##############################################################################
convertirNumero macro numero,limite
LOCAL negativo,salto
xor ax,ax
mov al,[limite + 1]
mov numero,al
mov al,numero
cmp [limite + 0],1d
je negativo
jmp salto
negativo:
neg al
xor ah,ah
mov numero,al
salto:
endm
;##############################################################################
;########################## NEGAR NUMERO ###################
;##############################################################################
negarNumero macro
LOCAL negativo,salto
cmp bl,0d
jl negativo
jmp salto
negativo:
neg bx
salto:
endm
;##############################################################################
;########################## POTENCIA ###################
;##############################################################################
potencia macro cantidad,valor
LOCAL ciclo,fin
xor cx,cx
mov cl,cantidad
mov ax,1d
cmp cl,0d
jg ciclo
mov ax,1d
jmp fin
ciclo:
cmp cx,1d
jl fin
mul valor
dec cx
jmp ciclo
fin:
endm
;##############################################################################
;########################## MOSTRAR FUNCION ORIGINAL ###################
;##############################################################################
mostrarFuncionOTexto macro
mostrarCaracter 'f'
mostrarCaracter '('
mostrarCaracter 'x'
mostrarCaracter ')'
mostrarCaracter '='
mostrarCaracter 32
mostrarCaracter 32
mostrarCaracter 32
mostrarCoeficiente coeficiente4,'4'
mostrarCoeficiente coeficiente3,'3'
mostrarCoeficiente coeficiente2,'2'
mostrarCoeficiente coeficiente1,'1'
mostrarCoeficiente coeficiente0,'0'
endm
;##############################################################################
;########################## MOSTRAR COEFICIENTE ###################
;##############################################################################
mostrarCoeficiente macro coeficiente,numero
LOCAL salto
mostrarSigno [coeficiente + 0]
mov dl,[coeficiente + 1]
xor dh,dh
mostrarNumero dl
mov dl,numero
cmp dl,48d
je salto
mostrarCaracter 'X'
mostrarCaracter numero
mostrarCaracter 32
mostrarCaracter 32
salto:
endm
;##############################################################################
;########################## MOSTRAR EL SIGNO + / - ###################
;##############################################################################
mostrarSigno macro signo
LOCAL positivo,salto
cmp signo,0d
je positivo
mostrarCaracter '-'
jmp salto
positivo:
mostrarCaracter '+'
salto:
endm
;##############################################################################
;########################## CALCULAR DERIVADA ###################
;##############################################################################
calcularDerivada macro coeficiente,ncoeficiente,numero
xor ax,ax
xor bx,bx
xor cx,cx
mov al,[coeficiente + 1]
mov bx,numero
mul bx
mov cl,[coeficiente + 0]
mov [ncoeficiente + 0],cl
mov [ncoeficiente + 1],al
endm
;##############################################################################
;########################## MOSTRAR EN PANTALLA LA DERIVADA ###################
;##############################################################################
mostrarDerivadaTexto macro
calcularDerivada coeficiente4,coeficiente3D,4d
calcularDerivada coeficiente3,coeficiente2D,3d
calcularDerivada coeficiente2,coeficiente1D,2d
calcularDerivada coeficiente1,coeficiente0D,1d
mostrarCaracter 'f'
mostrarCaracter 39d
mostrarCaracter '('
mostrarCaracter 'x'
mostrarCaracter ')'
mostrarCaracter '='
mostrarCaracter 32
mostrarCaracter 32
mostrarCaracter 32
mostrarCoeficiente coeficiente3D,'3'
mostrarCoeficiente coeficiente2D,'2'
mostrarCoeficiente coeficiente1D,'1'
mostrarCoeficiente coeficiente0D,'0'
endm
;##############################################################################
;########################## MOSTRAR NUMEROS EN DECENA ###################
;##############################################################################
mostrarNumero macro numero
LOCAL unidad,salto
xor ax,ax
xor cx,cx
mov al,numero
cmp al,10d
jl unidad
mov cl,10d
div cl
push ax
mov cl,al
add cl,48d
mostrarCaracter cl
pop ax
mov cl,ah
add cl,48d
mostrarCaracter cl
jmp salto
unidad:
mov bx,ax
add bx,48d
mostrarCaracter 48d
mostrarCaracter bl
salto:
endm
;##############################################################################
;########################## CALCULAR INTEGRAL ###################
;##############################################################################
calcularIntegral macro coeficiente,ncoeficiente,numero
xor ax,ax
xor cx,cx
mov cl,[coeficiente + 0]
mov [ncoeficiente + 0],cl
mov cl,[coeficiente + 1]
mov [ncoeficiente + 1],cl
mov [ncoeficiente + 2],numero
endm
;##############################################################################
;########################## MOSTRAR EN PANTALLA LA INTEGRAL ###################
;##############################################################################
mostrarIntegralTexto macro
calcularIntegral coeficiente4,coeficiente5I,5d
calcularIntegral coeficiente3,coeficiente4I,4d
calcularIntegral coeficiente2,coeficiente3I,3d
calcularIntegral coeficiente1,coeficiente2I,2d
calcularIntegral coeficiente0,coeficiente1I,1d
mostrarCaracter 'F'
mostrarCaracter '('
mostrarCaracter 'x'
mostrarCaracter ')'
mostrarCaracter '='
mostrarCaracter 32
mostrarCaracter 32
mostrarCaracter 32
mostrarCoeficienteIntegral coeficiente5I,'5'
mostrarCoeficienteIntegral coeficiente4I,'4'
mostrarCoeficienteIntegral coeficiente3I,'3'
mostrarCoeficienteIntegral coeficiente2I,'2'
mostrarCoeficienteIntegral coeficiente1I,'1'
endm
;##############################################################################
;########################## MOSTRAR COEFICIENTE DE UNA INTEGRAL ###################
;##############################################################################
mostrarCoeficienteIntegral macro coeficiente,numero
LOCAL salto
mostrarSigno [coeficiente + 0]
mov dl,[coeficiente + 1]
xor dh,dh
mostrarNumero dl
mostrarCaracter '/'
mov dl,[coeficiente + 2]
xor dh,dh
mostrarNumero dl
mov dl,numero
cmp dl,48d
je salto
mostrarCaracter 'X'
mostrarCaracter numero
mostrarCaracter 32
mostrarCaracter 32
salto:
endm |
programs/oeis/070/A070884.asm | karttu/loda | 1 | 247020 | ; A070884: 7 + x where x is congruent to {0, 4, 6, 10, 12, 16, 22, 24} mod 30.
; 7,11,13,17,19,23,29,31,37,41,43,47,49,53,59,61,67,71,73,77,79,83,89,91,97,101,103,107,109,113,119,121,127,131,133,137,139,143,149,151,157,161,163,167,169,173,179,181,187,191,193,197,199,203,209,211,217,221
add $0,1
cal $0,84968 ; Multiples of 7 coprime to 30.
mov $1,$0
div $1,7
|
GroupingScript.applescript | ishiharak/GroupingScript-for-Mac | 0 | 279 | <reponame>ishiharak/GroupingScript-for-Mac
set inputFile to choose file with prompt "Please specify CSV file formatted in order of id, group and alias."
set csvText to repChar((read inputFile as string), ASCII character 13, "")
set users to textToTwoDArray(csvText, character id 10, ",")
tell application "Finder"
repeat with user in users
try
set thePath to container of (path to me)
set nameOfGroup to (item 2 of user)
set nameOfAlias to (item 3 of user)
on error
return
end try
try
make new folder at thePath with properties {name:nameOfGroup}
end try
try
set pathOfUser to ((thePath as string) & item 1 of user) as alias
set pathOfGroup to ((thePath as string) & item 2 of user) as alias
if exists (pathOfGroup as string) & nameOfAlias then
move ((pathOfGroup as string) & nameOfAlias) as alias to trash
end if
make new alias file at pathOfGroup to pathOfUser with properties {name:nameOfAlias}
end try
end repeat
end tell
on textToTwoDArray(theText, mainDelimiter, secondaryDelimiter)
set {tids, text item delimiters} to {text item delimiters, mainDelimiter}
set firstArray to text items of theText
set text item delimiters to secondaryDelimiter
set twoDArray to {}
repeat with anItem in firstArray
set end of twoDArray to text items of anItem
end repeat
set text item delimiters to tids
return twoDArray
end textToTwoDArray
on repChar(origText, targStr, repStr)
set {txdl, AppleScript's text item delimiters} to {AppleScript's text item delimiters, targStr}
set temp to text items of origText
set AppleScript's text item delimiters to repStr
set res to temp as text
set AppleScript's text item delimiters to txdl
return res
end repChar |
samples/stemwords.adb | stcarrez/ada-stemmer | 3 | 3026 | with Ada.Text_IO;
with Ada.Command_Line;
with Stemmer.Factory;
procedure Stemwords is
use Stemmer.Factory;
function Get_Language (Name : in String) return Language_Type;
function Is_Space (C : in Character) return Boolean;
function Is_Space (C : in Character) return Boolean is
begin
return C = ' ' or C = ASCII.HT;
end Is_Space;
function Get_Language (Name : in String) return Language_Type is
begin
return Language_Type'Value ("L_" & Name);
exception
when Constraint_Error =>
Ada.Text_IO.Put_Line ("Unsupported language: " & Ada.Command_Line.Argument (1));
return L_ENGLISH;
end Get_Language;
Count : constant Natural := Ada.Command_Line.Argument_Count;
begin
if Count <= 1 then
Ada.Text_IO.Put_Line ("Usage: stemwords language file");
return;
end if;
declare
Lang : constant Language_Type := Get_Language (Ada.Command_Line.Argument (1));
Path : constant String := Ada.Command_Line.Argument (2);
File : Ada.Text_IO.File_Type;
begin
Ada.Text_IO.Open (File, Ada.Text_IO.In_File, Path);
while not Ada.Text_IO.End_Of_File (File) loop
declare
Line : constant String := Ada.Text_IO.Get_Line (File);
Pos : Positive := Line'First;
Last_Pos : Positive;
Start_Pos : Positive;
begin
while Pos <= Line'Last loop
Last_Pos := Pos;
while Pos <= Line'Last and then Is_Space (Line (Pos)) loop
Pos := Pos + 1;
end loop;
if Last_Pos < Pos then
Ada.Text_IO.Put (Line (Last_Pos .. Pos - 1));
end if;
exit when Pos > Line'Last;
Start_Pos := Pos;
while Pos <= Line'Last and then not Is_Space (Line (Pos)) loop
Pos := Pos + 1;
end loop;
Ada.Text_IO.Put (Stemmer.Factory.Stem (Lang, Line (Start_Pos .. Pos - 1)));
end loop;
Ada.Text_IO.New_Line;
end;
end loop;
Ada.Text_IO.Close (File);
end;
end Stemwords;
|
README/DependentlyTyped/Definability.agda | nad/dependently-typed-syntax | 5 | 8093 | <reponame>nad/dependently-typed-syntax
------------------------------------------------------------------------
-- A definability result: A "closed value" is the semantics of a
-- closed term if and only if it satisfies all "Kripke predicates"
------------------------------------------------------------------------
-- This module is based on parts of <NAME>'s (at the time of
-- writing forthcoming) MSc thesis, "On Definability and Normalization
-- by Evaluation in the Logical Framework". I have not followed
-- Ramcke's development to the letter, but I have taken inspiration
-- from it. Ramcke seems to in turn have taken inspiration from Jung
-- and Tiuryn's "A New Characterization of Lambda Definability".
import Axiom.Extensionality.Propositional as E
open import Level using (Level)
open import Data.Universe
-- The code makes use of the assumption that propositional equality is
-- extensional for functions.
module README.DependentlyTyped.Definability
(Uni₀ : Universe Level.zero Level.zero)
(ext : E.Extensionality Level.zero Level.zero)
where
open import Data.Product as Prod renaming (curry to c)
open import Function.Base hiding (_∋_) renaming (const to k)
open import Function.Equality using (_⟨$⟩_)
open import Function.Equivalence
using (_⇔_; module Equivalence; equivalence)
open import README.DependentlyTyped.NBE Uni₀ ext
open import README.DependentlyTyped.NormalForm Uni₀
open import README.DependentlyTyped.Term Uni₀
open import Relation.Binary.PropositionalEquality as P using (_≡_)
-- Predicates.
Predicate : Set₁
Predicate = ∀ {Γ σ} → Value Γ σ → Set
private
variable
Γ Δ : Ctxt
Γ₊ : Ctxt₊ Γ
σ τ : Type Γ
P : Predicate
-- Kripke predicates.
record Kripke (P : Predicate) : Set where
field
-- Single-step weakening.
weaken₁ :
{v : Value Γ σ} →
P v → P (v /̂Val ŵk[ τ ])
-- For π-types Kripke predicates have to be defined in a certain
-- way (up to logical equivalence).
definition-for-π :
∀ {σ τ} {f : Value Γ (Type-π σ τ)} →
P f
⇔
(∀ (Γ₊ : Ctxt₊ Γ) {v : Value (Γ ++₊ Γ₊) (σ /̂ ŵk₊ Γ₊)} →
P v → P ((f /̂Val ŵk₊ Γ₊) ˢ v))
-- Weakening.
weaken :
{v : Value Γ σ} (Γ₊ : Ctxt₊ Γ) →
P v → P (v /̂Val ŵk₊ Γ₊)
weaken ε = id
weaken (σ ◅ Γ₊) = weaken Γ₊ ∘ weaken₁
-- A "fundamental theorem" for Kripke predicates.
fundamental :
{ρ̂ : Γ ⇨̂ Δ} →
(∀ {σ} (x : Γ ∋ σ) → P (x /̂∋ ρ̂)) →
(t : Γ ⊢ σ) →
P (⟦ t ⟧ /̂Val ρ̂)
fundamental hyp (var x) = hyp x
fundamental hyp (t₁ · t₂) =
(Equivalence.to definition-for-π ⟨$⟩ fundamental hyp t₁)
ε (fundamental hyp t₂)
fundamental hyp (ƛ t) =
Equivalence.from definition-for-π ⟨$⟩ λ Δ₊ p →
fundamental
(λ { zero → p
; (suc x) → weaken Δ₊ (hyp x)
})
t
-- A special case for closed terms.
fundamental-closed : {σ : Type ε} → (t : ε ⊢ σ) → P ⟦ t ⟧
fundamental-closed = fundamental (λ ())
open Kripke
-- A predicate based on V̌alue.
∃-V̌alue : Predicate
∃-V̌alue {Γ = Γ} {σ = σ} v =
∃ λ (v̌ : V̌alue Γ σ) → v ≅-Value ⟦̌ v̌ ⟧
-- ∃-V̌alue is a Kripke predicate.
∃-V̌alue-Kripke : Kripke ∃-V̌alue
weaken₁ ∃-V̌alue-Kripke =
Prod.map ([_⟶_].function w̌eaken _)
(λ { P.refl → [_⟶_].corresponds w̌eaken _ _ })
definition-for-π ∃-V̌alue-Kripke {Γ = Γ} {σ = σ} {τ = τ} {f = f} =
equivalence
(λ { (f , P.refl) Γ₊ (v , P.refl) →
proj₁ f Γ₊ v , proj₂ f Γ₊ v
})
(λ hyp →
let
g : V̌alue-π Γ _ _ (IType-π σ τ)
g = λ Γ₊ v → proj₁ (hyp Γ₊ (v , P.refl))
lemma : f ≅-Value ⟦̌ _ ∣ g ⟧-π
lemma =
[ f ] ≡⟨⟩
[ c ((f /̂Val ŵk₊ (_ ◅ ε)) ˢ ⟦ var zero ⟧n) ] ≡⟨ curry-cong (ˢ-cong (P.refl {x = [ f /̂Val _ ]})
(P.sym $ ňeutral-to-normal-identity _ _)) ⟩
[ c ((f /̂Val ŵk₊ (_ ◅ ε)) ˢ
⟦ ňeutral-to-normal _ (var zero) ⟧n) ] ≡⟨⟩
[ c ((f /̂Val ŵk₊ (_ ◅ ε)) ˢ ⟦̌ řeflect _ (var zero) ⟧) ] ≡⟨ curry-cong (proj₂ (hyp _ _)) ⟩
[ c ⟦̌ g (_ ◅ ε) (řeflect _ (var zero)) ⟧ ] ≡⟨ P.sym (unfold-⟦̌∣⟧-π _ g) ⟩
[ ⟦̌ _ ∣ g ⟧-π ] ∎
in
( g
, (λ Γ₊ v → [ (⟦̌ _ ∣ g ⟧-π /̂Val ŵk₊ Γ₊) ˢ ⟦̌ v ⟧ ] ≡⟨ ˢ-cong (/̂Val-cong (P.sym lemma) P.refl) P.refl ⟩
[ (f /̂Val ŵk₊ Γ₊) ˢ ⟦̌ v ⟧ ] ≡⟨ proj₂ (hyp _ _) ⟩
[ ⟦̌ g Γ₊ v ⟧ ] ∎)
)
, lemma
)
where
open P.≡-Reasoning
-- The definability result.
definability :
{σ : Type ε} {v : Value ε σ} →
(∃ λ (t : ε ⊢ σ) → v ≡ ⟦ t ⟧)
⇔
({P : Predicate} → Kripke P → P v)
definability = equivalence
(λ { (t , P.refl) kripke → fundamental-closed kripke t })
(λ hyp → Prod.map ([_⟶_].function V̌al-subst.trans _)
≅-Value-⇒-≡
(hyp ∃-V̌alue-Kripke))
|
msx/rc2014-extended/alloc.asm | zoggins/yellow-msx-series-for-rc2014 | 19 | 177429 |
;-----------------------------------------------------------------------
;
; ALLOC ALLOCATES SPECIFIED AMOUNT OF MEMORY DOWNWARD FROM CURRENT
; HIMEM
;
; INPUTS:
; HL = MEMORY SIZE TO ALLOCATE
; OUTPUTS:
; IF SUCCESSFUL, CARRY FLAG RESET, HL POINTS TO THE BEGINNING OF ALLOCATED AREA
; OTHERWISE, CARRY FLAG SET, ALLOCATION NOT DONE.
;
ALLOC:
LD A, L ;IS REQUESTED SIZE 0?
OR H
RET Z ;YES, ALLOCATION ALWAYS SUCCEEDS
EX DE, HL ;CALCULATE -SIZE
LD HL, 0
SBC HL, DE
LD C, L ;REMEMBER SPECIFIED SIZE
LD B, H
ADD HL, SP ;[HL] = [SP] - SIZE
CCF
RET C ;SIZE TOO BIG
LD A, H
CP 0C2H ;HIGH(BOOTAD)
RET C ;NO ROOM LEFT
LD DE, (BOTTOM) ;GET CURRENT RAM BOTTOM
SBC HL, DE ;GET MEMORY SPACE LEFT AFTER ALLOCATION
RET C ;NO SPACE LEFT
LD A, H ;DO WE STILL HAVE BREATHING ROOM?
CP 2 ;HIGH(512)
RET C ;NO, NOT ENOUGH SPACE LEFT
;
; NOW, REQUESTED SIZE IS LEGAL, BEGIN ALLOCATION
;
PUSH BC ;SAVE -SIZE
LD HL, 0
ADD HL, SP ;GET CURRENT STACK POINTER TO [HL]
LD E, L ;MOVE SOURCE ADDRESS TO [DE]
LD D, H
ADD HL, BC
PUSH HL ;SAVE DESTINATION
LD HL, (STKTOP)
OR A
SBC HL, DE
LD C, L ;MOVE BYTE COUNT TO MOVE TO [BC]
LD B, H
INC BC
POP HL ;RESTORE DESTINATION
LD SP, HL ;DESTINATION BECOMES THE NEW SP
EX DE, HL
LDIR ;MOVE STACK CONTENTS
POP BC ;RESTORE -SIZE
LD HL, (HIMEM)
ADD HL, BC
LD (HIMEM), HL
LD DE, -2*(2+9+256)
ADD HL, DE
LD (FILTAB), HL ;POINTER TO FIRST FCB
EX DE, HL
LD HL, (MEMSIZ) ;UPDATE MEMSIZ
ADD HL, BC
LD (MEMSIZ), HL
LD HL, (NULBUF) ;UPDATE NULBUF
ADD HL, BC
LD (NULBUF), HL
LD HL, (STKTOP) ;UPDATE STKTOP
ADD HL, BC
;
; RE-BUILD BASIC'S FILE STRUCTURES
;
LD (STKTOP), HL
DEC HL ;AND SAVSTK
DEC HL
LD (SAVSTK), HL
LD L, E ;GET FILTAB IN [HL]
LD H, D
INC HL ;POINT TO FIRST FCB
INC HL
INC HL
INC HL
LD A, 2
DSKFLL:
EX DE, HL
LD (HL), E ;SET ADDRESS IN FILTAB
INC HL
LD (HL), D
INC HL
EX DE, HL
LD BC, 7
LD (HL), B ;MAKE IT LOOK CLOSED
ADD HL, BC
LD (HL), B ;CLEAR FLAG BYTE
LD BC, 9+256-7
ADD HL, BC ;POINT TO NEXT FCB
DEC A
JR NZ, DSKFLL
RET
; call_bios: ld iy,(EXPTBL-1) ;BIOS slot in iyh
; jp CALSLT ;interslot call
|
src/boot.asm | mohammad-yazdani/curros | 0 | 23193 | %include "multiboot2.inc"
KERNEL_PAGE_SIZE equ 0x1000
KERNEL_IMAGE_VADDR equ 0xFFFFFFFF80000000
KERNEL_PMAP_VADDR equ 0xFFFF800000000000
%define GET_PADDR(x) ((x) - KERNEL_IMAGE_VADDR)
%define GET_PML4(vaddr) (((vaddr) >> 39 ) & 0x1FF)
%define GET_PDPT(vaddr) (((vaddr) >> 30 ) & 0x1FF)
global sys_entry
extern kmain
section .multiboot_header
ASM_MULTIBOOT_CHECK_SUM equ (0xFFFFFFFF - (MULTIBOOT2_HEADER_MAGIC + ASM_MULTIBOOT_HEADER_SIZE + MULTIBOOT_ARCHITECTURE_I386) + 1)
section .multiboot_header
bits 32
align KERNEL_PAGE_SIZE
;====================
align MULTIBOOT_HEADER_ALIGN
start_hdr:
dd MULTIBOOT2_HEADER_MAGIC
dd MULTIBOOT_ARCHITECTURE_I386
dd ASM_MULTIBOOT_HEADER_SIZE
dd ASM_MULTIBOOT_CHECK_SUM
;====================
align MULTIBOOT_INFO_ALIGN
dw MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST
dw 0 ; flag
dd (8+4*3) ; size
dd MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME
dd MULTIBOOT_TAG_TYPE_MMAP
dd MULTIBOOT_TAG_TYPE_ACPI_NEW
;====================
align MULTIBOOT_INFO_ALIGN
dw MULTIBOOT_HEADER_TAG_MODULE_ALIGN; type=6
dw 0 ; flag
dd 8 ; size
;====================
align MULTIBOOT_INFO_ALIGN
dw MULTIBOOT_HEADER_TAG_END
dw 0 ; flag
dd 8 ; size
;====================
ASM_MULTIBOOT_HEADER_SIZE equ ($ - start_hdr)
section .text
bits 32
sys_entry:
cli
cld
cmp eax, MULTIBOOT2_BOOTLOADER_MAGIC
jne .end
; save multiboot info
mov dword [GET_PADDR(multiboot_info_ptr)], ebx
; setup stack
call check_long_mode ; check support for long mode
cmp eax, 1
jne .end
; disable paging first
mov eax, cr0 ; Set the A-register to control register 0.
and eax, ~(1 << 31) & 0xFFFFFFFF ; Clear the PG-bit, which is bit 31, and hack to get rid of warning
mov cr0, eax ; Set control register 0 to the A-register.
; point the first PML4 entry to the identity pdpt
mov eax, GET_PADDR(init_pml4)
mov dword [eax], GET_PADDR(init_pdpt_iden) + 11b ; write the lower bits, higher = 0
; point the nth PML4 entry to the kernel pdpt
mov eax, GET_PADDR(init_pml4) + GET_PML4(KERNEL_IMAGE_VADDR) * 8
mov dword [eax], GET_PADDR(init_pdpt_kern) + 11b
; point the nth PML4 entry to the kernel pmap pdpt
mov eax, GET_PADDR(init_pml4) + GET_PML4(KERNEL_PMAP_VADDR) * 8
mov dword [eax], GET_PADDR(init_pdpt_pmap) + 11b
; identity map the first 4GB and to kernel pmap region
mov eax, GET_PADDR(init_pdpt_iden)
mov edx, GET_PADDR(init_pdpt_pmap)
mov ebx, 10000011b ; R/W + SU + 1G page
mov ecx, 4 ; loop 4 times
.l0:
mov dword [eax], ebx
mov dword [edx], ebx
add ebx, 1*1024*1024*1024 ; 1G
add eax, 8
add edx, 8
loop .l0
; map the first 1 GB, which contains the kernel, to KERNEL_BASE_VADDR
mov eax, GET_PADDR(init_pdpt_kern)
; extract the PML4 entry
add eax, GET_PDPT(KERNEL_IMAGE_VADDR) * 8
mov ebx, 10000011b ; R/W + SU + 1G page
mov dword [eax], ebx
; enable PAE
mov eax, cr4 ; Set the A-register to control register 4.
or eax, 1 << 5 ; Set the PAE-bit, which is the 6th bit (bit 5).
mov cr4, eax ; Set control register 4 to the A-register.
; enable long mode
mov ecx, 0xC0000080 ; Set the C-register to 0xC0000080, which is the EFER MSR.
rdmsr ; Read from the model-specific register.
or eax, 1 << 8 ; Set the LM-bit which is the 9th bit (bit 8).
wrmsr ; Write to the model-specific register.
; let cr3 point at page table
mov eax, GET_PADDR(init_pml4)
mov cr3, eax
; enable paging, enter compatibility mode
mov eax, cr0 ; Set the A-register to control register 0.
or eax, 1 << 31 ; Set the PG-bit, which is bit 31.
mov cr0, eax ; Set control register 0 to the A-register.
; now we are in compat mode
; load the long mode GDT
lgdt [GET_PADDR(init_gdt.ptr)]
; switch to long mode
jmp init_gdt.code:GET_PADDR(sys_entry_64)
.end:
hlt
check_long_mode:
push ebp
mov ebp,esp
pushfd
pop eax
mov ecx, eax
xor eax, 1 << 21
push eax
popfd
pushfd
pop eax
push ecx
popfd
xor eax, ecx
jz .not_supported
mov eax, 0x80000000 ; Set the A-register to 0x80000000.
cpuid ; CPU identification.
cmp eax, 0x80000001 ; Compare the A-register with 0x80000001.
jb .not_supported ; It is less, there is no long mode.
mov eax, 0x80000001 ; Set the A-register to 0x80000001.
cpuid ; CPU identification.
test edx, 1 << 29 ; Test if the LM-bit, which is bit 29, is set in the D-register.
jz .not_supported ; They arent, there is no long mode.
mov eax,1
jmp .end
.not_supported:
xor eax,eax
.end:
mov esp,ebp
pop ebp
ret
section .data
bits 32
multiboot_info_ptr:
dd 0
section .text
bits 64
sys_entry_64:
; note that we are in long mode but rip is still lower
; switch to high address
mov rax, .high
jmp rax
.high:
; set ds segment
mov rax,init_gdt.data
mov ds, rax
; map GDT into virtual address space
mov qword [init_gdt.ptr + 2], init_gdt
lgdt [init_gdt.ptr]
;reload cs
push qword init_gdt.data ; ss
push qword init_stack ; rsp
pushfq
push qword init_gdt.code ; cs
push qword .reload ; rip
iretq
.reload:
mov rax, ss
mov ds, rax
mov es, rax
mov fs, rax
mov gs, rax
; unmap the first 4GB because we don't need them anymore
mov rax, GET_PADDR(init_pml4)
mov qword [rax], 0 ;
; flush TLB
mov rax, cr3
mov cr3, rax
; kernel is now in only -2GB mode
xor rdi, rdi
mov edi, dword [multiboot_info_ptr]
mov rax, KERNEL_PMAP_VADDR
add rdi, rax
call kmain
.end:
hlt
section .data
bits 64
align KERNEL_PAGE_SIZE
times KERNEL_PAGE_SIZE db 0
init_stack:
init_pml4:
align KERNEL_PAGE_SIZE
times KERNEL_PAGE_SIZE db 0
init_pdpt_iden:
align KERNEL_PAGE_SIZE
times KERNEL_PAGE_SIZE db 0
init_pdpt_pmap:
align KERNEL_PAGE_SIZE
times KERNEL_PAGE_SIZE db 0
init_pdpt_kern:
align KERNEL_PAGE_SIZE
times KERNEL_PAGE_SIZE db 0
init_gdt: ; Global Descriptor Table (long mode).
.null: equ $ - init_gdt ; The null descriptor.
dw 0 ; Limit (low).
dw 0 ; Base (low).
db 0 ; Base (middle)
db 0 ; Access.
db 0 ; Granularity.
db 0 ; Base (high).
.code: equ $ - init_gdt ; The code descriptor.
dw 0 ; Limit (low).
dw 0 ; Base (low).
db 0 ; Base (middle)
db 10011010b ; Access (exec/read).
db 00100000b ; Granularity.
db 0 ; Base (high).
.data: equ $ - init_gdt ; The data descriptor.
dw 0 ; Limit (low).
dw 0 ; Base (low).
db 0 ; Base (middle)
db 10010010b ; Access (read/write).
db 00100000b ; Granularity.
db 0 ; Base (high).
.ptr:
; GDT PTR
dw $ - init_gdt - 1 ; Limit.
dq GET_PADDR(init_gdt) ; Base.
|
libsrc/gfx/wide/w_xorborder.asm | ahjelm/z88dk | 640 | 98586 | ; ----- void __CALLEE__ xorborder(int x, int y, int x2, int y2)
IF !__CPU_INTEL__ && !__CPU_GBZ80__
SECTION code_graphics
PUBLIC xorborder
PUBLIC _xorborder
EXTERN asm_xorborder
.xorborder
._xorborder
pop af
pop de
pop hl
exx ; w_plotpixel and swapgfxbk must not use the alternate registers, no problem with w_line_r
pop de
pop hl
push hl
push de
exx
push hl
push de
push af ; ret addr
jp asm_xorborder
ENDIF
|
Src/SacaraVm/vm_set_ip.asm | mrfearless/sacara | 0 | 100924 | header_VmSetIp
vm_set_ip PROC
push ebp
mov ebp, esp
; read the argument
push [ebp+arg0]
call_vm_stack_pop_enc
; set the IP
mov ebx, [ebp+arg0]
mov [ebx+vm_ip], eax
mov esp, ebp
pop ebp
ret
vm_set_ip ENDP
header_marker |
drlvm/vm/interpreter/src/invokeJNI_Windows_em64t.asm | sirinath/Harmony | 8 | 803 | <filename>drlvm/vm/interpreter/src/invokeJNI_Windows_em64t.asm
; Licensed to the Apache Software Foundation (ASF) under one or more
; contributor license agreements. See the NOTICE file distributed with
; this work for additional information regarding copyright ownership.
; The ASF licenses this file to You 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.
PUBLIC invokeJNI
_TEXT SEGMENT
invokeJNI PROC
; int64 invokeJNI(uint64 *args, uword n_fps, uword n_stacks, GenericFunctionPointer f);
; rcx - memory
; rdx - n fp args
; r8 - n mem args
; r9 - function ptr
push rbp
mov rbp, rsp
mov rax, rcx ; mem
mov rcx, r8 ; n mem args
; cycle to fill all fp args
movsd xmm0, qword ptr [rax+8]
movsd xmm1, qword ptr [rax+16]
movsd xmm2, qword ptr [rax+24]
movsd xmm3, qword ptr [rax+32]
mov r10, r9 ; func ptr
; check for memory args
cmp rcx, 0
jz cycle_end
mov rdx, rsp ; Check stack alignment on 16 bytes
and rdx, 8 ; This code may be removed after we make sure that
jz no_abort ; compiler always calls us with aligned stack
int 3
no_abort:
mov rdx, rcx ; Align stack on 16 bytes before pushing stack
and rdx, 1 ; arguments in case we have odd number of stack
shl rdx, 3 ; arguments
sub rsp, rdx
; store memory args
lea r9, qword ptr [rax + rcx * 8 + 64]
sub r9, rsp ; offset
cycle:
push qword ptr [rsp+r9]
loop cycle
cycle_end:
mov rcx, [rax + 40]
mov rdx, [rax + 48]
mov r8, [rax + 56]
mov r9, [rax + 64]
sub rsp, 32 ; shadow space
call r10
leave
ret
invokeJNI ENDP
_TEXT ENDS
END
|
4_10.asm | juancstlm/Assembly-Programming | 0 | 94473 | <filename>4_10.asm
; Finds the largest value in an array
.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword
.data
array DWORD 8,9,2,1,4
max DWORD ?
.code
main proc
mov esi, OFFSEST array
mov ecx, SIZEOF array
call MaxNum
invoke ExitProcess,0
main ENDP
MaxNum proc
L2:
push esi
add esi, 4
sub ecx, 1
L1:
pop eax
pop ebx
cmp eax, ebx
ja small
push ebx
sub ecx,1
jnz L1
small:
push eax
sub ecx,1
jnz L1
pop eax
ret
ret
MaxNum endp
end main |
programs/oeis/267/A267882.asm | jmorken/loda | 1 | 10055 | ; A267882: Total number of ON (black) cells after n iterations of the "Rule 233" elementary cellular automaton starting with a single ON (black) cell.
; 1,1,4,10,19,30,43,58,75,94,115,138,163,190,219,250,283,318,355,394,435,478,523,570,619,670,723,778,835,894,955,1018,1083,1150,1219,1290,1363,1438,1515,1594,1675,1758,1843,1930,2019,2110,2203,2298,2395,2494,2595,2698,2803,2910,3019,3130,3243,3358,3475,3594,3715,3838,3963,4090,4219,4350,4483,4618,4755,4894,5035,5178,5323,5470,5619,5770,5923,6078,6235,6394,6555,6718,6883,7050,7219,7390,7563,7738,7915,8094,8275,8458,8643,8830,9019,9210,9403,9598,9795,9994,10195,10398,10603,10810,11019,11230,11443,11658,11875,12094,12315,12538,12763,12990,13219,13450,13683,13918,14155,14394,14635,14878,15123,15370,15619,15870,16123,16378,16635,16894,17155,17418,17683,17950,18219,18490,18763,19038,19315,19594,19875,20158,20443,20730,21019,21310,21603,21898,22195,22494,22795,23098,23403,23710,24019,24330,24643,24958,25275,25594,25915,26238,26563,26890,27219,27550,27883,28218,28555,28894,29235,29578,29923,30270,30619,30970,31323,31678,32035,32394,32755,33118,33483,33850,34219,34590,34963,35338,35715,36094,36475,36858,37243,37630,38019,38410,38803,39198,39595,39994,40395,40798,41203,41610,42019,42430,42843,43258,43675,44094,44515,44938,45363,45790,46219,46650,47083,47518,47955,48394,48835,49278,49723,50170,50619,51070,51523,51978,52435,52894,53355,53818,54283,54750,55219,55690,56163,56638,57115,57594,58075,58558,59043,59530,60019,60510,61003,61498,61995,62494
lpb $0
mov $1,$0
pow $0,2
sub $0,1
trn $0,4
mul $1,2
mov $2,1
add $2,$1
add $2,$0
mov $0,1
mov $1,$2
mul $1,2
lpe
sub $1,2
trn $1,2
div $1,2
add $1,1
|
extern/game_support/stm32f4/src/stm32f4-i2c.adb | AdaCore/training_material | 15 | 347 | <filename>extern/game_support/stm32f4/src/stm32f4-i2c.adb
------------------------------------------------------------------------------
-- --
-- Hardware Abstraction Layer for STM32 Targets --
-- --
-- Copyright (C) 2014, 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. --
-- --
------------------------------------------------------------------------------
with STM32F4.RCC; use STM32F4.RCC;
with Ada.Real_Time; use Ada.Real_Time;
package body STM32F4.I2C is
subtype I2C_SR1_Flag is I2C_Status_Flag range Start_Bit .. SMB_Alert;
subtype I2C_SR2_Flag is I2C_Status_Flag range Master_Slave_Mode .. Dual_Flag;
SR1_Flag_Pos : constant array (I2C_SR1_Flag) of Natural :=
(0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 14, 15);
SR2_Flag_Pos : constant array (I2C_SR2_Flag) of Natural :=
(0, 1, 2, 4, 5, 6, 7);
---------------
-- Configure --
---------------
procedure Configure
(Port : in out I2C_Port;
Clock_Speed : Word;
Mode : I2C_Device_Mode;
Duty_Cycle : I2C_Duty_Cycle;
Own_Address : Half_Word;
Ack : I2C_Acknowledgement;
Ack_Address : I2C_Acknowledge_Address)
is
CR2, CR1 : Half_Word;
CCR : Half_Word := 0;
PCLK1 : constant Word := System_Clock_Frequencies.PCLK1;
Freq_Range : constant Half_Word := Half_Word (PCLK1 / 1_000_000);
begin
-- Load CR2 and clear FREQ
CR2 := Port.CR2 and (not CR2_FREQ);
Port.CR2 := CR2 or Freq_Range;
Set_State (Port, Disabled);
if Clock_Speed <= 100_000 then
CCR := Half_Word (PCLK1 / (Clock_Speed * 2));
if CCR < 4 then
CCR := 4;
end if;
Port.TRISE := Freq_Range + 1;
else
-- Fast mode
if Duty_Cycle = DutyCycle_2 then
CCR := Half_Word (PCLK1 / (Clock_Speed * 3));
else
CCR := Half_Word (PCLK1 / (Clock_Speed * 25));
CCR := CCR or DutyCycle_16_9'Enum_Rep;
end if;
if (CCR and CCR_CCR) = 0 then
CCR := 1;
end if;
CCR := CCR or CCR_FS;
Port.TRISE := (Freq_Range * 300) / 1000 + 1;
end if;
Port.CCR := CCR;
Set_State (Port, Enabled);
CR1 := Port.CR1;
CR1 := CR1 and CR1_Clear_Mask;
CR1 := CR1 or Mode'Enum_Rep or Ack'Enum_Rep;
Port.CR1 := CR1;
Port.OAR1 := Ack_Address'Enum_Rep or Own_Address'Enum_Rep;
end Configure;
---------------
-- Set_State --
---------------
procedure Set_State (Port : in out I2C_Port; State : I2C_State) is
begin
if State = Enabled then
Port.CR1 := Port.CR1 or CR1_PE;
else
Port.CR1 := Port.CR1 and (not CR1_PE);
end if;
end Set_State;
------------------
-- Port_Enabled --
------------------
function Port_Enabled (Port : I2C_Port) return Boolean is
begin
return (Port.CR1 and CR1_PE) /= 0;
end Port_Enabled;
--------------------
-- Generate_Start --
--------------------
procedure Generate_Start (Port : in out I2C_Port; State : I2C_State) is
begin
if State = Enabled then
Port.CR1 := Port.CR1 or CR1_START;
else
Port.CR1 := Port.CR1 and (not CR1_START);
end if;
end Generate_Start;
-------------------
-- Generate_Stop --
-------------------
procedure Generate_Stop (Port : in out I2C_Port; State : I2C_State) is
begin
if State = Enabled then
Port.CR1 := Port.CR1 or CR1_STOP;
else
Port.CR1 := Port.CR1 and (not CR1_STOP);
end if;
end Generate_Stop;
--------------------
-- Send_7Bit_Addr --
--------------------
procedure Send_7Bit_Address
(Port : in out I2C_Port;
Address : Byte;
Direction : I2C_Direction)
is
Destination : Half_Word := Half_Word (Address);
begin
if Direction = Receiver then
Destination := Destination or I2C_OAR1_ADD0;
else
Destination := Destination and (not I2C_OAR1_ADD0);
end if;
Port.DR := Destination;
end Send_7Bit_Address;
--------------
-- Get_Flag --
--------------
function Status (Port : I2C_Port; Flag : I2C_Status_Flag) return Boolean is
begin
if Flag in I2C_SR1_Flag then
return (Port.SR1 and (2**SR1_Flag_Pos (Flag))) /= 0;
else
return (Port.SR2 and (2**SR2_Flag_Pos (Flag))) /= 0;
end if;
end Status;
----------------
-- Clear_Flag --
----------------
procedure Clear_Status
(Port : in out I2C_Port;
Target : Clearable_I2C_Status_Flag)
is
begin
-- note that only a subset of the status flags can be cleared
Port.SR1 := not (2 ** SR1_Flag_Pos (Target));
-- we do not logically AND status bits
end Clear_Status;
-------------------------------
-- Clear_Address_Sent_Status --
-------------------------------
procedure Clear_Address_Sent_Status (Port : in out I2C_Port) is
Temp : Half_Word with Volatile;
ADDR_Mask : constant Half_Word := 2 ** SR1_Flag_Pos (Address_Sent);
STOP_Mask : constant Half_Word := 2 ** SR1_Flag_Pos (Stop_Detection);
begin
-- To clear the ADDR flag we have to read SR2 after reading SR1.
-- However, per the RM, section 27.6.7, page 850, we should only read
-- SR2 if the Address_Sent flag is set in SR1, or if the Stop_Detection
-- flag is cleared, because the Address_Sent flag could be set in
-- the middle of reading SR1 and SR2 but will be cleared by the
-- read sequence nonetheless.
Temp := Port.SR1;
if ((Temp and ADDR_Mask) = 1) or ((Temp and STOP_Mask) = 0) then
Temp := Port.SR2;
end if;
end Clear_Address_Sent_Status;
---------------------------------
-- Clear_Stop_Detection_Status --
---------------------------------
procedure Clear_Stop_Detection_Status (Port : in out I2C_Port) is
Temp : Half_Word with Volatile, Unreferenced;
begin
Temp := Port.SR1;
Port.CR1 := Port.CR1 or CR1_PE;
end Clear_Stop_Detection_Status;
-------------------
-- Wait_For_Flag --
-------------------
procedure Wait_For_State
(Port : I2C_Port;
Queried : I2C_Status_Flag;
State : I2C_State;
Time_Out : Natural := 1_000_000)
is
Expected : constant Boolean := State = Enabled;
Deadline : constant Time := Clock + Milliseconds (Time_Out);
begin
while Status (Port, Queried) /= Expected loop
if Clock >= Deadline then
raise I2C_Timeout;
end if;
end loop;
end Wait_For_State;
---------------
-- Send_Data --
---------------
procedure Send_Data (Port : in out I2C_Port; Data : Byte) is
begin
Port.DR := Half_Word (Data);
end Send_Data;
---------------
-- Read_Data --
---------------
function Read_Data (Port : I2C_Port) return Byte is
begin
return Byte (Port.DR);
end Read_Data;
--------------------
-- Set_Ack_Config --
--------------------
procedure Set_Ack_Config (Port : in out I2C_Port; State : I2C_State) is
begin
if State = Enabled then
Port.CR1 := Port.CR1 or CR1_ACK;
else
Port.CR1 := Port.CR1 and (not CR1_ACK);
end if;
end Set_Ack_Config;
---------------------
-- Set_Nack_Config --
---------------------
procedure Set_Nack_Config
(Port : in out I2C_Port;
Pos : I2C_Nack_Position)
is
begin
if Pos = Next then
Port.CR1 := Port.CR1 or CR1_POS;
else
Port.CR1 := Port.CR1 and (not CR1_POS);
end if;
end Set_Nack_Config;
-----------
-- Start --
-----------
procedure Start
(Port : in out I2C_Port;
Address : Byte;
Direction : I2C_Direction)
is
begin
Generate_Start (Port, Enabled);
Wait_For_State (Port, Start_Bit, Enabled);
Set_Ack_Config (Port, Enabled);
Send_7Bit_Address (Port, Address, Direction);
while not Status (Port, Address_Sent) loop
if Status (Port, Ack_Failure) then
raise Program_Error;
end if;
end loop;
Clear_Address_Sent_Status (Port);
end Start;
--------------
-- Read_Ack --
--------------
function Read_Ack (Port : in out I2C_Port) return Byte is
begin
Set_Ack_Config (Port, Enabled);
Wait_For_State (Port, Rx_Data_Register_Not_Empty, Enabled);
return Read_Data (Port);
end Read_Ack;
---------------
-- Read_Nack --
---------------
function Read_Nack (Port : in out I2C_Port) return Byte is
begin
Set_Ack_Config (Port, Disabled);
Generate_Stop (Port, Enabled);
Wait_For_State (Port, Rx_Data_Register_Not_Empty, Enabled);
return Read_Data (Port);
end Read_Nack;
-----------
-- Write --
-----------
procedure Write (Port : in out I2C_Port; Data : Byte) is
begin
Wait_For_State (Port, Tx_Data_Register_Empty, Enabled);
Send_Data (Port, Data);
while
not Status (Port, Tx_Data_Register_Empty) or else
not Status (Port, Byte_Transfer_Finished)
loop
null;
end loop;
end Write;
----------
-- Stop --
----------
procedure Stop (Port : in out I2C_Port) is
begin
Generate_Stop (Port, Enabled);
end Stop;
----------------------
-- Enable_Interrupt --
----------------------
procedure Enable_Interrupt
(Port : in out I2C_Port;
Source : I2C_Interrupt)
is
begin
Port.CR2 := Port.CR2 or Source'Enum_Rep;
end Enable_Interrupt;
-----------------------
-- Disable_Interrupt --
-----------------------
procedure Disable_Interrupt
(Port : in out I2C_Port;
Source : I2C_Interrupt)
is
begin
Port.CR2 := Port.CR2 and not Source'Enum_Rep;
end Disable_Interrupt;
-------------
-- Enabled --
-------------
function Enabled
(Port : in out I2C_Port;
Source : I2C_Interrupt)
return Boolean
is
begin
return (Port.CR2 and Source'Enum_Rep) = Source'Enum_Rep;
end Enabled;
end STM32F4.I2C;
|
programs/oeis/006/A006048.asm | neoneye/loda | 22 | 245139 | <gh_stars>10-100
; A006048: Number of entries in first n rows of Pascal's triangle not divisible by 3.
; 1,3,6,8,12,18,21,27,36,38,42,48,52,60,72,78,90,108,111,117,126,132,144,162,171,189,216,218,222,228,232,240,252,258,270,288,292,300,312,320,336,360,372,396
lpb $0
mov $2,$0
sub $0,1
seq $2,6047 ; Number of entries in n-th row of Pascal's triangle not divisible by 3.
add $1,$2
lpe
add $1,1
mov $0,$1
|
loader/video/vgatext.asm | hakonmagnus/ether | 2 | 82190 | <filename>loader/video/vgatext.asm<gh_stars>1-10
;=============================================================================|
; _______ _________ _______ _______ |
; ( ____ \\__ __/|\ /|( ____ \( ____ ) |
; | ( \/ ) ( | ) ( || ( \/| ( )| |
; | (__ | | | (___) || (__ | (____)| By <NAME>. |
; | __) | | | ___ || __) | __) Licensed under MIT. |
; | ( | | | ( ) || ( | (\ ( |
; | (____/\ | | | ) ( || (____/\| ) \ \__ |
; (_______/ )_( |/ \|(_______/|/ \__/ |
;=============================================================================|
bits 32
%define VGA_TEXT_VIDEO_MEMORY 0xB8000
%define VGA_TEXT_COLS 80
%define VGA_TEXT_ROWS 25
vga_text_cursor_x db 0
vga_text_cursor_y db 0
vga_text_color db 0x0F
;=============================================================================;
; vga_text_put_char ;
; Print a single ASCII character ;
; @param AL = Character to print ;
;=============================================================================;
vga_text_put_char:
pusha
cmp al, 0x08
jne .cont1
cmp byte [vga_text_cursor_x], 0
je .cont1
dec byte [vga_text_cursor_x]
jmp .finish
.cont1:
cmp al, 0x09
je .tab
cmp al, 0x0D
je .cr
cmp al, 0x0A
je .nl
cmp al, 0x20
jb .finish
mov bl, al
mov edi, VGA_TEXT_VIDEO_MEMORY
xor eax, eax
mov ecx, VGA_TEXT_COLS * 2
mov byte al, [vga_text_cursor_y]
mul ecx
push eax
mov byte al, [vga_text_cursor_x]
mov cl, 2
mul cl
pop ecx
add eax, ecx
xor ecx, ecx
add edi, eax
mov dl, bl
mov byte dh, [vga_text_color]
mov word [edi], dx
inc byte [vga_text_cursor_x]
jmp .finish
.tab:
add byte [vga_text_cursor_x], 8
and byte [vga_text_cursor_x], ~7
jmp .finish
.cr:
mov byte [vga_text_cursor_x], 0
jmp .finish
.nl:
mov byte [vga_text_cursor_x], 0
inc byte [vga_text_cursor_y]
.finish:
cmp byte [vga_text_cursor_x], 80
jb .done
mov byte [vga_text_cursor_x], 0
inc byte [vga_text_cursor_y]
.done:
popa
call vga_text_move_cursor
ret
;=============================================================================;
; vga_text_print_string ;
; Print a string to the VGA text console ;
; @param ESI = String to print ;
;=============================================================================;
vga_text_print_string:
pusha
.loop:
lodsb
test al, al
jz .done
call vga_text_put_char
jmp .loop
.done:
popa
ret
;=============================================================================;
; vga_text_move_cursor ;
; Update the hardware cursor ;
;=============================================================================;
vga_text_move_cursor:
pusha
mov byte bh, [vga_text_cursor_y]
mov byte bl, [vga_text_cursor_x]
xor eax, eax
mov ecx, VGA_TEXT_COLS
mov al, bh
mul ecx
add al, bl
mov ebx, eax
mov al, 0x0F
mov dx, 0x3D4
out dx, al
mov al, bl
mov dx, 0x3D5
out dx, al
xor eax, eax
mov al, 0x0E
mov dx, 0x3D4
out dx, al
mov al, bh
mov dx, 0x3D5
out dx, al
popa
ret
;=============================================================================;
; vga_text_clear_screen ;
; Clear the screen in VGA text mode ;
;=============================================================================;
vga_text_clear_screen:
pusha
cld
mov edi, VGA_TEXT_VIDEO_MEMORY
mov cx, 2000
mov byte ah, [vga_text_color]
mov al, ' '
rep stosw
mov byte [vga_text_cursor_x], 0
mov byte [vga_text_cursor_y], 0
call vga_text_move_cursor
popa
ret |
poasm/riched/misc.asm | AlexRogalskiy/Masm | 0 | 167028 | <gh_stars>0
; #########################################################################
Select_All Proc hEdit:DWORD
LOCAL Cr :CHARRANGE
mov Cr.cpMin,0
invoke GetWindowTextLength,hEdit
inc eax
mov Cr.cpMax, eax
invoke SendMessage,hEdit,EM_EXSETSEL,0,ADDR Cr
ret
Select_All endp
; #########################################################################
Confirmation proc hEditor:DWORD
invoke SendMessage,hEditor,WM_GETTEXTLENGTH,0,0
cmp eax, 0
jne @F
return 0
@@:
invoke SendMessage,hEditor,EM_GETMODIFY,0,0
cmp eax, 0 ; zero = unmodified
jne @F
return 0
@@:
szText confirm,"File is not saved, Save it now ?"
invoke MessageBox,hWnd,ADDR confirm,
ADDR szDisplayName,
MB_YESNOCANCEL or MB_ICONQUESTION
ret
Confirmation endp
; #########################################################################
|
pwnlib/shellcraft/templates/arm/linux/setpgid.asm | IMULMUL/python3-pwntools | 325 | 245514 | <%
from pwnlib.shellcraft.arm.linux import syscall
%>
<%page args="pid, pgid"/>
<%docstring>
Invokes the syscall setpgid. See 'man 2 setpgid' for more information.
Arguments:
pid(pid_t): pid
pgid(pid_t): pgid
</%docstring>
${syscall('SYS_setpgid', pid, pgid)}
|
src/a0xfa.adb | python36/0xfa | 0 | 24827 | with ada.text_io;
with ada.command_line;
with gnat.os_lib;
with ada.strings;
with ada.strings.bounded;
with ada.containers.vectors;
with ada.containers.indefinite_ordered_maps;
with ada.containers.ordered_maps;
with ada.containers.doubly_linked_lists;
with interfaces;
with ada.exceptions;
with ada.containers;
with ada.io_exceptions;
with ada.finalization;
with getter;
with getter.file;
with getter.for_loop;
with getter.macros;
with numbers; use numbers;
with strings; use strings;
with address; use address;
with labels; use labels;
with env; use env;
procedure a0xfa is
use type byte;
use type word;
parse_error : exception;
programm_address : pos_addr_t := create(0);
ff : constant word := 16#ffff#;
r_pc : constant word := 0;
r_sp : constant word := 1;
r_sr : constant word := 2;
procedure error (s : string) is
begin
print(s);
gnat.os_lib.os_exit(1);
end error;
procedure error_parse (s : string) is
begin
raise parse_error with s;
end error_parse;
procedure warning (msg : string) is
begin
print("[warning]: " & msg);
end warning;
type record_handler_type;
type handler_type is access function (s : string) return record_handler_type;
type record_handler_type is record
ptr : handler_type;
end record;
type operation_access is access function (a, b : word) return word;
parse_def_cursor : environment_t.cursor := environment_t.no_element;
package operands_t is new ada.containers.doubly_linked_lists(word, "=");
type operation_t is record
operation_ptr : operation_access := words_add'access;
priority : positive := 1;
operand_cur : operands_t.cursor;
end record;
package operations_t is new ada.containers.vectors(
element_type => operation_t, index_type => natural);
function ">" (a, b : operation_t) return boolean is
begin
return a.priority > b.priority;
end;
procedure insert_sorted (ops : in out operations_t.vector; op : operation_t) is
tmp_cursor : operations_t.cursor := ops.first;
begin
while operations_t.has_element(tmp_cursor) loop
if op > operations_t.element(tmp_cursor) then
operations_t.insert(ops, tmp_cursor, op);
return;
end if;
operations_t.next(tmp_cursor);
end loop;
operations_t.append(ops, op);
end insert_sorted;
procedure environment_repr is
tmp_cursor : environment_t.cursor := environment.first;
begin
while environment_t.has_element(tmp_cursor) loop
print(environment_t.key(tmp_cursor) & " : " & environment_t.element(tmp_cursor)'img);
environment_t.next(tmp_cursor);
end loop;
end environment_repr;
type commands is (
f_rrc, f_swpb, f_rra, f_sxt, f_push, f_call, f_reti,
f_jne, f_jeq, f_jnc, f_jc, f_jn, f_jge, f_jl, f_jmp,
f_mov, f_add, f_addc, f_subc, f_sub, f_cmp, f_dadd,
f_bit, f_bic, f_bis, f_xor, f_and,
f_jnz, f_jz, f_jlo, f_jhs,
f_clrc, f_clrn, f_clrz, f_dint, f_eint, f_nop, f_ret, f_setc, f_setn, f_setz,
f_adc, f_br, f_clr, f_dadc, f_dec, f_decd, f_inc,
f_incd, f_inv, f_pop, f_rla, f_rlc, f_sbc, f_tst,
f_raw);
subtype single_commands is commands range f_rrc..f_reti;
subtype jump_commands is commands range f_jne..f_jmp;
subtype alternatives_jump_commands is commands range f_jnz..f_jhs;
subtype two_commands is commands range f_mov..f_and;
subtype emulated_commands is commands range f_jnz..f_tst;
subtype zero_emulated_commands is commands range f_clrc..f_setz;
subtype single_emulated_commands is commands range f_adc..f_tst;
type addressing_modes is (
m_constant,
m_immediate, m_indexed, m_symbolic, m_absolute,
m_indirect_register, m_indirect_autoincrement, m_register);
type operand_t is record
mode : addressing_modes := m_constant;
value : word := 0;
register : word := 0;
label : label_t := null_label;
end record;
null_operand : constant operand_t := (m_register, 0, ff, null_label);
type command_t is record
command : commands;
source, destination : operand_t := null_operand;
num_operands : byte := 0;
bw : boolean := true;
end record;
package programm_t is new ada.containers.ordered_maps(
element_type => command_t, key_type => pos_addr_t);
programm : programm_t.map;
null_command : command_t := (f_raw, null_operand, null_operand, 0, true);
type words_t is array (word range <>) of word;
command : command_t := null_command;
procedure void (r : record_handler_type) is begin null; end void;
function parse_main (s : string) return record_handler_type;
-- procedure from_file (path : string);
function parse_word (s : string) return word is
begin
return value(s);
exception
when constraint_error => error_parse("bad value " & s); return 0;
end parse_word;
function validate_register (s : string) return boolean is
begin
return car(s) = 'r' and then natural'value(cdr(s)) in 0..15;
exception
when constraint_error => return false;
end validate_register;
procedure validate_variable_assert (s : string) is
begin
if not validate_variable(s) then
error_parse("error var name " & s);
end if;
end validate_variable_assert;
function parse_def (s : string) return record_handler_type is
use type environment_t.cursor;
tb : boolean;
begin
if parse_def_cursor = environment_t.no_element then
validate_variable_assert(s);
environment.insert(s, 0, parse_def_cursor, tb);
if not tb then
warning("variable """ & s & """ redefined");
end if;
return (ptr => parse_def'access);
end if;
environment.replace_element(parse_def_cursor, parse_word(s));
parse_def_cursor := environment_t.no_element;
return (ptr => parse_main'access);
end parse_def;
function parse_defs (s : string) return record_handler_type is
begin
if s = ".end_defs" then
return (ptr => parse_main'access);
end if;
void(parse_def(s));
return (ptr => parse_defs'access);
end parse_defs;
function parse_undef (s : string) return record_handler_type is
begin
validate_variable_assert(s);
if not environment_t.contains(environment, s) then
warning("variable name """ & s & """ not defined");
else
environment.delete(s);
end if;
return (ptr => parse_main'access);
end parse_undef;
function parse_set (s : string) return record_handler_type is
begin
validate_variable_assert(s);
if not environment_t.contains(environment, s) then
error_parse("variable name """ & s & """ not defined");
end if;
void(parse_undef(s));
return parse_def(s);
end parse_set;
function parse_include (s : string) return record_handler_type is
begin
if first_element(s) /= '"' or last_element(s) /= '"' then
error_parse("error .include format");
end if;
getter.file.open(trim(s((s'first + 1)..(s'last - 1))));
return (ptr => parse_main'access);
end parse_include;
type for_loop_step_t is (for_loop_var, for_loop_mode, for_loop_range);
for_loop_step : for_loop_step_t := for_loop_var;
tmp_for_loop_cursor : environment_t.cursor;
function parse_for_loop (s : string) return record_handler_type is
tb : boolean;
dots_pos : natural;
begin
if for_loop_step = for_loop_var then
validate_variable_assert(s);
environment.insert(s, 0, tmp_for_loop_cursor, tb);
if not tb then
error_parse("variable name """ & s & """ already defined");
end if;
for_loop_step := for_loop_mode;
elsif for_loop_step = for_loop_mode then
if s /= "in" then
error_parse("error format for: " & s);
end if;
for_loop_step := for_loop_range;
elsif for_loop_step = for_loop_range then
dots_pos := fix.index(s, "..");
if dots_pos < 2 or (dots_pos + 1) >= s'last then
error_parse("error range: " & s);
end if;
getter.for_loop.create(
parse_word(s(s'first..(dots_pos - 1))),
parse_word(s((dots_pos + 2)..s'last)),
tmp_for_loop_cursor);
for_loop_step := for_loop_var;
return (ptr => parse_main'access);
end if;
return (ptr => parse_for_loop'access);
end parse_for_loop;
macro_name : unb.unbounded_string := unb.null_unbounded_string;
macro_params : unb.unbounded_string := unb.null_unbounded_string;
macro_wait_open : boolean := false;
function get_macros_name_params (s : string) return boolean is
use type unb.unbounded_string;
open_pos : natural := 1;
procedure set_macro_name (name : string) is
begin
if not validate_variable(name) then
error_parse("error macros name: " & name);
end if;
macro_name := unb.to_unbounded_string(name);
end set_macro_name;
procedure append_param (s : string) is
begin
if s'length = 0 then
return;
end if;
unb.append(macro_params, s & ' ');
end append_param;
begin
if macro_name = unb.null_unbounded_string then
macro_wait_open := true;
open_pos := fix.index(s, "(");
if open_pos > 0 then
set_macro_name(s(s'first..(open_pos - 1)));
else
set_macro_name(s);
return false;
end if;
end if;
if macro_wait_open then
if s(open_pos) /= '(' then
error_parse("wait '(' but: " & s);
end if;
macro_wait_open := false;
inc(open_pos);
end if;
if endswith(s, ')') then
if s'length > 1 then
append_param(s(open_pos..(s'last - 1)));
end if;
return true;
else
append_param(s(open_pos..s'last));
end if;
return false;
end get_macros_name_params;
function parse_macros (s : string) return record_handler_type is
begin
if get_macros_name_params(s) then
getter.macros.define(unb.to_string(macro_name), unb.to_string(macro_params));
macro_name := unb.null_unbounded_string;
macro_params := unb.null_unbounded_string;
return (ptr => parse_main'access);
end if;
return (ptr => parse_macros'access);
end parse_macros;
function parse_instruction (s : string) return record_handler_type is
begin
if s = ".def" then
return (ptr => parse_def'access);
elsif s = ".undef" then
return (ptr => parse_undef'access);
elsif s = ".set" then
return (ptr => parse_set'access);
elsif s = ".include" then
return (ptr => parse_include'access);
elsif s = ".for" then
return (ptr => parse_for_loop'access);
elsif s = ".macro" then
return (ptr => parse_macros'access);
elsif s = ".defs" then
return (ptr => parse_defs'access);
end if;
error_parse("unknown instruction " & s);
return (ptr => parse_main'access);
end parse_instruction;
function in_labels (s : string) return boolean is
begin
return get_by_name(s) /= null_label;
end in_labels;
function validate_command (s : string) return boolean is
begin
return commands'value("f_" &
s(s'first..(s'last - to_natural(endswith(s, ".b"), 2) - to_natural(endswith(s, ".w"), 2)))) >= commands'first;
exception
when others => return false;
end validate_command;
function parse_label (s : string) return record_handler_type is
tmp_word : word;
label : label_t;
begin
if first_element(s) in '0'..'9' then
tmp_word := parse_word(s);
if not valid_value_for_pos_addr(tmp_word) then
error_parse("bad value address " & s);
end if;
if last_label /= null_label and then programm_address = get(last_label) then
error_parse("set address must be before define label");
end if;
programm_address := create(tmp_word);
elsif first_element(s) in 'a'..'z' then
validate_variable_assert(s);
if validate_register(s) then
error_parse(s & " label can not be r0..15");
elsif validate_command(s) then
error_parse(s & " label can not be command");
end if;
label := get_by_name(s);
if label /= null_label then
if get(label) = null_pos_addr then
label.set(programm_address);
else
error_parse("label " & s & " already defined");
end if;
else
create(s, programm_address);
end if;
else
error_parse("invalid data " & s);
end if;
return (ptr => parse_main'access);
end parse_label;
function get_var_val (s : string) return word is
tmp_cursor : environment_t.cursor;
begin
tmp_cursor := environment_t.find(environment, s);
-- environment_repr;
if environment_t.has_element(tmp_cursor) then
return environment_t.element(tmp_cursor);
end if;
error_parse("variable " & s & " undefined");
return 0;
end get_var_val;
function parse_precompile (s : string) return string is
use type ada.containers.count_type;
start_pos, end_pos : natural := 0;
value : word := 0;
operation : operation_access := words_add'access;
i : natural := s'first;
priority : positive;
operations : operations_t.vector;
operands : operands_t.list;
tmp_operation : operation_t;
k_priority : natural := 0;
begin
while i < s'last + 1 loop
if s(i) in '0'..'9'|'a'..'z'|'_' then
if start_pos = end_pos then
start_pos := i;
end_pos := i + 1;
else
if i /= end_pos then
error_parse("error " & s(start_pos..i));
end if;
inc(end_pos);
end if;
else
if s(i) = ' ' then
null;
elsif s(i) = '(' then
k_priority := k_priority + 10;
elsif s(i) = ')' then
if k_priority = 0 then
error_parse(s & " ')' > '('");
end if;
k_priority := k_priority - 10;
elsif start_pos /= end_pos then
if s(start_pos) in 'a'..'z' then
-- print(s(start_pos..(end_pos - 1)) & get_var_val(s(start_pos..(end_pos - 1)))'img);
operands.append(get_var_val(s(start_pos..(end_pos - 1))));
else
-- print(s(start_pos..(end_pos - 1)));
operands.append(parse_word(s(start_pos..(end_pos - 1))));
end if;
if s(i) = ';' then
exit;
elsif s(i) = '<' then
if s(i + 1) /= '<' then
error_parse(s & " unknown operation. maybe << ?");
end if;
inc(i);
operation := words_sl'access;
priority := k_priority + 4;
elsif s(i) = '>' then
if s(i + 1) /= '>' then
error_parse(s & " unknown operation. maybe >> ?");
end if;
inc(i);
operation := words_sr'access;
priority := k_priority + 4;
elsif s(i) = '+' then
operation := words_add'access;
priority := k_priority + 5;
elsif s(i) = '-' then
operation := words_sub'access;
priority := k_priority + 5;
elsif s(i) = '*' then
if s(i + 1) = '*' then
operation := words_pow'access;
priority := k_priority + 7;
inc(i);
else
operation := words_mul'access;
priority := k_priority + 6;
end if;
elsif s(i) = '/' then
operation := words_div'access;
priority := k_priority + 6;
elsif s(i) = '%' then
operation := words_mod'access;
priority := k_priority + 6;
elsif s(i) = '|' then
operation := words_or'access;
priority := k_priority + 1;
elsif s(i) = '&' then
operation := words_and'access;
priority := k_priority + 3;
elsif s(i) = '^' then
operation := words_xor'access;
priority := k_priority + 2;
else
error_parse(s & " unknown operation");
end if;
-- print(" = " & operands_t.element(operands, operands.last_index)'img);
insert_sorted(operations, (operation, priority, operands.last));
start_pos := end_pos;
else
error_parse(s & " error");
end if;
end if;
inc(i);
end loop;
if k_priority /= 0 then
error_parse(s & " '(' > ')'");
end if;
if operations_t.length(operations) = 0 and operands_t.length(operands) = 1 then
return ltrim(operands_t.first_element(operands)'img);
end if;
while not operations_t.is_empty(operations) loop
tmp_operation := operations_t.first_element(operations);
value := tmp_operation.operation_ptr.all(
operands_t.element(tmp_operation.operand_cur),
operands_t.element(operands_t.next(tmp_operation.operand_cur)));
operands_t.replace_element(operands, operands_t.next(tmp_operation.operand_cur), value);
operands.delete(tmp_operation.operand_cur);
operations_t.delete_first(operations);
end loop;
return ltrim(value'img);
end parse_precompile;
function operand_has_ext_word (operand : operand_t) return boolean is
begin
return operand.mode in m_symbolic|m_absolute|m_immediate|m_indexed;
end operand_has_ext_word;
procedure command_to_programm (cmd : in out command_t) is
tmp_cursor : programm_t.cursor;
inserted : boolean;
prev_addr : pos_addr_t;
prev_cursor : programm_t.cursor;
procedure inc_addr_by_mode (operand : operand_t; addr : in out pos_addr_t) is
begin
if operand /= null_operand then
if operand_has_ext_word(operand) then
inc(addr);
end if;
end if;
end inc_addr_by_mode;
begin
if cmd.command in emulated_commands then
case cmd.command is
when f_adc =>
cmd.command := f_addc;
cmd.destination := cmd.source;
cmd.source.mode := m_constant;
cmd.source.value := 0;
when f_br =>
cmd.command := f_mov;
cmd.destination.mode := m_register;
cmd.destination.register := r_pc;
when f_clr =>
cmd.command := f_mov;
cmd.destination := cmd.source;
cmd.source.mode := m_constant;
cmd.source.value := 0;
when f_clrc =>
cmd.command := f_bic;
cmd.source.mode := m_constant;
cmd.source.value := 1;
cmd.destination.mode := m_register;
cmd.destination.register := r_sr;
when f_clrn =>
cmd.command := f_bic;
cmd.source.mode := m_constant;
cmd.source.value := 4;
cmd.destination.mode := m_register;
cmd.destination.register := r_sr;
when f_clrz =>
cmd.command := f_bic;
cmd.source.mode := m_constant;
cmd.source.value := 2;
cmd.destination.mode := m_register;
cmd.destination.register := r_sr;
when f_dadc =>
cmd.command := f_dadd;
cmd.destination := cmd.source;
cmd.source.mode := m_constant;
cmd.source.value := 0;
when f_dec =>
cmd.command := f_sub;
cmd.destination := cmd.source;
cmd.source.mode := m_constant;
cmd.source.value := 1;
when f_decd =>
cmd.command := f_sub;
cmd.destination := cmd.source;
cmd.source.mode := m_constant;
cmd.source.value := 2;
when f_dint =>
cmd.command := f_bic;
cmd.source.mode := m_constant;
cmd.source.value := 8;
cmd.destination.mode := m_register;
cmd.destination.register := r_sr;
when f_eint =>
cmd.command := f_bis;
cmd.source.mode := m_constant;
cmd.source.value := 8;
cmd.destination.mode := m_register;
cmd.destination.register := r_sr;
when f_inc =>
cmd.command := f_add;
cmd.destination := cmd.source;
cmd.source.mode := m_constant;
cmd.source.value := 1;
when f_incd =>
cmd.command := f_add;
cmd.destination := cmd.source;
cmd.source.mode := m_constant;
cmd.source.value := 2;
when f_inv =>
cmd.command := f_xor;
cmd.destination := cmd.source;
cmd.source.mode := m_constant;
cmd.source.value := 16#ffff#;
when f_nop =>
cmd.command := f_mov;
cmd.source.mode := m_constant;
cmd.source.value := 0;
cmd.destination.mode := m_register;
cmd.destination.register := 3;
when f_pop =>
cmd.command := f_mov;
cmd.destination := cmd.source;
cmd.source.mode := m_indirect_autoincrement;
cmd.source.register := r_sp;
when f_ret =>
cmd.command := f_mov;
cmd.source.mode := m_indirect_autoincrement;
cmd.source.register := r_sp;
cmd.destination.mode := m_register;
cmd.destination.register := r_pc;
when f_rla =>
cmd.command := f_add;
cmd.destination := cmd.source;
when f_rlc =>
cmd.command := f_addc;
cmd.destination := cmd.source;
when f_sbc =>
cmd.command := f_subc;
cmd.destination := cmd.source;
cmd.source.mode := m_constant;
cmd.source.value := 0;
when f_setc =>
cmd.command := f_bis;
cmd.source.mode := m_constant;
cmd.source.value := 1;
cmd.destination.mode := m_register;
cmd.destination.register := r_sr;
when f_setn =>
cmd.command := f_bis;
cmd.source.mode := m_constant;
cmd.source.value := 4;
cmd.destination.mode := m_register;
cmd.destination.register := r_sr;
when f_setz =>
cmd.command := f_bis;
cmd.source.mode := m_constant;
cmd.source.value := 2;
cmd.destination.mode := m_register;
cmd.destination.register := r_sr;
when f_tst =>
cmd.command := f_cmp;
cmd.destination := cmd.source;
cmd.source.mode := m_constant;
cmd.source.value := 0;
when f_jnz =>
cmd.command := f_jne;
when f_jz =>
cmd.command := f_jeq;
when f_jlo =>
cmd.command := f_jnc;
when f_jhs =>
cmd.command := f_jc;
when others => null;
end case;
elsif cmd.command = f_reti then
cmd.source.mode := m_register;
cmd.source.register := 0;
end if;
programm_t.insert(programm, programm_address, cmd, tmp_cursor, inserted);
if not inserted then
error_parse("rewrite command: " & hex(get(programm_address)));
end if;
prev_cursor := programm_t.previous(tmp_cursor);
if programm_t.has_element(prev_cursor) then
prev_addr := programm_t.key(prev_cursor);
if programm_t.element(prev_cursor).command not in jump_commands|alternatives_jump_commands|f_raw then
inc_addr_by_mode(programm_t.element(prev_cursor).source, prev_addr);
inc_addr_by_mode(programm_t.element(prev_cursor).destination, prev_addr);
end if;
if prev_addr >= programm_address and programm_t.key(prev_cursor) < programm_address then
error_parse("rewrite previous command: " & hex(get(programm_address)));
end if;
end if;
inc(programm_address);
if cmd.command not in jump_commands|alternatives_jump_commands|f_raw then
inc_addr_by_mode(cmd.source, programm_address);
inc_addr_by_mode(cmd.destination, programm_address);
end if;
tmp_cursor := programm_t.next(tmp_cursor);
if programm_t.has_element(tmp_cursor) then
if programm_t.key(tmp_cursor) < programm_address then
error_parse("rewrite next command: " & hex(get(programm_address)));
end if;
end if;
end command_to_programm;
function parse_register (s : string) return word is
begin
if not validate_register(s) then
error_parse(s & " is not register");
end if;
return word'value(cdr(s));
end parse_register;
procedure parse_operand (addr : in out operand_t; s : string) is
open_pos, close_pos : natural;
begin
if first_element(s) = '#' then
addr.mode := m_immediate;
if s(s'first + 1) in '0'..'9'|'-' then
addr.value := parse_word(cdr(s));
if addr.value in 0..2|4|8|ff then
addr.mode := m_constant;
end if;
elsif in_labels(cdr(s)) then
addr.label := get_by_name(cdr(s));
else
addr.label := create(cdr(s));
end if;
elsif first_element(s) = ''' and s'length = 3 then
addr.mode := m_immediate;
addr.value := character'pos(s(s'first + 1));
elsif first_element(s) = '@' then
if last_element(s) = '+' then
addr.mode := m_indirect_autoincrement;
addr.register := parse_register(s((s'first + 1)..(s'last - 1)));
else
addr.mode := m_indirect_register;
addr.register := parse_register(cdr(s));
end if;
elsif validate_register(s) then
addr.mode := m_register;
addr.register := parse_register(s);
elsif first_element(s) = '&' and then s'length > 1 then
addr.mode := m_absolute;
if s(s'first + 1) in '0'..'9'|'-' then
addr.value := parse_word(cdr(s));
addr.label := null_label;
elsif in_labels(cdr(s)) then
addr.label := get_by_name(cdr(s));
else
addr.label := create(cdr(s));
end if;
elsif first_element(s) in '0'..'9' and last_element(s) /= ')' then
addr.mode := m_symbolic;
addr.value := parse_word(s);
addr.label := null_label;
elsif in_labels(s) then
addr.mode := m_symbolic;
addr.label := get_by_name(s);
elsif validate_variable(s) then
addr.mode := m_symbolic;
addr.label := create(s);
else
open_pos := fix.index(s, "(");
close_pos := fix.index(s, ")");
if open_pos > s'first and close_pos > (open_pos + 1) then
addr.mode := m_indexed;
addr.value := parse_word(s(s'first..(open_pos - 1)));
addr.register := parse_register(s((open_pos + 1)..(close_pos - 1)));
else
error_parse(s & " error parse operand");
end if;
end if;
end parse_operand;
function parse_operation (s : string) return record_handler_type is
begin
if command = null_command then
if not validate_command(s) then
error_parse(s & " unknown operation");
end if;
if endswith(s, ".b") then
command.command := commands'value("f_" & s(s'first..(s'last - 2)));
command.bw := false;
elsif endswith(s, ".w") then
command.command := commands'value("f_" & s(s'first..(s'last - 2)));
else
command.command := commands'value("f_" & s);
end if;
if command.command in two_commands then
command.num_operands := 2;
return (ptr => parse_operation'access);
elsif command.command in zero_emulated_commands|f_reti then
null;
else
command.num_operands := 1;
return (ptr => parse_operation'access);
end if;
elsif command.source = null_operand then
parse_operand(command.source, s);
if command.num_operands = 2 then
return (ptr => parse_operation'access);
end if;
else
parse_operand(command.destination, s);
end if;
command_to_programm(command);
command := null_command;
return (ptr => parse_main'access);
end parse_operation;
function parse_raw (s : string) return record_handler_type is
begin
if car(s) in 'a'..'z' then
if in_labels(s) then
command.source.value := get(get(get_by_name(s)));
elsif not validate_variable(s) then
error_parse(s & " bad name");
else
command.source.value := get_var_val(s);
end if;
else
command.source.value := parse_word(s);
end if;
-- command.source.value := swpb(command.source.value);
command.source.mode := m_constant;
command.command := f_raw;
command.num_operands := 0;
command_to_programm(command);
command := null_command;
return (ptr => parse_main'access);
end parse_raw;
function parse_string (s : string) return record_handler_type is
i : natural := s'first;
begin
if s'length < 3 then
error_parse(s & " error string");
end if;
command.source.label := null_label;
command.source.mode := m_constant;
command.command := f_raw;
command.num_operands := 0;
while i /= s'last + 1 loop
if s(i) = '"' then
if i /= s'last then
error_parse("end of string before end");
end if;
command := null_command;
return (ptr => parse_main'access);
end if;
if s(i) = '\' then
if i = s'last then
error_parse(" \ end of string");
end if;
inc(i);
end if;
command.source.value := character'pos(s(i));
command_to_programm(command);
inc(i);
end loop;
command := null_command;
return (ptr => parse_string'access);
end parse_string;
function parse_call_macros (s : string) return record_handler_type is
begin
if get_macros_name_params(s) then
getter.macros.call(unb.to_string(macro_name), unb.to_string(macro_params));
macro_name := unb.null_unbounded_string;
macro_params := unb.null_unbounded_string;
return (ptr => parse_main'access);
end if;
return (ptr => parse_call_macros'access);
end parse_call_macros;
function parse_main (s : string) return record_handler_type is
begin
if first_element(s) = '.' then
return parse_instruction(s);
elsif last_element(s) = ':' then
return parse_label(s(s'first..(s'last - 1)));
elsif first_element(s) in 'a'..'z' then
if fix.index(s, "(") > 1 then
return parse_call_macros(s);
elsif validate_command(s) then
return parse_operation(s);
else
return parse_raw(s);
end if;
elsif first_element(s) in '0'..'9' then
return parse_raw(s);
elsif first_element(s) = '"' then
return parse_string(s((s'first + 1)..s'last));
else
error_parse("error " & s);
end if;
return (ptr => parse_main'access);
end parse_main;
-- function preparse (s : string) return string is
-- start_pos, end_pos, comment_pos : natural;
-- begin
-- comment_pos := fix.index(s, ";", ada.strings.forward);
-- start_pos := fix.index(s, "{", ada.strings.backward);
-- if start_pos > 0 and start_pos < comment_pos then
-- end_pos := fix.index(s, "}", start_pos, ada.strings.forward);
-- if end_pos < start_pos or end_pos > comment_pos then
-- error_parse("error """ & s & """ no closed brackets");
-- end if;
-- return preparse(
-- s(s'first..(start_pos-1)) &
-- parse_precompile(s((start_pos + 1)..(end_pos - 1)) & ';') &
-- s((end_pos + 1)..s'last));
-- end if;
-- return s;
-- end preparse;
-- вынести в модуль и сделать через финализе
type code_t is access all unb.unbounded_string;
type pre_code_t is record
start_pos, end_pos : natural;
code : code_t;
end record;
result : aliased unb.unbounded_string;
-- type for_loop_t is record
-- start_i, end_i, cur_i : natural;
-- cursor : environment_t.cursor := environment_t.no_element;
-- code : unb.unbounded_string;
-- last : positive := 1;
-- end record;
-- for_loop_status : natural := 0;
-- package for_loops_t is new ada.containers.vectors(element_type => for_loop_t, index_type => natural);
-- for_loops : for_loops_t.vector;
-- tmp_for_loop, last_for_loop : for_loop_t;
-- for_end_offset : natural := 0;
function pre_code_cmp (a, b : pre_code_t) return boolean is
begin
return false;
end pre_code_cmp;
package pre_codes_t is new ada.containers.doubly_linked_lists(pre_code_t, pre_code_cmp);
pre_codes : pre_codes_t.list;
end_asm : boolean := false;
-- type record_getter_type;
-- type getter_type is access function (getter : in out record_getter_type) return character;
-- type record_getter_type is record
-- ptr : getter_type;
-- end record;
-- current_file : ada.text_io.file_type;
-- function get_from_file (getter : in out record_getter_type) return character is
-- begin
-- if ada.text_io.end_of_file(current_file) then
-- return ascii.nul;
-- end if;
-- end get_from_file;
function get_line return string is
use type unb.unbounded_string;
use type ada.containers.count_type;
-- start_for : constant unb.unbounded_string := unb.to_unbounded_string(".for");
-- end_for : constant unb.unbounded_string := unb.to_unbounded_string(".end_for");
-- in_for : constant unb.unbounded_string := unb.to_unbounded_string("in");
last_code : code_t := result'access;
c : character;
-- tb : boolean;
-- dots_pos : natural;
begin
loop
result := unb.null_unbounded_string;
loop
-- -- if not for_loops_t.is_empty(for_loops) then
-- c := ' ';
-- if unb.length(last_for_loop.code) < last_for_loop.last then
-- inc(last_for_loop.cur_i);
-- last_for_loop.last := 1;
-- environment.replace_element(last_for_loop.cursor, word(last_for_loop.cur_i));
-- else
-- c := unb.element(last_for_loop.code, last_for_loop.last);
-- inc(last_for_loop.last);
-- end if;
-- if last_for_loop.cur_i > last_for_loop.end_i then
-- for_loop_status := 0;
-- environment.delete(last_for_loop.cursor);
-- for_loops.delete_last;
-- if for_loops_t.length(for_loops) > 0 then
-- last_for_loop := for_loops_t.last_element(for_loops);
-- end if;
-- end if;
-- -- elsif ada.text_io.end_of_file(file) then
-- -- c := ' ';
-- -- end_asm := true;
-- else
c := getter.get;
if c = ascii.nul then
end_asm := true;
return "";
end if;
-- end if;
-- if for_loop_status = 4 then
-- unb.append(tmp_for_loop.code, c);
-- -- if ada.text_io.end_of_line(file) and for_loops_t.is_empty(for_loops) then
-- -- unb.append(tmp_for_loop.code, ' ');
-- -- end if;
-- end if;
-- \; \{ \} \ \, \\ \.
-- if c = ';' then
-- if not ada.text_io.end_of_line(file) then
-- ada.text_io.skip_line(file);
-- end if;
-- exit when pre_codes_t.is_empty(pre_codes);
if c = '{' then
pre_codes.append((0, 0, new unb.unbounded_string));
last_code := pre_codes_t.last_element(pre_codes).code;
elsif c = '}' then
if pre_codes_t.is_empty(pre_codes) then
error_parse("""}"" without start");
end if;
if pre_codes_t.has_element(pre_codes_t.previous(pre_codes_t.last(pre_codes))) then
unb.append(pre_codes_t.element(pre_codes_t.previous(pre_codes_t.last(pre_codes))).code.all, parse_precompile(unb.to_string(last_code.all) & ';'));
else
unb.append(result, parse_precompile(unb.to_string(last_code.all) & ';'));
end if;
-- free(last_code);
pre_codes.delete_last;
if pre_codes_t.is_empty(pre_codes) then
last_code := result'access;
else
last_code := pre_codes_t.last_element(pre_codes).code;
end if;
elsif pre_codes_t.is_empty(pre_codes) and c in ' '|',' then
exit;
else
unb.append(last_code.all, c);
end if;
-- if ada.text_io.end_of_line(file) and for_loop_status /= 5 and for_loops_t.is_empty(for_loops) then
-- exit when pre_codes_t.is_empty(pre_codes);
-- unb.append(last_code.all, ' ');
-- end if;
end loop;
-- if for_loop_status = 1 then
-- validate_variable_assert(unb.to_string(result));
-- environment.insert(unb.to_string(result), 0, tmp_for_loop.cursor, tb);
-- if not tb then
-- error_parse("variable name """ & unb.to_string(result & """ already defined"));
-- end if;
-- inc(for_loop_status);
-- elsif for_loop_status = 2 then
-- if result /= in_for then
-- error_parse("error format for");
-- end if;
-- inc(for_loop_status);
-- elsif for_loop_status = 3 then
-- dots_pos := unb.index(result, "..");
-- if dots_pos < 2 or (dots_pos + 1) >= unb.length(result) then
-- error_parse("error range: " & unb.to_string(result));
-- end if;
-- tmp_for_loop.start_i := natural(parse_word(unb.slice(result, 1, dots_pos - 1)));
-- tmp_for_loop.cur_i := tmp_for_loop.start_i;
-- tmp_for_loop.end_i := natural(parse_word(unb.slice(result, dots_pos + 2, unb.length(result))));
-- environment.replace_element(tmp_for_loop.cursor, word(tmp_for_loop.cur_i));
-- inc(for_loop_status);
-- elsif result = start_for then
-- if for_loop_status = 4 then
-- inc(for_end_offset);
-- else
-- for_loop_status := 1;
-- tmp_for_loop.code := unb.null_unbounded_string;
-- tmp_for_loop.last := 1;
-- end if;
-- elsif for_loop_status = 4 then
-- if result = end_for then
-- if for_end_offset /= 0 then
-- dec(for_end_offset);
-- else
-- unb.replace_slice(tmp_for_loop.code, unb.length(tmp_for_loop.code) - 8, unb.length(tmp_for_loop.code), " ");
-- if for_loops_t.length(for_loops) > 0 then
-- for_loops.replace_element(for_loops_t.last(for_loops), last_for_loop);
-- end if;
-- last_for_loop := tmp_for_loop;
-- for_loops.append(last_for_loop);
-- for_loop_status := 5;
-- end if;
-- end if;
-- else
return unb.to_string(result);
-- end if;
end loop;
return "";
end get_line;
procedure from_file is
-- file : ada.text_io.file_type;
-- tmp_ustr : unb.unbounded_string;
handler_ptr : handler_type := parse_main'access;
-- cur_pos : natural := 0;
-- last_space : natural := 0;
begin
-- getter.file.open(path);
while not end_asm loop
-- print(end_asm'img & path);
declare
l : constant string := get_line;
begin
-- print(l & end_asm'img);
if l /= "" then
handler_ptr := handler_ptr(l).ptr;
end if;
end;
end loop;
end_asm := false;
-- ada.text_io.open(file, ada.text_io.in_file, path);
-- while not end_asm loop
-- declare
-- l : constant string := get_line(file);
-- begin
-- if l /= "" then
-- handler_ptr := handler_ptr(l).ptr;
-- end if;
-- end;
-- end loop;
-- end_asm := false;
-- ada.text_io.close(file);
exception
when this_error: parse_error =>
if ada.exceptions.exception_message(this_error) /= "" then
print('[' & ltrim(getter.get_line'img) & "]: " &
ada.exceptions.exception_message(this_error));
end if;
-- ada.text_io.close(file);
raise parse_error with "";
when ada.io_exceptions.name_error =>
-- error_parse("no such file " & path);
raise;
when others =>
-- if ada.text_io.is_open(file) then
-- ada.text_io.close(file);
-- end if;
raise;
end from_file;
procedure update_checksum (var : in out word; val : word) is
begin
var := var + (val and 255);
var := var + sr(val, 8);
end update_checksum;
function word_to_str_revers (val : word) return string is
begin
return image(sr(val, 8) or sl(val, 8), 16);
end word_to_str_revers;
out_text : unb.unbounded_string;
cur : programm_t.cursor;
line_addr : pos_addr_t;
package line_t is new ada.strings.bounded.generic_bounded_length(max => 40);
out_file : ada.text_io.file_type;
words : words_t(0..18);
size : word := 0;
procedure command_to_words (cmd : command_t; addr : pos_addr_t) is
operation : word := 0;
offset : word := 0;
procedure set_bits (pos, length : natural; val : word) is
begin
operation := (operation and (sl(((2 ** length) - 1), pos - length) xor ff)) or sl(val and ((2 ** length) - 1), pos - length);
end set_bits;
procedure repr_ext_word (op : operand_t) is
begin
if operand_has_ext_word(op) then
inc(words(0));
incd(offset);
if op.label /= null_label and then get(op.label) = null_pos_addr then
error_parse("label " & name(op.label) & " used but not defined");
end if;
if op.mode = m_absolute then
if op.label /= null_label then
words(words(0)) := get(get(op.label));
else
words(words(0)) := op.value;
end if;
elsif op.mode = m_immediate then
if op.label /= null_label then
words(words(0)) := get(get(op.label));
else
words(words(0)) := op.value;
end if;
elsif op.mode = m_symbolic then
if op.label /= null_label then
words(words(0)) := get(get(op.label) - addr) - offset;
else
words(words(0)) := op.value - get(addr) - offset;
end if;
else
words(words(0)) := op.value;
end if;
end if;
end repr_ext_word;
procedure repr_destination is
begin
if cmd.command not in two_commands then
return;
end if;
case cmd.destination.mode is
when m_register =>
set_bits(8, 1, 0);
set_bits(4, 4, cmd.destination.register);
when m_indexed =>
set_bits(8, 1, 1);
set_bits(4, 4, cmd.destination.register);
when m_symbolic =>
set_bits(8, 1, 1);
set_bits(4, 4, r_pc);
when m_absolute =>
set_bits(8, 1, 1);
set_bits(4, 4, r_sr);
when others =>
error_parse(cdr(cmd.destination.mode'img, 2) & " not be used for destination");
end case;
repr_ext_word(cmd.destination);
end repr_destination;
procedure source_to_operation (pos : natural) is
begin
case cmd.source.mode is
when m_register|m_indexed|m_indirect_register|m_indirect_autoincrement =>
set_bits(pos, 4, cmd.source.register);
when m_symbolic|m_immediate =>
set_bits(pos, 4, r_pc);
when m_absolute =>
set_bits(pos, 4, r_sr);
when m_constant =>
if cmd.source.value = 0 then
set_bits(6, 2, 0);
set_bits(pos, 4, 3);
elsif cmd.source.value = 1 then
set_bits(6, 2, 1);
set_bits(pos, 4, 3);
elsif cmd.source.value = 2 then
set_bits(6, 2, 2);
set_bits(pos, 4, 3);
elsif cmd.source.value = 4 then
set_bits(6, 2, 2);
set_bits(pos, 4, r_sr);
elsif cmd.source.value = 8 then
set_bits(6, 2, 3);
set_bits(pos, 4, r_sr);
elsif cmd.source.value = -1 then
set_bits(6, 2, 3);
set_bits(pos, 4, 3);
else
error_parse("constant not constant");
end if;
end case;
end source_to_operation;
procedure repr_operands is
begin
if cmd.command in jump_commands|f_raw then
return;
end if;
if cmd.source.mode = m_register then
set_bits(6, 2, 0);
elsif cmd.source.mode in m_indexed|m_symbolic|m_absolute then
set_bits(6, 2, 1);
elsif cmd.source.mode = m_indirect_register then
set_bits(6, 2, 2);
elsif cmd.source.mode in m_indirect_autoincrement|m_immediate then
set_bits(6, 2, 3);
end if;
set_bits(7, 1, to_word(not cmd.bw));
if cmd.command in single_commands then
source_to_operation(4);
set_bits(13, 6, commands'pos(cmd.command) - commands'pos(single_commands'first) + 32);
elsif cmd.command in two_commands then
source_to_operation(12);
set_bits(16, 4, commands'pos(cmd.command) - commands'pos(two_commands'first) + 4);
end if;
repr_ext_word(cmd.source);
repr_destination;
end repr_operands;
w : word := 0;
begin
if cmd.command = f_raw then
set_bits(16, 16, cmd.source.value);
elsif cmd.command in jump_commands then
set_bits(16, 3, 1);
set_bits(13, 3, commands'pos(cmd.command) - commands'pos(jump_commands'first));
if cmd.source.mode /= m_symbolic then
error_parse("jump operand must be symbolic");
end if;
if cmd.source.label = null_label then
if odd(cmd.source.value) then
error_parse("jump addres [" & cmd.source.value'img & " ] must be even");
end if;
w := sr((cmd.source.value - get(addr) - 2), 1);
elsif get(cmd.source.label) = null_pos_addr then
error_parse("label " & name(cmd.source.label) & " used but not defined");
else
w := sr(get(get(cmd.source.label) - addr - create(2)), 1);
end if;
if w in 16#200#..16#7dff# then
if cmd.source.label /= null_label then
error_parse("jump to " & name(cmd.source.label) & " address > 10bit");
else
error_parse("jump to " & cmd.source.value'img & " address > 10bit");
end if;
end if;
set_bits(10, 10, w);
end if;
inc(words(0));
w := words(0);
repr_operands;
words(w) := operation;
end command_to_words;
procedure append_line is
l : word := word'min(words(0), 8);
checksum : word;
begin
if l = 0 then
return;
end if;
size := size + l * 2;
checksum := l * 2;
update_checksum(checksum, get(line_addr));
unb.append(out_text, ':' & cdr(image(l * 2, 16), 2) & image(get(line_addr), 16) & "00");
for i in 1..l loop
update_checksum(checksum, words(i));
unb.append(out_text, word_to_str_revers(words(i)));
end loop;
unb.append(out_text, cdr(image(256 - (checksum and 255), 16), 2) & ascii.cr & ascii.lf);
if words(0) > 8 then
for i in 9..words(0) loop
words(i - 8) := words(i);
end loop;
words(0) := words(0) - 8;
line_addr := line_addr + word(16);
else
if programm_t.has_element(cur) then
line_addr := programm_t.key(cur);
end if;
words(0) := 0;
end if;
end append_line;
reti_inserted : boolean := false;
reti_cursor : programm_t.cursor;
reti_address : pos_addr_t;
begin
print(" 0xfa [http://0xfa.space]");
print("a0xfa v0.1.0 - msp430 assembler (ihex format [https://wikipedia.org/wiki/Intel_HEX])");
print("");
if word'size > ada.containers.hash_type'size then
error("hash type error");
end if;
if word'size > natural'size then
error("integer size error");
end if;
if ada.command_line.argument_count /= 2 then
error("format: a0xfa input_file_path output_file_path");
end if;
getter.file.open(ada.command_line.argument(1));
from_file;
reti_address := create(get_var_val("mem_code_end") - 1);
loop
programm_t.insert(programm, reti_address, (f_reti, null_operand, null_operand, 0, true), reti_cursor, reti_inserted);
exit when reti_inserted;
dec(reti_address);
end loop;
for i in 32736..32767 loop
programm_t.insert(programm, address.create(word(i * 2)), (f_raw, (m_constant, get(reti_address), 0, null_label), null_operand, 0, true), reti_cursor, reti_inserted);
end loop;
cur := programm.first;
line_addr := programm.first_key;
words(0) := 0;
while programm_t.has_element(cur) loop
command_to_words(programm_t.element(cur), programm_t.key(cur));
programm_t.next(cur);
if words(0) >= 8 then
append_line;
end if;
if not programm_t.has_element(cur) or else programm_t.key(cur) /= (line_addr + words(0) * 2) then
append_line;
end if;
end loop;
unb.append(out_text, ":00000001FF");
ada.text_io.create(out_file, name => ada.command_line.argument(2));
ada.text_io.put(out_file, unb.to_string(out_text));
ada.text_io.close(out_file);
print("done. size:" & size'img & "b");
exception
when this_error: parse_error =>
error(ada.exceptions.exception_message(this_error));
when this_error: ada.io_exceptions.use_error =>
error("Error: " & ada.exceptions.exception_message(this_error));
end a0xfa;
|
libsrc/_DEVELOPMENT/alloc/obstack/c/sccz80/obstack_copy0_callee.asm | meesokim/z88dk | 0 | 10190 | <reponame>meesokim/z88dk<gh_stars>0
; ===============================================================
; Dec 2013
; ===============================================================
;
; void *obstack_copy0(struct obstack *ob, void *address, size_t size)
;
; Attempt to allocate size+1 bytes from the obstack and initialize
; it by copying data from address, terminating the copy with a
; NUL char. Implicitly closes any growing object.
;
; ===============================================================
SECTION code_alloc_obstack
PUBLIC obstack_copy0_callee
obstack_copy0_callee:
pop hl
pop bc
pop de
ex (sp),hl
INCLUDE "alloc/obstack/z80/asm_obstack_copy0.asm"
|
automaton-script/src/main/antlr4/ascript/AScript.g4 | francoiscolombo/fc-automation | 0 | 3758 | <reponame>francoiscolombo/fc-automation<filename>automaton-script/src/main/antlr4/ascript/AScript.g4<gh_stars>0
grammar AScript;
import ASExpression, ASTokens;
prog: block EOF;
statement
: letstmt
| printstmt
| inputstmt
| ifstmt
| forstmt
| whilestmt
| repeatstmt
| continuestmt
| exitstmt
| compressstmt
| extractstmt
| copystmt
| showstmt
| downloadstmt
| executestmt
| filestmt
| linesstmt1
| linesstmt2
| linesstmt3
| packagestmt
| scriptstmt
| sendstmt
| templatestmt1
| templatestmt2
| unzipstmt
| zipstmt
| pingstmt
| scanstmt
| COMMENT;
block
: (statement (NEWLINE+ | EOF))*
;
letstmt
: LET? vardecl EQ expression
;
vardecl
: varname varsuffix?
;
varname
: ID
;
varsuffix
: DOLLAR
;
printstmt
: PRINT expression
;
inputstmt
: INPUT string TO vardecl
;
ifstmt
: IF expression NEWLINE* THEN NEWLINE+ block elifstmt* elsestmt? ENDIF
;
elifstmt
: ELSE IF expression NEWLINE* THEN NEWLINE+ block
;
elsestmt
: ELSE NEWLINE+ block
;
forstmt
: FOR vardecl EQ expression TO expression (STEP expression)? NEWLINE+ block ENDFOR
;
whilestmt
: WHILE expression NEWLINE+ block ENDWHILE
;
repeatstmt
: REPEAT NEWLINE+ block NEWLINE* UNTIL expression
;
continuestmt
: CONTINUE
;
exitstmt
: EXIT
;
compressstmt
: COMPRESS expression TO expression
;
extractstmt
: EXTRACT expression TO expression
;
copystmt
: COPY FROM expression TO expression
;
showstmt
: SHOW FILE? expression
;
downloadstmt
: DOWNLOAD FROM expression TO expression
;
executestmt
: EXECUTE expression FROM DIR expression TO vardecl
;
filestmt
: FILE expression STATE expression (OWNER expression)? (MODE expression)?
;
linesstmt1
: LINES expression BEFORE REGEX expression SET expression
;
linesstmt2
: LINES expression AFTER REGEX expression SET expression
;
linesstmt3
: LINES expression REPLACE REGEX expression BY expression
;
packagestmt
: PACKAGE exprlist
;
scriptstmt
: CALL expression OUTPUT vardecl
;
sendstmt
: SEND FILE expression TO string PORT number ON expression
;
templatestmt1
: TEMPLATE FROM expression TO expression
;
templatestmt2
: TEMPLATE CONTENT expression TO expression
;
unzipstmt
: UNZIP FROM expression TO expression
;
zipstmt
: ZIP FROM expression TO expression
;
pingstmt
: PING expression
;
scanstmt
: SCAN NETWORK? expression
;
|
regtests/el-utils-tests.adb | jquorning/ada-el | 6 | 7146 | -----------------------------------------------------------------------
-- el-contexts-tests - Tests the EL contexts
-- Copyright (C) 2011, 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 Util.Test_Caller;
with Util.Properties;
with Util.Beans.Objects;
with EL.Contexts.Default;
package body EL.Utils.Tests is
use Util.Tests;
use Util.Beans.Objects;
package Caller is new Util.Test_Caller (Test, "EL.Utils");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test EL.Utils.Expand",
Test_Expand_Properties'Access);
Caller.Add_Test (Suite, "Test EL.Utils.Expand (recursion)",
Test_Expand_Recursion'Access);
Caller.Add_Test (Suite, "Test EL.Utils.Eval",
Test_Eval'Access);
end Add_Tests;
-- ------------------------------
-- Test expand list of properties
-- ------------------------------
procedure Test_Expand_Properties (T : in out Test) is
Context : EL.Contexts.Default.Default_Context;
Props : Util.Properties.Manager;
Result : Util.Properties.Manager;
begin
Props.Set ("context", "#{homedir}/context");
Props.Set ("homedir", "#{home}/#{user}");
Props.Set ("unknown", "#{not_defined}");
Props.Set ("user", "joe");
Props.Set ("home", "/home");
EL.Utils.Expand (Source => Props,
Into => Result,
Context => Context);
Assert_Equals (T, "joe", String '(Result.Get ("user")), "Invalid expansion");
Assert_Equals (T, "/home/joe", String '(Result.Get ("homedir")), "Invalid expansion");
Assert_Equals (T, "/home/joe/context", String '(Result.Get ("context")),
"Invalid expansion");
Assert_Equals (T, "", String '(Result.Get ("unknown")), "Invalid expansion");
end Test_Expand_Properties;
-- ------------------------------
-- Test expand list of properties
-- ------------------------------
procedure Test_Expand_Recursion (T : in out Test) is
Context : EL.Contexts.Default.Default_Context;
Props : Util.Properties.Manager;
Result : Util.Properties.Manager;
begin
Props.Set ("context", "#{homedir}/context");
Props.Set ("homedir", "#{home}/#{user}");
Props.Set ("user", "joe");
Props.Set ("home", "#{context}");
EL.Utils.Expand (Source => Props,
Into => Result,
Context => Context);
Assert_Equals (T, "joe", String '(Result.Get ("user")), "Invalid expansion");
Assert_Equals (T, "/joe/context/joe/context/joe/context/joe",
String '(Result.Get ("homedir")),
"Invalid expansion");
end Test_Expand_Recursion;
-- ------------------------------
-- Test expand list of properties
-- ------------------------------
procedure Test_Eval (T : in out Test) is
Context : EL.Contexts.Default.Default_Context;
begin
Assert_Equals (T, "1", EL.Utils.Eval (Value => "1",
Context => Context), "Invalid eval <empty string>");
Assert_Equals (T, "3", EL.Utils.Eval (Value => "#{2+1}",
Context => Context), "Invalid eval <valid expr>");
declare
Value, Result : Util.Beans.Objects.Object;
begin
Value := Util.Beans.Objects.To_Object (Integer '(123));
Result := EL.Utils.Eval (Value => Value,
Context => Context);
T.Assert (Value = Result, "Eval should return the same object");
Value := Util.Beans.Objects.To_Object (String '("345"));
Result := EL.Utils.Eval (Value => Value,
Context => Context);
T.Assert (Value = Result, "Eval should return the same object");
end;
end Test_Eval;
end EL.Utils.Tests;
|
programs/oeis/022/A022158.asm | neoneye/loda | 22 | 8554 | ; A022158: First column of spectral array W(sqrt(3)).
; 1,5,8,10,13,17,20,22,25,29,32,34,38,41,43,46,50,53,55,58,62,65,67,71,74,77,79,83,86,88,91,95,98,100,103,107,110,112,116,119,122,124,128,131,133,136,140,143,145,148,152,155,157,161,164,166,169,173,176,178,181,185,188,190,193,197,200,202,206,209,211,214,218,221,223,226,230,233,235,239,242,245,247,251,254,256,259,263,266,268,271,275,278,280,284,287,290,292,296,299
seq $0,22838 ; Beatty sequence for sqrt(3); complement of A054406.
seq $0,198081 ; Ceiling(n*Sqrt(3)).
sub $0,1
|
src.pinprint/pinprint.ads | persan/a-cups | 0 | 26606 | package Pinprint is
end Pinprint;
|
Logic/PropositionalLogic.agda | Smaug123/agdaproofs | 4 | 15389 | <reponame>Smaug123/agdaproofs
{-# OPTIONS --safe --warning=error #-}
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import LogicalFormulae
open import Functions.Definition
open import Boolean.Definition
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Vectors
module Logic.PropositionalLogic where
data Propositions {a : _} (primitives : Set a) : Set a where
ofPrimitive : primitives → Propositions primitives
false : Propositions primitives
implies : (a b : Propositions primitives) → Propositions primitives
prNot : {a : _} {pr : Set a} → Propositions pr → Propositions pr
prNot p = implies p false
impliesIsBigger : {a : _} {pr : Set a} {P Q : Propositions pr} → Q ≡ implies P Q → False
impliesIsBigger {P = P} {Q} ()
impliesInjectiveL : {a : _} {A : Set a} → {p q r : Propositions A} → implies p q ≡ implies r q → p ≡ r
impliesInjectiveL refl = refl
impliesInjectiveR : {a : _} {A : Set a} → {p q r : Propositions A} → implies p q ≡ implies p r → q ≡ r
impliesInjectiveR refl = refl
impliesInjective : {a : _} {A : Set a} → {p q r s : Propositions A} → implies p q ≡ implies r s → (p ≡ r) && (q ≡ s)
impliesInjective refl = refl ,, refl
record Valuation {a : _} (primitives : Set a) : Set a where
field
v : Propositions primitives → Bool
vFalse : v false ≡ BoolFalse
vImplicationF : {p q : Propositions primitives} → v p ≡ BoolTrue → v q ≡ BoolFalse → v (implies p q) ≡ BoolFalse
vImplicationVacuous : {p q : Propositions primitives} → v p ≡ BoolFalse → v (implies p q) ≡ BoolTrue
vImplicationT : {p q : Propositions primitives} → v q ≡ BoolTrue → v (implies p q) ≡ BoolTrue
-- Proposition 1a
valuationIsDetermined : {a : _} {pr : Set a} → (v1 v2 : Valuation pr) → ({x : pr} → Valuation.v v1 (ofPrimitive x) ≡ Valuation.v v2 (ofPrimitive x)) → {x : Propositions pr} → Valuation.v v1 x ≡ Valuation.v v2 x
valuationIsDetermined v1 v2 pr {ofPrimitive x} = pr
valuationIsDetermined v1 v2 pr {false} rewrite Valuation.vFalse v1 | Valuation.vFalse v2 = refl
valuationIsDetermined v1 v2 pr {implies x y} with valuationIsDetermined v1 v2 pr {x}
valuationIsDetermined v1 v2 pr {implies x y} | eqX with valuationIsDetermined v1 v2 pr {y}
... | eqY with inspect (Valuation.v v1 x)
valuationIsDetermined v1 v2 pr {implies x y} | eqX | eqY | BoolTrue with≡ p with inspect (Valuation.v v1 y)
valuationIsDetermined v1 v2 pr {implies x y} | eqX | eqY | BoolTrue with≡ p | BoolTrue with≡ q rewrite p | q | Valuation.vImplicationT v2 {p = x} {q = y} (equalityCommutative eqY) | Valuation.vImplicationT v1 {p = x} {q = y} q = refl
valuationIsDetermined v1 v2 pr {implies x y} | eqX | eqY | BoolTrue with≡ p | BoolFalse with≡ q rewrite p | q | Valuation.vImplicationF v1 p q | Valuation.vImplicationF v2 (equalityCommutative eqX) (equalityCommutative eqY) = refl
valuationIsDetermined v1 v2 pr {implies x y} | eqX | eqY | BoolFalse with≡ p rewrite p | Valuation.vImplicationVacuous v1 {q = y} p | Valuation.vImplicationVacuous v2 {q = y} (equalityCommutative eqX) = refl
extendValuationV : {a : _} {pr : Set a} → (w : pr → Bool) → Propositions pr → Bool
extendValuationV w (ofPrimitive x) = w x
extendValuationV w false = BoolFalse
extendValuationV w (implies x y) with extendValuationV w x
... | BoolTrue with extendValuationV w y
extendValuationV w (implies x y) | BoolTrue | BoolTrue = BoolTrue
... | BoolFalse = BoolFalse
extendValuationV w (implies x y) | BoolFalse = BoolTrue
extendValuation : {a : _} {pr : Set a} → (w : pr → Bool) → Valuation pr
Valuation.v (extendValuation w) = extendValuationV w
Valuation.vFalse (extendValuation w) = refl
Valuation.vImplicationF (extendValuation w) {p} {q} pT qF with Valuation.v (extendValuation w) p
Valuation.vImplicationF (extendValuation w) {p} {q} refl qF | BoolTrue with Valuation.v (extendValuation w) q
Valuation.vImplicationF (extendValuation w) {p} {q} refl () | BoolTrue | BoolTrue
Valuation.vImplicationF (extendValuation w) {p} {q} refl refl | BoolTrue | BoolFalse = refl
Valuation.vImplicationF (extendValuation w) {p} {q} () qF | BoolFalse
Valuation.vImplicationVacuous (extendValuation w) {p} {q} pF with Valuation.v (extendValuation w) p
Valuation.vImplicationVacuous (extendValuation w) {p} {q} () | BoolTrue
Valuation.vImplicationVacuous (extendValuation w) {p} {q} refl | BoolFalse = refl
Valuation.vImplicationT (extendValuation w) {p} {q} qT with Valuation.v (extendValuation w) p
Valuation.vImplicationT (extendValuation w) {p} {q} qT | BoolTrue with Valuation.v (extendValuation w) q
Valuation.vImplicationT (extendValuation w) {p} {q} refl | BoolTrue | BoolTrue = refl
Valuation.vImplicationT (extendValuation w) {p} {q} () | BoolTrue | BoolFalse
Valuation.vImplicationT (extendValuation w) {p} {q} qT | BoolFalse = refl
-- Proposition 1b
valuationsAreFree : {a : _} {pr : Set a} → (w : pr → Bool) → {x : pr} → Valuation.v (extendValuation w) (ofPrimitive x) ≡ w x
valuationsAreFree w = refl
Tautology : {a : _} {pr : Set a} (prop : Propositions pr) → Set a
Tautology {pr = pr} prop = (v : Valuation pr) → Valuation.v v prop ≡ BoolTrue
record IsSubset {a b : _} (sub : Set a) (super : Set b) : Set (a ⊔ b) where
field
ofElt : sub → super
mapProp : {a b : _} {pr1 : Set a} {pr2 : Set b} → (pr1 → pr2) → Propositions pr1 → Propositions pr2
mapProp f (ofPrimitive x) = ofPrimitive (f x)
mapProp f false = false
mapProp f (implies p q) = implies (mapProp f p) (mapProp f q)
inheritedValuation : {a b : _} {sub : Set a} {super : Set b} → (IsSubset sub super) → Valuation super → Valuation sub
Valuation.v (inheritedValuation isSub v) prop = Valuation.v v (mapProp (IsSubset.ofElt isSub) prop)
Valuation.vFalse (inheritedValuation isSub v) = Valuation.vFalse v
Valuation.vImplicationF (inheritedValuation isSub v) pT qF = Valuation.vImplicationF v pT qF
Valuation.vImplicationVacuous (inheritedValuation isSub v) pF = Valuation.vImplicationVacuous v pF
Valuation.vImplicationT (inheritedValuation isSub v) qT = Valuation.vImplicationT v qT
inheritedValuation' : {a b : _} {sub : Set a} {super : Set b} → (IsSubset sub (Propositions super)) → Valuation super → (x : sub) → Bool
inheritedValuation' subset v x = Valuation.v v (IsSubset.ofElt subset x)
Entails : {a b : _} {sub : Set a} {super : Set b} (S : IsSubset sub (Propositions super)) (P : Propositions super) → Set (a ⊔ b)
Entails {sub = sub} {super = super} S P = {v : Valuation super} → ({s : sub} → inheritedValuation' S v s ≡ BoolTrue) → Valuation.v v P ≡ BoolTrue
data ThreeElements : Set where
One : ThreeElements
Two : ThreeElements
Three : ThreeElements
indexAxiom : {a : _} (A : Set a) → ThreeElements → Set a
indexAxiom A One = Propositions A && Propositions A
indexAxiom A Two = Propositions A & Propositions A & Propositions A
indexAxiom A Three = Propositions A
indexPropositionalAxioms : {a : _} {A : Set a} → Set a
indexPropositionalAxioms {A = A} = Sg ThreeElements (indexAxiom A)
-- An axiom system is simply a subset of a set of propositions.
propositionalAxioms : {a : _} {A : Set a} → IsSubset (indexPropositionalAxioms {A = A}) (Propositions A)
IsSubset.ofElt propositionalAxioms (One , (p ,, q)) = implies p (implies q p)
IsSubset.ofElt propositionalAxioms (Two , record { one = p ; two = q ; three = r }) = implies (implies p (implies q r)) (implies (implies p q) (implies p r))
IsSubset.ofElt propositionalAxioms (Three , p) = implies (prNot (prNot p)) p
record Selection {a : _} {A : Set a} {n : ℕ} (l : Vec A n) : Set a where
field
element : A
position : ℕ
pos<N : position <N n
elementIsAt : vecIndex l position pos<N ≡ element
data Proof {a b c : _} {A : Set a} {axioms : Set b} (axiomsSubset : IsSubset axioms (Propositions A)) {givens : Set c} (givensSubset : IsSubset givens (Propositions A)) : (n : ℕ) → Set (a ⊔ b ⊔ c)
data ProofStep {a b c : _} {A : Set a} {axioms : Set b} (axiomsSubset : IsSubset axioms (Propositions A)) {givens : Set c} (givensSubset : IsSubset givens (Propositions A)) {n : ℕ} (proofSoFar : Proof {a} {b} {c} {A} {axioms} axiomsSubset {givens} givensSubset n) : Set (a ⊔ b ⊔ c)
toSteps : {a b c : _} {A : Set a} {axioms : Set b} {axiomsSubset : IsSubset axioms (Propositions A)} {givens : Set c} {givensSubset : IsSubset givens (Propositions A)} {n : ℕ} (pr : Proof {axioms = axioms} axiomsSubset {givens = givens} givensSubset n) → Vec (Propositions A) n
data ProofStep {a} {b} {c} {A} {axioms} axiomsSubset {givens} givensSubset proofSoFar where
axiom : axioms → ProofStep axiomsSubset givensSubset proofSoFar
given : givens → ProofStep axiomsSubset givensSubset proofSoFar
modusPonens : (implication : Selection (toSteps proofSoFar)) → (argument : Selection (toSteps proofSoFar)) → (conclusion : Propositions A) → (Selection.element implication ≡ implies (Selection.element argument) conclusion) → ProofStep axiomsSubset givensSubset proofSoFar
data Proof {a} {b} {c} {A} {axioms} axiomsSubset {givens} givensSubset where
empty : Proof axiomsSubset givensSubset 0
nextStep : (n : ℕ) → (previous : Proof {axioms = axioms} axiomsSubset {givens = givens} givensSubset n) → ProofStep axiomsSubset givensSubset previous → Proof axiomsSubset givensSubset (succ n)
toSteps empty = []
toSteps {axiomsSubset = axiomsSubset} (nextStep n pr (axiom x)) = (IsSubset.ofElt axiomsSubset x) ,- toSteps pr
toSteps {givensSubset = givensSubset} (nextStep n pr (given x)) = IsSubset.ofElt givensSubset x ,- toSteps pr
toSteps (nextStep n pr (modusPonens implication argument conclusion x)) = conclusion ,- toSteps pr
record Proves {a b c : _} {A : Set a} {axioms : Set b} (axiomsSubset : IsSubset axioms (Propositions A)) {givens : Set c} (givensSubset : IsSubset givens (Propositions A)) (P : Propositions A) : Set (a ⊔ b ⊔ c) where
field
n : ℕ
proof : Proof axiomsSubset givensSubset (succ n)
ofStatement : vecIndex (toSteps proof) 0 (succIsPositive n) ≡ P
addSingletonSet : {a : _} → Set a → Set a
addSingletonSet A = True || A
interpretSingletonSet : {a b c : _} {A : Set a} {B : Set b} {C : Set c} → IsSubset A B → (c : C) → (addSingletonSet A) → C || B
interpretSingletonSet A<B c (inl x) = inl c
interpretSingletonSet A<B _ (inr x) = inr (IsSubset.ofElt A<B x)
inrInjective : {a b : _} {A : Set a} {B : Set b} {b1 b2 : B} → inr {a = a} {A = A} b1 ≡ inr b2 → b1 ≡ b2
inrInjective refl = refl
singletonSubset : {a b c : _} {A : Set a} {B : Set b} {C : Set c} → IsSubset A B → (c : C) → IsSubset (addSingletonSet A) (C || B)
IsSubset.ofElt (singletonSubset subs c) = interpretSingletonSet subs c
adjoinGiven : {a b : _} {A : Set a} {givens : Set b} (givensSubset : IsSubset givens A) (P : A) → IsSubset (addSingletonSet givens) A
IsSubset.ofElt (adjoinGiven record { ofElt = ofElt } P) (inl x) = P
IsSubset.ofElt (adjoinGiven record { ofElt = ofElt } _) (inr x) = ofElt x
vecIndexRefl : {a : _} {A : Set a} {n : ℕ} {v1 v2 : Vec A n} → {pos : ℕ} → {pos<N1 pos<N2 : pos <N n} → v1 ≡ v2 → vecIndex v1 pos pos<N1 ≡ vecIndex v2 pos pos<N2
vecIndexRefl {v1 = v1} {.v1} {pos} {pos<N1} {pos<N2} refl = refl
{-
proofRemainsValidOnAddingGivens : {a b c : _} {A : Set a} {axioms : Set b} {axiomsSubset : IsSubset axioms (Propositions A)} {givens : Set c} {givensSubset : IsSubset givens (Propositions A)} {n : ℕ} → {Q : Propositions A} → Proof axiomsSubset givensSubset n → Proof axiomsSubset (adjoinGiven givensSubset Q) n
pr' : {a b c : _} {A : Set a} {axioms : Set b} {axiomsSubset : IsSubset axioms (Propositions A)} {givens : Set c} {givensSubset : IsSubset givens (Propositions A)} {n : ℕ} → {Q : Propositions A} → (pr : Proof axiomsSubset givensSubset n) → toSteps pr ≡ toSteps (proofRemainsValidOnAddingGivens {Q = Q} pr)
pr' empty = refl
pr' (nextStep n pr (axiom x)) rewrite pr' pr = refl
pr' (nextStep n pr (given x)) rewrite pr' pr = refl
pr' (nextStep n pr (modusPonens implication argument conclusion x)) rewrite pr' pr = refl
proofRemainsValidOnAddingGivens {Q = Q} empty = empty
proofRemainsValidOnAddingGivens {Q = Q} (nextStep n pr (axiom x)) = nextStep n (proofRemainsValidOnAddingGivens pr) (axiom x)
proofRemainsValidOnAddingGivens {Q = Q} (nextStep n pr (given x)) = nextStep n (proofRemainsValidOnAddingGivens pr) (given (inr x))
proofRemainsValidOnAddingGivens {A = A} {axiomsSubset = axiomsSubset} {givensSubset = givensSubset} {Q = Q} (nextStep n pr (modusPonens implication argument conclusion x)) = nextStep n (proofRemainsValidOnAddingGivens pr) (modusPonens (record { element = Selection.element implication ; position = Selection.position implication ; pos<N = Selection.pos<N implication ; elementIsAt = lemma implication }) (record { element = Selection.element argument ; position = Selection.position argument ; pos<N = Selection.pos<N argument ; elementIsAt = lemma argument }) conclusion x)
where
lemma : (sel : Selection (toSteps pr)) → vecIndex (toSteps (proofRemainsValidOnAddingGivens pr)) (Selection.position sel) (Selection.pos<N sel) ≡ Selection.element sel
lemma sel with proofRemainsValidOnAddingGivens {Q = Q} pr
... | nextStep n bl x = {!!}
-}
{-
proofImpliesProves : {a b c : _} {A : Set a} {axioms : Set b} {axiomsSubset : IsSubset axioms (Propositions A)} {givens : Set c} {givensSubset : IsSubset givens (Propositions A)} {n : ℕ} (0<n : 0 <N n) → (p : Proof axiomsSubset givensSubset n) → (pr : Propositions A) → vecIndex (toSteps p) 0 0<n ≡ pr → Proves axiomsSubset givensSubset pr
proofImpliesProves {n = zero} () p pr x
proofImpliesProves {n = succ n} _ p pr x = record { n = n ; proof = p ; ofStatement = transitivity (vecIndexRefl {v1 = toSteps p} refl) x }
deductionTheorem' : {a b c : _} {A : Set a} {axioms : Set b} {axiomsSubset : IsSubset axioms (Propositions A)} {givens : Set c} {givensSubset : IsSubset givens (Propositions A)} {n : ℕ} → {P Q : Propositions A} → Proves axiomsSubset givensSubset (implies P Q) → Proves axiomsSubset {givens = addSingletonSet givens} (adjoinGiven givensSubset P) Q
Proves.n (deductionTheorem' record { n = n ; proof = proof ; ofStatement = ofStatement }) = succ (succ n)
Proves.proof (deductionTheorem' {P = P} {Q = Q} record { n = n ; proof = proof ; ofStatement = ofStatement }) = nextStep (succ (succ n)) (nextStep (succ n) (proofRemainsValidOnAddingGivens proof) (given (inl record {}))) (modusPonens (record { element = implies P Q ; position = 1 ; pos<N = succPreservesInequality (succIsPositive _) ; elementIsAt = transitivity (equalityCommutative (vecIndexRefl (pr' proof))) ofStatement }) (record { element = P ; position = 0 ; pos<N = succIsPositive _ ; elementIsAt = refl }) Q refl)
Proves.ofStatement (deductionTheorem' record { n = n ; proof = proof ; ofStatement = ofStatement }) = refl
deductionTheorem : {a b c : _} {A : Set a} {givens : Set c} {givensSubset : IsSubset givens (Propositions A)} {n : ℕ} → {P Q : Propositions A} → Proves propositionalAxioms {givens = addSingletonSet givens} (adjoinGiven givensSubset P) Q → Proves propositionalAxioms givensSubset (implies P Q)
deductionTheorem {P = P} {Q} record { n = n ; proof = (nextStep .n proof (axiom x)) ; ofStatement = ofStatement } = {!!}
--... | bl = record { n = {!!} ; proof = nextStep (succ (succ (succ n))) (nextStep (succ (succ n)) (nextStep (succ n) {!deductionTheorem proof!} (axiom x)) (axiom (One , (Q ,, P)))) (modusPonens (record { element = implies Q (implies P Q) ; position = 0 ; pos<N = succIsPositive _ ; elementIsAt = refl }) (record { element = Q ; position = 1 ; pos<N = succPreservesInequality (succIsPositive _) ; elementIsAt = ofStatement }) (implies P Q) refl) ; ofStatement = {!!} }
deductionTheorem {P = P} {Q} record { n = n ; proof = (nextStep .n proof (given x)) ; ofStatement = ofStatement } = {!!}
deductionTheorem {P = P} {Q} record { n = n ; proof = (nextStep .n proof (modusPonens implication argument conclusion x)) ; ofStatement = ofStatement } = {!!}
{-
Proves.n (deductionTheorem {P = P} {Q} record { n = n ; proof = (nextStep .n proof (axiom x)) ; ofStatement = ofStatement }) = succ (succ (succ n))
Proves.proof (deductionTheorem {P = P} {Q} record { n = n ; proof = (nextStep .n proof (axiom x)) ; ofStatement = ofStatement }) = nextStep (succ (succ (succ n))) (nextStep (succ (succ n)) (nextStep (succ n) {!!} (axiom x)) (axiom (One , (Q ,, P)))) (modusPonens (record { element = implies Q (implies P Q) ; position = 0 ; pos<N = succIsPositive _ ; elementIsAt = refl }) (record { element = Q ; position = 1 ; pos<N = succPreservesInequality (succIsPositive _) ; elementIsAt = ofStatement }) (implies P Q) refl)
Proves.ofStatement (deductionTheorem {P = P} {Q} record { n = n ; proof = (nextStep .n proof (axiom x)) ; ofStatement = ofStatement }) = {!!}
deductionTheorem {P = P} {Q} record { n = n ; proof = (nextStep .n proof (given x)) ; ofStatement = ofStatement } = {!!}
deductionTheorem {P = P} {Q} record { n = n ; proof = (nextStep .n proof (modusPonens implication argument conclusion x)) ; ofStatement = ofStatement } = {!!}
-}
propositionalLogicSound : {a b c : _} {A : Set a} {givens : Set c} {givensSubset : IsSubset givens (Propositions A)} → {P : Propositions A} → Proves propositionalAxioms givensSubset P → Entails givensSubset P
Entails.entails (propositionalLogicSound {P = .(IsSubset.ofElt propositionalAxioms x)} record { n = .0 ; proof = (nextStep .0 empty (axiom x)) ; ofStatement = refl }) {v} values = propositionalAxiomsTautology x {v}
Entails.entails (propositionalLogicSound {P = P} record { n = .0 ; proof = (nextStep .0 empty (given x)) ; ofStatement = ofStatement }) {v} values rewrite equalityCommutative ofStatement = values {x}
Entails.entails (propositionalLogicSound {P = P} record { n = .0 ; proof = (nextStep .0 empty (modusPonens record { element = element ; position = zero ; pos<N = (le x₁ ()) ; elementIsAt = elementIsAt } argument conclusion x)) ; ofStatement = ofStatement }) {v} values
Entails.entails (propositionalLogicSound {P = P} record { n = .0 ; proof = (nextStep .0 empty (modusPonens record { element = element ; position = (succ position) ; pos<N = (le x₁ ()) ; elementIsAt = elementIsAt } argument conclusion x)) ; ofStatement = ofStatement }) {v} values
Entails.entails (propositionalLogicSound {P = P} record { n = .(succ n) ; proof = (nextStep .(succ n) (nextStep n proof y) x) ; ofStatement = ofStatement }) {v} values = {!!}
-}
|
alloy4fun_models/trashltl/models/4/qP2G4cALAKtT3ivgs.als | Kaixi26/org.alloytools.alloy | 0 | 4454 | <gh_stars>0
open main
pred idqP2G4cALAKtT3ivgs_prop5 {
always some f : File | eventually f in Trash
}
pred __repair { idqP2G4cALAKtT3ivgs_prop5 }
check __repair { idqP2G4cALAKtT3ivgs_prop5 <=> prop5o } |
mastersystem/zxb-sms-2012-02-23/zxb-sms/example/test.asm | gb-archive/really-old-stuff | 10 | 28875 | <filename>mastersystem/zxb-sms-2012-02-23/zxb-sms/example/test.asm
;==============================================================
; WLA-DX banking setup
;==============================================================
.memorymap
defaultslot 0
; rom area
slotsize $4000
slot 0 $0000
slot 1 $4000
slot 2 $8000
; ram area
slotsize $2000
slot 3 $C000
slot 4 $E000
.endme
.rombankmap
bankstotal 2
banksize $4000
banks 2
.endro
;==============================================================
; SDSC tag and SMS rom header
;==============================================================
.sdsctag 0.0,"ZX Basic program","Generated by zxb2wla 0.03 alpha","Haroldo"
.smstag
.include "..\lib\wla\boot.inc"
;==============================================================
; Includes
;==============================================================
.include "..\lib\wla\Useful functions.inc"
.include "..\lib\wla\BBC Micro font.inc"
.include "..\lib\wla\sprite.inc"
.section "ZX Basic code" free
zb__START_PROGRAM:
ld hl, 256
ld (zb_ballSpdX), hl
ld hl, 256
ld (zb_ballSpdY), hl
zb__LABEL0:
call zb_ReadJoypad1
ld (zb_joy), a
ld hl, 4
push hl
ld a, (zb_joy)
ld l, a
ld h, 0
call zb_AndW
ld a, h
or l
jp z, zb__LABEL2
ld hl, (zb_padSpdX)
ld de, -64
add hl, de
ld (zb_padSpdX), hl
push hl
ld de, 65024
pop hl
or a
sbc hl, de
add hl, hl
jp nc, zb__LABEL5
ld hl, 65024
ld (zb_padSpdX), hl
zb__LABEL5:
jp zb__LABEL3
zb__LABEL2:
ld hl, 8
push hl
ld a, (zb_joy)
ld l, a
ld h, 0
call zb_AndW
ld a, h
or l
jp z, zb__LABEL6
ld hl, (zb_padSpdX)
ld de, 64
add hl, de
ld (zb_padSpdX), hl
push hl
ld hl, 512
pop de
or a
sbc hl, de
add hl, hl
jp nc, zb__LABEL9
ld hl, 512
ld (zb_padSpdX), hl
zb__LABEL9:
jp zb__LABEL7
zb__LABEL6:
ld hl, (zb_padSpdX)
push hl
ld de, 0
pop hl
or a
sbc hl, de
add hl, hl
jp nc, zb__LABEL12
ld hl, (zb_padSpdX)
call zb__NEGHL
srl h
rr l
call zb__NEGHL
ld (zb_padSpdX), hl
jp zb__LABEL13
zb__LABEL12:
ld hl, (zb_padSpdX)
srl h
rr l
ld (zb_padSpdX), hl
zb__LABEL13:
zb__LABEL11:
zb__LABEL7:
zb__LABEL3:
ld hl, (zb_padX)
push hl
ld hl, (zb_padSpdX)
ex de, hl
pop hl
add hl, de
ld (zb_padX), hl
push hl
ld de, 0
pop hl
or a
sbc hl, de
add hl, hl
jp nc, zb__LABEL14
ld hl, 0
ld (zb_padX), hl
jp zb__LABEL15
zb__LABEL14:
ld hl, (zb_padX)
push hl
ld hl, 13312
pop de
or a
sbc hl, de
add hl, hl
jp nc, zb__LABEL17
ld hl, 13312
ld (zb_padX), hl
zb__LABEL17:
zb__LABEL15:
ld hl, (zb_ballX)
push hl
ld hl, (zb_ballSpdX)
ex de, hl
pop hl
add hl, de
ld (zb_ballX), hl
ld hl, (zb_ballY)
push hl
ld hl, (zb_ballSpdY)
ex de, hl
pop hl
add hl, de
ld (zb_ballY), hl
ld hl, (zb_ballX)
push hl
ld de, 0
pop hl
or a
sbc hl, de
add hl, hl
jp nc, zb__LABEL18
ld hl, 0
ld (zb_ballX), hl
ld hl, (zb_ballSpdX)
call zb__NEGHL
ld (zb_ballSpdX), hl
jp zb__LABEL19
zb__LABEL18:
ld hl, (zb_ballX)
push hl
ld hl, 15872
pop de
or a
sbc hl, de
add hl, hl
jp nc, zb__LABEL21
ld hl, 15872
ld (zb_ballX), hl
ld hl, (zb_ballSpdX)
call zb__NEGHL
ld (zb_ballSpdX), hl
zb__LABEL21:
zb__LABEL19:
ld hl, (zb_ballY)
push hl
ld de, 0
pop hl
or a
sbc hl, de
add hl, hl
jp nc, zb__LABEL22
ld hl, 0
ld (zb_ballY), hl
ld hl, (zb_ballSpdY)
call zb__NEGHL
ld (zb_ballSpdY), hl
jp zb__LABEL23
zb__LABEL22:
ld hl, (zb_ballY)
push hl
ld hl, 11776
pop de
or a
sbc hl, de
add hl, hl
jp nc, zb__LABEL25
ld hl, 11776
ld (zb_ballY), hl
ld hl, (zb_ballSpdY)
call zb__NEGHL
ld (zb_ballSpdY), hl
zb__LABEL25:
zb__LABEL23:
call zb_DrawPad
ld a, 10
push af
ld hl, (zb_ballY)
ld b, 6
zb__LABEL32:
sra h
rr l
djnz zb__LABEL32
ld a, l
push af
ld hl, (zb_ballX)
ld b, 6
zb__LABEL33:
sra h
rr l
djnz zb__LABEL33
ld a, l
push af
ld a, 6
call zb_SetSprite
call zb_WaitForVBlankNoInt
call zb_UpdateSprites
jp zb__LABEL0
zb__LABEL1:
zb_UpdateSprites:
;#line 1
jp UpdateSprites
;#line 2
zb_UpdateSprites__leave:
ret
zb_WaitForVBlankNoInt:
;#line 8
jp WaitForVBlankNoInt
;#line 9
zb_WaitForVBlankNoInt__leave:
ret
zb_SetSprite:
;#line 15
exx
pop hl
exx
ld d, 0
ld e, a
pop bc
ld hl, hw_sprites_y
add hl, de
pop af
ld (hl), a
ld hl, hw_sprites_xc
add hl, de
add hl, de
ld (hl), b
inc hl
pop af
ld (hl), a
exx
push hl
exx
;#line 35
zb_SetSprite__leave:
ret
zb_ReadJoypad1:
;#line 52
in a, ($dc)
cpl
;#line 54
zb_ReadJoypad1__leave:
ret
zb_ReadJoypad2:
;#line 59
in a, ($dc)
cpl
rla
rla
rla
and $03
ld l, a
in a, ($dd)
cpl
add a, a
add a, a
or l
;#line 71
zb_ReadJoypad2__leave:
ret
zb_AndW:
;#line 76
pop bc
pop de
ld a, l
and e
ld l, a
ld a, h
and d
ld h, a
push bc
;#line 85
zb_AndW__leave:
ret
zb_DrawPad:
push ix
ld ix, 0
add ix, sp
ld hl, 0
push hl
ld hl, (zb_padX)
ld b, 6
zb__LABEL34:
sra h
rr l
djnz zb__LABEL34
ld a, l
ld (ix-2), a
ld a, 28
push af
ld a, 160
push af
ld a, (ix-2)
push af
xor a
call zb_SetSprite
ld a, (ix-2)
add a, 8
ld (ix-2), a
ld (ix-1), 1
jp zb__LABEL26
zb__LABEL30:
ld a, 29
push af
ld a, 160
push af
ld a, (ix-2)
push af
ld a, (ix-1)
call zb_SetSprite
ld a, (ix-2)
add a, 8
ld (ix-2), a
zb__LABEL31:
ld a, (ix-1)
inc a
ld (ix-1), a
zb__LABEL26:
ld a, (ix-1)
push af
ld a, 4
pop hl
cp h
jp nc, zb__LABEL30
zb__LABEL29:
ld a, 30
push af
ld a, 160
push af
ld a, (ix-2)
push af
ld a, (ix-1)
call zb_SetSprite
zb_DrawPad__leave:
ld sp, ix
pop ix
ret
;#line 1 "neg16.asm"
; Negates HL value (16 bit)
zb__ABS16:
bit 7, h
ret z
zb__NEGHL:
ld a, l ; HL = -HL
cpl
ld l, a
ld a, h
cpl
ld h, a
inc hl
ret
;#line 366 "test.zxb"
ret
.ends
.section "ZXB variable init values" free
ZXBASIC_USER_DATA_VALUES:
; zb_ballSpdX
.db 00, 00
; zb_padX
.db 00, 00
; zb_ballX
.db 00, 00
; zb_ballY
.db 00, 00
; zb_ballSpdY
.db 00, 00
; zb_padSpdX
.db 00, 00
; zb_joy
.db 00
ZXBASIC_USER_DATA_VALUES_END:
.ends
.ramsection "ZXBasic Variables" slot 3
ZXBASIC_USER_DATA ds 0
zb_ballSpdX ds 2
zb_padX ds 2
zb_ballX ds 2
zb_ballY ds 2
zb_ballSpdY ds 2
zb_padSpdX ds 2
zb_joy ds 1
ZXBASIC_USER_DATA_END ds 0
.ends
|
src/lv-objx-lmeter.ads | Fabien-Chouteau/ada-lvlg | 3 | 3083 | <reponame>Fabien-Chouteau/ada-lvlg
with Lv.Style;
package Lv.Objx.Lmeter is
subtype Instance is Obj_T;
-- Create a line meter objects
-- @param par pointer to an object, it will be the parent of the new line meter
-- @param copy pointer to a line meter object, if not NULL then the new object will be copied from it
-- @return pointer to the created line meter
function Create (Parent : Obj_T; Copy : Instance) return Instance;
----------------------
-- Setter functions --
----------------------
-- Set a new value on the line meter
-- @param self pointer to a line meter object
-- @param value new value
procedure Set_Value (Self : Instance; Value : Int16_T);
-- Set minimum and the maximum values of a line meter
-- @param self pointer to he line meter object
-- @param min minimum value
-- @param max maximum value
procedure Set_Range (Self : Instance; Min : Int16_T; Max : Int16_T);
-- Set the scale settings of a line meter
-- @param self pointer to a line meter object
-- @param angle angle of the scale (0..360)
-- @param line_cnt number of lines
procedure Set_Scale (Self : Instance; Angle : Uint16_T; Line_Cnt : Uint8_T);
-- Set the styles of a line meter
-- @param self pointer to a line meter object
-- @param bg set the style of the line meter
procedure Set_Style (Self : Instance; Style : access Lv.Style.Style);
----------------------
-- Getter functions --
----------------------
-- Get the value of a line meter
-- @param self pointer to a line meter object
-- @return the value of the line meter
function Value (Self : Instance) return Int16_T;
-- Get the minimum value of a line meter
-- @param self pointer to a line meter object
-- @return the minimum value of the line meter
function Min_Value (Self : Instance) return Int16_T;
-- Get the maximum value of a line meter
-- @param self pointer to a line meter object
-- @return the maximum value of the line meter
function Max_Value (Self : Instance) return Int16_T;
-- Get the scale number of a line meter
-- @param self pointer to a line meter object
-- @return number of the scale units
function Line_Count (Self : Instance) return Uint8_T;
-- Get the scale angle of a line meter
-- @param self pointer to a line meter object
-- @return angle of the scale
function Scale_Angle (Self : Instance) return Uint16_T;
-- Get the style of a line meter
-- @param self pointer to a line meter object
-- @return pointer to the line meter's style
function Style (Self : Instance) return access Lv.Style.Style;
-------------
-- Imports --
-------------
pragma Import (C, Create, "lv_lmeter_create");
pragma Import (C, Set_Value, "lv_lmeter_set_value");
pragma Import (C, Set_Range, "lv_lmeter_set_range");
pragma Import (C, Set_Scale, "lv_lmeter_set_scale");
pragma Import (C, Set_Style, "lv_lmeter_set_style_inline");
pragma Import (C, Value, "lv_lmeter_get_value");
pragma Import (C, Min_Value, "lv_lmeter_get_min_value");
pragma Import (C, Max_Value, "lv_lmeter_get_max_value");
pragma Import (C, Line_Count, "lv_lmeter_get_line_count");
pragma Import (C, Scale_Angle, "lv_lmeter_get_scale_angle");
pragma Import (C, Style, "lv_lmeter_get_style_inline");
end Lv.Objx.Lmeter;
|
libsrc/stdio_new/error/stdio_error_zc.asm | andydansby/z88dk-mk2 | 1 | 165531 | ; stdio_error_zc
; 06.2008 aralbrec
XLIB stdio_error_zc
pop hl
.stdio_error_zc
ld hl,0
scf
ret
|
runtime/ravenscar-sfp-stm32f427/gnarl-common/s-multip.ads | TUM-EI-RCS/StratoX | 12 | 3314 | <reponame>TUM-EI-RCS/StratoX<filename>runtime/ravenscar-sfp-stm32f427/gnarl-common/s-multip.ads<gh_stars>10-100
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . M U L T I P R O C E S S O R S --
-- --
-- S p e c --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. In accordance with the copyright of that document, you can freely --
-- copy and modify this specification, provided that if you redistribute a --
-- modified version, any changes that you have made are clearly indicated. --
-- --
------------------------------------------------------------------------------
with System.BB.Parameters;
package System.Multiprocessors
with SPARK_Mode => On is
pragma Preelaborate (Multiprocessors);
type CPU_Range is range 0 .. System.BB.Parameters.Max_Number_Of_CPUs;
subtype CPU is CPU_Range range 1 .. CPU_Range'Last;
Not_A_Specific_CPU : constant CPU_Range := 0;
function Number_Of_CPUs return CPU;
pragma Inline (Number_Of_CPUs);
-- Number of available CPUs
end System.Multiprocessors;
|
test/succeed/Issue655.agda | np/agda-git-experiment | 1 | 15662 | <reponame>np/agda-git-experiment<gh_stars>1-10
-- Andreas, 2012-07-31, issue reported by <NAME>
-- {-# OPTIONS -v tc:100 -v term:100 #-}
-- {-# OPTIONS -v tc.def.alias:20 #-}
-- {-# OPTIONS -v tc:0 -v term:0 #-}
module Issue655 where
-- import Common.Level -- this should not be necessary
module TypeAliases where
postulate A : Set
B = A → A
module Ex0 where
postulate
f : ∀ {A : Set} → A → A
yellow = f
boring : ∀ {A : Set} → A → A
boring = f
boring' = λ {A} → f {A}
module Ex1 where
postulate
A : Set
f : ∀ {x : A} → A
yellow = f
boring : ∀ {x : A} → A
boring {x} = f {x}
boring' = λ {x} → f {x}
module Ex2 where
postulate
A : Set
f : ∀ {B : Set} (x : B) {y : A} → A
a : A
yellow = f a
boring : ∀ {y : A} → A
boring {y} = f a {y}
boring' = λ {y} → f a {y}
-- no longer yellow...
|
programs/oeis/098/A098117.asm | neoneye/loda | 22 | 96747 | <reponame>neoneye/loda<gh_stars>10-100
; A098117: a(n) = 5^(prime(n) - 1) + 5^prime(n) - 1.
; 29,149,3749,93749,58593749,1464843749,915527343749,22888183593749,14305114746093749,223517417907714843749,5587935447692871093749,87311491370201110839843749,54569682106375694274902343749,1364242052659392356872558593749
seq $0,6005 ; The odd prime numbers together with 1.
mov $1,5
pow $1,$0
div $1,2
mul $1,24
div $1,1200
mul $1,120
add $1,29
mov $0,$1
|
source/oasis/program-elements-call_statements.ads | reznikmm/gela | 0 | 14266 | -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Elements.Statements;
with Program.Elements.Expressions;
with Program.Lexical_Elements;
with Program.Elements.Parameter_Associations;
package Program.Elements.Call_Statements is
pragma Pure (Program.Elements.Call_Statements);
type Call_Statement is
limited interface and Program.Elements.Statements.Statement;
type Call_Statement_Access is access all Call_Statement'Class
with Storage_Size => 0;
not overriding function Called_Name
(Self : Call_Statement)
return not null Program.Elements.Expressions.Expression_Access
is abstract;
not overriding function Parameters
(Self : Call_Statement)
return Program.Elements.Parameter_Associations
.Parameter_Association_Vector_Access is abstract;
type Call_Statement_Text is limited interface;
type Call_Statement_Text_Access is access all Call_Statement_Text'Class
with Storage_Size => 0;
not overriding function To_Call_Statement_Text
(Self : in out Call_Statement)
return Call_Statement_Text_Access is abstract;
not overriding function Left_Bracket_Token
(Self : Call_Statement_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Right_Bracket_Token
(Self : Call_Statement_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Semicolon_Token
(Self : Call_Statement_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Call_Statements;
|
test/interaction/empty.agda | shlevy/agda | 1,989 | 14131 | primitive
abstract
postulate
private
mutual
macro
variable
instance
record F : Set where
field
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.