��������-����������� ����� �� ���������

����� �������� ���������� ����� �������� �������� � ��������� ���� �������. ���� ����� �������� ����� ������������� �, � ����������� �� ����� �������������, ����� ����� ������ ��������, �������� ������� ��������� ��� ��������� ���������. �������� ���� ������������� �������� ����������� ����� � ����� ���� �����������.
������� id/st ���������� SPARC, ������������ � ������� 2.2, ��������� ��������-����������� ��������� � 13-��������� ���������.
��������� �������� ������������� ����� ������ ��������� �������������. ��������, ���� �������� ������������ ����� ���������� ����� ������ �������, � � �������� �������� ������, ���� ����� ����� �������������� ��� ���������� �������. � ���� ������ �������� ������ ������������ ����� ����������� �����.
3 ������ ������, � �������� ����� ��������� ��������� �� ��������� ������, � �������� ����� �������� �������� ����������� ���� ������������ ������ ���������. ��� ���� ������� -- ������� ������ ��������� �� �������� ���� ��� ���� ���������� ���������, � �������� -����� ��������� ���������� � ���� ����� ��� ������������� ���������.
� ���� ������� ����� ������������ (� ������ ������������) ����������� ��������.

�������� ����

�������� ���� �������� ����������� �������� ��������� ������ ��� ��������� ���������� � �������������� ����������� ������ (�, C++, Pascal) � ������ ������, ����������� ����������� ������.
��������� ������������ ������ � �������������� ������ �������, ����� ������ �� ���������� ��������� �������� ����� ����������� ����� ��������� ����������. � SPARC ��� ����������� ������� ������������ ���� �� ������������ ����� (���. 2.9), �� ����������� ������ ����������� ����� ������� ������ � ��������� �������� ������ ��� ��������� ���������� � �����, ����������� � ���.

���. 2.9. ����������� ���� ���������� SPARC

��� ����� ��������� ��������� ��������� (���� ���� ������ ����) ��������� ����� �� ���������� ������, �����������, ����� ���������� ����������. ��������� ���� ���������� � ��������� ����������� (��������, � PDP-11) ���������� ������������ ��������� �����, � � ����������� � ��������, � ��680�� � VAX, � ������� ����������� ��������� ��� � �86, ��������� ����� �������� ������ ������������ ��� ��������� �� ��������� � ��� ���� ���� ���������� ��������� ������� (���. 2.10, ������ 2.4).

������ 2.4. ������������, ������������� � ����������� ��������� �����. ��� �� ����� � � ��������� ��� ��������� GNU � 2.7.2.1 (����������� ������)

#include <stdio.h>
# include <strings.h>

/* �������� ����������� ���������� ������� SMTP (RFC822) */
int parse_line(FILE * socket)
{
/* �������� RFC822, ������� ����� ����� �� ����� 4 ����,� ��� ������ � �� ����� 255 ���� V char cmd[5], args [255]; fscanf (socket, "%s %s\n", cmd, args);
if (stricmpfcmd, "HELO")==0) {
fprintf (socket, "200 Hello, %s, glad to meet you\n", args);
return 200;
)
/* etc */
fprintf (socket, "500 Unknown command %s\n", cmd);
return 500;
.file "sample" gcc2_compiled. : _ gnu_compiled_c : .text LCO:
.ascii "%s %s\12\0" LCI:
.ascii "HELCAO" LC2:
.ascii "200 Hello, %s, glad to meet you\12\0" LC3:
.ascii "500 Unknown command %s\12\0"
.align 2, 0x90 .globl _parse_line _parse_line:
; x86 ����� ��� ���� ���� ����������� ������� enter, �� ��� ����� ; ����������� ����� �������� �� ����� 255 ����. � ������ ������ ���� ; ����� ������� ������, � ��� ���������� ����������� �������.
pushl %ebp ; ��������� ��������� �����
; ��������� ��� ������������.
movl %esp, %ebp ; ��������� ��������� ������ �����
subl $264,%esp ; � ��� ����. ; ����� ������� �������
leal -264 (%ebp) , %��� ; �������� � ���� ��������� �� args � pushl %eax
leal -8 (%ebp) , %��� ; ... �� cmd
pushl %eax
pushl $LCO ; �� ��������� ���������
; ���� ����������� ��������� ���� ���������� ������������ �����. movl 8(%ebp),%eax ; �������� socket �� ���� ������������ pushl %eax ; � ����
call fscanf ; ����� (��������� � �����) addl $16,%esp ; ������� ����
; � ����� � ���������� ���������� ����������, ������� �������� �� ��
; ����� ������ ���������� ���������. ���������� ������ �� �����,
; ������� �� ����.
pushl $LC1
leal -8(%ebp),%eax
pushl %eax
call _stricmp
addl $8,%esp
movl %eax,%eax ; ����������� ����������� � �������� :)
; � ���� �������� �������, ����� ����������� ������ ����� � ����� ; ������������.
testl %eax,%���
jne L14
leal -264(%ebp),%���
pushl %eax
pushl $LC2
movl 8(%ebp),%eax
pushl %eax
call _fprintf
addl $12,%esp
; �������� ��������, ��� ���������� �� ���� ������������ ������ ������ ; ������� �� ������ ��������� return.
movl $200,%eax
jmp L13
� ������������ ������������� ����� �������� �� ������� ����� �������: � ��������� �� ����� ������� �������������� ���� ���� �� ������ � ������������� �������. ��� ������������ ������������ ������� NOP ; (��� �������� 0x90).
align 2,0x90 L14:
leal -8(%ebp),%���
Pushl %eax
Pushl $LC3
movl 8(%ebp),%eax pushl %eax
call _fprintf
addl ?12,%esp
movl $500,%eax
jmp L13
.align 2,0x90 L13:
; ������� leave ��������� ��������, �������� ������� �������: ; ��� ������������ ��������: move %ebp, %esp; pop %ebp. ; ������ ����� ����� ������� �� �����������, ������� ����������� ; �� ���� ������ � ������ ������ ���.
leave
ret

���. 2.10. �������� ����

����������
�������� ��������, ��� ��������� �� ������� 2.4 �������� ������������ ������. � ������������ �������, ��� ������� ������� ����� ����� �� ����� 4 ����, � ��� ������ ������ � ����������� �� ����� 255. ���� ���������-������ �� ������ ����� ������ (�������� ����������) ������������� RFC822 [RFC822], ��� ��� � �����. �� ���� ��������� ����������� ����� ��������� �� �������������, ��� ���� ����: ��� ����� ���������� ����� ������� ������� �/��� ����� ������� ������. �����������, � ������� ��� ����� ��������, ����� ����� �������� ����������� � ����� 12.

�� �������� � �������� ������.

�������� ����� � ������� ������ SPARC
��������������� SPARC ����� �� ����� �������� ��� ��������� �����. ��-������, �� ������ ��������� ���������� ��������� ���������� � ������ 32-��������� ��������� ���������. ������ ����� ��������� ��������� � ������� 2.4. ��-������, ������� ��������, ����� � �������� ���������� ���� �������� �� �������� ���������, ��� ������� 6 ���������-���������� ���� �� ������. �-�������, ������� ������������ ����� ���������� � ��� ������ ����������� ��� ������ ������� ��������� �������� ����� �����������. �-���������, � ������������� ������� ����������� ���� ����� ������������ �������������� ����������� ��������. ��� ��� �������� �������� ��� ������ �������� ��������� ����� [www.sparc.com v9].
��� ���� ���� ������������ �������� Isp (�6) � %fp (i6). ������� save %sp, -96 %sp ������ ���������: ��� ���������� ������ ��� ��������, �������� �������� ���� � �������� ��������� �������� � ������ �������. ��������� ������ ������� ���������� ��������� ��������, ������ %sp ���������� %fp, � ��������� �������� ���������� ��� � ����� %sp.
����� ������ ���� �������� ����� ������ ��� ��������� ������������ ������������ �����. ����������� ���� SPARC ������������ ����� ��������� �����, ����������� ��������� �������� �������� ����������� ������������������ ���������� CANSAVE � CANRESTORE. ����, ����������� ����� ���������� ���� ���� ���������, �������� ������� ��������� (���. 2.11). �� ������� �������� ��������� ������������ �����, � ������� ������� ������� ����� ������������ ���� �������� ���� (CANRESTORE=1) � ��������� ��� (CANSAVE=3). ������� OTHERWIN ��������� ���������� ����������� ����, ������� ������ ���������. ����������� ���� w4 �� ������� (������������ ��� ����������) ������ ���� ��������. ������� ����, �������� ������� ���� � ������� ������������ �����, ��������� �������������� ����������, � ����� ������ ���������� ���� ����������� ����, ��� ����� ����������� ��������� CANSAVE + CANRESTORE + OTHERWIN = NWINDOWS - 2, ��� NWINDOWS- ���������� ���� (�� ������� ����������� ���� ����� 8 ����, �. �. 128 ���������).

���. 2.11. ����������� ���� SPARC � ���� ���������� ������. �������� CANSAVE � CANRESTORE (���. �� [www.sparc.com v9])

����� �� ��������� �������� �������� ���� ���� �� ��������� ������� (� ��������, ������������ �� ��� 2.11 ��� ����� ��������� ����� ������� ������� ��������� �������� ��� ����� �������� �� ���� �������� � ������� � ��������������� ���� w7), ������������ �������������� ��������� ���������� ���� (window fill) � ������ ���� (window spill). ��� ���� ���������� ��������� ���������, ������� ����������� ���� �� ��������� OTHERWIN, ��������� �� ���������� � �������� ����� ��������������� �������� � ��� ���������� ��������������� ���������� �������������� ��� ���� �� ���������������� �����.
� ������������� ������� ���������� � ����� ���� ����� ��������� � ����� ������, ������� ���������������� ��������� ������ ������ ����� �� ��������� ����� �� ������ �� ������������ �� ����������� ����, � ��������� �� ���� ���� ������ ������ ������ � %sp ���������������� ����. ��� ���� ����� �����, ����� �������� ��������� ����� � ����� ������������ ���� ������������� ����� ��������.