EMIT: различия между версиями
AtH (обсуждение | вклад) Нет описания правки |
AtH (обсуждение | вклад) |
||
Строка 129: | Строка 129: | ||
JMP TYPE$ | JMP TYPE$ | ||
ERMES4: DB ' PRINTER ERROR $' | ERMES4: DB ' PRINTER ERROR $' | ||
</PRE> | |||
=== colorForth (cf2019.nasm 2019 Sep 14) === | |||
<PRE> | |||
clip1: | |||
mov edi, [ v_xy ] | |||
mov ecx, edi | |||
test cx, cx | |||
jns .forward | |||
xor ecx, ecx | |||
.forward: | |||
and ecx, 0x0000FFFF | |||
mov [ v_yc ], ecx | |||
imul ecx, ( scrnw1 * BYTES_PER_PIXEL ) | |||
sar edi, 16 | |||
jns .forward2 | |||
xor edi, edi | |||
.forward2: | |||
mov [ v_xc ], edi | |||
lea edi, [ edi * BYTES_PER_PIXEL + ecx ] | |||
add edi, [ vframe ] | |||
ret | |||
bit16: ; write a 16 x 24 glyph to the graphic screen | |||
lodsw ; load the 16 bit value pointed to by SI into ax | |||
xchg al, ah ; eax_TOS_ | |||
.back: | |||
shl ax, 0x01 ; eax_TOS_ | |||
jnc .forward | |||
mov [ edi ], dx ; | |||
jmp .forward2 | |||
.forward: | |||
ror edx, 0x10 ; use the background colour, in the high 16 bits | |||
; mov [ edi ], dx ; | |||
ror edx, 0x10 ; return to the foreground colour, in the low 16 bits | |||
.forward2: | |||
add edi, byte BYTES_PER_PIXEL | |||
loop .back | |||
ret | |||
; write the background after the glyph | |||
bit16Background: ; number of pixels to write in ecx , screen address in edi , colours in edx | |||
ror edx, 0x10 ; use the background colour, in the high 16 bits | |||
.back: | |||
; mov [ edi ], dx ; | |||
add edi, byte BYTES_PER_PIXEL | |||
loop .back | |||
ror edx, 0x10 ; return to the foreground colour, in the low 16 bits | |||
ret | |||
… | |||
emit1: ; ( c -- ) \ display a single width and height character | |||
call qcr | |||
push esi | |||
push edi | |||
push edx | |||
imul _TOS_, byte 16*24/8 | |||
lea esi, [ _TOS_ + font16x24 ] | |||
call clip1 | |||
mov edx, [ v_foregroundColour ] | |||
mov ecx, 0x18 ; 24 lines | |||
.back: | |||
push ecx | |||
mov ecx, 0x10 | |||
call bit16 | |||
mov ecx, 0x04 | |||
push edi | |||
call bit16Background | |||
pop edi | |||
pop ecx | |||
add edi, ( scrnw1 - 16 ) * BYTES_PER_PIXEL ; address of the next line of the glyph | |||
loop .back ; next horizontal line | |||
mov ecx, 0x04 ; 4 background lines | |||
.back2: | |||
push ecx | |||
mov ecx, 0x10 | |||
call bit16Background | |||
mov ecx, 0x04 | |||
push edi | |||
call bit16Background | |||
pop edi | |||
pop ecx | |||
add edi, ( scrnw1 - 16 ) * BYTES_PER_PIXEL ; address of the next line of the glyph | |||
loop .back2 ; next horizontal line | |||
pop edx | |||
pop edi | |||
pop esi | |||
_DROP_ | |||
space1: | |||
add dword [ v_xy ], iconw1 * 0x10000 ; 22 horizontal pixels | |||
ret | |||
… | |||
clip2: | |||
mov edi, [ v_xy ] | |||
mov ecx, edi | |||
test cx, cx | |||
jns .forward | |||
xor ecx, ecx | |||
.forward: | |||
and ecx, 0x0000FFFF | |||
mov [ v_yc ], ecx | |||
imul ecx, ( scrnw2 * BYTES_PER_PIXEL ) | |||
sar edi, 16 | |||
jns .forward2 | |||
xor edi, edi | |||
.forward2: | |||
mov [ v_xc ], edi | |||
lea edi, [ edi * BYTES_PER_PIXEL + ecx ] | |||
add edi, [ vframe ] | |||
ret | |||
emit2: ; ( c -- ) \ display a single width and height character | |||
call qcr | |||
push esi | |||
push edi | |||
push edx | |||
imul _TOS_, byte 16*24/8 | |||
lea esi, [ _TOS_ + font16x24 ] | |||
call clip2 | |||
mov edx, [ v_foregroundColour ] | |||
mov ecx, 0x18 ; 24 lines | |||
.back: | |||
push ecx | |||
mov ecx, 0x10 | |||
call bit16 | |||
mov ecx, 0x04 | |||
push edi | |||
call bit16Background | |||
pop edi | |||
pop ecx | |||
add edi, ( scrnw2 - 16 ) * BYTES_PER_PIXEL ; address of the next line of the glyph | |||
loop .back ; next horizontal line | |||
mov ecx, 0x04 ; 4 background lines | |||
.back2: | |||
push ecx | |||
mov ecx, 0x10 | |||
call bit16Background | |||
mov ecx, 0x04 | |||
push edi | |||
call bit16Background | |||
pop edi | |||
pop ecx | |||
add edi, ( scrnw2 - 16 ) * BYTES_PER_PIXEL ; address of the next line of the glyph | |||
loop .back2 ; next horizontal line | |||
pop edx | |||
pop edi | |||
pop esi | |||
_DROP_ | |||
space2: | |||
add dword [ v_xy ], iconw2 * 0x10000 ; 22 horizontal pixels | |||
ret | |||
… | |||
emit_: | |||
cmp byte [ displayMode ], 0 | |||
jz emit1 | |||
jmp emit2 | |||
</PRE> | </PRE> | ||
Текущая версия от 18:49, 30 июня 2021
EMIT (испустить, выдать) — стандартное слово Каллисто.
EMIT ( c −− ) Отобразить литеру.
Отображает на индикаторе литеру, код которой находится в стеке.
Ввод слова EMIT[править]
В режиме ЛАТ последовательно нажмите четыре клавиши ИП ÷ 7 2
EMIT в стандарте ANS Forth[править]
6.1.1320 EMIT CORE ( x -- ) Если x - графический символ в наборе символов определенном реализацией - показать x. Эффект EMIT для всех других значений x - определенное реализацией. Когда просматривается символ, чьи символом-определенные биты имеют значение между hex 20 и 7E включительно, отображается соответствующий стандартный символ, определенный 3.1.2.1 Графические символы. Поскольку различные устройства вывода могут реагировать по-разному на управляющие символы, программы, использующие управляющие символы для выполнения специфических функций, имеют зависимость от окружения. Каждый EMIT, имеет дело только с одним символом. См.: 6.1.2310 TYPE.
История[править]
Слово EMIT является одним из наиболее старых и устоявшихся слов Форта.
EMIT появился в Форте в 1965 году, когда Чак Мур подрабатывал наёмным программистом в городе Нью-Йорк. Тогда появились миникомпьютеры, а с ними и терминалы. Интерпретатор был идеален для ввода с телетайпа и вскоре стал включать код для работы с выводом.
Слово TYPE появилось, как цикл, вызывающий EMIT для отображения символов. В Каллисто TYPE работает быстрее, т.к обновляет экран после вывода всей строки, а EMIT — после каждого символа.
В MMSFORTH слово EMIT называлось ECHO
EMIT в предыдущем стандарте Forth-83 (англ.)[править]
EMIT 16b -- M,83 The least-significant 7-bit ASCII character is displayed. SEE: "9.5.3 EMIT" 9.5.3 EMIT Because of the potential non-transportable action by terminal devices of control characters, the use of ASCII control characters is an environmental dependency. Each EMIT deals with only one ASCII character. The ASCII character occupies the least-significant 7 bits; the more-significant bits may be environmentally dependent. Using the more-significant bits when other than zero is an environmentally dependent usage. EMIT must display as many bits as can be sent.
EMIT в стандарте Forth-79 (англ.)[править]
EMIT char -- 207 Transmit character to the current output device.
EMIT в fig-FORTH Release 1 glossary, май 1979 (англ.)[править]
EMIT c --- L0 Transmit ascii character c to the selected output device. OUT is incremented for each character output.
Реализация[править]
984 ;#EMIT 985 ; EMIT ( c −− ) Отобразить литеру. 986 LEMIT: .DB 4 987 .TEXT "EMIT" 988 .DW LEMI 989 EMIT: .DW JEMIT 990 JEMIT: PKRM03 PGSB CHPUT ; Отобразить на экране литеру, код которого находится в стеке. 991 PGOTO CHPUTC3 … 1000 CHPUTC3: KGRPH 1001 PGOTO JDROP … 2052 JDROP: 1 ; Да, это обработчик DROP 2053 NDROP: RM3 + M3 ; А сюда сваливается 2DROP 2054 KGOTO9
Реализация из SP-Forth 4.20:
: EMIT ( x -- ) \ 94 \ Если x - изображаемый символ, вывести его на дисплей. \ Программы, использующие управляющие символы, зависят от окружения. >R RP@ 1 TYPE RDROP ;
Советская реализация[править]
Слово EMIT в ФОРТ-ЕС и FORTH ИТЭФ также было примитивом. Вот его описание и опубликованная часть определения из ядра ФОРТ-ЕС:
EMIT С-> ВЫВЕСТИ НА ТЕРМИНАЛ ЛИТЕРУ С КОДОМ C 6 Экран номер 6 ( 09.09.86 KEY CR EMIT TYPE (EXPECT/ RBLK MBLK ) ( следующие определения дают только имена процедур) CODE EMIT ( С-> ВЫВЕСТИ ЛИТЕРУ С КОДОМ С НА ТЕРМИНАЛ) END-CODE
Определение слова EMIT в FORTH ИТЭФ:
OK: NEXT HEAD 204Q,'EMI',324Q,EMIT,$EMIT ; EMIT $EMIT LABEL FAR POP AX ENT$: PUSH AX MOV AH, 15 INT 16 POP AX MOV AH, 14 JMP $EM PRINT: MOV DX, 0 ; Установка номера принтера SUB AH, AH INT 23 TES AH, 51Q JE OK ERR4: MOV AL, AH ADD AL, 60Q MOV AH, 14 INT 16 MOV DX, OFFSET ERMES4 MOV AH, 9H INT 21H JMP TYPE$ ERMES4: DB ' PRINTER ERROR $'
colorForth (cf2019.nasm 2019 Sep 14)[править]
clip1: mov edi, [ v_xy ] mov ecx, edi test cx, cx jns .forward xor ecx, ecx .forward: and ecx, 0x0000FFFF mov [ v_yc ], ecx imul ecx, ( scrnw1 * BYTES_PER_PIXEL ) sar edi, 16 jns .forward2 xor edi, edi .forward2: mov [ v_xc ], edi lea edi, [ edi * BYTES_PER_PIXEL + ecx ] add edi, [ vframe ] ret bit16: ; write a 16 x 24 glyph to the graphic screen lodsw ; load the 16 bit value pointed to by SI into ax xchg al, ah ; eax_TOS_ .back: shl ax, 0x01 ; eax_TOS_ jnc .forward mov [ edi ], dx ; jmp .forward2 .forward: ror edx, 0x10 ; use the background colour, in the high 16 bits ; mov [ edi ], dx ; ror edx, 0x10 ; return to the foreground colour, in the low 16 bits .forward2: add edi, byte BYTES_PER_PIXEL loop .back ret ; write the background after the glyph bit16Background: ; number of pixels to write in ecx , screen address in edi , colours in edx ror edx, 0x10 ; use the background colour, in the high 16 bits .back: ; mov [ edi ], dx ; add edi, byte BYTES_PER_PIXEL loop .back ror edx, 0x10 ; return to the foreground colour, in the low 16 bits ret … emit1: ; ( c -- ) \ display a single width and height character call qcr push esi push edi push edx imul _TOS_, byte 16*24/8 lea esi, [ _TOS_ + font16x24 ] call clip1 mov edx, [ v_foregroundColour ] mov ecx, 0x18 ; 24 lines .back: push ecx mov ecx, 0x10 call bit16 mov ecx, 0x04 push edi call bit16Background pop edi pop ecx add edi, ( scrnw1 - 16 ) * BYTES_PER_PIXEL ; address of the next line of the glyph loop .back ; next horizontal line mov ecx, 0x04 ; 4 background lines .back2: push ecx mov ecx, 0x10 call bit16Background mov ecx, 0x04 push edi call bit16Background pop edi pop ecx add edi, ( scrnw1 - 16 ) * BYTES_PER_PIXEL ; address of the next line of the glyph loop .back2 ; next horizontal line pop edx pop edi pop esi _DROP_ space1: add dword [ v_xy ], iconw1 * 0x10000 ; 22 horizontal pixels ret … clip2: mov edi, [ v_xy ] mov ecx, edi test cx, cx jns .forward xor ecx, ecx .forward: and ecx, 0x0000FFFF mov [ v_yc ], ecx imul ecx, ( scrnw2 * BYTES_PER_PIXEL ) sar edi, 16 jns .forward2 xor edi, edi .forward2: mov [ v_xc ], edi lea edi, [ edi * BYTES_PER_PIXEL + ecx ] add edi, [ vframe ] ret emit2: ; ( c -- ) \ display a single width and height character call qcr push esi push edi push edx imul _TOS_, byte 16*24/8 lea esi, [ _TOS_ + font16x24 ] call clip2 mov edx, [ v_foregroundColour ] mov ecx, 0x18 ; 24 lines .back: push ecx mov ecx, 0x10 call bit16 mov ecx, 0x04 push edi call bit16Background pop edi pop ecx add edi, ( scrnw2 - 16 ) * BYTES_PER_PIXEL ; address of the next line of the glyph loop .back ; next horizontal line mov ecx, 0x04 ; 4 background lines .back2: push ecx mov ecx, 0x10 call bit16Background mov ecx, 0x04 push edi call bit16Background pop edi pop ecx add edi, ( scrnw2 - 16 ) * BYTES_PER_PIXEL ; address of the next line of the glyph loop .back2 ; next horizontal line pop edx pop edi pop esi _DROP_ space2: add dword [ v_xy ], iconw2 * 0x10000 ; 22 horizontal pixels ret … emit_: cmp byte [ displayMode ], 0 jz emit1 jmp emit2
Ссылки[править]
- Исходный текст слова EMIT в Каллисто Классик 1.0
- См. слова SPACE, ↵ и ↖
- Слово EMIT в стандарте ANS Forth (англ.)
- Слово EMIT в черновике Forth 200x (англ.)
- ОСНОВЫ ФОРТА, ЧИСЛО ТИПОВ ЧИСЕЛ и ВВОД-ВЫВОД в книге Л.Броуди «Начальный курс программирования на языке Форт»
- Fundamental Forth, A Number of Kinds of Numbers и I/O and You в книге Leo Brodie Starting Forth (англ.)
Это заготовка статьи. Вы можете помочь проекту, дополнив её. |