/programs/develop/archer/trunk/@RCHER.ASM |
---|
0,0 → 1,424 |
; @RCHER - DEflate unpacker v1.0 |
; |
; Written in pure assembler by Ivushkin Andrey aka Willow |
; |
; Created: May 6, 2005 |
; |
; Last changed: July 14, 2005 |
; |
; Compile with FASM |
SYS equ meos |
PARAM_PTR equ png_image |
DUMPFILE equ '/hd/1/out.txt' |
SHOW_RBLOCK equ 0;1 |
SHOW_PNG_SEC equ 0;1 |
SHOW_METH equ 0;1 |
FILE_NUM equ 0 |
MEMORY equ 0x800000 |
BITS equ 16 |
BUFSIZE equ 32 |
BUFPTR equ area |
PASSW_LEN equ 32 |
NO_STOPS equ 1 |
SHOW_CHARS equ 0 |
BSIZE equ 512 |
INBUF equ BUFSIZE*BSIZE*2 |
OUTBUF equ 4*1024*1024 |
IGNORE_DIRS equ 0 |
MOVE_SLINE_LEV equ 8 |
DECRYPT_MODE equ 100b |
PNG_MODE equ 10b |
TAR_MODE equ 1000b |
STAY_MODE equ 10000b |
IPC_MODE equ 100000b |
RAW_MODE equ 1000000b |
THREAD_YES equ 10000000b |
if SYS eq win |
format PE console |
entry start |
;match =win,SYS |
;{ |
; include 'D:\Ivushkin\projects\fasmw\INCLUDE\win32a.inc' |
;} |
else |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd start |
dd I_END |
dd MEMORY |
dd MEMORY-2048 |
if PARAM_PTR eq param |
dd 0 |
else |
dd PARAM_PTR |
end if |
dd 0x0 |
include "lang.inc" |
if PARAM_PTR eq param |
param db 'RQ' |
db '000037' |
db '/hd/1/zip/png.zip',0 |
end if |
;match =meos,SYS |
;{ |
include "macros.inc" |
; purge mov |
include "debug.inc" |
;} |
end if |
language equ en |
if SYS eq win |
section '.text' code readable executable writeable |
end if |
include "arcmacro.inc" |
include "parser.inc" |
include "deflate.inc" |
include "sys.inc" |
FileNum dd FILE_NUM |
;FNAME equ '/hd/1/zip/pngsuite/s01n3p01.png' |
start: |
if SYS eq win |
invoke GetStdHandle, STD_OUTPUT_HANDLE |
mov [cons],eax |
invoke GetStdHandle, STD_INPUT_HANDLE |
mov [cons_in],eax |
Msg 0 |
Msg 1 |
else |
Msg 0 |
Msg 1 |
mcall 40,10000101b |
; jmp again |
CmdLine |
red: |
call draw_window |
mcall 12,2 |
still: |
mcall 10 |
cmp eax,1 |
je red |
cmp eax,2 |
jne .nokey |
mcall 2 |
cmp ah,9 |
jz quit |
jmp still |
.nokey: |
cmp eax,3 |
jne still |
mcall 17 |
cmp ah,1 |
jne still |
mcall 23,30 |
cmp eax,3 |
jne .noquit |
call KillViewer |
mcall -1 |
.noquit: |
mcall 17 |
QueryFile |
and [FileNum],0 |
test eax,eax |
jnz still |
end if |
again: |
Newline |
xor eax,eax |
; and [Flags],STAY_MODE |
and [CRC32],eax |
and [IDATsize],eax |
mov [Adler32],1 |
call OpenFile |
test ebx,ebx |
jnz .sizeok2 |
.sizebad2: |
Msg 14 |
jmp quit |
.sizeok2: |
mov [filesize],ebx |
test [Flags],RAW_MODE |
jz .norawm |
mov eax,[arc_base] |
xor ebx,ebx |
call FileSeek |
jmp .sizeok |
.norawm: |
call SfxParse |
call ZipParse |
cmp edx,52 |
je .notzip |
mov ecx,[FileNum] |
call ZipFindN |
cmp edx,4 |
je quit |
test [Flags],DECRYPT_MODE |
jz .nopass |
call ZipDecrypt |
push esi |
mov ecx,31 |
._: |
mov al,[esi] |
push eax |
call decrypt_byte |
xor al,byte[esp] |
add esp,4 |
call UKeys |
mov [esi],al |
inc esi |
loop ._ |
pop esi |
ud2 |
.nopass: |
cmp [unp_size],0 |
jne .sizeok |
.sizebadq: |
Msg 13 |
jmp quit |
.notzip: |
call GzipParse |
test edx,edx |
jne .notgzip |
jmp .sizeok |
.notgzip: |
call PngParse |
test edx,edx |
jz .sizeok1 |
cmp edx,21 |
je .sizebad |
test [Flags],RAW_MODE |
jne .sizeok |
Msg 40 |
jmp exit |
.sizebad: |
Msg 17 |
jmp exit |
.sizeok1: |
if ~ SYS eq win |
call KillViewer |
end if |
Msg 39 |
mov edi,[outp] |
call Deflate.blkbegin |
jmp .defl_end |
.sizeok: |
call Deflate ; <=========== |
.defl_end: |
test [bits],7 |
jnz .esi_ok |
dec esi |
.esi_ok: |
push dword[esi] ; <- Adler !!! |
mov esi,output |
sub edi,esi |
mov ecx,edi |
mov [outfile.size],ecx |
test [Flags],RAW_MODE |
jnz .skipAdler |
test [Flags],PNG_MODE |
jnz .skipCRC |
push esi ecx |
call UCRC |
Msg 11 |
mov eax,[CRC32] |
mov edx,36 |
cmp eax,[CRC_check] |
je .crcok |
dec edx |
.crcok: |
Msg edx |
if SYS eq win |
else |
dph eax |
end if |
pop ecx esi |
jmp .skipAdler |
.skipCRC: |
call UAdler |
Msg 10 |
mov eax,[Adler32] |
bswap eax ; <- calculated Adler !!! |
mov edx,36 |
cmp eax,[esp] |
je .adlok |
dec edx |
.adlok: |
Msg edx |
if SYS eq win |
else |
dph eax |
end if |
.skipAdler: |
pop eax |
Newline |
.nomoreIDAT: |
mov ebx,output |
if SYS eq win |
Msg 37 |
invoke CloseHandle, [hnd] |
invoke CreateFile,dumpfile,GENERIC_WRITE, FILE_SHARE_WRITE, NULL, \ |
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL |
mov [hnd],eax |
invoke WriteFile, eax,ebx,[outfile.size],cparam1,NULL |
invoke CloseHandle, [hnd] |
else |
test [Flags],PNG_MODE |
jnz .nosave |
test [Flags],TAR_MODE |
jnz .nomsg |
Msg 37 |
.nomsg: |
mov [outfile.out],ebx |
mcall 58,outfile |
test [Flags],TAR_MODE |
jnz .nosave |
call StartPad |
.nosave: |
end if |
test [Flags],PNG_MODE |
jz NoPng |
xor eax,eax |
mov edi,filters |
mov ecx,6 |
rep stosd |
mov edi,png_image |
mov esi,output |
;// |
mov [outp],edi |
;// |
call PngFilter |
call FiltStats |
mov [outfile.size],edi |
mov ebx,[outp];png_image |
if SYS eq win |
exit: |
Msg 12 |
invoke CreateFile,outfile,GENERIC_WRITE, FILE_SHARE_WRITE, NULL, \ |
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL |
mov [hnd],eax |
invoke WriteFile, eax,ebx,[outfile.size],cparam1,NULL |
invoke CloseHandle, [hnd] |
call RunViewer |
and [arc_base],0 |
and [Flags],STAY_MODE |
quit: |
QueryFile |
test eax,eax |
jnz again |
invoke ExitProcess,0 |
else |
exit: |
mov [outfile.out],ebx |
test [Flags],TAR_MODE |
jz .notar |
Msg 37 |
mcall 58,outfile |
call StartPad |
.notar: |
Msg 12 |
call RunViewer |
and [arc_base],0 |
and [Flags],STAY_MODE |
quit: |
test [Flags],STAY_MODE |
jnz red |
mcall -1 |
end if |
NoPng: |
test [Flags],TAR_MODE |
if SYS eq win |
jz quit |
else |
jz still |
end if |
mov ecx,dumpf_len |
mov esi,dumpfile |
mov edi,filename |
rep movsb |
call OpenFile |
test ebx,ebx |
jz again.sizebadq |
call TarParse |
mov ecx,[FileNum] |
call TarFindN |
cmp [outfile.size],0 |
jz again.sizebadq |
mov ebx,esi |
jmp exit |
if ~ SYS eq win |
draw_window: |
mcall 12,1 |
mov ebx,15 |
mov ecx,ebx |
mov edx,0x0e26830 |
mov edi,edx |
mcall 0,,,,0x1f2a870 |
mcall 8,,,1+1 shl 30 |
mcall 4,<6,5>,0x10d0d0d0,msgs+5,1 |
mcall ,<5,5>,0x10202020 |
ret |
end if |
include 'data.inc' |
if SYS eq win |
section '.idata' import data readable writeable |
library kernel,'KERNEL32.DLL',\ |
comdlg,'COMDLG32.DLL',\ |
user,'USER32.DLL' |
import kernel,\ |
CreateFile,'CreateFileA',\ |
GetFileSize,'GetFileSize',\ |
ReadFile,'ReadFile',\ |
WriteFile,'WriteFile',\ |
SetFilePointer,'SetFilePointer',\ |
CloseHandle,'CloseHandle',\ |
GetStdHandle,'GetStdHandle',\ |
WriteConsole,'WriteConsoleA',\ |
ReadConsole,'ReadConsoleA',\ |
CreateProcess,'CreateProcessA',\ |
WritePrivateProfileString,'WritePrivateProfileStringA',\ |
ExitProcess,'ExitProcess' |
import comdlg,\ |
GetOpenFileName,'GetOpenFileNameA' |
import user,\ |
wsprintf,'wsprintfA',\ |
SendMessage,'SendMessageA',\ |
FindWindowEx,'FindWindowExA',\ |
WaitForInputIdle,'WaitForInputIdle' |
section '.reloc' fixups data readable discardable |
end if |
if ~ SYS in <meos,win> |
error "Please specify SYS: meos OR win" |
end if |
/programs/develop/archer/trunk/archer.txt |
---|
0,0 → 1,176 |
@RCHER FOR MENUET v1.0 July 14, 2005 |
Written in pure assembler by Ivushkin Andrey aka Willow |
Deflate unpacker |
Vivat assembler et MENUETOS! |
I tender thanks to everyone who spends his time in feasible effortsfor that |
little OS evolution. Now in my own rating the Mario79's distro named Kolibri4 |
takes 1th place. It is always pleasant to use modern software. Go on! |
@RCHER is intended to view & unpack data compressed by Deflate method |
(including both static and dynamic Huffman). This method (although it isn't the |
best already) is used by such file formats as ZIP (modern versions: PKZIP for |
MS-DOS can create archives using other, less effective compression methods, |
which @RCHER doesn't support), GZIP, JAR, OpenOffice files, SFX ZIP executables |
and some others. I couldn't prevent myself to include support of PNG images |
(they use the similar compression) and TAR and TAR+GZIP archives. |
When the program is started, a little button carrying a @ symbol appears in the |
left top corner of screen. Clicking this button opens a SYSXTREE dialog to |
select a file being unpacked. Doubleclick closes the application. @RCHER |
outputs its information messages to Debug Board. If an archive contains more |
than one file, the 1st is by default unpacked into /HD/1/OUT.TXT (you may |
change the DUMPFILE constant in @RCHER.ASM) and is opened through TINYPAD |
or - if it's a PNG image - in the built-in viewer. |
These are unpacking flags that may exist in a commandline before an archive |
filename: |
s - do not close the program after unpacking; |
n - decompress the K-th archive file, where K is the following dword in |
commandline; |
N - decompress the K-th archive file, where K is ASCII number from the |
following 6 bytes of commandline; |
R - "raw" Deflate data, without descriptors and headers; |
q - begin file parsing from offset of K, where K is following dword in |
commandline; |
Q - begin file parsing from offset of K, where K is ASCII number from the |
following 6 bytes of commandline. |
Commandline example: |
cmd_string: |
db 'sN000037q' |
dd 1465 |
db '/hd/1/png.zip',0 |
It means to open the 34th (counting from 0) file of archive /hd/1/png.zip |
and do not terminate. Archive will be parsed starting at offset 1465. |
To-Do list: |
1. Support for interlaced PNG, alpha-channels, gamma-correction, background, |
Significant bits and a lot of cool parts of that format. |
2. Output of archive content through IPC or into a built-in window like SYSTREE |
(as we are going to decide with the respected colleagues). |
3. Searching of archive files by name and wildcards! |
4. Unpacking into a file specified. |
5. Means on saving memory space (now @RCHER gorges 8 Mb!): moving RAM areas, |
blocked file output. To do the last thing it is necessary to test carefully |
the reliability of harddisk I/O, directory creation and file deletion. These |
kernel capabilities aren't still documented. |
6. Archive contents integration into SYSXTREE & MFAR filemanagers. We have to |
unify the calling format (like a structure in the sysfunc 58). |
7. Add comments to source. |
8. Correct bugs to be found |
Special thanks to: |
Explanation of algorythm of Deflate format decoder with decoding samples |
(evm.narod.ru) |
RFC 1951 DEFLATE Compressed Data Format Specification version 1.3 |
ZIP File Format Specification version 4.5 by PKWARE Inc. |
"An Explanation of the Deflate Algorithm" by Antaeus Feldspar |
RFC 1952 GZIP file format specification version 4.3 |
TAR Format. Information from File Format List 2.0 by Max Maischein. |
RFC 1950 ZLIB Compressed Data Format Specification version 3.3 |
PNG (Portable Network Graphics) Specification version 1.0 |
Michael Dipperstein's Huffman Code Page |
I expect your remarks and suggestions on the @RCHER's topic, "Coding" section |
at meos.sysbin.com forum. |
See you later! |
**************************************** |
**************************************** |
@RCHER MENUET v1.0 14 ¨î«ï 2005 £. |
¯¨á ç¨á⮬ áᥬ¡«¥à¥ ¢ãèª¨ë¬ ¤à¥¥¬ (Willow) |
Deflate à ᯠª®¢é¨ª |
Vivat assembler et MenuetOS! |
ëà ¦ î ¨áªà¥îî ¡« £®¤ à®áâì ¢á¥¬ ⥬, ªâ® ¥ ¦ «¥ï ᢮¥£® ¢à¥¬¥¨, |
¤¥« ¥â ¯®á¨«ìë© ¢ª« ¤ ¢ à §¢¨â¨¥ í⮩ ¬ «¥ìª®© . ¥©ç á ¢ ¬®¥¬ ᮡá⢥®¬ |
३⨣¥ 1-¥ ¬¥áâ® § ¨¬ ¥â ¤¨áâਡã⨢ Mario79 Kolibri4. ᥣ¤ ¯à¨ïâ® |
¯®«ì§®¢ âìáï ᮢ६¥ë¬ . ª ¤¥à¦ âì! |
@RCHER ¯à¥¤ § ç¥ ¤«ï ¯à®á¬®âà ¨ à ᯠª®¢ª¨ ¤ ëå, ᦠâëå á ¯®¬®éìî ¬¥â®¤ |
Deflate (¢ª«îç ï áâ â¨ç¥áª¨© ¨ ¤¨ ¬¨ç¥áª¨© ää¬ ). ë¬ ¬¥â®¤®¬ (å®âï ® |
㦥 ¥ ¯à¥â¥¤ã¥â §¢ ¨¥ ¨«ãç襣®) ¯®«ì§ãîâáï ä®à¬ âë ä ©«®¢ ZIP |
(ᮢ६¥ë¥ ¢¥àᨨ: PKZIP ¤«ï MS-DOS ¬®¦¥â ᮧ¤ ¢ âì à娢ë á ¤à㣨¬¨, ¬¥¥¥ |
íä䥪⨢묨 ¬¥â®¤ ¬¨ ᦠâ¨ï, ª®â®àë¥ @RCHER ¥ ¯®¤¤¥à¦¨¢ ¥â), GZIP, JAR, |
ä ©«ë OpenOffice, SFX-ZIP ¯à¨«®¦¥¨ï ¨ àï¤ ¤à㣨å. ¥ ¬®£ 㤥ঠâìáï ¨ ¥ |
ᤥ« âì ¯®¤¤¥à¦ªã ¨§®¡à ¦¥¨© ¢ ä®à¬ ⥠PNG (¨á¯®«ì§ãîé¨å தáâ¢¥ë© ¬¥â®¤ |
ᦠâ¨ï) ¨ à娢®¢ TAR ¨ TAR+GZIP. |
ਠ§ ¯ã᪥ ¯à®£à ¬¬ë ¢ «¥¢®¬ ¢¥à奬 㣫ã íªà ¯®ï¢«ï¥âáï ¬ «¥ìª ï ª®¯ª |
á® § 窮¬ @. ਠ¦ ⨨ ¥¥ ®âªàë¢ ¥âáï ®ª® ¢ë¡®à ä ©« (SYSXTREE) ¤«ï |
à ᯠª®¢ª¨. ¢®©®© 饫箪 § ªàë¢ ¥â ¯à¨«®¦¥¨¥. ä®à¬ æ¨®ë¥ á®®¡é¥¨ï |
@RCHER ¢ë¢®¤¨â ¤®áªã ®â« ¤ª¨. ᫨ à娢 ᮤ¥à¦¨â ¥áª®«ìª® ä ©«®¢, ¯® |
㬮«ç ¨î ¯¥à¢ë© ¨§ ¨å à ᯠª®¢ë¢ ¥âáï /HD/1/OUT.TXT (¯®¬¥ï©â¥ ¯à¨ |
¥®¡å®¤¨¬®á⨠ª®áâ âã DUMPFILE ¢ @RCHER.ASM) ¨ ®âªàë¢ ¥âáï ç¥à¥§ TINYPAD |
¨«¨ - ¢ á«ãç ¥ ª à⨪¨ PNG - ¢ ®ª¥ ¢áâ஥®£® ¯à®á¬®âà騪 . |
ª®¬ ¤®© áâப¥ ¯¥à¥¤ ¨¬¥¥¬ à娢 ¬®£ãâ ¢ ¯à®¨§¢®«ì®¬ ¯®à浪¥ 㪠§ë¢ âìáï |
ä« £¨ à ᯠª®¢ª¨: |
s - ¥ § ªàë¢ âì ¯à®£à ¬¬ã ¯®á«¥ à ᯠª®¢ª¨; |
n - à ᯠª®¢ âì K-© ä ©« à娢 , £¤¥ K - á«¥¤ãî騩 dword ¢ ª®¬ ¤®© áâப¥; |
N - à ᯠª®¢ âì K-© ä ©« à娢 , £¤¥ K - ASCII ç¨á«® ¨§ á«¥¤ãîé¨å 6 ¡ ©â |
ª®¬ ¤®© áâப¨; |
R - "áëàë¥" Deflate-¤ ë¥, ¡¥§ ®¯¨á ⥫¥© ¨ § £®«®¢ª®¢; |
q - ¯à®á¬®âà ä ©« ç âì ᮠᬥ饨ï K, £¤¥ K - á«¥¤ãî騩 dword ¢ ª®¬ ¤®© |
áâப¥; |
Q - ¯à®á¬®âà ä ©« ç âì ᮠᬥ饨ï K, £¤¥ K - ASCII ç¨á«® ¨§ á«¥¤ãîé¨å 6 |
¡ ©â ª®¬ ¤®© áâப¨. |
ਬ¥à ª®¬ ¤®© áâப¨: |
cmd_string: |
db 'sN000037q' |
dd 1465 |
db '/hd/1/png.zip',0 |
â® ®§ ç ¥â, çâ® á«¥¤ã¥â ®âªàëâì 34-© (áç¨â ï ®â 0) ä ©« à娢 /hd/1/png.zip |
¨ ¥ § ¢¥àè âì à ¡®âã. à®á¬®âà à娢 ç¥âáï ᮠᬥ饨ï 1465. |
â® ¥é¥ 㦮 ᤥ« âì: |
1. ®¤¤¥à¦ª ç¥à¥ááâà®çëå (interlaced) PNG, â ª¦¥ «ìä -ª «®¢, £ ¬¬ë, |
ä® , Significant bits ¨ ªãç¨ ¤àã£¨å ¯à¨¬®ç¥ª í⮣® ä®à¬ â . |
2. 뢮¤ ᮤ¥à¦¨¬®£® à娢®¢ ç¥à¥§ IPC ¨«¨ ¢® ¢áâ஥®¬ ®ª¥ ¯®¤®¡¨¥ SYSTREE |
(íâ® ª ª à¥è¨¬ á 㢠¦ ¥¬ë¬¨ ª®««¥£ ¬¨). |
3. ®¨áª ä ©«®¢ ¢ à娢¥ ¯® ¨¬¥¨ ¨ ¤ ¦¥ ¬ ᪥! |
4. ᯠª®¢ª ¢ 㪠§ ë© ä ©«. |
5. ¥à®¯à¨ïâ¨ï ¯® íª®®¬¨¨ ¯ ¬ï⨠(ᥩç á @RCHER ¦à¥â 8 ¡!): ¯¥à¥¬¥é¥¨¥ |
ãç á⪮¢ ¯ ¬ïâ¨, ¡«®çë© ¢ë¢®¤ ¢ ä ©«. «ï ¯®á«¥¤¥£® ¥®¡å®¤¨¬® âé â¥«ì® |
¯à®â¥áâ¨à®¢ âì ¤¥¦®áâì ¢®®¤ -¢ë¢®¤ , ᮧ¤ ¨ï ª â «®£®¢ ¨ 㤠«¥¨ï |
ä ©«®¢. ®ª í⨠¢®§¬®¦®á⨠ï¤à ¥ ¤®ªã¬¥â¨à®¢ ë. |
6. ⥣à æ¨ï à娢ëå ª â «®£®¢ ¢ ä ©«®¢ë¥ ¬¥¥¤¦¥àë SYSXTREE, MFAR. |
®âॡã¥âáï ã¨ä¨æ¨à®¢ âì ä®à¬ ⠢맮¢ ( ¯®¤®¡¨¥ áâàãªâãàë ¢ 58 äãªæ¨¨). |
7. ⪮¬¬¥â¨à®¢ âì ª®¤. |
8. á¯à ¢¨âì ¡ £¨, ª®â®àë¥, ¥á®¬¥®, ©¤ãâáï ;-) |
á®¡ë¥ ¡« £®¤ à®áâ¨: |
¯¨á ¨¥ «£®à¨â¬ ¤¥ª®¤¥à ä®à¬ â Deflate ¯à¨¬¥à å ¤¥ª®¤¨à®¢ ¨ï |
(evm.narod.ru) |
RFC 1951 DEFLATE Compressed Data Format Specification version 1.3 |
ZIP File Format Specification version 4.5 by PKWARE Inc. |
"An Explanation of the Deflate Algorithm" by Antaeus Feldspar |
RFC 1952 GZIP file format specification version 4.3 |
TAR Format. Information from File Format List 2.0 by Max Maischein. |
RFC 1950 ZLIB Compressed Data Format Specification version 3.3 |
PNG (Portable Network Graphics) Specification version 1.0 |
Michael Dipperstein's Huffman Code Page |
¤ã ¢ è¨å § ¬¥ç ¨© ¨ ¯à¥¤«®¦¥¨© ®¤®¨¬¥®© ¢¥âª¥ à §¤¥« "®¤¨£" ä®à㬠|
meos.sysbin.com |
® ®¢ëå ¢áâà¥ç! |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/archer/trunk/arcmacro.inc |
---|
0,0 → 1,440 |
; @RCHER macros and messages |
; Written in pure assembler by Ivushkin Andrey aka Willow |
macro stop |
{ |
if SYS eq win & NO_STOPS eq 0 |
int3 |
end if |
} |
macro wait |
{ |
if ~ SYS eq win |
local .nodrw,.ex |
pusha |
mcall 10 |
cmp eax,1 |
jne .nodrw |
call draw_window |
.nodrw: |
mcall 17 |
.ex: |
popa |
end if |
} |
macro rbits dest,cnt |
{ |
if ~ cnt eq |
mov ecx,cnt |
end if |
if dest eq 0 |
xor eax,eax |
else |
mov eax,dest |
end if |
call read_bits |
} |
macro rep_err cond_ok, result, msg |
{ |
local .m |
j#cond_ok .m |
if ~ msg eq |
Msg msg |
end if |
mov edx,result |
jmp .err |
.m: |
} |
macro memcpy_esi dest, count,_add |
{ |
push esi |
if ~ _add eq |
add esi,_add |
end if |
mov edi,dest |
mov ecx,count |
rep movsb |
pop esi |
} |
DebugPrint: |
; in: edx-asciiz string ptr |
pusha |
if SYS eq win |
mov ecx,255 |
xor eax,eax |
mov edi,edx |
repne scasb |
sub edi,edx |
dec edi |
invoke WriteConsole,[cons],edx,edi,cparam1,NULL |
else |
call debug_outstr |
end if |
popa |
ret |
macro DebugPrintDec |
{ |
if SYS eq win |
call int2str |
mov edx,os_work |
call DebugPrint |
else |
call debug_outdec |
end if |
} |
macro Newline |
{ |
if SYS eq win |
pusha |
invoke WriteConsole,[cons],cr_lf,2,cparam1,NULL |
popa |
else |
newline |
end if |
} |
Msgcall: |
; edx - msg number |
pusha |
movzx edx,word[strs+edx*2] |
add edx,msgs |
call DebugPrint |
popa |
ret |
macro Msg num |
{ |
if ~ num eq edx |
mov edx,num |
end if |
call Msgcall |
} |
MSG_COUNT=0 |
macro str_table [str] |
{ |
forward |
local label |
dw label-msgs |
common |
msgs: |
forward |
label db str,0 |
MSG_COUNT=MSG_COUNT+1 |
} |
strs: |
if language eq ru |
str_table \ |
<'*** @RCHER - Deflate Unpacker ***',13,10>,\ ;0 |
<'*** Copyright Wiland Inc., 2005 ***',13,10>,\ ;1 |
' ©«®¢ ¢ à娢¥: ',\ ;2 |
<'End of Directory ¤®á⨣ãâ',13,10>,\ ;3 |
'¥â ä ©« á â ª¨¬ ®¬¥à®¬',\ ;4 |
<'FindByNumber ',13,10>,\ ;5 |
<'¥¢¥àë© ID ¡«®ª ää¬ ',13,10>,\ ;6 |
<'訡ª ¢ ª®¤ å ää¬ !',13,10>,\ ;7 |
<13,10,' áç¥â â ¡«¨æë CRC32',13,10>,\ ;8 |
'.',\ ;9 |
'Adler32',\ ;10 |
'CRC32',\ ;11 |
<' ¢¥à襮.',13,10>,\ ;12 |
<' ©« ¨¬¥¥â ã«¥¢ãî ¤«¨ã, à ᯠª®¢ª ®â¬¥¥ .',13,10>,\ ;13 |
<'âà ï ¤«¨ ä ©« -¨áâ®ç¨ª . 訡ª ¢ ¨¬¥¨? ⬥ .',13,10>,\ ;14 |
<'¥ GZIP à娢',13,10>,\ ;15 |
<'«¨èª®¬ ¡®«ì让 à §¬¥à ¢ë室®£® ä ©« ',13,10>,\ ;16 |
<"訡ª ¯à¨ à ᯠª®¢ª¥.",13,10>,\ ; 17 |
<'¥ à¨á㮪 PNG',13,10>,\ ; 18 |
<13,10,'*¤'>,\ ;19 |
<13,10,'*á'>,\ ;20 |
'¥®¦¨¤ ë© ª®¥æ ¡«®ª®¢ IDAT',\ ;21 |
'¥ä¨«ìâà æ¨ï:',\ ;22 |
'¨«ìâàë: None ',\ ;23 |
' Sub ',\ ;24 |
' Up ',\ ;25 |
' Avg ',\ ;26 |
' Paeth ',\ ;27 |
' 訡®ª: ',\ ;28 |
<'¥à¥ááâà®çë© PNG',13,10>,\ ;29 |
<'«®ª ¡¥§ ᦠâ¨ï',13,10>,\ ;30 |
<'¨¯ 梥⠥ ¯®¤¤¥à¦¨¢ ¥âáï',13,10>,\ ;31 |
<'¢¥¤¨â¥ ¯ à®«ì ¤«ï § è¨ä஢ ®£® ä ©« :',13,10>,\ ;32 |
<'®¨áª ä ©« ...',13,10>,\ ;33 |
'¥ ¬®¤ã«ì SFX',\ ;34 |
' ¥¢¥à ! ',\ ;35 |
' OK: ',\ ;36 |
<' ¯¨áì OUT.TXT',13,10>,\ ;37 |
' ',\ ;38 |
<'®¤£®â®¢ª ¨§®¡à ¦¥¨ï...',13,10>,\ ;39 |
<'ª ¦¨â¥ "R" ¤«ï ®¡à ¡®âª¨ áëàëå ¤ ëå. ⬥ .',13,10>,\ ;40 |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' <- ¥¨§¢¥áâë© ¬¥â®¤ ᦠâ¨ï',\ ;50 |
' <- § è¨ä஢ ',\ ;51 |
<'¥ ZIP à娢',13,10> ; 52 |
else |
str_table \ |
<'*** @RCHER - Deflate Unpacker ***',13,10>,\ ;0 |
<'*** Copyright Wiland Inc., 2005 ***',13,10>,\ ;1 |
'Files in archive: ',\ ;2 |
<'End of Directory reached',13,10>,\ ;3 |
'No file has this number',\ ;4 |
<'FindByNumber succeded',13,10>,\ ;5 |
<'Invalid Huffman block ID',13,10>,\ ;6 |
<'Error while getting Huffman codes!',13,10>,\ ;7 |
<13,10,'Rebuilding CRC32 table',13,10>,\ ;8 |
'.',\ ;9 |
'Adler32',\ ;10 |
'CRC32',\ ;11 |
<'Job finished.',13,10>,\ ;12 |
<'File of zero length, unpacking aborted.',13,10>,\ ;13 |
<'Source file has strange length, may be missing? Abort.',13,10>,\ ;14 |
<'Not a GZIP archive',13,10>,\ ;15 |
<'Destination file is too large for now',13,10>,\ ;16 |
<"Can't unpack content.",13,10>,\ ; 17 |
<'Not a PNG image',13,10>,\ ; 18 |
<13,10,'*d'>,\ ;19 |
<13,10,'*s'>,\ ;20 |
'Unexpected end of IDAT chunks',\ ;21 |
'Unfiltering:',\ ;22 |
'Filters: None ',\ ;23 |
' Sub ',\ ;24 |
' Up ',\ ;25 |
' Avg ',\ ;26 |
' Paeth ',\ ;27 |
' Invalid ',\ ;28 |
<'Interlaced PNG',13,10>,\ ;29 |
<'Stored block',13,10>,\ ;30 |
<'Color type not supported',13,10>,\ ;31 |
<'Enter password for encrypted file:',13,10>,\ ;32 |
<'Searching for file...',13,10>,\ ;33 |
'Not a SFX module',\ ;34 |
' error! ',\ ;35 |
' OK: ',\ ;36 |
<'Creating OUT.TXT',13,10>,\ ;37 |
' ',\ ;38 |
<'Preparing bitmap...',13,10>,\ ;39 |
<'Specify "R" to force raw data. Abort.',13,10>,\ ;40 |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' ',\ ; |
' <- unknown compression method',\ ;50 |
' <- encrypted',\ ;51 |
<'Not a ZIP archive',13,10> ; 52 |
end if |
macro opendialog redproc,openoff,erroff,path |
{ |
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc |
local run_fileinfo, param |
local getmesloop, loox, mred, mkey, mbutton, mgetmes |
local dlg_is_work, ready |
; |
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec, |
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save) |
; |
cld |
;; mov esi,path |
mov edi,path |
xor eax,eax |
mov ecx,200 |
rep stosb |
;mov [get_loops],0 |
mov [dlg_pid_get],0 |
; Get my PID in dec format 4 bytes |
mcall 9,os_work,-1 |
; convert eax bin to param dec |
mov eax,dword [os_work+30] ;offset of myPID |
mov edi,param+4-1 ;offset to 4 bytes |
mov ecx,4 |
mov ebx,10 |
cld |
new_d: |
xor edx,edx |
div ebx |
add dl,'0' |
mov [edi],dl |
dec edi |
loop new_d |
; write 1 byte space to param |
mov [param+4],byte 32 ;Space for next parametr |
; and 1 byte type of dialog to param |
mov [param+5],byte 'O' ;Get Open dialog (Use 'S' for Save dialog) |
; |
; STEP2 prepare IPC area for get messages |
; |
; prepare IPC area |
mov [path],dword 0 |
mov [path+4],dword 8 |
; define IPC memory |
mov eax,60 |
mov ebx,1 ; define IPC |
mov ecx,path ; offset of area |
mov edx,150 ; size 150 bytes |
int 0x40 |
mcall 40,1000111b |
; |
; STEP 3 run SYSTEM XTREE with parameters |
; |
mcall 58,run_fileinfo |
call redproc |
mov [get_loops],0 |
getmesloop: |
mov eax,23 |
mov ebx,50 ;0.5 sec |
int 0x40 |
cmp eax,1 |
je mred |
cmp eax,2 |
je mkey |
cmp eax,3 |
je mbutton |
cmp eax,7 |
je mgetmes |
; Get number of procces |
mcall 9,os_work,-1 |
mov ebp,eax |
loox: |
mcall 9,os_work,ebp |
mov eax,[DLGPID] |
cmp dword[os_work+30],eax ;IF Dialog find |
je dlg_is_work ;jmp to dlg_is_work |
dec ebp |
jnz loox |
jmp erroff |
dlg_is_work: |
cmp word[os_work+50],word 9 ;If slot state 9 - dialog is terminated |
je erroff ;TESTODP2 terminated too |
cmp [dlg_pid_get],dword 1 |
je getmesloop |
inc [get_loops] |
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated |
jae erroff |
jmp getmesloop |
mred: |
call redproc |
jmp getmesloop |
mkey: |
mcall 2 ; read (eax=2) |
jmp getmesloop |
mbutton: |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne getmesloop |
mov eax,-1 ; close this program |
int 0x40 |
mgetmes: |
; If dlg_pid_get then second message get jmp to still |
cmp [dlg_pid_get],dword 1 |
je ready |
; First message is number of PID SYSXTREE dialog |
; convert PID dec to PID bin |
movzx eax,byte [path+16] |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+1] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+2] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+3] |
add eax,ebx |
sub eax,48 |
mov [DLGPID],eax |
; Claear and prepare IPC area for next message |
mov [path],dword 0 |
mov [path+4],dword 8 |
mov [path+8],dword 0 |
mov [path+12],dword 0 |
mov [path+16],dword 0 |
; Set dlg_pid_get for get next message |
mov [dlg_pid_get],dword 1 |
call redproc ;show DLG_PID |
jmp getmesloop |
ready: |
; |
; The second message get |
; Second message is 100 bytes path to SAVE/OPEN file |
; shl path string on 16 bytes |
; |
cld |
mov esi,path+16 |
mov edi,path |
mov ecx,200 |
rep movsb |
mov [edi],byte 0 |
jmp openoff |
; DATA AREA |
get_loops dd 0 |
dlg_pid_get dd 0 |
DLGPID dd 0 |
param: |
dd 0 ; My dec PID |
dd 0,0 ; Type of dialog |
run_fileinfo: |
dd 16 |
dd 0 |
dd param |
dd 0 |
dd os_work ; 0x10000 |
;run_filepath |
db '/RD/1/SYSXTREE',0 |
} |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/archer/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm @rcher.asm @rcher |
@pause |
/programs/develop/archer/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm @rcher.asm @rcher |
@pause |
/programs/develop/archer/trunk/data.inc |
---|
0,0 → 1,158 |
; @RCHER data area |
; Written in pure assembler by Ivushkin Andrey aka Willow |
if SYS eq win |
dumpfile: |
db 'D:\Ivushkin\projects\zip\output.dmp',0 |
dumpf_len=$-dumpfile |
end if |
outfile: |
if SYS eq win |
db 'D:\Ivushkin\projects\zip\output.raw',0 |
end if |
dd 1 |
dd 0 |
.size dd 0 |
.out dd output |
dd os_work |
if ~SYS eq win |
dumpfile: |
db DUMPFILE,0 |
dumpf_len=$-dumpfile |
end if |
Finfo: |
dd 0 |
.block dd 0 |
.count dd BUFSIZE*2 |
.ptr dd BUFPTR |
dd os_work |
filename: |
if SYS eq win |
db 'png\absolut0.png',0 |
;db 'fasm-1.54.tgz',0 |
;include 'testsu~1.inc' |
; db 'pngsuite\pngsuite.tar.gz',0 ; OK |
; db 'pngsuite\basn4a08.png',0 ; OK |
; db 'goldhill.png',0 ; beeping |
; db 'arl_logo.png',0 ; wrong out |
; db 'tech.png',0 ; wrong out |
; db 'png\lena0000.png',0 |
; db 'arcs\' |
; db 'NTOSKRNL.gz' |
; db 'msg_enc.zip' |
;db 'msgplain.zip' |
; db 'c_866.gz' |
; db 'zalman_2.png' ;OK |
; db 'arcs\headerbar.png',0 ;OK |
; db 'fonts1.png' ;OK |
; db 'fonts.png' ; |
; db 'skin.png' ;OK |
; db 'JavaPowered8.png'; OK |
; db 'opr008S8.png' |
; db 'goldhill.png' |
; db 'k3b.png',0 |
; db 'image0051.png' |
; db 'window-elements.png',0 |
; db 'WWW.zip',0 |
; db 'png.zip',0 |
; db 'zlib09.zip',0 |
else |
if ~ FNAME eq |
db FNAME |
end if |
; db '/hd/1/zip/png.zip',0 |
; db '/hd/1/zip/files/opossum.png' |
; db '/rd/1/www.zip',0 |
; db '/hd/1/zip/test2.zip',0 |
end if |
db 0 |
rb 256-($-filename) |
I_END: |
if SYS eq win |
cr_lf db 0xa,0xd |
hnd dd ? |
cons dd ? |
cons_in dd ? |
cparam1 dd ? |
cparam2 dd ? |
end if |
DKeys rd 3 |
Dheader rb 12 |
Dpassword rb PASSW_LEN |
png_bpp dd ? |
sline_len dd ? |
IDATcount dd ? |
IDATsize dd ? |
PNG_info: |
.Width dd ? |
.Height dd ? |
.Bit_depth db ? |
.Color_type db ? |
.Compression_method db ? |
.Filter_method db ? |
.Interlace_method db ? |
.Palette rb 3*256 |
gpbf dw ? |
file_count dd ? |
filters rd 6 |
arc_base dd ? |
outp dd ? |
unp_size dd ? |
CRC_check dd ? |
CRC32 dd ? |
CRC32table rd 256 |
Adler32 dd ? |
child dd ? |
clientPID dd ? |
filesize dd ? |
bits db ? |
cur_byte dd ? |
lastblk db ? |
Flags dd ? |
tblCount dw ? |
tblLen dw ? |
hclen db ? |
max_len dw ? |
bl_count rb BITS |
next_code rw BITS |
tmp_clit: |
rw 20 |
calph: |
rw 20 |
sorted_clit rw 20 |
seql_c db ? |
seql rb BITS |
seqd_c db ? |
seqd rb BITS |
hlit dw ? |
Literal rw 286 |
Lit_c rw 286 |
hdist db ? |
Distance rw 32 |
Dist_c rw 32 |
area: |
rb INBUF |
os_work rb 4*1024 |
output: |
rb OUTBUF |
png_image: |
if SYS eq win |
rb OUTBUF |
end if |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/archer/trunk/debug.inc |
---|
0,0 → 1,131 |
macro debug_print str |
{ |
local ..string, ..label |
jmp ..label |
..string db str,0 |
..label: |
pushf |
pushad |
mov edx,..string |
call debug_outstr |
popad |
popf |
} |
dps fix debug_print |
macro debug_print_dec arg |
{ |
pushf |
pushad |
if ~arg eq eax |
mov eax,arg |
end if |
call debug_outdec |
popad |
popf |
} |
dpd fix debug_print_dec |
;--------------------------------- |
debug_outdec: ;(eax - num, edi-str) |
push 10 ;2 |
pop ecx ;1 |
push -'0' ;2 |
.l0: |
xor edx,edx ;2 |
div ecx ;2 |
push edx ;1 |
test eax,eax ;2 |
jnz .l0 ;2 |
.l1: |
pop eax ;1 |
add al,'0' ;2 |
call debug_outchar ; stosb |
jnz .l1 ;2 |
ret ;1 |
;--------------------------------- |
debug_outchar: ; al - char |
pushf |
pushad |
mov cl,al |
mov eax,63 |
mov ebx,1 |
int 0x40 |
popad |
popf |
ret |
debug_outstr: |
mov eax,63 |
mov ebx,1 |
@@: |
mov cl,[edx] |
test cl,cl |
jz @f |
int 40h |
inc edx |
jmp @b |
@@: |
ret |
macro newline |
{ |
dps <13,10> |
} |
macro print message |
{ |
dps message |
newline |
} |
macro pregs |
{ |
dps "EAX: " |
dpd eax |
dps " EBX: " |
dpd ebx |
newline |
dps "ECX: " |
dpd ecx |
dps " EDX: " |
dpd edx |
newline |
} |
macro debug_print_hex arg |
{ |
pushf |
pushad |
if ~arg eq eax |
mov eax, arg |
end if |
call debug_outhex |
popad |
popf |
} |
dph fix debug_print_hex |
debug_outhex: |
; eax - number |
mov edx, 8 |
.new_char: |
rol eax, 4 |
movzx ecx, al |
and cl, 0x0f |
mov cl, [__hexdigits + ecx] |
pushad |
mcall 63, 1 |
popad |
dec edx |
jnz .new_char |
ret |
__hexdigits: |
db '0123456789ABCDEF' |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/archer/trunk/deflate.inc |
---|
0,0 → 1,615 |
; @RCHER main algorythm |
; Written in pure assembler by Ivushkin Andrey aka Willow |
macro get_a _type,_size,c1,c2,c3,c4,c5 |
{ |
get_#_type: |
local .no,.no0,.ex |
push edx |
and [Flags],not 1 |
if _type eq Len |
cmp eax,c4 |
jne .no |
mov eax,c5 |
jmp .ex |
.no: |
end if |
sub eax,c1 |
ja .no0 |
add eax,c2 |
jmp .ex |
.no0: |
add eax,c3 |
push eax |
mov ecx,eax |
shr ecx,_size |
xor eax,eax |
call read_bits |
pop edx |
and edx,1 shl _size-1 |
shl edx,cl |
movzx ecx,[tblH#_type+ecx*2] |
add edx,ecx |
add eax,edx |
.ex: |
or [Flags],1 |
pop edx |
ret |
} |
; ************************* |
Deflate: |
mov edi,[outp] |
.init: |
mov [bits],8 |
lodsb |
call setcurb |
.blkbegin: |
and [lastblk],0 |
and [Flags],not 1 |
rbits 0,1 |
test eax,eax |
je .nolast |
mov [lastblk],1 |
.nolast: |
rbits 0,2 |
cmp eax,10b |
je .DynHuff |
cmp eax,01b |
je .static |
test eax,eax |
jnz .errorID |
Msg 30 |
movzx ecx,[bits] |
call read_bits |
movzx ecx,word[esi-1] |
add esi,3 |
rep movsb |
jmp .check_last |
.errorID: |
Msg 6 |
ret |
; Static Huffman |
.static: |
if SHOW_METH eq 1 |
Msg 20 |
end if |
mov edi,[outp] |
or [Flags],1 |
.next: |
rbits 0,7 |
; stop |
cmp eax,0x17 |
ja .no7 |
add eax,256 |
cmp eax,256 |
jne .noend |
.check_last: |
mov [outp],edi |
cmp [lastblk],1 |
je .ex |
jmp .blkbegin |
.noend: |
call get_Len |
mov ebx,eax |
rbits 0,5 |
call get_Dist |
neg eax |
push esi |
lea esi,[edi+eax] |
mov ecx,ebx |
rep movsb |
pop esi |
jmp .next |
.no7: |
rbits eax,1 |
cmp eax,0xc8 |
jb .no9 |
rbits eax,1 |
sub eax,0xd0 |
jmp .no81 |
.no9: |
cmp eax,0xc0 |
jb .no81 |
add eax,0x58 |
jmp .noend |
.no81: |
sub eax,0x30 |
stosb |
jmp .next |
.ex: |
ret |
; ************* dynamic Huffman ************ |
.DynHuff: |
; dps '##' |
if SHOW_METH eq 1 |
Msg 19 |
end if |
pusha |
xor eax,eax |
mov ecx,(area-bl_count) / 4 |
mov edi,bl_count |
rep stosd |
popa |
; max_len=0 |
and [max_len],0 |
rbits 0,5 |
; hlit-257 |
add eax,257 |
mov [hlit],ax |
rbits 0,5 |
; hdist-1 |
inc eax |
mov [hdist],al |
rbits 0,4 |
; hclen-4 |
add eax,4 |
mov [hclen],al |
mov ecx,eax |
push edi |
mov edi,tmp_clit |
; read code lengths for code lengths |
.alphloop: |
push ecx |
rbits 0,3 |
stosb |
pop ecx |
loop .alphloop |
; sort code lengths for code lengths |
push esi |
movzx ecx,[hclen] |
xor eax,eax |
mov edi,tmp_clit |
mov esi,tblSort |
.sortloop: |
lodsb |
movzx bx,byte[edi] |
mov [sorted_clit+eax*2],bx |
inc edi |
loop .sortloop |
pop esi edi |
.generate: |
mov ecx,19 |
mov ebx,calph |
mov edx,seql |
mov eax,sorted_clit |
call Huffc |
and [tblCount],0 |
or [Flags],1 |
mov edi,Lit_c |
mov ebp,sorted_clit |
.again: |
cmp edi,output+OUTBUF |
jb ._ok |
Msg 16 |
jmp .ex |
._ok: |
mov edx,seql |
mov ebx,calph |
call get_code |
call ExpLen |
cmp [hlit],ax |
ja .again |
if SHOW_CHARS eq 1 |
mov edi,Lit_c |
call Show_codes |
end if |
mov edi,Dist_c |
and [tblCount],0 |
.again2: |
mov ebx,calph |
call get_code |
call ExpLen |
cmp [hdist],al |
ja .again2 |
movzx ecx,[hlit] |
mov ebx,Literal |
mov edx,seql |
mov eax,Lit_c |
call Huffc |
movzx ecx,[hdist] |
mov ebx,Distance |
mov edx,seqd |
mov eax,Dist_c |
call Huffc |
push [hlit] |
pop [tblLen] |
mov ebp,Lit_c |
mov edx,seql |
mov ebx,Literal |
mov edi,[outp] |
and [tblCount],0 |
.again3: ; <------------ |
call get_code |
cmp eax,256 |
je .check_last |
ja .dist |
stosb |
jmp .again3 |
.dist: |
call get_Len |
push eax ebx edx ebp |
mov ecx,32 |
mov ebp,Dist_c |
mov edx,seqd |
mov ebx,Distance |
mov [tblLen],32 |
call get_code |
call get_Dist |
push [hlit] |
pop [tblLen] |
neg eax |
pop ebp edx ebx ecx |
push esi |
lea esi,[edi+eax] |
rep movsb |
pop esi |
jmp .again3 |
; ****************************************** |
Huffc: |
; EBX - dest array, ECX - length, EDX - br_seq dest, EAX - source array |
push esi edi eax ecx |
mov edi,bl_count |
xor eax,eax |
mov ecx,BITS |
rep stosw |
pop ecx |
mov esi,[esp] |
mov [tblLen],cx |
mov [max_len],ax |
; Count the number of codes for each code length |
.cnt_loop: |
lodsw |
cmp [max_len],ax |
jae .skip |
mov [max_len],ax |
.skip: |
inc byte[bl_count+eax] |
loop .cnt_loop |
movzx ecx,[max_len] |
xor eax,eax |
and [bl_count],al |
xor esi,esi ; edx - bits |
mov edi,next_code+2 |
push ebx |
; Find the numerical value of the smallest code for each code length |
.nc_loop: |
movzx bx,byte[bl_count+esi] |
add ax,bx |
shl ax,1 |
stosw |
inc esi |
loop .nc_loop |
pop ebx |
; clear table |
movzx ecx,[tblLen] |
xor eax,eax |
dec eax |
mov edi,ebx |
rep stosw |
inc eax |
movzx ecx,[tblLen] |
mov esi,[esp] |
mov edi,ebx |
; Assign numerical values to all codes |
.loop3: |
lodsw |
test eax,eax |
jz .lp |
push [next_code+eax*2] |
pop word[edi] |
inc [next_code+eax*2] |
.lp: |
add edi,2 |
loop .loop3 |
; Clear all codes |
xor eax,eax |
mov edi,edx |
movzx ecx,[max_len] |
mov [edi-1],al |
; Prepare read bit sequences |
.rebiloop: |
inc eax |
cmp [bl_count+eax],0 |
jz .sk |
stosb |
inc byte[edx-1] |
.sk: |
loop .rebiloop |
movzx ecx,byte[edx-1] |
dec ecx |
jecxz .noreb2 |
.reb2loop: |
mov al,[edx+ecx-1] |
sub [edx+ecx],al |
loop .reb2loop |
.noreb2: |
pop eax edi esi |
ret |
; ****************************************** |
; get Codes of variable sizes |
get_code: |
; EDX - br_seq, EBX - source table, EBP - codelength table |
push edx edi |
xor eax,eax |
movzx ecx,byte[edx-1] |
mov [codel],ax |
.rb3: |
push ecx |
movzx ecx,byte[edx] |
add [codel],cx |
call read_bits |
movzx ecx,[tblLen] |
inc ecx |
mov edi,ebx |
.scas: |
repne scasw |
jecxz .notfound |
push edi ecx |
sub edi,ebx |
sub edi,2 |
mov cx,[codel] |
cmp cx,[ds:ebp+edi] |
jne .notfound2 |
mov eax,edi |
shr eax,1 |
add esp,12 |
.pp: |
pop edi edx |
ret |
.notfound2: |
pop ecx |
pop edi |
jmp .scas |
.notfound: |
pop ecx |
inc edx |
loop .rb3 |
Msg 7 |
jmp .pp |
codel dw ? |
; ****************************************** |
ExpLen: |
cmp eax,16 |
jae .noliteral |
inc [tblCount] |
stosw |
jmp .nomatch |
.noliteral: |
and [Flags],not 1 |
mov ebx,3 |
cmp eax,17 |
jae .code1718 |
mov ecx,2 |
xor eax,eax |
call read_bits |
lea ecx,[eax+ebx] |
mov ax,[edi-2] |
.cc: |
add [tblCount],cx |
rep stosw |
or [Flags],1 |
jmp .nomatch |
.code1718: |
jne .code18 |
mov ecx,3 |
.cc2: |
xor eax,eax |
call read_bits |
lea ecx,[eax+ebx] |
xor eax,eax |
jmp .cc |
.code18: |
mov ebx,11 |
mov ecx,7 |
jmp .cc2 |
.nomatch: |
mov ax,[tblCount] |
ret |
get_a Len,2,256+8,10,3,285,258 |
get_a Dist,1,3,4,1 |
; ****************************************** |
read_bits: ; eax-dest; ecx-count |
push edx ecx |
.shift: |
if RBLOCK eq 4 |
ror [cur_byte],1 |
else |
ror byte[cur_byte],1 |
end if |
pushf |
test [Flags],1 |
je .noh1 |
popf |
rcl eax,1 |
jmp .dec |
.noh1: |
popf |
rcr eax,1 |
.dec: |
dec [bits] |
jnz .loop1 |
.push: |
push eax |
mov eax,[esi] |
call setcurb |
pop eax |
if RBLOCK eq 1 |
inc esi |
inc [IDATcount] |
else |
inc esi |
inc [IDATcount] |
end if |
cmp esi,area+INBUF-BSIZE |
jbe .ok |
pusha |
if SHOW_RBLOCK eq 1 |
Msg 9 |
end if |
mov eax,0 |
mov ebx,1 |
call FileSeek |
mov [esp+4],esi |
popa |
.ok: |
test [Flags],PNG_MODE |
jz .idatok |
mov edx,[IDATcount] |
cmp edx,[IDATsize] |
jbe .idatok |
pusha |
lodsd |
call PngParse.nxt_sec |
mov [IDATcount],1 |
mov [esp+4],esi |
mov [esp+20],edx |
popa |
cmp edx,21 |
jne .idatok |
mov eax,256 |
pop ecx |
jmp .exx |
.idatok: |
mov [bits],8 |
.loop1: |
loop .shift2 |
jmp .popc |
.shift2: |
jmp .shift |
.popc: |
pop ecx |
test [Flags],1 |
jne .exx |
.noh2: |
rol eax,cl |
.exx: |
pop edx |
ret |
if SHOW_CHARS eq 1 |
Show_codes: |
pusha |
movzx ecx,[tblLen] |
mov ecx,256 |
xor eax,eax |
.lp2: |
mov [braces+1],al |
push eax ecx |
invoke StrFormat,eax,strbuf,20 |
invoke WriteConsole,[cons],strbuf,16,param1,NULL |
invoke WriteConsole,[cons],braces,6,param1,NULL |
mov eax,[esp+4] |
movzx eax,word[edi+eax*2] |
test eax,eax |
jz .skip |
invoke WriteConsole,[cons],exist,6,param1,NULL |
.skip: |
invoke WriteConsole,[cons],braces+6,2,param1,NULL |
pop ecx eax |
inc eax |
loop .lp |
jmp .ex |
.lp: |
jmp .lp2 |
.ex: |
popa |
ret |
cons dd ? |
param1 dd ? |
braces db '( ) = ',0xa, 0xd |
strbuf rb 20 |
exist db 'exists' |
end if |
makeCRC: |
pusha |
Msg 8 |
mov edi,CRC32table |
add edi,255*4 |
std |
mov ecx,255 |
mov ebx,0xedb88320 |
.m1: |
mov eax,ecx |
push ecx |
mov ecx,8 |
.m2: |
shr eax,1 |
jnc .m3 |
xor eax,ebx |
.m3: |
loop .m2 |
pop ecx |
stosd |
loop .m1 |
popa |
cld |
ret |
UCRC: |
; in: esi - data to calculate CRC |
; ecx - its length |
; [CRC32] - previous CRC32 |
; out: [CRC32]- partial CRC32 (no pre- & post-conditioning!) |
pusha |
cmp dword[CRC32table+4],0x77073096 |
je .tbl_rdy |
call makeCRC |
.tbl_rdy: |
mov eax,[CRC32] |
not eax |
.m1: |
movzx ebx,al |
shr eax,8 |
xor bl,[esi] |
xor eax,[CRC32table+ebx*4] |
inc esi |
loop .m1 |
not eax |
mov [CRC32],eax |
popa |
ret |
UAdler: |
; in: esi - data to calculate CRC |
; ecx - its length |
; [Adler32] - previous Adler32 |
; out: [Adler32]- partial Adler32 |
pusha |
mov ebp,65521 |
movzx ebx,word[Adler32] ; s1-ebx |
movzx edi,word[Adler32+2] ; s2-edi |
.m1: |
movzx eax,byte[esi] |
add eax,ebx |
xor edx,edx |
div ebp |
mov ebx,edx |
lea eax,[edi+ebx] |
xor edx,edx |
div ebp |
mov edi,edx |
inc esi |
loop .m1 |
shl edi,16 |
add edi,ebx |
mov [Adler32],edi |
popa |
ret |
tblSort db 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 |
tblHLen dw 7,11,19,35,67,131 |
tblHDist dw 3,5,9,17,33,65,129,257,513,1025,2049,4097,8193,16385 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/archer/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/archer/trunk/parser.inc |
---|
0,0 → 1,896 |
; @RCHER parser and filter routines |
; Written in pure assembler by Ivushkin Andrey aka Willow |
fhs_local equ 0x04034b50 |
fhs_central equ 0x02014b50 |
fhs_end equ 0x06054b50 |
fhs_enc equ 0x08074b50 |
SkipASCIIZ: |
xor eax,eax |
mov ecx,255 |
mov edi,esi |
repne scasb |
mov esi,edi |
ret |
PrintFilename: |
pusha |
mov esi,edx |
mov edi,os_work |
mov edx,edi |
rep movsb |
mov dword[edi],0x00a0d |
call DebugPrint |
; mcall 10 |
; mcall 2 |
popa |
ret |
; Parse routines: |
; out: edx= 0 if all ok, 1 - central dir, 2-EOD |
; 50 - encrypted |
; 51 - not deflated |
; 52 - invalid format |
; 53 - dir skipped |
; 1 - encrypted |
; **************************************************** |
ZipParse: |
call ResetFile |
.nxt: |
call ZipCrawl |
cmp edx,3 |
je .ex |
cmp edx,1 |
je .skipinc |
if IGNORE_DIRS eq 1 |
cmp edx,53 |
jne .skipinc |
end if |
inc [file_count] |
.skipinc: |
cmp edx,52 |
je .er1 |
cmp edx,50 |
jne .seek |
.er1: |
Msg edx |
ret |
.seek: |
add eax,ecx |
mov ebx,1 |
call FileSeek |
jmp .nxt |
.ex: |
Msg 2 |
mov eax,[file_count] |
if ~ SYS eq win |
dpd eax |
else |
pusha |
call int2str |
mov edx,os_work |
call DebugPrint |
popa |
end if |
Newline |
ret |
ZipFindN: |
; ecx - file # |
Msg 33 |
cmp ecx,[file_count] |
jae .err |
push ecx |
call ResetFile |
.nxt: |
call ZipCrawl |
cmp edx,51 |
je .ok2 |
.noenc: |
test edx,edx |
jnz .err |
.ok2: |
add eax,ecx |
cmp dword[esp],0 |
jz .ok |
dec dword[esp] |
mov ebx,1 |
call FileSeek |
jmp .nxt |
.err: |
mov edx,4 |
jmp .ex |
.ok: |
pop ecx |
sub eax,[esi+18] |
add esi,eax |
mov edx,5 |
.ex: |
push edx |
Msg edx |
pop edx |
ret |
ZipCrawl: |
mov edx,52 |
cmp dword[esi],fhs_central |
jne .noc |
mov eax,46 |
movzx ecx,word[esi+28] |
add eax,ecx |
movzx ecx,word[esi+30] |
add eax,ecx |
movzx ecx,word[esi+32] |
mov edx,1 |
ret |
.noc: |
cmp dword[esi],fhs_end |
jne .noe |
.edx3: |
Msg 3 |
mov edx,3 |
ret |
.noe: |
cmp dword[esi],fhs_local |
je .loc |
cmp dword[esi],fhs_enc |
jne .err |
mov eax,16 |
xor ecx,ecx |
mov edx,1 |
ret |
.loc: |
push word[esi+6] |
pop [gpbf] |
push dword[esi+14] |
pop [CRC_check] |
push dword[esi+22] |
pop [unp_size] |
movzx ecx,word[esi+26] |
mov eax,30 |
lea edx,[esi+eax] |
add eax,ecx |
if IGNORE_DIRS eq 1 |
cmp byte[edx+ecx-1],'/' |
je .skipdp |
end if |
call PrintFilename |
.skipdp: |
movzx ecx,word[esi+28] |
add eax,[esi+18] |
test [gpbf],1 |
jz .no_enc |
or [Flags],DECRYPT_MODE ; encrypted |
mov edx,51 |
jmp .err |
.no_enc: |
test word[esi+8],7 |
rep_err z,50 |
.ok: |
xor edx,edx |
.err: |
ret |
; *********************************************** |
GzipParse: |
ID1ID2 equ 0x8b1f |
FTEXT equ 1b |
FHCRC equ 10b |
FEXTRA equ 100b |
FNAME equ 1000b |
FCOMMENT equ 10000b |
mov eax,7 |
mov ebx,2 |
call FileSeek |
push dword[esi] |
pop [CRC_check] |
push dword[esi+4] |
pop [unp_size] |
call ResetFile |
xor edx,edx |
cmp word[esi],ID1ID2 |
rep_err e, 52, 15 |
cmp byte[esi+2],8 |
rep_err e, 52, 50 |
mov bl,[esi+3] ; bl - FLG |
add esi,10 ; esi->extra |
test bl,FEXTRA |
jz .noextr |
movzx eax,word[esi] |
lea esi,[esi+eax+2] ; esi->FNAME |
.noextr: |
test bl,FNAME |
jz .nofname |
mov edx,esi |
call DebugPrint |
call SkipASCIIZ |
cmp dword[esi-5],'.tar' |
jne .nofname |
or [Flags],TAR_MODE |
.nofname: ; esi->FCOMMENT |
test bl,FCOMMENT |
jz .nocomm |
call SkipASCIIZ |
.nocomm: ; esi->HCRC |
test bl,FHCRC |
jz .noCRC16 |
add esi,2 |
.noCRC16: |
cmp [unp_size],OUTBUF |
jb .sizeok2 |
Msg 16 |
mov edx,15 |
ret |
.sizeok2: |
xor edx,edx |
.err: |
ret |
PngParse: |
ID1 equ 0x474e5089 |
ID2 equ 0x0a1a0a0d |
FDICT equ 100000b |
InitIDAT equ 2 |
mov [IDATcount],InitIDAT |
call ResetFile |
cmp dword[esi],ID1 |
rep_err e, 52, 18 |
cmp dword[esi+4],ID2 |
rep_err e, 52, 18 |
add esi,8 |
cmp dword[esi+4],'IHDR' |
rep_err e,52, 18 |
or [Flags],PNG_MODE |
memcpy_esi PNG_info,13,8 |
mov eax,[PNG_info.Width] |
bswap eax |
mov [PNG_info.Width],eax |
mov eax,[PNG_info.Height] |
bswap eax |
mov [PNG_info.Height],eax |
add esi,25 |
cmp byte[esi-5],0 |
rep_err e,52,29 |
.nxt_sec: |
lodsd |
bswap eax ; eax - section size |
push eax |
lodsd |
mov edi,Png_ch |
mov ecx,(E_ch-Png_ch) / 4 |
repne scasd |
pop eax |
mov ebx,[esi-4] |
mov edx,os_work |
mov [edx],ebx |
mov dword[edx+4],0x0a0d |
.dp: |
sub edi,Png_ch |
shr edi,2 ; edi- chunk # |
if SHOW_PNG_SEC eq 1 |
call DebugPrint |
end if |
cmp edi,1 |
jne .noend |
mov edx,21 |
jmp .err |
.noend: |
cmp edi,2 |
jne .noplte |
memcpy_esi PNG_info.Palette,eax |
jmp .noidat |
.noplte: |
cmp edi,3 |
jne .noidat |
mov [IDATsize],eax |
cmp [IDATcount],InitIDAT |
jne .ex |
mov [bits],8 |
if RBLOCK eq 4 |
lodsd |
else |
lodsb |
end if |
call setcurb |
rbits 0,16 |
test ah,FDICT |
jz .ex |
rbits 0,32 |
add [IDATcount],4 |
jmp .ex |
.noidat: |
add eax,4 |
mov ebx,1 |
call FileSeek |
jmp .nxt_sec |
.ex: |
xor edx,edx |
.err: |
ret |
Png_ch: |
dd 'IEND','PLTE','IDAT','????' |
E_ch: |
ZipDecrypt: |
push edi |
mov ecx,3 |
mov edi,Dheader |
rep movsd |
pop edi |
call QueryPwd |
jecxz .ex |
push esi |
mov [DKeys], 305419896 |
mov [DKeys+4],591751049 |
mov [DKeys+8],878082192 |
xor eax,eax |
mov esi,Dpassword |
.enc_init: |
lodsb |
call UKeys |
loop .enc_init |
mov ecx,12 |
mov esi,Dheader |
.dec_header: |
call decrypt_byte |
xor al,[esi] |
call UKeys |
mov [esi],al |
inc esi |
loop .dec_header |
mov eax,[CRC_check] |
pop esi |
.ex: |
ret |
QueryPwd: |
; out: ecx - passwd len |
if SYS eq win |
Msg 32 |
invoke ReadConsole,[cons_in],Dpassword,PASSW_LEN,cparam1,NULL |
test eax,eax |
jnz .inp_ok |
xor ecx,ecx |
jmp .ex |
.inp_ok: |
mov ecx,[cparam1] |
cmp ecx,PASSW_LEN |
je .ex |
sub ecx,2 |
else |
end if |
.ex: |
ret |
UKeys: |
; in: al - char |
pusha |
mov edi,134775813 |
mov ebx,DKeys |
mov esi,os_work |
mov byte[esi],al |
mov ecx,1 |
push dword[ebx] |
pop [CRC32] |
call UCRC |
push [CRC32] |
pop dword[ebx] |
mov eax,[ebx] |
and eax,0xff |
add eax,[ebx+4] |
mul edi |
inc eax |
mov [ebx+4],eax |
shr eax,24 |
mov byte[esi],al |
push dword[ebx+8] |
pop [CRC32] |
call UCRC |
push [CRC32] |
pop dword[ebx+8] |
popa |
ret |
decrypt_byte: |
; out: al |
push ebx edx |
movzx ebx,word[DKeys+8] |
or ebx,2 |
mov eax,ebx |
xor eax,1 |
mul ebx |
shr eax,8 |
pop edx ebx |
ret |
setcurb: |
; in: eax |
test [Flags],DECRYPT_MODE |
jz .noenc |
push eax |
call decrypt_byte |
xor al,byte[esp] |
add esp,4 |
call UKeys |
.noenc: |
mov [cur_byte],eax |
ret |
TarParse: |
call ResetFile |
.nxt: |
call TarCrawl |
; wait |
cmp edx,3 |
je ZipParse.ex |
if IGNORE_DIRS eq 1 |
cmp edx,53 |
jne .skipinc |
end if |
inc [file_count] |
.skipinc: |
add eax,ecx |
mov ebx,1 |
call FileSeek |
jmp .nxt |
TarFindN: |
; in: ecx - file number |
; ecx - file # |
Msg 33 |
cmp ecx,[file_count] |
jae .err |
push ecx |
call ResetFile |
.nxt: |
call TarCrawl |
if IGNORE_DIRS eq 1 |
cmp edx,53 |
je .seek |
end if |
test edx,edx |
jnz .err |
cmp dword[esp],0 |
jz .ok |
dec dword[esp] |
.seek: |
add eax,ecx |
mov ebx,1 |
call FileSeek |
jmp .nxt |
.err: |
mov edx,4 |
jmp .ex |
.ok: |
pop ecx |
add esi,eax |
mov edx,5 |
.ex: |
Msg edx |
ret |
TarCrawl: |
cmp byte[esi],0 |
jz ZipCrawl.edx3 |
push esi |
mov ecx,11 |
add esi,0x7c |
call Octal_str |
mov esi,[esp] |
mov [outfile.size],eax |
call SkipASCIIZ |
if IGNORE_DIRS eq 1 |
cmp byte[esi-2],'/' |
je .skipdp |
end if |
mov edx,[esp] |
lea ecx,[esi-1] |
sub ecx,edx |
call PrintFilename |
.skipdp: |
mov ecx,[outfile.size] |
jecxz .zerolen |
shr ecx,9 |
inc ecx |
shl ecx,9 |
.zerolen: |
mov eax,512 |
pop esi |
jmp ZipCrawl.ok |
Octal_str: |
; in: esi - ASCIIZ octal string |
; ecx - its length |
; out: eax - value |
push esi ebx ecx |
xor ebx,ebx |
xor eax,eax |
.jec: |
jecxz .zero |
cmp byte[esi+ecx-1],' ' |
jne .lp |
dec ecx |
jmp .jec |
.lp: |
lodsb |
shl ebx,3 |
cmp eax,' ' |
je .space |
lea ebx,[ebx+eax-'0'] |
.space: |
loop .lp |
mov eax,ebx |
.zero: |
pop ecx ebx esi |
ret |
TRAILING_BUF equ 2048 |
SfxParse: |
call ResetFile |
cmp word[esi],'MZ' |
rep_err e, 34 |
mov eax,TRAILING_BUF |
mov ecx,eax |
mov ebx,2 |
call FileSeek |
mov edi,esi |
mov al,'P' |
.lp: |
repne scasb |
cmp dword[edi-1],fhs_end |
je .end_found |
jecxz .err |
jmp .lp |
.end_found: |
dec edi |
mov esi,edi |
mov eax,[edi+12] |
neg eax |
mov ebx,1 |
call FileSeek |
push dword[esi+42] |
pop [arc_base] |
.err: |
ret |
; Created: May 31, 2005 |
FiltCall: |
dd PngFilter.nofilt,Filt_sub,Filt_up,Filt_av,Filt_paeth,PngFilter.nofilt |
PngFilter: |
; esi - filtered uncompressed image data |
; edi - destination |
mov cl,[PNG_info.Color_type] |
mov eax,1 |
cmp cl,3 |
je .palette |
test cl,2 |
jz .notriple |
add eax,2 |
.notriple: |
test cl,4 |
jz .calc_bpp |
inc eax |
.calc_bpp: |
mul [PNG_info.Bit_depth] |
.palette: |
mov ecx,eax ; in bits |
shr eax,3 ; in bytes |
test eax,eax |
jnz .noz |
inc eax |
.noz: |
mov [png_bpp],eax |
mov eax,[PNG_info.Width] |
mov ebp,eax |
imul ecx |
shr eax,3 |
test eax,eax |
jnz .noz2 |
inc eax |
.noz2: |
mov [sline_len],eax ; scanline length |
push edi |
and [Flags],not 1 |
mov ecx,[PNG_info.Height] |
.scanline: |
; Msg 9,1 |
push ecx |
lodsb |
movzx eax,al |
cmp eax,5 |
jb .f_ok |
mov eax,5 |
.f_ok: |
inc dword[filters+eax*4] |
jmp dword[FiltCall+eax*4] |
.nofilt: |
mov dl,[PNG_info.Color_type] |
cmp dl,3 |
jne .nopalette |
lodsb |
mov [cur_byte],eax |
mov [bits],8 |
mov ecx,ebp |
.pixel: |
push ecx |
movzx ecx,[PNG_info.Bit_depth] |
call rb_png |
push esi |
lea esi,[eax+eax*2] |
add esi,PNG_info.Palette |
call PngStore |
pop esi |
pop ecx |
loop .pixel |
cmp [bits],8 |
jne .lp |
dec esi |
.lp: |
pop ecx |
loop .sl |
jmp .sl2 |
.sl: |
;// |
MV equ 1 |
; mov eax,ecx |
; and eax,1 shl MOVE_SLINE_LEV-1 |
; jnz .scanline |
;stop |
if MV eq 0 |
push ecx |
mov ecx,edi |
sub ecx,esi |
sub [outp],esi |
mov edi,output |
add [outp],edi |
rep movsb |
mov esi,output |
pop ecx |
pop eax |
push [outp] |
end if |
;;// |
jmp .scanline |
.sl2: |
;// |
; call MoveScanline |
sub edi,[outp] |
;// |
; sub edi,[esp] |
pop eax |
ret |
.nopalette: |
test dl,2 |
jz .notriple1 |
.__: |
mov ecx,[PNG_info.Width] |
.RGBcp: |
call PngStore |
add esi,[png_bpp] |
loop .RGBcp |
jmp .lp |
.notriple1: |
test dl,dl |
jz .gray |
cmp dl,4 |
jne .__ |
; Msg 31 |
; ud2 |
.gray: |
; stop |
push ecx |
mov ecx,[PNG_info.Width] |
mov [bits],8 |
lodsb |
mov [cur_byte],eax |
.gray2: |
push ecx |
movzx ecx,[PNG_info.Bit_depth] |
push ecx |
call rb_png |
pop ecx |
cmp ecx,8 |
jbe .lo |
add esi,2 |
shr eax,8 |
jmp .stsb |
.lo: |
neg ecx |
add ecx,8 |
shl eax,cl |
.stsb: |
mov ecx,3 |
rep stosb |
pop ecx |
loop .gray2 |
dec esi |
pop ecx |
jmp .lp |
Filt_sub: |
; dps '-' |
mov ecx,[sline_len] |
sub ecx,[png_bpp] |
push esi edi |
mov edi,esi |
add edi,[png_bpp] |
.scan: ; esi - previous, edi - current |
lodsb |
add [edi],al |
inc edi |
loop .scan |
pop edi esi |
; dps '-' |
jmp PngFilter.nofilt |
Filt_up: |
cmp ecx,[PNG_info.Height] |
je PngFilter.nofilt |
push esi edi |
mov ecx,[sline_len] |
mov edi,esi |
sub esi,ecx |
dec esi |
jmp Filt_sub.scan |
Filt_av: |
pusha |
mov ecx,[sline_len] |
mov ebp,[PNG_info.Height] |
mov edx,[png_bpp] ; edx-raw |
neg edx |
mov ebx,ecx |
sub ebx,[png_bpp] |
mov edi,esi |
sub esi,ecx |
dec esi ; esi-prior |
.lpavg: |
xor eax,eax |
cmp [esp+24h],ebp |
je .1stl |
movzx eax,byte[esi] |
.1stl: |
cmp ecx,ebx |
ja .leftbad |
push ecx |
movzx ecx,byte[edi+edx] |
add eax,ecx |
pop ecx |
.leftbad: |
shr eax,1 |
add [edi],al |
inc esi |
inc edi |
loop .lpavg |
popa |
jmp PngFilter.nofilt |
Filt_paeth: |
pusha |
mov ecx,[sline_len] |
mov edx,[png_bpp] |
neg edx |
lea ebp,[ecx+edx] ; left edge |
mov edi,esi |
sub esi,ecx |
dec esi |
.lpaeth: |
push ecx |
movzx eax,byte[edi+edx] |
movzx ebx,byte[esi] |
movzx ecx,byte[esi+edx] |
push eax |
mov eax,[esp+28h] |
cmp eax,[PNG_info.Height] ; 1st line |
jne .no1stlineok |
xor ebx,ebx |
xor ecx,ecx |
.no1stlineok: |
pop eax |
cmp [esp],ebp ; ecx |
jbe .leftok ; x-bpp>=0 |
xor eax,eax |
xor ecx,ecx |
.leftok: |
pusha ; eax-28, ebx-16, ecx-24 |
lea edx,[eax+ebx] |
sub edx,ecx ; p=edx |
sub eax,edx ; pa := abs(p - a) |
jge .eaxp |
neg eax |
.eaxp: |
sub ebx,edx ; pb := abs(p - b) |
jge .ebxp |
neg ebx |
.ebxp: |
sub ecx,edx ; pc := abs(p - c) |
jge .ecxp |
neg ecx |
.ecxp: |
cmp eax,ebx |
ja .noa |
cmp eax,ecx |
jbe .ex ; pa-min |
.noa: |
cmp ebx,ecx |
ja .nob |
mov eax,[esp+16] |
jmp .ex2 |
.nob: |
mov eax,[esp+24] |
.ex2: |
mov [esp+28],eax |
.ex: |
popa |
add [edi],al |
inc esi |
inc edi |
pop ecx |
loop .lpaeth |
popa |
jmp PngFilter.nofilt |
rb_png: ; eax-dest; ecx-count |
push ecx |
xor eax,eax |
.shift: |
rol byte[cur_byte],1 |
rcl eax,1 |
.dec: |
dec [bits] |
jnz .loop1 |
.push: |
push dword[esi] |
pop [cur_byte] |
mov [bits],8 |
inc esi |
.loop1: |
loop .shift |
pop ecx |
ret |
PngStore: |
push esi |
cmp [PNG_info.Bit_depth],8 |
jbe .lo |
add esi,3 |
.lo: |
if ~ SYS eq win |
mov esi,[esi] |
bswap esi |
shr esi,8 |
mov [edi],esi |
add edi,3 |
else |
movsw |
movsb |
end if |
pop esi |
ret |
FiltStats: |
pusha |
xor ebx,ebx |
mov edx,23 |
mov ecx,6 |
.lp: |
push ecx edx |
Msg edx |
mov eax,[filters+ebx*4] |
DebugPrintDec |
pop edx ecx |
inc edx |
inc ebx |
loop .lp |
Newline |
popa |
ret |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/archer/trunk/sys.inc |
---|
0,0 → 1,326 |
; @RCHER system-dependent and other stuff |
; Written in pure assembler by Ivushkin Andrey aka Willow |
OpenFile: |
mov [outp],output |
mov esi,area |
and [Finfo.block],0 |
if SYS eq win |
invoke CreateFile, filename, GENERIC_READ, FILE_SHARE_READ, NULL, \ |
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL |
inc eax |
test eax,eax |
jz .ex |
dec eax |
mov [hnd],eax |
invoke GetFileSize,eax,NULL |
.ex: |
mov ebx,eax |
mov [filesize],eax |
else |
mcall 58,Finfo |
mov [filesize],ebx |
end if |
ret |
ResetFile: |
and [file_count],0 |
mov eax,[arc_base] |
xor ebx,ebx |
mov esi,area |
call FileSeek |
ret |
FileSeek: |
; eax - offset |
; esi - current pointer (in memory!) |
; ebx - translation method: 0 - beginning, 1 - current, 2 - end |
push eax ecx edx |
mov edx,[Finfo.block] |
imul edx,BSIZE |
sub esi,BUFPTR |
add esi,edx |
cmp ebx,1 |
je .cur |
jb .begin |
mov esi,[filesize] |
not eax |
.cur: |
add eax,esi |
.begin: |
mov ecx,BSIZE |
xor edx,edx |
div ecx |
lea esi,[BUFPTR+edx] |
mov [Finfo.block],eax |
if SYS eq win |
mul ecx |
invoke SetFilePointer,[hnd],eax,NULL,FILE_BEGIN |
invoke ReadFile,[hnd],area,INBUF, os_work, NULL |
; add [byte_count],area |
else |
; pregs |
; wait |
mov [Finfo.count],BUFSIZE*2 |
mcall 58,Finfo |
; mov [byte_count],area+INBUF |
end if |
pop edx ecx eax |
ret |
macro QueryFile |
{ |
local ex |
if SYS eq win |
invoke GetOpenFileName,ofstruc |
else |
opendialog draw_window,QFok,QFcanc,filename |
QFok: |
xor eax,eax |
jmp ex |
ret |
QFcanc: |
mov eax,1 |
end if |
ex: |
} |
RunViewer: |
test [Flags],PNG_MODE |
jz .ex |
if SYS eq win |
mov eax,[PNG_info.Width] |
call int2str |
invoke WritePrivateProfileString,ini_sec,ini_rwidth,os_work,ini_file |
mov eax,[PNG_info.Height] |
call int2str |
invoke WritePrivateProfileString,ini_sec,ini_rheight,os_work,ini_file |
invoke CreateProcess,NULL,iview_cmd,NULL,NULL,TRUE,\ |
NORMAL_PRIORITY_CLASS,NULL,NULL,suinfo,pinfo |
invoke WaitForInputIdle,dword[pinfo],0xFFFFFFFF |
invoke FindWindowEx, NULL,NULL,NULL,rawwnd_txt |
invoke FindWindowEx, eax,NULL,NULL,ok_txt |
invoke SendMessage,eax,BM_CLICK,NULL,NULL |
else |
test [Flags],THREAD_YES |
jnz .ex |
mcall 51,1,thread,MEMORY |
mov [child],eax |
end if |
.ex: |
ret |
if SYS eq win |
int2str: |
; in: eax - number |
; out: formatted string -> os_work |
invoke wsprintf,os_work,fmt_str,eax |
add esp,12 |
ret |
rawwnd_txt db 'Set RAW open parameters',0 |
ok_txt db 'OK',0 |
ini_sec db 'RAW',0 |
ini_rwidth db 'RWidth',0 |
ini_rheight db 'RHeight',0 |
ini_file db "C:\Program Files\IrfanView\i_view32.ini",0 |
fmt_str db "%d",0 |
iview_cmd db '"C:\Program Files\IrfanView\i_view32.exe"' |
db ' "D:\Ivushkin\projects\zip\output.raw"',0 |
filt_str: |
db 'Pictures (*.png)',0,'*.png',0 |
db 'Archives (*.zip;*.*gz)',0,'*.zip;*.*gz',0 |
db 'All files (*.*)',0,'*.*',0,0 |
suinfo STARTUPINFO |
pinfo PROCESS_INFORMATION |
cpstruc: |
ofstruc: |
dd ofstruc_end-ofstruc |
dd NULL |
dd NULL |
dd filt_str |
dd NULL |
dd NULL |
dd 0 |
dd filename |
dd 256 |
dd NULL |
dd 0 |
dd NULL |
dd NULL |
dd NULL |
dw NULL |
dw NULL |
dd NULL |
dd NULL |
dd NULL |
dd NULL |
dd NULL |
dd NULL |
dd NULL |
ofstruc_end: |
else |
mov ebx,-1 |
mov ecx,ebx |
mov edx,[PNG_info.Width] |
add edx,10 |
mov esi,[PNG_info.Width] |
add esi,30 |
mcall 67 |
mcall 7,outfile,[outfile.size],10 shl 16+15 |
.ex: |
ret |
MIN_WIDTH equ 300 |
thread: |
.red: |
mcall 12,1 |
mov ebx,[PNG_info.Width] |
cmp ebx,MIN_WIDTH |
jae .more |
mov ebx,MIN_WIDTH |
.more: |
add ebx,20 |
mov ecx,[PNG_info.Height] |
add ecx,30 |
mcall 0,,,0x3808080 |
mcall 4,<5,7>,0x10f0f0f0,filename,255 |
mov ecx,[PNG_info.Width] |
shl ecx,16 |
add ecx,[PNG_info.Height] |
mcall 7,png_image,,10 shl 16+25 |
mcall 12,2 |
.still: |
mcall 10 |
cmp eax,1 |
je .red |
cmp eax,2 |
jne .nokey |
mcall 2 |
cmp ah,27 ; Esc - close |
je .close |
jmp .still |
.nokey: |
cmp eax,3 |
jne .still |
.close: |
and [child],0 |
mcall -1 |
KillViewer: |
pusha |
mov edi,[child] |
test edi,edi |
jz .noth |
mcall 9,os_work,-1 |
mov ecx,eax |
.fchild: |
push ecx |
mcall 9,os_work |
cmp edi,[ebx+30] |
jne .lp |
mov ecx,[esp] |
mcall 18,2 |
pop ecx |
jmp .noth |
.lp: |
pop ecx |
loop .fchild |
.noth: |
popa |
ret |
macro CmdLine |
{ |
mov esi,PARAM_PTR |
.parse: |
lodsb |
test al,al |
jnz .noend |
or [Flags],STAY_MODE |
jmp red |
.noend: |
cmp al,' ' |
je .stay |
cmp al,'/' |
jne .yespar |
mov ecx,255 |
dec esi |
mov edi,filename |
xor al,al |
rep stosb |
mov ecx,255 |
mov edi,filename |
rep movsb |
jmp again |
.yespar: |
cmp al,'N' |
jne .nonum |
call get_6ASCII_num |
.fnum: |
mov [FileNum],eax |
jmp .parse |
.nonum: |
cmp al,'n' |
jne .nonum2 |
lodsd |
jmp .fnum |
.nonum2: |
cmp al,'s' |
jne .nostay |
.stay: |
or [Flags],STAY_MODE |
jmp .parse |
.nostay: |
cmp al,'i' |
jne .noclPID |
lodsd |
mov [clientPID],eax |
or [Flags],IPC_MODE |
jmp .parse |
.noclPID: |
cmp al,'R' |
jne .noraw |
or [Flags],RAW_MODE |
jmp .parse |
.noraw: |
cmp al,'q' |
jne .noofs |
lodsd |
.fofs: |
mov [arc_base],eax |
jmp .parse |
.noofs: |
cmp al,'Q' |
jne .noofs2 |
call get_6ASCII_num |
jmp .fofs |
.noofs2: |
jmp .parse |
get_6ASCII_num: |
; in: esi - str ptr, out: eax - num |
xor edx,edx |
mov ebx,10 |
mov ecx,6 |
.lp: |
xor eax,eax |
lodsb |
sub al,'0' |
imul edx,ebx |
add edx,eax |
loop .lp |
mov eax,edx |
ret |
} |
StartPad: |
mcall 19,editorcmd,dumpfile |
ret |
editorcmd db 'TINYPAD ' |
end if |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/cmd/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm cmd.asm cmd |
@pause |
/programs/develop/cmd/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm cmd.asm cmd |
@pause |
/programs/develop/cmd/trunk/cmd.asm |
---|
0,0 → 1,2967 |
; CMD - Command line interpreter |
; copyleft Chemist dmitry_gt@tut.by |
; |
; Compile with FASM for Menuet |
; |
; |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd START |
dd I_END |
dd 0x300000 |
dd 0x7fff0 |
dd 0x0 |
dd 0x0 |
include "macros.inc" |
START: |
call cmdexist |
call draw |
call fill |
call clearcmd |
call autoexec |
call ppr |
call cursor |
still: |
mov eax,10 |
int 0x40 |
cmp eax,1 |
je re |
cmp eax,2 |
je key |
cmp eax,3 |
je button |
jmp still |
button: |
mov eax,17 |
int 0x40 |
cmp ah,1 |
jne noclose |
jmp exit |
noclose: |
jmp still |
re: |
call draw |
call red |
jmp still |
red: |
call cls1 |
mov dword [xpos],24 |
mov dword [linev],2000 |
mov eax,dword [ypos] |
push eax |
mov dword [ypos],6 |
mov ecx,dword [lpress] |
loop1: |
push ecx |
mov eax,4 |
mov ebx,[ypos] |
shl ebx,16 |
add ebx,[xpos] |
mov ecx,0x00ddeeff |
mov edx,tic_table |
add edx,dword [linev] |
mov esi,81 |
int 0x40 |
add dword [xpos],10 |
add dword [linev],81 |
pop ecx |
loop loop1 |
sub dword [xpos],10 |
no_line: |
pop eax |
mov dword [ypos],eax |
no_red: |
ret |
key: |
mov eax,2 |
int 0x40 |
cmp ah,27 |
jne no_escape |
mov dword [ypos],42 |
call clearstr |
call ppr |
mov dword [count],0 |
call cursor |
jmp still |
no_escape: |
cmp ah,178 |
jne no_aup |
cmp dword [count],0 |
jne no_aup |
cmp dword [oldcount],0 |
je no_aup |
call clearsum |
sub dword [ypos],6 |
cld |
mov ecx,81 |
mov edi,tic_table+600 |
mov esi,tic_table+900 |
rep movsb |
cld |
mov ecx,dword [oldcount] |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,tic_table+600 |
rep movsb |
call red |
mov eax,dword [oldcount] |
mov dword [count],eax |
add dword [linen],eax |
add dword [linel],eax |
mov ebx,6 |
imul ebx,eax |
add dword [ypos],ebx |
call cursor |
jmp still |
no_aup: |
cmp ah,8 |
jne no_backspace |
cmp dword [count],0 |
je still |
cmp dword [count],0 |
je no_backspace |
call clearsum |
sub dword [ypos],12 |
call clearsum |
sub dword [ypos],6 |
call cursor |
dec dword [count] |
jmp still |
no_backspace: |
cmp ah,13 |
jne no_enter |
cmp dword [count],0 |
jne enter_ok |
call clearsum |
jmp ecmd2 |
enter_ok: |
call checkcmd |
cmp byte [tic_table+600],'/' |
jne no_script |
cmp dword [count],1 |
je nparam5 |
jmp command |
no_script: |
call oldcmd |
call checkprg |
jmp ecmd2 |
no_enter: |
cmp ah,176 ; Arrow keys, HOME, END, and DEL are unsupported now |
je still |
cmp ah,179 |
je still |
cmp ah,177 |
je still |
cmp ah,178 |
je still |
cmp ah,182 |
je still |
cmp ah,180 |
je still |
cmp ah,181 |
je still |
cmp dword [count],74 |
je still |
mov byte [smb],ah |
mov edi,tic_table+600 |
add edi,dword [count] |
mov esi,smb |
movsb |
inc dword [count] |
call clearsum |
sub dword [ypos],6 |
call print |
add dword [ypos],6 |
call cursor |
jmp still |
clearstr: |
mov dword [ypos],6 |
mov dword [clr],480 |
call clear |
mov eax,dword [linel] |
sub dword [linen],eax |
mov dword [linel],0 |
mov ecx,eax |
push eax |
loop4: |
push ecx |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,fill1 |
movsb |
inc dword [linen] |
pop ecx |
loop loop4 |
pop eax |
sub dword [linen],eax |
mov dword [ypos],42 |
ret |
clearsum: |
mov dword [clr],6 |
call clear |
dec dword [linen] |
dec dword [linel] |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,fill1 |
movsb |
ret |
clear: |
mov eax,13 |
mov ebx,[ypos] |
shl ebx,16 |
add ebx,[clr] |
mov ecx,[xpos] |
shl ecx,16 |
add ecx,9 |
mov edx,0 |
int 0x40 |
add dword [ypos],6 |
ret |
draw: |
mov eax,12 |
mov ebx,1 |
int 0x40 |
mov eax,0 |
mov ebx,100*65536+492 |
mov ecx,100*65536+280 |
mov edx,0 |
mov esi,0x805080d0 |
mov edi,0x005080d0 |
int 0x40 |
mov eax,4 |
mov ebx,8*65536+8 |
mov ecx,0x10ddeeff |
mov edx,title |
mov esi,title_end-title |
int 0x40 |
mov eax,8 |
mov ebx,(492-19)*65536+12 |
mov ecx,5*65536+12 |
mov edx,1 |
mov esi,0x6688dd |
int 0x40 |
mov eax,12 |
mov ebx,2 |
int 0x40 |
ret |
print: |
mov eax,4 |
mov ebx,[ypos] |
shl ebx,16 |
add ebx,[xpos] |
mov ecx,0x00ddeeff |
mov edx,smb |
mov esi,1 |
int 0x40 |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,smb |
movsb |
inc dword [linen] |
inc dword [linel] |
ret |
cursor: |
mov eax,4 |
mov ebx,[ypos] |
shl ebx,16 |
add ebx,[xpos] |
mov ecx,0x00ddeeff |
mov edx,smb_cursor |
mov esi,1 |
int 0x40 |
mov edi,tic_table |
mov esi,smb_cursor |
add edi,dword [linen] |
movsb |
inc dword [linen] |
inc dword [linel] |
ret |
ppr: |
mov eax,4 |
mov ebx,6 |
shl ebx,16 |
add ebx,[xpos] |
mov ecx,0x00ddeeff |
mov edx,prompt |
mov esi,5 |
int 0x40 |
mov dword [ypos],42 |
cld |
mov ecx,5 |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,prompt |
rep movsb |
add dword [linen],6 |
add dword [linel],6 |
ret |
help: |
cmp byte [callp],1 |
je gonext8 |
call clearsum |
gonext8: |
call newline |
call newline |
mov edx,h1 |
call printf |
call newline |
mov edx,h2 |
call printf |
call newline |
call newline |
mov edx,h3 |
call printf |
call newline |
call newline |
mov edx,h4 |
call printf |
call newline |
mov edx,h5 |
call printf |
call newline |
mov edx,h6 |
call printf |
call newline |
mov edx,h7 |
call printf |
call newline |
call newline |
mov edx,h8 |
call printf |
call newline |
mov edx,h9 |
call printf |
call newline |
mov edx,h10 |
call printf |
call newline |
mov edx,h11 |
call printf |
call newline |
mov edx,h12 |
call printf |
call newline |
mov edx,h13 |
call printf |
call newline |
call newline |
mov edx,h14 |
call printf |
call newline |
call newline |
mov edx,h15 |
call printf |
call newline |
mov edx,h16 |
call printf |
call newline |
cmp byte [callp],1 |
je go |
jmp ecmd |
ver: |
cmp byte [callp],1 |
je gonext7 |
call clearsum |
gonext7: |
call newline |
mov edx,about |
call printf |
cmp byte [callp],1 |
je go |
jmp ecmd |
pause1: |
cmp byte [callp],1 |
je gonext1 |
call clearsum |
gonext1: |
call pause2 |
cmp byte [callp],1 |
je go |
jmp ecmd |
ls: |
call oldcmd |
call cls2 |
loopls: |
inc dword [blockcnt] |
mov eax,34 |
mov ebx,0 |
mov ecx,0 |
mov edx,0 |
add edx,dword [blockcnt] |
mov esi,1 |
mov edi,tic_table+7000 |
int 0x40 |
mov ecx,16 |
loop40: |
push ecx |
cld |
mov ecx,8 |
mov edi,filename |
mov esi,tic_table |
add esi,dword [lscnt] |
rep movsb |
add dword [lscnt],8 |
mov edi,filename+8 |
mov esi,ddot |
movsb |
cld |
mov ecx,3 |
mov edi,filename+9 |
mov esi,tic_table |
add esi,dword [lscnt] |
rep movsb |
cmp byte [filename+10],0 |
jne no_fn_space1 |
mov edi,filename+10 |
mov esi,dzero |
movsb |
no_fn_space1: |
cmp byte [filename],0xe5 ; deleted file |
je no_newline |
cmp byte [filename],0xf ; long fat32 filename |
je no_newline |
cmp byte [filename],0x10 ; folder |
je no_newline |
cmp word [filename],'AK' |
jne filename_ok |
cmp byte [filename+3],'e' |
jne filename_ok |
cmp byte [filename+5],'y' |
jne filename_ok |
cmp byte [filename+7],'a' |
jne filename_ok |
cmp byte [filename+10],'s' |
jne filename_ok |
jmp no_newline |
filename_ok: |
mov eax,6 |
mov ebx,filename |
mov ecx,0 |
mov edx,-1 |
mov esi,tic_table+25000 |
int 0x40 |
cmp eax,4294967295 |
jne ls_print |
jmp no_newline |
ls_print_done: |
inc byte [lscntf] |
add dword [ypos],96 |
cmp byte [lscntf],5 |
jne no_newline |
mov byte [lscntf],0 |
inc byte [lscntx] |
cmp byte [lscntx],23 |
je pause2n |
mov dword [ypos],6 |
call newline |
no_newline: |
add dword [lscnt],24 |
pop ecx |
dec ecx |
cmp ecx,0 |
jne loop40 |
cmp dword [blockcnt],16 |
je ls_end |
jmp no_pause2 |
pause2n: |
mov byte [lscntx],0 |
call newline |
call pause2 |
call cls2 |
mov dword [lscnt],8024 |
jmp loopls |
no_pause2: |
mov dword [lscnt],8024 |
jmp loopls |
ls_end: |
mov dword [blockcnt],0 |
mov dword [lscnt],8024 |
mov byte [lscntf],0 |
mov byte [lscntx],0 |
cmp byte [callp],1 |
je go |
jmp ecmd2 |
ls_print: |
mov edi,filename+8 |
mov esi,fill1 |
movsb |
mov eax,4 |
mov ebx,[ypos] |
shl ebx,16 |
add ebx,[xpos] |
mov edx,filename |
mov ecx,0x00ddeeff |
mov esi,12 |
int 0x40 |
cld |
mov ecx,12 |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,filename |
rep movsb |
add dword [linen],16 |
add dword [linel],16 |
jmp ls_print_done |
lscheck: |
cmp byte [callp],1 |
je gonext9 |
call clearsum |
gonext9: |
sub dword [count],3 |
cld |
mov ecx,dword [count] |
mov edi,tic_table+400 |
mov esi,tic_table+600 |
add esi,3 |
rep movsb |
mov ebx,tic_table+400 |
push esi edi ecx eax |
mov esi,ebx |
mov edi,tic_table+400 |
mov ecx,70 |
strup2: |
mov al,[esi] |
cmp al,'A' |
jb @f |
cmp al,'z' |
ja @f |
cmp al,'a' |
jb @f |
add al,-0x20 |
@@: |
mov [edi],al |
inc esi |
inc edi |
dec ecx |
jnz strup2 |
pop eax ecx edi esi |
mov ecx,dword [count] |
looplsc: |
cmp byte [tic_table+400+ecx],'.' |
je chdot |
loop looplsc |
jmp chnodot |
chdot: |
mov ebx,dword [count] |
cld |
mov ecx,5 |
mov edi,tic_table+400 |
add edi,ebx |
mov esi,dzero |
rep movsb |
mov eax,6 |
mov ebx,tic_table+400 |
mov ecx,0 |
mov edx,-1 |
mov esi,tic_table+25000 |
int 0x40 |
cmp eax,4294967295 |
je nosuchfile |
jmp lschok |
chnodot: |
mov ebx,dword [count] |
mov edi,tic_table+400 |
add edi,ebx |
mov esi,ddot |
movsb |
inc ebx |
cld |
mov ecx,3 |
mov edi,tic_table+400 |
add edi,ebx |
mov esi,fill3 |
rep movsb |
mov eax,6 |
mov ebx,tic_table+400 |
mov ecx,0 |
mov edx,-1 |
mov esi,tic_table+25000 |
int 0x40 |
cmp eax,4294967295 |
je nosuchfile |
mov edi,tic_table+400 |
add edi,dword [count] |
mov esi,fill1 |
movsb |
lschok: |
call newline |
mov eax,4 |
mov ebx,6 |
shl ebx,16 |
add ebx,[xpos] |
mov edx,tic_table+400 |
mov esi,12 |
mov ecx,0x00ddeeff |
int 0x40 |
cld |
mov ecx,12 |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,tic_table+400 |
rep movsb |
add dword [linen],12 |
add dword [linel],12 |
add dword [count],3 |
cmp byte [callp],1 |
je go |
jmp ecmd |
ps: |
call oldcmd |
call cls2 |
call newline |
mov edx,proc_head |
call printf |
call newline |
mov edx,proc_hd11 |
call printf |
call newline |
call newline |
mov eax,9 |
mov ebx,tic_table |
mov ecx,1 |
int 0x40 |
mov dword [count2],eax |
ll1: |
inc dword [pn] |
mov eax,9 |
mov ebx,tic_table |
mov ecx,[pn] |
int 0x40 |
mov ebx,[tic_table+30] |
mov dword [fnumb],4 |
mov dword [ypos],6 |
call decnumb |
cld |
mov ecx,4 |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,tic_table+200 |
rep movsb |
add dword [linen],5 |
add dword [linel],5 |
cld |
mov ecx,11 |
mov esi,tic_table+10 |
mov edi,pname |
rep movsb |
mov dword [ypos],36 |
mov edx,pname |
mov eax,4 |
mov ebx,[ypos] |
shl ebx,16 |
add ebx,[xpos] |
mov ecx,0x00ddeeff |
mov esi,12 |
int 0x40 |
cld |
mov ecx,11 |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,pname |
rep movsb |
add dword [linen],10 |
add dword [linel],10 |
mov dword [ypos],94 |
mov ebx,[tic_table+22] |
mov dword [fnumb],8 |
call decnumb |
cld |
mov ecx,8 |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,tic_table+200 |
rep movsb |
add dword [linen],10 |
add dword [linel],10 |
mov dword [ypos],154 |
mov ebx,[tic_table+26] |
mov dword [fnumb],8 |
call decnumb |
cld |
mov ecx,8 |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,tic_table+200 |
rep movsb |
add dword [linen],12 |
add dword [linel],12 |
mov dword [ypos],228 |
mov ebx,[pn] |
mov dword [fnumb],4 |
call decnumb |
cld |
mov ecx,4 |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,tic_table+200 |
rep movsb |
add dword [linel],4 |
add dword [linen],4 |
call newline |
mov dword [ypos],60 |
cmp dword [xpos],254 |
jne nscreen |
call pause2 |
call cls2 |
mov dword [xpos],24 |
call newline |
mov dword [ypos],60 |
mov edx,proc_head |
call printf |
call newline |
mov edx,proc_hd11 |
call printf |
call newline |
call newline |
nscreen: |
mov eax, dword [count2] |
cmp dword [pn],eax |
jne ll1 |
mov dword [pn],0 |
cmp byte [callp],1 |
je go |
jmp ecmd2 |
printn: |
mov eax,47 |
shl ebx,16 |
mov edx,[ypos] |
shl edx,16 |
add edx,[xpos] |
mov esi,0x00ddeeff |
int 0x40 |
ret |
pause2: |
call newline |
mov edx,mess1 |
call printf |
mov eax,10 |
int 0x40 |
red3: |
cmp eax,2 |
je back |
cmp eax,3 |
je exit |
call draw |
call red |
mov eax,10 |
int 0x40 |
jmp red3 |
back: |
mov eax,2 |
int 0x40 |
cmp ah,27 |
je checmd |
ret |
exit: |
mov eax,-1 |
int 0x40 |
checmd: |
cmp byte [callp],1 |
je ecmd3 |
jmp ecmd |
err: |
call clearsum |
call newline |
call ppr |
cmp dword [count],0 |
je ecmd1 |
mov edx,err1 |
mov eax,4 |
mov ebx,[ypos] |
shl ebx,16 |
add ebx,[xpos] |
mov ecx,0x00ddeeff |
mov esi,27 |
int 0x40 |
cld |
mov ecx,27 |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,err1 |
rep movsb |
add dword [linen],27 |
add dword [linel],27 |
call clearcmd |
jmp cmd_ok2 |
nparam: |
cmp byte [callp],1 |
je gonext4 |
call clearsum |
gonext4: |
call newline |
mov edx,mess2 |
call printf |
cmp byte [callp],1 |
je go |
jmp ecmd |
nparam2: |
cmp byte [callp],1 |
je gonext3 |
call clearsum |
gonext3: |
call newline |
mov edx,mess5 |
call printf |
cmp byte [callp],0 |
je ecmd |
jmp go |
cp: |
cmp byte [callp],1 |
je gonext10 |
call clearsum |
gonext10: |
sub dword [count],3 |
cld |
mov ecx,dword [count] |
mov edi,tic_table+400 |
mov esi,tic_table+600 |
add esi,3 |
rep movsb |
mov ecx,12 |
loop50: |
cmp byte [tic_table+400+ecx],'+' |
je file2 |
loop loop50 |
add dword [count],3 |
jmp nparam3 |
file2: |
mov dword [f1len],ecx |
inc ecx |
mov ebx,ecx |
cld |
mov edi,tic_table+9000 |
mov esi,tic_table+400 |
rep movsb |
mov ecx,12 |
mov edi,tic_table+9100 |
mov esi,tic_table+400 |
add esi,ebx |
rep movsb |
mov ebx,tic_table+9000 |
push esi edi ecx eax |
mov esi,ebx |
mov edi,tic_table+9000 |
mov ecx,12 |
strup3: |
mov al,[esi] |
cmp al,'A' |
jb @f |
cmp al,'z' |
ja @f |
cmp al,'a' |
jb @f |
add al,-0x20 |
@@: |
mov [edi],al |
inc esi |
inc edi |
dec ecx |
jnz strup3 |
pop eax ecx edi esi |
mov ecx,dword [f1len] |
loopcp: |
cmp byte [tic_table+9000+ecx],'.' |
je chdotcp |
loop loopcp |
jmp chnodotcp |
chdotcp: |
mov ebx,dword [f1len] |
cld |
mov ecx,4 |
mov edi,tic_table+9000 |
add edi,ebx |
mov esi,dzero |
rep movsb |
jmp gocp1 |
chnodotcp: |
mov ebx,dword [f1len] |
mov edi,tic_table+9000 |
add edi,ebx |
mov esi,ddot |
movsb |
inc ebx |
cld |
mov ecx,3 |
mov edi,tic_table+9000 |
add edi,ebx |
mov esi,fill3 |
rep movsb |
gocp1: |
mov eax,6 |
mov ebx,tic_table+9000 |
mov ecx,0 |
mov edx,-1 |
mov esi,tic_table+25000 |
int 0x40 |
cmp eax,4294967295 |
je nosuchfile |
mov dword [filesize],eax |
mov ebx,tic_table+9100 |
push esi edi ecx eax |
mov esi,ebx |
mov edi,tic_table+9100 |
mov ecx,12 |
strup4: |
mov al,[esi] |
cmp al,'A' |
jb @f |
cmp al,'z' |
ja @f |
cmp al,'a' |
jb @f |
add al,-0x20 |
@@: |
mov [edi],al |
inc esi |
inc edi |
dec ecx |
jnz strup4 |
pop eax ecx edi esi |
mov ebx,dword [f1len] |
mov ecx,dword [count] |
sub ecx,ebx |
mov dword [f2len],ecx |
loopcp2: |
cmp byte [tic_table+9100+ecx],'.' |
je chdotcp2 |
loop loopcp2 |
jmp chnodotcp2 |
chdotcp2: |
mov ebx,dword [f2len] |
cld |
mov ecx,4 |
mov edi,tic_table+9100 |
add edi,ebx |
mov esi,dzero |
rep movsb |
jmp gocp2 |
chnodotcp2: |
mov ebx,dword [f2len] |
mov edi,tic_table+9100 |
add edi,ebx |
mov esi,ddot |
movsb |
inc ebx |
cld |
mov ecx,3 |
mov edi,tic_table+9100 |
add edi,ebx |
mov esi,fill3 |
rep movsb |
gocp2: |
mov eax,6 |
mov ebx,tic_table+9100 |
mov ecx,0 |
mov edx,-1 |
mov esi,tic_table+25000 |
int 0x40 |
cmp eax,4294967295 |
jne alreadyexist |
mov eax,33 |
mov ebx,tic_table+9100 |
mov ecx,tic_table+25000 |
mov edx,dword [filesize] |
mov esi,0 |
int 0x40 |
cmp eax,0 |
jne no_ok |
mov eax,6 |
mov ebx,tic_table+9100 |
mov ecx,0 |
mov edx,-1 |
mov esi,tic_table+25000 |
int 0x40 |
cmp eax,4294967295 |
je no_ok |
call newline |
mov edx,mess11 |
call printf |
jmp cp_end |
no_ok: |
call newline |
mov edx,mess12 |
call printf |
cp_end: |
add dword [count],3 |
cmp byte [callp],1 |
je go |
jmp ecmd |
alreadyexist: |
add dword [count],3 |
call newline |
mov edx,mess13 |
call printf |
cmp byte [callp],1 |
je go |
jmp ecmd |
rn: |
cmp byte [callp],1 |
je gonext11 |
call clearsum |
gonext11: |
sub dword [count],3 |
cld |
mov ecx,dword [count] |
mov edi,tic_table+400 |
mov esi,tic_table+600 |
add esi,3 |
rep movsb |
mov ecx,12 |
loop51: |
push ecx |
cmp byte [tic_table+400+ecx],'+' |
je file3 |
pop ecx |
loop loop51 |
add dword [count],3 |
jmp nparam4 |
file3: |
mov dword [f1len],ecx |
inc ecx |
mov ebx,ecx |
cld |
mov edi,tic_table+9000 |
mov esi,tic_table+400 |
rep movsb |
mov ecx,12 |
mov edi,tic_table+9100 |
mov esi,tic_table+400 |
add esi,ebx |
rep movsb |
mov ebx,tic_table+9000 |
push esi edi ecx eax |
mov esi,ebx |
mov edi,tic_table+9000 |
mov ecx,12 |
strup5: |
mov al,[esi] |
cmp al,'A' |
jb @f |
cmp al,'z' |
ja @f |
cmp al,'a' |
jb @f |
add al,-0x20 |
@@: |
mov [edi],al |
inc esi |
inc edi |
dec ecx |
jnz strup5 |
pop eax ecx edi esi |
mov ecx,dword [f1len] |
looprn: |
cmp byte [tic_table+9000+ecx],'.' |
je chdotrn |
loop looprn |
jmp chnodotrn |
chdotrn: |
mov ebx,dword [f1len] |
cld |
mov ecx,4 |
mov edi,tic_table+9000 |
add edi,ebx |
mov esi,dzero |
rep movsb |
jmp gorn1 |
chnodotrn: |
mov ebx,dword [f1len] |
mov edi,tic_table+9000 |
add edi,ebx |
mov esi,ddot |
movsb |
inc ebx |
cld |
mov ecx,3 |
mov edi,tic_table+9000 |
add edi,ebx |
mov esi,fill3 |
rep movsb |
gorn1: |
mov eax,6 |
mov ebx,tic_table+9000 |
mov ecx,0 |
mov edx,-1 |
mov esi,tic_table+25000 |
int 0x40 |
cmp eax,4294967295 |
je nosuchfile |
mov ebx,tic_table+9100 |
push esi edi ecx eax |
mov esi,ebx |
mov edi,tic_table+9100 |
mov ecx,12 |
strup6: |
mov al,[esi] |
cmp al,'A' |
jb @f |
cmp al,'z' |
ja @f |
cmp al,'a' |
jb @f |
add al,-0x20 |
@@: |
mov [edi],al |
inc esi |
inc edi |
dec ecx |
jnz strup6 |
pop eax ecx edi esi |
mov ebx,dword [f1len] |
mov ecx,dword [count] |
sub ecx,ebx |
mov dword [f2len],ecx |
looprn2: |
cmp byte [tic_table+9100+ecx],'.' |
je chdotrn2 |
loop looprn2 |
jmp chnodotrn2 |
chdotrn2: |
mov ebx,dword [f2len] |
cld |
mov ecx,4 |
mov edi,tic_table+9100 |
add edi,ebx |
mov esi,dzero |
rep movsb |
jmp gorn2 |
chnodotrn2: |
mov ebx,dword [f2len] |
mov edi,tic_table+9100 |
add edi,ebx |
mov esi,ddot |
movsb |
inc ebx |
cld |
mov ecx,3 |
mov edi,tic_table+9100 |
add edi,ebx |
mov esi,fill3 |
rep movsb |
gorn2: |
mov eax,6 |
mov ebx,tic_table+9100 |
mov ecx,0 |
mov edx,-1 |
mov esi,tic_table+25000 |
int 0x40 |
cmp eax,4294967295 |
jne alreadyexist |
mov eax,6 |
mov ebx,tic_table+9000 |
mov ecx,0 |
mov edx,-1 |
mov esi,tic_table+25000 |
int 0x40 |
mov dword [filesize],eax |
mov eax,33 |
mov ebx,tic_table+9100 |
mov ecx,tic_table+25000 |
mov edx,dword [filesize] |
mov esi,0 |
int 0x40 |
cmp eax,0 |
jne no_ok1 |
mov eax,6 |
mov ebx,tic_table+9100 |
mov ecx,0 |
mov edx,-1 |
mov esi,tic_table+25000 |
int 0x40 |
cmp eax,4294967295 |
je no_ok1 |
mov eax,32 |
mov ebx,tic_table+9000 |
int 0x40 |
call newline |
mov edx,mess14 |
call printf |
jmp rn_end |
no_ok1: |
call newline |
mov edx,mess15 |
call printf |
rn_end: |
add dword [count],3 |
cmp byte [callp],1 |
je go |
jmp ecmd |
del: |
cmp byte [callp],1 |
je gonext12 |
call clearsum |
gonext12: |
sub dword [count],4 |
cld |
mov ecx,dword [count] |
mov edi,tic_table+400 |
mov esi,tic_table+600 |
add esi,4 |
rep movsb |
mov ebx,tic_table+400 |
push esi edi ecx eax |
mov esi,ebx |
mov edi,tic_table+400 |
mov ecx,70 |
strup1: |
mov al,[esi] |
cmp al,'A' |
jb @f |
cmp al,'z' |
ja @f |
cmp al,'a' |
jb @f |
add al,-0x20 |
@@: |
mov [edi],al |
inc esi |
inc edi |
dec ecx |
jnz strup1 |
pop eax ecx edi esi |
mov ecx,dword [count] |
loopdel: |
cmp byte [tic_table+400+ecx],'.' |
je chdotdel |
loop loopdel |
jmp chnodotdel |
chdotdel: |
mov ebx,dword [count] |
cld |
mov ecx,4 |
mov edi,tic_table+400 |
add edi,ebx |
mov esi,dzero |
rep movsb |
jmp godel |
chnodotdel: |
mov ebx,dword [count] |
mov edi,tic_table+400 |
add edi,ebx |
mov esi,ddot |
movsb |
inc ebx |
cld |
mov ecx,3 |
mov edi,tic_table+400 |
add edi,ebx |
mov esi,fill3 |
rep movsb |
godel: |
mov eax,6 |
mov ebx,tic_table+400 |
mov ecx,0 |
mov edx,-1 |
mov esi,tic_table+25000 |
int 0x40 |
cmp eax,4294967295 |
je nosuchfile2 |
mov eax,32 |
mov ebx,tic_table+400 |
int 0x40 |
call newline |
mov edx,mess6 |
call printf |
add dword [count],4 |
del_end: |
add dword [count],4 |
cmp byte [callp],1 |
je go |
jmp ecmd |
nosuchfile: |
add dword [count],3 |
call newline |
mov edx,mess7 |
call printf |
cmp byte [callp],0 |
je ecmd |
jmp go |
nosuchfile2: |
add dword [count],4 |
call newline |
mov edx,mess7 |
call printf |
cmp byte [callp],1 |
je go |
jmp ecmd |
nosuchfile3: |
inc dword [count] |
call newline |
mov edx,mess7 |
call printf |
jmp ecmd |
autoexec: |
mov eax,6 |
mov ebx,autoexfile |
mov ecx,0 |
mov edx,-1 |
mov esi,tic_table+15000 |
int 0x40 |
cmp eax,4294967295 |
je noaxfile |
sub dword [linen],81 |
sub dword [xpos],10 |
dec dword [lpress] |
jmp autolabel |
noaxfile: |
ret |
command: |
call clearsum |
dec dword [count] |
cld |
mov ecx,dword [count] |
mov edi,filename |
mov esi,tic_table+601 |
rep movsb |
mov ebx,filename |
push esi edi ecx eax |
mov esi,ebx |
mov edi,filename |
mov ecx,12 |
strup7: |
mov al,[esi] |
cmp al,'A' |
jb @f |
cmp al,'z' |
ja @f |
cmp al,'a' |
jb @f |
add al,-0x20 |
@@: |
mov [edi],al |
inc esi |
inc edi |
dec ecx |
jnz strup7 |
pop eax ecx edi esi |
cld |
mov ecx,4 |
mov edi,filename+8 |
mov esi,dcmd |
rep movsb |
mov eax,6 |
mov ebx,filename |
mov ecx,0 |
mov edx,-1 |
mov esi,tic_table+15000 |
int 0x40 |
cmp eax,4294967295 |
je nosuchfile3 |
autolabel: |
mov dword [filesize2],eax |
mov byte [callp],1 |
go: |
call clearcmd |
gonext: |
cmp dword [filesize2],0 |
je ecmd3 |
mov ebx,tic_table |
add ebx,dword [readcnt] |
cmp byte [ebx],13 |
je read |
inc dword [readcnt] |
inc dword [readcnt2] |
dec dword [filesize2] |
jmp gonext |
read: |
mov ecx,dword [readcnt2] |
mov ebx,0 |
mov edx,dword [readcnt] |
sub edx,dword [readcnt2] |
loop60: |
push ecx |
mov edi,tic_table+600 |
add edi,ebx |
mov esi,tic_table |
add esi,edx |
movsb |
inc ebx |
inc edx |
pop ecx |
loop loop60 |
mov eax,dword [readcnt2] |
mov dword [count],eax |
mov dword [readcnt2],0 |
add dword [readcnt],2 |
jmp checkcmd |
decnumb: |
cmp dword [fnumb],4 |
je go1 |
call divide |
mov dword [n8],edx |
mov ebx,eax |
call divide |
mov dword [n7],edx |
mov ebx,eax |
call divide |
mov dword [n6],edx |
mov ebx,eax |
call divide |
mov dword [n5],edx |
mov ebx,eax |
go1: |
call divide |
mov dword [n4],edx |
mov ebx,eax |
call divide |
mov dword [n3],edx |
mov ebx,eax |
call divide |
mov dword [n2],edx |
mov ebx,eax |
call divide |
mov dword [n1],edx |
add dword [n1],48 |
add dword [n2],48 |
add dword [n3],48 |
add dword [n4],48 |
cmp dword [fnumb],4 |
je go2 |
add dword [n5],48 |
add dword [n6],48 |
add dword [n7],48 |
add dword [n8],48 |
go2: |
mov edi,tic_table+200 |
mov esi,n1 |
movsb |
mov edi,tic_table+201 |
mov esi,n2 |
movsb |
mov edi,tic_table+202 |
mov esi,n3 |
movsb |
mov edi,tic_table+203 |
mov esi,n4 |
movsb |
cmp dword [fnumb],4 |
je go4 |
mov edi,tic_table+204 |
mov esi,n5 |
movsb |
mov edi,tic_table+205 |
mov esi,n6 |
movsb |
mov edi,tic_table+206 |
mov esi,n7 |
movsb |
mov edi,tic_table+207 |
mov esi,n8 |
movsb |
go4: |
mov eax,4 |
mov ebx,[ypos] |
shl ebx,16 |
add ebx,[xpos] |
mov ecx,0x00ddeeff |
mov edx,tic_table+200 |
mov esi,dword [fnumb] |
int 0x40 |
ret |
divide: |
mov eax,ebx |
xor edx,edx |
mov ecx,10 |
div ecx |
ret |
kill: |
mov eax,0 |
mov ebx,0 |
mov ecx,0 |
mov edx,0 |
mov al, byte [tic_table+608] |
mov bl, byte [tic_table+607] |
mov cl, byte [tic_table+606] |
mov dl, byte [tic_table+605] |
sub al,48 |
sub bl,48 |
sub cl,48 |
sub dl,48 |
imul ebx,10 |
imul ecx,100 |
imul edx,1000 |
mov esi,0 |
add esi,eax |
add esi,ebx |
add esi,ecx |
add esi,edx |
mov ecx,esi |
mov eax,9 |
mov ebx,tic_table |
int 0x40 |
cmp eax,ecx |
jb nosuchprocess |
mov eax,18 |
mov ebx,2 |
mov edx,0 |
int 0x40 |
call clearsum |
call newline |
mov edx,mess3 |
call printf |
call newline |
mov edx,mess4 |
call printf |
cmp byte [callp],1 |
je go |
jmp ecmd |
ecmd1: |
sub dword [xpos],10 |
jmp ecmd |
nosuchprocess: |
call clearsum |
call newline |
mov edx,mess8 |
call printf |
cmp byte [callp],1 |
je go |
jmp ecmd |
echoeol: |
cmp byte [callp],1 |
je gonext15 |
call clearsum |
gonext15: |
call newline |
cmp byte [callp],1 |
je go |
jmp ecmd |
echo: |
cmp byte [callp],1 |
je gonext13 |
call clearsum |
gonext13: |
sub dword [count],5 |
cld |
mov ecx,dword [count] |
mov edi,tic_table+300 |
mov esi,tic_table+600 |
add esi,5 |
rep movsb |
call newline |
mov eax,4 |
mov ebx,6 |
shl ebx,16 |
add ebx,[xpos] |
mov edx,tic_table+300 |
mov ecx,0x00ddeeff |
mov esi,dword [count] |
int 0x40 |
cld |
mov ecx,dword [count] |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,tic_table+300 |
rep movsb |
mov eax,dword [count] |
add dword [linen],eax |
add dword [linel],eax |
add dword [count],5 |
cmp byte [callp],1 |
je go |
jmp ecmd |
printf: |
mov eax,4 |
mov ebx,6 |
shl ebx,16 |
add ebx,[xpos] |
mov ecx,0x00ddeeff |
mov esi,45 |
int 0x40 |
cld |
mov ecx,45 |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,edx |
rep movsb |
add dword [linen],46 |
add dword [linel],46 |
add dword [ypos],6 |
ret |
printipc: |
mov eax,4 |
mov ebx,6 |
shl ebx,16 |
add ebx,[xpos] |
mov ecx,0x00ddeeff |
mov esi,79 |
int 0x40 |
cld |
mov ecx,79 |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,edx |
rep movsb |
add dword [linen],80 |
add dword [linel],80 |
mov dword [ypos],480 |
ret |
clearcmd: |
cld |
mov ecx,80 |
mov edi,tic_table+600 |
mov esi,tic_table+500 |
rep movsb |
mov ecx,80 |
mov edi,tic_table+400 |
mov esi,tic_table+500 |
rep movsb |
mov ecx,81 |
mov edi,tic_table+800 |
mov [esi],byte 'x' |
rep movsb |
mov ecx,12 |
mov edi,filename |
mov esi,pname |
rep movsb |
mov dword [count],0 |
mov dword [pn],0 |
mov dword [blockcnt],0 |
mov dword [lscnt],8024 |
ret |
oldcmd: |
mov eax,dword [count] |
mov dword [oldcount],eax |
cld |
mov ecx,81 |
mov edi,tic_table+900 |
mov esi,tic_table+500 |
rep movsb |
cld |
mov ecx,81 |
mov edi,tic_table+900 |
mov esi,tic_table+600 |
rep movsb |
ret |
ecmd: |
call oldcmd |
call clearcmd |
call newline |
call ppr |
call cursor |
jmp still |
ecmd2: |
call clearcmd |
call newline |
call ppr |
call cursor |
jmp still |
ecmd3: |
call clearcmd |
call newline |
call ppr |
call cursor |
mov dword [readcnt],15000 |
mov dword [readcnt2],0 |
mov byte [callp],0 |
mov dword [filesize2],0 |
jmp still |
chparam: |
pop ecx |
mov eax,ecx |
mov edx,eax |
push edx |
inc eax |
cld |
mov edi,tic_table+400 |
mov esi,tic_table+600 |
rep movsb |
mov ecx,dword [count] |
sub ecx,eax |
cld |
mov edi,tic_table+800 |
mov esi,tic_table+600 |
add esi,eax |
rep movsb |
pop edx |
mov dword [ipccount],edx |
cld |
mov ecx,11 |
mov edi,tic_table+400 |
add edi,edx |
mov esi,qspace |
rep movsb |
mov eax,19 |
mov ebx,tic_table+400 |
mov ecx,tic_table+800 |
int 0x40 |
cmp eax,0xfffffff0 |
jb cmd_ok |
jmp err |
cls: |
call oldcmd |
call cls2 |
cmp byte [callp],0 |
jne needret |
call clearcmd |
call ppr |
call cursor |
jmp still |
needret: |
sub dword [linen],81 |
dec dword [lpress] |
sub dword [xpos],10 |
jmp gonext |
cls1: |
mov eax,13 |
mov ebx,6*65536+486 |
mov ecx,24*65536+250 |
mov edx,0 |
int 0x40 |
ret |
cls2: |
mov dword [linen],2000 |
mov ecx,2025 |
loop2: |
push ecx |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,fill1 |
movsb |
inc dword [linen] |
pop ecx |
loop loop2 |
mov dword [linel],0 |
mov dword [linen],2000 |
mov dword [linev],2000 |
mov dword [xpos],24 |
mov dword [ypos],6 |
mov dword [lpress],1 |
mov dword [stnum],1 |
call cls1 |
ret |
chscr: |
cmp dword [xpos],264 |
jne no_scr |
mov dword [cnt_loop1],4500 |
mov dword [cnt_loop2],2000 |
mov ecx,2025 |
loop10: |
push ecx |
mov edi,tic_table |
add edi,dword [cnt_loop1] |
mov esi,tic_table |
add esi,dword [cnt_loop2] |
movsb |
inc dword [cnt_loop1] |
inc dword [cnt_loop2] |
pop ecx |
loop loop10 |
mov dword [cnt_loop1],2000 |
mov ecx,2025 |
loop11: |
push ecx |
mov edi,tic_table |
add edi,dword [cnt_loop1] |
mov esi,fill1 |
movsb |
inc dword [cnt_loop1] |
pop ecx |
loop loop11 |
mov dword [cnt_loop1],2000 |
mov dword [cnt_loop2],4581 |
mov ecx,1944 |
loop12: |
push ecx |
mov edi,tic_table |
add edi,dword [cnt_loop1] |
mov esi,tic_table |
add esi,dword [cnt_loop2] |
movsb |
inc dword [cnt_loop1] |
inc dword [cnt_loop2] |
pop ecx |
loop loop12 |
dec dword [lpress] |
sub dword [linen],81 |
mov dword [xpos],264 |
mov dword [ypos],6 |
mov dword [clr],480 |
call clear |
call red |
no_scr: |
ret |
newline: |
call chscr |
push edx |
mov edx,81 |
sub edx,dword [linel] |
add dword [linen],edx |
pop edx |
inc dword [lpress] |
mov dword [linel],0 |
add dword [xpos],10 |
ret |
fill: |
cld |
mov ecx,81 |
mov edi,tic_table+500 |
mov esi,fill1 |
rep movsb |
ret |
nparam3: |
cmp byte [callp],1 |
je gonext5 |
call clearsum |
gonext5: |
call newline |
mov edx,mess9 |
call printf |
cmp byte [callp],1 |
je go |
jmp ecmd |
nparam4: |
cmp byte [callp],1 |
je gonext6 |
call clearsum |
gonext6: |
call newline |
mov edx,mess0 |
call printf |
cmp byte [callp],1 |
je go |
jmp ecmd |
nparam5: |
cmp byte [callp],1 |
je gonext14 |
call clearsum |
gonext14: |
call newline |
mov edx,mess16 |
call printf |
jmp ecmd |
endscr: |
cmp byte [callp],1 |
je ecmd3 |
call clearsum |
call newline |
mov edx,mess17 |
call printf |
jmp ecmd |
checkcmd: |
cmp dword [tic_table+600],'help' |
jne no_help |
cmp dword [count],4 |
jne no_help |
jmp help |
no_help: |
cmp dword [tic_table+600],'exit' |
jne no_exit |
cmp dword [count],4 |
jne no_exit |
jmp exit |
no_exit: |
cmp word [tic_table+600],'ve' |
jne no_ver |
cmp byte [tic_table+602],'r' |
jne no_ver |
cmp dword [count],3 |
jne no_ver |
jmp ver |
no_ver: |
cmp word [tic_table+600],'cl' |
jne no_cls |
cmp byte [tic_table+602],'s' |
jne no_cls |
cmp dword [count],3 |
jne no_cls |
jmp cls |
no_cls: |
cmp dword [tic_table+600],'shut' |
jne no_shutdown |
cmp dword [tic_table+604],'down' |
jne no_shutdown |
cmp dword [count],8 |
jne no_shutdown |
mov eax,18 |
mov ebx,1 |
int 0x40 |
mov eax,5 |
mov ebx,200 |
int 0x40 |
no_shutdown: |
cmp word [tic_table+600],'ps' |
jne no_ps |
cmp dword [count],2 |
je ps |
no_ps: |
cmp dword [tic_table+600],'kill' |
jne no_kill |
cmp byte [tic_table+604],' ' |
jne no_kill |
cmp dword [count],9 |
je kill |
jmp nparam |
no_kill: |
cmp dword [tic_table+600],'paus' |
jne no_pause |
cmp byte [tic_table+604],'e' |
jne no_pause |
cmp dword [count],5 |
je pause1 |
no_pause: |
cmp dword [tic_table+600],'echo' |
jne no_echo |
cmp dword [count],4 |
je echoeol |
cmp byte [tic_table+604],' ' |
je echo |
no_echo: |
cmp word [tic_table+600],'de' |
jne no_del |
cmp byte [tic_table+602],'l' |
jne no_del |
cmp byte [tic_table+603],' ' |
jne no_del |
cmp dword [count],3 |
je nparam2 |
cmp dword [count],4 |
je nparam2 |
jmp del |
no_del: |
cmp word [tic_table+600],'ls' |
jne no_ls |
cmp dword [count],2 |
je ls |
cmp dword [count],3 |
je ls |
jmp lscheck |
no_ls: |
cmp word [tic_table+600],'cp' |
jne no_cp |
cmp dword [count],2 |
je nparam3 |
cmp dword [count],3 |
je nparam3 |
cmp dword [count],4 |
je nparam3 |
cmp dword [count],5 |
je nparam3 |
cmp byte [tic_table+602],' ' |
jne no_cp |
jmp cp |
no_cp: |
cmp word [tic_table+600],'rn' |
jne no_rn |
cmp dword [count],2 |
je nparam4 |
cmp dword [count],3 |
je nparam4 |
cmp dword [count],4 |
je nparam4 |
cmp dword [count],5 |
je nparam4 |
cmp byte [tic_table+602],' ' |
jne no_rn |
jmp rn |
no_rn: |
cmp dword [tic_table+600],'ends' |
jne no_end |
cmp dword [count],4 |
je endscr |
no_end: |
cmp byte [callp],1 |
je checkprg |
ret |
checkprg: |
mov ebx,tic_table+600 |
push esi edi ecx eax |
mov esi,ebx |
mov edi,tic_table+600 |
mov ecx,74 |
strup: |
mov al,[esi] |
cmp al,'A' |
jb @f |
cmp al,'z' |
ja @f |
cmp al,'a' |
jb @f |
add al,-0x20 |
@@: |
mov [edi],al |
inc esi |
inc edi |
dec ecx |
jnz strup |
pop eax ecx edi esi |
mov ecx,dword [count] |
loop20: |
push ecx |
cmp byte [tic_table+600+ecx],'&' |
je chparam |
pop ecx |
loop loop20 |
cld |
mov ecx,11 |
mov edi,tic_table+600 |
add edi,dword [count] |
mov esi,qspace |
rep movsb |
mov eax,19 |
mov ebx,tic_table+600 |
mov ecx,0 |
int 0x40 |
cmp eax,0xfffffff0 |
jb cmd_ok_1 |
jmp err |
cmd_ok_1: |
mov eax,dword [count] |
mov dword [ipccount],eax |
cmd_ok: |
mov eax,60 |
mov ebx,1 |
mov ecx,ipcb |
mov edx,118 |
int 0x40 |
call clearipc |
mov eax,40 |
mov ebx,01000111b |
int 0x40 |
mov eax,23 |
mov ebx,10 |
int 0x40 |
cmp eax,7 |
jne noipc |
cmp byte [callp],1 |
je printipcprgname |
call clearsum |
ipccontinue: |
mov eax,9 |
mov ebx,tic_table+100000 |
mov ecx,-1 |
int 0x40 |
mov ecx,eax |
loopfindipc: |
push ecx |
mov eax,9 |
mov ebx,tic_table+100000 |
int 0x40 |
mov bl,[tic_table+600] |
cmp byte [tic_table+100000+10],bl |
jne goonipc |
cmp dword [ipccount],1 |
je ipcfinished |
mov bl,[tic_table+601] |
cmp byte [tic_table+100000+11],bl |
jne goonipc |
cmp dword [ipccount],2 |
je ipcfinished |
mov bl,[tic_table+602] |
cmp byte [tic_table+100000+12],bl |
jne goonipc |
cmp dword [ipccount],3 |
je ipcfinished |
mov bl,[tic_table+603] |
cmp byte [tic_table+100000+13],bl |
jne goonipc |
cmp dword [ipccount],4 |
je ipcfinished |
mov bl,[tic_table+604] |
cmp byte [tic_table+100000+14],bl |
jne goonipc |
cmp dword [ipccount],5 |
je ipcfinished |
mov bl,[tic_table+605] |
cmp byte [tic_table+100000+15],bl |
jne goonipc |
cmp dword [ipccount],6 |
je ipcfinished |
mov bl,[tic_table+606] |
cmp byte [tic_table+100000+16],bl |
jne goonipc |
cmp dword [ipccount],7 |
je ipcfinished |
mov bl,[tic_table+607] |
cmp byte [tic_table+100000+17],bl |
jne goonipc |
goonipc: |
pop ecx |
dec ecx |
jnz loopfindipc |
ipcfinished: |
mov ebx,[tic_table+100000+30] |
mov dword [ipcpid],ebx |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [ipcpid] |
mov edx,ddot |
mov esi,1 |
int 0x40 |
call newline |
call clearipc |
jmp waitipc |
printipcprgname: |
call newline |
call printcmd |
jmp ipccontinue |
noipc: |
cmp byte [callp],1 |
je prtcmd |
call clearsum |
jmp cmd_ok2 |
printcmd: |
mov eax,4 |
mov ebx,6 |
shl ebx,16 |
add ebx,[xpos] |
mov edx,tic_table+600 |
mov ecx,0x00ddeeff |
mov esi,dword [count] |
int 0x40 |
cld |
mov ecx,dword [count] |
mov edi,tic_table |
add edi,dword [linen] |
mov esi,tic_table+600 |
rep movsb |
mov eax,dword [count] |
add dword [linen],eax |
add dword [linel],eax |
ret |
prtcmd: |
call newline |
call printcmd |
jmp go |
cmd_ok2: |
cmp byte [callp],1 |
je go |
ret |
waitipc: |
mov eax,40 |
mov ebx,01000111b |
int 0x40 |
mov eax,10 |
int 0x40 |
cmp eax,7 |
je ipcok |
cmp eax,1 |
je reipc |
cmp eax,3 |
je exit |
cmp eax,2 |
je keyipc |
jmp waitipc |
keyipc: |
mov eax,2 |
int 0x40 |
jmp waitipc |
reipc: |
call draw |
call red |
jmp waitipc |
clearipc: |
cld |
mov ecx,118 |
mov edi,ipcb |
mov esi,ipcc |
rep movsb |
ret |
ipcok: |
cmp dword [ipcb+16],'~ccc' |
je ipccls |
cmp dword [ipcb+16],'~eee' |
je endipc |
cmp dword [ipcb+16],'~lll' |
je ipcline |
cmp dword [ipcb+16],'~ppp' |
je ipcprint |
cmp dword [ipcb+16],'~kkk' |
je ipckey |
jmp waitipc |
reipc2: |
call draw |
call red |
ipckey: |
mov eax,10 |
int 0x40 |
cmp eax,1 |
je reipc2 |
cmp eax,3 |
je exit |
cmp eax,2 |
je ipckeypressed |
jmp ipckey |
ipckeypressed: |
mov eax,2 |
int 0x40 |
mov byte [ipckeyvalue],ah |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [ipcpid] |
mov edx,ipckeyvalue |
mov esi,1 |
int 0x40 |
call clearipc |
jmp waitipc |
ipccls: |
call cls2 |
call clearipc |
jmp waitipc |
ipcline: |
call newline |
call clearipc |
jmp waitipc |
ipcprint: |
mov edx,ipcb+20 |
call printipc |
call clearipc |
jmp waitipc |
endipc: |
cmp byte [callp],1 |
je go |
call clearsum |
jmp ecmd |
cmdexist: |
mov eax,9 |
mov ebx,tic_table |
mov ecx,-1 |
int 0x40 |
mov ecx,eax |
loopex: |
push ecx |
mov eax,9 |
mov ebx,I_END |
int 0x40 |
cmp word [I_END+10],'CM' |
jne no_cmd |
cmp byte [I_END+12],'D' |
jne no_cmd |
inc byte [cmd_ex] |
cmp byte [cmd_ex],2 |
je exit |
no_cmd: |
pop ecx |
loop loopex |
ret |
title: |
db 'CMD - Command line interpreter' |
title_end: |
smb_cursor db '|' |
prompt db 'CMD>>' |
h1 db ' CMD - Command line interpreter version 0.26 ' |
h2 db ' copyleft Chemist - dmitry_gt@tut.by ' |
h3 db ' Available commands: ' |
h4 db ' HELP - Display this text LS - List files ' |
h5 db ' EXIT - Exit Programm CP - Copy file ' |
h6 db ' CLS - Clear Screen PS - Process info ' |
h7 db ' KILL - Kill Process RN - Rename File ' |
h8 db ' VER - Display programm version ' |
h9 db ' DEL - Delete file from ramdisk ' |
h10 db ' SHUTDOWN - Quit Menuet ' |
h11 db ' PAUSE - Wait for keypress ' |
h12 db ' ECHO - Print text to screen ' |
h13 db ' ENDS - End script ' |
h14 db ' /[filename] - Execute script ' |
h15 db ' Use & symbol to enter params: ' |
h16 db ' tinypad&cmd.asm - open cmd.asm ' |
about db 'Command Line Interpreter version 0.26 ' |
err1 db 'Unknown command or filename' |
proc_head db ' PID Name Start Length Proc_NUMB ' |
proc_hd11 db '-------------------------------------------- ' |
mess1 db 'Press any key to continue (ESC - Cancel)... ' |
mess2 db 'Plz specify a 4 byte process number (not PID) ' |
mess3 db 'Process with number you specified has been ' |
mess4 db 'terminated. ' |
mess5 db 'Usage: del [filename] ' |
mess6 db 'Filename you specified has been deleted. ' |
mess7 db 'No such file! ' |
mess8 db 'No such process! ' |
mess9 db 'Usage: cp [source_file+destination_file] ' |
mess0 db 'Usage: rn [source_file+destination_file] ' |
mess11 db 'File successfully copied ' |
mess12 db 'ERROR: Can not copy file! ' |
mess13 db 'ERROR: Output file alredy exist! ' |
mess14 db 'File successfully renamed ' |
mess15 db 'ERROR: Can not rename file! ' |
mess16 db 'You must specify a command script filename! ' |
mess17 db 'This command is available only in scripts! ' |
linen dd 2000 |
lpress dd 1 |
linel dd 0 |
linev dd 2000 |
stnum dd 1 |
rdstat dd 0 |
ypos dd 6 |
xpos dd 24 |
count dd 0 |
clr dd 0 |
smb db 0 |
pn dd 0 |
count2 dd 0 |
count3 dd 9 |
oldcount dd 0 |
oldcount1 dd 0 |
fnumb dd 0 |
n1 dd 0 |
n2 dd 0 |
n3 dd 0 |
n4 dd 0 |
n5 dd 0 |
n6 dd 0 |
n7 dd 0 |
n8 dd 0 |
ddot db '.' |
dcmd db '.CMD',0 |
cnt_loop1 dd 0 |
cnt_loop2 dd 0 |
lscnt dd 8024 |
blockcnt dd 0 |
lscntf db 0 |
lscntx db 0 |
filesize dd 0 |
filesize2 dd 0 |
readcnt dd 15000 |
readcnt2 dd 0 |
callp db 0 |
callp2 db 0 |
fill1 db ' ' |
fill3 db ' ',0 |
pname db ' ',0 |
autoexfile db 'AUTOEXEC.CMD',0 |
filename db ' ',0 |
dzero db 0,0,0,0 |
qspace db ' ' |
f1len dd 0 |
f2len dd 0 |
ipcpid dd 0 |
ipckeyvalue db 0 |
ipccount dd 0 |
cmd_ex db 0 |
ipcb: |
db 0 |
db 0,0,0 |
dd 8 |
times 110 db 0 |
ipcc: |
db 0 |
db 0,0,0 |
dd 8 |
times 110 db 0 |
I_END: |
tic_table: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/cmd/trunk/cmdipc.inc |
---|
0,0 → 1,221 |
include "macros.inc" |
initipc: |
mov eax,9 |
mov ebx,prc |
mov ecx,-1 |
int 0x40 |
mov ecx,eax |
loop1: |
push ecx |
mov eax,9 |
mov ebx,prc |
int 0x40 |
cmp word [prc+10],'CM' |
jne no_cmd |
cmp byte [prc+12],'D' |
jne no_cmd |
mov ebx,[prc+30] |
mov dword [cmdpid],ebx |
mov dword [cmdnumb],ecx |
no_cmd: |
pop ecx |
loop loop1 |
cmp dword [cmdpid],0 |
jne no_exit |
jmp exit |
no_exit: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,printf |
mov esi,4 |
int 0x40 |
call initcmd |
waitcmdinit: |
mov eax,40 |
mov ebx,01000000b |
int 0x40 |
mov eax,23 |
mov ebx,100 |
int 0x40 |
cmp eax,7 |
je cmd_ok |
jmp exit |
cmd_ok: |
cmp byte [ipcb+16],'.' |
jne exit |
mov eax,18 |
mov ebx,3 |
mov ecx,dword [cmdnumb] |
int 0x40 |
ret |
pause1: |
mov eax,5 |
mov ebx,1 |
int 0x40 |
ret |
exit: |
mov eax,-1 |
int 0x40 |
cls: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipccls |
mov esi,4 |
int 0x40 |
call pause1 |
ret |
print: |
mov ecx,84 |
loopprt: |
mov edi,stripc |
add edi,ecx |
mov esi,fill_symbol |
movsb |
loop loopprt |
cld |
mov ecx,4 |
mov edi,stripc |
mov esi,printf |
rep movsb |
cld |
mov edx,79 |
sub edx,eax |
mov ecx,79 |
sub ecx,edx |
mov edi,stripc+4 |
mov esi,ebx |
rep movsb |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,stripc |
mov esi,84 |
int 0x40 |
call pause1 |
ret |
eol: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipceol |
mov esi,4 |
int 0x40 |
call pause1 |
ret |
initcmd: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipckey |
mov esi,4 |
int 0x40 |
mov eax,60 |
mov ebx,1 |
mov ecx,ipcb |
mov edx,28 |
int 0x40 |
cld |
mov ecx,28 |
mov edi,ipcb |
mov esi,ipcc |
rep movsb |
ret |
getkey: |
call initcmd |
waitagain: |
mov eax,40 |
mov ebx,01000000b |
int 0x40 |
mov eax,10 |
int 0x40 |
cmp eax,7 |
jne waitagain |
mov edi,key |
mov esi,ipcb+16 |
movsb |
ret |
endipc: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipcend |
mov esi,4 |
int 0x40 |
jmp exit |
cmdpid dd 0 |
cmdnumb dd 0 |
printf db '~ppp' |
ipceol db '~lll' |
ipcend db '~eee' |
ipccls db '~ccc' |
ipckey db '~kkk' |
key db 0 |
ipcb: |
db 0 |
db 0,0,0 |
dd 8 |
times 20 db 0 |
ipcc: |
db 0 |
db 0,0,0 |
dd 8 |
times 20 db 0 |
stripc: times 84 db 0 |
fill_symbol db 0 |
prc: times 52 db 0 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/cmd/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/cmd/trunk/readme.txt |
---|
0,0 → 1,381 |
CMD - Èíòåðïðåòàòîð êîìàíäíîé ñòðîêè äëÿ Menuet |
Íàïèñàíî by Chemist dmitry_gt@tut.by |
Âåðñèÿ 0.27 |
Ðóññêèé òåêñò íåìíîãî ïîíèæå. |
----------------------------------------------------------------------- |
CMD - Command Line Interpreter for Menuet |
Copyleft Chemist - dmitry_gt@tut.by |
Version 0.27 |
As my english is not well, I will tell a few words about this |
program. It supports 14 commands, such as cp (copy file), |
rn (rename file), ps (process list), kill (kill process) etc. |
You can type 'help' after starting this shell to examine with |
other commands. Also it uses several special symbols, such as |
&, /, . and +. Use & sumbol to enter params. For example, |
type tinypad&cmd.asm to open cmd.asm file in tinypad editor. |
/ symbol is used to run special command scripts for CMD. |
It's syntax is: /filename without extension (For example, |
type /autoexec to execute autoexec.cmd file for CMD). And + |
symbol is used in cp and rn commands. You must type |
cp example.asm+example.bak to copy example.asm file to |
example.bak. Use dot to launch program, if CMD command and |
other external command match. For example, type help for |
'help' command or type .help to run 'help' program. |
This shell supports executeing special command |
scripts (something like .BAT files in MS-DOS). This files |
have an .CMD extinsion and u must use / symbol to execute it. |
U can use any CMD commands and filenames in this scripts. |
But you can't run other scripts from any CMD script (/ symbol). |
I recommed to use tipypad editor to edit this scripts and do |
not leave spaces and other symbols after commands in the script |
file, because it's executeing is not very developed yet. |
And it's strongly recommended to use ends command in the end |
of the script, because there are some problems with redrawing |
the window after executing scripts without this command. |
Every time when you launch CMD autoexec.cmd file automatically |
executes. You can edit or delete this file if you want. |
This version of CMD shell supports IPC. It mean, than you can |
write your own programs for this shell. Look at .ASM files in |
the Examples directory in this archive. I think that you will |
understand them without any difficulties. Do not forget, that |
you need CMDIPC.ASM file to compile this sources. It's |
recommended to compile it with MACROS.INC file (included in |
this archieve) to make their size smaller. |
And now about some bugs etc. |
---------------------------- |
I've noticed, that there are some difficulties with files with |
1 or 2 symbols in extension. I recommend do not use such files |
not only in CMD, but almost in every programs in MeOS. It's |
possible to create such file in tinypad, and then (in MS-DOS or |
Windows) Scandisk will find errors in filenames etc. CMD do |
not support properly such filenames now. |
In CMDIPC.INC and CMD.ASM I used 5-th function (pause), because |
I need it when CMD communicates with IPC programs. It's |
even possible, that it will not enough 1/100 sec. on slow PC's, |
because CMD need this time to finish IPC-command from other |
IPC-program. U can change ebx value in CMDIPC.ASM in pause1: |
if you want. But it slows communication betwen CMD and |
IPC-programs for CMD. I hope, that you understand my words. :) |
Now (in this version) you can launch only one CMD shell. |
Because it's difficult to make communication betwen several |
copyes of CMD in memory and IPC-programs. I will solve this |
problem in future. |
I've tested this shell only on Ivan Poddubny's russian |
distributive. Also I recommend you to use it. :) CMD shell |
is included into this distributive (but possible not it's |
final version). |
Source code of this program is not optimized yet. I have such |
manner of programming from my childhood that my source code |
is not very "compact" |
etc. ;-) |
And now other information: |
-------------------------- |
I do not want CMD design to change. I like white symbols on |
the black background. If you want to change the source and |
redistribute it, please, do not change it's design. :) |
If you will find some bugs or you have some wishes (or even you |
correct some mistakes in my english texts) - |
email me: dmitry_gt@tut.by |
And this program is distributed "as is". Use it on your own |
risk. ;-) |
And again - my English is not well. :) |
That's all! |
19.06.2004, |
Chemist |
Now russian text :) |
----------------------------------------------------------------------- |
Äîñòóïíûå êîìàíäû: |
ls [filename] - âûâîä ñïèñêà ôàéëîâ. Åñëè ïîñëå êîìàíäû |
óêàçàòü èìÿ ôàéëà, òî êîìàíäà ïðîâåðèò åãî |
íà íàëè÷èå. |
cp [source_file+destination_file] - êîìàíäà äëÿ |
êîïèðîâàíèÿ ôàéëîâ. Ïðîâåðÿåò ôàéëû íà |
íàëè÷èå, è â ñëó÷àå îøèáêè âûâîäèò |
ñîîòâåòñòâóþùèå ñîîáùåíèÿ. |
rn [source_file+destination_file] - êîìàíäà äëÿ |
ïåðåèìåíîâàíèÿ ôàéëîâ. Òàê æå |
ïðîâåðÿåò ôàéëû íà íàëè÷èå, è â |
ñëó÷àå îøèáêè âûâîäèò ñîîòâåòñòâóþùèå |
ñîîáùåíèÿ. |
ps - âûâîä èíôîðìàöèè î ïðîöåññàõ â ñèñòåìå. |
kill - ïðåðâàòü ïðîöåññ â ñèñòåìå. Âíèìàíèå, |
ïîñëå êîìàíäû ñëåäóåò ââîäèòü 4-õ |
çíà÷íûé íîìåð ïðîöåññà, à íå PID. Íîìåð |
ïðîöåññà óêàçàí â ïîñëåäíåé êîëîíêå ïðè |
âûçîâå êîìàíäû ps. |
help - âûâîä êðàòêîé ñïðàâî÷íîé èíôîðìàöèè. |
ver - âûâîä èñïîëüçóåìîé âåðñèè èíòåðïðåòàòîðà. |
cls - î÷èñòêà ýêðàíà. |
exit - âûõîä èç èíòåðïðåòàòîðà. |
del [filename] - óäàëèòü ôàéë ñ ðàìäèñêà. Ïðè îòñóòñòâèè |
çàïðàøèâàåìîãî ôàéëà áóäåò âûâåäåíî |
ñîîòâåòñòâóþùèå ñîîáùåíèå îá îøèáêå. |
shutdown - çàâåðøèòü ðàáîòó ñèñòåìû. |
pause - îæèäàòü íàæàòèå êëàâèøè. Èñïîëüçóåòñÿ äëÿ |
"âçàèìîäåéñòâèÿ" ïîëüçîâàòåëÿ ñ êîìàíäíûìè |
ñêðèïòàìè äëÿ êîíñîëè (èíòåðïðåòàòîðà). |
Íàïðèìåð, ìîæíî èñïîëüçîâàòü äàííûé ñêðèïò |
echo Do you want to delete cmd.asm? |
pause |
del cmd.asm |
äëÿ òîãî, ÷òîáû ïîèíòåðåñîâàòüñÿ ìíåíèåì |
ïîëüçîâàòåëÿ, õî÷åò ëè îí óäàëèòü ôàéë cmd.asm |
èëè ïðåðâàòü ðàáîòó ñêðèïòà. |
pause >nul Òî æå ñàìîå, òîëüêî áåç âûâîäà ñòðîêè |
'Press ane key to continue (ESC - cancel)' |
echo [text] - âûâîä òåêñòà íà ýêðàí. Ïðåäíàçíà÷åíà äëÿ |
ïîäà÷è ïîëüçîâàòåëþ èíôîðìàöèè èç êîìàíäíîãî |
ñêðèïòà. Åñëè ââåñòè êîìàíäó echo áåç òåêñòà, |
òî ýòî ïðîñòî âûçîâåò ïåðåõîä íà ñëåäóþùóþ |
ñòðîêó. |
ends - êîìàíäà, äîñòóïíàÿ òîëüêî èç èñïîëíÿåìûõ |
ñêðèïòîâ. Ñëóæèò äëÿ èõ êîððåêòíîãî çàâåðøåíèÿ, |
ò.ê. èíîãäà êîìàíäíûå ñêðèïòû, ó êîòîðûõ â |
êîíöå ñòîÿëè íåíóæíûå ïðîáåëû èëè ñèìâîëû EOL, |
âûçûâàëè ïðîáëåìû ñ ïåðåðèñîâêîé îêíà. Ñêîðåå |
âñåãî ýòà êîìàíäà ïðèñóòñòâóåò â êîíñîëè |
âðåìåííî è áóäåò óáðàíà ïîñëå ðåøåíèÿ ýòîé |
ïðîáëåìû. |
----------------------------------------------------------------------- |
Óïðàâëÿþùèå ñèìâîëû: |
/[êîìàíäíûé ñêðèïò] - ïðåäíàçíà÷åí äëÿ âûçîâà íà èñïîëíåíèå |
êîìàíäíîãî ñêðèïòà èç êîíñîëè. Íå ìîæåò |
èñïîëüçîâàòüñÿ â íåïîñðåäñòâåííî â ñàìèõ |
êîìàíäíûõ ñêðèïòàõ. Åñëè ðàñøèðåíèå èñïîë- |
íÿåìîãî ñêðèïòà .cmd, òî åãî óêàçûâàòü |
íåîáÿçàòåëüíî. |
& - äàííûé ñèìâîë èñïîëüçóåòñÿ äëÿ ïåðåäà÷è âûçûâàåìîé |
ïðîãðàììå ïàðàìåòðîâ. Íàïðèìåð, êîìàíäà tinypad&cmd.asm |
ïåðåäàñò ïðîãðàììå tinypad ïàðàìåòð cmd.asm, |
ñîîòâåòñòâåííî, tinypad îòêðîåò ôàéë cmd.asm. |
+ - ðàçäåëÿåò èìåíà èñõîäíîãî è ðåçóëüòèðóþùåãî ôàéëîâ â |
êîìàíäàõ cp è rn. |
. - çàïóñêàåò óêàçàííóþ ïîñëå òî÷êè ïðîãðàììó, äàæå åñëè îíà |
ñîâïàäàåò ñ êîìàíäîé CMD. Íàïðèìåð, help - âûïîëíèòü |
êîìàíäó 'help', íî .help - çàïóñòèòü âíåøíþþ ïðîãðàììó |
'help' (õîòÿ òàêîé ïîêà âðîäå è íåòó :). |
----------------------------------------------------------------------- |
Íàâèãàöèÿ ïî êîíñîëè: |
Äëÿ ðåäàêòèðîâàíèÿ êîìàíäíîé ñòðîêè èñïîëüçóþòñÿ êëàâèøè ESC, |
BACKSPACE. ESC - äëÿ óäàëåíèÿ âñåé êîìàíäíîé ñòðîêè, |
BACKSPACE - äëÿ óäàëåíèÿ ïîñëåäíåãî ââåäåííîãî ñèìâîëà. Ïî |
ìîåìó ìíåíèþ, èñïîëüçîâàíèå òàêèõ êëàâèø, êàê HOME, END, ARROW |
KEY etc. íå èìååò ñìûñëà, ò.ê. ââîäèìûå êîìàíäû ñëèøêîì |
ïðîñòû è íå òðåáóþò ïîäðîáíîãî ðåäàêòèðîâàíèÿ. Ïîýòîìó ÿ |
îñòàâèë âñå ïðèìåðíî òàê, êàê áûëî â MS-DOS 6.22. |
Êëàâèøà UPARROW èñïîëüçóåòñÿ äëÿ ïîâòîðà ïîñëåäíåé ââåäåííîé |
êîìàíäû. |
----------------------------------------------------------------------- |
Èñïîëüçîâàíèå IPC âî âíåøíèõ ïðîãðàììàõ: |
Âû ìîæåòå ïèñàòü ïðîãðàììû, âçàèìîäåéñòâóþùèå ñ CMD ÷åðåç IPC. |
 îñíîâíîì, ÿ ïîëàãàþ, ýòî ìîæåò ïðèãîäèòñÿ äëÿ íàïèñàíèÿ |
êîíñîëüíûõ ïðèëîæåíèé äëÿ ñàìîãî CMD (õîòÿ âîçìîæíî è äðóãîå). |
Äëÿ ýòîãî, ê âàøåé ïðîãðàììå âàì íåîáõðäèìî ïîäêëþ÷èòü ôàéë |
CMDIPC.INC (Åñòåñòâåííî, îò ýòîãî ðàçìåð ïðîãðàììû ïîñëå |
êîìïèëÿöèè íåñêîëüêî óâåëè÷èòñÿ). Ïîñëå ýòîãî âàì ñòàíóò |
äîñòóïíû 6 ôóíêöèè IPC, êîòîðûå âû ìîæåòå âûçûâàòü ñ ïîìîùüþ |
call èç ñâîåé æå ïðîãðàììû. Âîò èõ îïèñàíèå: |
--------------------------------------------------------------- |
initipc - èíèöèàëèçàöèÿ IPC äëÿ ðàáîòû ñ CMD. |
call initipc - èíèöèàëèçèðîâàòü IPC äëÿ ðàáîòû ñ CMD. |
ÂÍÈÌÀÍÈÅ! Èñïîëüçóéòå â ñàìîì íà÷àëå ïðîãðàììû. CMD áóäåò æäàòü |
òîëüêî 10/100 ñåêóíäû äëÿ òîãî, ÷òîáû ïîëó÷èòü |
ñîîáùåíèå ïî IPC (õîòÿ ýòîãî âïîëíå äîñòàòî÷íî). |
--------------------------------------------------------------- |
print - âûâåñòè ñòðîêó â ýêðàí CMD. |
mov eax,strlen |
mov ebx,string |
call print |
Ãäå strlen - äëèíà ñòðîêè â áàéòàõ, |
string - óêàçàòåëü íà ñòðîêó. |
call print - âûâîä ñòðîêè. |
--------------------------------------------------------------- |
cls - î÷èñòèòü ýêðàí CMD. |
call cls - âûçâàòü î÷èñòêó ýêðàíà. |
--------------------------------------------------------------- |
eol - ïðîïóñòèòü ñòðîêó. |
call eol - âûçâàòü ïðîïóñ ñòðîêè. |
--------------------------------------------------------------- |
getkey - ñ÷èòàòü êîä íàæàòîé êëàâèøè â CMD. |
call getkey - îæèäàòü íàæàòèÿ êëàâèøè è ñ÷èòàòü åå êîä. |
Âûâîä: byte [key] - êîä íàæàòîé êëàâèøè. |
ÂÍÈÌÀÍÈÅ: Ïîñëå çàïóñêà ïðîãðàììû èç CMD, êîòîðàÿ |
ïîääåðæèâàåò IPC, òî îêíî CMD àêòèâèðóåòñÿ ñðàçó |
ïîñëå çàïóñêà ïðîãðàììû. Ïîýòîìó, óæå íå íóæíî |
òûêàòü ìûøêîé íà îêíî äëÿ òîãî, ÷òîáû ââåñòè |
÷òî-íèáóäü â êîíñîëü, êàê ýòî áûëî â ïðîøëûõ âåðñèÿõ. |
--------------------------------------------------------------- |
endipc - Çàâåðøèòü ðàáîòó IPC-ïðîãðàììû. |
call endipc - çàâåðøèòü ïðîãðàììó. |
--------------------------------------------------------------- |
Âîîáùåì, âû ìîæåòå ïîñìîòðåòü ôàéë HELLO.ASM, êîòîðûé ëåæèò â |
ýòîì àðõèâå. Òàì âñå äîëæíî áûòü ïîíÿòíî. Åñòåñòâåííî, íèêòî |
âàì íå ìåøàåò èñïîëüçîâàòü ïàðàìåòðû â IPC-ïðîãðàììàõ äëÿ CMD. |
Ñìîòðèòå ïðèìåð PARAM.ASM. |
Êñòàòè, â ñàìîì CMD è â CMDIPC.INC èñïîëüçóåòñÿ 5-ÿ ôóíêöèÿ |
(ïàóçà) äëÿ òîãî, ÷òîáû äàòü âðåìÿ äðóã-äðóãó âûïîëíèòü |
òðåáóåìûå îò íèõ ÷åðåç IPC äåéñòâèÿ. È åñëè ó âàñ êîìï ñèëüíî |
òîðìîçíþ÷èé, òî âîçìîæíî, âûäåëåííîãî âðåìåíè áóäåò |
íåäîñòàòî÷íî. Ýòî íå ñëîæíî ïîëå÷èòü, óâåëè÷èâ çíà÷åíèå |
ebx ïåðåä âûçîâîì ôóíêöèè ÿäðà (eax,5 - ïàóçà). Â ïðîòèâíîì |
ñëó÷àå ìîãóò ïîâûëåòàòü âûçîâû IPC èëè ÷òî-íèáóäü âîîáùå |
çàâèñíåò (ïåðâîå - âåðîÿòíåå). Íî, åñòåñòâåííî, íè÷åãî |
ñòðàøíîãî â ýòîì íåò. ;-) |
----------------------------------------------------------------------- |
Èçâåñòíûå îøèáêè è íåäîðàáîòêè: |
Ïðè ðàáîòå ñ êîíñîëüþ CMD è ñèñòåìîé MenuetOS âîîáùå, ÿ |
çàìåòèë,÷òî íåêîòîðûå ñîçäàííûå â Menuet ôàéëû íå |
âîñïðèíèìàþòñÿ MS-DOS. Ýòî â ïåðâóþ î÷åðåäü êàñàåòñÿ ôàéëîâ, |
ñ èìåíàìè òèïà 1.1, b.bb è ò.ä. Ïîýòîìó âîçìîæíû ðàçëè÷íûå |
òóïèêîâûå ñèòóàöèè ïðè âçàèìîäåéñòâèè ñîçäàííûõ èëè |
êîïèðîâàííûõ ôàéëîâ â MeOS ñ âîñïðèÿòèåì èõ â MS-DOS è Windows |
ñèñòåìàõ. È êàñàåòñÿ ýòî íå òîëüêî CMD, íî, íàïðèìåð, è |
òèíèïàäà. Ïîýòîìó ÿ ðåêîìåíäóþ èñïîëüçîâàòü â Menuet ôàéëû èëè |
áåç ðàñøèðåíèÿ âîîáùå, èëè ñ ïîëíûì ðàñøèðåíèåì (çàíèìàþùèì |
âñå 3 áàéòà, ò.å. filename.ext, à íå filename.ex). Â ïðèíöèïå |
ìåõàíèçì êîìàíä LS, LS èìÿ_ôàéëà, CP, DEL è RN èçìåíåí, íî |
ïîêà íåò ñîâìåñòèìîñòè ìåæäó ðàçëè÷íûìè ïðîãðàììàìè, |
ðàáîòàþùèìè ñ ôàéëàìè â Menuet. Ò.å. äàæå âîçìîæíî, |
÷òî âû íå ñìîæåòå ðàáîòàòü â êîíñîëè ñ ôàéëîì, ñîçäàííîì â |
òèíèïàäå, à ïîòîì skandisk âîîáùå âûäàñò îøèáêó ïðè ïðîâåðêå |
ôàéëîâîé ñòðóêòóðû äèñêåòû, êîãäà íàòêíåòñÿ íà ýòîò ôàéë, è îí |
íå áóäåò ÷èòàåì èç windows èëè MS-DOS.  ïðèíöèïå, ÿ òåñòèðîâàë |
ïðîãðàììó òîëüêî íà ìîåì PC, ïîýòîìó âîçìîæíî âñ¸. :) |
P.S. Êîìàíäà LS ïîêàæåò ïîëíîñòüþ âñå ôàéëû íà ðàìäèñêå, â òîì |
÷èñëå òå, êîòîðûå ñîçäàíû íåïðàâèëüíî è íå áóäóò ðàáîòàòü â |
MS-DOS, LS èìÿ_ôàéëà è ò.ä. ìîæåò óæå èõ íå çàìåòèòü. Â |
ïðèíöèïå òàêàÿ æå êàðòèíà áóäåò è â windows. Ò.å. âû ñìîæåòå |
ëèöåçðåòü èìåíà ýòèõ ôàéëîâ, íàïðèìåð, â windows commander'e, |
íî áëîêíîò èõ íå îòêðîåò. |
Äëÿ òîãî, ÷òîáà äàòü âðåìÿ CMD îáðàáîòàòü IPC-çàïðîñ, â |
CMDIPC.ASM ìíå ïðèøëîñü èñïîëüçîâàòü 5-þ ôóíêöèþ (ïàóçà), |
ïîýòîìó íåìíîãî çàìåäëÿåòñÿ âðåìÿ ïîëó÷åíèÿ íîâûõ IPC-çàïðîñîâ. |
 äàííîé âåðñèè âû íå ìîæåòå çàïóñêàòü áîëüøå îäíîãî |
òåðìèíàëà CMD îäíîâðåìåííî. Ýòî ñâÿçàíî ñ òåì, ÷òî ÿ åùå íå |
äîáàâèë âîçìîæíîñòè ðàáîòû íåñêîëüêèõ êîíñîëåé ñ |
IPC-ïðîãðàììàìè îäíîâðåìåííî. |
Êîä ïðîãðàììû íà äàííûé ìîìåíò íåîïòèìèçèðîâàí. |
etc. :) |
----------------------------------------------------------------------- |
Âìåñòå ñ ïðîãðàììîé ïîñòàâëÿåòñÿ ôàéë autoexec.cmd, êîòîðûé |
àâòîìàòè÷åñêè èñïîëíÿåòñÿ ïðè çàïóñêå èíòåðïðåòàòîðà. Åãî |
ìîæíî óäàëèòü ïðè íåíàäîáíîñòè. |
Äëÿ âûçîâà ïðèìåðà èñïîëíÿåìîãî ñêðèïðà íàáåðèòå /example |
Âñâÿçè ñ ìîëîäîñòüþ è ÷àñòè÷íîé íåäîðàáîòàííîñòè ñàìîé |
ïðîãðàììû âîçìîæíû îøèáêè â å¸ ðàáîòå, î êîòîðûõ ïðîñüáà |
ñîîáùàòü íà dmitry_gt@tut.by |
 áëèæàéøåå âðåìÿ íå ïëàíèðóåòñÿ íîâûõ íîâîââåäåíèé â êîíñîëü, |
ò.ê. íà å¸ äîðàáîòêó óõîäèò ìíîãî âðåìåíè è ÿ ñ÷èòàþ, ÷òî îíà |
è íà äàííûé ìîìåíò áîëåå-ìåíåå ôóíêöèîíàëüíà (â ìàñøòàáàõ |
MenuetOS, êîíå÷íî). ß ñ÷èòàþ, ÷òî ðàöèîíàëüíåå áóäåò ñêîíöåíò- |
ðèðîâàòüñÿ íà óñòàíåíèè áàãîâ è íåäîðàáîòîê â ïðîãðàììå. |
Åñëè êòî-íèáóäü ïîæåëàåò äîäåëàòü ïðîãðàììó, òî ÿ áû ïîïðîñèë |
íå èçìåíÿòü å¸ äèçàéí (ìíå îí íðàâèòñÿ ;-) ). |
Î âñåõ îøèáêàõ ( òîì ÷èñëå ãðàììàòè÷åñêèõ â àíãëèéñêîì òåêñòå) |
ïðîñüáà ñîîáùàòü íà dmitry_gt@tut.by |
È åùå çàáûë ñêàçàòü, òî ïðîãðàììà ðàñïîñòðàíÿåòñÿ "as is", è |
àâòîð íå íåñåò îòâåòñòâåííîñòè çà âîçìîæíûé óùåðá, ïðè÷èíåííûé |
ïðîãðàììîé. |
19.06.2004, |
Chemist |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/circle/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm circle.asm circle |
@pause |
/programs/develop/examples/circle/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm circle.asm circle |
@pause |
/programs/develop/examples/circle/trunk/circle.asm |
---|
0,0 → 1,167 |
; |
; SHAPED WINDOW - BASIC EXAMPLE |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x1000 ; required amount of memory |
dd 0x1000 ; esp |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
call shape_window ; function for shaping |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne noclose |
mov eax,-1 ; close this program |
int 0x40 |
noclose: |
jmp still |
shape_window: |
pusha |
mov eax,50 ; give the shape reference area |
mov ebx,0 |
mov ecx,shape_reference |
int 0x40 |
mov eax,50 ; give the shape scale 32 x 32 -> 128 x 128 |
mov ebx,1 ; you dont have to give this, scale is 1:1 by default |
mov ecx,2 |
int 0x40 |
popa |
ret |
shape_reference: ; 32 x 32 ( window_size_X + 1 ) * ( window_size_Y + 1 ) |
db 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0 |
db 0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0 |
db 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0 |
db 0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0 |
db 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0 |
db 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0 |
db 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0 |
db 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0 |
db 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0 |
db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 |
db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0 |
db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0 |
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0 |
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0 |
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0 |
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0 |
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0 |
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0 |
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0 |
db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0 |
db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0 |
db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 |
db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 |
db 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0 |
db 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0 |
db 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0 |
db 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0 |
db 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0 |
db 0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0 |
db 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0 |
db 0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0 |
db 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0 |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536 ; [x start] *65536 + [x size] |
mov ecx,100*65536 ; [y start] *65536 + [y size] |
mov bx,word [x_size] |
mov cx,word [y_size] |
mov edx,0x00cccc00 ; color of work area RRGGBB,8->color glide |
mov esi,0x00cccc00 ; color of grab bar RRGGBB,8->color glide |
mov edi,0x00cccc00 ; color of frames RRGGBB |
int 0x40 |
; CLOSE BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,78*65536+12 ; [x start] *65536 + [x size] |
mov ecx,20*65536+12 ; [y start] *65536 + [y size] |
mov edx,1 ; button id |
mov esi,0x5599cc ; button color RRGGBB |
int 0x40 |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
; DATA AREA |
x_size dd 127 |
y_size dd 127 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/circle/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/example/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm example.asm example |
@pause |
/programs/develop/examples/example/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm example.asm example |
@pause |
/programs/develop/examples/example/trunk/example.asm |
---|
0,0 → 1,177 |
; |
; ਬ¥à ¯à®£à ¬¬ë ¤«ï MenuetOS |
; ®§¢ã稢 ¥â ª®¤ ¦ ⮩ ª« ¢¨è¨ ;) |
; |
; ®¬¯¨«¨à®¢ âì FASM'®¬ |
; |
; ¬. â ª¦¥: |
; template.asm - ¯à¨¬¥à ¯à®á⥩襩 ¯à®£à ¬¬ë (®¢ë©!) |
; rb.asm - ª®â¥ªá⮥ ¬¥î à ¡®ç¥£® á⮫ |
; example2.asm - ¯à¨¬¥à ¬¥î ¨ ¤®¯®«¨â¥«ìëå ®ª® |
; example3.asm - ¯à¨¬¥à ¬¥î, ॠ«¨§®¢ ®£® ¯®-¤à㣮¬ã |
;--------------------------------------------------------------------- |
use32 ; ¢ª«îç¨âì 32-¡¨âë© à¥¦¨¬ áᥬ¡«¥à |
org 0x0 ; ¤à¥á æ¨ï á ã«ï |
db 'MENUET01' ; 8-¡ ©âë© ¨¤¥â¨ä¨ª â®à MenuetOS |
dd 0x01 ; ¢¥àá¨ï § £®«®¢ª (¢á¥£¤ 1) |
dd START ; ¤à¥á ¯¥à¢®© ª®¬ ¤ë |
dd I_END ; à §¬¥à ¯à®£à ¬¬ë |
dd 0x1000 ; ª®«¨ç¥á⢮ ¯ ¬ï⨠|
dd 0x1000 ; ¤à¥á ¢¥àè¨ë áâíª |
dd 0x0 ; ¤à¥á ¡ãä¥à ¤«ï ¯ à ¬¥â஢ (¥ ¨á¯®«ì§ã¥âáï) |
dd 0x0 ; § १¥à¢¨à®¢ ® |
include 'lang.inc' |
include 'macros.inc' ; ¬ ªà®áë ®¡«¥£ç îâ ¦¨§ì áᥬ¡«¥à騪®¢! |
;--------------------------------------------------------------------- |
;--- ---------------------------------------------- |
;--------------------------------------------------------------------- |
START: |
red: ; ¯¥à¥à¨á®¢ âì ®ª® |
call draw_window ; ¢ë§ë¢ ¥¬ ¯à®æ¥¤ãàã ®âà¨á®¢ª¨ ®ª |
;--------------------------------------------------------------------- |
;--- ---------------------------------------- |
;--------------------------------------------------------------------- |
still: |
mcall 10 ; äãªæ¨ï 10 - ¦¤ âì ᮡëâ¨ï |
cmp eax,1 ; ¯¥à¥à¨á®¢ âì ®ª® ? |
je red ; ¥á«¨ ¤ - ¬¥âªã red |
cmp eax,2 ; ¦ â ª« ¢¨è ? |
je key ; ¥á«¨ ¤ - key |
cmp eax,3 ; ¦ â ª®¯ª ? |
je button ; ¥á«¨ ¤ - button |
jmp still ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ç «® 横« |
;--------------------------------------------------------------------- |
key: ; ¦ â ª« ¢¨è ª« ¢¨ âãॠ|
mcall 2 ; äãªæ¨ï 2 - áç¨â âì ª®¤ ᨬ¢®« (¢ ah) |
mov [Music+1], ah ; § ¯¨á âì ª®¤ ᨬ¢®« ª ª ª®¤ ®âë |
; äãªæ¨ï 55-55: á¨áâ¥¬ë© ¤¨ ¬¨ª ("PlayNote") |
; esi - ¤à¥á ¬¥«®¤¨¨ |
; mov eax,55 |
; mov ebx,eax |
; mov esi,Music |
; int 0x40 |
; ¨«¨ ª®à®âª®: |
mcall 55, eax, , , Music |
jmp still ; ¢¥àãâìáï ª ç «ã 横« |
;--------------------------------------------------------------------- |
button: |
mcall 17 ; 17 - ¯®«ãç¨âì ¨¤¥â¨ä¨ª â®à ¦ ⮩ ª®¯ª¨ |
cmp ah, 1 ; ¥á«¨ ¦ â ª®¯ª á ®¬¥à®¬ 1, |
jne still ; ¢¥àãâìáï |
.exit: |
mcall -1 ; ¨ ç¥ ª®¥æ ¯à®£à ¬¬ë |
;--------------------------------------------------------------------- |
;--- ---------------------------------- |
;--------------------------------------------------------------------- |
draw_window: |
mcall 12, 1 ; äãªæ¨ï 12: á®®¡é¨âì ®¡ ®âà¨á®¢ª¥ ®ª |
; 1 - ç¨ ¥¬ à¨á®¢ âì |
; ¤ «¥¥: á ç « ¤«¨ë© ¢ ਠâ (§ ª®¬¬¥â¨à®¢ ë©) |
; § ⥬ ª®à®âª¨© «®£ á ¨á¯®«ì§®¢ ¨¥¬ ¬ ªà®á®¢ |
; ð |
; mov eax,0 ; äãªæ¨ï 0 : ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª® |
; mov ebx,200*65536+200 ; [x áâ àâ] *65536 + [x à §¬¥à] |
; mov ecx,200*65536+100 ; [y áâ àâ] *65536 + [y à §¬¥à] |
; mov edx,0x02aabbcc ; 梥â à ¡®ç¥© ®¡« á⨠RRGGBB,8->color gl |
; mov esi,0x805080d0 ; 梥⠯®«®áë § £®«®¢ª RRGGBB,8->color gl |
; mov edi,0x005080d0 ; 梥â à ¬ª¨ RRGGBB |
; int 0x40 |
mcall 0, <200,200>, <200,50>, 0x02AABBCC, 0x805080D0, 0x005080D0 |
; |
; mov eax,4 ; äãªæ¨ï 4 : ¯¨á âì ¢ ®ª¥ ⥪áâ |
; mov ebx,8*65536+8 ; [x] *65536 + [y] |
; mov ecx,0x10ddeeff ; èà¨äâ 1 ¨ 梥â ( 0xF0RRGGBB ) |
; mov edx,header ; ¤à¥á áâப¨ |
; mov esi,header.size ; ¨ ¥ñ ¤«¨ |
; int 0x40 |
mcall 4, <8,8>, 0x10DDEEFF, header, header.size |
; mov eax,4 |
; mov ebx,8 shl 16 + 30 |
; mov ecx,0 |
; mov edx,message |
; mov esi,message.size |
; int 0x40 |
mcall 4, <8, 30>, 0, message, message.size |
; |
; mov eax,8 ; äãªæ¨ï 8 : ®¯à¥¤¥«¨âì ¨ à¨á®¢ âì ª®¯ªã |
; mov ebx,(200-19)*65536+12 ; [x áâ àâ] *65536 + [x à §¬¥à] |
; mov ecx,5*65536+12 ; [y áâ àâ] *65536 + [y à §¬¥à] |
; mov edx,1 ; ¨¤¥â¨ä¨ª â®à ª®¯ª¨ - 1 |
; mov esi,0x6688dd ; 梥⠪®¯ª¨ RRGGBB |
; int 0x40 |
mcall 8, <200-19, 12>, <5, 12>, 1, 0x6688DD |
mcall 12, 2 ; äãªæ¨ï 12: á®®¡é¨âì ®¡ ®âà¨á®¢ª¥ ®ª |
; 2, § ª®ç¨«¨ à¨á®¢ âì |
ret ; ¢ë室¨¬ ¨§ ¯à®æ¥¤ãàë |
;--------------------------------------------------------------------- |
;--- ---------------------------------------------- |
;--------------------------------------------------------------------- |
; ®â â ª ï ¢®â ª®à®âª ï "¬¥«®¤¨ï". |
; â®à®© ¡ ©â ¨§¬¥ï¥âáï ¦ ⨥¬ ª« ¢¨èë |
Music: |
db 0x90, 0x30, 0 |
;--------------------------------------------------------------------- |
; ¨â¥àä¥©á ¯à®£à ¬¬ë ¬®£®ï§ëçë© |
; ë ¬®¦¥â¥ § ¤ âì ï§ëª ¢ MACROS.INC (lang fix ï§ëª) |
lsz message,\ |
ru,' ¦¬¨â¥ «î¡ãî ª« ¢¨èã...',\ |
en,'Press any key...',\ |
fr,'Pressez une touche...' |
lsz header,\ |
ru,' ',\ |
en,'EXAMPLE APPLICATION',\ |
fr,"L'exemplaire programme" |
;--------------------------------------------------------------------- |
I_END: ; ¬¥âª ª®æ ¯à®£à ¬¬ë |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/example/trunk/macros.inc |
---|
0,0 → 1,267 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/example2/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm example2.asm example2 |
@pause |
/programs/develop/examples/example2/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm example2.asm example2 |
@pause |
/programs/develop/examples/example2/trunk/dialogs1.inc |
---|
0,0 → 1,597 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; ; |
; DIALOGS1.INC ; |
; ; |
; COMPILE WITH FASM for MENUET ; |
; ; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
menus dd 3 ; number of menus |
m_x dd 0x5 ; x start |
m_y dd 20 ; y start |
m_xs dd 290 ; x size |
m_ys dd 14 ; y size |
g_stack dd 0xf000 ; thread stack - required |
menu:; AB C D E F G |
db '*D FILE +Save File +Load File +- +Quit ' |
db '*B EDIT +Copy +Paste ' |
db '*B HELP +Setup +About.. ' |
db '@' ; end mark |
; A : Data type '*' -> New menu , '+' -> menu selection |
; B : Number of selections in menu (A+) |
; C : Menu header text |
; D-G : Menu selection text |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; DATA BELOW IS FOR DIALOGS1.INC INTERNALS |
menu_action dd '----' |
window_on db 0 |
g_n dd -1 |
g_x dd 0x0 |
g_t dd 0x0 |
g_1 dd 0x0 |
g_l dd 0x0 |
closet db 0 |
table: times 1024 db 0 |
last_mouse dd 0x0 |
mo_x dd 0x0 |
mo_y dd 0x0 |
check_mouse: |
pusha |
cmp [window_on],1 |
je no_open |
mov eax,37 |
mov ebx,2 |
int 0x40 |
cmp [window_on],0 |
jne openw2 |
cmp eax,0 |
je no_open |
openw2: |
waitformouse: |
mov eax,23 |
mov ebx,2 |
int 0x40 |
cmp eax,0 |
jne no_open |
mov eax,37 |
mov ebx,2 |
int 0x40 |
cmp eax,0 |
jne waitformouse |
mov eax,37 |
mov ebx,1 |
int 0x40 |
mov esi,eax |
shr eax,16 |
xor edx,edx |
mov ebx,50 |
div ebx |
mov edx,eax |
cmp edx,[g_n] |
je no_open |
cmp edx,[menus] |
jge no_open |
mov eax,esi |
and eax,0xffff |
mov ebx,[m_y] |
cmp eax,ebx |
jbe no_open |
add ebx,[m_ys] |
cmp eax,ebx |
jge no_open |
cmp [window_on],0 |
je noww |
mov [closet],1 |
mov ecx,100 |
waitm: |
mov eax,5 |
mov ebx,1 |
int 0x40 |
dec ecx |
jz no_open |
cmp [window_on],0 |
jne waitm |
noww: |
mov eax,edx |
jmp cll |
no_open: |
mov [last_mouse],esi |
popa |
ret |
cll: |
mov [window_on],2 |
mov [g_n],eax |
mov [g_x],96 |
mov [g_t],0 |
mov [g_1],1 |
mov eax,9 |
mov ebx,table |
mov ecx,-1 |
int 0x40 |
mov eax,[table+34] |
mov [mo_x],eax |
mov eax,[table+38] |
mov [mo_y],eax |
mov eax,51 |
mov ebx,1 |
mov ecx,alert_entry |
mov edx,[g_stack] |
int 0x40 |
mov [esp+28],dword 0 ; clear button entry |
mov [menu_action],'MD ' |
check_gr: |
popa |
ret |
draw_menu: |
mov eax,9 |
mov ebx,table |
mov ecx,-1 |
int 0x40 |
cmp [table+46],dword 30 |
jb drmr |
mov eax,13 ; white background |
mov ebx,[m_x] |
shl ebx,16 |
add ebx,[m_xs] |
inc ebx |
mov ecx,[m_y] |
shl ecx,16 |
add ecx,[m_ys] |
mov edx,0xf0f8ff |
int 0x40 |
mov eax,38 ; egde lines |
mov ebx,[m_x] |
shl ebx,16 |
add ebx,[m_x] |
add ebx,[m_xs] |
mov ecx,[m_y] |
shl ecx,16 |
add ecx,[m_y] |
mov edx,0x000000 |
int 0x40 |
mov eax,38 |
mov ecx,[m_y] |
add ecx,[m_ys] |
shl ecx,16 |
add ecx,[m_y] |
add ecx,[m_ys] |
int 0x40 |
mov esi,menu-1 |
mov edi,[m_x] |
mov ebp,1 |
new_menu: |
inc esi |
cmp [esi],byte '*' |
jne drmnl1 |
push esi |
mov eax,4 |
mov ebx,edi |
shl ebx,16 |
add ebx,[m_y] |
add ebx,0x00050004 |
mov ecx,0x000000 |
mov edx,esi |
add edx,3 |
mov esi,12 |
int 0x40 ; draw text |
pop esi |
add esi,2 |
add edi,50 |
inc ebp |
drmnl1: |
cmp [esi],byte '@' |
jne new_menu |
drmr: |
ret |
alert_box: |
; eax : x size - min 200 |
; ebx : pointer to ASCIIZ - max 128 character text |
; ecx : button 1 id ( OK or YES ) |
; edx : button 2 id or zero ( NO ) |
cmp [window_on],0 |
jne alert_box_return |
mov [window_on],1 |
cmp eax,100 |
jg size_ok |
mov eax,100 |
size_ok: |
mov [g_x],eax |
mov [g_t],ebx |
mov [g_1],ecx |
mov ecx,0 |
new_search: |
cmp [ebx],byte 0 |
je found_len |
inc ebx |
inc ecx |
cmp ecx,128 |
jbe new_search |
found_len: |
mov [g_l],ecx |
mov eax,51 |
mov ebx,1 |
mov ecx,alert_entry |
mov edx,[g_stack] |
int 0x40 |
mov [menu_action],'MA ' |
alert_box_return: |
ret |
alert_entry: |
call alert_draw_window |
alert_still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
int 0x40 |
cmp eax,1 ; redraw request ? |
je alert_red |
cmp eax,2 ; key in buffer ? |
je alert_key |
cmp eax,3 ; button in buffer ? |
je alert_button |
cmp [closet],0 |
jne ccc |
mov eax,9 |
mov ebx,table |
mov ecx,-1 |
int 0x40 |
cmp ax,[table+4] |
je no_close |
ccc: |
mov [closet],0 |
mov [g_n],-1 |
mov [menu_action],'----' |
mov [window_on],0 |
mov eax,-1 |
int 0x40 |
no_close: |
jmp alert_still |
alert_red: ; redraw |
call alert_draw_window |
jmp alert_still |
alert_key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp alert_still |
alert_button: ; button |
mov eax,17 ; get id |
int 0x40 |
shr eax,8 |
cmp eax,3 |
jg no_action1 |
dec eax |
shl eax,2 |
mov eax,dword [eax+rtext] |
mov [menu_action],eax |
jmp action_done |
no_action1: |
sub eax,16 |
add eax,65 |
shl eax,8 |
mov ebx,[g_n] |
add ebx,65 |
add eax,ebx |
mov [menu_action],eax |
action_done: |
mov [closet],0 |
mov [g_n],-1 |
mov [window_on],0 |
mov eax,-1 ; close this program |
int 0x40 |
rtext db 'NO YES OK ' |
jmp alert_still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
alert_draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
cmp [window_on],2 |
jne no_win_type_2 |
mov edx,menu-1 |
mov ecx,[g_n] |
add ecx,1 |
find_menu: |
inc edx |
cmp [edx],byte '*' |
je menu_loop |
jmp find_menu |
menu_loop: |
loop find_menu |
movzx ebp,byte [edx+1] |
sub ebp,64 |
push edx |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,[g_n] |
imul ebx,50 |
add ebx,[mo_x] |
add ebx,[m_x] |
shl ebx,16 |
add ebx,[g_x] |
mov ecx,[mo_y] |
add ecx,[m_y] |
add ecx,[m_ys] |
shl ecx,16 |
mov edx,14 |
imul edx,ebp |
add edx,7 |
add ecx,edx |
mov edx,0x00ffffff ; color of work area RRGGBB,8->color gl |
mov esi,0x00ffffff ; color of grab bar RRGGBB,8->color gl |
mov edi,0x000000cc ; color of frames RRGGBB |
int 0x40 |
pop edx |
mov ebx,5*65536+7 ; draw info text with function 4 |
mov ecx,0x10000000 |
mov esi,12 |
mov ebp,16 |
no_d_found: |
inc edx |
cmp [edx],byte '*' |
je d_drawed |
cmp [edx],byte '@' |
je d_drawed |
cmp [edx],byte '+' |
jne no_d_found |
inc edx |
pusha ; draw button |
mov eax,8 |
mov ecx,ebx |
mov ebx,[g_x] |
add ebx,0x0000fffe |
shl ecx,16 |
add ecx,0xfffc0000+14 |
mov edx,0x40000000 |
add edx,ebp |
mov esi,0 |
int 0x40 |
popa |
mov eax,4 ; draw text |
int 0x40 |
inc ebp |
add ebx,14 |
jmp no_d_found |
d_drawed: |
no_win_type_2: |
cmp [window_on],1 |
jne no_win_1 |
mov eax,14 ; to middle of screen |
int 0x40 |
mov ecx,eax |
and ecx,0xffff |
shr ecx,1 |
shr eax,1 |
mov ebx,[g_x] |
shr ebx,1 |
shl ebx,16 |
sub eax,ebx |
mov ebx,eax |
mov eax,0 ; function 0 : define and draw window |
mov bx,word [g_x] |
sub ecx,80 |
shl ecx,16 |
mov cx,110 ; [y start] *65536 + [y size] |
mov edx,0x02ffffff ; color of work area RRGGBB,8->color gl |
mov esi,0x80d05050 ; color of grab bar RRGGBB,8->color gl |
mov edi,0x00d05050 ; color of frames RRGGBB |
int 0x40 |
mov eax,4 ; label |
mov ebx,8*65536+8 |
mov ecx,0x10ddeeff |
mov edx,alert_labelt1 |
mov esi,alert_label1len-alert_labelt1 |
int 0x40 |
mov eax,4 |
mov ebx,10*65536+43 |
mov ecx,0x10000000 |
mov edx,[g_t] |
mov esi,[g_l] |
int 0x40 |
cmp [g_1],1 |
jne gadgets_no_1 |
mov eax,8 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,30*65536+40 |
mov ecx,75*65536+16 |
mov edx,3 |
mov esi,0x446688 |
int 0x40 |
mov eax,4 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,31*65536+80 |
mov ecx,0x10ffffff |
mov edx,alert_t2 |
mov esi,alert_t2len-alert_t2 |
int 0x40 |
gadgets_no_1: |
cmp [g_1],2 |
jne gadgets_no_2 |
mov eax,8 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,0*65536+40 |
mov ecx,75*65536+16 |
mov edx,1 |
mov esi,0x446688 |
int 0x40 |
mov eax,8 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,57*65536+40 |
mov ecx,75*65536+16 |
mov edx,2 |
mov esi,0x446688 |
int 0x40 |
mov eax,4 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,1*65536+80 |
mov ecx,0x10ffffff |
mov edx,alert_t1 |
mov esi,alert_t1len-alert_t1 |
int 0x40 |
gadgets_no_2: |
no_win_1: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
; DATA AREA |
alert_t1: |
db ' No Yes' |
alert_t1len: |
alert_t2: |
db ' OK' |
alert_t2len: |
alert_labelt1: |
db 'ALERT' |
alert_label1len: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/example2/trunk/example2.asm |
---|
0,0 → 1,201 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; MENU / DIALOG EXAMPLE |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x10000 ; memory for app |
dd 0x10000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
include 'lang.inc' |
include 'macros.inc' |
include 'dialogs1.inc' |
menu_history dd 0x0 |
START: ; start of execution |
call draw_window_main |
still: ; wait here for event |
mov eax,23 |
mov ebx,2 |
int 0x40 |
cmp eax,1 ; process events |
je red |
cmp eax,2 |
je key |
cmp eax,3 |
je button |
call check_mouse ; DIALOG CHECK |
mov eax,[menu_action] |
cmp eax,[menu_history] |
je nodisplay |
mov [menu_history],eax |
mov eax,13 |
mov ebx,220*65536+6*4 |
mov ecx,70*65536+8 |
mov edx,0xffffff |
int 0x40 |
mov eax,4 ; show menu selections |
mov ebx,220*65536+70 |
mov ecx,0x000000 |
mov edx,menu_action |
mov esi,4 |
int 0x40 |
nodisplay: |
cmp word [menu_action],word 'AD' ; user requests close |
jne no_menu_close |
mov eax,-1 |
int 0x40 |
no_menu_close: |
jmp still |
red: ; redraw |
call draw_window_main |
jmp still |
key: |
mov eax,2 ; key in buffer |
int 0x40 |
jmp still |
button: ; button in buffer |
mov eax,17 |
int 0x40 |
cmp ah,1 ; close application |
jne noclose |
mov eax,-1 |
int 0x40 |
noclose: |
cmp ah,2 |
jne no_alert_box ; ALERT BOX |
mov eax,170 ; window width |
mov ebx,alert_text ; asciiz string |
mov ecx,1 ; OK button |
call alert_box ; function call |
jmp still |
no_alert_box: |
cmp ah,3 |
jne no_choose_box ; CHOOSE BOX |
mov eax,220 ; window width |
mov ebx,choose_text ; asciiz string |
mov ecx,2 ; YES/NO buttons |
call alert_box ; function call |
jmp still |
no_choose_box: |
jmp still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window_main: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
mov eax,0 ; open window |
mov ebx,100*65536+300 |
mov ecx,100*65536+120 |
mov edx,0x02ffffff |
mov esi,0x805080d0 |
mov edi,0x005080d0 |
int 0x40 |
call draw_menu ; DRAW MENU |
mov eax,4 ; window label |
mov ebx,8*65536+8 |
mov ecx,0x10ddeeff |
mov edx,labelt |
mov esi,labellen-labelt |
int 0x40 |
mov eax,8 ; close button |
mov ebx,(300-17)*65536+10 |
mov ecx,5*65536+10 |
mov edx,1 |
mov esi,0x4466bb |
int 0x40 |
mov eax,8 ; button : OPEN ALERT BOX |
mov ebx,25*65536+150 |
mov ecx,61*65536+14 |
mov edx,2 |
mov esi,0x4466aa |
int 0x40 |
mov eax,8 ; button : OPEN CHOOSE BOX |
mov ebx,25*65536+150 |
mov ecx,81*65536+14 |
mov edx,3 |
mov esi,0x4466aa |
int 0x40 |
mov ebx,20*65536+55 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,10 |
add edx,40 |
cmp [edx],byte 'x' |
jne newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
; DATA AREA |
text: |
db ' ' |
db ' OPEN ALERT BOX ' |
db ' ' |
db ' OPEN CHOOSE BOX ' |
db 'x <- END MARKER, DONT DELETE ' |
labelt: |
db 'EXAMPLE APPLICATION' |
labellen: |
alert_text db ' File not found !',0 |
choose_text db ' Save file before exit ? ',0 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/example2/trunk/macros.inc |
---|
0,0 → 1,267 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/example3/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm example3.asm example3 |
@pause |
/programs/develop/examples/example3/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm example3.asm example3 |
@pause |
/programs/develop/examples/example3/trunk/example3.asm |
---|
0,0 → 1,433 |
; |
; MENU EXAMPLE |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x1000 ; memory for app |
dd 0x1000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
call draw_window ; draw window |
call clear_data ; clear status bar |
still: |
mov eax,10 ; wait here for event |
int 0x40 ; do it |
cmp eax,1 ; redraw request ? |
je red ; yes jump to it |
cmp eax,2 ; key in buffer ? |
je key ; yes jump to it |
cmp eax,3 ; button in buffer ? |
je button ; yes jump to it |
jmp still ; start again |
red: ; redraw |
call draw_window ; redraw window |
call clear_data ; clear status info |
jmp still ; start again |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 ; do it |
jmp still ; start again |
button: ; button |
mov eax,17 ; get id |
int 0x40 ; do it |
cmp ah,1 ; is it the close button |
jne noclose ; no then jump code |
mov eax,-1 ; close this program |
int 0x40 ; do it |
noclose: |
cmp ah,100 ; is it main menu |
jb not_menu ; no then jump code |
cmp ah,104 ; is it main menu |
ja not_menu ; no then jump code |
call draw_window ; redraw window |
call clear_data ; clear status info |
call draw_data ; update status info |
call write_sub ; draw a sub menu |
jmp still ; start again |
not_menu: |
cmp ah,110 ; is it a sub menu |
jb not_sub ; no then jump code |
cmp ah,145 ; is it a sub menu |
ja not_sub ; no then jump code |
call draw_window ; redraw window |
call clear_data ; clear status info |
mov [button_press],1 ; sub button pressed |
call draw_data ; update status info |
mov [button_press],0 ; clear pressed |
jmp still ; start again |
not_sub: |
jmp still ; start again |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
push eax ; save register |
mov eax,12 ; function 12: tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 ; do it |
mov eax,0 ; function 0: define and draw window |
mov ebx,50*65536 ; [x start] *65536 |
add ebx,[x_size] ; add [x size] |
mov ecx,50*65536 ; [y start] *65536 |
add ecx,[y_size] ; add [y size] |
mov edx,0x80ffffff ; colour of work area RRGGBB |
mov esi,0x806688dd ; grab bar colour. negative glide |
int 0x40 ; do it |
mov eax,4 ; function 4: write text to window |
mov ebx,6*65536+7 ; [x start] *65536 + [y start] |
mov ecx,0x00ffffff ; text colour |
mov edx,window_text ; pointer to text beginning |
mov esi,12 ; text length |
int 0x40 ; do it |
mov eax,8 ; function 8: define and draw button |
mov ebx,(381-18)*65536+13 ; [x start] *65536 + [x size] |
mov ecx,4*65536+13 ; [y start] *65536 + [y size] |
mov edx,1 ; button id |
mov esi,0x6688dd ; button color RRGGBB |
int 0x40 ; do it |
mov eax,13 ; function 13: draw bar |
mov ebx,1*65536 ; [x start] *65536 |
add ebx,[x_size] ; add [x size] |
dec ebx ; x size - 1 |
mov ecx,[y_size] ; [y start] *65536 |
sub ecx,17 ; minus height |
shl ecx,16 ; *65536 |
add ecx,17 ; add height |
mov edx,0x006688dd ; bar colour |
int 0x40 ; do it |
mov eax,4 ; function 4 : write text to window |
mov ebx,5*65536 ; [x start] *65536 |
add ebx,[y_size] ; add [y start] |
sub ebx,12 ; move up |
xor ecx,ecx ; text colour |
mov edx,button_no ; pointer to text beginning |
mov esi,14 ; text length |
int 0x40 ; do it |
add ebx,95*65536 ; move xy position |
mov edx,menu_text ; pointer to text beginning |
int 0x40 ; do it |
call write_main ; draw menu |
mov eax,12 ; function 12: tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 ; do it |
pop eax ; restore register |
ret ; return |
; ************* WRITE MAIN ************* |
write_main: |
mov eax,13 ; function 13: draw bar |
mov ebx,1*65536 ; [x start] *65536 |
add ebx,[x_size] ; +[x_size] |
dec ebx ; x size - 1 |
mov ecx,21*65536+17 ; [y start] *65536 +[y size] |
mov edx,[menu_colour] ; menu colour |
int 0x40 ; do it |
mov [main_pos],1 ; start position first button |
xor edi,edi ; data offset = 0 |
next_main_item: |
mov al,[MENU_DATA+edi] ; get byte at menu_data + offset |
cmp al,'E' ; is it the END |
je main_get_out ; yes then exit |
cmp al,'0' ; is it a main menu item |
jne not_main_menu ; no then jump code |
main_menu: |
mov al,[MENU_DATA+edi+1] ; get byte at menu_data + offset + 1 |
cmp al,'0' ; is it a divider |
je is_main_bar ; yes then jump code |
mov eax,8 ; function 8: define button |
mov ebx,[main_pos] ; [x start] |
shl ebx,16 ; *65536 |
add bl,75 ; +[x size] |
mov ecx,21*65536+16 ; [y start] *65536 +[y size] |
xor edx,edx ; clear register |
mov dl,[MENU_DATA+edi+2] ; get byte button id number |
mov esi,[menu_colour] ; button colour |
int 0x40 ; do it |
mov eax,4 ; function 4: write text to window |
add ebx,6*65536-49 ; move xy position |
xor ecx,ecx ; text colour |
mov edx,MENU_DATA+3 ; point at menu text |
add edx,edi ; add our offset |
mov esi,11 ; number of characters |
int 0x40 ; do it |
is_main_bar: |
add [main_pos],76 ; update button position |
not_main_menu: |
add edi,14 ; update offset |
jmp next_main_item ; do next menu item |
main_get_out: |
ret ; return |
; *********** DRAW DATA *********** |
draw_data: |
push eax ; save register |
mov ebx,0x00030000 ; display 3 decimal characters |
xor ecx,ecx ; clear register |
mov cl,ah ; swap data |
mov eax,47 ; function 47: display number to window |
mov edx,70*65536 ; [x start] *65536 |
add edx,[y_size] ; +[y start] |
sub edx,12 ; move position |
xor esi,esi ; text colour |
int 0x40 ; do it |
pop eax ; restore register |
cmp [button_press],1 ; has a sub button been pressed |
je draw_get_out ; then jump code |
push eax ; save register |
xor edx,edx ; clear register |
shr ax,8 ; move button id into al |
sub eax,100 ; subtract 100 |
mov dx,14 ; use record length as multiplier |
mul dx ; multiply |
mov edx,eax ; swap registers |
add edx,MENU_DATA ; add offset |
inc edx ; add 1 |
mov ebx,188*65536 ; [x start] *65536 |
add ebx,[y_size] ; +[y start] |
sub ebx,12 ; move position |
mov esi,1 ; 1 character |
mov eax,4 ; function 4: write text to window |
xor ecx,ecx ; text colour |
int 0x40 ; do it |
pop eax ; restore register |
draw_get_out: |
ret ; return |
; **************** CLEAR DATA ****************** |
clear_data: |
push eax ; save register |
mov eax,13 ; function 13: draw bar |
mov ebx,67*65536+23 ; [x start] *65536 +[x size] |
mov ecx,[y_size] ; [y start] |
sub ecx,15 ; move position |
shl ecx,16 ; *65536 |
add ecx,13 ; [y size] |
mov edx,0x00aaaaaa ; bar colour |
int 0x40 ; do it |
mov ebx,185*65536+11 ; move position |
int 0x40 ; do it again |
pop eax ; restore register |
ret ; return |
; ************* WRITE SUB ************* |
write_sub: |
push eax ; save register |
mov [but_pos],38 ; y start position offset |
mov [sub_pos],1 ; x start position offset |
xor edx,edx ; clear register |
shr ax,8 ; move button id into al |
sub eax,100 ; subtract 100 |
mov dx,76 ; menu width + 1 |
mul dx ; multiply |
add [sub_pos],eax ; add menu position to offset |
pop eax ; restore register |
xor edx,edx ; clear register |
shr ax,8 ; move button id into al |
sub eax,100 ; subtract 100 |
mov dx,14 ; use record length as multiplier |
mul dx ; multiply |
add eax,MENU_DATA ; add offset |
inc eax ; plus 1 |
mov al,[eax] ; get menu number byte |
mov [menu_number],al ; save it |
xor edi,edi ; clear offset |
next_sub_item: |
mov al,[MENU_DATA+edi] ; get byte at menu_data + offset |
cmp al,'E' ; is it the END |
je sub_get_out ; yes then exit |
cmp al,[menu_number] ; is it sub menu item |
jne not_sub_menu ; no then jump code |
sub_menu: |
mov al,[MENU_DATA+edi+1] ; get byte at menu_data + offset + 1 |
cmp al,'0' ; is it a divider |
jne is_sub_button ; no then jump code |
mov eax,13 ; function 13: draw bar |
mov edx,[menu_colour] ; bar colour |
mov ebx,[sub_pos] ; [x start] |
shl ebx,16 ; *65536 |
add ebx,76 ; [x size] |
mov ecx,[but_pos] ; [y start] |
shl ecx,16 ; *65536 |
add ecx,17 ; [y size] |
int 0x40 ; do it |
jmp is_sub_bar ; jump button code |
is_sub_button: |
mov eax,8 ; function 8: define and draw button |
xor edx,edx ; clear register |
mov dl,[MENU_DATA+edi+2] ; get byte button id number |
mov ebx,[sub_pos] ; [x start] |
shl ebx,16 ; *65536 |
add ebx,75 ; [x size] |
mov ecx,[but_pos] ; [y start] |
shl ecx,16 ; *65536 |
add ecx,16 ; [y size] |
mov esi,[menu_colour] ; button colour |
int 0x40 ; do it |
mov ebx,[sub_pos] ; [x start] |
shl ebx,16 ; *65536 |
add ebx,6*65536 ; move position |
add ebx,[but_pos] ; [y start] |
add bl,5 ; move position |
xor ecx,ecx ; clear register |
mov edx,MENU_DATA+3 ; point to button text |
add edx,edi ; add offset |
mov esi,11 ; number of characters |
mov eax,4 ; function 4: write text to window |
int 0x40 ; do it |
is_sub_bar: |
add [but_pos],17 ; move y position |
not_sub_menu: |
add edi,14 ; move offset |
jmp next_sub_item ; do next button |
sub_get_out: |
ret ; return |
; ***************** DATA AREA ****************** |
x_size: dd 381 ; window x size |
y_size: dd 200 ; window y size |
window_text db 'MENU EXAMPLE' ; grab bar text |
button_no db 'BUTTON No: ' ; status bar text |
menu_text db 'MENU SELECTED:' ; status bar text |
button_press dd 0 |
menu_colour dd 0x00aaaaaa ; menu & button colour |
menu_number db '0' ; menu selection |
sub_pos dd 1 ; sub menu x position |
but_pos dd 38 ; sub menu y position |
main_pos dd 1 ; main menu x position |
MENU_DATA: db '01' ; MAIN MENU = 0 - 1 = menu |
db 100 ; button id |
db 'FILE ' ; button text |
db '02' ; MAIN MENU = 0 - 2 = menu |
db 101 ; button id |
db 'EDIT ' ; button text |
db '04' ; MAIN MENU = 0 - 3 = menu |
db 102 ; button id |
db 'TEST ' ; button text |
db '00' ; MAIN MENU = 0 - 0 = divider |
db 103 ; SPACER ID |
db ' ' ; SPACER TEXT padding |
db '03' ; MAIN MENU = 0 - 4 = menu |
db 104 ; button id |
db 'HELP ' ; button text |
db '11' ; menu level = 1 - 1 = button |
db 110 ; button id |
db 'LOAD ' ; button text |
db '11' ; menu level = 1 - 1 = button |
db 111 ; button id |
db 'SAVE ' ; button text |
db '10' ; menu level = 1 - 0 = divider |
db 112 ; SPACER ID |
db ' ' ; SPACER TEXT padding |
db '11' ; menu level = 1 - 1 = button |
db 113 ; button id |
db 'QUIT ' ; button text |
db '21' ; menu level = 2 - 1 = button |
db 120 ; button id |
db 'COPY ' ; button text |
db '21' ; menu level = 2 - 1 = button |
db 121 ; button id |
db 'PASTE ' ; button text |
db '31' ; menu level = 3 - 1 = button |
db 130 ; button id |
db 'SETUP ' ; button text |
db '31' ; menu level = 3 - 1 = button |
db 131 ; button id |
db 'ABOUT.. ' ; button text |
db '41' ; menu level = 3 - 1 = button |
db 140 ; button id |
db 'TEST 1 ' ; button text |
db '41' ; menu level = 3 - 1 = button |
db 141 ; button id |
db 'TEST 2 ' ; button text |
db '41' ; menu level = 3 - 1 = button |
db 142 ; button id |
db 'TEST 3 ' ; button text |
db '41' ; menu level = 3 - 1 = button |
db 143 ; button id |
db 'TEST 4 ' ; button text |
db '41' ; menu level = 3 - 1 = button |
db 144 ; button id |
db 'TEST 5 ' ; button text |
db '41' ; menu level = 3 - 1 = button |
db 145 ; button id |
db 'TEST 6 ' ; button text |
db 'END' ; IMPORTANT need an END |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/example3/trunk/macros.inc |
---|
0,0 → 1,267 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/hello/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm hello.asm hello |
@pause |
/programs/develop/examples/hello/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm hello.asm hello |
@pause |
/programs/develop/examples/hello/trunk/cmdipc.inc |
---|
0,0 → 1,221 |
include "macros.inc" |
initipc: |
mov eax,9 |
mov ebx,prc |
mov ecx,-1 |
int 0x40 |
mov ecx,eax |
loop1: |
push ecx |
mov eax,9 |
mov ebx,prc |
int 0x40 |
cmp word [prc+10],'CM' |
jne no_cmd |
cmp byte [prc+12],'D' |
jne no_cmd |
mov ebx,[prc+30] |
mov dword [cmdpid],ebx |
mov dword [cmdnumb],ecx |
no_cmd: |
pop ecx |
loop loop1 |
cmp dword [cmdpid],0 |
jne no_exit |
jmp exit |
no_exit: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,printf |
mov esi,4 |
int 0x40 |
call initcmd |
waitcmdinit: |
mov eax,40 |
mov ebx,01000000b |
int 0x40 |
mov eax,23 |
mov ebx,100 |
int 0x40 |
cmp eax,7 |
je cmd_ok |
jmp exit |
cmd_ok: |
cmp byte [ipcb+16],'.' |
jne exit |
mov eax,18 |
mov ebx,3 |
mov ecx,dword [cmdnumb] |
int 0x40 |
ret |
pause1: |
mov eax,5 |
mov ebx,1 |
int 0x40 |
ret |
exit: |
mov eax,-1 |
int 0x40 |
cls: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipccls |
mov esi,4 |
int 0x40 |
call pause1 |
ret |
print: |
mov ecx,84 |
loopprt: |
mov edi,stripc |
add edi,ecx |
mov esi,fill_symbol |
movsb |
loop loopprt |
cld |
mov ecx,4 |
mov edi,stripc |
mov esi,printf |
rep movsb |
cld |
mov edx,79 |
sub edx,eax |
mov ecx,79 |
sub ecx,edx |
mov edi,stripc+4 |
mov esi,ebx |
rep movsb |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,stripc |
mov esi,84 |
int 0x40 |
call pause1 |
ret |
eol: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipceol |
mov esi,4 |
int 0x40 |
call pause1 |
ret |
initcmd: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipckey |
mov esi,4 |
int 0x40 |
mov eax,60 |
mov ebx,1 |
mov ecx,ipcb |
mov edx,28 |
int 0x40 |
cld |
mov ecx,28 |
mov edi,ipcb |
mov esi,ipcc |
rep movsb |
ret |
getkey: |
call initcmd |
waitagain: |
mov eax,40 |
mov ebx,01000000b |
int 0x40 |
mov eax,10 |
int 0x40 |
cmp eax,7 |
jne waitagain |
mov edi,key |
mov esi,ipcb+16 |
movsb |
ret |
endipc: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipcend |
mov esi,4 |
int 0x40 |
jmp exit |
cmdpid dd 0 |
cmdnumb dd 0 |
printf db '~ppp' |
ipceol db '~lll' |
ipcend db '~eee' |
ipccls db '~ccc' |
ipckey db '~kkk' |
key db 0 |
ipcb: |
db 0 |
db 0,0,0 |
dd 8 |
times 20 db 0 |
ipcc: |
db 0 |
db 0,0,0 |
dd 8 |
times 20 db 0 |
stripc: times 84 db 0 |
fill_symbol db 0 |
prc: times 52 db 0 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/hello/trunk/hello.asm |
---|
0,0 → 1,71 |
; Hello, World! - Programm example for CMD shell |
; Compile with FASM for Menuet |
; |
; You must run this program from CMD shell only |
; |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd START |
dd I_END |
dd 0x100000 |
dd 0x7fff0 |
dd 0x0 |
dd 0x0 |
include "lang.inc" |
include "cmdipc.inc" ; ®¤ª«îç¨âì ä ©« CMDIPC.INC |
START: |
call initipc ; ¨¨æ¨ «¨§¨à®¢ âì ¤«ï à ¡®âë á CMD |
mov eax,26 ; «¨ áâப¨ |
mov ebx,hello_text ; ª § ⥫ì áâபã |
call print ; 뢥á⨠áâபã |
again: |
call getkey ; ¦¨¤ âì ¦ â¨ï ª« ¢¨è¨ ¨ áç¨â âì ¥¥ ¢ key |
cmp byte [key],'Y' ; ãâ ¯à®£à ¬¬ ¯à®¢¥àï¥â, ¦ â «¨ ã¦. ª« ¢¨è |
je goodday |
cmp byte [key],'y' |
je goodday |
cmp byte [key],'N' |
je goodmorning |
cmp byte [key],'n' |
je goodmorning |
jmp again ; ᫨ ã¦. ª« ¢¨è ¥ ¦ â , â® áç¨â âì ª« ¢¨èã |
; § ®¢® |
goodday: ; 뢥á⨠¯à¨¢¥âá⢨¥ Good Day, World! |
call eol ; யãáâ¨âì áâபã |
mov eax,16 |
mov ebx,text4 |
call print |
call eol ; யãáâ¨âì áâபã |
jmp endipc ; ¢¥àè¨âì ¯à®£à ¬¬ã |
goodmorning: ; 뢥á⨠¯à¨¢¥âá⢨¥ Good Morning, World! |
call eol |
mov eax,20 |
mov ebx,text5 |
call print |
call eol |
jmp endipc ; ¢¥àé¨âì ¯à®£à ¬¬ã |
hello_text db 'Is it after 12 noon? [Y\N]?' |
text4 db 'Good day, World!' |
text5 db 'Good morning, World!' |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/hello/trunk/macros.inc |
---|
0,0 → 1,265 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a { ; mike.dld |
if ~a eq |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/template/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm template.asm template |
@pause |
/programs/develop/examples/template/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm template.asm template |
@pause |
/programs/develop/examples/template/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a { ; mike.dld |
if ~a eq |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; language for programs |
lang fix ru ; ru en fr ge fi |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/template/trunk/template.asm |
---|
0,0 → 1,102 |
; <--- description ---> |
; compiler: FASM 1.50 |
; name: Basic window example for MenuetOS |
; version: 1.01 |
; last update: 25/08/2004 |
; written by: Ivan Poddubny |
; e-mail: ivan-yar@bk.ru |
; <--- include all MeOS stuff ---> |
include "lang.inc" |
include "macros.inc" |
; <--- start of MenuetOS application ---> |
MEOS_APP_START |
; <--- start of code ---> |
CODE |
call draw_window ; at first create and draw the window |
wait_event: ; main cycle |
mov eax, 10 |
int 0x40 |
cmp eax, 1 ; if event == 1 |
je redraw ; jump to redraw handler |
cmp eax, 2 ; else if event == 2 |
je key ; jump to key handler |
cmp eax, 3 ; else if event == 3 |
je button ; jump to button handler |
jmp wait_event ; else return to the start of main cycle |
redraw: ; redraw event handler |
call draw_window |
jmp wait_event |
key: ; key event handler |
mov eax, 2 ; get key code |
int 0x40 |
jmp wait_event |
button: ; button event handler |
mov eax, 17 ; get button identifier |
int 0x40 |
cmp ah, 1 |
jne wait_event ; return if button id != 1 |
or eax, -1 ; exit application |
int 0x40 |
draw_window: |
mov eax, 12 ; start drawing |
mov ebx, 1 |
int 0x40 |
mov eax, 0 ; create and draw the window |
mov ebx, 100*65536+300 ; (window_cx)*65536+(window_sx) |
mov ecx, 100*65536+200 ; (window_cy)*65536+(window_sy) |
mov edx, 0x03ffffff ; work area color & window type 3 |
; mov esi, 0 ; grab color (not used) |
; mov edi, 0 ; frame color (not used) |
int 0x40 |
mov eax, 4 ; window header |
mov ebx, 8*65536+8 ; coordinates |
mov ecx, 0x10ffffff ; color & font N1 |
mov edx, header ; address of text |
mov esi, header.size ; length of text |
int 0x40 |
mov eax, 12 ; finish drawing |
mov ebx, 2 |
int 0x40 |
ret |
; <--- initialised data ---> |
DATA |
lsz header,\ |
ru, " ¡«® ¯à®£à ¬¬ë",\ |
en, "Template program",\ |
fr, "La programme poncive" |
; <--- uninitialised data ---> |
UDATA |
MEOS_APP_END |
; <--- end of MenuetOS application ---> |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/thread/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm thread.asm thread |
@pause |
/programs/develop/examples/thread/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm thread.asm thread |
@pause |
/programs/develop/examples/thread/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a { ; mike.dld |
if ~a eq |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; language for programs |
lang fix ru ; ru en fr ge fi |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/examples/thread/trunk/thread.asm |
---|
0,0 → 1,175 |
; |
; THREAD EXAMPLE |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x2000 ; memory for app |
dd 0x1000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne noclose |
mov eax,-1 ; close this program (thread) |
int 0x40 |
noclose: |
cmp ah,2 |
jne no_thread |
cmp [thread_stack],0x1f00 |
jge no_thread |
add [thread_stack],0x100 |
mov eax,51 |
mov ebx,1 |
mov ecx,START |
mov edx,[thread_stack] |
int 0x40 |
jmp still |
no_thread: |
jmp still |
thread_stack dd 0x1000 |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,10*65536+290 ; [x start] *65536 + [x size] |
mov ecx,10*65536+130 ; [y start] *65536 + [y size] |
mov esi,[thread_stack] |
sub esi,0x1000 |
shr esi,4 |
shl esi,16 |
add ebx,esi |
add ecx,esi |
mov edx,0x03ffffff ; color of work area RRGGBB,8->color gl |
mov esi,0x808899ff ; color of grab bar RRGGBB,8->color gl |
mov edi,0x008899ff ; color of frames RRGGBB |
int 0x40 |
; WINDOW LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
mov ecx,0x10ddeeff ; color of text RRGGBB |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
mov eax,8 ; NEW THREAD BUTTON |
mov ebx,25*65536+128 |
mov ecx,88*65536+20 |
mov edx,2 |
mov esi,0x90b0d0 ;0x5577cc |
int 0x40 |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0x224466 |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,10 |
add edx,40 |
cmp [edx],byte 'x' |
jne newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
; DATA AREA |
if lang eq ru |
text: |
db ' , ' |
db ' . ' |
db ' ' |
db ' . ' |
db ' . ' |
db ' ' |
db ' ' |
db 'x' ; <- END MARKER, DONT DELETE |
labelt: |
db ' 51®© ' |
labellen: |
else |
text: |
db 'THIS EXAMPLE CREATES THREADS BY RUNNING ' |
db 'THE SAME CODE MULTIPLE TIMES. ALL WE ' |
db 'NEED IS A NEW STACK FOR EACH THREAD. ' |
db 'ALL THREADS SHARE THE SAME MEMORY. ' |
db ' ' |
db ' ' |
db ' CREATE NEW THREAD ' |
db 'x' ; <- END MARKER, DONT DELETE |
labelt: |
db 'THREAD EXAMPLE' |
labellen: |
end if |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/fasm/trunk/TABLES.INC |
---|
0,0 → 1,1828 |
; flat assembler core |
; Copyright (c) 1999-2006, Tomasz Grysztar. |
; All rights reserved. |
include_variable db 'INCLUDE',0 |
symbol_characters db 27 |
db 9,0Ah,0Dh,1Ah,20h,'+-/*=<>()[]{}:,|&~#`;\' |
preprocessor_directives: |
db 6,'define' |
dw define_symbolic_constant-preprocessor |
db 7,'include' |
dw include_file-preprocessor |
db 3,'irp' |
dw irp_directive-preprocessor |
db 4,'irps' |
dw irps_directive-preprocessor |
db 5,'macro' |
dw define_macro-preprocessor |
db 5,'match' |
dw match_directive-preprocessor |
db 5,'purge' |
dw purge_macro-preprocessor |
db 4,'rept' |
dw rept_directive-preprocessor |
db 7,'restore' |
dw restore_equ_constant-preprocessor |
db 7,'restruc' |
dw purge_struc-preprocessor |
db 5,'struc' |
dw define_struc-preprocessor |
db 0 |
macro_directives: |
db 6,'common' |
dw common_block-preprocessor |
db 7,'forward' |
dw forward_block-preprocessor |
db 5,'local' |
dw local_symbols-preprocessor |
db 7,'reverse' |
dw reverse_block-preprocessor |
db 0 |
operators: |
db 1,'+',80h |
db 1,'-',81h |
db 1,'*',90h |
db 1,'/',91h |
db 3,'mod',0A0h |
db 3,'and',0B0h |
db 2,'or',0B1h |
db 3,'xor',0B2h |
db 3,'shl',0C0h |
db 3,'shr',0C1h |
db 0 |
single_operand_operators: |
db 1,'+',0 |
db 1,'-',083h |
db 3,'not',0D0h |
db 3,'rva',0E0h |
db 0 |
directive_operators: |
db 2,'as',86h |
db 2,'at',80h |
db 7,'defined',88h |
db 3,'dup',81h |
db 2,'eq',0F0h |
db 6,'eqtype',0F7h |
db 4,'from',82h |
db 2,'in',0F6h |
db 2,'on',84h |
db 3,'ptr',85h |
db 4,'used',89h |
db 0 |
address_registers: |
db 2,'bp',25h |
db 2,'bx',23h |
db 2,'di',27h |
db 3,'eax',40h |
db 3,'ebp',45h |
db 3,'ebx',43h |
db 3,'ecx',41h |
db 3,'edi',47h |
db 3,'edx',42h |
db 3,'esi',46h |
db 3,'esp',44h |
db 3,'r10',8Ah |
db 4,'r10d',4Ah |
db 3,'r11',8Bh |
db 4,'r11d',4Bh |
db 3,'r12',8Ch |
db 4,'r12d',4Ch |
db 3,'r13',8Dh |
db 4,'r13d',4Dh |
db 3,'r14',8Eh |
db 4,'r14d',4Eh |
db 3,'r15',8Fh |
db 4,'r15d',4Fh |
db 2,'r8',88h |
db 3,'r8d',48h |
db 2,'r9',89h |
db 3,'r9d',49h |
db 3,'rax',80h |
db 3,'rbp',85h |
db 3,'rbx',83h |
db 3,'rcx',81h |
db 3,'rdi',87h |
db 3,'rdx',82h |
db 3,'rip',0F0h |
db 3,'rsi',86h |
db 3,'rsp',84h |
db 2,'si',26h |
db 0 |
address_sizes: |
db 4,'byte',1 |
db 5,'dword',4 |
db 5,'qword',8 |
db 4,'word',2 |
db 0 |
symbols: |
dw symbols_2-symbols,(symbols_3-symbols_2)/(2+2) |
dw symbols_3-symbols,(symbols_4-symbols_3)/(3+2) |
dw symbols_4-symbols,(symbols_5-symbols_4)/(4+2) |
dw symbols_5-symbols,(symbols_6-symbols_5)/(5+2) |
dw symbols_6-symbols,(symbols_7-symbols_6)/(6+2) |
dw symbols_7-symbols,(symbols_8-symbols_7)/(7+2) |
dw symbols_8-symbols,(symbols_9-symbols_8)/(8+2) |
dw symbols_9-symbols,(symbols_10-symbols_9)/(9+2) |
dw symbols_10-symbols,(symbols_11-symbols_10)/(10+2) |
dw symbols_11-symbols,(symbols_end-symbols_11)/(11+2) |
symbols_2: |
db 'ah',10h,04h |
db 'al',10h,10h |
db 'ax',10h,20h |
db 'bh',10h,07h |
db 'bl',10h,13h |
db 'bp',10h,25h |
db 'bx',10h,23h |
db 'ch',10h,05h |
db 'cl',10h,11h |
db 'cs',10h,62h |
db 'cx',10h,21h |
db 'dh',10h,06h |
db 'di',10h,27h |
db 'dl',10h,12h |
db 'ds',10h,64h |
db 'dx',10h,22h |
db 'es',10h,61h |
db 'fs',10h,65h |
db 'gs',10h,66h |
db 'ms',17h,41h |
db 'mz',18h,20h |
db 'pe',18h,30h |
db 'r8',10h,88h |
db 'r9',10h,89h |
db 'si',10h,26h |
db 'sp',10h,24h |
db 'ss',10h,63h |
db 'st',10h,0A0h |
symbols_3: |
db 'bpl',10h,15h |
db 'cr0',10h,50h |
db 'cr1',10h,51h |
db 'cr2',10h,52h |
db 'cr3',10h,53h |
db 'cr4',10h,54h |
db 'cr5',10h,55h |
db 'cr6',10h,56h |
db 'cr7',10h,57h |
db 'cr8',10h,58h |
db 'cr9',10h,59h |
db 'dil',10h,17h |
db 'dll',1Bh,80h |
db 'dr0',10h,70h |
db 'dr1',10h,71h |
db 'dr2',10h,72h |
db 'dr3',10h,73h |
db 'dr4',10h,74h |
db 'dr5',10h,75h |
db 'dr6',10h,76h |
db 'dr7',10h,77h |
db 'dr8',10h,78h |
db 'dr9',10h,79h |
db 'eax',10h,40h |
db 'ebp',10h,45h |
db 'ebx',10h,43h |
db 'ecx',10h,41h |
db 'edi',10h,47h |
db 'edx',10h,42h |
db 'elf',18h,50h |
db 'esi',10h,46h |
db 'esp',10h,44h |
db 'far',12h,3 |
db 'gui',1Bh,2 |
db 'mm0',10h,0B0h |
db 'mm1',10h,0B1h |
db 'mm2',10h,0B2h |
db 'mm3',10h,0B3h |
db 'mm4',10h,0B4h |
db 'mm5',10h,0B5h |
db 'mm6',10h,0B6h |
db 'mm7',10h,0B7h |
db 'r10',10h,8Ah |
db 'r11',10h,8Bh |
db 'r12',10h,8Ch |
db 'r13',10h,8Dh |
db 'r14',10h,8Eh |
db 'r15',10h,8Fh |
db 'r8b',10h,18h |
db 'r8d',10h,48h |
db 'r8l',10h,18h |
db 'r8w',10h,28h |
db 'r9b',10h,19h |
db 'r9d',10h,49h |
db 'r9l',10h,19h |
db 'r9w',10h,29h |
db 'rax',10h,80h |
db 'rbp',10h,85h |
db 'rbx',10h,83h |
db 'rcx',10h,81h |
db 'rdi',10h,87h |
db 'rdx',10h,82h |
db 'rsi',10h,86h |
db 'rsp',10h,84h |
db 'sil',10h,16h |
db 'spl',10h,14h |
db 'st0',10h,0A0h |
db 'st1',10h,0A1h |
db 'st2',10h,0A2h |
db 'st3',10h,0A3h |
db 'st4',10h,0A4h |
db 'st5',10h,0A5h |
db 'st6',10h,0A6h |
db 'st7',10h,0A7h |
db 'tr0',10h,90h |
db 'tr1',10h,91h |
db 'tr2',10h,92h |
db 'tr3',10h,93h |
db 'tr4',10h,94h |
db 'tr5',10h,95h |
db 'tr6',10h,96h |
db 'tr7',10h,97h |
db 'wdm',1Bh,81h |
symbols_4: |
db 'byte',11h,1 |
db 'code',19h,5 |
db 'coff',18h,40h |
db 'cr10',10h,5Ah |
db 'cr11',10h,5Bh |
db 'cr12',10h,5Ch |
db 'cr13',10h,5Dh |
db 'cr14',10h,5Eh |
db 'cr15',10h,5Fh |
db 'data',19h,6 |
db 'dr10',10h,7Ah |
db 'dr11',10h,7Bh |
db 'dr12',10h,7Ch |
db 'dr13',10h,7Dh |
db 'dr14',10h,7Eh |
db 'dr15',10h,7Fh |
db 'ms64',17h,49h |
db 'near',12h,2 |
db 'pe64',18h,38h |
db 'r10b',10h,1Ah |
db 'r10d',10h,4Ah |
db 'r10l',10h,1Ah |
db 'r10w',10h,2Ah |
db 'r11b',10h,1Bh |
db 'r11d',10h,4Bh |
db 'r11l',10h,1Bh |
db 'r11w',10h,2Bh |
db 'r12b',10h,1Ch |
db 'r12d',10h,4Ch |
db 'r12l',10h,1Ch |
db 'r12w',10h,2Ch |
db 'r13b',10h,1Dh |
db 'r13d',10h,4Dh |
db 'r13l',10h,1Dh |
db 'r13w',10h,2Dh |
db 'r14b',10h,1Eh |
db 'r14d',10h,4Eh |
db 'r14l',10h,1Eh |
db 'r14w',10h,2Eh |
db 'r15b',10h,1Fh |
db 'r15d',10h,4Fh |
db 'r15l',10h,1Fh |
db 'r15w',10h,2Fh |
db 'word',11h,2 |
db 'xmm0',10h,0C0h |
db 'xmm1',10h,0C1h |
db 'xmm2',10h,0C2h |
db 'xmm3',10h,0C3h |
db 'xmm4',10h,0C4h |
db 'xmm5',10h,0C5h |
db 'xmm6',10h,0C6h |
db 'xmm7',10h,0C7h |
db 'xmm8',10h,0C8h |
db 'xmm9',10h,0C9h |
symbols_5: |
db 'align',1Ch,0 |
db 'dword',11h,4 |
db 'elf64',18h,58h |
db 'fword',11h,6 |
db 'pword',11h,6 |
db 'qword',11h,8 |
db 'short',12h,1 |
db 'tbyte',11h,0Ah |
db 'tword',11h,0Ah |
db 'use16',13h,16 |
db 'use32',13h,32 |
db 'use64',13h,64 |
db 'xmm10',10h,0CAh |
db 'xmm11',10h,0CBh |
db 'xmm12',10h,0CCh |
db 'xmm13',10h,0CDh |
db 'xmm14',10h,0CEh |
db 'xmm15',10h,0CFh |
symbols_6: |
db 'binary',18h,10h |
db 'dqword',11h,16 |
db 'export',1Ah,0 |
db 'fixups',1Ah,5 |
db 'import',1Ah,1 |
db 'native',1Bh,1 |
symbols_7: |
db 'console',1Bh,3 |
symbols_8: |
db 'linkinfo',19h,9 |
db 'readable',19h,30 |
db 'resource',1Ah,2 |
db 'writable',19h,31 |
symbols_9: |
db 'shareable',19h,28 |
db 'writeable',19h,31 |
symbols_10: |
db 'executable',19h,29 |
db 'linkremove',19h,11 |
symbols_11: |
db 'discardable',19h,25 |
db 'notpageable',19h,27 |
symbols_end: |
instructions: |
dw instructions_2-instructions,(instructions_3-instructions_2)/(2+3) |
dw instructions_3-instructions,(instructions_4-instructions_3)/(3+3) |
dw instructions_4-instructions,(instructions_5-instructions_4)/(4+3) |
dw instructions_5-instructions,(instructions_6-instructions_5)/(5+3) |
dw instructions_6-instructions,(instructions_7-instructions_6)/(6+3) |
dw instructions_7-instructions,(instructions_8-instructions_7)/(7+3) |
dw instructions_8-instructions,(instructions_9-instructions_8)/(8+3) |
dw instructions_9-instructions,(instructions_10-instructions_9)/(9+3) |
dw instructions_10-instructions,(instructions_11-instructions_10)/(10+3) |
dw instructions_11-instructions,(instructions_end-instructions_11)/(11+3) |
instructions_2: |
db 'bt',4 |
dw bt_instruction-assembler |
db 'if',0 |
dw if_directive-assembler |
db 'in',0 |
dw in_instruction-assembler |
db 'ja',77h |
dw conditional_jump-assembler |
db 'jb',72h |
dw conditional_jump-assembler |
db 'jc',72h |
dw conditional_jump-assembler |
db 'je',74h |
dw conditional_jump-assembler |
db 'jg',7Fh |
dw conditional_jump-assembler |
db 'jl',7Ch |
dw conditional_jump-assembler |
db 'jo',70h |
dw conditional_jump-assembler |
db 'jp',7Ah |
dw conditional_jump-assembler |
db 'js',78h |
dw conditional_jump-assembler |
db 'jz',74h |
dw conditional_jump-assembler |
db 'or',08h |
dw basic_instruction-assembler |
instructions_3: |
db 'aaa',37h |
dw simple_instruction_except64-assembler |
db 'aad',0D5h |
dw aa_instruction-assembler |
db 'aam',0D4h |
dw aa_instruction-assembler |
db 'aas',3Fh |
dw simple_instruction_except64-assembler |
db 'adc',10h |
dw basic_instruction-assembler |
db 'add',00h |
dw basic_instruction-assembler |
db 'and',20h |
dw basic_instruction-assembler |
db 'bsf',0BCh |
dw bs_instruction-assembler |
db 'bsr',0BDh |
dw bs_instruction-assembler |
db 'btc',7 |
dw bt_instruction-assembler |
db 'btr',6 |
dw bt_instruction-assembler |
db 'bts',5 |
dw bt_instruction-assembler |
db 'cbw',98h |
dw simple_instruction_16bit-assembler |
db 'cdq',99h |
dw simple_instruction_32bit-assembler |
db 'clc',0F8h |
dw simple_instruction-assembler |
db 'cld',0FCh |
dw simple_instruction-assembler |
db 'cli',0FAh |
dw simple_instruction-assembler |
db 'cmc',0F5h |
dw simple_instruction-assembler |
db 'cmp',38h |
dw basic_instruction-assembler |
db 'cqo',99h |
dw simple_instruction_64bit-assembler |
db 'cwd',99h |
dw simple_instruction_16bit-assembler |
db 'daa',27h |
dw simple_instruction_except64-assembler |
db 'das',2Fh |
dw simple_instruction_except64-assembler |
db 'dec',1 |
dw inc_instruction-assembler |
db 'div',6 |
dw single_operand_instruction-assembler |
db 'end',0 |
dw end_directive-assembler |
db 'fld',0 |
dw fld_instruction-assembler |
db 'fst',2 |
dw fld_instruction-assembler |
db 'hlt',0F4h |
dw simple_instruction-assembler |
db 'inc',0 |
dw inc_instruction-assembler |
db 'ins',6Ch |
dw ins_instruction-assembler |
db 'int',0CDh |
dw int_instruction-assembler |
db 'jae',73h |
dw conditional_jump-assembler |
db 'jbe',76h |
dw conditional_jump-assembler |
db 'jge',7Dh |
dw conditional_jump-assembler |
db 'jle',7Eh |
dw conditional_jump-assembler |
db 'jmp',0 |
dw jmp_instruction-assembler |
db 'jna',76h |
dw conditional_jump-assembler |
db 'jnb',73h |
dw conditional_jump-assembler |
db 'jnc',73h |
dw conditional_jump-assembler |
db 'jne',75h |
dw conditional_jump-assembler |
db 'jng',7Eh |
dw conditional_jump-assembler |
db 'jnl',7Dh |
dw conditional_jump-assembler |
db 'jno',71h |
dw conditional_jump-assembler |
db 'jnp',7Bh |
dw conditional_jump-assembler |
db 'jns',79h |
dw conditional_jump-assembler |
db 'jnz',75h |
dw conditional_jump-assembler |
db 'jpe',7Ah |
dw conditional_jump-assembler |
db 'jpo',7Bh |
dw conditional_jump-assembler |
db 'lar',2 |
dw lar_instruction-assembler |
db 'lds',3 |
dw ls_instruction-assembler |
db 'lea',0 |
dw lea_instruction-assembler |
db 'les',0 |
dw ls_instruction-assembler |
db 'lfs',4 |
dw ls_instruction-assembler |
db 'lgs',5 |
dw ls_instruction-assembler |
db 'lsl',3 |
dw lar_instruction-assembler |
db 'lss',2 |
dw ls_instruction-assembler |
db 'ltr',3 |
dw pm_word_instruction-assembler |
db 'mov',0 |
dw mov_instruction-assembler |
db 'mul',4 |
dw single_operand_instruction-assembler |
db 'neg',3 |
dw single_operand_instruction-assembler |
db 'nop',90h |
dw simple_instruction-assembler |
db 'not',2 |
dw single_operand_instruction-assembler |
db 'org',0 |
dw org_directive-assembler |
db 'out',0 |
dw out_instruction-assembler |
db 'pop',0 |
dw pop_instruction-assembler |
db 'por',0EBh |
dw mmx_instruction-assembler |
db 'rcl',2 |
dw sh_instruction-assembler |
db 'rcr',3 |
dw sh_instruction-assembler |
db 'rep',0F3h |
dw prefix_instruction-assembler |
db 'ret',0C2h |
dw ret_instruction-assembler |
db 'rol',0 |
dw sh_instruction-assembler |
db 'ror',1 |
dw sh_instruction-assembler |
db 'rsm',0AAh |
dw simple_extended_instruction-assembler |
db 'sal',4 |
dw sh_instruction-assembler |
db 'sar',7 |
dw sh_instruction-assembler |
db 'sbb',18h |
dw basic_instruction-assembler |
db 'shl',4 |
dw sh_instruction-assembler |
db 'shr',5 |
dw sh_instruction-assembler |
db 'stc',0F9h |
dw simple_instruction-assembler |
db 'std',0FDh |
dw simple_instruction-assembler |
db 'sti',0FBh |
dw simple_instruction-assembler |
db 'str',1 |
dw pm_store_word_instruction-assembler |
db 'sub',28h |
dw basic_instruction-assembler |
db 'ud2',0Bh |
dw simple_extended_instruction-assembler |
db 'xor',30h |
dw basic_instruction-assembler |
instructions_4: |
db 'arpl',0 |
dw arpl_instruction-assembler |
db 'call',0 |
dw call_instruction-assembler |
db 'cdqe',98h |
dw simple_instruction_64bit-assembler |
db 'clgi',0DDh |
dw simple_vmx_instruction-assembler |
db 'clts',6 |
dw simple_extended_instruction-assembler |
db 'cmps',0A6h |
dw cmps_instruction-assembler |
db 'cwde',98h |
dw simple_instruction_32bit-assembler |
db 'data',0 |
dw data_directive-assembler |
db 'else',0 |
dw else_directive-assembler |
db 'emms',77h |
dw simple_extended_instruction-assembler |
db 'fabs',100001b |
dw simple_fpu_instruction-assembler |
db 'fadd',0 |
dw basic_fpu_instruction-assembler |
db 'fbld',4 |
dw fbld_instruction-assembler |
db 'fchs',100000b |
dw simple_fpu_instruction-assembler |
db 'fcom',2 |
dw basic_fpu_instruction-assembler |
db 'fcos',111111b |
dw simple_fpu_instruction-assembler |
db 'fdiv',6 |
dw basic_fpu_instruction-assembler |
db 'feni',0E0h |
dw finit_instruction-assembler |
db 'fild',0 |
dw fild_instruction-assembler |
db 'fist',2 |
dw fild_instruction-assembler |
db 'fld1',101000b |
dw simple_fpu_instruction-assembler |
db 'fldz',101110b |
dw simple_fpu_instruction-assembler |
db 'fmul',1 |
dw basic_fpu_instruction-assembler |
db 'fnop',010000b |
dw simple_fpu_instruction-assembler |
db 'fsin',111110b |
dw simple_fpu_instruction-assembler |
db 'fstp',3 |
dw fld_instruction-assembler |
db 'fsub',4 |
dw basic_fpu_instruction-assembler |
db 'ftst',100100b |
dw simple_fpu_instruction-assembler |
db 'fxam',100101b |
dw simple_fpu_instruction-assembler |
db 'fxch',0 |
dw fxch_instruction-assembler |
db 'heap',0 |
dw heap_directive-assembler |
db 'idiv',7 |
dw single_operand_instruction-assembler |
db 'imul',0 |
dw imul_instruction-assembler |
db 'insb',6Ch |
dw simple_instruction-assembler |
db 'insd',6Dh |
dw simple_instruction_32bit-assembler |
db 'insw',6Dh |
dw simple_instruction_16bit-assembler |
db 'int1',0F1h |
dw simple_instruction-assembler |
db 'int3',0CCh |
dw simple_instruction-assembler |
db 'into',0CEh |
dw simple_instruction_except64-assembler |
db 'invd',8 |
dw simple_extended_instruction-assembler |
db 'iret',0CFh |
dw iret_instruction-assembler |
db 'jcxz',0E3h |
dw loop_instruction_16bit-assembler |
db 'jnae',72h |
dw conditional_jump-assembler |
db 'jnbe',77h |
dw conditional_jump-assembler |
db 'jnge',7Ch |
dw conditional_jump-assembler |
db 'jnle',7Fh |
dw conditional_jump-assembler |
db 'lahf',9Fh |
dw simple_instruction-assembler |
db 'lgdt',2 |
dw lgdt_instruction-assembler |
db 'lidt',3 |
dw lgdt_instruction-assembler |
db 'lldt',2 |
dw pm_word_instruction-assembler |
db 'lmsw',16h |
dw pm_word_instruction-assembler |
db 'load',0 |
dw load_directive-assembler |
db 'lock',0F0h |
dw prefix_instruction-assembler |
db 'lods',0ACh |
dw lods_instruction-assembler |
db 'loop',0E2h |
dw loop_instruction-assembler |
db 'movd',0 |
dw movd_instruction-assembler |
db 'movq',0 |
dw movq_instruction-assembler |
db 'movs',0A4h |
dw movs_instruction-assembler |
db 'orpd',56h |
dw sse_pd_instruction-assembler |
db 'orps',56h |
dw sse_ps_instruction-assembler |
db 'outs',6Eh |
dw outs_instruction-assembler |
db 'pand',0DBh |
dw mmx_instruction-assembler |
db 'popa',61h |
dw simple_instruction_except64-assembler |
db 'popd',4 |
dw pop_instruction-assembler |
db 'popf',9Dh |
dw simple_instruction-assembler |
db 'popq',8 |
dw pop_instruction-assembler |
db 'popw',2 |
dw pop_instruction-assembler |
db 'push',0 |
dw push_instruction-assembler |
db 'pxor',0EFh |
dw mmx_instruction-assembler |
db 'repe',0F3h |
dw prefix_instruction-assembler |
db 'repz',0F3h |
dw prefix_instruction-assembler |
db 'retd',0C2h |
dw ret_instruction_32bit_except64-assembler |
db 'retf',0CAh |
dw retf_instruction-assembler |
db 'retn',0C2h |
dw ret_instruction-assembler |
db 'retq',0C2h |
dw ret_instruction_only64-assembler |
db 'retw',0C2h |
dw ret_instruction_16bit-assembler |
db 'sahf',9Eh |
dw simple_instruction-assembler |
db 'salc',0D6h |
dw simple_instruction_except64-assembler |
db 'scas',0AEh |
dw stos_instruction-assembler |
db 'seta',97h |
dw set_instruction-assembler |
db 'setb',92h |
dw set_instruction-assembler |
db 'setc',92h |
dw set_instruction-assembler |
db 'sete',94h |
dw set_instruction-assembler |
db 'setg',9Fh |
dw set_instruction-assembler |
db 'setl',9Ch |
dw set_instruction-assembler |
db 'seto',90h |
dw set_instruction-assembler |
db 'setp',9Ah |
dw set_instruction-assembler |
db 'sets',98h |
dw set_instruction-assembler |
db 'setz',94h |
dw set_instruction-assembler |
db 'sgdt',0 |
dw lgdt_instruction-assembler |
db 'shld',0A4h |
dw shd_instruction-assembler |
db 'shrd',0ACh |
dw shd_instruction-assembler |
db 'sidt',1 |
dw lgdt_instruction-assembler |
db 'sldt',0 |
dw pm_store_word_instruction-assembler |
db 'smsw',14h |
dw pm_store_word_instruction-assembler |
db 'stgi',0DCh |
dw simple_vmx_instruction-assembler |
db 'stos',0AAh |
dw stos_instruction-assembler |
db 'test',0 |
dw test_instruction-assembler |
db 'verr',4 |
dw pm_word_instruction-assembler |
db 'verw',5 |
dw pm_word_instruction-assembler |
db 'wait',9Bh |
dw simple_instruction-assembler |
db 'xadd',0C0h |
dw basic_486_instruction-assembler |
db 'xchg',0 |
dw xchg_instruction-assembler |
db 'xlat',0D7h |
dw xlat_instruction-assembler |
instructions_5: |
db 'addpd',58h |
dw sse_pd_instruction-assembler |
db 'addps',58h |
dw sse_ps_instruction-assembler |
db 'addsd',58h |
dw sse_sd_instruction-assembler |
db 'addss',58h |
dw sse_ss_instruction-assembler |
db 'align',0 |
dw align_directive-assembler |
db 'andpd',54h |
dw sse_pd_instruction-assembler |
db 'andps',54h |
dw sse_ps_instruction-assembler |
db 'bound',0 |
dw bound_instruction-assembler |
db 'break',0 |
dw break_directive-assembler |
db 'bswap',0 |
dw bswap_instruction-assembler |
db 'cmova',47h |
dw cmov_instruction-assembler |
db 'cmovb',42h |
dw cmov_instruction-assembler |
db 'cmovc',42h |
dw cmov_instruction-assembler |
db 'cmove',44h |
dw cmov_instruction-assembler |
db 'cmovg',4Fh |
dw cmov_instruction-assembler |
db 'cmovl',4Ch |
dw cmov_instruction-assembler |
db 'cmovo',40h |
dw cmov_instruction-assembler |
db 'cmovp',4Ah |
dw cmov_instruction-assembler |
db 'cmovs',48h |
dw cmov_instruction-assembler |
db 'cmovz',44h |
dw cmov_instruction-assembler |
db 'cmppd',0 |
dw cmppd_instruction-assembler |
db 'cmpps',0 |
dw cmpps_instruction-assembler |
db 'cmpsb',0A6h |
dw simple_instruction-assembler |
db 'cmpsd',0 |
dw cmpsd_instruction-assembler |
db 'cmpsq',0A7h |
dw simple_instruction_64bit-assembler |
db 'cmpss',0 |
dw cmpss_instruction-assembler |
db 'cmpsw',0A7h |
dw simple_instruction_16bit-assembler |
db 'cpuid',0A2h |
dw simple_extended_instruction-assembler |
db 'divpd',5Eh |
dw sse_pd_instruction-assembler |
db 'divps',5Eh |
dw sse_ps_instruction-assembler |
db 'divsd',5Eh |
dw sse_sd_instruction-assembler |
db 'divss',5Eh |
dw sse_ss_instruction-assembler |
db 'enter',0 |
dw enter_instruction-assembler |
db 'entry',0 |
dw entry_directive-assembler |
db 'extrn',0 |
dw extrn_directive-assembler |
db 'f2xm1',110000b |
dw simple_fpu_instruction-assembler |
db 'faddp',0 |
dw faddp_instruction-assembler |
db 'fbstp',6 |
dw fbld_instruction-assembler |
db 'fclex',0E2h |
dw finit_instruction-assembler |
db 'fcomi',0F0h |
dw fcomi_instruction-assembler |
db 'fcomp',3 |
dw basic_fpu_instruction-assembler |
db 'fdisi',0E1h |
dw finit_instruction-assembler |
db 'fdivp',7 |
dw faddp_instruction-assembler |
db 'fdivr',7 |
dw basic_fpu_instruction-assembler |
db 'femms',0Eh |
dw simple_extended_instruction-assembler |
db 'ffree',0 |
dw ffree_instruction-assembler |
db 'fiadd',0 |
dw fi_instruction-assembler |
db 'ficom',2 |
dw fi_instruction-assembler |
db 'fidiv',6 |
dw fi_instruction-assembler |
db 'fimul',1 |
dw fi_instruction-assembler |
db 'finit',0E3h |
dw finit_instruction-assembler |
db 'fistp',3 |
dw fild_instruction-assembler |
db 'fisub',4 |
dw fi_instruction-assembler |
db 'fldcw',5 |
dw fldcw_instruction-assembler |
db 'fldpi',101011b |
dw simple_fpu_instruction-assembler |
db 'fmulp',1 |
dw faddp_instruction-assembler |
db 'fneni',0E0h |
dw fninit_instruction-assembler |
db 'fprem',111000b |
dw simple_fpu_instruction-assembler |
db 'fptan',110010b |
dw simple_fpu_instruction-assembler |
db 'fsave',6 |
dw fsave_instruction-assembler |
db 'fsqrt',111010b |
dw simple_fpu_instruction-assembler |
db 'fstcw',7 |
dw fstcw_instruction-assembler |
db 'fstsw',0 |
dw fstsw_instruction-assembler |
db 'fsubp',5 |
dw faddp_instruction-assembler |
db 'fsubr',5 |
dw basic_fpu_instruction-assembler |
db 'fucom',4 |
dw ffree_instruction-assembler |
db 'fwait',9Bh |
dw simple_instruction-assembler |
db 'fyl2x',110001b |
dw simple_fpu_instruction-assembler |
db 'icebp',0F1h |
dw simple_instruction-assembler |
db 'iretd',0CFh |
dw simple_instruction_32bit-assembler |
db 'iretq',0CFh |
dw simple_instruction_64bit-assembler |
db 'iretw',0CFh |
dw simple_instruction_16bit-assembler |
db 'jecxz',0E3h |
dw loop_instruction_32bit-assembler |
db 'jrcxz',0E3h |
dw loop_instruction_64bit-assembler |
db 'label',0 |
dw label_directive-assembler |
db 'lddqu',0 |
dw lddqu_instruction-assembler |
db 'leave',0C9h |
dw simple_instruction-assembler |
db 'lodsb',0ACh |
dw simple_instruction-assembler |
db 'lodsd',0ADh |
dw simple_instruction_32bit-assembler |
db 'lodsq',0ADh |
dw simple_instruction_64bit-assembler |
db 'lodsw',0ADh |
dw simple_instruction_16bit-assembler |
db 'loopd',0E2h |
dw loop_instruction_32bit-assembler |
db 'loope',0E1h |
dw loop_instruction-assembler |
db 'loopq',0E2h |
dw loop_instruction_64bit-assembler |
db 'loopw',0E2h |
dw loop_instruction_16bit-assembler |
db 'loopz',0E1h |
dw loop_instruction-assembler |
db 'maxpd',5Fh |
dw sse_pd_instruction-assembler |
db 'maxps',5Fh |
dw sse_ps_instruction-assembler |
db 'maxsd',5Fh |
dw sse_sd_instruction-assembler |
db 'maxss',5Fh |
dw sse_ss_instruction-assembler |
db 'minpd',5Dh |
dw sse_pd_instruction-assembler |
db 'minps',5Dh |
dw sse_ps_instruction-assembler |
db 'minsd',5Dh |
dw sse_sd_instruction-assembler |
db 'minss',5Dh |
dw sse_ss_instruction-assembler |
db 'movsb',0A4h |
dw simple_instruction-assembler |
db 'movsd',0 |
dw movsd_instruction-assembler |
db 'movsq',0A5h |
dw simple_instruction_64bit-assembler |
db 'movss',0 |
dw movss_instruction-assembler |
db 'movsw',0A5h |
dw simple_instruction_16bit-assembler |
db 'movsx',0BEh |
dw movx_instruction-assembler |
db 'movzx',0B6h |
dw movx_instruction-assembler |
db 'mulpd',59h |
dw sse_pd_instruction-assembler |
db 'mulps',59h |
dw sse_ps_instruction-assembler |
db 'mulsd',59h |
dw sse_sd_instruction-assembler |
db 'mulss',59h |
dw sse_ss_instruction-assembler |
db 'mwait',0C9h |
dw monitor_instruction-assembler |
db 'outsb',6Eh |
dw simple_instruction-assembler |
db 'outsd',6Fh |
dw simple_instruction_32bit-assembler |
db 'outsw',6Fh |
dw simple_instruction_16bit-assembler |
db 'paddb',0FCh |
dw mmx_instruction-assembler |
db 'paddd',0FEh |
dw mmx_instruction-assembler |
db 'paddq',0D4h |
dw mmx_instruction-assembler |
db 'paddw',0FDh |
dw mmx_instruction-assembler |
db 'pandn',0DFh |
dw mmx_instruction-assembler |
db 'pause',0 |
dw pause_instruction-assembler |
db 'pavgb',0E0h |
dw mmx_instruction-assembler |
db 'pavgw',0E3h |
dw mmx_instruction-assembler |
db 'pf2id',1Dh |
dw amd3dnow_instruction-assembler |
db 'pf2iw',1Ch |
dw amd3dnow_instruction-assembler |
db 'pfacc',0AEh |
dw amd3dnow_instruction-assembler |
db 'pfadd',9Eh |
dw amd3dnow_instruction-assembler |
db 'pfmax',0A4h |
dw amd3dnow_instruction-assembler |
db 'pfmin',94h |
dw amd3dnow_instruction-assembler |
db 'pfmul',0B4h |
dw amd3dnow_instruction-assembler |
db 'pfrcp',96h |
dw amd3dnow_instruction-assembler |
db 'pfsub',9Ah |
dw amd3dnow_instruction-assembler |
db 'pi2fd',0Dh |
dw amd3dnow_instruction-assembler |
db 'pi2fw',0Ch |
dw amd3dnow_instruction-assembler |
db 'popad',61h |
dw simple_instruction_32bit_except64-assembler |
db 'popaw',61h |
dw simple_instruction_16bit_except64-assembler |
db 'popfd',9Dh |
dw simple_instruction_32bit_except64-assembler |
db 'popfq',9Dh |
dw simple_instruction_only64-assembler |
db 'popfw',9Dh |
dw simple_instruction_16bit-assembler |
db 'pslld',0F2h |
dw mmx_ps_instruction-assembler |
db 'psllq',0F3h |
dw mmx_ps_instruction-assembler |
db 'psllw',0F1h |
dw mmx_ps_instruction-assembler |
db 'psrad',0E2h |
dw mmx_ps_instruction-assembler |
db 'psraw',0E1h |
dw mmx_ps_instruction-assembler |
db 'psrld',0D2h |
dw mmx_ps_instruction-assembler |
db 'psrlq',0D3h |
dw mmx_ps_instruction-assembler |
db 'psrlw',0D1h |
dw mmx_ps_instruction-assembler |
db 'psubb',0F8h |
dw mmx_instruction-assembler |
db 'psubd',0FAh |
dw mmx_instruction-assembler |
db 'psubq',0FBh |
dw mmx_instruction-assembler |
db 'psubw',0F9h |
dw mmx_instruction-assembler |
db 'pusha',60h |
dw simple_instruction_except64-assembler |
db 'pushd',4 |
dw push_instruction-assembler |
db 'pushf',9Ch |
dw simple_instruction-assembler |
db 'pushq',8 |
dw push_instruction-assembler |
db 'pushw',2 |
dw push_instruction-assembler |
db 'rcpps',53h |
dw sse_ps_instruction-assembler |
db 'rcpss',53h |
dw sse_ss_instruction-assembler |
db 'rdmsr',32h |
dw simple_extended_instruction-assembler |
db 'rdpmc',33h |
dw simple_extended_instruction-assembler |
db 'rdtsc',31h |
dw simple_extended_instruction-assembler |
db 'repne',0F2h |
dw prefix_instruction-assembler |
db 'repnz',0F2h |
dw prefix_instruction-assembler |
db 'retfd',0CAh |
dw ret_instruction_32bit-assembler |
db 'retfq',0CAh |
dw ret_instruction_64bit-assembler |
db 'retfw',0CAh |
dw ret_instruction_16bit-assembler |
db 'retnd',0C2h |
dw ret_instruction_32bit_except64-assembler |
db 'retnq',0C2h |
dw ret_instruction_only64-assembler |
db 'retnw',0C2h |
dw ret_instruction_16bit-assembler |
db 'scasb',0AEh |
dw simple_instruction-assembler |
db 'scasd',0AFh |
dw simple_instruction_32bit-assembler |
db 'scasq',0AFh |
dw simple_instruction_64bit-assembler |
db 'scasw',0AFh |
dw simple_instruction_16bit-assembler |
db 'setae',93h |
dw set_instruction-assembler |
db 'setbe',96h |
dw set_instruction-assembler |
db 'setge',9Dh |
dw set_instruction-assembler |
db 'setle',9Eh |
dw set_instruction-assembler |
db 'setna',96h |
dw set_instruction-assembler |
db 'setnb',93h |
dw set_instruction-assembler |
db 'setnc',93h |
dw set_instruction-assembler |
db 'setne',95h |
dw set_instruction-assembler |
db 'setng',9Eh |
dw set_instruction-assembler |
db 'setnl',9Dh |
dw set_instruction-assembler |
db 'setno',91h |
dw set_instruction-assembler |
db 'setnp',9Bh |
dw set_instruction-assembler |
db 'setns',99h |
dw set_instruction-assembler |
db 'setnz',95h |
dw set_instruction-assembler |
db 'setpe',9Ah |
dw set_instruction-assembler |
db 'setpo',9Bh |
dw set_instruction-assembler |
db 'stack',0 |
dw stack_directive-assembler |
db 'store',0 |
dw store_directive-assembler |
db 'stosb',0AAh |
dw simple_instruction-assembler |
db 'stosd',0ABh |
dw simple_instruction_32bit-assembler |
db 'stosq',0ABh |
dw simple_instruction_64bit-assembler |
db 'stosw',0ABh |
dw simple_instruction_16bit-assembler |
db 'subpd',5Ch |
dw sse_pd_instruction-assembler |
db 'subps',5Ch |
dw sse_ps_instruction-assembler |
db 'subsd',5Ch |
dw sse_sd_instruction-assembler |
db 'subss',5Ch |
dw sse_ss_instruction-assembler |
db 'times',0 |
dw times_directive-assembler |
db 'vmrun',0D8h |
dw simple_svm_instruction-assembler |
db 'vmxon',6 |
dw vmxon_instruction-assembler |
db 'while',0 |
dw while_directive-assembler |
db 'wrmsr',30h |
dw simple_extended_instruction-assembler |
db 'xlatb',0D7h |
dw simple_instruction-assembler |
db 'xorpd',57h |
dw sse_pd_instruction-assembler |
db 'xorps',57h |
dw sse_ps_instruction-assembler |
instructions_6: |
db 'andnpd',55h |
dw sse_pd_instruction-assembler |
db 'andnps',55h |
dw sse_ps_instruction-assembler |
db 'cmovae',43h |
dw cmov_instruction-assembler |
db 'cmovbe',46h |
dw cmov_instruction-assembler |
db 'cmovge',4Dh |
dw cmov_instruction-assembler |
db 'cmovle',4Eh |
dw cmov_instruction-assembler |
db 'cmovna',46h |
dw cmov_instruction-assembler |
db 'cmovnb',43h |
dw cmov_instruction-assembler |
db 'cmovnc',43h |
dw cmov_instruction-assembler |
db 'cmovne',45h |
dw cmov_instruction-assembler |
db 'cmovng',4Eh |
dw cmov_instruction-assembler |
db 'cmovnl',4Dh |
dw cmov_instruction-assembler |
db 'cmovno',41h |
dw cmov_instruction-assembler |
db 'cmovnp',4Bh |
dw cmov_instruction-assembler |
db 'cmovns',49h |
dw cmov_instruction-assembler |
db 'cmovnz',45h |
dw cmov_instruction-assembler |
db 'cmovpe',4Ah |
dw cmov_instruction-assembler |
db 'cmovpo',4Bh |
dw cmov_instruction-assembler |
db 'comisd',2Fh |
dw comisd_instruction-assembler |
db 'comiss',2Fh |
dw comiss_instruction-assembler |
db 'fcmovb',0C0h |
dw fcmov_instruction-assembler |
db 'fcmove',0C8h |
dw fcmov_instruction-assembler |
db 'fcmovu',0D8h |
dw fcmov_instruction-assembler |
db 'fcomip',0F0h |
dw fcomip_instruction-assembler |
db 'fcompp',0 |
dw fcompp_instruction-assembler |
db 'fdivrp',6 |
dw faddp_instruction-assembler |
db 'ffreep',0 |
dw ffreep_instruction-assembler |
db 'ficomp',3 |
dw fi_instruction-assembler |
db 'fidivr',7 |
dw fi_instruction-assembler |
db 'fisttp',1 |
dw fild_instruction-assembler |
db 'fisubr',5 |
dw fi_instruction-assembler |
db 'fldenv',4 |
dw fldenv_instruction-assembler |
db 'fldl2e',101010b |
dw simple_fpu_instruction-assembler |
db 'fldl2t',101001b |
dw simple_fpu_instruction-assembler |
db 'fldlg2',101100b |
dw simple_fpu_instruction-assembler |
db 'fldln2',101101b |
dw simple_fpu_instruction-assembler |
db 'fnclex',0E2h |
dw fninit_instruction-assembler |
db 'fndisi',0E1h |
dw fninit_instruction-assembler |
db 'fninit',0E3h |
dw fninit_instruction-assembler |
db 'fnsave',6 |
dw fnsave_instruction-assembler |
db 'fnstcw',7 |
dw fldcw_instruction-assembler |
db 'fnstsw',0 |
dw fnstsw_instruction-assembler |
db 'format',0 |
dw format_directive-assembler |
db 'fpatan',110011b |
dw simple_fpu_instruction-assembler |
db 'fprem1',110101b |
dw simple_fpu_instruction-assembler |
db 'frstor',4 |
dw fnsave_instruction-assembler |
db 'frstpm',0E5h |
dw fninit_instruction-assembler |
db 'fscale',111101b |
dw simple_fpu_instruction-assembler |
db 'fsetpm',0E4h |
dw fninit_instruction-assembler |
db 'fstenv',6 |
dw fstenv_instruction-assembler |
db 'fsubrp',4 |
dw faddp_instruction-assembler |
db 'fucomi',0E8h |
dw fcomi_instruction-assembler |
db 'fucomp',5 |
dw ffree_instruction-assembler |
db 'fxsave',0 |
dw fxsave_instruction-assembler |
db 'haddpd',07Ch |
dw sse_pd_instruction-assembler |
db 'haddps',07Ch |
dw cvtpd2dq_instruction-assembler |
db 'hsubpd',07Dh |
dw sse_pd_instruction-assembler |
db 'hsubps',07Dh |
dw cvtpd2dq_instruction-assembler |
db 'invlpg',0 |
dw invlpg_instruction-assembler |
db 'lfence',0E8h |
dw fence_instruction-assembler |
db 'looped',0E1h |
dw loop_instruction_32bit-assembler |
db 'loopeq',0E1h |
dw loop_instruction_64bit-assembler |
db 'loopew',0E1h |
dw loop_instruction_16bit-assembler |
db 'loopne',0E0h |
dw loop_instruction-assembler |
db 'loopnz',0E0h |
dw loop_instruction-assembler |
db 'loopzd',0E1h |
dw loop_instruction_32bit-assembler |
db 'loopzq',0E1h |
dw loop_instruction_64bit-assembler |
db 'loopzw',0E1h |
dw loop_instruction_16bit-assembler |
db 'mfence',0F0h |
dw fence_instruction-assembler |
db 'movapd',28h |
dw movpd_instruction-assembler |
db 'movaps',28h |
dw movps_instruction-assembler |
db 'movdqa',66h |
dw movdq_instruction-assembler |
db 'movdqu',0F3h |
dw movdq_instruction-assembler |
db 'movhpd',16h |
dw movlpd_instruction-assembler |
db 'movhps',16h |
dw movlps_instruction-assembler |
db 'movlpd',12h |
dw movlpd_instruction-assembler |
db 'movlps',12h |
dw movlps_instruction-assembler |
db 'movnti',0C3h |
dw movnti_instruction-assembler |
db 'movntq',0E7h |
dw movntq_instruction-assembler |
db 'movsxd',63h |
dw movsxd_instruction-assembler |
db 'movupd',10h |
dw movpd_instruction-assembler |
db 'movups',10h |
dw movps_instruction-assembler |
db 'paddsb',0ECh |
dw mmx_instruction-assembler |
db 'paddsw',0EDh |
dw mmx_instruction-assembler |
db 'pextrw',0C5h |
dw pextrw_instruction-assembler |
db 'pfnacc',8Ah |
dw amd3dnow_instruction-assembler |
db 'pfsubr',0AAh |
dw amd3dnow_instruction-assembler |
db 'pinsrw',0C4h |
dw pinsrw_instruction-assembler |
db 'pmaxsw',0EEh |
dw mmx_instruction-assembler |
db 'pmaxub',0DEh |
dw mmx_instruction-assembler |
db 'pminsw',0EAh |
dw mmx_instruction-assembler |
db 'pminub',0DAh |
dw mmx_instruction-assembler |
db 'pmulhw',0E5h |
dw mmx_instruction-assembler |
db 'pmullw',0D5h |
dw mmx_instruction-assembler |
db 'psadbw',0F6h |
dw mmx_instruction-assembler |
db 'pshufd',66h |
dw pshufd_instruction-assembler |
db 'pshufw',0 |
dw pshufw_instruction-assembler |
db 'pslldq',111b |
dw ps_dq_instruction-assembler |
db 'psrldq',011b |
dw ps_dq_instruction-assembler |
db 'psubsb',0E8h |
dw mmx_instruction-assembler |
db 'psubsw',0E9h |
dw mmx_instruction-assembler |
db 'pswapd',0BBh |
dw amd3dnow_instruction-assembler |
db 'public',0 |
dw public_directive-assembler |
db 'pushad',60h |
dw simple_instruction_32bit_except64-assembler |
db 'pushaw',60h |
dw simple_instruction_16bit_except64-assembler |
db 'pushfd',9Ch |
dw simple_instruction_32bit_except64-assembler |
db 'pushfq',9Ch |
dw simple_instruction_only64-assembler |
db 'pushfw',9Ch |
dw simple_instruction_16bit-assembler |
db 'rdtscp',1 |
dw swapgs_instruction-assembler |
db 'repeat',0 |
dw repeat_directive-assembler |
db 'setalc',0D6h |
dw simple_instruction_except64-assembler |
db 'setnae',92h |
dw set_instruction-assembler |
db 'setnbe',97h |
dw set_instruction-assembler |
db 'setnge',9Ch |
dw set_instruction-assembler |
db 'setnle',9Fh |
dw set_instruction-assembler |
db 'sfence',0F8h |
dw fence_instruction-assembler |
db 'shufpd',0C6h |
dw sse_pd_instruction-assembler |
db 'shufps',0C6h |
dw sse_ps_instruction-assembler |
db 'skinit',0 |
dw skinit_instruction-assembler |
db 'sqrtpd',51h |
dw sse_pd_instruction-assembler |
db 'sqrtps',51h |
dw sse_ps_instruction-assembler |
db 'sqrtsd',51h |
dw sse_sd_instruction-assembler |
db 'sqrtss',51h |
dw sse_ss_instruction-assembler |
db 'swapgs',0 |
dw swapgs_instruction-assembler |
db 'sysret',07h |
dw simple_extended_instruction-assembler |
db 'vmcall',0C1h |
dw simple_vmx_instruction-assembler |
db 'vmload',0DAh |
dw simple_svm_instruction-assembler |
db 'vmread',0 |
dw vmread_instruction-assembler |
db 'vmsave',0DBh |
dw simple_svm_instruction-assembler |
db 'vmxoff',0C4h |
dw simple_vmx_instruction-assembler |
db 'wbinvd',9 |
dw simple_extended_instruction-assembler |
instructions_7: |
db 'clflush',111b |
dw fxsave_instruction-assembler |
db 'cmovnae',42h |
dw cmov_instruction-assembler |
db 'cmovnbe',47h |
dw cmov_instruction-assembler |
db 'cmovnge',4Ch |
dw cmov_instruction-assembler |
db 'cmovnle',4Fh |
dw cmov_instruction-assembler |
db 'cmpeqpd',0 |
dw cmp_pd_instruction-assembler |
db 'cmpeqps',0 |
dw cmp_ps_instruction-assembler |
db 'cmpeqsd',0 |
dw cmp_sd_instruction-assembler |
db 'cmpeqss',0 |
dw cmp_ss_instruction-assembler |
db 'cmplepd',2 |
dw cmp_pd_instruction-assembler |
db 'cmpleps',2 |
dw cmp_ps_instruction-assembler |
db 'cmplesd',2 |
dw cmp_sd_instruction-assembler |
db 'cmpless',2 |
dw cmp_ss_instruction-assembler |
db 'cmpltpd',1 |
dw cmp_pd_instruction-assembler |
db 'cmpltps',1 |
dw cmp_ps_instruction-assembler |
db 'cmpltsd',1 |
dw cmp_sd_instruction-assembler |
db 'cmpltss',1 |
dw cmp_ss_instruction-assembler |
db 'cmpxchg',0B0h |
dw basic_486_instruction-assembler |
db 'display',0 |
dw display_directive-assembler |
db 'fcmovbe',0D0h |
dw fcmov_instruction-assembler |
db 'fcmovnb',0C0h |
dw fcomi_instruction-assembler |
db 'fcmovne',0C8h |
dw fcomi_instruction-assembler |
db 'fcmovnu',0D8h |
dw fcomi_instruction-assembler |
db 'fdecstp',110110b |
dw simple_fpu_instruction-assembler |
db 'fincstp',110111b |
dw simple_fpu_instruction-assembler |
db 'fnstenv',6 |
dw fldenv_instruction-assembler |
db 'frndint',111100b |
dw simple_fpu_instruction-assembler |
db 'fsincos',111011b |
dw simple_fpu_instruction-assembler |
db 'fucomip',0E8h |
dw fcomip_instruction-assembler |
db 'fucompp',0 |
dw fucompp_instruction-assembler |
db 'fxrstor',1 |
dw fxsave_instruction-assembler |
db 'fxtract',110100b |
dw simple_fpu_instruction-assembler |
db 'fyl2xp1',111001b |
dw simple_fpu_instruction-assembler |
db 'invlpga',0DFh |
dw invlpga_instruction-assembler |
db 'ldmxcsr',10b |
dw fxsave_instruction-assembler |
db 'loopned',0E0h |
dw loop_instruction_32bit-assembler |
db 'loopneq',0E0h |
dw loop_instruction_64bit-assembler |
db 'loopnew',0E0h |
dw loop_instruction_16bit-assembler |
db 'loopnzd',0E0h |
dw loop_instruction_32bit-assembler |
db 'loopnzq',0E0h |
dw loop_instruction_64bit-assembler |
db 'loopnzw',0E0h |
dw loop_instruction_16bit-assembler |
db 'monitor',0C8h |
dw monitor_instruction-assembler |
db 'movddup',12h |
dw sse_sd_instruction-assembler |
db 'movdq2q',0 |
dw movdq2q_instruction-assembler |
db 'movhlps',12h |
dw movhlps_instruction-assembler |
db 'movlhps',16h |
dw movhlps_instruction-assembler |
db 'movntdq',0E7h |
dw movntdq_instruction-assembler |
db 'movntpd',2Bh |
dw movntdq_instruction-assembler |
db 'movntps',2Bh |
dw movntps_instruction-assembler |
db 'movq2dq',0 |
dw movq2dq_instruction-assembler |
db 'paddusb',0DCh |
dw mmx_instruction-assembler |
db 'paddusw',0DDh |
dw mmx_instruction-assembler |
db 'pavgusb',0BFh |
dw amd3dnow_instruction-assembler |
db 'pcmpeqb',74h |
dw mmx_instruction-assembler |
db 'pcmpeqd',76h |
dw mmx_instruction-assembler |
db 'pcmpeqw',75h |
dw mmx_instruction-assembler |
db 'pcmpgtb',64h |
dw mmx_instruction-assembler |
db 'pcmpgtd',66h |
dw mmx_instruction-assembler |
db 'pcmpgtw',65h |
dw mmx_instruction-assembler |
db 'pfcmpeq',0B0h |
dw amd3dnow_instruction-assembler |
db 'pfcmpge',90h |
dw amd3dnow_instruction-assembler |
db 'pfcmpgt',0A0h |
dw amd3dnow_instruction-assembler |
db 'pfpnacc',8Eh |
dw amd3dnow_instruction-assembler |
db 'pfrsqrt',97h |
dw amd3dnow_instruction-assembler |
db 'pmaddwd',0F5h |
dw mmx_instruction-assembler |
db 'pmulhrw',0B7h |
dw amd3dnow_instruction-assembler |
db 'pmulhuw',0E4h |
dw mmx_instruction-assembler |
db 'pmuludq',0F4h |
dw mmx_instruction-assembler |
db 'pshufhw',0F3h |
dw pshufd_instruction-assembler |
db 'pshuflw',0F2h |
dw pshufd_instruction-assembler |
db 'psubusb',0D8h |
dw mmx_instruction-assembler |
db 'psubusw',0D9h |
dw mmx_instruction-assembler |
db 'rsqrtps',52h |
dw sse_ps_instruction-assembler |
db 'rsqrtss',52h |
dw sse_ss_instruction-assembler |
db 'section',0 |
dw section_directive-assembler |
db 'segment',0 |
dw segment_directive-assembler |
db 'stmxcsr',11b |
dw fxsave_instruction-assembler |
db 'syscall',05h |
dw simple_extended_instruction-assembler |
db 'sysexit',35h |
dw simple_extended_instruction-assembler |
db 'ucomisd',2Eh |
dw comisd_instruction-assembler |
db 'ucomiss',2Eh |
dw comiss_instruction-assembler |
db 'virtual',0 |
dw virtual_directive-assembler |
db 'vmclear',6 |
dw vmclear_instruction-assembler |
db 'vmmcall',0D9h |
dw simple_vmx_instruction-assembler |
db 'vmptrld',6 |
dw vmx_instruction-assembler |
db 'vmptrst',7 |
dw vmx_instruction-assembler |
db 'vmwrite',0 |
dw vmwrite_instruction-assembler |
instructions_8: |
db 'addsubpd',0D0h |
dw sse_pd_instruction-assembler |
db 'addsubps',0D0h |
dw cvtpd2dq_instruction-assembler |
db 'cmpneqpd',4 |
dw cmp_pd_instruction-assembler |
db 'cmpneqps',4 |
dw cmp_ps_instruction-assembler |
db 'cmpneqsd',4 |
dw cmp_sd_instruction-assembler |
db 'cmpneqss',4 |
dw cmp_ss_instruction-assembler |
db 'cmpnlepd',6 |
dw cmp_pd_instruction-assembler |
db 'cmpnleps',6 |
dw cmp_ps_instruction-assembler |
db 'cmpnlesd',6 |
dw cmp_sd_instruction-assembler |
db 'cmpnless',6 |
dw cmp_ss_instruction-assembler |
db 'cmpnltpd',5 |
dw cmp_pd_instruction-assembler |
db 'cmpnltps',5 |
dw cmp_ps_instruction-assembler |
db 'cmpnltsd',5 |
dw cmp_sd_instruction-assembler |
db 'cmpnltss',5 |
dw cmp_ss_instruction-assembler |
db 'cmpordpd',7 |
dw cmp_pd_instruction-assembler |
db 'cmpordps',7 |
dw cmp_ps_instruction-assembler |
db 'cmpordsd',7 |
dw cmp_sd_instruction-assembler |
db 'cmpordss',7 |
dw cmp_ss_instruction-assembler |
db 'cvtdq2pd',0E6h |
dw cvtdq2pd_instruction-assembler |
db 'cvtdq2ps',5Bh |
dw sse_ps_instruction-assembler |
db 'cvtpd2dq',0E6h |
dw cvtpd2dq_instruction-assembler |
db 'cvtpd2pi',2Dh |
dw cvtpd2pi_instruction-assembler |
db 'cvtpd2ps',5Ah |
dw sse_pd_instruction-assembler |
db 'cvtpi2pd',2Ah |
dw cvtpi2pd_instruction-assembler |
db 'cvtpi2ps',2Ah |
dw cvtpi2ps_instruction-assembler |
db 'cvtps2dq',5Bh |
dw sse_pd_instruction-assembler |
db 'cvtps2pd',5Ah |
dw cvtps2pd_instruction-assembler |
db 'cvtps2pi',2Dh |
dw cvtps2pi_instruction-assembler |
db 'cvtsd2si',2Dh |
dw cvtsd2si_instruction-assembler |
db 'cvtsd2ss',5Ah |
dw sse_sd_instruction-assembler |
db 'cvtsi2sd',2Ah |
dw cvtsi2sd_instruction-assembler |
db 'cvtsi2ss',2Ah |
dw cvtsi2ss_instruction-assembler |
db 'cvtss2sd',5Ah |
dw sse_ss_instruction-assembler |
db 'cvtss2si',2Dh |
dw cvtss2si_instruction-assembler |
db 'fcmovnbe',0D0h |
dw fcomi_instruction-assembler |
db 'maskmovq',0 |
dw maskmovq_instruction-assembler |
db 'movmskpd',0 |
dw movmskpd_instruction-assembler |
db 'movmskps',0 |
dw movmskps_instruction-assembler |
db 'movshdup',16h |
dw cvtdq2pd_instruction-assembler |
db 'movsldup',12h |
dw cvtdq2pd_instruction-assembler |
db 'packssdw',6Bh |
dw mmx_instruction-assembler |
db 'packsswb',63h |
dw mmx_instruction-assembler |
db 'packuswb',67h |
dw mmx_instruction-assembler |
db 'pfrcpit1',0A6h |
dw amd3dnow_instruction-assembler |
db 'pfrcpit2',0B6h |
dw amd3dnow_instruction-assembler |
db 'pfrsqit1',0A7h |
dw amd3dnow_instruction-assembler |
db 'pmovmskb',0D7h |
dw pextrw_instruction-assembler |
db 'prefetch',0 |
dw amd_prefetch_instruction-assembler |
db 'sysenter',34h |
dw simple_extended_instruction-assembler |
db 'unpckhpd',15h |
dw sse_pd_instruction-assembler |
db 'unpckhps',15h |
dw sse_ps_instruction-assembler |
db 'unpcklpd',14h |
dw sse_pd_instruction-assembler |
db 'unpcklps',14h |
dw sse_ps_instruction-assembler |
db 'vmlaunch',0C2h |
dw simple_vmx_instruction-assembler |
db 'vmresume',0C3h |
dw simple_vmx_instruction-assembler |
instructions_9: |
db 'cmpxchg8b',8 |
dw cmpxchgx_instruction-assembler |
db 'cvttpd2dq',0E6h |
dw sse_pd_instruction-assembler |
db 'cvttpd2pi',2Ch |
dw cvtpd2pi_instruction-assembler |
db 'cvttps2dq',5Bh |
dw cvtdq2pd_instruction-assembler |
db 'cvttps2pi',2Ch |
dw cvtps2pi_instruction-assembler |
db 'cvttsd2si',2Ch |
dw cvtsd2si_instruction-assembler |
db 'cvttss2si',2Ch |
dw cvtss2si_instruction-assembler |
db 'prefetchw',1 |
dw amd_prefetch_instruction-assembler |
db 'punpckhbw',68h |
dw mmx_instruction-assembler |
db 'punpckhdq',6Ah |
dw mmx_instruction-assembler |
db 'punpckhwd',69h |
dw mmx_instruction-assembler |
db 'punpcklbw',60h |
dw mmx_instruction-assembler |
db 'punpckldq',62h |
dw mmx_instruction-assembler |
db 'punpcklwd',61h |
dw mmx_instruction-assembler |
instructions_10: |
db 'cmpunordpd',3 |
dw cmp_pd_instruction-assembler |
db 'cmpunordps',3 |
dw cmp_ps_instruction-assembler |
db 'cmpunordsd',3 |
dw cmp_sd_instruction-assembler |
db 'cmpunordss',3 |
dw cmp_ss_instruction-assembler |
db 'cmpxchg16b',16 |
dw cmpxchgx_instruction-assembler |
db 'loadall286',5 |
dw simple_extended_instruction-assembler |
db 'loadall386',7 |
dw simple_extended_instruction-assembler |
db 'maskmovdqu',0 |
dw maskmovdqu_instruction-assembler |
db 'prefetcht0',1 |
dw prefetch_instruction-assembler |
db 'prefetcht1',2 |
dw prefetch_instruction-assembler |
db 'prefetcht2',3 |
dw prefetch_instruction-assembler |
db 'punpckhqdq',6Dh |
dw sse_pd_instruction-assembler |
db 'punpcklqdq',6Ch |
dw sse_pd_instruction-assembler |
instructions_11: |
db 'prefetchnta',0 |
dw prefetch_instruction-assembler |
instructions_end: |
data_directives: |
dw data_directives_2-data_directives,(data_directives_3-data_directives_2)/(2+3) |
dw data_directives_3-data_directives,(data_directives_4-data_directives_3)/(3+3) |
dw data_directives_4-data_directives,(data_directives_end-data_directives_4)/(4+3) |
data_directives_2: |
db 'db',1 |
dw data_bytes-assembler |
db 'dd',4 |
dw data_dwords-assembler |
db 'df',6 |
dw data_pwords-assembler |
db 'dp',6 |
dw data_pwords-assembler |
db 'dq',8 |
dw data_qwords-assembler |
db 'dt',10 |
dw data_twords-assembler |
db 'du',2 |
dw data_unicode-assembler |
db 'dw',2 |
dw data_words-assembler |
db 'rb',1 |
dw reserve_bytes-assembler |
db 'rd',4 |
dw reserve_dwords-assembler |
db 'rf',6 |
dw reserve_pwords-assembler |
db 'rp',6 |
dw reserve_pwords-assembler |
db 'rq',8 |
dw reserve_qwords-assembler |
db 'rt',10 |
dw reserve_twords-assembler |
db 'rw',2 |
dw reserve_words-assembler |
data_directives_3: |
data_directives_4: |
db 'file',1 |
dw data_file-assembler |
data_directives_end: |
/programs/develop/fasm/trunk/assemble.inc |
---|
0,0 → 1,1951 |
; flat assembler core |
; Copyright (c) 1999-2006, Tomasz Grysztar. |
; All rights reserved. |
assembler: |
xor eax,eax |
mov [stub_size],eax |
mov [number_of_sections],eax |
mov [current_pass],ax |
mov [resolver_flags],eax |
assembler_loop: |
mov eax,[labels_list] |
mov [display_buffer],eax |
mov eax,[additional_memory] |
mov [free_additional_memory],eax |
mov eax,[additional_memory_end] |
mov [structures_buffer],eax |
mov esi,[source_start] |
mov edi,[code_start] |
xor eax,eax |
mov dword [adjustment],eax |
mov dword [adjustment+4],eax |
mov dword [org_origin],edi |
mov dword [org_origin+4],eax |
mov [org_start],edi |
mov [org_registers],eax |
mov [org_symbol],eax |
mov [error_line],eax |
mov [counter],eax |
mov [format_flags],eax |
mov [number_of_relocations],eax |
mov [undefined_data_end],eax |
mov [next_pass_needed],al |
mov [output_format],al |
mov [labels_type],al |
mov [virtual_data],al |
mov [code_type],16 |
pass_loop: |
call assemble_line |
jnc pass_loop |
mov eax,[additional_memory_end] |
cmp eax,[structures_buffer] |
je pass_done |
sub eax,20h |
mov eax,[eax+4] |
mov [current_line],eax |
jmp missing_end_directive |
pass_done: |
call close_pass |
mov eax,[labels_list] |
check_symbols: |
cmp eax,[memory_end] |
jae symbols_checked |
test byte [eax+8],8 |
jz symbol_defined_ok |
mov cx,[current_pass] |
cmp cx,[eax+18] |
jne symbol_defined_ok |
test byte [eax+8],1 |
jz symbol_defined_ok |
sub cx,[eax+16] |
cmp cx,1 |
jne symbol_defined_ok |
and byte [eax+8],not 1 |
or [next_pass_needed],-1 |
symbol_defined_ok: |
test byte [eax+8],10h |
jz use_prediction_ok |
mov cx,[current_pass] |
and byte [eax+8],not 10h |
test byte [eax+8],20h |
jnz check_use_prediction |
cmp cx,[eax+18] |
jne use_prediction_ok |
test byte [eax+8],8 |
jz use_prediction_ok |
jmp use_misprediction |
check_use_prediction: |
test byte [eax+8],8 |
jz use_misprediction |
cmp cx,[eax+18] |
je use_prediction_ok |
use_misprediction: |
or [next_pass_needed],-1 |
use_prediction_ok: |
test byte [eax+8],40h |
jz check_next_symbol |
and byte [eax+8],not 40h |
test byte [eax+8],4 |
jnz define_misprediction |
mov cx,[current_pass] |
test byte [eax+8],80h |
jnz check_define_prediction |
cmp cx,[eax+16] |
jne check_next_symbol |
test byte [eax+8],1 |
jz check_next_symbol |
jmp define_misprediction |
check_define_prediction: |
test byte [eax+8],1 |
jz define_misprediction |
cmp cx,[eax+16] |
je check_next_symbol |
define_misprediction: |
or [next_pass_needed],-1 |
check_next_symbol: |
add eax,LABEL_STRUCTURE_SIZE |
jmp check_symbols |
symbols_checked: |
cmp [next_pass_needed],0 |
jne next_pass |
mov eax,[error_line] |
or eax,eax |
jz assemble_ok |
mov [current_line],eax |
jmp near [error] |
next_pass: |
inc [current_pass] |
mov ax,[current_pass] |
cmp ax,[passes_limit] |
je code_cannot_be_generated |
jmp assembler_loop |
assemble_ok: |
ret |
assemble_line: |
mov eax,[display_buffer] |
sub eax,100h |
cmp edi,eax |
ja out_of_memory |
lods byte [esi] |
cmp al,1 |
je assemble_instruction |
jb source_end |
cmp al,3 |
jb define_label |
je define_constant |
cmp al,0Fh |
je new_line |
cmp al,13h |
je code_type_setting |
cmp al,10h |
jne illegal_instruction |
lods byte [esi] |
jmp segment_prefix |
code_type_setting: |
lods byte [esi] |
mov [code_type],al |
jmp line_assembled |
new_line: |
lods dword [esi] |
mov [current_line],eax |
mov [prefixed_instruction],0 |
continue_line: |
cmp byte [esi],0Fh |
je line_assembled |
jmp assemble_line |
define_label: |
lods dword [esi] |
cmp eax,0Fh |
jb invalid_use_of_symbol |
je reserved_word_used_as_symbol |
mov ebx,eax |
lods byte [esi] |
mov cl,al |
mov eax,edi |
xor edx,edx |
sub eax,dword [org_origin] |
sbb edx,dword [org_origin+4] |
mov ch,[labels_type] |
cmp [virtual_data],0 |
jne make_virtual_label |
or byte [ebx+9],1 |
xchg eax,[ebx] |
xchg edx,[ebx+4] |
sub eax,[ebx] |
sbb edx,[ebx+4] |
mov dword [adjustment],eax |
mov dword [adjustment+4],edx |
or eax,edx |
setnz ah |
jmp finish_label_symbol |
make_virtual_label: |
and byte [ebx+9],not 1 |
cmp eax,[ebx] |
mov [ebx],eax |
setne ah |
cmp edx,[ebx+4] |
mov [ebx+4],edx |
setne al |
or ah,al |
finish_label_symbol: |
cmp cl,[ebx+10] |
mov [ebx+10],cl |
setne al |
or ah,al |
cmp ch,[ebx+11] |
mov [ebx+11],ch |
setne al |
or ah,al |
mov edx,[org_registers] |
cmp edx,[ebx+12] |
mov [ebx+12],edx |
setne al |
or ah,al |
or ch,ch |
jz label_symbol_ok |
mov edx,[org_symbol] |
cmp edx,[ebx+20] |
mov [ebx+20],edx |
setne al |
or ah,al |
label_symbol_ok: |
mov cx,[current_pass] |
xchg [ebx+16],cx |
mov edx,[current_line] |
mov [ebx+28],edx |
and byte [ebx+8],not 2 |
test byte [ebx+8],1 |
jz new_label |
cmp cx,[ebx+16] |
je symbol_already_defined |
inc cx |
sub cx,[ebx+16] |
setnz al |
or ah,al |
jz continue_line |
test byte [ebx+8],8 |
jz continue_line |
mov cx,[current_pass] |
cmp cx,[ebx+18] |
jne continue_line |
or [next_pass_needed],-1 |
jmp continue_line |
new_label: |
or byte [ebx+8],1 |
jmp continue_line |
define_constant: |
lods dword [esi] |
inc esi |
cmp eax,0Fh |
jb invalid_use_of_symbol |
je reserved_word_used_as_symbol |
mov edx,[eax+8] |
push edx |
cmp [current_pass],0 |
je get_constant_value |
test dl,4 |
jnz get_constant_value |
mov cx,[current_pass] |
cmp cx,[eax+16] |
je get_constant_value |
and dl,not 1 |
mov [eax+8],dl |
get_constant_value: |
push eax |
mov al,byte [esi-1] |
push eax |
call get_value |
pop ebx |
mov ch,bl |
pop ebx |
pop dword [ebx+8] |
cmp ebx,0Fh |
jb invalid_use_of_symbol |
je reserved_word_used_as_symbol |
xor cl,cl |
mov ch,[value_type] |
cmp ch,3 |
je invalid_use_of_symbol |
make_constant: |
and byte [ebx+9],not 1 |
cmp eax,[ebx] |
mov [ebx],eax |
setne ah |
cmp edx,[ebx+4] |
mov [ebx+4],edx |
setne al |
or ah,al |
cmp cl,[ebx+10] |
mov [ebx+10],cl |
setne al |
or ah,al |
cmp ch,[ebx+11] |
mov [ebx+11],ch |
setne al |
or ah,al |
xor edx,edx |
cmp edx,[ebx+12] |
mov [ebx+12],edx |
setne al |
or ah,al |
or ch,ch |
jz constant_symbol_ok |
mov edx,[symbol_identifier] |
cmp edx,[ebx+20] |
mov [ebx+20],edx |
setne al |
or ah,al |
constant_symbol_ok: |
mov cx,[current_pass] |
xchg [ebx+16],cx |
mov edx,[current_line] |
mov [ebx+28],edx |
test byte [ebx+8],1 |
jz new_constant |
cmp cx,[ebx+16] |
jne redeclare_constant |
test byte [ebx+8],2 |
jz symbol_already_defined |
or byte [ebx+8],4 |
jmp instruction_assembled |
redeclare_constant: |
inc cx |
sub cx,[ebx+16] |
setnz al |
or ah,al |
jz instruction_assembled |
test byte [ebx+8],4 |
jnz instruction_assembled |
test byte [ebx+8],8 |
jz instruction_assembled |
mov cx,[current_pass] |
cmp cx,[ebx+18] |
jne instruction_assembled |
or [next_pass_needed],-1 |
jmp instruction_assembled |
new_constant: |
or byte [ebx+8],1+2 |
jmp instruction_assembled |
assemble_instruction: |
mov [operand_size],0 |
mov [size_override],0 |
mov [operand_prefix],0 |
mov [rex_prefix],0 |
mov [immediate_size],0 |
movzx ebx,word [esi] |
mov al,[esi+2] |
add ebx,assembler |
add esi,3 |
jmp near ebx |
instruction_assembled: |
mov al,[esi] |
cmp al,0Fh |
je line_assembled |
or al,al |
jnz extra_characters_on_line |
line_assembled: |
clc |
ret |
source_end: |
dec esi |
stc |
ret |
skip_line: |
call skip_symbol |
jnc skip_line |
ret |
skip_symbol: |
lods byte [esi] |
or al,al |
jz nothing_to_skip |
cmp al,0Fh |
je nothing_to_skip |
cmp al,1 |
je skip_instruction |
cmp al,2 |
je skip_label |
cmp al,3 |
je skip_label |
cmp al,20h |
jb skip_assembler_symbol |
cmp al,'(' |
je skip_expression |
cmp al,'[' |
je skip_address |
skip_done: |
clc |
ret |
skip_label: |
add esi,2 |
skip_instruction: |
add esi,2 |
skip_assembler_symbol: |
inc esi |
jmp skip_done |
skip_address: |
mov al,[esi] |
and al,11110000b |
cmp al,60h |
jb skip_expression |
cmp al,70h |
ja skip_expression |
inc esi |
jmp skip_address |
skip_expression: |
lods byte [esi] |
or al,al |
jz skip_string |
cmp al,'.' |
je skip_fp_value |
cmp al,')' |
je skip_done |
cmp al,']' |
je skip_done |
cmp al,'!' |
je skip_expression |
cmp al,0Fh |
je skip_expression |
cmp al,10h |
je skip_register |
cmp al,11h |
je skip_label_value |
cmp al,80h |
jae skip_expression |
movzx eax,al |
add esi,eax |
jmp skip_expression |
skip_label_value: |
add esi,3 |
skip_register: |
inc esi |
jmp skip_expression |
skip_fp_value: |
add esi,12 |
jmp skip_done |
skip_string: |
lods dword [esi] |
add esi,eax |
inc esi |
jmp skip_done |
nothing_to_skip: |
dec esi |
stc |
ret |
org_directive: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_qword_value |
mov cl,[value_type] |
test cl,1 |
jnz invalid_use_of_symbol |
mov [labels_type],cl |
mov ecx,edi |
sub ecx,eax |
adc edx,0 |
neg edx |
mov dword [org_origin],ecx |
mov dword [org_origin+4],edx |
mov [org_registers],0 |
mov [org_start],edi |
mov edx,[symbol_identifier] |
mov [org_symbol],edx |
cmp [output_format],1 |
ja instruction_assembled |
cmp edi,[code_start] |
jne instruction_assembled |
cmp eax,100h |
jne instruction_assembled |
bts [format_flags],0 |
jmp instruction_assembled |
label_directive: |
lods byte [esi] |
cmp al,2 |
jne invalid_argument |
lods dword [esi] |
cmp eax,0Fh |
jb invalid_use_of_symbol |
je reserved_word_used_as_symbol |
inc esi |
mov ebx,eax |
xor cl,cl |
lods byte [esi] |
cmp al,':' |
je get_label_size |
dec esi |
cmp al,11h |
jne label_size_ok |
get_label_size: |
lods word [esi] |
cmp al,11h |
jne invalid_argument |
mov cl,ah |
label_size_ok: |
mov eax,edi |
xor edx,edx |
sub eax,dword [org_origin] |
sbb edx,dword [org_origin+4] |
mov ebp,[org_registers] |
cmp byte [esi],80h |
je get_free_label_value |
mov ch,[labels_type] |
push [org_symbol] |
pop [address_symbol] |
cmp [virtual_data],0 |
jne make_free_label |
or byte [ebx+9],1 |
xchg eax,[ebx] |
xchg edx,[ebx+4] |
sub eax,[ebx] |
sbb edx,[ebx+4] |
mov dword [adjustment],eax |
mov dword [adjustment+4],edx |
or eax,edx |
setne ah |
jmp finish_label |
get_free_label_value: |
inc esi |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
push dword [ebx+8] |
push ebx ecx |
and byte [ebx+8],not 1 |
cmp byte [esi],'.' |
je invalid_value |
call get_address_value |
or bh,bh |
setnz ch |
xchg ch,cl |
mov bp,cx |
shl ebp,16 |
xchg bl,bh |
mov bp,bx |
pop ecx ebx |
pop dword [ebx+8] |
mov ch,[value_type] |
or ch,ch |
jz make_free_label |
cmp ch,4 |
je make_free_label |
cmp ch,2 |
jne invalid_use_of_symbol |
make_free_label: |
and byte [ebx+9],not 1 |
cmp eax,[ebx] |
mov [ebx],eax |
setne ah |
cmp edx,[ebx+4] |
mov [ebx+4],edx |
setne al |
or ah,al |
jmp finish_label |
finish_label: |
cmp cl,[ebx+10] |
mov [ebx+10],cl |
setne al |
or ah,al |
cmp ch,[ebx+11] |
mov [ebx+11],ch |
setne al |
or ah,al |
cmp ebp,[ebx+12] |
mov [ebx+12],ebp |
setne al |
or ah,al |
or ch,ch |
jz free_label_symbol_ok |
mov edx,[address_symbol] |
cmp edx,[ebx+20] |
mov [ebx+20],edx |
setne al |
or ah,al |
free_label_symbol_ok: |
mov cx,[current_pass] |
xchg [ebx+16],cx |
mov edx,[current_line] |
mov [ebx+28],edx |
and byte [ebx+8],not 2 |
test byte [ebx+8],1 |
jz new_free_label |
cmp cx,[ebx+16] |
je symbol_already_defined |
inc cx |
sub cx,[ebx+16] |
setnz al |
or ah,al |
jz instruction_assembled |
test byte [ebx+8],8 |
jz instruction_assembled |
mov cx,[current_pass] |
cmp cx,[ebx+18] |
jne instruction_assembled |
or [next_pass_needed],-1 |
jmp instruction_assembled |
new_free_label: |
or byte [ebx+8],1 |
jmp instruction_assembled |
load_directive: |
lods byte [esi] |
cmp al,2 |
jne invalid_argument |
lods dword [esi] |
cmp eax,0Fh |
jb invalid_use_of_symbol |
je reserved_word_used_as_symbol |
inc esi |
push eax |
mov al,1 |
cmp byte [esi],11h |
jne load_size_ok |
lods byte [esi] |
lods byte [esi] |
load_size_ok: |
cmp al,8 |
ja invalid_value |
mov [operand_size],al |
mov dword [value],0 |
mov dword [value+4],0 |
lods word [esi] |
cmp ax,82h+'(' shl 8 |
jne invalid_argument |
load_from_code: |
cmp byte [esi],'.' |
je invalid_value |
call get_relative_offset |
neg eax |
cmp [next_pass_needed],0 |
jne load_address_ok |
cmp [value_type],0 |
jne invalid_use_of_symbol |
load_address_ok: |
push esi edi |
mov esi,edi |
sub esi,eax |
jc bad_load_address |
cmp esi,[org_start] |
jb bad_load_address |
mov edi,value |
movzx ecx,[operand_size] |
cmp ecx,eax |
ja bad_load_address |
rep movs byte [edi],[esi] |
jmp value_loaded |
bad_load_address: |
cmp [error_line],0 |
jne value_loaded |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],value_out_of_range |
value_loaded: |
pop edi esi |
mov eax,dword [value] |
mov edx,dword [value+4] |
pop ebx |
xor cx,cx |
jmp make_constant |
store_directive: |
cmp byte [esi],11h |
je sized_store |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
call get_byte_value |
xor edx,edx |
movzx eax,al |
mov [operand_size],1 |
jmp store_value_ok |
sized_store: |
call get_value |
store_value_ok: |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov dword [value],eax |
mov dword [value+4],edx |
lods word [esi] |
cmp ax,80h+'(' shl 8 |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_relative_offset |
neg eax |
cmp [next_pass_needed],0 |
jne store_address_ok |
cmp [value_type],0 |
jne invalid_use_of_symbol |
store_address_ok: |
push esi edi |
sub edi,eax |
jc bad_store_address |
cmp edi,[org_start] |
jb bad_store_address |
mov esi,value |
movzx ecx,[operand_size] |
cmp ecx,eax |
ja bad_store_address |
rep movs byte [edi],[esi] |
mov eax,edi |
pop edi esi |
cmp edi,[undefined_data_end] |
jne instruction_assembled |
cmp eax,[undefined_data_start] |
jbe instruction_assembled |
mov [undefined_data_start],eax |
jmp instruction_assembled |
bad_store_address: |
pop edi esi |
cmp [error_line],0 |
jne instruction_assembled |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],value_out_of_range |
jmp instruction_assembled |
display_directive: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],0 |
jne display_byte |
inc esi |
lods dword [esi] |
mov ecx,eax |
push edi |
mov edi,[display_buffer] |
sub edi,4 |
sub edi,eax |
mov [display_buffer],edi |
rep movs byte [edi],[esi] |
stos dword [edi] |
pop edi |
inc esi |
jmp display_next |
display_byte: |
call get_byte_value |
push edi |
mov edi,[display_buffer] |
sub edi,4+1 |
mov [display_buffer],edi |
stos byte [edi] |
mov eax,1 |
stos dword [edi] |
pop edi |
display_next: |
cmp edi,[display_buffer] |
ja out_of_memory |
lods byte [esi] |
cmp al,',' |
je display_directive |
dec esi |
jmp instruction_assembled |
flush_display_buffer: |
mov eax,[display_buffer] |
or eax,eax |
jz display_done |
mov esi,[labels_list] |
cmp esi,eax |
je display_done |
display_messages: |
sub esi,4 |
mov ecx,[esi] |
sub esi,ecx |
push esi |
call display_block |
pop esi |
cmp esi,[display_buffer] |
jne display_messages |
mov eax,[labels_list] |
mov [display_buffer],eax |
display_done: |
ret |
times_directive: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_dword_value |
cmp [next_pass_needed],0 |
jne times_value_ok |
cmp [value_type],0 |
jne invalid_use_of_symbol |
times_value_ok: |
cmp eax,0 |
je zero_times |
jl negative_times |
cmp byte [esi],':' |
jne times_argument_ok |
inc esi |
times_argument_ok: |
push [counter] |
push [counter_limit] |
mov [counter_limit],eax |
mov [counter],1 |
times_loop: |
mov eax,esp |
sub eax,100h |
jc stack_overflow |
cmp eax,[stack_limit] |
jb stack_overflow |
push esi |
or [prefixed_instruction],-1 |
call continue_line |
mov eax,[counter_limit] |
cmp [counter],eax |
je times_done |
inc [counter] |
pop esi |
jmp times_loop |
times_done: |
pop eax |
pop [counter_limit] |
pop [counter] |
jmp instruction_assembled |
negative_times: |
cmp [error_line],0 |
jne zero_times |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_value |
zero_times: |
call skip_line |
jmp instruction_assembled |
virtual_directive: |
lods byte [esi] |
cmp al,80h |
jne virtual_at_current |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_address_value |
mov ebp,[address_symbol] |
xor ch,ch |
or bh,bh |
jz set_virtual |
mov ch,1 |
jmp set_virtual |
virtual_at_current: |
dec esi |
mov al,[labels_type] |
mov [value_type],al |
mov ebp,[org_symbol] |
mov eax,edi |
xor edx,edx |
sub eax,dword [org_origin] |
sbb edx,dword [org_origin+4] |
mov bx,word [org_registers] |
mov cx,word [org_registers+2] |
xchg bh,bl |
xchg ch,cl |
set_virtual: |
push [org_registers] |
mov byte [org_registers],bh |
mov byte [org_registers+1],bl |
mov byte [org_registers+2],ch |
mov byte [org_registers+3],cl |
call allocate_structure_data |
mov word [ebx],virtual_directive-assembler |
not eax |
not edx |
add eax,1 |
adc edx,0 |
add eax,edi |
adc edx,0 |
xchg dword [org_origin],eax |
xchg dword [org_origin+4],edx |
mov [ebx+10h],eax |
mov [ebx+14h],edx |
pop eax |
mov [ebx+18h],eax |
mov al,[virtual_data] |
mov [ebx+2],al |
mov al,[labels_type] |
mov [ebx+3],al |
mov eax,edi |
xchg eax,[org_start] |
mov [ebx+0Ch],eax |
xchg ebp,[org_symbol] |
mov [ebx+1Ch],ebp |
mov [ebx+8],edi |
mov eax,[current_line] |
mov [ebx+4],eax |
or [virtual_data],-1 |
mov al,[value_type] |
test al,1 |
jnz invalid_use_of_symbol |
mov [labels_type],al |
jmp instruction_assembled |
allocate_structure_data: |
mov ebx,[structures_buffer] |
sub ebx,20h |
cmp ebx,[free_additional_memory] |
jb out_of_memory |
mov [structures_buffer],ebx |
ret |
find_structure_data: |
mov ebx,[structures_buffer] |
scan_structures: |
cmp ebx,[additional_memory_end] |
je no_such_structure |
cmp ax,[ebx] |
je structure_data_found |
add ebx,20h |
jmp scan_structures |
structure_data_found: |
ret |
no_such_structure: |
stc |
ret |
end_virtual: |
call find_structure_data |
jc unexpected_instruction |
mov al,[ebx+2] |
mov [virtual_data],al |
mov al,[ebx+3] |
mov [labels_type],al |
mov eax,[ebx+10h] |
mov dword [org_origin],eax |
mov eax,[ebx+14h] |
mov dword [org_origin+4],eax |
mov eax,[ebx+18h] |
mov [org_registers],eax |
mov eax,[ebx+0Ch] |
mov [org_start],eax |
mov eax,[ebx+1Ch] |
mov [org_symbol],eax |
mov edi,[ebx+8] |
remove_structure_data: |
push esi edi |
mov esi,[structures_buffer] |
mov ecx,ebx |
sub ecx,esi |
lea edi,[esi+20h] |
mov [structures_buffer],edi |
shr ecx,2 |
rep movs dword [edi],[esi] |
pop edi esi |
ret |
repeat_directive: |
cmp [prefixed_instruction],0 |
jne unexpected_instruction |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_dword_value |
cmp [next_pass_needed],0 |
jne repeat_value_ok |
cmp [value_type],0 |
jne invalid_use_of_symbol |
repeat_value_ok: |
cmp eax,0 |
je zero_repeat |
jl negative_repeat |
call allocate_structure_data |
mov word [ebx],repeat_directive-assembler |
xchg eax,[counter_limit] |
mov [ebx+10h],eax |
mov eax,1 |
xchg eax,[counter] |
mov [ebx+14h],eax |
mov [ebx+8],esi |
mov eax,[current_line] |
mov [ebx+4],eax |
jmp instruction_assembled |
end_repeat: |
cmp [prefixed_instruction],0 |
jne unexpected_instruction |
call find_structure_data |
jc unexpected_instruction |
mov eax,[counter_limit] |
inc [counter] |
cmp [counter],eax |
jbe continue_repeating |
stop_repeat: |
mov eax,[ebx+10h] |
mov [counter_limit],eax |
mov eax,[ebx+14h] |
mov [counter],eax |
call remove_structure_data |
jmp instruction_assembled |
continue_repeating: |
mov esi,[ebx+8] |
jmp instruction_assembled |
negative_repeat: |
cmp [error_line],0 |
jne zero_repeat |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_value |
zero_repeat: |
mov al,[esi] |
or al,al |
jz missing_end_directive |
cmp al,0Fh |
jne extra_characters_on_line |
call find_end_repeat |
jmp instruction_assembled |
find_end_repeat: |
call find_structure_end |
cmp ax,repeat_directive-assembler |
jne unexpected_instruction |
ret |
while_directive: |
cmp [prefixed_instruction],0 |
jne unexpected_instruction |
call allocate_structure_data |
mov word [ebx],while_directive-assembler |
mov eax,1 |
xchg eax,[counter] |
mov [ebx+10h],eax |
mov [ebx+8],esi |
mov eax,[current_line] |
mov [ebx+4],eax |
do_while: |
push ebx |
call calculate_logical_expression |
or al,al |
jnz while_true |
mov al,[esi] |
or al,al |
jz missing_end_directive |
cmp al,0Fh |
jne extra_characters_on_line |
stop_while: |
call find_end_while |
pop ebx |
mov eax,[ebx+10h] |
mov [counter],eax |
call remove_structure_data |
jmp instruction_assembled |
while_true: |
pop ebx |
jmp instruction_assembled |
end_while: |
cmp [prefixed_instruction],0 |
jne unexpected_instruction |
call find_structure_data |
jc unexpected_instruction |
mov eax,[ebx+4] |
mov [current_line],eax |
inc [counter] |
jz too_many_repeats |
mov esi,[ebx+8] |
jmp do_while |
find_end_while: |
call find_structure_end |
cmp ax,while_directive-assembler |
jne unexpected_instruction |
ret |
if_directive: |
cmp [prefixed_instruction],0 |
jne unexpected_instruction |
call calculate_logical_expression |
mov dl,al |
mov al,[esi] |
or al,al |
jz missing_end_directive |
cmp al,0Fh |
jne extra_characters_on_line |
or dl,dl |
jnz if_true |
call find_else |
jc instruction_assembled |
mov al,[esi] |
cmp al,1 |
jne else_true |
cmp word [esi+1],if_directive-assembler |
jne else_true |
add esi,4 |
jmp if_directive |
if_true: |
xor al,al |
make_if_structure: |
call allocate_structure_data |
mov word [ebx],if_directive-assembler |
mov byte [ebx+2],al |
mov eax,[current_line] |
mov [ebx+4],eax |
jmp instruction_assembled |
else_true: |
or al,al |
jz missing_end_directive |
cmp al,0Fh |
jne extra_characters_on_line |
or al,-1 |
jmp make_if_structure |
else_directive: |
cmp [prefixed_instruction],0 |
jne unexpected_instruction |
mov ax,if_directive-assembler |
call find_structure_data |
jc unexpected_instruction |
cmp byte [ebx+2],0 |
jne unexpected_instruction |
found_else: |
mov al,[esi] |
cmp al,1 |
jne skip_else |
cmp word [esi+1],if_directive-assembler |
jne skip_else |
add esi,4 |
call find_else |
jnc found_else |
call remove_structure_data |
jmp instruction_assembled |
skip_else: |
or al,al |
jz missing_end_directive |
cmp al,0Fh |
jne extra_characters_on_line |
call find_end_if |
call remove_structure_data |
jmp instruction_assembled |
end_if: |
cmp [prefixed_instruction],0 |
jne unexpected_instruction |
call find_structure_data |
jc unexpected_instruction |
call remove_structure_data |
jmp instruction_assembled |
find_else: |
call find_structure_end |
cmp ax,else_directive-assembler |
je else_found |
cmp ax,if_directive-assembler |
jne unexpected_instruction |
stc |
ret |
else_found: |
clc |
ret |
find_end_if: |
call find_structure_end |
cmp ax,if_directive-assembler |
jne unexpected_instruction |
ret |
find_structure_end: |
push [error_line] |
mov eax,[current_line] |
mov [error_line],eax |
find_end_directive: |
call skip_line |
lods byte [esi] |
cmp al,0Fh |
jne no_end_directive |
lods dword [esi] |
mov [current_line],eax |
skip_labels: |
cmp byte [esi],2 |
jne labels_ok |
add esi,6 |
jmp skip_labels |
labels_ok: |
cmp byte [esi],1 |
jne find_end_directive |
mov ax,[esi+1] |
cmp ax,prefix_instruction-assembler |
je find_end_directive |
add esi,4 |
cmp ax,repeat_directive-assembler |
je skip_repeat |
cmp ax,while_directive-assembler |
je skip_while |
cmp ax,if_directive-assembler |
je skip_if |
cmp ax,else_directive-assembler |
je structure_end |
cmp ax,end_directive-assembler |
jne find_end_directive |
cmp byte [esi],1 |
jne find_end_directive |
mov ax,[esi+1] |
add esi,4 |
cmp ax,repeat_directive-assembler |
je structure_end |
cmp ax,while_directive-assembler |
je structure_end |
cmp ax,if_directive-assembler |
jne find_end_directive |
structure_end: |
pop [error_line] |
ret |
no_end_directive: |
mov eax,[error_line] |
mov [current_line],eax |
jmp missing_end_directive |
skip_repeat: |
call find_end_repeat |
jmp find_end_directive |
skip_while: |
call find_end_while |
jmp find_end_directive |
skip_if: |
call skip_if_block |
jmp find_end_directive |
skip_if_block: |
call find_else |
jc if_block_skipped |
cmp byte [esi],1 |
jne skip_after_else |
cmp word [esi+1],if_directive-assembler |
jne skip_after_else |
add esi,4 |
jmp skip_if_block |
skip_after_else: |
call find_end_if |
if_block_skipped: |
ret |
end_directive: |
lods byte [esi] |
cmp al,1 |
jne invalid_argument |
lods word [esi] |
inc esi |
cmp ax,virtual_directive-assembler |
je end_virtual |
cmp ax,repeat_directive-assembler |
je end_repeat |
cmp ax,while_directive-assembler |
je end_while |
cmp ax,if_directive-assembler |
je end_if |
cmp ax,data_directive-assembler |
je end_data |
jmp invalid_argument |
break_directive: |
mov ebx,[structures_buffer] |
mov al,[esi] |
or al,al |
jz find_breakable_structure |
cmp al,0Fh |
jne extra_characters_on_line |
find_breakable_structure: |
cmp ebx,[additional_memory_end] |
je unexpected_instruction |
mov ax,[ebx] |
cmp ax,repeat_directive-assembler |
je break_repeat |
cmp ax,while_directive-assembler |
je break_while |
cmp ax,if_directive-assembler |
je break_if |
add ebx,20h |
jmp find_breakable_structure |
break_if: |
push [current_line] |
mov eax,[ebx+4] |
mov [current_line],eax |
call remove_structure_data |
call skip_if_block |
pop [current_line] |
mov ebx,[structures_buffer] |
jmp find_breakable_structure |
break_repeat: |
push ebx |
call find_end_repeat |
pop ebx |
jmp stop_repeat |
break_while: |
push ebx |
jmp stop_while |
data_bytes: |
call define_data |
lods byte [esi] |
cmp al,'(' |
je get_byte |
cmp al,'?' |
jne invalid_argument |
mov eax,edi |
mov byte [edi],0 |
inc edi |
jmp undefined_data |
get_byte: |
cmp byte [esi],0 |
je get_string |
call get_byte_value |
stos byte [edi] |
ret |
get_string: |
inc esi |
lods dword [esi] |
mov ecx,eax |
lea eax,[edi+ecx] |
cmp eax,[display_buffer] |
ja out_of_memory |
rep movs byte [edi],[esi] |
inc esi |
ret |
undefined_data: |
cmp [virtual_data],0 |
je mark_undefined_data |
ret |
mark_undefined_data: |
cmp eax,[undefined_data_end] |
je undefined_data_ok |
mov [undefined_data_start],eax |
undefined_data_ok: |
mov [undefined_data_end],edi |
ret |
define_data: |
cmp edi,[display_buffer] |
jae out_of_memory |
cmp byte [esi],'(' |
jne simple_data_value |
mov ebx,esi |
inc esi |
call skip_expression |
xchg esi,ebx |
cmp byte [ebx],81h |
jne simple_data_value |
inc esi |
call get_dword_value |
cmp [next_pass_needed],0 |
jne dup_value_ok |
cmp [value_type],0 |
jne invalid_use_of_symbol |
dup_value_ok: |
inc esi |
cmp eax,0 |
jg dup_positive |
cmp [error_line],0 |
jne dup_invalid |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_value |
dup_invalid: |
mov eax,1 |
dup_positive: |
cmp byte [esi],'{' |
jne duplicate_single_data_value |
inc esi |
duplicate_data: |
push eax esi |
duplicated_values: |
cmp edi,[display_buffer] |
jae out_of_memory |
call near dword [esp+8] |
lods byte [esi] |
cmp al,',' |
je duplicated_values |
cmp al,'}' |
jne invalid_argument |
pop ebx eax |
dec eax |
jz data_defined |
mov esi,ebx |
jmp duplicate_data |
duplicate_single_data_value: |
cmp edi,[display_buffer] |
jae out_of_memory |
push eax esi |
call near dword [esp+8] |
pop ebx eax |
dec eax |
jz data_defined |
mov esi,ebx |
jmp duplicate_single_data_value |
simple_data_value: |
cmp edi,[display_buffer] |
jae out_of_memory |
call near dword [esp] |
data_defined: |
lods byte [esi] |
cmp al,',' |
je define_data |
dec esi |
add esp,4 |
jmp instruction_assembled |
data_unicode: |
or [base_code],-1 |
jmp define_words |
data_words: |
mov [base_code],0 |
define_words: |
call define_data |
lods byte [esi] |
cmp al,'(' |
je get_word |
cmp al,'?' |
jne invalid_argument |
mov eax,edi |
mov word [edi],0 |
scas word [edi] |
jmp undefined_data |
ret |
get_word: |
cmp [base_code],0 |
je word_data_value |
cmp byte [esi],0 |
je word_string |
word_data_value: |
call get_word_value |
call mark_relocation |
stos word [edi] |
ret |
word_string: |
inc esi |
lods dword [esi] |
mov ecx,eax |
jecxz word_string_ok |
lea eax,[edi+ecx*2] |
cmp eax,[display_buffer] |
ja out_of_memory |
xor ah,ah |
copy_word_string: |
lods byte [esi] |
stos word [edi] |
loop copy_word_string |
word_string_ok: |
inc esi |
ret |
data_dwords: |
call define_data |
lods byte [esi] |
cmp al,'(' |
je get_dword |
cmp al,'?' |
jne invalid_argument |
mov eax,edi |
mov dword [edi],0 |
scas dword [edi] |
jmp undefined_data |
get_dword: |
push esi |
call get_dword_value |
pop ebx |
cmp byte [esi],':' |
je complex_dword |
call mark_relocation |
stos dword [edi] |
ret |
complex_dword: |
mov esi,ebx |
cmp byte [esi],'.' |
je invalid_value |
call get_word_value |
push eax |
inc esi |
lods byte [esi] |
cmp al,'(' |
jne invalid_operand |
mov al,[value_type] |
push eax |
cmp byte [esi],'.' |
je invalid_value |
call get_word_value |
call mark_relocation |
stos word [edi] |
pop eax |
mov [value_type],al |
pop eax |
call mark_relocation |
stos word [edi] |
ret |
data_pwords: |
call define_data |
lods byte [esi] |
cmp al,'(' |
je get_pword |
cmp al,'?' |
jne invalid_argument |
mov eax,edi |
mov dword [edi],0 |
scas dword [edi] |
mov word [edi],0 |
scas word [edi] |
jmp undefined_data |
get_pword: |
push esi |
call get_pword_value |
pop ebx |
cmp byte [esi],':' |
je complex_pword |
call mark_relocation |
stos dword [edi] |
mov ax,dx |
stos word [edi] |
ret |
complex_pword: |
mov esi,ebx |
cmp byte [esi],'.' |
je invalid_value |
call get_word_value |
push eax |
inc esi |
lods byte [esi] |
cmp al,'(' |
jne invalid_operand |
mov al,[value_type] |
push eax |
cmp byte [esi],'.' |
je invalid_value |
call get_dword_value |
call mark_relocation |
stos dword [edi] |
pop eax |
mov [value_type],al |
pop eax |
call mark_relocation |
stos word [edi] |
ret |
data_qwords: |
call define_data |
lods byte [esi] |
cmp al,'(' |
je get_qword |
cmp al,'?' |
jne invalid_argument |
mov eax,edi |
mov dword [edi],0 |
scas dword [edi] |
mov dword [edi],0 |
scas dword [edi] |
jmp undefined_data |
get_qword: |
call get_qword_value |
call mark_relocation |
stos dword [edi] |
mov eax,edx |
stos dword [edi] |
ret |
data_twords: |
call define_data |
lods byte [esi] |
cmp al,'(' |
je get_tword |
cmp al,'?' |
jne invalid_argument |
mov eax,edi |
mov dword [edi],0 |
scas dword [edi] |
mov dword [edi],0 |
scas dword [edi] |
mov word [edi],0 |
scas word [edi] |
jmp undefined_data |
get_tword: |
cmp byte [esi],'.' |
jne complex_tword |
inc esi |
cmp word [esi+8],8000h |
je fp_zero_tword |
mov eax,[esi] |
stos dword [edi] |
mov eax,[esi+4] |
stos dword [edi] |
mov ax,[esi+8] |
add ax,3FFFh |
cmp ax,8000h |
jae value_out_of_range |
mov bl,[esi+11] |
shl bx,15 |
or ax,bx |
stos word [edi] |
add esi,13 |
ret |
fp_zero_tword: |
xor eax,eax |
stos dword [edi] |
stos dword [edi] |
mov al,[esi+11] |
shl ax,15 |
stos word [edi] |
add esi,13 |
ret |
complex_tword: |
call get_word_value |
push eax |
inc esi |
lods byte [esi] |
cmp al,'(' |
jne invalid_operand |
mov al,[value_type] |
push eax |
cmp byte [esi],'.' |
je invalid_value |
call get_qword_value |
call mark_relocation |
stos dword [edi] |
mov eax,edx |
stos dword [edi] |
pop eax |
mov [value_type],al |
pop eax |
call mark_relocation |
stos word [edi] |
ret |
data_file: |
lods word [esi] |
cmp ax,'(' |
jne invalid_argument |
add esi,4 |
call open_binary_file |
mov eax,[esi-4] |
lea esi,[esi+eax+1] |
mov al,2 |
xor edx,edx |
call lseek |
push eax |
xor edx,edx |
cmp byte [esi],':' |
jne position_ok |
inc esi |
cmp byte [esi],'(' |
jne invalid_argument |
inc esi |
cmp byte [esi],'.' |
je invalid_value |
push ebx |
call get_dword_value |
pop ebx |
mov edx,eax |
sub [esp],edx |
position_ok: |
cmp byte [esi],',' |
jne size_ok |
inc esi |
cmp byte [esi],'(' |
jne invalid_argument |
inc esi |
cmp byte [esi],'.' |
je invalid_value |
push ebx edx |
call get_dword_value |
pop edx ebx |
mov [esp],eax |
size_ok: |
xor al,al |
call lseek |
pop ecx |
mov edx,edi |
add edi,ecx |
jc out_of_memory |
cmp edi,[display_buffer] |
ja out_of_memory |
call read |
jc error_reading_file |
call close |
lods byte [esi] |
cmp al,',' |
je data_file |
dec esi |
jmp instruction_assembled |
open_binary_file: |
push esi |
push edi |
mov esi,[current_line] |
mov esi,[esi] |
get_current_path: |
lodsb |
stosb |
or al,al |
jnz get_current_path |
cut_current_path: |
cmp edi,[esp] |
je current_path_ok |
cmp byte [edi-1],'\' |
je current_path_ok |
cmp byte [edi-1],'/' |
je current_path_ok |
dec edi |
jmp cut_current_path |
current_path_ok: |
mov esi,[esp+4] |
call preprocess_path |
pop edx |
mov esi,edx |
call open |
jnc file_opened |
mov edi,esi |
mov esi,[esp] |
push edi |
call preprocess_path |
pop edx |
mov esi,edx |
call open |
jc file_not_found |
file_opened: |
mov edi,esi |
pop esi |
ret |
reserve_bytes: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_dword_value |
cmp [next_pass_needed],0 |
jne rb_value_ok |
cmp [value_type],0 |
jne invalid_use_of_symbol |
rb_value_ok: |
cmp eax,0 |
jl reserve_negative |
mov ecx,eax |
mov edx,ecx |
add edx,edi |
jc out_of_memory |
cmp edx,[display_buffer] |
ja out_of_memory |
push edi |
cmp [next_pass_needed],0 |
je zero_bytes |
add edi,ecx |
jmp reserved_data |
zero_bytes: |
xor eax,eax |
shr ecx,1 |
jnc bytes_stosb_ok |
stos byte [edi] |
bytes_stosb_ok: |
shr ecx,1 |
jnc bytes_stosw_ok |
stos word [edi] |
bytes_stosw_ok: |
rep stos dword [edi] |
reserved_data: |
pop eax |
call undefined_data |
jmp instruction_assembled |
reserve_negative: |
cmp [error_line],0 |
jne instruction_assembled |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_value |
jmp instruction_assembled |
reserve_words: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_dword_value |
cmp [next_pass_needed],0 |
jne rw_value_ok |
cmp [value_type],0 |
jne invalid_use_of_symbol |
rw_value_ok: |
cmp eax,0 |
jl reserve_negative |
mov ecx,eax |
mov edx,ecx |
shl edx,1 |
jc out_of_memory |
add edx,edi |
jc out_of_memory |
cmp edx,[display_buffer] |
ja out_of_memory |
push edi |
cmp [next_pass_needed],0 |
je zero_words |
lea edi,[edi+ecx*2] |
jmp reserved_data |
zero_words: |
xor eax,eax |
shr ecx,1 |
jnc words_stosw_ok |
stos word [edi] |
words_stosw_ok: |
rep stos dword [edi] |
jmp reserved_data |
reserve_dwords: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_dword_value |
cmp [next_pass_needed],0 |
jne rd_value_ok |
cmp [value_type],0 |
jne invalid_use_of_symbol |
rd_value_ok: |
cmp eax,0 |
jl reserve_negative |
mov ecx,eax |
mov edx,ecx |
shl edx,1 |
jc out_of_memory |
shl edx,1 |
jc out_of_memory |
add edx,edi |
jc out_of_memory |
cmp edx,[display_buffer] |
ja out_of_memory |
push edi |
cmp [next_pass_needed],0 |
je zero_dwords |
lea edi,[edi+ecx*4] |
jmp reserved_data |
zero_dwords: |
xor eax,eax |
rep stos dword [edi] |
jmp reserved_data |
reserve_pwords: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_dword_value |
cmp [next_pass_needed],0 |
jne rp_value_ok |
cmp [value_type],0 |
jne invalid_use_of_symbol |
rp_value_ok: |
cmp eax,0 |
jl reserve_negative |
mov ecx,eax |
shl ecx,1 |
jc out_of_memory |
add ecx,eax |
mov edx,ecx |
shl edx,1 |
jc out_of_memory |
add edx,edi |
jc out_of_memory |
cmp edx,[display_buffer] |
ja out_of_memory |
push edi |
cmp [next_pass_needed],0 |
je zero_words |
lea edi,[edi+ecx*2] |
jmp reserved_data |
reserve_qwords: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_dword_value |
cmp [next_pass_needed],0 |
jne rq_value_ok |
cmp [value_type],0 |
jne invalid_use_of_symbol |
rq_value_ok: |
cmp eax,0 |
jl reserve_negative |
mov ecx,eax |
shl ecx,1 |
jc out_of_memory |
mov edx,ecx |
shl edx,1 |
jc out_of_memory |
shl edx,1 |
jc out_of_memory |
add edx,edi |
jc out_of_memory |
cmp edx,[display_buffer] |
ja out_of_memory |
push edi |
cmp [next_pass_needed],0 |
je zero_dwords |
lea edi,[edi+ecx*4] |
jmp reserved_data |
reserve_twords: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_dword_value |
cmp [next_pass_needed],0 |
jne rt_value_ok |
cmp [value_type],0 |
jne invalid_use_of_symbol |
rt_value_ok: |
cmp eax,0 |
jl reserve_negative |
mov ecx,eax |
shl ecx,2 |
jc out_of_memory |
add ecx,eax |
mov edx,ecx |
shl edx,1 |
jc out_of_memory |
add edx,edi |
jc out_of_memory |
cmp edx,[display_buffer] |
ja out_of_memory |
push edi |
cmp [next_pass_needed],0 |
je zero_words |
lea edi,[edi+ecx*2] |
jmp reserved_data |
align_directive: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_dword_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov edx,eax |
dec edx |
test eax,edx |
jnz negative_times |
or eax,eax |
jz negative_times |
cmp eax,1 |
je instruction_assembled |
mov ecx,edi |
sub ecx,dword [org_origin] |
cmp [org_registers],0 |
jne section_not_aligned_enough |
cmp [labels_type],0 |
je make_alignment |
cmp [output_format],3 |
je pe_alignment |
mov ebx,[org_symbol] |
cmp byte [ebx],0 |
jne section_not_aligned_enough |
cmp eax,[ebx+10h] |
jbe make_alignment |
jmp section_not_aligned_enough |
pe_alignment: |
cmp eax,1000h |
ja section_not_aligned_enough |
make_alignment: |
dec eax |
and ecx,eax |
jz instruction_assembled |
neg ecx |
add ecx,eax |
inc ecx |
mov edx,ecx |
add edx,edi |
jc out_of_memory |
cmp edx,[display_buffer] |
ja out_of_memory |
push edi |
cmp [next_pass_needed],0 |
je nops |
add edi,ecx |
jmp reserved_data |
nops: |
mov eax,90909090h |
shr ecx,1 |
jnc nops_stosb_ok |
stos byte [edi] |
nops_stosb_ok: |
shr ecx,1 |
jnc nops_stosw_ok |
stos word [edi] |
nops_stosw_ok: |
rep stos dword [edi] |
jmp reserved_data |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/fasm/trunk/errors.inc |
---|
0,0 → 1,131 |
; flat assembler core |
; Copyright (c) 1999-2006, Tomasz Grysztar. |
; All rights reserved. |
out_of_memory: |
call fatal_error |
db 'out of memory',0 |
stack_overflow: |
call fatal_error |
db 'out of stack space',0 |
main_file_not_found: |
call fatal_error |
db 'source file not found',0 |
unexpected_end_of_file: |
call fatal_error |
db 'unexpected end of file',0 |
code_cannot_be_generated: |
call fatal_error |
db 'code cannot be generated',0 |
format_limitations_exceeded: |
call fatal_error |
db 'format limitations exceeded',0 |
write_failed: |
call fatal_error |
db 'write failed',0 |
file_not_found: |
call assembler_error |
db 'file not found',0 |
error_reading_file: |
call assembler_error |
db 'error reading file',0 |
invalid_file_format: |
call assembler_error |
db 'invalid file format',0 |
invalid_macro_arguments: |
call assembler_error |
db 'invalid macro arguments',0 |
incomplete_macro: |
call assembler_error |
db 'incomplete macro',0 |
unexpected_characters: |
call assembler_error |
db 'unexpected characters',0 |
invalid_argument: |
call assembler_error |
db 'invalid argument',0 |
illegal_instruction: |
call assembler_error |
db 'illegal instruction',0 |
invalid_operand: |
call assembler_error |
db 'invalid operand',0 |
invalid_operand_size: |
call assembler_error |
db 'invalid size of operand',0 |
operand_size_not_specified: |
call assembler_error |
db 'operand size not specified',0 |
operand_sizes_do_not_match: |
call assembler_error |
db 'operand sizes do not match',0 |
invalid_address_size: |
call assembler_error |
db 'invalid size of address value',0 |
address_sizes_do_not_agree: |
call assembler_error |
db 'address sizes do not agree',0 |
prefix_conflict: |
call assembler_error |
db 'disallowed combination of registers',0 |
long_immediate_not_encodable: |
call assembler_error |
db 'not encodable with long immediate',0 |
relative_jump_out_of_range: |
call assembler_error |
db 'relative jump out of range',0 |
invalid_expression: |
call assembler_error |
db 'invalid expression',0 |
invalid_address: |
call assembler_error |
db 'invalid address',0 |
invalid_value: |
call assembler_error |
db 'invalid value',0 |
value_out_of_range: |
call assembler_error |
db 'value out of range',0 |
undefined_symbol: |
call assembler_error |
db 'undefined symbol',0 |
invalid_use_of_symbol: |
call assembler_error |
db 'invalid use of symbol',0 |
name_too_long: |
call assembler_error |
db 'name too long',0 |
invalid_name: |
call assembler_error |
db 'invalid name',0 |
reserved_word_used_as_symbol: |
call assembler_error |
db 'reserved word used as symbol',0 |
symbol_already_defined: |
call assembler_error |
db 'symbol already defined',0 |
missing_end_quote: |
call assembler_error |
db 'missing end quote',0 |
missing_end_directive: |
call assembler_error |
db 'missing end directive',0 |
unexpected_instruction: |
call assembler_error |
db 'unexpected instruction',0 |
extra_characters_on_line: |
call assembler_error |
db 'extra characters on line',0 |
section_not_aligned_enough: |
call assembler_error |
db 'section is not aligned enough',0 |
setting_already_specified: |
call assembler_error |
db 'setting already specified',0 |
data_already_defined: |
call assembler_error |
db 'data already defined',0 |
too_many_repeats: |
call assembler_error |
db 'too many repeats',0 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/fasm/trunk/expressi.inc |
---|
0,0 → 1,2688 |
; flat assembler core |
; Copyright (c) 1999-2006, Tomasz Grysztar. |
; All rights reserved. |
convert_expression: |
push ebp |
call get_fp_value |
jnc fp_expression |
mov [current_offset],esp |
expression_loop: |
push edi |
mov edi,single_operand_operators |
call get_operator |
pop edi |
or al,al |
jz expression_element |
push eax |
jmp expression_loop |
expression_element: |
mov al,[esi] |
cmp al,1Ah |
je expression_number |
cmp al,22h |
je expression_number |
cmp al,'(' |
je expression_number |
mov al,'!' |
stos byte [edi] |
jmp expression_operator |
expression_number: |
call convert_number |
expression_operator: |
push edi |
mov edi,operators |
call get_operator |
pop edi |
or al,al |
jz expression_end |
operators_loop: |
cmp esp,[current_offset] |
je push_operator |
mov bl,al |
and bl,0F0h |
mov bh,byte [esp] |
and bh,0F0h |
cmp bl,bh |
ja push_operator |
pop ebx |
mov byte [edi],bl |
inc edi |
jmp operators_loop |
push_operator: |
push eax |
jmp expression_loop |
expression_end: |
cmp esp,[current_offset] |
je expression_converted |
pop eax |
stos byte [edi] |
jmp expression_end |
expression_converted: |
pop ebp |
ret |
fp_expression: |
mov al,'.' |
stos byte [edi] |
mov eax,[fp_value] |
stos dword [edi] |
mov eax,[fp_value+4] |
stos dword [edi] |
mov eax,[fp_value+8] |
stos dword [edi] |
pop ebp |
ret |
convert_number: |
lea eax,[edi-10h] |
cmp eax,[labels_list] |
jae out_of_memory |
cmp byte [esi],'(' |
je expression_value |
inc edi |
call get_number |
jc symbol_value |
or ebp,ebp |
jz valid_number |
mov byte [edi-1],0Fh |
ret |
valid_number: |
cmp dword [edi+4],0 |
jne qword_number |
cmp word [edi+2],0 |
jne dword_number |
cmp byte [edi+1],0 |
jne word_number |
byte_number: |
mov byte [edi-1],1 |
inc edi |
ret |
qword_number: |
mov byte [edi-1],8 |
add edi,8 |
ret |
dword_number: |
mov byte [edi-1],4 |
scas dword [edi] |
ret |
word_number: |
mov byte [edi-1],2 |
scas word [edi] |
ret |
expression_value: |
mov eax,esp |
sub eax,100h |
jc stack_overflow |
cmp eax,[stack_limit] |
jb stack_overflow |
inc esi |
push [current_offset] |
call convert_expression |
pop [current_offset] |
lods byte [esi] |
cmp al,')' |
jne invalid_expression |
ret |
symbol_value: |
push edi |
mov edi,address_registers |
call get_operator |
or al,al |
jnz register_value |
mov edi,directive_operators |
call get_operator |
pop edi |
or al,al |
jnz broken_value |
lods byte [esi] |
cmp al,1Ah |
jne invalid_value |
lods byte [esi] |
movzx ecx,al |
call get_label_id |
store_label_value: |
mov byte [edi-1],11h |
stos dword [edi] |
ret |
broken_value: |
mov eax,0Fh |
jmp store_label_value |
register_value: |
pop edi |
mov byte [edi-1],10h |
stos byte [edi] |
ret |
get_number: |
xor ebp,ebp |
lods byte [esi] |
cmp al,22h |
je get_text_number |
cmp al,1Ah |
jne not_number |
lods byte [esi] |
movzx ecx,al |
mov [number_start],esi |
mov al,[esi] |
cmp al,'$' |
je number_begin |
sub al,30h |
cmp al,9 |
ja invalid_number |
number_begin: |
mov ebx,esi |
add esi,ecx |
push esi |
dec esi |
mov dword [edi],0 |
mov dword [edi+4],0 |
cmp byte [ebx],'$' |
je pascal_hex_number |
cmp word [ebx],'0x' |
je get_hex_number |
mov al,[esi] |
dec esi |
cmp al,'h' |
je get_hex_number |
cmp al,'b' |
je get_bin_number |
cmp al,'d' |
je get_dec_number |
cmp al,'o' |
je get_oct_number |
cmp al,'H' |
je get_hex_number |
cmp al,'B' |
je get_bin_number |
cmp al,'D' |
je get_dec_number |
cmp al,'O' |
je get_oct_number |
inc esi |
get_dec_number: |
mov ebx,esi |
mov esi,[number_start] |
get_dec_digit: |
cmp esi,ebx |
ja number_ok |
xor edx,edx |
mov eax,[edi] |
shld edx,eax,2 |
shl eax,2 |
add eax,[edi] |
adc edx,0 |
add eax,eax |
adc edx,edx |
mov [edi],eax |
mov eax,[edi+4] |
add eax,eax |
jc dec_out_of_range |
add eax,eax |
jc dec_out_of_range |
add eax,[edi+4] |
jc dec_out_of_range |
add eax,eax |
jc dec_out_of_range |
add eax,edx |
jc dec_out_of_range |
mov [edi+4],eax |
movzx eax,byte [esi] |
sub al,30h |
cmp al,9 |
ja bad_number |
add [edi],eax |
adc dword [edi+4],0 |
jc dec_out_of_range |
inc esi |
jmp get_dec_digit |
dec_out_of_range: |
or ebp,-1 |
inc esi |
jmp get_dec_digit |
bad_number: |
pop eax |
invalid_number: |
mov esi,[number_start] |
dec esi |
not_number: |
dec esi |
stc |
ret |
get_bin_number: |
xor bl,bl |
get_bin_digit: |
cmp esi,[number_start] |
jb number_ok |
movzx eax,byte [esi] |
sub al,30h |
cmp al,1 |
ja bad_number |
xor edx,edx |
mov cl,bl |
dec esi |
cmp bl,64 |
je bin_out_of_range |
inc bl |
cmp cl,32 |
jae bin_digit_high |
shl eax,cl |
or dword [edi],eax |
jmp get_bin_digit |
bin_digit_high: |
sub cl,32 |
shl eax,cl |
or dword [edi+4],eax |
jmp get_bin_digit |
bin_out_of_range: |
or al,al |
jz get_bin_digit |
or ebp,-1 |
jmp get_bin_digit |
pascal_hex_number: |
cmp cl,1 |
je bad_number |
get_hex_number: |
xor bl,bl |
get_hex_digit: |
cmp esi,[number_start] |
jb number_ok |
movzx eax,byte [esi] |
cmp al,'x' |
je hex_number_ok |
cmp al,'$' |
je pascal_hex_ok |
sub al,30h |
cmp al,9 |
jbe hex_digit_ok |
sub al,7 |
cmp al,15 |
jbe hex_letter_digit_ok |
sub al,20h |
cmp al,15 |
ja bad_number |
hex_letter_digit_ok: |
cmp al,10 |
jb bad_number |
hex_digit_ok: |
xor edx,edx |
mov cl,bl |
dec esi |
cmp bl,64 |
je hex_out_of_range |
add bl,4 |
cmp cl,32 |
jae hex_digit_high |
shl eax,cl |
or dword [edi],eax |
jmp get_hex_digit |
hex_digit_high: |
sub cl,32 |
shl eax,cl |
or dword [edi+4],eax |
jmp get_hex_digit |
hex_out_of_range: |
or al,al |
jz get_hex_digit |
or ebp,-1 |
jmp get_hex_digit |
get_oct_number: |
xor bl,bl |
get_oct_digit: |
cmp esi,[number_start] |
jb number_ok |
movzx eax,byte [esi] |
sub al,30h |
cmp al,7 |
ja bad_number |
oct_digit_ok: |
xor edx,edx |
mov cl,bl |
dec esi |
cmp bl,64 |
jae oct_out_of_range |
add bl,3 |
cmp cl,30 |
je oct_digit_wrap |
ja oct_digit_high |
shl eax,cl |
or dword [edi],eax |
jmp get_oct_digit |
oct_digit_wrap: |
shl eax,cl |
adc dword [edi+4],0 |
or dword [edi],eax |
jmp get_oct_digit |
oct_digit_high: |
sub cl,32 |
shl eax,cl |
or dword [edi+4],eax |
jmp get_oct_digit |
oct_out_of_range: |
or al,al |
jz get_oct_digit |
or ebp,-1 |
jmp get_oct_digit |
hex_number_ok: |
dec esi |
pascal_hex_ok: |
cmp esi,[number_start] |
jne bad_number |
number_ok: |
pop esi |
number_done: |
clc |
ret |
get_text_number: |
lods dword [esi] |
mov edx,eax |
xor bl,bl |
mov dword [edi],0 |
mov dword [edi+4],0 |
get_text_character: |
sub edx,1 |
jc number_done |
movzx eax,byte [esi] |
inc esi |
mov cl,bl |
cmp bl,64 |
je text_out_of_range |
add bl,8 |
cmp cl,32 |
jae text_character_high |
shl eax,cl |
or dword [edi],eax |
jmp get_text_character |
text_character_high: |
sub cl,32 |
shl eax,cl |
or dword [edi+4],eax |
jmp get_text_character |
text_out_of_range: |
or ebp,-1 |
jmp get_text_character |
get_fp_value: |
push edi esi |
lods byte [esi] |
cmp al,1Ah |
je fp_value_start |
cmp al,'-' |
je fp_sign_ok |
cmp al,'+' |
jne not_fp_value |
fp_sign_ok: |
lods byte [esi] |
cmp al,1Ah |
jne not_fp_value |
fp_value_start: |
lods byte [esi] |
movzx ecx,al |
cmp cl,1 |
jbe not_fp_value |
lea edx,[esi+1] |
xor ah,ah |
check_fp_value: |
lods byte [esi] |
cmp al,'.' |
je fp_character_dot |
cmp al,'E' |
je fp_character_exp |
cmp al,'e' |
je fp_character_exp |
cmp al,'F' |
je fp_last_character |
cmp al,'f' |
je fp_last_character |
digit_expected: |
cmp al,'0' |
jb not_fp_value |
cmp al,'9' |
ja not_fp_value |
jmp fp_character_ok |
fp_character_dot: |
cmp esi,edx |
je not_fp_value |
or ah,ah |
jnz not_fp_value |
or ah,1 |
lods byte [esi] |
loop digit_expected |
not_fp_value: |
pop esi edi |
stc |
ret |
fp_last_character: |
cmp cl,1 |
jne not_fp_value |
or ah,4 |
jmp fp_character_ok |
fp_character_exp: |
cmp esi,edx |
je not_fp_value |
cmp ah,1 |
ja not_fp_value |
or ah,2 |
cmp ecx,1 |
jne fp_character_ok |
cmp byte [esi],'+' |
je fp_exp_sign |
cmp byte [esi],'-' |
jne fp_character_ok |
fp_exp_sign: |
inc esi |
cmp byte [esi],1Ah |
jne not_fp_value |
inc esi |
lods byte [esi] |
movzx ecx,al |
inc ecx |
fp_character_ok: |
dec ecx |
jnz check_fp_value |
or ah,ah |
jz not_fp_value |
pop esi |
lods byte [esi] |
mov [fp_sign],0 |
cmp al,1Ah |
je fp_get |
inc esi |
cmp al,'+' |
je fp_get |
mov [fp_sign],1 |
fp_get: |
lods byte [esi] |
movzx ecx,al |
xor edx,edx |
mov edi,fp_value |
mov [edi],edx |
mov [edi+4],edx |
mov [edi+12],edx |
call fp_optimize |
mov [fp_format],0 |
mov al,[esi] |
fp_before_dot: |
lods byte [esi] |
cmp al,'.' |
je fp_dot |
cmp al,'E' |
je fp_exponent |
cmp al,'e' |
je fp_exponent |
cmp al,'F' |
je fp_done |
cmp al,'f' |
je fp_done |
sub al,30h |
mov edi,fp_value+16 |
xor edx,edx |
mov dword [edi+12],edx |
mov dword [edi],edx |
mov dword [edi+4],edx |
mov [edi+7],al |
mov dl,7 |
mov dword [edi+8],edx |
call fp_optimize |
mov edi,fp_value |
push ecx |
mov ecx,10 |
call fp_mul |
pop ecx |
mov ebx,fp_value+16 |
call fp_add |
loop fp_before_dot |
fp_dot: |
mov edi,fp_value+16 |
xor edx,edx |
mov [edi],edx |
mov [edi+4],edx |
mov byte [edi+7],80h |
mov [edi+8],edx |
mov dword [edi+12],edx |
dec ecx |
jz fp_done |
fp_after_dot: |
lods byte [esi] |
cmp al,'E' |
je fp_exponent |
cmp al,'e' |
je fp_exponent |
cmp al,'F' |
je fp_done |
cmp al,'f' |
je fp_done |
inc [fp_format] |
cmp [fp_format],80h |
jne fp_counter_ok |
mov [fp_format],7Fh |
fp_counter_ok: |
dec esi |
mov edi,fp_value+16 |
push ecx |
mov ecx,10 |
call fp_div |
push dword [edi] |
push dword [edi+4] |
push dword [edi+8] |
push dword [edi+12] |
lods byte [esi] |
sub al,30h |
movzx ecx,al |
call fp_mul |
mov ebx,edi |
mov edi,fp_value |
call fp_add |
mov edi,fp_value+16 |
pop dword [edi+12] |
pop dword [edi+8] |
pop dword [edi+4] |
pop dword [edi] |
pop ecx |
loop fp_after_dot |
jmp fp_done |
fp_exponent: |
or [fp_format],80h |
xor edx,edx |
xor ebp,ebp |
dec ecx |
jnz get_exponent |
cmp byte [esi],'+' |
je fp_exponent_sign |
cmp byte [esi],'-' |
jne fp_done |
not ebp |
fp_exponent_sign: |
add esi,2 |
lods byte [esi] |
movzx ecx,al |
get_exponent: |
movzx eax,byte [esi] |
inc esi |
sub al,30h |
cmp al,10 |
jae exponent_ok |
imul edx,10 |
cmp edx,8000h |
jae value_out_of_range |
add edx,eax |
loop get_exponent |
exponent_ok: |
mov edi,fp_value |
or edx,edx |
jz fp_done |
mov ecx,edx |
or ebp,ebp |
jnz fp_negative_power |
fp_power: |
push ecx |
mov ecx,10 |
call fp_mul |
pop ecx |
loop fp_power |
jmp fp_done |
fp_negative_power: |
push ecx |
mov ecx,10 |
call fp_div |
pop ecx |
loop fp_negative_power |
fp_done: |
mov edi,fp_value |
mov al,[fp_format] |
mov [edi+10],al |
mov al,[fp_sign] |
mov [edi+11],al |
test byte [edi+15],80h |
jz fp_ok |
add dword [edi],1 |
adc dword [edi+4],0 |
jnc fp_ok |
mov eax,[edi+4] |
shrd [edi],eax,1 |
shr eax,1 |
or eax,80000000h |
mov [edi+4],eax |
inc word [edi+8] |
fp_ok: |
pop edi |
clc |
ret |
fp_mul: |
or ecx,ecx |
jz fp_zero |
mov eax,[edi+12] |
mul ecx |
mov [edi+12],eax |
mov ebx,edx |
mov eax,[edi] |
mul ecx |
add eax,ebx |
adc edx,0 |
mov [edi],eax |
mov ebx,edx |
mov eax,[edi+4] |
mul ecx |
add eax,ebx |
adc edx,0 |
mov [edi+4],eax |
.loop: |
or edx,edx |
jz .done |
mov eax,[edi] |
shrd [edi+12],eax,1 |
mov eax,[edi+4] |
shrd [edi],eax,1 |
shrd eax,edx,1 |
mov [edi+4],eax |
shr edx,1 |
inc dword [edi+8] |
cmp dword [edi+8],8000h |
jge value_out_of_range |
jmp .loop |
.done: |
ret |
fp_div: |
mov eax,[edi+4] |
xor edx,edx |
div ecx |
mov [edi+4],eax |
mov eax,[edi] |
div ecx |
mov [edi],eax |
mov eax,[edi+12] |
div ecx |
mov [edi+12],eax |
mov ebx,eax |
or ebx,[edi] |
or ebx,[edi+4] |
jz fp_zero |
.loop: |
test byte [edi+7],80h |
jnz .exp_ok |
mov eax,[edi] |
shld [edi+4],eax,1 |
mov eax,[edi+12] |
shld [edi],eax,1 |
add eax,eax |
mov [edi+12],eax |
dec dword [edi+8] |
add edx,edx |
jmp .loop |
.exp_ok: |
mov eax,edx |
xor edx,edx |
div ecx |
add [edi+12],eax |
adc dword [edi],0 |
adc dword [edi+4],0 |
jnc .done |
mov eax,[edi+4] |
mov ebx,[edi] |
shrd [edi],eax,1 |
shrd [edi+12],ebx,1 |
shr eax,1 |
or eax,80000000h |
mov [edi+4],eax |
inc dword [edi+8] |
.done: |
ret |
fp_add: |
cmp dword [ebx+8],8000h |
je .done |
cmp dword [edi+8],8000h |
je .copy |
mov eax,[ebx+8] |
cmp eax,[edi+8] |
jge .exp_ok |
mov eax,[edi+8] |
.exp_ok: |
call .change_exp |
xchg ebx,edi |
call .change_exp |
xchg ebx,edi |
mov edx,[ebx+12] |
mov eax,[ebx] |
mov ebx,[ebx+4] |
add [edi+12],edx |
adc [edi],eax |
adc [edi+4],ebx |
jnc .done |
mov eax,[edi] |
shrd [edi+12],eax,1 |
mov eax,[edi+4] |
shrd [edi],eax,1 |
shr eax,1 |
or eax,80000000h |
mov [edi+4],eax |
inc dword [edi+8] |
.done: |
ret |
.copy: |
mov eax,[ebx] |
mov [edi],eax |
mov eax,[ebx+4] |
mov [edi+4],eax |
mov eax,[ebx+8] |
mov [edi+8],eax |
mov eax,[ebx+12] |
mov [edi+12],eax |
ret |
.change_exp: |
push ecx |
mov ecx,eax |
sub ecx,[ebx+8] |
mov edx,[ebx+4] |
jecxz .exp_done |
.exp_loop: |
mov ebp,[ebx] |
shrd [ebx+12],ebp,1 |
shrd [ebx],edx,1 |
shr edx,1 |
inc dword [ebx+8] |
loop .exp_loop |
.exp_done: |
mov [ebx+4],edx |
pop ecx |
ret |
fp_optimize: |
mov eax,[edi] |
mov ebp,[edi+4] |
or ebp,[edi] |
or ebp,[edi+12] |
jz fp_zero |
.loop: |
test byte [edi+7],80h |
jnz .done |
shld [edi+4],eax,1 |
mov ebp,[edi+12] |
shld eax,ebp,1 |
mov [edi],eax |
shl dword [edi+12],1 |
dec dword [edi+8] |
jmp .loop |
.done: |
ret |
fp_zero: |
mov dword [edi+8],8000h |
ret |
calculate_expression: |
mov [current_offset],edi |
mov [value_undefined],0 |
cmp byte [esi],0 |
je get_string_value |
cmp byte [esi],'.' |
je convert_fp |
calculation_loop: |
lods byte [esi] |
cmp al,1 |
je get_byte_number |
cmp al,2 |
je get_word_number |
cmp al,4 |
je get_dword_number |
cmp al,8 |
je get_qword_number |
cmp al,0Fh |
je value_out_of_range |
cmp al,10h |
je get_register |
cmp al,11h |
je get_label |
cmp al,')' |
je expression_calculated |
cmp al,']' |
je expression_calculated |
cmp al,'!' |
je invalid_expression |
sub edi,14h |
mov ebx,edi |
sub ebx,14h |
cmp al,0E0h |
je calculate_rva |
cmp al,0D0h |
je calculate_not |
cmp al,083h |
je calculate_neg |
mov dx,[ebx+8] |
or dx,[edi+8] |
cmp al,80h |
je calculate_add |
cmp al,81h |
je calculate_sub |
mov ah,[ebx+12] |
or ah,[edi+12] |
jz absolute_values_calculation |
cmp [error_line],0 |
jne absolute_values_calculation |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_use_of_symbol |
absolute_values_calculation: |
cmp al,90h |
je calculate_mul |
cmp al,91h |
je calculate_div |
or dx,dx |
jnz invalid_expression |
cmp al,0A0h |
je calculate_mod |
cmp al,0B0h |
je calculate_and |
cmp al,0B1h |
je calculate_or |
cmp al,0B2h |
je calculate_xor |
cmp al,0C0h |
je calculate_shl |
cmp al,0C1h |
je calculate_shr |
jmp invalid_expression |
expression_calculated: |
sub edi,14h |
cmp [value_undefined],0 |
je expression_value_ok |
xor eax,eax |
mov [edi],eax |
mov [edi+4],eax |
mov [edi+12],al |
expression_value_ok: |
ret |
get_byte_number: |
mov word [edi+8],0 |
mov byte [edi+12],0 |
xor eax,eax |
lods byte [esi] |
stos dword [edi] |
xor al,al |
stos dword [edi] |
add edi,0Ch |
jmp calculation_loop |
get_word_number: |
mov word [edi+8],0 |
mov byte [edi+12],0 |
xor eax,eax |
lods word [esi] |
stos dword [edi] |
xor ax,ax |
stos dword [edi] |
add edi,0Ch |
jmp calculation_loop |
get_dword_number: |
mov word [edi+8],0 |
mov byte [edi+12],0 |
movs dword [edi],[esi] |
xor eax,eax |
stos dword [edi] |
add edi,0Ch |
jmp calculation_loop |
get_qword_number: |
mov word [edi+8],0 |
mov byte [edi+12],0 |
movs dword [edi],[esi] |
movs dword [edi],[esi] |
add edi,0Ch |
jmp calculation_loop |
get_register: |
mov byte [edi+9],0 |
mov byte [edi+12],0 |
lods byte [esi] |
mov [edi+8],al |
mov byte [edi+10],1 |
xor eax,eax |
stos dword [edi] |
stos dword [edi] |
add edi,0Ch |
jmp calculation_loop |
get_label: |
xor eax,eax |
mov [edi+8],eax |
mov [edi+12],al |
mov [edi+20],eax |
lods dword [esi] |
cmp eax,0Fh |
jb predefined_label |
je reserved_word_used_as_symbol |
mov ebx,eax |
mov ax,[current_pass] |
mov [ebx+18],ax |
or byte [ebx+8],8 |
test byte [ebx+8],1 |
jz label_undefined |
cmp ax,[ebx+16] |
je label_defined |
test byte [ebx+8],4 |
jnz label_undefined |
test byte [ebx+9],1 |
jz label_defined |
mov eax,[ebx] |
sub eax,dword [adjustment] |
stos dword [edi] |
mov eax,[ebx+4] |
sbb eax,dword [adjustment+4] |
stos dword [edi] |
mov eax,dword [adjustment] |
or eax,dword [adjustment+4] |
jz got_label |
or [next_pass_needed],-1 |
jmp got_label |
label_defined: |
mov eax,[ebx] |
stos dword [edi] |
mov eax,[ebx+4] |
stos dword [edi] |
got_label: |
mov al,[ebx+11] |
mov [edi-8+12],al |
mov eax,[ebx+12] |
mov [edi-8+8],eax |
mov eax,[ebx+20] |
mov [edi-8+16],eax |
add edi,0Ch |
mov al,[ebx+10] |
or al,al |
jz calculation_loop |
cmp [size_override],-1 |
je calculation_loop |
cmp [size_override],0 |
je check_size |
cmp [operand_size],0 |
jne calculation_loop |
mov [operand_size],al |
jmp calculation_loop |
check_size: |
xchg [operand_size],al |
or al,al |
jz calculation_loop |
cmp al,[operand_size] |
jne operand_sizes_do_not_match |
jmp calculation_loop |
current_offset_label: |
mov al,[labels_type] |
mov [edi+12],al |
mov eax,[org_symbol] |
mov [edi+16],eax |
mov eax,[current_offset] |
xor edx,edx |
sub eax,dword [org_origin] |
sbb edx,dword [org_origin+4] |
stos dword [edi] |
mov eax,edx |
stos dword [edi] |
mov eax,[org_registers] |
stos dword [edi] |
add edi,8 |
jmp calculation_loop |
org_origin_label: |
mov al,[labels_type] |
mov [edi+12],al |
mov eax,[org_symbol] |
mov [edi+16],eax |
mov eax,[org_start] |
xor edx,edx |
sub eax,dword [org_origin] |
sbb edx,dword [org_origin+4] |
stos dword [edi] |
mov eax,edx |
stos dword [edi] |
mov eax,[org_registers] |
stos dword [edi] |
add edi,8 |
jmp calculation_loop |
counter_label: |
mov eax,[counter] |
make_dword_label_value: |
stos dword [edi] |
xor eax,eax |
stos dword [edi] |
add edi,0Ch |
jmp calculation_loop |
timestamp_label: |
call make_timestamp |
jmp make_dword_label_value |
predefined_label: |
or eax,eax |
jz current_offset_label |
cmp eax,1 |
je counter_label |
cmp eax,2 |
je timestamp_label |
cmp eax,3 |
je org_origin_label |
label_undefined: |
cmp [current_pass],1 |
ja undefined_value |
force_next_pass: |
or [next_pass_needed],-1 |
undefined_value: |
mov byte [edi+12],0 |
or [value_undefined],-1 |
xor eax,eax |
stos dword [edi] |
stos dword [edi] |
add edi,0Ch |
cmp [error_line],0 |
jne calculation_loop |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],undefined_symbol |
jmp calculation_loop |
calculate_add: |
mov ecx,[ebx+16] |
cmp byte [edi+12],0 |
je add_values |
mov ecx,[edi+16] |
cmp byte [ebx+12],0 |
je add_values |
cmp [error_line],0 |
jne add_values |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_use_of_symbol |
add_values: |
mov al,[edi+12] |
or [ebx+12],al |
mov [ebx+16],ecx |
mov eax,[edi] |
add [ebx],eax |
mov eax,[edi+4] |
adc [ebx+4],eax |
or dx,dx |
jz calculation_loop |
push esi |
mov esi,ebx |
lea ebx,[edi+10] |
mov cl,[edi+8] |
call add_register |
lea ebx,[edi+11] |
mov cl,[edi+9] |
call add_register |
pop esi |
jmp calculation_loop |
add_register: |
or cl,cl |
jz add_register_done |
add_register_start: |
cmp [esi+8],cl |
jne add_in_second_slot |
mov al,[ebx] |
add [esi+10],al |
jnz add_register_done |
mov byte [esi+8],0 |
ret |
add_in_second_slot: |
cmp [esi+9],cl |
jne create_in_first_slot |
mov al,[ebx] |
add [esi+11],al |
jnz add_register_done |
mov byte [esi+9],0 |
ret |
create_in_first_slot: |
cmp byte [esi+8],0 |
jne create_in_second_slot |
mov [esi+8],cl |
mov al,[ebx] |
mov [esi+10],al |
ret |
create_in_second_slot: |
cmp byte [esi+9],0 |
jne invalid_expression |
mov [esi+9],cl |
mov al,[ebx] |
mov [esi+11],al |
add_register_done: |
ret |
calculate_sub: |
xor ah,ah |
mov ah,[ebx+12] |
mov al,[edi+12] |
or al,al |
jz sub_values |
cmp al,ah |
jne invalid_sub |
xor ah,ah |
mov ecx,[edi+16] |
cmp ecx,[ebx+16] |
je sub_values |
cmp ecx,[org_symbol] |
jne invalid_sub |
test byte [ebx+12],1 |
jnz invalid_sub |
mov ah,3 |
sub_values: |
mov [ebx+12],ah |
mov eax,[edi] |
sub [ebx],eax |
mov eax,[edi+4] |
sbb [ebx+4],eax |
or dx,dx |
jz calculation_loop |
push esi |
mov esi,ebx |
lea ebx,[edi+10] |
mov cl,[edi+8] |
call sub_register |
lea ebx,[edi+11] |
mov cl,[edi+9] |
call sub_register |
pop esi |
jmp calculation_loop |
invalid_sub: |
cmp [error_line],0 |
jne sub_values |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_use_of_symbol |
jmp sub_values |
sub_register: |
or cl,cl |
jz add_register_done |
neg byte [ebx] |
jmp add_register_start |
calculate_mul: |
or dx,dx |
jz mul_start |
cmp word [ebx+8],0 |
jne mul_start |
mov eax,[ebx] |
xchg eax,[edi] |
mov [ebx],eax |
mov eax,[ebx+4] |
xchg eax,[edi+4] |
mov [ebx+4],eax |
mov eax,[ebx+8] |
xchg eax,[edi+8] |
mov [ebx+8],eax |
mov eax,[ebx+12] |
xchg eax,[edi+12] |
mov [ebx+12],eax |
mul_start: |
push esi edx |
mov esi,ebx |
xor bl,bl |
bt dword [esi+4],31 |
jnc mul_first_sign_ok |
not dword [esi] |
not dword [esi+4] |
add dword [esi],1 |
adc dword [esi+4],0 |
not bl |
mul_first_sign_ok: |
bt dword [edi+4],31 |
jnc mul_second_sign_ok |
not dword [edi] |
not dword [edi+4] |
add dword [edi],1 |
adc dword [edi+4],0 |
not bl |
mul_second_sign_ok: |
cmp dword [esi+4],0 |
jz mul_numbers |
cmp dword [edi+4],0 |
jnz value_out_of_range |
mul_numbers: |
mov eax,[esi+4] |
mul dword [edi] |
or edx,edx |
jnz value_out_of_range |
mov ecx,eax |
mov eax,[esi] |
mul dword [edi+4] |
or edx,edx |
jnz value_out_of_range |
add ecx,eax |
jc value_out_of_range |
mov eax,[esi] |
mul dword [edi] |
add edx,ecx |
jc value_out_of_range |
test edx,1 shl 31 |
jnz value_out_of_range |
mov [esi],eax |
mov [esi+4],edx |
or bl,bl |
jz mul_ok |
not dword [esi] |
not dword [esi+4] |
add dword [esi],1 |
adc dword [esi+4],0 |
mul_ok: |
pop edx |
or dx,dx |
jz mul_calculated |
cmp word [edi+8],0 |
jne invalid_value |
cmp byte [esi+8],0 |
je mul_first_register_ok |
mov al,[edi] |
cbw |
cwde |
cdq |
cmp edx,[edi+4] |
jne value_out_of_range |
cmp eax,[edi] |
jne value_out_of_range |
imul byte [esi+10] |
mov dl,ah |
cbw |
cmp ah,dl |
jne value_out_of_range |
mov [esi+10],al |
mul_first_register_ok: |
cmp byte [esi+9],0 |
je mul_calculated |
mov al,[edi] |
cbw |
cwde |
cdq |
cmp edx,[edi+4] |
jne value_out_of_range |
cmp eax,[edi] |
jne value_out_of_range |
imul byte [esi+11] |
mov dl,ah |
cbw |
cmp ah,dl |
jne value_out_of_range |
mov [esi+11],al |
mul_calculated: |
pop esi |
jmp calculation_loop |
calculate_div: |
push esi edx |
mov esi,ebx |
call div_64 |
pop edx |
or dx,dx |
jz div_calculated |
cmp byte [esi+8],0 |
je div_first_register_ok |
mov al,[edi] |
cbw |
cwde |
cdq |
cmp edx,[edi+4] |
jne value_out_of_range |
cmp eax,[edi] |
jne value_out_of_range |
or al,al |
jz value_out_of_range |
mov al,[esi+10] |
cbw |
idiv byte [edi] |
or ah,ah |
jnz invalid_use_of_symbol |
mov [esi+10],al |
div_first_register_ok: |
cmp byte [esi+9],0 |
je div_calculated |
mov al,[edi] |
cbw |
cwde |
cdq |
cmp edx,[edi+4] |
jne value_out_of_range |
cmp eax,[edi] |
jne value_out_of_range |
or al,al |
jz value_out_of_range |
mov al,[esi+11] |
cbw |
idiv byte [edi] |
or ah,ah |
jnz invalid_use_of_symbol |
mov [esi+11],al |
div_calculated: |
pop esi |
jmp calculation_loop |
calculate_mod: |
push esi |
mov esi,ebx |
call div_64 |
mov [esi],eax |
mov [esi+4],edx |
pop esi |
jmp calculation_loop |
calculate_and: |
mov eax,[edi] |
and [ebx],eax |
mov eax,[edi+4] |
and [ebx+4],eax |
jmp calculation_loop |
calculate_or: |
mov eax,[edi] |
or [ebx],eax |
mov eax,[edi+4] |
or [ebx+4],eax |
jmp calculation_loop |
calculate_xor: |
mov eax,[edi] |
xor [ebx],eax |
mov eax,[edi+4] |
xor [ebx+4],eax |
jmp calculation_loop |
shr_negative: |
not dword [edi] |
not dword [edi+4] |
add dword [edi],1 |
adc dword [edi+4],0 |
calculate_shl: |
mov eax,dword [edi+4] |
bt eax,31 |
jc shl_negative |
or eax,eax |
jnz zero_value |
mov ecx,[edi] |
cmp ecx,64 |
jae zero_value |
cmp ecx,32 |
jae shl_high |
mov edx,[ebx+4] |
mov eax,[ebx] |
shld edx,eax,cl |
shl eax,cl |
mov [ebx],eax |
mov [ebx+4],edx |
jmp calculation_loop |
shl_high: |
sub cl,32 |
mov eax,[ebx] |
shl eax,cl |
mov [ebx+4],eax |
mov dword [ebx],0 |
jmp calculation_loop |
shl_negative: |
not dword [edi] |
not dword [edi+4] |
add dword [edi],1 |
adc dword [edi+4],0 |
calculate_shr: |
mov eax,dword [edi+4] |
bt eax,31 |
jc shr_negative |
or eax,eax |
jnz zero_value |
mov ecx,[edi] |
cmp ecx,64 |
jae zero_value |
cmp ecx,32 |
jae shr_high |
mov edx,[ebx+4] |
mov eax,[ebx] |
shrd eax,edx,cl |
shr edx,cl |
mov [ebx],eax |
mov [ebx+4],edx |
jmp calculation_loop |
shr_high: |
sub cl,32 |
mov eax,[ebx+4] |
shr eax,cl |
mov [ebx],eax |
mov dword [ebx+4],0 |
jmp calculation_loop |
zero_value: |
mov dword [ebx],0 |
mov dword [ebx+4],0 |
jmp calculation_loop |
calculate_not: |
cmp word [edi+8],0 |
jne invalid_expression |
cmp byte [edi+12],0 |
je not_ok |
cmp [error_line],0 |
jne not_ok |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_use_of_symbol |
not_ok: |
cmp [value_size],1 |
je not_byte |
cmp [value_size],2 |
je not_word |
cmp [value_size],4 |
je not_dword |
cmp [value_size],6 |
je not_pword |
not_qword: |
not dword [edi] |
not dword [edi+4] |
add edi,14h |
jmp calculation_loop |
not_byte: |
cmp dword [edi+4],0 |
jne not_qword |
cmp word [edi+2],0 |
jne not_qword |
cmp byte [edi+1],0 |
jne not_qword |
not byte [edi] |
add edi,14h |
jmp calculation_loop |
not_word: |
cmp dword [edi+4],0 |
jne not_qword |
cmp word [edi+2],0 |
jne not_qword |
not word [edi] |
add edi,14h |
jmp calculation_loop |
not_dword: |
cmp dword [edi+4],0 |
jne not_qword |
not dword [edi] |
add edi,14h |
jmp calculation_loop |
not_pword: |
cmp word [edi+6],0 |
jne not_qword |
not dword [edi] |
not word [edi+4] |
add edi,14h |
jmp calculation_loop |
calculate_neg: |
cmp word [edi+8],0 |
jne invalid_expression |
cmp byte [edi+12],0 |
je neg_ok |
cmp [error_line],0 |
jne neg_ok |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_use_of_symbol |
neg_ok: |
mov eax,[edi] |
mov edx,[edi+4] |
mov dword [edi],0 |
mov dword [edi+4],0 |
sub [edi],eax |
sbb [edi+4],edx |
add edi,14h |
jmp calculation_loop |
calculate_rva: |
cmp word [edi+8],0 |
jne invalid_expression |
cmp [output_format],5 |
je calculate_gotoff |
cmp [output_format],3 |
jne invalid_expression |
test [format_flags],8 |
jnz pe64_rva |
mov al,2 |
bt [resolver_flags],0 |
jc rva_type_ok |
xor al,al |
rva_type_ok: |
cmp byte [edi+12],al |
je rva_ok |
cmp [error_line],0 |
jne rva_ok |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_use_of_symbol |
rva_ok: |
mov byte [edi+12],0 |
mov eax,[code_start] |
mov eax,[eax+34h] |
cdq |
sub [edi],eax |
sbb [edi+4],edx |
add edi,14h |
jmp calculation_loop |
pe64_rva: |
mov al,4 |
bt [resolver_flags],0 |
jc pe64_rva_type_ok |
xor al,al |
pe64_rva_type_ok: |
cmp byte [edi+12],al |
je pe64_rva_ok |
cmp [error_line],0 |
jne pe64_rva_ok |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_use_of_symbol |
pe64_rva_ok: |
mov byte [edi+12],0 |
mov eax,[code_start] |
mov edx,[eax+34h] |
mov eax,[eax+30h] |
sub [edi],eax |
sbb [edi+4],edx |
add edi,14h |
jmp calculation_loop |
calculate_gotoff: |
test [format_flags],8+1 |
jnz invalid_expression |
cmp byte [edi+12],2 |
je gotoff_ok |
cmp [error_line],0 |
jne pe64_rva_ok |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_use_of_symbol |
gotoff_ok: |
mov byte [edi+12],5 |
add edi,14h |
jmp calculation_loop |
div_64: |
xor ebx,ebx |
cmp dword [edi],0 |
jne divider_ok |
cmp dword [edi+4],0 |
jne divider_ok |
cmp [next_pass_needed],0 |
je value_out_of_range |
jmp div_done |
divider_ok: |
bt dword [esi+4],31 |
jnc div_first_sign_ok |
not dword [esi] |
not dword [esi+4] |
add dword [esi],1 |
adc dword [esi+4],0 |
not bx |
div_first_sign_ok: |
bt dword [edi+4],31 |
jnc div_second_sign_ok |
not dword [edi] |
not dword [edi+4] |
add dword [edi],1 |
adc dword [edi+4],0 |
not bl |
div_second_sign_ok: |
cmp dword [edi+4],0 |
jne div_high |
mov ecx,[edi] |
mov eax,[esi+4] |
xor edx,edx |
div ecx |
mov [esi+4],eax |
mov eax,[esi] |
div ecx |
mov [esi],eax |
mov eax,edx |
xor edx,edx |
jmp div_done |
div_high: |
mov eax,[esi+4] |
xor edx,edx |
div dword [edi+4] |
mov ebx,[esi] |
mov [esi],eax |
mov dword [esi+4],0 |
mov ecx,edx |
mul dword [edi] |
div_high_loop: |
cmp ecx,edx |
ja div_high_done |
jb div_high_large_correction |
cmp ebx,eax |
jae div_high_done |
div_high_correction: |
dec dword [esi] |
sub eax,[edi] |
sbb edx,[edi+4] |
jnc div_high_loop |
div_high_done: |
sub ebx,eax |
sbb ecx,edx |
mov edx,ecx |
mov eax,ebx |
ret |
div_high_large_correction: |
push eax edx |
mov eax,edx |
sub eax,ecx |
xor edx,edx |
div dword [edi+4] |
shr eax,1 |
jz div_high_small_correction |
sub [esi],eax |
push eax |
mul dword [edi+4] |
sub dword [esp+4],eax |
pop eax |
mul dword [edi] |
sub dword [esp+4],eax |
sbb dword [esp],edx |
pop edx eax |
jmp div_high_loop |
div_high_small_correction: |
pop edx eax |
jmp div_high_correction |
div_done: |
or bh,bh |
jz remainder_ok |
not eax |
not edx |
add eax,1 |
adc edx,0 |
remainder_ok: |
or bl,bl |
jz div_ok |
not dword [esi] |
not dword [esi+4] |
add dword [esi],1 |
adc dword [esi+4],0 |
div_ok: |
ret |
convert_fp: |
inc esi |
mov word [edi+8],0 |
mov byte [edi+12],0 |
mov al,[value_size] |
cmp al,4 |
je convert_fp_dword |
cmp al,8 |
je convert_fp_qword |
jmp invalid_value |
convert_fp_dword: |
xor eax,eax |
cmp word [esi+8],8000h |
je fp_dword_store |
mov bx,[esi+8] |
mov eax,[esi+4] |
shl eax,1 |
shr eax,9 |
jnc fp_dword_ok |
inc eax |
bt eax,23 |
jnc fp_dword_ok |
and eax,1 shl 23 - 1 |
inc bx |
shr eax,1 |
fp_dword_ok: |
add bx,7Fh |
cmp bx,100h |
jae value_out_of_range |
shl ebx,23 |
or eax,ebx |
fp_dword_store: |
mov bl,[esi+11] |
shl ebx,31 |
or eax,ebx |
mov [edi],eax |
xor eax,eax |
mov [edi+4],eax |
add esi,13 |
ret |
convert_fp_qword: |
xor eax,eax |
xor edx,edx |
cmp word [esi+8],8000h |
je fp_qword_store |
mov bx,[esi+8] |
mov eax,[esi] |
mov edx,[esi+4] |
add eax,eax |
adc edx,edx |
mov ecx,edx |
shr edx,12 |
shrd eax,ecx,12 |
jnc fp_qword_ok |
add eax,1 |
adc edx,0 |
bt edx,20 |
jnc fp_qword_ok |
and edx,1 shl 20 - 1 |
inc bx |
shr edx,1 |
rcr eax,1 |
fp_qword_ok: |
add bx,3FFh |
cmp bx,800h |
jae value_out_of_range |
shl ebx,20 |
or edx,ebx |
fp_qword_store: |
mov bl,[esi+11] |
shl ebx,31 |
or edx,ebx |
mov [edi],eax |
mov [edi+4],edx |
add esi,13 |
ret |
get_string_value: |
inc esi |
lods dword [esi] |
mov ecx,eax |
cmp ecx,8 |
ja value_out_of_range |
mov edx,edi |
xor eax,eax |
stos dword [edi] |
stos dword [edi] |
mov edi,edx |
rep movs byte [edi],[esi] |
mov edi,edx |
inc esi |
mov word [edi+8],0 |
mov byte [edi+12],0 |
ret |
get_byte_value: |
mov [value_size],1 |
mov [size_override],-1 |
call calculate_expression |
mov eax,[edi+16] |
mov [symbol_identifier],eax |
mov [value_type],0 |
cmp word [edi+8],0 |
jne invalid_value |
cmp byte [edi+12],0 |
je check_byte_value |
cmp [error_line],0 |
jne check_byte_value |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_use_of_symbol |
check_byte_value: |
mov eax,[edi] |
mov edx,[edi+4] |
or edx,edx |
jz byte_positive |
cmp edx,-1 |
jne range_exceeded |
cmp eax,-80h |
jb range_exceeded |
ret |
byte_positive: |
cmp eax,100h |
jae range_exceeded |
return_byte_value: |
ret |
range_exceeded: |
xor eax,eax |
xor edx,edx |
cmp [error_line],0 |
jne return_byte_value |
mov ecx,[current_line] |
mov [error_line],ecx |
mov [error],value_out_of_range |
ret |
get_word_value: |
mov [value_size],2 |
mov [size_override],-1 |
call calculate_expression |
mov eax,[edi+16] |
mov [symbol_identifier],eax |
cmp word [edi+8],0 |
jne invalid_value |
mov al,[edi+12] |
mov [value_type],al |
cmp al,2 |
jb check_word_value |
cmp [error_line],0 |
jne check_word_value |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_use_of_symbol |
check_word_value: |
mov eax,[edi] |
mov edx,[edi+4] |
or edx,edx |
jz word_positive |
cmp edx,-1 |
jne range_exceeded |
cmp eax,-8000h |
jb range_exceeded |
ret |
word_positive: |
cmp eax,10000h |
jae range_exceeded |
ret |
get_dword_value: |
mov [value_size],4 |
mov [size_override],-1 |
call calculate_expression |
mov eax,[edi+16] |
mov [symbol_identifier],eax |
cmp word [edi+8],0 |
jne invalid_value |
mov al,[edi+12] |
mov [value_type],al |
cmp al,4 |
jne check_dword_value |
mov [value_type],2 |
mov eax,[edi] |
cdq |
cmp edx,[edi+4] |
jne range_exceeded |
ret |
check_dword_value: |
mov eax,[edi] |
mov edx,[edi+4] |
or edx,edx |
jz dword_positive |
cmp edx,-1 |
jne range_exceeded |
bt eax,31 |
jnc range_exceeded |
dword_positive: |
ret |
get_pword_value: |
mov [value_size],6 |
mov [size_override],-1 |
call calculate_expression |
mov eax,[edi+16] |
mov [symbol_identifier],eax |
cmp word [edi+8],0 |
jne invalid_value |
mov al,[edi+12] |
mov [value_type],al |
cmp al,4 |
jne check_pword_value |
cmp [error_line],0 |
jne check_pword_value |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_use_of_symbol |
check_pword_value: |
mov eax,[edi] |
mov edx,[edi+4] |
cmp edx,10000h |
jge range_exceeded |
cmp edx,-8000h |
jl range_exceeded |
ret |
get_qword_value: |
mov [value_size],8 |
mov [size_override],-1 |
call calculate_expression |
mov eax,[edi+16] |
mov [symbol_identifier],eax |
cmp word [edi+8],0 |
jne invalid_value |
mov al,[edi+12] |
mov [value_type],al |
check_qword_value: |
mov eax,[edi] |
mov edx,[edi+4] |
ret |
get_value: |
mov [operand_size],0 |
lods byte [esi] |
call get_size_operator |
cmp al,'(' |
jne invalid_value |
mov al,[operand_size] |
cmp al,1 |
je value_byte |
cmp al,2 |
je value_word |
cmp al,4 |
je value_dword |
cmp al,6 |
je value_pword |
cmp al,8 |
je value_qword |
or al,al |
jnz invalid_value |
value_qword: |
call get_qword_value |
ret |
value_pword: |
call get_pword_value |
movzx edx,dx |
ret |
value_dword: |
call get_dword_value |
xor edx,edx |
ret |
value_word: |
call get_word_value |
xor edx,edx |
movzx eax,ax |
ret |
value_byte: |
call get_byte_value |
xor edx,edx |
movzx eax,al |
ret |
get_address_value: |
mov [address_size],0 |
mov [value_size],8 |
calculate_address: |
cmp byte [esi],'.' |
je invalid_address |
call calculate_expression |
mov eax,[edi+16] |
mov [address_symbol],eax |
mov al,[edi+12] |
mov [value_type],al |
cmp al,5 |
je gotoff_address |
test al,1 |
jnz invalid_use_of_symbol |
or al,al |
jz address_size_ok |
shl al,5 |
jmp address_symbol_ok |
gotoff_address: |
mov al,40h |
address_symbol_ok: |
mov ah,[address_size] |
or [address_size],al |
shr al,4 |
or ah,ah |
jz address_size_ok |
cmp al,ah |
je address_size_ok |
cmp ax,0408h |
jne address_sizes_do_not_agree |
mov [value_type],2 |
mov eax,[edi] |
cdq |
cmp edx,[edi+4] |
je address_size_ok |
cmp [error_line],0 |
jne address_size_ok |
mov ecx,[current_line] |
mov [error_line],ecx |
mov [error],value_out_of_range |
address_size_ok: |
xor bx,bx |
xor cl,cl |
mov ch,[address_size] |
cmp word [edi+8],0 |
je check_immediate_address |
mov al,[edi+8] |
mov dl,[edi+10] |
call get_address_register |
mov al,[edi+9] |
mov dl,[edi+11] |
call get_address_register |
mov ax,bx |
shr ah,4 |
shr al,4 |
or bh,bh |
jz check_address_registers |
or bl,bl |
jz check_address_registers |
cmp al,ah |
jne invalid_address |
check_address_registers: |
or al,ah |
cmp al,4 |
je sib_allowed |
cmp al,8 |
je sib_allowed |
or cl,cl |
jz check_word_value |
cmp cl,1 |
je check_word_value |
jmp invalid_address |
get_address_register: |
or al,al |
jz address_register_ok |
cmp dl,1 |
jne scaled_register |
or bh,bh |
jnz scaled_register |
mov bh,al |
address_register_ok: |
ret |
scaled_register: |
or bl,bl |
jnz invalid_address |
mov bl,al |
mov cl,dl |
jmp address_register_ok |
sib_allowed: |
or bh,bh |
jnz check_index_scale |
cmp cl,2 |
je special_index_scale |
cmp cl,3 |
je special_index_scale |
cmp cl,5 |
je special_index_scale |
cmp cl,9 |
je special_index_scale |
check_index_scale: |
or cl,cl |
jz address_registers_ok |
cmp cl,1 |
je address_registers_ok |
cmp cl,2 |
je address_registers_ok |
cmp cl,4 |
je address_registers_ok |
cmp cl,8 |
je address_registers_ok |
jmp invalid_address |
special_index_scale: |
mov bh,bl |
dec cl |
address_registers_ok: |
jmp check_dword_value |
check_immediate_address: |
cmp [code_type],64 |
jne check_dword_value |
cmp [address_size],4 |
je check_dword_value |
jmp check_qword_value |
get_relative_offset: |
mov [value_size],4 |
mov [size_override],-1 |
call calculate_expression |
calculate_relative_offset: |
push esi |
add edi,14h |
mov esi,[display_buffer] |
sub esi,7 |
lea eax,[esi-14h] |
cmp eax,edi |
jb out_of_memory |
mov byte [esi],11h |
xor eax,eax |
mov dword [esi+1],eax |
mov word [esi+5],')' shl 8 + 81h |
call calculation_loop |
pop esi |
cmp word [edi+8],0 |
jne invalid_value |
mov al,[edi+12] |
mov [value_type],al |
mov eax,[edi+16] |
mov [symbol_identifier],eax |
mov eax,[edi] |
mov edx,[edi+4] |
or edx,edx |
jz offset_positive |
cmp edx,-1 |
jne range_exceeded |
bt eax,31 |
jnc range_exceeded |
ret |
offset_positive: |
bt eax,31 |
jc range_exceeded |
ret |
preevaluate_logical_expression: |
push edi |
call preevaluate_logical_value |
preevaluation_loop: |
cmp al,0FFh |
je invalid_logical_expression |
mov dl,[esi] |
inc esi |
cmp dl,'|' |
je preevaluate_or |
cmp dl,'&' |
je preevaluate_and |
cmp dl,'}' |
je preevaluation_done |
or dl,dl |
jnz invalid_logical_expression |
preevaluation_done: |
pop edx |
dec esi |
ret |
preevaluate_or: |
cmp al,'1' |
je quick_true |
cmp al,'0' |
je leave_only_following |
push edi |
mov al,dl |
stos byte [edi] |
call preevaluate_logical_value |
pop ebx |
cmp al,'0' |
je leave_only_preceding |
cmp al,'1' |
jne preevaluation_loop |
stos byte [edi] |
xor al,al |
jmp preevaluation_loop |
preevaluate_and: |
cmp al,'0' |
je quick_false |
cmp al,'1' |
je leave_only_following |
push edi |
mov al,dl |
stos byte [edi] |
call preevaluate_logical_value |
pop ebx |
cmp al,'1' |
je leave_only_preceding |
cmp al,'0' |
jne preevaluation_loop |
stos byte [edi] |
xor al,al |
jmp preevaluation_loop |
leave_only_following: |
mov edi,[esp] |
call preevaluate_logical_value |
jmp preevaluation_loop |
leave_only_preceding: |
mov edi,ebx |
xor al,al |
jmp preevaluation_loop |
quick_true: |
call skip_logical_value |
jc invalid_logical_expression |
mov edi,[esp] |
mov al,'1' |
jmp preevaluation_loop |
quick_false: |
call skip_logical_value |
jc invalid_logical_expression |
mov edi,[esp] |
mov al,'0' |
jmp preevaluation_loop |
invalid_logical_expression: |
pop edi |
mov esi,edi |
mov al,0FFh |
stos byte [edi] |
ret |
skip_logical_value: |
cmp byte [esi],'~' |
jne negation_skipped |
inc esi |
jmp skip_logical_value |
negation_skipped: |
cmp byte [esi],'{' |
jne skip_simple_logical_value |
inc esi |
skip_logical_expression: |
call skip_logical_value |
lods byte [esi] |
or al,al |
jz wrongly_structured_logical_expression |
cmp al,0Fh |
je wrongly_structured_logical_expression |
cmp al,'|' |
je skip_logical_expression |
cmp al,'&' |
je skip_logical_expression |
cmp al,'}' |
je logical_value_skipped |
wrongly_structured_logical_expression: |
stc |
ret |
skip_simple_logical_value: |
mov al,[esi] |
or al,al |
jz logical_value_skipped |
cmp al,0Fh |
je logical_value_skipped |
cmp al,'}' |
je logical_value_skipped |
cmp al,'|' |
je logical_value_skipped |
cmp al,'&' |
je logical_value_skipped |
call skip_symbol |
jmp skip_simple_logical_value |
logical_value_skipped: |
clc |
ret |
preevaluate_logical_value: |
mov ebp,edi |
preevaluate_negation: |
cmp byte [esi],'~' |
jne preevaluate_negation_ok |
movs byte [edi],[esi] |
jmp preevaluate_negation |
preevaluate_negation_ok: |
mov ebx,esi |
xor edx,edx |
cmp byte [esi],'{' |
jne find_logical_value_boundaries |
movs byte [edi],[esi] |
push ebp |
call preevaluate_logical_expression |
pop ebp |
cmp al,0FFh |
je invalid_logical_value |
cmp byte [esi],'}' |
jne invalid_logical_value |
or al,al |
jnz preevaluated_expression_value |
movs byte [edi],[esi] |
ret |
preevaluated_expression_value: |
inc esi |
lea edx,[edi-1] |
sub edx,ebp |
test edx,1 |
jz expression_negation_ok |
xor al,1 |
expression_negation_ok: |
mov edi,ebp |
ret |
invalid_logical_value: |
mov edi,ebp |
mov al,0FFh |
ret |
find_logical_value_boundaries: |
mov al,[esi] |
or al,al |
jz logical_value_boundaries_found |
cmp al,'}' |
je logical_value_boundaries_found |
cmp al,'|' |
je logical_value_boundaries_found |
cmp al,'&' |
je logical_value_boundaries_found |
or edx,edx |
jnz next_symbol_in_logical_value |
cmp al,0F0h |
je preevaluable_logical_operator |
cmp al,0F7h |
je preevaluable_logical_operator |
cmp al,0F6h |
jne next_symbol_in_logical_value |
preevaluable_logical_operator: |
mov edx,esi |
next_symbol_in_logical_value: |
call skip_symbol |
jmp find_logical_value_boundaries |
logical_value_boundaries_found: |
or edx,edx |
jz non_preevaluable_logical_value |
mov al,[edx] |
cmp al,0F0h |
je compare_symbols |
cmp al,0F7h |
je compare_symbol_types |
cmp al,0F6h |
je scan_symbols_list |
non_preevaluable_logical_value: |
mov ecx,esi |
mov esi,ebx |
sub ecx,esi |
jz invalid_logical_value |
cmp esi,edi |
je leave_logical_value_intact |
rep movs byte [edi],[esi] |
xor al,al |
ret |
leave_logical_value_intact: |
add edi,ecx |
add esi,ecx |
xor al,al |
ret |
compare_symbols: |
lea ecx,[esi-1] |
sub ecx,edx |
mov eax,edx |
sub eax,ebx |
cmp ecx,eax |
jne preevaluated_false |
push esi edi |
mov esi,ebx |
lea edi,[edx+1] |
repe cmps byte [esi],[edi] |
pop edi esi |
je preevaluated_true |
preevaluated_false: |
mov eax,edi |
sub eax,ebp |
test eax,1 |
jnz store_true |
store_false: |
mov edi,ebp |
mov al,'0' |
ret |
preevaluated_true: |
mov eax,edi |
sub eax,ebp |
test eax,1 |
jnz store_false |
store_true: |
mov edi,ebp |
mov al,'1' |
ret |
compare_symbol_types: |
push esi |
lea esi,[edx+1] |
type_comparison: |
cmp esi,[esp] |
je types_compared |
mov al,[esi] |
cmp al,[ebx] |
jne different_type |
cmp al,'(' |
jne equal_type |
mov al,[esi+1] |
mov ah,[ebx+1] |
cmp al,ah |
je equal_type |
or al,al |
jz different_type |
or ah,ah |
jz different_type |
cmp al,'.' |
je different_type |
cmp ah,'.' |
je different_type |
equal_type: |
call skip_symbol |
xchg esi,ebx |
call skip_symbol |
xchg esi,ebx |
jmp type_comparison |
types_compared: |
pop esi |
cmp byte [ebx],0F7h |
jne preevaluated_false |
jmp preevaluated_true |
different_type: |
pop esi |
jmp preevaluated_false |
scan_symbols_list: |
push edi esi |
lea esi,[edx+1] |
sub edx,ebx |
lods byte [esi] |
cmp al,'<' |
jne invalid_symbols_list |
get_next_from_list: |
mov edi,esi |
get_from_list: |
cmp byte [esi],',' |
je compare_in_list |
cmp byte [esi],'>' |
je compare_in_list |
cmp esi,[esp] |
jae invalid_symbols_list |
call skip_symbol |
jmp get_from_list |
compare_in_list: |
mov ecx,esi |
sub ecx,edi |
cmp ecx,edx |
jne not_equal_length_in_list |
mov esi,ebx |
repe cmps byte [esi],[edi] |
mov esi,edi |
jne not_equal_in_list |
skip_rest_of_list: |
cmp byte [esi],'>' |
je check_list_end |
cmp esi,[esp] |
jae invalid_symbols_list |
call skip_symbol |
jmp skip_rest_of_list |
check_list_end: |
inc esi |
cmp esi,[esp] |
jne invalid_symbols_list |
pop esi edi |
jmp preevaluated_true |
not_equal_in_list: |
add esi,ecx |
not_equal_length_in_list: |
lods byte [esi] |
cmp al,',' |
je get_next_from_list |
cmp esi,[esp] |
jne invalid_symbols_list |
pop esi edi |
jmp preevaluated_false |
invalid_symbols_list: |
pop esi edi |
jmp invalid_logical_value |
calculate_logical_expression: |
call get_logical_value |
logical_loop: |
cmp byte [esi],'|' |
je logical_or |
cmp byte [esi],'&' |
je logical_and |
ret |
logical_or: |
inc esi |
or al,al |
jnz logical_value_already_determined |
push eax |
call get_logical_value |
pop ebx |
or al,bl |
jmp logical_loop |
logical_and: |
inc esi |
or al,al |
jz logical_value_already_determined |
push eax |
call get_logical_value |
pop ebx |
and al,bl |
jmp logical_loop |
logical_value_already_determined: |
push eax |
call skip_logical_value |
jc invalid_expression |
pop eax |
jmp logical_loop |
get_logical_value: |
xor al,al |
check_for_negation: |
cmp byte [esi],'~' |
jne negation_ok |
inc esi |
xor al,-1 |
jmp check_for_negation |
negation_ok: |
push eax |
mov al,[esi] |
cmp al,'{' |
je logical_expression |
cmp al,0FFh |
je invalid_expression |
cmp al,88h |
je check_for_defined |
cmp al,89h |
je check_for_used |
cmp al,'0' |
je given_false |
cmp al,'1' |
je given_true |
call get_value |
mov bl,[value_type] |
push eax edx ebx |
mov al,[esi] |
or al,al |
jz logical_number |
cmp al,0Fh |
je logical_number |
cmp al,'}' |
je logical_number |
cmp al,'&' |
je logical_number |
cmp al,'|' |
je logical_number |
inc esi |
mov [compare_type],al |
call get_value |
pop ebx |
cmp [next_pass_needed],0 |
jne values_ok |
cmp bl,[value_type] |
jne invalid_use_of_symbol |
values_ok: |
pop ecx ebx |
cmp [compare_type],'=' |
je check_equal |
cmp [compare_type],'>' |
je check_greater |
cmp [compare_type],'<' |
je check_less |
cmp [compare_type],0F1h |
je check_not_equal |
cmp [compare_type],0F2h |
je check_not_less |
cmp [compare_type],0F3h |
je check_not_greater |
jmp invalid_expression |
check_equal: |
cmp eax,ebx |
jne return_false |
cmp edx,ecx |
jne return_false |
jmp return_true |
check_greater: |
cmp edx,ecx |
jl return_true |
jg return_false |
cmp eax,ebx |
jb return_true |
jae return_false |
check_less: |
cmp edx,ecx |
jl return_false |
jg return_true |
cmp eax,ebx |
jbe return_false |
ja return_true |
check_not_less: |
cmp edx,ecx |
jl return_true |
jg return_false |
cmp eax,ebx |
jbe return_true |
ja return_false |
check_not_greater: |
cmp edx,ecx |
jl return_false |
jg return_true |
cmp eax,ebx |
jb return_false |
jae return_true |
check_not_equal: |
cmp eax,ebx |
jne return_true |
cmp edx,ecx |
jne return_true |
jmp return_false |
logical_number: |
pop ebx edx eax |
or bl,bl |
jnz invalid_expression |
or eax,edx |
jnz return_true |
jmp return_false |
check_for_defined: |
or bl,-1 |
lods word [esi] |
cmp ah,'(' |
jne invalid_expression |
check_expression: |
lods byte [esi] |
or al,al |
jz defined_string |
cmp al,'.' |
je defined_fp_value |
cmp al,')' |
je expression_checked |
cmp al,0Fh |
je check_expression |
cmp al,10h |
je defined_register |
cmp al,11h |
je check_if_symbol_defined |
cmp al,80h |
jae check_expression |
movzx eax,al |
add esi,eax |
jmp check_expression |
defined_register: |
inc esi |
jmp check_expression |
defined_fp_value: |
add esi,12 |
jmp expression_checked |
defined_string: |
lods dword [esi] |
add esi,eax |
inc esi |
jmp expression_checked |
check_if_symbol_defined: |
lods dword [esi] |
cmp eax,-1 |
je invalid_expression |
cmp eax,0Fh |
jb check_expression |
je reserved_word_used_as_symbol |
test byte [eax+8],4 |
jnz no_prediction |
test byte [eax+8],1 |
jz symbol_predicted_undefined |
mov cx,[current_pass] |
sub cx,[eax+16] |
jz check_expression |
cmp cx,1 |
ja symbol_predicted_undefined |
or byte [eax+8],40h+80h |
jmp check_expression |
no_prediction: |
test byte [eax+8],1 |
jz symbol_undefined |
mov cx,[current_pass] |
sub cx,[eax+16] |
jz check_expression |
jmp symbol_undefined |
symbol_predicted_undefined: |
or byte [eax+8],40h |
and byte [eax+8],not 80h |
symbol_undefined: |
xor bl,bl |
jmp check_expression |
expression_checked: |
mov al,bl |
jmp logical_value_ok |
check_for_used: |
lods word [esi] |
cmp ah,2 |
jne invalid_expression |
lods dword [esi] |
cmp eax,0Fh |
jb invalid_use_of_symbol |
je reserved_word_used_as_symbol |
inc esi |
test byte [eax+8],8 |
jz not_used |
mov cx,[current_pass] |
sub cx,[eax+18] |
jz return_true |
cmp cx,1 |
ja not_used |
or byte [eax+8],10h+20h |
jmp return_true |
not_used: |
or byte [eax+8],10h |
and byte [eax+8],not 20h |
jmp return_false |
given_false: |
inc esi |
return_false: |
xor al,al |
jmp logical_value_ok |
given_true: |
inc esi |
return_true: |
or al,-1 |
jmp logical_value_ok |
logical_expression: |
inc esi |
call calculate_logical_expression |
push eax |
lods byte [esi] |
cmp al,'}' |
jne invalid_expression |
pop eax |
logical_value_ok: |
pop ebx |
xor al,bl |
ret |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/fasm/trunk/fasm.asm |
---|
0,0 → 1,551 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; flat assembler source ;; |
;; Copyright (c) 1999-2006, Tomasz Grysztar ;; |
;; All rights reserved. ;; |
;; ;; |
;; Menuet port by VT ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
NORMAL_MODE = 8 |
CONSOLE_MODE = 32 |
MAGIC1 = 6*(text.line_size-1)+6*2+2 |
MAGIC2 = 14 |
MAGIC3 = 1 |
MAGIC4 = 7 |
OUTPUTXY = (5+MAGIC4) shl 16 + MAGIC2*3+MAGIC3+MAGIC4+1+2 |
MAX_PATH = 100 |
APP_MEMORY = 0x00800000 |
;; Menuet header |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; program start |
dd program_end ; program image size |
dd APP_MEMORY ; required amount of memory |
dd 0xDFFF0 ; stack |
dd params,0x0 ; parameters,icon |
include 'lang.inc' |
include 'fasm.inc' |
center fix true |
START: ; Start of execution |
cmp [params],0 |
jz noparams |
mov ecx,10 |
mov al,' ' |
mov edi,infile |
push ecx |
cld |
rep stosd |
mov ecx,[esp] |
mov edi,outfile |
rep stosd |
pop ecx |
mov edi,path |
rep stosd |
mov esi,params |
; DEBUGF "params: %s\n",esi |
mov edi,infile |
call mov_param_str |
; mov edi,infile |
; DEBUGF " input: %s\n",edi |
inc esi |
mov edi,outfile |
call mov_param_str |
; mov edi,outfile |
; DEBUGF "output: %s\n",edi |
inc esi |
mov edi,path |
call mov_param_str |
; mov edi,path |
; DEBUGF " path: %s\n",edi |
cmp [esi], dword ',run' |
jne @f |
mov [_run_outfile],1 |
@@: |
mov [_mode],CONSOLE_MODE |
jmp start |
noparams: |
call draw_window |
still: |
mcall 10 ; Wait here for event |
dec eax ; Redraw request |
jz red |
dec eax ; Key in buffer |
jz key |
dec eax ; Button in buffer |
jz button |
jmp still |
red: ; Redraw |
call draw_window |
jmp still |
key: ; Key |
mcall 2 ; Read it and ignore |
jmp still |
button: ; Button in Window |
mcall 17 |
cmp ah,2 ; Start compiling |
je start |
cmp ah,3 ; Start compiled file |
jnz norunout |
mov edx,outfile |
call make_fullpaths |
mcall 58,file_info_start |
; xor ecx,ecx |
jmp still |
norunout: |
mov ecx,[skinh] |
add ecx,MAGIC3+MAGIC2/2-3 |
mov [ya],ecx |
cmp ah,11 ; Infile |
je f1 |
cmp ah,12 ; Outfile |
je f2 |
cmp ah,13 ; Path |
je f3 |
dec ah ; Close application |
jnz still |
mcall -1 |
skinh dd ? |
draw_window: |
pusha |
mcall 12,1 ; Start of draw |
get_sys_colors 1,0 |
mcall 0,<50,280>,<50,250>,[sc.work] ; Draw Window |
draw_caption header,header.size ; Draw Window Label Text |
mov ecx,[skinh-2] |
mov cx,word[skinh] |
madd ecx,MAGIC3,MAGIC3 |
mov ebx,[pinfo.x_size] |
madd ebx,5,-5 |
push ecx |
madd ecx,MAGIC2*3+2,MAGIC2*3+2 |
mcall 38,,,[sc.work_graph] |
pop ecx |
sub ebx,MAGIC1+3 |
mcall |
madd ecx,MAGIC2,MAGIC2 |
mcall |
madd ecx,MAGIC2,MAGIC2 |
mcall |
madd ecx,MAGIC2,MAGIC2 |
mcall |
push ebx |
mpack ebx,MAGIC1+5,MAGIC1+5 |
sub cx,MAGIC2*3 |
mcall |
mov ebx,[esp-2] |
pop bx |
mcall |
add esp,2 |
mpack ebx,5,MAGIC1-1 |
mpack ecx,[skinh],MAGIC2-2 |
madd ecx,MAGIC3+1,0 |
mcall 8,,,0x4000000B ; Button: Enter Infile |
madd ecx,MAGIC2,0 |
mcall ,,,0x4000000C ; Button: Enter Outfile |
madd ecx,MAGIC2,0 |
mcall ,,,0x4000000D ; Button: Enter Path |
mpack ebx,[pinfo.x_size],MAGIC1 |
msub ebx,MAGIC1+5+1,0 |
mpack ecx,[skinh],MAGIC2*3/2-1 |
madd ecx,MAGIC3,0 |
mcall ,,,0x00000002,[sc.work_button] |
madd ecx,MAGIC2*3/2+1,0 |
mcall ,,,0x00000003 |
mpack ebx,5+6,[skinh] ; Draw Window Text |
add bx,MAGIC3+MAGIC2/2-3 |
mov ecx,[sc.work_text] |
mov edx,text |
mov esi,text.line_size |
mov eax,4 |
newline: |
mcall |
add ebx,MAGIC2 |
add edx,text.line_size |
cmp byte[edx],'x' |
jne newline |
mov ebx,[pinfo.x_size] |
sub ebx,MAGIC1+5+1-9 |
shl ebx,16 |
mov bx,word[skinh] |
add bx,MAGIC3+(MAGIC2*3/2-1)/2-3 |
mcall ,,[sc.work_button_text],s_compile,7 |
add ebx,MAGIC2*3/2+1 |
mcall ,,,s_run |
mpack ebx,MAGIC1+5+6,[skinh] |
add ebx,MAGIC3+MAGIC2/2-3+MAGIC2*0 |
mov esi,[pinfo.x_size] |
sub esi,MAGIC1*2+5*2+6+3 |
mov eax,esi |
mov cl,6 |
div cl |
cmp al,MAX_PATH |
jbe @f |
mov al,MAX_PATH |
@@: movzx esi,al |
mcall 4,,[sc.work_text],infile |
add ebx,MAGIC2 |
mcall ,,,outfile |
add ebx,MAGIC2 |
mcall ,,,path |
call draw_messages |
mcall 12,2 ; End of Draw |
popa |
ret |
bottom_right dd ? |
draw_messages: |
mov eax,13 ; clear work area |
mpack ebx,5+MAGIC4-2,[pinfo.x_size] |
sub ebx,5*2+MAGIC4*2-1-2*2 |
mpack ecx,[skinh],[pinfo.y_size] |
madd ecx,MAGIC2*3+MAGIC3+MAGIC4+1,-(MAGIC2*3+MAGIC3+MAGIC4*2+5)+2 |
mov word[bottom_right+2],bx |
mov word[bottom_right],cx |
msub [bottom_right],7,11 |
add [bottom_right],OUTPUTXY |
sub ecx,[skinh] |
mov edx,[sc.work] |
int 0x40 |
_cy = 0 |
_sy = 2 |
_cx = 4 |
_sx = 6 |
push ebx ecx |
mpack ebx,5+MAGIC4-3,5+MAGIC4-2 |
add bx,[esp+_cx] |
mov ecx,[esp+_sy-2] |
mov cx,[esp+_sy] |
msub ecx,1,1 |
mcall 38,,,[sc.work_graph] |
mov si,[esp+_cy] |
add cx,si |
shl esi,16 |
add ecx,esi |
madd ecx,1,1 |
mcall |
mpack ebx,5+MAGIC4-3,5+MAGIC4-3 |
mov esi,[esp+_sy-2] |
mov si,cx |
mov ecx,esi |
mcall |
mov si,[esp+_cx] |
add bx,si |
shl esi,16 |
add ebx,esi |
madd ebx,1,1 |
mcall |
pop ecx ebx |
ret |
; read string |
f1: mov [addr],infile |
add [ya],MAGIC2*0 |
jmp rk |
f2: mov [addr],outfile |
add [ya],MAGIC2*1 |
jmp rk |
f3: mov [addr],path |
add [ya],MAGIC2*2 |
rk: |
mov edi,[addr] |
mov al,0 |
mov ecx,MAX_PATH |
add edi,ecx |
dec edi |
std |
repe scasb |
sub ecx,MAX_PATH |
neg ecx |
mov al,$1C ; '' |
add edi,2 |
push edi |
cld |
rep stosb |
call print_text |
pop edi |
f11:mcall 10 |
cmp eax,2 |
jne read_done |
mcall; 2 |
shr eax,8 |
cmp al,13 |
je read_done |
cmp al,8 |
jne nobs |
cmp edi,[addr] |
je f11 |
sub edi,1 |
mov byte[edi],$1C ; '_' |
call print_text |
jmp f11 |
nobs: |
movzx ebx,al |
sub ebx,$20 |
jle f11 |
sub al,[sub_table+ebx] |
keyok: |
mov ecx,[addr] |
add ecx,MAX_PATH |
cmp edi,ecx |
jae f11 |
mov [edi],al |
call print_text |
inc edi |
jmp f11 |
read_done: |
mov ecx,[addr] |
add ecx,MAX_PATH |
sub ecx,edi |
mov al,0;' ' |
cld |
rep stosb |
call print_text |
jmp still |
print_text: |
mpack ebx,MAGIC1+5+6,[pinfo.x_size] |
sub ebx,MAGIC1*2+5*2+6+3 |
movzx esi,bx |
mov ecx,[ya-2] |
mov cx,8 |
mcall 13,,,[sc.work] |
mpack ebx,MAGIC1+5+6,[ya] |
mov eax,esi |
mov cl,6 |
div cl |
cmp al,MAX_PATH |
jbe @f |
mov al,MAX_PATH |
@@: movzx esi,al |
mcall 4,,[sc.work_text],[addr] |
ret |
; DATA |
sz header,'FASM FOR MENUET' |
text: |
db ' INFILE:' |
.line_size = $-text |
db 'OUTFILE:' |
db ' PATH:' |
db 'x' |
s_compile db 'COMPILE' |
s_run db ' RUN ' |
infile db 'EXAMPLE.ASM' |
times MAX_PATH+$-infile db 0 |
outfile db 'EXAMPLE' |
times MAX_PATH+$-outfile db 0 |
path db '/RD/1/' |
times MAX_PATH+$-path db 0 |
lf db 13,10,0 |
addr dd 0x0 |
ya dd 0x0 |
zero db 0x0 |
mov_param_str: |
@@: |
mov al,[esi] |
cmp al,',' |
je @f |
cmp al,0 |
je @f |
mov [edi],al |
inc esi |
inc edi |
jmp @b |
@@: |
mov al,0 |
stosb |
ret |
start: |
cmp [_mode],NORMAL_MODE |
jne @f |
call draw_messages |
push [skinh] |
pop [textxy] |
add [textxy],OUTPUTXY |
@@: |
mov esi,_logo |
call display_string |
; |
; Fasm native code |
; |
mov [input_file],infile |
mov [output_file],outfile |
call init_memory |
call make_timestamp |
mov [start_time],eax |
call preprocessor |
call parser |
call assembler |
call formatter |
call display_user_messages |
movzx eax,[current_pass] |
inc eax |
call display_number |
mov esi,_passes_suffix |
call display_string |
call make_timestamp |
sub eax,[start_time] |
xor edx,edx |
mov ebx,100 |
div ebx |
or eax,eax |
jz display_bytes_count |
xor edx,edx |
mov ebx,10 |
div ebx |
push edx |
call display_number |
mov dl,'.' |
call display_character |
pop eax |
call display_number |
mov esi,_seconds_suffix |
call display_string |
display_bytes_count: |
mov eax,[written_size] |
call display_number |
mov esi,_bytes_suffix |
call display_string |
xor al,al |
cmp [_run_outfile],0 |
je @f |
mov edx,outfile |
call make_fullpaths |
mov eax,58 |
mov ebx,file_info_start |
xor ecx,ecx |
int 0x40 |
@@: |
jmp exit_program |
include 'system.inc' |
include 'version.inc' |
include 'errors.inc' |
include 'expressi.inc' |
include 'preproce.inc' |
include 'parser.inc' |
include 'assemble.inc' |
include 'formats.inc' |
include 'x86_64.inc' |
include 'tables.inc' |
_logo db 'flat assembler version ',VERSION_STRING,13,10,0 |
_passes_suffix db ' passes, ',0 |
_seconds_suffix db ' seconds, ',0 |
_bytes_suffix db ' bytes.',13,10,0 |
_include db 'INCLUDE',0 |
_counter db 4,'0000' |
_mode dd NORMAL_MODE |
_run_outfile dd 0 |
sub_table: |
times $41 db $00 |
times $1A db $20 |
times $25 db $00 |
times $10 db $20 |
times $30 db $00 |
times $10 db $50 |
times $04 db $00,$01 |
times $08 db $00 |
;include_debug_strings |
params db 0 ; 'TINYPAD.ASM,TINYPAD,/HD/1/TPAD4/', |
program_end: |
rb 1000h |
align 4 |
include 'variable.inc' |
program_base dd ? |
buffer_address dd ? |
memory_setting dd ? |
start_time dd ? |
sc system_colors |
pinfo process_information |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/fasm/trunk/formats.inc |
---|
0,0 → 1,3836 |
; flat assembler core |
; Copyright (c) 1999-2006, Tomasz Grysztar. |
; All rights reserved. |
formatter: |
cmp [output_file],0 |
jne output_path_ok |
push edi |
mov esi,[input_file] |
mov edi,[free_additional_memory] |
copy_output_path: |
lods byte [esi] |
cmp edi,[structures_buffer] |
jae out_of_memory |
stos byte [edi] |
or al,al |
jnz copy_output_path |
dec edi |
mov eax,edi |
find_extension: |
dec eax |
cmp eax,[free_additional_memory] |
jb extension_found |
cmp byte [eax],'\' |
je extension_found |
cmp byte [eax],'/' |
je extension_found |
cmp byte [eax],'.' |
jne find_extension |
mov edi,eax |
extension_found: |
lea eax,[edi+9] |
cmp eax,[structures_buffer] |
jae out_of_memory |
cmp [output_format],2 |
je exe_extension |
jb bin_extension |
cmp [output_format],4 |
je obj_extension |
cmp [output_format],5 |
je o_extension |
cmp [output_format],3 |
jne no_extension |
cmp [subsystem],1 |
je sys_extension |
bt [format_flags],8 |
jnc exe_extension |
mov eax,'.dll' |
jmp make_extension |
sys_extension: |
mov eax,'.sys' |
jmp make_extension |
bin_extension: |
mov eax,'.bin' |
bt [format_flags],0 |
jnc make_extension |
mov eax,'.com' |
jmp make_extension |
obj_extension: |
mov eax,'.obj' |
jmp make_extension |
o_extension: |
mov eax,'.o' |
bt [format_flags],0 |
jnc make_extension |
no_extension: |
xor eax,eax |
jmp make_extension |
exe_extension: |
mov eax,'.exe' |
make_extension: |
xchg eax,[edi] |
scas dword [edi] |
mov byte [edi],0 |
scas byte [edi] |
mov esi,edi |
stos dword [edi] |
sub edi,9 |
xor eax,eax |
mov ebx,characters |
adapt_case: |
mov al,[esi] |
or al,al |
jz adapt_next |
xlat byte [ebx] |
cmp al,[esi] |
je adapt_ok |
sub byte [edi],20h |
adapt_ok: |
inc esi |
adapt_next: |
inc edi |
cmp byte [edi],0 |
jne adapt_case |
mov esi,edi |
lea ecx,[esi+1] |
sub ecx,[free_additional_memory] |
mov edi,[structures_buffer] |
dec edi |
std |
rep movs byte [edi],[esi] |
cld |
inc edi |
mov [structures_buffer],edi |
mov [output_file],edi |
pop edi |
output_path_ok: |
cmp [output_format],4 |
je coff_formatter |
cmp [output_format],5 |
jne common_formatter |
bt [format_flags],0 |
jnc elf_formatter |
common_formatter: |
mov eax,edi |
sub eax,[code_start] |
mov [real_code_size],eax |
cmp edi,[undefined_data_end] |
jne calculate_code_size |
mov edi,[undefined_data_start] |
calculate_code_size: |
sub edi,[code_start] |
mov [code_size],edi |
mov [written_size],0 |
mov edx,[output_file] |
call create |
jc write_failed |
cmp [output_format],3 |
jne stub_written |
mov edx,[code_start] |
mov ecx,[stub_size] |
sub edx,ecx |
add [written_size],ecx |
call write |
stub_written: |
cmp [output_format],2 |
jne write_output |
call write_mz_header |
write_output: |
call write_code |
output_written: |
call close |
ret |
write_code: |
mov eax,[written_size] |
mov [headers_size],eax |
mov edx,[code_start] |
mov ecx,[code_size] |
add [written_size],ecx |
call write |
jc write_failed |
ret |
format_directive: |
cmp edi,[code_start] |
jne unexpected_instruction |
cmp [virtual_data],0 |
jne unexpected_instruction |
cmp [output_format],0 |
jne unexpected_instruction |
lods byte [esi] |
cmp al,17h |
je format_prefix |
cmp al,18h |
jne invalid_argument |
lods byte [esi] |
select_format: |
mov dl,al |
shr al,4 |
mov [output_format],al |
and edx,0Fh |
or [format_flags],edx |
cmp al,2 |
je format_mz |
cmp al,3 |
je format_pe |
cmp al,4 |
je format_coff |
cmp al,5 |
je format_elf |
jmp instruction_assembled |
format_prefix: |
lods byte [esi] |
mov ah,al |
lods byte [esi] |
cmp al,18h |
jne invalid_argument |
lods byte [esi] |
mov edx,eax |
shr dl,4 |
shr dh,4 |
cmp dl,dh |
jne invalid_argument |
or al,ah |
jmp select_format |
entry_directive: |
bts [format_flags],10h |
jc setting_already_specified |
mov al,[output_format] |
cmp al,2 |
je mz_entry |
cmp al,3 |
je pe_entry |
cmp al,5 |
jne illegal_instruction |
bt [format_flags],0 |
jc elf_entry |
jmp illegal_instruction |
stack_directive: |
bts [format_flags],11h |
jc setting_already_specified |
mov al,[output_format] |
cmp al,2 |
je mz_stack |
cmp al,3 |
je pe_stack |
jmp illegal_instruction |
heap_directive: |
bts [format_flags],12h |
jc setting_already_specified |
mov al,[output_format] |
cmp al,2 |
je mz_heap |
cmp al,3 |
je pe_heap |
jmp illegal_instruction |
segment_directive: |
cmp [virtual_data],0 |
jne illegal_instruction |
mov al,[output_format] |
cmp al,2 |
je mz_segment |
cmp al,5 |
je elf_segment |
jmp illegal_instruction |
section_directive: |
cmp [virtual_data],0 |
jne illegal_instruction |
mov al,[output_format] |
cmp al,3 |
je pe_section |
cmp al,4 |
je coff_section |
cmp al,5 |
je elf_section |
jmp illegal_instruction |
public_directive: |
mov al,[output_format] |
cmp al,4 |
je public_allowed |
cmp al,5 |
jne illegal_instruction |
bt [format_flags],0 |
jc illegal_instruction |
public_allowed: |
lods byte [esi] |
cmp al,2 |
jne invalid_argument |
lods dword [esi] |
cmp eax,0Fh |
jb invalid_use_of_symbol |
je reserved_word_used_as_symbol |
mov dx,[current_pass] |
mov [eax+18],dx |
or byte [eax+8],8 |
inc esi |
mov ebx,[free_additional_memory] |
lea edx,[ebx+10h] |
cmp edx,[structures_buffer] |
jae out_of_memory |
mov [free_additional_memory],edx |
mov [ebx+8],eax |
mov eax,[current_line] |
mov [ebx+0Ch],eax |
lods byte [esi] |
cmp al,86h |
jne invalid_argument |
lods word [esi] |
cmp ax,'(' |
jne invalid_argument |
mov [ebx+4],esi |
lods dword [esi] |
lea esi,[esi+eax+1] |
mov byte [ebx],80h |
jmp instruction_assembled |
extrn_directive: |
mov al,[output_format] |
cmp al,4 |
je extrn_allowed |
cmp al,5 |
jne illegal_instruction |
bt [format_flags],0 |
jc illegal_instruction |
extrn_allowed: |
lods word [esi] |
cmp ax,'(' |
jne invalid_argument |
mov ebx,esi |
lods dword [esi] |
lea esi,[esi+eax+1] |
mov edx,[free_additional_memory] |
lea eax,[edx+0Ch] |
cmp eax,[structures_buffer] |
jae out_of_memory |
mov [free_additional_memory],eax |
mov byte [edx],81h |
mov [edx+4],ebx |
lods byte [esi] |
cmp al,86h |
jne invalid_argument |
lods byte [esi] |
cmp al,2 |
jne invalid_argument |
lods dword [esi] |
cmp eax,0Fh |
jb invalid_use_of_symbol |
je reserved_word_used_as_symbol |
inc esi |
mov ebx,eax |
xor ah,ah |
lods byte [esi] |
cmp al,':' |
je get_extrn_size |
dec esi |
cmp al,11h |
jne extrn_size_ok |
get_extrn_size: |
lods word [esi] |
cmp al,11h |
jne invalid_argument |
extrn_size_ok: |
mov [address_symbol],edx |
movzx ecx,ah |
mov [edx+8],ecx |
xor eax,eax |
xor edx,edx |
xor ebp,ebp |
mov ch,2 |
test [format_flags],8 |
jz make_free_label |
mov ch,4 |
jmp make_free_label |
mark_relocation: |
cmp [value_type],0 |
je relocation_ok |
cmp [virtual_data],0 |
jne relocation_ok |
cmp [output_format],2 |
je mark_mz_relocation |
cmp [output_format],3 |
je mark_pe_relocation |
cmp [output_format],4 |
je mark_coff_relocation |
cmp [output_format],5 |
je mark_elf_relocation |
relocation_ok: |
ret |
close_pass: |
mov al,[output_format] |
cmp al,3 |
je close_pe |
cmp al,4 |
je close_coff |
cmp al,5 |
je close_elf |
ret |
format_mz: |
mov edx,[additional_memory] |
push edi |
mov edi,edx |
mov ecx,1Ch shr 2 |
xor eax,eax |
rep stos dword [edi] |
mov [free_additional_memory],edi |
pop edi |
mov word [edx+0Ch],0FFFFh |
mov word [edx+10h],1000h |
mov [code_type],16 |
jmp instruction_assembled |
mark_mz_relocation: |
push eax ebx |
inc [number_of_relocations] |
mov ebx,[free_additional_memory] |
mov eax,edi |
sub eax,[code_start] |
mov [ebx],ax |
shr eax,16 |
shl ax,12 |
mov [ebx+2],ax |
cmp word [ebx],0FFFFh |
jne mz_relocation_ok |
inc word [ebx+2] |
sub word [ebx],10h |
mz_relocation_ok: |
add ebx,4 |
cmp ebx,[structures_buffer] |
jae out_of_memory |
mov [free_additional_memory],ebx |
pop ebx eax |
ret |
mz_segment: |
lods byte [esi] |
cmp al,2 |
jne invalid_argument |
lods dword [esi] |
cmp eax,0Fh |
jb invalid_use_of_symbol |
je reserved_word_used_as_symbol |
inc esi |
mov ebx,eax |
mov eax,edi |
sub eax,[code_start] |
mov ecx,0Fh |
add eax,0Fh |
and eax,1111b |
sub ecx,eax |
mov edx,edi |
xor al,al |
rep stos byte [edi] |
mov dword [org_origin],edi |
mov dword [org_origin+4],0 |
mov [org_registers],0 |
mov [org_start],edi |
mov eax,edx |
call undefined_data |
mov eax,edi |
sub eax,[code_start] |
shr eax,4 |
cmp eax,10000h |
jae value_out_of_range |
mov edx,eax |
mov al,16 |
cmp byte [esi],13h |
jne segment_type_ok |
inc esi |
lods byte [esi] |
segment_type_ok: |
mov [code_type],al |
mov eax,edx |
mov cx,0100h |
xor edx,edx |
xor ebp,ebp |
mov [address_symbol],edx |
jmp make_free_label |
mz_entry: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
call get_word_value |
cmp [value_type],1 |
je initial_cs_ok |
cmp [error_line],0 |
jne initial_cs_ok |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_address |
initial_cs_ok: |
mov edx,[additional_memory] |
mov [edx+16h],ax |
lods byte [esi] |
cmp al,':' |
jne invalid_argument |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
ja invalid_address |
call get_word_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov edx,[additional_memory] |
mov [edx+14h],ax |
jmp instruction_assembled |
mz_stack: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
call get_word_value |
cmp byte [esi],':' |
je stack_pointer |
cmp ax,10h |
jb invalid_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov edx,[additional_memory] |
mov [edx+10h],ax |
jmp instruction_assembled |
stack_pointer: |
cmp [value_type],1 |
je initial_ss_ok |
cmp [error_line],0 |
jne initial_ss_ok |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_address |
initial_ss_ok: |
mov edx,[additional_memory] |
mov [edx+0Eh],ax |
lods byte [esi] |
cmp al,':' |
jne invalid_argument |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
call get_word_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov edx,[additional_memory] |
mov [edx+10h],ax |
bts [format_flags],4 |
jmp instruction_assembled |
mz_heap: |
cmp [output_format],2 |
jne illegal_instruction |
lods byte [esi] |
call get_size_operator |
cmp ah,1 |
je invalid_value |
cmp ah,2 |
ja invalid_value |
cmp al,'(' |
jne invalid_argument |
call get_word_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov edx,[additional_memory] |
mov [edx+0Ch],ax |
jmp instruction_assembled |
write_mz_header: |
mov edx,[additional_memory] |
bt [format_flags],4 |
jc mz_stack_ok |
mov eax,[real_code_size] |
dec eax |
shr eax,4 |
inc eax |
mov [edx+0Eh],ax |
shl eax,4 |
movzx ecx,word [edx+10h] |
add eax,ecx |
mov [real_code_size],eax |
mz_stack_ok: |
mov edi,[free_additional_memory] |
mov eax,[number_of_relocations] |
shl eax,2 |
add eax,1Ch |
sub edi,eax |
xchg edi,[free_additional_memory] |
mov ecx,0Fh |
add eax,0Fh |
and eax,1111b |
sub ecx,eax |
xor al,al |
rep stos byte [edi] |
sub edi,[free_additional_memory] |
mov ecx,edi |
shr edi,4 |
mov word [edx],'MZ' ; signature |
mov [edx+8],di ; header size in paragraphs |
mov eax,[number_of_relocations] |
mov [edx+6],ax ; number of relocation entries |
mov eax,[code_size] |
add eax,ecx |
mov esi,eax |
shr esi,9 |
and eax,1FFh |
inc si |
or ax,ax |
jnz mz_size_ok |
mov ax,200h |
dec si |
mz_size_ok: |
mov [edx+2],ax ; number of bytes in last page |
mov [edx+4],si ; number of pages |
mov eax,[real_code_size] |
dec eax |
shr eax,4 |
inc eax |
mov esi,[code_size] |
dec esi |
shr esi,4 |
inc esi |
sub eax,esi |
mov [edx+0Ah],ax ; minimum memory in addition to code |
add [edx+0Ch],ax ; maximum memory in addition to code |
salc |
mov ah,al |
or [edx+0Ch],ax |
mov word [edx+18h],1Ch ; offset of relocation table |
add [written_size],ecx |
call write |
jc write_failed |
ret |
make_stub: |
mov [stub_file],edx |
or edx,edx |
jnz stub_from_file |
push esi |
mov edx,edi |
xor eax,eax |
mov ecx,20h |
rep stos dword [edi] |
mov eax,40h+default_stub_end-default_stub |
mov cx,100h+default_stub_end-default_stub |
mov word [edx],'MZ' |
mov word [edx+4],1 |
mov word [edx+2],ax |
mov word [edx+8],4 |
mov word [edx+0Ah],10h |
mov word [edx+0Ch],0FFFFh |
mov word [edx+10h],cx |
mov word [edx+3Ch],ax |
mov word [edx+18h],40h |
lea edi,[edx+40h] |
mov esi,default_stub |
mov ecx,default_stub_end-default_stub |
rep movs byte [edi],[esi] |
pop esi |
jmp stub_ok |
default_stub: |
use16 |
push cs |
pop ds |
mov dx,stub_message-default_stub |
mov ah,9 |
int 21h |
mov ax,4C01h |
int 21h |
stub_message db 'This program cannot be run in DOS mode.',0Dh,0Ah,24h |
rq 1 |
default_stub_end: |
use32 |
stub_from_file: |
push esi |
mov esi,edx |
call open_binary_file |
mov edx,edi |
mov ecx,1Ch |
mov esi,edx |
call read |
jc binary_stub |
cmp word [esi],'MZ' |
jne binary_stub |
add edi,1Ch |
movzx ecx,word [esi+6] |
add ecx,11b |
and ecx,not 11b |
add ecx,(40h-1Ch) shr 2 |
lea eax,[edi+ecx*4] |
cmp edi,[display_buffer] |
jae out_of_memory |
xor eax,eax |
rep stos dword [edi] |
mov edx,40h |
xchg dx,[esi+18h] |
xor al,al |
call lseek |
movzx ecx,word [esi+6] |
shl ecx,2 |
lea edx,[esi+40h] |
call read |
mov edx,edi |
sub edx,esi |
shr edx,4 |
xchg dx,[esi+8] |
shl edx,4 |
xor al,al |
call lseek |
movzx ecx,word [esi+4] |
dec ecx |
shl ecx,9 |
movzx edx,word [esi+2] |
add ecx,edx |
mov edx,edi |
sub ecx,eax |
je read_stub_code |
jb stub_code_ok |
push ecx |
dec ecx |
shr ecx,3 |
inc ecx |
shl ecx,1 |
lea eax,[edi+ecx*4] |
cmp eax,[display_buffer] |
jae out_of_memory |
xor eax,eax |
rep stos dword [edi] |
pop ecx |
read_stub_code: |
call read |
stub_code_ok: |
call close |
mov edx,edi |
sub edx,esi |
mov ax,dx |
and ax,1FFh |
mov [esi+2],ax |
dec edx |
shr edx,9 |
inc edx |
mov [esi+4],dx |
mov eax,edi |
sub eax,esi |
mov [esi+3Ch],eax |
pop esi |
stub_ok: |
ret |
binary_stub: |
mov esi,edi |
mov ecx,40h shr 2 |
xor eax,eax |
rep stos dword [edi] |
mov al,2 |
xor edx,edx |
call lseek |
push eax |
xor al,al |
xor edx,edx |
call lseek |
mov ecx,[esp] |
add ecx,40h+111b |
and ecx,not 111b |
mov ax,cx |
and ax,1FFh |
mov [esi+2],ax |
lea eax,[ecx+1FFh] |
shr eax,9 |
mov [esi+4],ax |
mov [esi+3Ch],ecx |
sub ecx,40h |
mov eax,10000h |
sub eax,ecx |
jbe binary_heap_ok |
shr eax,4 |
mov [esi+0Ah],ax |
binary_heap_ok: |
mov word [esi],'MZ' |
mov word [esi+8],4 |
mov ax,0FFFFh |
mov [esi+0Ch],ax |
dec ax |
mov [esi+10h],ax |
sub ax,0Eh |
mov [esi+0Eh],ax |
mov [esi+16h],ax |
mov word [esi+14h],100h |
mov word [esi+18h],40h |
mov eax,[display_buffer] |
sub eax,ecx |
cmp edi,eax |
jae out_of_memory |
mov edx,edi |
shr ecx,2 |
xor eax,eax |
rep stos dword [edi] |
pop ecx |
call read |
call close |
pop esi |
ret |
format_pe: |
xor edx,edx |
mov [machine],14Ch |
mov [subsystem],3 |
mov [subsystem_version],3 + 10 shl 16 |
mov [image_base],400000h |
test [format_flags],8 |
jz pe_settings |
mov [machine],8664h |
mov [subsystem_version],5 + 0 shl 16 |
mov [image_base_high],0 |
pe_settings: |
cmp byte [esi],84h |
je get_stub_name |
cmp byte [esi],80h |
je get_pe_base |
cmp byte [esi],1Bh |
jne pe_settings_ok |
lods byte [esi] |
lods byte [esi] |
test al,80h+40h |
jz subsystem_setting |
cmp al,80h |
je dll_flag |
cmp al,81h |
je wdm_flag |
jmp pe_settings |
dll_flag: |
bts [format_flags],8 |
jc setting_already_specified |
jmp pe_settings |
wdm_flag: |
bts [format_flags],9 |
jc setting_already_specified |
jmp pe_settings |
subsystem_setting: |
bts [format_flags],7 |
jc setting_already_specified |
and ax,3Fh |
mov [subsystem],ax |
cmp byte [esi],'(' |
jne pe_settings |
inc esi |
cmp byte [esi],'.' |
jne invalid_value |
inc esi |
push edx |
cmp byte [esi+11],0 |
jne invalid_value |
cmp byte [esi+10],2 |
ja invalid_value |
mov dx,[esi+8] |
cmp dx,8000h |
je zero_version |
mov eax,[esi+4] |
cmp dx,7 |
jg invalid_value |
mov cx,7 |
sub cx,dx |
mov eax,[esi+4] |
shr eax,cl |
mov ebx,eax |
shr ebx,24 |
cmp bl,100 |
jae invalid_value |
and eax,0FFFFFFh |
mov ecx,100 |
mul ecx |
shrd eax,edx,24 |
jnc version_value_ok |
inc eax |
version_value_ok: |
shl eax,16 |
mov ax,bx |
jmp subsystem_version_ok |
zero_version: |
xor eax,eax |
subsystem_version_ok: |
pop edx |
add esi,13 |
mov [subsystem_version],eax |
jmp pe_settings |
get_pe_base: |
bts [format_flags],10 |
jc setting_already_specified |
lods word [esi] |
cmp ah,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
push edx edi |
add edi,[stub_size] |
test [format_flags],8 |
jnz get_pe64_base |
call get_dword_value |
mov [image_base],eax |
jmp pe_base_ok |
get_pe64_base: |
call get_qword_value |
mov [image_base],eax |
mov [image_base_high],edx |
pe_base_ok: |
pop edi edx |
cmp [value_type],0 |
jne invalid_use_of_symbol |
cmp byte [esi],84h |
jne pe_settings_ok |
get_stub_name: |
lods byte [esi] |
lods word [esi] |
cmp ax,'(' |
jne invalid_argument |
lods dword [esi] |
mov edx,esi |
add esi,eax |
inc esi |
pe_settings_ok: |
mov ebp,[stub_size] |
or ebp,ebp |
jz make_pe_stub |
cmp edx,[stub_file] |
je pe_stub_ok |
sub edi,[stub_size] |
mov [code_start],edi |
make_pe_stub: |
call make_stub |
mov eax,edi |
sub eax,[code_start] |
mov [stub_size],eax |
mov [code_start],edi |
mov ebp,eax |
pe_stub_ok: |
mov edx,edi |
mov ecx,18h+0E0h |
test [format_flags],8 |
jz zero_pe_header |
add ecx,10h |
zero_pe_header: |
add ebp,ecx |
shr ecx,2 |
xor eax,eax |
rep stos dword [edi] |
mov word [edx],'PE' ; signature |
mov ax,[machine] |
mov word [edx+4],ax |
mov dword [edx+38h],1000h ; section alignment |
mov dword [edx+3Ch],200h ; file alignment |
mov word [edx+40h],1 ; OS version |
mov eax,[subsystem_version] |
mov [edx+48h],eax |
mov ax,[subsystem] |
mov [edx+5Ch],ax |
cmp ax,1 |
jne pe_alignment_ok |
mov eax,20h |
mov dword [edx+38h],eax |
mov dword [edx+3Ch],eax |
pe_alignment_ok: |
mov word [edx+1Ah],VERSION_MAJOR + VERSION_MINOR shl 8 |
test [format_flags],8 |
jnz init_pe64_specific |
mov dword [edx+14h],0E0h ; size of optional header |
mov dword [edx+16h],10B010Eh; flags and magic value |
mov eax,[image_base] |
mov dword [edx+34h],eax |
mov dword [edx+60h],1000h ; stack reserve |
mov dword [edx+64h],1000h ; stack commit |
mov dword [edx+68h],10000h ; heap reserve |
mov dword [edx+6Ch],0 ; heap commit |
mov dword [edx+74h],16 ; number of directories |
jmp pe_header_ok |
init_pe64_specific: |
mov dword [edx+14h],0F0h ; size of optional header |
mov dword [edx+16h],20B002Eh; flags and magic value |
mov eax,[image_base] |
mov dword [edx+30h],eax |
mov eax,[image_base_high] |
mov dword [edx+34h],eax |
mov dword [edx+60h],1000h ; stack reserve |
mov dword [edx+68h],1000h ; stack commit |
mov dword [edx+70h],10000h ; heap reserve |
mov dword [edx+78h],0 ; heap commit |
mov dword [edx+84h],16 ; number of directories |
pe_header_ok: |
bsf ecx,[edx+3Ch] |
imul ebx,[number_of_sections],28h |
or ebx,ebx |
jnz reserve_space_for_section_headers |
mov ebx,28h |
reserve_space_for_section_headers: |
add ebx,ebp |
dec ebx |
shr ebx,cl |
inc ebx |
shl ebx,cl |
sub ebx,ebp |
mov ecx,ebx |
mov eax,[display_buffer] |
sub eax,ecx |
cmp edi,eax |
jae out_of_memory |
shr ecx,2 |
xor eax,eax |
rep stos dword [edi] |
mov eax,edi |
sub eax,[code_start] |
add eax,[stub_size] |
mov [edx+54h],eax ; size of headers |
mov ecx,[edx+38h] |
dec ecx |
add eax,ecx |
not ecx |
and eax,ecx |
bt [format_flags],8 |
jc pe_entry_init_ok |
mov [edx+28h],eax ; entry point rva |
pe_entry_init_ok: |
mov [number_of_sections],0 |
movzx ebx,word [edx+14h] |
lea ebx,[edx+18h+ebx] |
mov [current_section],ebx |
mov dword [ebx],'.fla' |
mov dword [ebx+4],'t' |
mov [ebx+14h],edi |
mov [ebx+0Ch],eax |
mov dword [ebx+24h],0E0000060h |
xor ecx,ecx |
not eax |
not ecx |
add eax,1 |
adc ecx,0 |
add eax,edi |
adc ecx,0 |
test [format_flags],8 |
jnz pe64_org |
sub eax,[edx+34h] |
sbb ecx,0 |
mov bl,2 |
mov [code_type],32 |
jmp pe_org_ok |
pe64_org: |
sub eax,[edx+30h] |
sbb ecx,[edx+34h] |
mov bl,4 |
mov [code_type],64 |
pe_org_ok: |
bt [resolver_flags],0 |
jc pe_labels_type_ok |
xor bl,bl |
pe_labels_type_ok: |
mov [labels_type],bl |
mov dword [org_origin],eax |
mov dword [org_origin+4],ecx |
mov [org_registers],0 |
mov [org_start],edi |
bt [format_flags],8 |
jnc dll_flag_ok |
or dword [edx+16h],2000h |
dll_flag_ok: |
bt [format_flags],9 |
jnc wdm_flag_ok |
or word [edx+5Eh],2000h |
wdm_flag_ok: |
jmp instruction_assembled |
pe_section: |
call close_pe_section |
bts [format_flags],5 |
lea ecx,[ebx+28h] |
add edx,[edx+54h] |
sub edx,[stub_size] |
cmp ecx,edx |
jbe new_section |
lea ebx,[edx-28h] |
or [next_pass_needed],-1 |
push edi |
mov edi,ebx |
mov ecx,28h shr 4 |
xor eax,eax |
rep stos dword [edi] |
pop edi |
new_section: |
mov [ebx+0Ch],eax |
lods word [esi] |
cmp ax,'(' |
jne invalid_argument |
lea edx,[esi+4] |
mov ecx,[esi] |
lea esi,[esi+4+ecx+1] |
cmp ecx,8 |
ja name_too_long |
xor eax,eax |
mov [ebx],eax |
mov [ebx+4],eax |
push esi edi |
mov edi,ebx |
mov esi,edx |
rep movs byte [edi],[esi] |
pop edi esi |
mov dword [ebx+24h],0 |
mov [ebx+14h],edi |
mov edx,[code_start] |
mov eax,edi |
xor ecx,ecx |
sub eax,[ebx+0Ch] |
sbb ecx,0 |
test [format_flags],8 |
jnz pe64_section_org |
sub eax,[edx+34h] |
sbb ecx,0 |
mov [labels_type],2 |
mov [code_type],32 |
bt [resolver_flags],0 |
jc pe_section_org_ok |
mov [labels_type],0 |
jmp pe_section_org_ok |
pe64_section_org: |
sub eax,[edx+30h] |
sbb ecx,[edx+34h] |
mov [labels_type],4 |
mov [code_type],64 |
bt [resolver_flags],0 |
jc pe_section_org_ok |
mov [labels_type],0 |
pe_section_org_ok: |
mov dword [org_origin],eax |
mov dword [org_origin+4],ecx |
mov [org_registers],0 |
mov [org_start],edi |
get_section_flags: |
lods byte [esi] |
cmp al,1Ah |
je set_directory |
cmp al,19h |
je section_flag |
dec esi |
jmp instruction_assembled |
set_directory: |
movzx eax,byte [esi] |
inc esi |
mov ecx,ebx |
test [format_flags],8 |
jnz pe64_directory |
xchg ecx,[edx+78h+eax*8] |
mov dword [edx+78h+eax*8+4],-1 |
jmp pe_directory_set |
pe64_directory: |
xchg ecx,[edx+88h+eax*8] |
mov dword [edx+88h+eax*8+4],-1 |
pe_directory_set: |
or ecx,ecx |
jnz data_already_defined |
push ebx edx |
call generate_pe_data |
pop edx ebx |
jmp get_section_flags |
section_flag: |
lods byte [esi] |
cmp al,9 |
je invalid_argument |
cmp al,11 |
je invalid_argument |
mov cl,al |
mov eax,1 |
shl eax,cl |
test dword [ebx+24h],eax |
jnz setting_already_specified |
or dword [ebx+24h],eax |
jmp get_section_flags |
close_pe_section: |
mov ebx,[current_section] |
mov edx,[code_start] |
mov eax,edi |
sub eax,[ebx+14h] |
jnz finish_section |
bt [format_flags],5 |
jc finish_section |
mov eax,[ebx+0Ch] |
ret |
finish_section: |
mov [ebx+8],eax |
cmp edi,[undefined_data_end] |
jne align_section |
cmp dword [edx+38h],1000h |
jb align_section |
mov edi,[undefined_data_start] |
align_section: |
mov [undefined_data_end],0 |
mov ebp,edi |
sub ebp,[ebx+14h] |
mov ecx,[edx+3Ch] |
dec ecx |
lea eax,[ebp+ecx] |
not ecx |
and eax,ecx |
mov [ebx+10h],eax |
sub eax,ebp |
mov ecx,eax |
xor al,al |
rep stos byte [edi] |
mov eax,[code_start] |
sub eax,[stub_size] |
sub [ebx+14h],eax |
mov eax,[ebx+8] |
or eax,eax |
jz udata_ok |
cmp dword [ebx+10h],0 |
jne udata_ok |
or byte [ebx+24h],80h |
udata_ok: |
mov ecx,[edx+38h] |
dec ecx |
add eax,ecx |
not ecx |
and eax,ecx |
add eax,[ebx+0Ch] |
add ebx,28h |
mov [current_section],ebx |
inc word [number_of_sections] |
jz format_limitations_exceeded |
ret |
data_directive: |
cmp [output_format],3 |
jne illegal_instruction |
lods byte [esi] |
cmp al,1Ah |
je predefined_data_type |
cmp al,'(' |
jne invalid_argument |
call get_byte_value |
cmp al,16 |
jb data_type_ok |
jmp invalid_value |
predefined_data_type: |
movzx eax,byte [esi] |
inc esi |
data_type_ok: |
mov ebx,[current_section] |
mov ecx,edi |
sub ecx,[ebx+14h] |
add ecx,[ebx+0Ch] |
mov edx,[code_start] |
test [format_flags],8 |
jnz pe64_data |
xchg ecx,[edx+78h+eax*8] |
jmp init_pe_data |
pe64_data: |
xchg ecx,[edx+88h+eax*8] |
init_pe_data: |
or ecx,ecx |
jnz data_already_defined |
call allocate_structure_data |
mov word [ebx],data_directive-assembler |
mov [ebx+2],al |
mov edx,[current_line] |
mov [ebx+4],edx |
call generate_pe_data |
jmp instruction_assembled |
end_data: |
cmp [output_format],3 |
jne illegal_instruction |
call find_structure_data |
jc unexpected_instruction |
movzx eax,byte [ebx+2] |
mov edx,[current_section] |
mov ecx,edi |
sub ecx,[edx+14h] |
add ecx,[edx+0Ch] |
mov edx,[code_start] |
test [format_flags],8 |
jnz end_pe64_data |
sub ecx,[edx+78h+eax*8] |
mov [edx+78h+eax*8+4],ecx |
jmp remove_structure_data |
end_pe64_data: |
sub ecx,[edx+88h+eax*8] |
mov [edx+88h+eax*8+4],ecx |
jmp remove_structure_data |
pe_entry: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
test [format_flags],8 |
jnz pe64_entry |
call get_dword_value |
mov bl,2 |
bt [resolver_flags],0 |
jc check_pe_entry_label_type |
xor bl,bl |
check_pe_entry_label_type: |
cmp [value_type],bl |
je pe_entry_ok |
cmp [error_line],0 |
jne pe_entry_ok |
mov edx,[current_line] |
mov [error_line],edx |
mov [error],invalid_address |
pe_entry_ok: |
mov edx,[code_start] |
sub eax,[edx+34h] |
mov [edx+28h],eax |
jmp instruction_assembled |
pe64_entry: |
call get_qword_value |
mov bl,4 |
bt [resolver_flags],0 |
jc check_pe64_entry_label_type |
xor bl,bl |
check_pe64_entry_label_type: |
cmp [value_type],bl |
je pe64_entry_type_ok |
cmp [error_line],0 |
jne pe64_entry_type_ok |
mov edx,[current_line] |
mov [error_line],edx |
mov [error],invalid_address |
pe64_entry_type_ok: |
mov ecx,[code_start] |
sub eax,[ecx+30h] |
sbb edx,[ecx+34h] |
jz pe64_entry_range_ok |
mov edx,[current_line] |
mov [error_line],edx |
mov [error],value_out_of_range |
pe64_entry_range_ok: |
mov [ecx+28h],eax |
jmp instruction_assembled |
pe_stack: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
test [format_flags],8 |
jnz pe64_stack |
call get_dword_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov edx,[code_start] |
mov [edx+60h],eax |
cmp byte [esi],',' |
jne default_stack_commit |
lods byte [esi] |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_dword_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov edx,[code_start] |
mov [edx+64h],eax |
cmp eax,[edx+60h] |
ja value_out_of_range |
jmp instruction_assembled |
default_stack_commit: |
mov dword [edx+64h],1000h |
mov eax,[edx+60h] |
cmp eax,1000h |
ja instruction_assembled |
mov dword [edx+64h],eax |
jmp instruction_assembled |
pe64_stack: |
call get_qword_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov ecx,[code_start] |
mov [ecx+60h],eax |
mov [ecx+64h],edx |
cmp byte [esi],',' |
jne default_pe64_stack_commit |
lods byte [esi] |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_qword_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov ecx,[code_start] |
mov [ecx+68h],eax |
mov [ecx+6Ch],edx |
cmp edx,[ecx+64h] |
ja value_out_of_range |
jb instruction_assembled |
cmp eax,[edx+60h] |
ja value_out_of_range |
jmp instruction_assembled |
default_pe64_stack_commit: |
mov dword [edx+68h],1000h |
cmp dword [edx+64h],0 |
jne instruction_assembled |
mov eax,[edx+60h] |
cmp eax,1000h |
ja instruction_assembled |
mov dword [edx+68h],eax |
jmp instruction_assembled |
pe_heap: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
test [format_flags],8 |
jnz pe64_heap |
call get_dword_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov edx,[code_start] |
mov [edx+68h],eax |
cmp byte [esi],',' |
jne instruction_assembled |
lods byte [esi] |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_dword_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov edx,[code_start] |
mov [edx+6Ch],eax |
cmp eax,[edx+68h] |
ja value_out_of_range |
jmp instruction_assembled |
pe64_heap: |
call get_qword_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov ecx,[code_start] |
mov [ecx+70h],eax |
mov [ecx+74h],edx |
cmp byte [esi],',' |
jne instruction_assembled |
lods byte [esi] |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
call get_qword_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov ecx,[code_start] |
mov [ecx+78h],eax |
mov [ecx+7Ch],edx |
cmp edx,[ecx+74h] |
ja value_out_of_range |
jb instruction_assembled |
cmp eax,[edx+70h] |
ja value_out_of_range |
jmp instruction_assembled |
mark_pe_relocation: |
push eax ebx |
mov al,2 |
test [format_flags],8 |
jz check_pe_relocation_type |
mov al,4 |
check_pe_relocation_type: |
cmp [value_type],al |
je pe_relocation_type_ok |
cmp [error_line],0 |
jne pe_relocation_type_ok |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],invalid_use_of_symbol |
pe_relocation_type_ok: |
mov ebx,[current_section] |
mov eax,edi |
sub eax,[ebx+14h] |
add eax,[ebx+0Ch] |
mov ebx,[free_additional_memory] |
inc [number_of_relocations] |
jz invalid_use_of_symbol |
mov [ebx],eax |
add ebx,4 |
cmp ebx,[structures_buffer] |
jae out_of_memory |
mov [free_additional_memory],ebx |
pop ebx eax |
ret |
generate_pe_data: |
cmp al,2 |
je make_pe_resource |
cmp al,5 |
je make_pe_fixups |
ret |
make_pe_resource: |
cmp byte [esi],82h |
jne resource_done |
inc esi |
lods word [esi] |
cmp ax,'(' |
jne invalid_argument |
lods dword [esi] |
mov edx,esi |
lea esi,[esi+eax+1] |
cmp [next_pass_needed],0 |
je resource_from_file |
cmp [current_pass],0 |
jne reserve_space_for_resource |
mov [resource_size],0 |
reserve_space_for_resource: |
add edi,[resource_size] |
cmp edi,[display_buffer] |
ja out_of_memory |
jmp resource_done |
resource_from_file: |
push esi |
mov esi,edx |
call open_binary_file |
push ebx |
mov esi,[free_additional_memory] |
lea eax,[esi+20h] |
cmp eax,[structures_buffer] |
ja out_of_memory |
mov edx,esi |
mov ecx,20h |
call read |
jc invalid_file_format |
xor eax,eax |
cmp [esi],eax |
jne invalid_file_format |
mov ax,0FFFFh |
cmp [esi+8],eax |
jne invalid_file_format |
cmp [esi+12],eax |
jne invalid_file_format |
mov eax,20h |
cmp [esi+4],eax |
jne invalid_file_format |
read_resource_headers: |
test eax,11b |
jz resource_file_alignment_ok |
mov edx,4 |
and eax,11b |
sub edx,eax |
mov al,1 |
call lseek |
resource_file_alignment_ok: |
mov [esi],eax |
lea edx,[esi+12] |
mov ecx,8 |
call read |
jc resource_headers_ok |
mov ecx,[esi+16] |
add [esi],ecx |
lea edx,[esi+20] |
sub ecx,8 |
mov [esi+16],ecx |
lea eax,[edx+ecx] |
cmp eax,[structures_buffer] |
ja out_of_memory |
call read |
jc invalid_file_format |
mov edx,[esi] |
add edx,[esi+12] |
mov eax,[esi+16] |
lea ecx,[esi+20] |
lea esi,[ecx+eax] |
add ecx,2 |
cmp word [ecx-2],0FFFFh |
je resource_header_type_ok |
check_resource_header_type: |
cmp ecx,esi |
jae invalid_file_format |
cmp word [ecx],0 |
je resource_header_type_ok |
add ecx,2 |
jmp check_resource_header_type |
resource_header_type_ok: |
add ecx,2 |
cmp word [ecx],0FFFFh |
je resource_header_name_ok |
check_resource_header_name: |
cmp ecx,esi |
jae invalid_file_format |
cmp word [ecx],0 |
je resource_header_name_ok |
add ecx,2 |
jmp check_resource_header_name |
resource_header_name_ok: |
xor al,al |
call lseek |
jmp read_resource_headers |
resource_headers_ok: |
xor eax,eax |
mov [esi],eax |
mov [resource_data],edi |
lea eax,[edi+16] |
cmp eax,[display_buffer] |
jae out_of_memory |
xor eax,eax |
stos dword [edi] |
call make_timestamp |
stos dword [edi] |
xor eax,eax |
stos dword [edi] |
stos dword [edi] |
xor ebx,ebx |
make_type_name_directory: |
mov esi,[free_additional_memory] |
xor edx,edx |
find_type_name: |
cmp dword [esi],0 |
je type_name_ok |
add esi,20 |
cmp word [esi],0FFFFh |
je check_next_type_name |
or ebx,ebx |
jz check_this_type_name |
xor ecx,ecx |
compare_with_previous_type_name: |
mov ax,[esi+ecx] |
cmp ax,[ebx+ecx] |
ja check_this_type_name |
jb check_next_type_name |
add ecx,2 |
mov ax,[esi+ecx] |
or ax,[ebx+ecx] |
jnz compare_with_previous_type_name |
jmp check_next_type_name |
check_this_type_name: |
or edx,edx |
jz type_name_found |
xor ecx,ecx |
compare_with_current_type_name: |
mov ax,[esi+ecx] |
cmp ax,[edx+ecx] |
ja check_next_type_name |
jb type_name_found |
add ecx,2 |
mov ax,[esi+ecx] |
or ax,[edx+ecx] |
jnz compare_with_current_type_name |
jmp same_type_name |
type_name_found: |
mov edx,esi |
same_type_name: |
mov [esi-16],edi |
check_next_type_name: |
mov eax,[esi-4] |
add esi,eax |
jmp find_type_name |
type_name_ok: |
or edx,edx |
jz type_name_directory_done |
mov ebx,edx |
make_type_name_entry: |
mov eax,[resource_data] |
inc word [eax+12] |
lea eax,[edi+8] |
cmp eax,[display_buffer] |
jae out_of_memory |
mov eax,ebx |
stos dword [edi] |
xor eax,eax |
stos dword [edi] |
jmp make_type_name_directory |
type_name_directory_done: |
mov ebx,-1 |
make_type_id_directory: |
mov esi,[free_additional_memory] |
mov edx,10000h |
find_type_id: |
cmp dword [esi],0 |
je type_id_ok |
add esi,20 |
cmp word [esi],0FFFFh |
jne check_next_type_id |
movzx eax,word [esi+2] |
cmp eax,ebx |
jle check_next_type_id |
cmp eax,edx |
jg check_next_type_id |
mov edx,eax |
mov [esi-16],edi |
check_next_type_id: |
mov eax,[esi-4] |
add esi,eax |
jmp find_type_id |
type_id_ok: |
cmp edx,10000h |
je type_id_directory_done |
mov ebx,edx |
make_type_id_entry: |
mov eax,[resource_data] |
inc word [eax+14] |
lea eax,[edi+8] |
cmp eax,[display_buffer] |
jae out_of_memory |
mov eax,ebx |
stos dword [edi] |
xor eax,eax |
stos dword [edi] |
jmp make_type_id_directory |
type_id_directory_done: |
mov esi,[resource_data] |
add esi,10h |
mov ecx,[esi-4] |
or cx,cx |
jz resource_directories_ok |
make_resource_directories: |
push ecx |
push edi |
mov edx,edi |
sub edx,[resource_data] |
bts edx,31 |
mov [esi+4],edx |
lea eax,[edi+16] |
cmp eax,[display_buffer] |
jae out_of_memory |
xor eax,eax |
stos dword [edi] |
call make_timestamp |
stos dword [edi] |
xor eax,eax |
stos dword [edi] |
stos dword [edi] |
mov ebp,esi |
xor ebx,ebx |
make_resource_name_directory: |
mov esi,[free_additional_memory] |
xor edx,edx |
find_resource_name: |
cmp dword [esi],0 |
je resource_name_ok |
push esi |
cmp [esi+4],ebp |
jne check_next_resource_name |
add esi,20 |
call skip_resource_name |
cmp word [esi],0FFFFh |
je check_next_resource_name |
or ebx,ebx |
jz check_this_resource_name |
xor ecx,ecx |
compare_with_previous_resource_name: |
mov ax,[esi+ecx] |
cmp ax,[ebx+ecx] |
ja check_this_resource_name |
jb check_next_resource_name |
add ecx,2 |
mov ax,[esi+ecx] |
or ax,[ebx+ecx] |
jnz compare_with_previous_resource_name |
jmp check_next_resource_name |
skip_resource_name: |
cmp word [esi],0FFFFh |
jne skip_unicode_string |
add esi,4 |
ret |
skip_unicode_string: |
add esi,2 |
cmp word [esi-2],0 |
jne skip_unicode_string |
ret |
check_this_resource_name: |
or edx,edx |
jz resource_name_found |
xor ecx,ecx |
compare_with_current_resource_name: |
mov ax,[esi+ecx] |
cmp ax,[edx+ecx] |
ja check_next_resource_name |
jb resource_name_found |
add ecx,2 |
mov ax,[esi+ecx] |
or ax,[edx+ecx] |
jnz compare_with_current_resource_name |
jmp same_resource_name |
resource_name_found: |
mov edx,esi |
same_resource_name: |
mov eax,[esp] |
mov [eax+8],edi |
check_next_resource_name: |
pop esi |
mov eax,[esi+16] |
lea esi,[esi+20+eax] |
jmp find_resource_name |
resource_name_ok: |
or edx,edx |
jz resource_name_directory_done |
mov ebx,edx |
make_resource_name_entry: |
mov eax,[esp] |
inc word [eax+12] |
lea eax,[edi+8] |
cmp eax,[display_buffer] |
jae out_of_memory |
mov eax,ebx |
stos dword [edi] |
xor eax,eax |
stos dword [edi] |
jmp make_resource_name_directory |
resource_name_directory_done: |
mov ebx,-1 |
make_resource_id_directory: |
mov esi,[free_additional_memory] |
mov edx,10000h |
find_resource_id: |
cmp dword [esi],0 |
je resource_id_ok |
push esi |
cmp [esi+4],ebp |
jne check_next_resource_id |
add esi,20 |
call skip_resource_name |
cmp word [esi],0FFFFh |
jne check_next_resource_id |
movzx eax,word [esi+2] |
cmp eax,ebx |
jle check_next_resource_id |
cmp eax,edx |
jg check_next_resource_id |
mov edx,eax |
mov eax,[esp] |
mov [eax+8],edi |
check_next_resource_id: |
pop esi |
mov eax,[esi+16] |
lea esi,[esi+20+eax] |
jmp find_resource_id |
resource_id_ok: |
cmp edx,10000h |
je resource_id_directory_done |
mov ebx,edx |
make_resource_id_entry: |
mov eax,[esp] |
inc word [eax+14] |
lea eax,[edi+8] |
cmp eax,[display_buffer] |
jae out_of_memory |
mov eax,ebx |
stos dword [edi] |
xor eax,eax |
stos dword [edi] |
jmp make_resource_id_directory |
resource_id_directory_done: |
pop eax |
mov esi,ebp |
pop ecx |
add esi,8 |
dec cx |
jnz make_resource_directories |
resource_directories_ok: |
shr ecx,16 |
jnz make_resource_directories |
mov esi,[resource_data] |
add esi,10h |
movzx eax,word [esi-4] |
movzx edx,word [esi-2] |
add eax,edx |
lea esi,[esi+eax*8] |
push edi ; address of language directories |
update_resource_directories: |
cmp esi,[esp] |
je resource_directories_updated |
add esi,10h |
mov ecx,[esi-4] |
or cx,cx |
jz language_directories_ok |
make_language_directories: |
push ecx |
push edi |
mov edx,edi |
sub edx,[resource_data] |
bts edx,31 |
mov [esi+4],edx |
lea eax,[edi+16] |
cmp eax,[display_buffer] |
jae out_of_memory |
xor eax,eax |
stos dword [edi] |
call make_timestamp |
stos dword [edi] |
xor eax,eax |
stos dword [edi] |
stos dword [edi] |
mov ebp,esi |
mov ebx,-1 |
make_language_id_directory: |
mov esi,[free_additional_memory] |
mov edx,10000h |
find_language_id: |
cmp dword [esi],0 |
je language_id_ok |
push esi |
cmp [esi+8],ebp |
jne check_next_language_id |
add esi,20 |
mov eax,esi |
call skip_resource_name |
call skip_resource_name |
neg eax |
add eax,esi |
and eax,11b |
add esi,eax |
get_language_id: |
movzx eax,word [esi+6] |
cmp eax,ebx |
jle check_next_language_id |
cmp eax,edx |
jge check_next_language_id |
mov edx,eax |
mov eax,[esp] |
mov [current_offset],eax |
check_next_language_id: |
pop esi |
mov eax,[esi+16] |
lea esi,[esi+20+eax] |
jmp find_language_id |
language_id_ok: |
cmp edx,10000h |
je language_id_directory_done |
mov ebx,edx |
make_language_id_entry: |
mov eax,[esp] |
inc word [eax+14] |
lea eax,[edi+8] |
cmp eax,[display_buffer] |
jae out_of_memory |
mov eax,ebx |
stos dword [edi] |
mov eax,[current_offset] |
stos dword [edi] |
jmp make_language_id_directory |
language_id_directory_done: |
pop eax |
mov esi,ebp |
pop ecx |
add esi,8 |
dec cx |
jnz make_language_directories |
language_directories_ok: |
shr ecx,16 |
jnz make_language_directories |
jmp update_resource_directories |
resource_directories_updated: |
mov esi,[resource_data] |
push edi |
make_name_strings: |
add esi,10h |
movzx eax,word [esi-2] |
movzx ecx,word [esi-4] |
add eax,ecx |
lea eax,[esi+eax*8] |
push eax |
or ecx,ecx |
jz string_entries_processed |
process_string_entries: |
push ecx |
mov edx,edi |
sub edx,[resource_data] |
bts edx,31 |
xchg [esi],edx |
mov ebx,edi |
xor ax,ax |
stos word [edi] |
copy_string_data: |
lea eax,[edi+2] |
cmp eax,[display_buffer] |
jae out_of_memory |
mov ax,[edx] |
or ax,ax |
jz string_data_copied |
stos word [edi] |
inc word [ebx] |
add edx,2 |
jmp copy_string_data |
string_data_copied: |
add esi,8 |
pop ecx |
loop process_string_entries |
string_entries_processed: |
pop esi |
cmp esi,[esp] |
jb make_name_strings |
mov eax,edi |
sub eax,[resource_data] |
test al,11b |
jz resource_strings_alignment_ok |
xor ax,ax |
stos word [edi] |
resource_strings_alignment_ok: |
pop edx |
pop ebx ; address of language directories |
mov ebp,edi |
update_language_directories: |
add ebx,10h |
movzx eax,word [ebx-2] |
movzx ecx,word [ebx-4] |
add ecx,eax |
make_data_records: |
push ecx |
mov esi,edi |
sub esi,[resource_data] |
xchg esi,[ebx+4] |
lea eax,[edi+16] |
cmp eax,[display_buffer] |
jae out_of_memory |
mov eax,esi |
stos dword [edi] |
mov eax,[esi+12] |
stos dword [edi] |
xor eax,eax |
stos dword [edi] |
stos dword [edi] |
pop ecx |
add ebx,8 |
loop make_data_records |
cmp ebx,edx |
jb update_language_directories |
pop ebx ; file handle |
mov esi,ebp |
mov ebp,edi |
update_data_records: |
push ebp |
mov ecx,edi |
mov eax,[current_section] |
sub ecx,[eax+14h] |
add ecx,[eax+0Ch] |
xchg ecx,[esi] |
mov edx,[ecx] |
xor al,al |
call lseek |
mov edx,edi |
mov ecx,[esi+4] |
add edi,ecx |
cmp edi,[display_buffer] |
ja out_of_memory |
call read |
mov eax,edi |
sub eax,[resource_data] |
and eax,11b |
jz resource_data_alignment_ok |
mov ecx,4 |
sub ecx,eax |
xor al,al |
rep stos byte [edi] |
resource_data_alignment_ok: |
pop ebp |
add esi,16 |
cmp esi,ebp |
jb update_data_records |
pop esi |
call close |
mov eax,edi |
sub eax,[resource_data] |
mov [resource_size],eax |
resource_done: |
ret |
make_pe_fixups: |
bts [resolver_flags],0 |
jc pe_relocatable_ok |
or [next_pass_needed],-1 |
pe_relocatable_ok: |
push esi |
mov ecx,[number_of_relocations] |
mov esi,[free_additional_memory] |
mov eax,ecx |
shl eax,2 |
sub esi,eax |
mov [free_additional_memory],esi |
or [number_of_relocations],-1 |
xor edx,edx |
mov ebp,edi |
make_fixups: |
cmp [esi],edx |
jb store_fixup |
mov eax,edi |
sub eax,ebp |
test eax,11b |
jz fixups_block |
xor ax,ax |
stos word [edi] |
add dword [ebx],2 |
fixups_block: |
mov eax,edx |
add edx,1000h |
cmp [esi],edx |
jae fixups_block |
stos dword [edi] |
mov ebx,edi |
mov eax,8 |
stos dword [edi] |
store_fixup: |
jecxz fixups_done |
add dword [ebx],2 |
mov eax,[esi] |
and ax,0FFFh |
test [format_flags],8 |
jnz fixup_64bit |
or ax,3000h |
jmp fixup_ok |
fixup_64bit: |
or ax,0A000h |
fixup_ok: |
stos word [edi] |
add esi,4 |
loop make_fixups |
fixups_done: |
pop esi |
ret |
close_pe: |
call close_pe_section |
mov edx,[code_start] |
mov [edx+50h],eax |
call make_timestamp |
mov edx,[code_start] |
mov [edx+8],eax |
mov eax,[number_of_relocations] |
cmp eax,-1 |
je pe_relocations_ok |
shl eax,2 |
sub [free_additional_memory],eax |
btr [resolver_flags],0 |
jnc pe_relocations_ok |
or [next_pass_needed],-1 |
pe_relocations_ok: |
mov eax,[number_of_sections] |
mov [edx+6],ax |
imul eax,28h |
movzx ecx,word [edx+14h] |
lea eax,[eax+18h+ecx] |
add eax,[stub_size] |
mov ecx,[edx+3Ch] |
dec ecx |
add eax,ecx |
not ecx |
and eax,ecx |
cmp eax,[edx+54h] |
je pe_sections_ok |
or [next_pass_needed],-1 |
pe_sections_ok: |
xor ecx,ecx |
add edx,78h |
test [format_flags],8 |
jz process_directories |
add edx,10h |
process_directories: |
mov eax,[edx+ecx*8] |
or eax,eax |
jz directory_ok |
cmp dword [edx+ecx*8+4],-1 |
jne directory_ok |
section_data: |
mov ebx,[edx+ecx*8] |
mov eax,[ebx+0Ch] |
mov [edx+ecx*8],eax ; directory rva |
mov eax,[ebx+8] |
mov [edx+ecx*8+4],eax ; directory size |
directory_ok: |
inc cl |
cmp cl,10h |
jb process_directories |
mov ebx,[code_start] |
sub ebx,[stub_size] |
mov ecx,edi |
sub ecx,ebx |
mov ebp,ecx |
shr ecx,1 |
xor eax,eax |
cdq |
calculate_checksum: |
mov dx,[ebx] |
add eax,edx |
mov dx,ax |
shr eax,16 |
add eax,edx |
add ebx,2 |
loop calculate_checksum |
add eax,ebp |
mov ebx,[code_start] |
mov [ebx+58h],eax |
ret |
format_coff: |
mov eax,[additional_memory] |
mov [symbols_stream],eax |
mov ebx,eax |
add eax,20h |
cmp eax,[structures_buffer] |
jae out_of_memory |
mov [free_additional_memory],eax |
xor eax,eax |
mov [ebx],al |
mov [ebx+4],eax |
mov [ebx+8],edi |
mov al,4 |
mov [ebx+10h],eax |
mov al,60h |
bt [format_flags],0 |
jnc flat_section_flags_ok |
or eax,0E0000000h |
flat_section_flags_ok: |
mov dword [ebx+14h],eax |
mov [current_section],ebx |
mov [number_of_sections],0 |
mov dword [org_origin],edi |
mov dword [org_origin+4],0 |
mov [org_registers],0 |
mov [org_start],edi |
mov [org_symbol],ebx |
mov [labels_type],2 |
mov [code_type],32 |
test [format_flags],8 |
jz instruction_assembled |
mov [labels_type],4 |
mov [code_type],64 |
jmp instruction_assembled |
coff_section: |
call close_coff_section |
mov ebx,[free_additional_memory] |
lea eax,[ebx+20h] |
cmp eax,[structures_buffer] |
jae out_of_memory |
mov [free_additional_memory],eax |
mov [current_section],ebx |
inc [number_of_sections] |
xor eax,eax |
mov [ebx],al |
mov [ebx+8],edi |
mov dword [org_origin],edi |
mov dword [org_origin+4],0 |
mov [org_registers],0 |
mov [org_start],edi |
mov [org_symbol],ebx |
mov [labels_type],2 |
test [format_flags],8 |
jz coff_labels_type_ok |
mov [labels_type],4 |
coff_labels_type_ok: |
mov [ebx+10h],eax |
mov [ebx+14h],eax |
lods word [esi] |
cmp ax,'(' |
jne invalid_argument |
mov [ebx+4],esi |
mov ecx,[esi] |
lea esi,[esi+4+ecx+1] |
cmp ecx,8 |
ja name_too_long |
coff_section_flags: |
cmp byte [esi],1Ch |
je coff_section_alignment |
cmp byte [esi],19h |
jne coff_section_settings_ok |
inc esi |
lods byte [esi] |
bt [format_flags],0 |
jc coff_section_flag_ok |
cmp al,7 |
ja invalid_argument |
coff_section_flag_ok: |
mov cl,al |
mov eax,1 |
shl eax,cl |
test dword [ebx+14h],eax |
jnz setting_already_specified |
or dword [ebx+14h],eax |
jmp coff_section_flags |
coff_section_alignment: |
bt [format_flags],0 |
jnc invalid_argument |
inc esi |
lods byte [esi] |
or al,al |
jnz invalid_argument |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
push ebx |
call get_dword_value |
pop ebx |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov edx,eax |
dec edx |
test eax,edx |
jnz invalid_value |
or eax,eax |
jz invalid_value |
cmp eax,2000h |
ja invalid_value |
bsf edx,eax |
inc edx |
shl edx,20 |
or [ebx+14h],edx |
xchg [ebx+10h],eax |
or eax,eax |
jnz setting_already_specified |
jmp coff_section_flags |
coff_section_settings_ok: |
cmp dword [ebx+10h],0 |
jne instruction_assembled |
mov dword [ebx+10h],4 |
bt [format_flags],0 |
jnc instruction_assembled |
or dword [ebx+14h],300000h |
jmp instruction_assembled |
close_coff_section: |
mov ebx,[current_section] |
mov eax,edi |
mov edx,[ebx+8] |
sub eax,edx |
mov [ebx+0Ch],eax |
xor eax,eax |
xchg [undefined_data_end],eax |
cmp eax,edi |
jne coff_section_ok |
cmp edx,[undefined_data_start] |
jne coff_section_ok |
mov edi,edx |
or byte [ebx+14h],80h |
coff_section_ok: |
ret |
mark_coff_relocation: |
cmp [value_type],3 |
je coff_relocation_relative |
push ebx eax |
test [format_flags],8 |
jnz coff_64bit_relocation |
mov al,6 |
jmp coff_relocation |
coff_64bit_relocation: |
mov al,1 |
cmp [value_type],4 |
je coff_relocation |
mov al,2 |
jmp coff_relocation |
coff_relocation_relative: |
push ebx |
bt [format_flags],0 |
jnc relative_ok |
mov ebx,[current_section] |
mov ebx,[ebx+8] |
sub ebx,edi |
sub eax,ebx |
add eax,4 |
relative_ok: |
push eax |
mov al,20 |
test [format_flags],8 |
jnz relative_coff_64bit_relocation |
cmp [labels_type],2 |
jne invalid_use_of_symbol |
jmp coff_relocation |
relative_coff_64bit_relocation: |
mov al,4 |
cmp [labels_type],4 |
jne invalid_use_of_symbol |
coff_relocation: |
mov ebx,[free_additional_memory] |
add ebx,0Ch |
cmp ebx,[structures_buffer] |
jae out_of_memory |
mov [free_additional_memory],ebx |
mov byte [ebx-0Ch],al |
mov eax,[current_section] |
mov eax,[eax+8] |
neg eax |
add eax,edi |
mov [ebx-0Ch+4],eax |
mov eax,[symbol_identifier] |
mov [ebx-0Ch+8],eax |
pop eax ebx |
ret |
close_coff: |
call close_coff_section |
cmp [next_pass_needed],0 |
je coff_closed |
mov eax,[symbols_stream] |
mov [free_additional_memory],eax |
coff_closed: |
ret |
coff_formatter: |
sub edi,[code_start] |
mov [code_size],edi |
call prepare_default_section |
mov edi,[free_additional_memory] |
mov ebx,edi |
mov ecx,28h shr 2 |
imul ecx,[number_of_sections] |
add ecx,14h shr 2 |
lea eax,[edi+ecx*4] |
cmp eax,[structures_buffer] |
jae out_of_memory |
xor eax,eax |
rep stos dword [edi] |
mov word [ebx],14Ch |
test [format_flags],8 |
jz coff_magic_ok |
mov word [ebx],8664h |
coff_magic_ok: |
mov word [ebx+12h],104h |
bt [format_flags],0 |
jnc coff_flags_ok |
or byte [ebx+12h],80h |
coff_flags_ok: |
push ebx |
call make_timestamp |
pop ebx |
mov [ebx+4],eax |
mov eax,[number_of_sections] |
mov [ebx+2],ax |
mov esi,[symbols_stream] |
xor eax,eax |
xor ecx,ecx |
enumerate_symbols: |
cmp esi,[free_additional_memory] |
je symbols_enumerated |
mov dl,[esi] |
or dl,dl |
jz enumerate_section |
cmp dl,80h |
je enumerate_public |
ja enumerate_extrn |
add esi,0Ch |
jmp enumerate_symbols |
enumerate_section: |
mov edx,eax |
shl edx,8 |
mov [esi],edx |
inc eax |
inc ecx |
mov [esi+1Eh],cx |
add esi,20h |
jmp enumerate_symbols |
enumerate_public: |
mov edx,eax |
shl edx,8 |
mov dl,80h |
mov [esi],edx |
mov edx,[esi+8] |
add esi,10h |
inc eax |
cmp byte [edx+11],2 |
jne enumerate_symbols |
mov edx,[edx+20] |
cmp byte [edx],81h |
jne enumerate_symbols |
inc eax |
jmp enumerate_symbols |
enumerate_extrn: |
mov edx,eax |
shl edx,8 |
mov dl,81h |
mov [esi],edx |
add esi,0Ch |
inc eax |
jmp enumerate_symbols |
prepare_default_section: |
mov ebx,[symbols_stream] |
cmp dword [ebx+0Ch],0 |
jne default_section_ok |
cmp [number_of_sections],0 |
je default_section_ok |
mov edx,ebx |
find_references_to_default_section: |
cmp ebx,[free_additional_memory] |
jne check_reference |
add [symbols_stream],20h |
ret |
check_reference: |
mov al,[ebx] |
or al,al |
jz skip_other_section |
cmp al,80h |
je check_public_reference |
ja next_reference |
cmp edx,[ebx+8] |
je default_section_ok |
next_reference: |
add ebx,0Ch |
jmp find_references_to_default_section |
check_public_reference: |
mov eax,[ebx+8] |
add ebx,10h |
test byte [eax+8],1 |
jz find_references_to_default_section |
mov cx,[current_pass] |
cmp cx,[eax+16] |
jne find_references_to_default_section |
cmp edx,[eax+20] |
je default_section_ok |
jmp find_references_to_default_section |
skip_other_section: |
add ebx,20h |
jmp find_references_to_default_section |
default_section_ok: |
inc [number_of_sections] |
ret |
symbols_enumerated: |
mov [ebx+0Ch],eax |
mov ebp,edi |
sub ebp,ebx |
push ebp |
lea edi,[ebx+14h] |
mov esi,[symbols_stream] |
find_section: |
cmp esi,[free_additional_memory] |
je sections_finished |
mov al,[esi] |
or al,al |
jz section_found |
add esi,0Ch |
cmp al,80h |
jne find_section |
add esi,4 |
jmp find_section |
section_found: |
push esi edi |
mov esi,[esi+4] |
or esi,esi |
jz default_section |
mov ecx,[esi] |
add esi,4 |
rep movs byte [edi],[esi] |
jmp section_name_ok |
default_section: |
mov al,'.' |
stos byte [edi] |
mov eax,'flat' |
stos dword [edi] |
section_name_ok: |
pop edi esi |
mov eax,[esi+0Ch] |
mov [edi+10h],eax |
mov eax,[esi+14h] |
mov [edi+24h],eax |
test al,80h |
jnz section_ptr_ok |
mov eax,[esi+8] |
sub eax,[code_start] |
add eax,ebp |
mov [edi+14h],eax |
section_ptr_ok: |
mov ebx,[code_start] |
mov edx,[code_size] |
add ebx,edx |
add edx,ebp |
xor ecx,ecx |
add esi,20h |
find_relocations: |
cmp esi,[free_additional_memory] |
je section_relocations_done |
mov al,[esi] |
or al,al |
jz section_relocations_done |
cmp al,80h |
jb add_relocation |
ja next_relocation |
add esi,10h |
jmp find_relocations |
add_relocation: |
lea eax,[ebx+0Ah] |
cmp eax,[display_buffer] |
ja out_of_memory |
mov eax,[esi+4] |
mov [ebx],eax |
mov eax,[esi+8] |
mov eax,[eax] |
shr eax,8 |
mov [ebx+4],eax |
movzx ax,byte [esi] |
mov [ebx+8],ax |
add ebx,0Ah |
inc ecx |
next_relocation: |
add esi,0Ch |
jmp find_relocations |
section_relocations_done: |
cmp ecx,10000h |
jb section_relocations_count_16bit |
bt [format_flags],0 |
jnc format_limitations_exceeded |
mov word [edi+20h],0FFFFh |
or dword [edi+24h],1000000h |
mov [edi+18h],edx |
push esi edi |
push ecx |
lea esi,[ebx-1] |
add ebx,0Ah |
lea edi,[ebx-1] |
imul ecx,0Ah |
std |
rep movs byte [edi],[esi] |
cld |
pop ecx |
inc esi |
inc ecx |
mov [esi],ecx |
xor eax,eax |
mov [esi+4],eax |
mov [esi+8],ax |
pop edi esi |
jmp section_relocations_ok |
section_relocations_count_16bit: |
mov [edi+20h],cx |
jcxz section_relocations_ok |
mov [edi+18h],edx |
section_relocations_ok: |
sub ebx,[code_start] |
mov [code_size],ebx |
add edi,28h |
jmp find_section |
sections_finished: |
mov edx,[free_additional_memory] |
mov ebx,[code_size] |
add ebp,ebx |
mov [edx+8],ebp |
add ebx,[code_start] |
mov edi,ebx |
mov ecx,[edx+0Ch] |
imul ecx,12h shr 1 |
xor eax,eax |
shr ecx,1 |
jnc zero_symbols_table |
stos word [edi] |
zero_symbols_table: |
rep stos dword [edi] |
mov edx,edi |
stos dword [edi] |
mov esi,[symbols_stream] |
make_symbols_table: |
cmp esi,[free_additional_memory] |
je symbols_table_ok |
mov al,[esi] |
cmp al,80h |
je add_public_symbol |
ja add_extrn_symbol |
or al,al |
jz add_section_symbol |
add esi,0Ch |
jmp make_symbols_table |
add_section_symbol: |
call store_symbol_name |
movzx eax,word [esi+1Eh] |
mov [ebx+0Ch],ax |
mov byte [ebx+10h],3 |
add esi,20h |
add ebx,12h |
jmp make_symbols_table |
add_extrn_symbol: |
call store_symbol_name |
mov byte [ebx+10h],2 |
add esi,0Ch |
add ebx,12h |
jmp make_symbols_table |
add_public_symbol: |
call store_symbol_name |
mov eax,[esi+0Ch] |
mov [current_line],eax |
mov eax,[esi+8] |
test byte [eax+8],1 |
jz undefined_symbol |
mov cx,[current_pass] |
cmp cx,[eax+16] |
jne undefined_symbol |
mov cl,[eax+11] |
or cl,cl |
jz public_constant |
test [format_flags],8 |
jnz check_64bit_public_symbol |
cmp cl,2 |
je public_symbol_type_ok |
jmp invalid_use_of_symbol |
check_64bit_public_symbol: |
cmp cl,4 |
jne invalid_use_of_symbol |
public_symbol_type_ok: |
mov ecx,[eax+20] |
cmp byte [ecx],81h |
je alias_symbol |
cmp byte [ecx],0 |
jne invalid_use_of_symbol |
mov cx,[ecx+1Eh] |
mov [ebx+0Ch],cx |
public_symbol_section_ok: |
cmp dword [eax+4],0 |
je store_public_symbol |
cmp dword [eax+4],-1 |
jne value_out_of_range |
bt dword [eax],31 |
jnc value_out_of_range |
store_public_symbol: |
mov eax,[eax] |
mov [ebx+8],eax |
mov byte [ebx+10h],2 |
add esi,10h |
add ebx,12h |
jmp make_symbols_table |
alias_symbol: |
bt [format_flags],0 |
jnc invalid_use_of_symbol |
mov ecx,[eax] |
or ecx,[eax+4] |
jnz invalid_use_of_symbol |
mov byte [ebx+10h],69h |
mov byte [ebx+11h],1 |
add ebx,12h |
mov ecx,[eax+20] |
mov ecx,[ecx] |
shr ecx,8 |
mov [ebx],ecx |
mov byte [ebx+4],3 |
add esi,10h |
add ebx,12h |
jmp make_symbols_table |
public_constant: |
mov word [ebx+0Ch],0FFFFh |
jmp public_symbol_section_ok |
symbols_table_ok: |
mov eax,edi |
sub eax,edx |
mov [edx],eax |
sub edi,[code_start] |
mov [code_size],edi |
mov [written_size],0 |
mov edx,[output_file] |
call create |
jc write_failed |
mov edx,[free_additional_memory] |
pop ecx |
add [written_size],ecx |
call write |
jc write_failed |
jmp write_output |
store_symbol_name: |
push esi |
mov esi,[esi+4] |
or esi,esi |
jz default_name |
lods dword [esi] |
mov ecx,eax |
cmp ecx,8 |
ja add_string |
push edi |
mov edi,ebx |
rep movs byte [edi],[esi] |
pop edi esi |
ret |
default_name: |
mov dword [ebx],'.fla' |
mov dword [ebx+4],'t' |
pop esi |
ret |
add_string: |
mov eax,edi |
sub eax,edx |
mov [ebx+4],eax |
inc ecx |
rep movs byte [edi],[esi] |
pop esi |
ret |
format_elf: |
test [format_flags],8 |
jnz format_elf64 |
mov edx,edi |
mov ecx,34h shr 2 |
lea eax,[edi+ecx*4] |
cmp eax,[display_buffer] |
jae out_of_memory |
xor eax,eax |
rep stos dword [edi] |
mov dword [edx],7Fh + 'ELF' shl 8 |
mov al,1 |
mov [edx+4],al |
mov [edx+5],al |
mov [edx+6],al |
mov [edx+14h],al |
mov byte [edx+12h],3 |
mov byte [edx+28h],34h |
mov byte [edx+2Eh],28h |
mov [code_type],32 |
cmp word [esi],1D19h |
je format_elf_exe |
mov [labels_type],2 |
elf_header_ok: |
mov byte [edx+10h],1 |
mov eax,[additional_memory] |
mov [symbols_stream],eax |
mov ebx,eax |
add eax,20h |
cmp eax,[structures_buffer] |
jae out_of_memory |
mov [free_additional_memory],eax |
xor eax,eax |
mov [current_section],ebx |
mov [number_of_sections],eax |
mov dword [org_origin],edi |
mov dword [org_origin+4],eax |
mov [org_registers],eax |
mov [org_start],edi |
mov [org_symbol],ebx |
mov [ebx],al |
mov [ebx+4],eax |
mov [ebx+8],edi |
mov al,111b |
mov [ebx+14h],eax |
mov al,4 |
mov [ebx+10h],eax |
test [format_flags],8 |
jz instruction_assembled |
mov byte [ebx+10h],8 |
jmp instruction_assembled |
format_elf64: |
mov edx,edi |
mov ecx,40h shr 2 |
lea eax,[edi+ecx*4] |
cmp eax,[display_buffer] |
jae out_of_memory |
xor eax,eax |
rep stos dword [edi] |
mov dword [edx],7Fh + 'ELF' shl 8 |
mov al,1 |
mov [edx+5],al |
mov [edx+6],al |
mov [edx+14h],al |
mov byte [edx+4],2 |
mov byte [edx+12h],62 |
mov byte [edx+34h],40h |
mov byte [edx+3Ah],40h |
mov [code_type],64 |
cmp word [esi],1D19h |
je format_elf64_exe |
mov [labels_type],4 |
jmp elf_header_ok |
elf_section: |
bt [format_flags],0 |
jc illegal_instruction |
call close_coff_section |
mov ebx,[free_additional_memory] |
lea eax,[ebx+20h] |
cmp eax,[structures_buffer] |
jae out_of_memory |
mov [free_additional_memory],eax |
mov [current_section],ebx |
inc word [number_of_sections] |
jz format_limitations_exceeded |
xor eax,eax |
mov [ebx],al |
mov [ebx+8],edi |
mov dword [org_origin],edi |
mov dword [org_origin+4],0 |
mov [org_registers],0 |
mov [org_start],edi |
mov [org_symbol],ebx |
test [format_flags],8 |
jnz elf64_labels_type |
mov [labels_type],2 |
jmp elf_labels_type_ok |
elf64_labels_type: |
mov [labels_type],4 |
elf_labels_type_ok: |
mov [ebx+10h],eax |
mov al,10b |
mov [ebx+14h],eax |
lods word [esi] |
cmp ax,'(' |
jne invalid_argument |
mov [ebx+4],esi |
mov ecx,[esi] |
lea esi,[esi+4+ecx+1] |
elf_section_flags: |
cmp byte [esi],1Ch |
je elf_section_alignment |
cmp byte [esi],19h |
jne elf_section_settings_ok |
inc esi |
lods byte [esi] |
sub al,28 |
xor al,11b |
test al,not 10b |
jnz invalid_argument |
mov cl,al |
mov al,1 |
shl al,cl |
test byte [ebx+14h],al |
jnz setting_already_specified |
or byte [ebx+14h],al |
jmp elf_section_flags |
elf_section_alignment: |
inc esi |
lods byte [esi] |
or al,al |
jnz invalid_argument |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
push ebx |
call get_dword_value |
pop ebx |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov edx,eax |
dec edx |
test eax,edx |
jnz invalid_value |
or eax,eax |
jz invalid_value |
xchg [ebx+10h],eax |
or eax,eax |
jnz setting_already_specified |
jmp elf_section_flags |
elf_section_settings_ok: |
cmp dword [ebx+10h],0 |
jne instruction_assembled |
mov dword [ebx+10h],4 |
test [format_flags],8 |
jz instruction_assembled |
mov byte [ebx+10h],8 |
jmp instruction_assembled |
mark_elf_relocation: |
cmp [value_type],3 |
je elf_relocation_relative |
push ebx eax |
cmp [value_type],3 |
je elf_gotoff_relocation |
mov al,1 |
test [format_flags],8 |
jz coff_relocation |
cmp [value_type],4 |
je coff_relocation |
mov al,11 |
jmp coff_relocation |
elf_gotoff_relocation: |
mov al,9 |
jmp coff_relocation |
elf_relocation_relative: |
cmp [labels_type],0 |
je invalid_use_of_symbol |
push ebx |
mov ebx,[current_section] |
mov ebx,[ebx+8] |
sub ebx,edi |
sub eax,ebx |
push eax |
mov al,2 |
jmp coff_relocation |
close_elf: |
bt [format_flags],0 |
jc close_elf_exe |
call close_coff_section |
cmp [next_pass_needed],0 |
je elf_closed |
mov eax,[symbols_stream] |
mov [free_additional_memory],eax |
elf_closed: |
ret |
elf_formatter: |
push edi |
call prepare_default_section |
mov esi,[symbols_stream] |
mov edi,[free_additional_memory] |
xor eax,eax |
mov ecx,4 |
rep stos dword [edi] |
test [format_flags],8 |
jz find_first_section |
mov ecx,2 |
rep stos dword [edi] |
find_first_section: |
mov al,[esi] |
or al,al |
jz first_section_found |
cmp al,80h |
jne skip_other_symbol |
add esi,4 |
skip_other_symbol: |
add esi,0Ch |
jmp find_first_section |
first_section_found: |
mov ebx,esi |
mov ebp,esi |
add esi,20h |
xor ecx,ecx |
xor edx,edx |
find_next_section: |
cmp esi,[free_additional_memory] |
je make_section_symbol |
mov al,[esi] |
or al,al |
jz make_section_symbol |
cmp al,80h |
je skip_public |
ja skip_extrn |
or byte [ebx+14h],40h |
skip_extrn: |
add esi,0Ch |
jmp find_next_section |
skip_public: |
add esi,10h |
jmp find_next_section |
make_section_symbol: |
mov eax,edi |
xchg eax,[ebx+4] |
stos dword [edi] |
test [format_flags],8 |
jnz elf64_section_symbol |
xor eax,eax |
stos dword [edi] |
stos dword [edi] |
call store_section_index |
jmp section_symbol_ok |
store_section_index: |
inc ecx |
mov eax,ecx |
shl eax,8 |
mov [ebx],eax |
inc dx |
jz format_limitations_exceeded |
mov eax,edx |
shl eax,16 |
mov al,3 |
test byte [ebx+14h],40h |
jz section_index_ok |
or ah,-1 |
inc dx |
jz format_limitations_exceeded |
section_index_ok: |
stos dword [edi] |
ret |
elf64_section_symbol: |
call store_section_index |
xor eax,eax |
stos dword [edi] |
stos dword [edi] |
stos dword [edi] |
stos dword [edi] |
section_symbol_ok: |
mov ebx,esi |
add esi,20h |
cmp ebx,[free_additional_memory] |
jne find_next_section |
inc dx |
jz format_limitations_exceeded |
mov [current_section],edx |
mov esi,[symbols_stream] |
find_other_symbols: |
cmp esi,[free_additional_memory] |
je elf_symbol_table_ok |
mov al,[esi] |
or al,al |
jz skip_section |
cmp al,80h |
je make_public_symbol |
ja make_extrn_symbol |
add esi,0Ch |
jmp find_other_symbols |
skip_section: |
add esi,20h |
jmp find_other_symbols |
make_public_symbol: |
mov eax,[esi+0Ch] |
mov [current_line],eax |
mov ebx,[esi+8] |
test byte [ebx+8],1 |
jz undefined_symbol |
mov ax,[current_pass] |
cmp ax,[ebx+16] |
jne undefined_symbol |
mov dl,[ebx+11] |
or dl,dl |
jz public_absolute |
mov eax,[ebx+20] |
cmp byte [eax],0 |
jne invalid_use_of_symbol |
mov eax,[eax+4] |
test [format_flags],8 |
jnz elf64_public |
cmp dl,2 |
jne invalid_use_of_symbol |
mov dx,[eax+0Eh] |
jmp section_for_public_ok |
elf64_public: |
cmp dl,4 |
jne invalid_use_of_symbol |
mov dx,[eax+6] |
jmp section_for_public_ok |
public_absolute: |
mov dx,0FFF1h |
section_for_public_ok: |
mov eax,[esi+4] |
stos dword [edi] |
test [format_flags],8 |
jnz elf64_public_symbol |
call get_public_value |
stos dword [edi] |
xor eax,eax |
mov al,[ebx+10] |
stos dword [edi] |
mov eax,edx |
shl eax,16 |
mov al,10h |
cmp byte [ebx+10],0 |
je elf_public_function |
or al,1 |
jmp store_elf_public_info |
elf_public_function: |
or al,2 |
store_elf_public_info: |
stos dword [edi] |
jmp public_symbol_ok |
elf64_public_symbol: |
mov eax,edx |
shl eax,16 |
mov al,10h |
cmp byte [ebx+10],0 |
je elf64_public_function |
or al,1 |
jmp store_elf64_public_info |
elf64_public_function: |
or al,2 |
store_elf64_public_info: |
stos dword [edi] |
call get_public_value |
stos dword [edi] |
xor eax,eax |
stos dword [edi] |
mov al,[ebx+10] |
stos dword [edi] |
xor al,al |
stos dword [edi] |
public_symbol_ok: |
inc ecx |
mov eax,ecx |
shl eax,8 |
mov al,80h |
mov [esi],eax |
add esi,10h |
jmp find_other_symbols |
get_public_value: |
mov eax,[ebx] |
cmp dword [ebx+4],0 |
je public_value_ok |
cmp dword [ebx+4],-1 |
jne value_out_of_range |
bt eax,31 |
jnc value_out_of_range |
public_value_ok: |
ret |
make_extrn_symbol: |
mov eax,[esi+4] |
stos dword [edi] |
test [format_flags],8 |
jnz elf64_extrn_symbol |
xor eax,eax |
stos dword [edi] |
mov eax,[esi+8] |
stos dword [edi] |
mov eax,10h |
stos dword [edi] |
jmp extrn_symbol_ok |
elf64_extrn_symbol: |
mov eax,10h |
stos dword [edi] |
xor al,al |
stos dword [edi] |
stos dword [edi] |
mov eax,[esi+8] |
stos dword [edi] |
xor eax,eax |
stos dword [edi] |
extrn_symbol_ok: |
inc ecx |
mov eax,ecx |
shl eax,8 |
mov al,81h |
mov [esi],eax |
add esi,0Ch |
jmp find_other_symbols |
elf_symbol_table_ok: |
mov edx,edi |
mov ebx,[free_additional_memory] |
xor al,al |
stos byte [edi] |
add edi,16 |
mov [edx+1],edx |
add ebx,10h |
test [format_flags],8 |
jz make_string_table |
add ebx,8 |
make_string_table: |
cmp ebx,edx |
je elf_string_table_ok |
test [format_flags],8 |
jnz make_elf64_string |
cmp byte [ebx+0Dh],0 |
je rel_prefix_ok |
mov byte [ebx+0Dh],0 |
mov eax,'.rel' |
stos dword [edi] |
rel_prefix_ok: |
mov esi,edi |
sub esi,edx |
xchg esi,[ebx] |
add ebx,10h |
make_elf_string: |
or esi,esi |
jz default_string |
lods dword [esi] |
mov ecx,eax |
rep movs byte [edi],[esi] |
xor al,al |
stos byte [edi] |
jmp make_string_table |
make_elf64_string: |
cmp byte [ebx+5],0 |
je elf64_rel_prefix_ok |
mov byte [ebx+5],0 |
mov eax,'.rel' |
stos dword [edi] |
mov al,'a' |
stos byte [edi] |
elf64_rel_prefix_ok: |
mov esi,edi |
sub esi,edx |
xchg esi,[ebx] |
add ebx,18h |
jmp make_elf_string |
default_string: |
mov eax,'.fla' |
stos dword [edi] |
mov ax,'t' |
stos word [edi] |
jmp make_string_table |
elf_string_table_ok: |
mov [edx+1+8],edi |
mov ebx,[code_start] |
mov eax,edi |
sub eax,[free_additional_memory] |
test [format_flags],8 |
jnz finish_elf64_header |
mov [ebx+20h],eax |
mov eax,[current_section] |
inc ax |
jz format_limitations_exceeded |
mov [ebx+32h],ax |
inc ax |
jz format_limitations_exceeded |
mov [ebx+30h],ax |
jmp elf_header_finished |
finish_elf64_header: |
mov [ebx+28h],eax |
mov eax,[current_section] |
inc ax |
jz format_limitations_exceeded |
mov [ebx+3Eh],ax |
inc ax |
jz format_limitations_exceeded |
mov [ebx+3Ch],ax |
elf_header_finished: |
xor eax,eax |
mov ecx,10 |
rep stos dword [edi] |
test [format_flags],8 |
jz elf_null_section_ok |
mov ecx,6 |
rep stos dword [edi] |
elf_null_section_ok: |
mov esi,ebp |
xor ecx,ecx |
make_section_entry: |
mov ebx,edi |
mov eax,[esi+4] |
mov eax,[eax] |
stos dword [edi] |
mov eax,1 |
cmp dword [esi+0Ch],0 |
je bss_section |
test byte [esi+14h],80h |
jz section_type_ok |
bss_section: |
mov al,8 |
section_type_ok: |
stos dword [edi] |
mov eax,[esi+14h] |
and al,3Fh |
call store_elf_machine_word |
xor eax,eax |
call store_elf_machine_word |
mov eax,[esi+8] |
mov [image_base],eax |
sub eax,[code_start] |
call store_elf_machine_word |
mov eax,[esi+0Ch] |
call store_elf_machine_word |
xor eax,eax |
stos dword [edi] |
stos dword [edi] |
mov eax,[esi+10h] |
call store_elf_machine_word |
xor eax,eax |
call store_elf_machine_word |
inc ecx |
add esi,20h |
xchg edi,[esp] |
mov ebp,edi |
convert_relocations: |
cmp esi,[free_additional_memory] |
je relocations_converted |
mov al,[esi] |
or al,al |
jz relocations_converted |
cmp al,80h |
jb make_relocation_entry |
ja relocation_entry_ok |
add esi,10h |
jmp convert_relocations |
make_relocation_entry: |
test [format_flags],8 |
jnz make_elf64_relocation_entry |
mov eax,[esi+4] |
stos dword [edi] |
mov eax,[esi+8] |
mov eax,[eax] |
mov al,[esi] |
stos dword [edi] |
jmp relocation_entry_ok |
make_elf64_relocation_entry: |
mov eax,[esi+4] |
stos dword [edi] |
xor eax,eax |
stos dword [edi] |
movzx eax,byte [esi] |
stos dword [edi] |
mov eax,[esi+8] |
mov eax,[eax] |
shr eax,8 |
stos dword [edi] |
xor eax,eax |
stos dword [edi] |
stos dword [edi] |
relocation_entry_ok: |
add esi,0Ch |
jmp convert_relocations |
store_elf_machine_word: |
stos dword [edi] |
test [format_flags],8 |
jz elf_machine_word_ok |
mov dword [edi],0 |
add edi,4 |
elf_machine_word_ok: |
ret |
relocations_converted: |
cmp edi,ebp |
xchg edi,[esp] |
je rel_section_ok |
mov eax,[ebx] |
sub eax,4 |
test [format_flags],8 |
jz store_relocations_name_offset |
dec eax |
store_relocations_name_offset: |
stos dword [edi] |
test [format_flags],8 |
jnz rela_section |
mov eax,9 |
jmp store_relocations_type |
rela_section: |
mov eax,4 |
store_relocations_type: |
stos dword [edi] |
xor al,al |
call store_elf_machine_word |
call store_elf_machine_word |
mov eax,ebp |
sub eax,[code_start] |
call store_elf_machine_word |
mov eax,[esp] |
sub eax,ebp |
call store_elf_machine_word |
mov eax,[current_section] |
stos dword [edi] |
mov eax,ecx |
stos dword [edi] |
inc ecx |
test [format_flags],8 |
jnz finish_elf64_rela_section |
mov eax,4 |
stos dword [edi] |
mov al,8 |
stos dword [edi] |
jmp rel_section_ok |
finish_elf64_rela_section: |
mov eax,8 |
stos dword [edi] |
xor al,al |
stos dword [edi] |
mov al,24 |
stos dword [edi] |
xor al,al |
stos dword [edi] |
rel_section_ok: |
cmp esi,[free_additional_memory] |
jne make_section_entry |
pop eax |
mov ebx,[code_start] |
sub eax,ebx |
mov [code_size],eax |
mov ecx,20h |
test [format_flags],8 |
jz adjust_elf_section_headers_offset |
mov ecx,28h |
adjust_elf_section_headers_offset: |
add [ebx+ecx],eax |
mov eax,1 |
stos dword [edi] |
mov al,2 |
stos dword [edi] |
xor al,al |
call store_elf_machine_word |
call store_elf_machine_word |
mov eax,[code_size] |
call store_elf_machine_word |
mov eax,[edx+1] |
sub eax,[free_additional_memory] |
call store_elf_machine_word |
mov eax,[current_section] |
inc eax |
stos dword [edi] |
mov eax,[number_of_sections] |
inc eax |
stos dword [edi] |
test [format_flags],8 |
jnz finish_elf64_sym_section |
mov eax,4 |
stos dword [edi] |
mov al,10h |
stos dword [edi] |
jmp sym_section_ok |
finish_elf64_sym_section: |
mov eax,8 |
stos dword [edi] |
xor al,al |
stos dword [edi] |
mov al,18h |
stos dword [edi] |
xor al,al |
stos dword [edi] |
sym_section_ok: |
mov al,1+8 |
stos dword [edi] |
mov al,3 |
stos dword [edi] |
xor al,al |
call store_elf_machine_word |
call store_elf_machine_word |
mov eax,[edx+1] |
sub eax,[free_additional_memory] |
add eax,[code_size] |
call store_elf_machine_word |
mov eax,[edx+1+8] |
sub eax,[edx+1] |
call store_elf_machine_word |
xor eax,eax |
stos dword [edi] |
stos dword [edi] |
mov al,1 |
call store_elf_machine_word |
xor eax,eax |
call store_elf_machine_word |
mov eax,'tab' |
mov dword [edx+1],'.sym' |
mov [edx+1+4],eax |
mov dword [edx+1+8],'.str' |
mov [edx+1+8+4],eax |
mov [written_size],0 |
mov edx,[output_file] |
call create |
jc write_failed |
call write_code |
mov ecx,edi |
mov edx,[free_additional_memory] |
sub ecx,edx |
add [written_size],ecx |
call write |
jc write_failed |
jmp output_written |
format_elf_exe: |
add esi,2 |
or [format_flags],1 |
mov [image_base],8048000h |
cmp byte [esi],80h |
jne elf_exe_base_ok |
lods word [esi] |
cmp ah,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
push edx |
call get_dword_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov [image_base],eax |
pop edx |
elf_exe_base_ok: |
mov byte [edx+10h],2 |
mov byte [edx+2Ah],20h |
mov ebx,edi |
mov ecx,20h shr 2 |
cmp [current_pass],0 |
je init_elf_segments |
imul ecx,[number_of_sections] |
init_elf_segments: |
xor eax,eax |
rep stos dword [edi] |
mov [number_of_sections],0 |
mov byte [ebx],1 |
mov word [ebx+1Ch],1000h |
mov byte [ebx+18h],111b |
mov eax,edi |
sub eax,[code_start] |
mov [ebx+4],eax |
add eax,[image_base] |
mov [ebx+8],eax |
mov [ebx+0Ch],eax |
mov [edx+18h],eax |
xor edx,edx |
not eax |
not edx |
add eax,1 |
adc edx,0 |
add eax,edi |
adc edx,0 |
mov dword [org_origin],eax |
mov dword [org_origin+4],edx |
mov [org_registers],0 |
mov [org_start],edi |
mov [symbols_stream],edi |
jmp instruction_assembled |
format_elf64_exe: |
add esi,2 |
or [format_flags],1 |
mov [image_base],400000h |
mov [image_base_high],0 |
cmp byte [esi],80h |
jne elf64_exe_base_ok |
lods word [esi] |
cmp ah,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
push edx |
call get_qword_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov [image_base],eax |
mov [image_base_high],edx |
pop edx |
elf64_exe_base_ok: |
mov byte [edx+10h],2 |
mov byte [edx+36h],38h |
mov ebx,edi |
mov ecx,38h shr 2 |
cmp [current_pass],0 |
je init_elf64_segments |
imul ecx,[number_of_sections] |
init_elf64_segments: |
xor eax,eax |
rep stos dword [edi] |
mov [number_of_sections],0 |
mov byte [ebx],1 |
mov word [ebx+30h],1000h |
mov byte [ebx+4],111b |
push edx |
mov eax,edi |
sub eax,[code_start] |
mov [ebx+8],eax |
xor edx,edx |
add eax,[image_base] |
adc edx,[image_base_high] |
mov [ebx+10h],eax |
mov [ebx+10h+4],edx |
mov [ebx+18h],eax |
mov [ebx+18h+4],edx |
pop ebx |
mov [ebx+18h],eax |
mov [ebx+18h+4],edx |
not eax |
not edx |
add eax,1 |
adc edx,0 |
add eax,edi |
adc edx,0 |
mov dword [org_origin],eax |
mov dword [org_origin+4],edx |
mov [org_registers],0 |
mov [org_start],edi |
mov [symbols_stream],edi |
jmp instruction_assembled |
elf_entry: |
lods byte [esi] |
cmp al,'(' |
jne invalid_argument |
cmp byte [esi],'.' |
je invalid_value |
test [format_flags],8 |
jnz elf64_entry |
call get_dword_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov edx,[code_start] |
mov [edx+18h],eax |
jmp instruction_assembled |
elf64_entry: |
call get_qword_value |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov ebx,[code_start] |
mov [ebx+18h],eax |
mov [ebx+1Ch],edx |
jmp instruction_assembled |
elf_segment: |
bt [format_flags],0 |
jnc illegal_instruction |
test [format_flags],8 |
jnz elf64_segment |
call close_elf_segment |
push eax |
mov ebx,[number_of_sections] |
shl ebx,5 |
add ebx,[code_start] |
add ebx,34h |
cmp ebx,[symbols_stream] |
jb new_elf_segment |
mov ebx,[symbols_stream] |
sub ebx,20h |
push edi |
mov edi,ebx |
mov ecx,20h shr 2 |
xor eax,eax |
rep stos dword [edi] |
pop edi |
or [next_pass_needed],-1 |
new_elf_segment: |
mov byte [ebx],1 |
mov word [ebx+1Ch],1000h |
elf_segment_flags: |
cmp byte [esi],19h |
jne elf_segment_flags_ok |
lods word [esi] |
sub ah,28 |
jbe invalid_argument |
cmp ah,1 |
je mark_elf_segment_flag |
cmp ah,3 |
ja invalid_argument |
xor ah,1 |
cmp ah,2 |
je mark_elf_segment_flag |
inc ah |
mark_elf_segment_flag: |
test [ebx+18h],ah |
jnz setting_already_specified |
or [ebx+18h],ah |
jmp elf_segment_flags |
elf_segment_flags_ok: |
mov eax,edi |
sub eax,[code_start] |
mov [ebx+4],eax |
pop edx |
and eax,0FFFh |
add edx,eax |
mov [ebx+8],edx |
mov [ebx+0Ch],edx |
mov eax,edx |
xor edx,edx |
not eax |
not edx |
add eax,1 |
adc edx,0 |
add eax,edi |
adc edx,0 |
mov dword [org_origin],eax |
mov dword [org_origin+4],edx |
mov [org_registers],0 |
mov [org_start],edi |
inc [number_of_sections] |
jmp instruction_assembled |
close_elf_segment: |
cmp [number_of_sections],0 |
jne finish_elf_segment |
cmp edi,[symbols_stream] |
jne first_elf_segment_ok |
push edi |
mov edi,[code_start] |
add edi,34h |
mov ecx,20h shr 2 |
xor eax,eax |
rep stos dword [edi] |
pop edi |
mov eax,[image_base] |
ret |
first_elf_segment_ok: |
inc [number_of_sections] |
finish_elf_segment: |
mov ebx,[number_of_sections] |
dec ebx |
shl ebx,5 |
add ebx,[code_start] |
add ebx,34h |
mov eax,edi |
sub eax,[code_start] |
sub eax,[ebx+4] |
mov edx,edi |
cmp edi,[undefined_data_end] |
jne elf_segment_size_ok |
mov edi,[undefined_data_start] |
elf_segment_size_ok: |
mov [ebx+14h],eax |
add eax,edi |
sub eax,edx |
mov [ebx+10h],eax |
mov eax,[ebx+8] |
add eax,[ebx+14h] |
add eax,0FFFh |
and eax,not 0FFFh |
ret |
elf64_segment: |
call close_elf64_segment |
push eax edx |
mov ebx,[number_of_sections] |
imul ebx,38h |
add ebx,[code_start] |
add ebx,40h |
cmp ebx,[symbols_stream] |
jb new_elf64_segment |
mov ebx,[symbols_stream] |
sub ebx,38h |
push edi |
mov edi,ebx |
mov ecx,38h shr 2 |
xor eax,eax |
rep stos dword [edi] |
pop edi |
or [next_pass_needed],-1 |
new_elf64_segment: |
mov byte [ebx],1 |
mov word [ebx+30h],1000h |
elf64_segment_flags: |
cmp byte [esi],19h |
jne elf64_segment_flags_ok |
lods word [esi] |
sub ah,28 |
jbe invalid_argument |
cmp ah,1 |
je mark_elf64_segment_flag |
cmp ah,3 |
ja invalid_argument |
xor ah,1 |
cmp ah,2 |
je mark_elf64_segment_flag |
inc ah |
mark_elf64_segment_flag: |
test [ebx+4],ah |
jnz setting_already_specified |
or [ebx+4],ah |
jmp elf64_segment_flags |
elf64_segment_flags_ok: |
mov ecx,edi |
sub ecx,[code_start] |
mov [ebx+8],ecx |
pop edx eax |
and ecx,0FFFh |
add eax,ecx |
adc edx,0 |
mov [ebx+10h],eax |
mov [ebx+10h+4],edx |
mov [ebx+18h],eax |
mov [ebx+18h+4],edx |
not eax |
not edx |
add eax,1 |
adc edx,0 |
add eax,edi |
adc edx,0 |
mov dword [org_origin],eax |
mov dword [org_origin+4],edx |
mov [org_registers],0 |
mov [org_start],edi |
inc [number_of_sections] |
jmp instruction_assembled |
close_elf64_segment: |
cmp [number_of_sections],0 |
jne finish_elf64_segment |
cmp edi,[symbols_stream] |
jne first_elf64_segment_ok |
push edi |
mov edi,[code_start] |
add edi,40h |
mov ecx,38h shr 2 |
xor eax,eax |
rep stos dword [edi] |
pop edi |
mov eax,[image_base] |
mov edx,[image_base_high] |
ret |
first_elf64_segment_ok: |
inc [number_of_sections] |
finish_elf64_segment: |
mov ebx,[number_of_sections] |
dec ebx |
imul ebx,38h |
add ebx,[code_start] |
add ebx,40h |
mov eax,edi |
sub eax,[code_start] |
sub eax,[ebx+8] |
mov edx,edi |
cmp edi,[undefined_data_end] |
jne elf64_segment_size_ok |
mov edi,[undefined_data_start] |
elf64_segment_size_ok: |
mov [ebx+28h],eax |
add eax,edi |
sub eax,edx |
mov [ebx+20h],eax |
mov eax,[ebx+10h] |
mov edx,[ebx+10h+4] |
add eax,[ebx+28h] |
adc edx,0 |
sub eax,1 |
sbb edx,0 |
shrd eax,edx,12 |
shr edx,12 |
add eax,1 |
adc edx,0 |
shld edx,eax,12 |
shl eax,12 |
ret |
close_elf_exe: |
test [format_flags],8 |
jnz close_elf64_exe |
call close_elf_segment |
mov edx,[code_start] |
mov eax,[number_of_sections] |
mov byte [edx+1Ch],34h |
mov [edx+2Ch],ax |
shl eax,5 |
add eax,edx |
add eax,34h |
cmp eax,[symbols_stream] |
je elf_exe_ok |
or [next_pass_needed],-1 |
elf_exe_ok: |
ret |
close_elf64_exe: |
call close_elf64_segment |
mov edx,[code_start] |
mov eax,[number_of_sections] |
mov byte [edx+20h],40h |
mov [edx+38h],ax |
imul eax,38h |
add eax,edx |
add eax,40h |
cmp eax,[symbols_stream] |
je elf64_exe_ok |
or [next_pass_needed],-1 |
elf64_exe_ok: |
ret |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/fasm/trunk/parser.inc |
---|
0,0 → 1,1349 |
; flat assembler core |
; Copyright (c) 1999-2006, Tomasz Grysztar. |
; All rights reserved. |
parser: |
mov eax,[memory_end] |
mov [labels_list],eax |
mov eax,[additional_memory] |
mov [free_additional_memory],eax |
xor eax,eax |
mov [current_locals_prefix],eax |
mov [anonymous_reverse],eax |
mov [anonymous_forward],eax |
mov [hash_tree],eax |
mov [blocks_stack],eax |
mov esi,[memory_start] |
mov edi,[source_start] |
parser_loop: |
mov [current_line],esi |
lea eax,[edi+100h] |
cmp eax,[labels_list] |
jae out_of_memory |
cmp byte [esi+16],0 |
je empty_line |
mov al,0Fh |
stos byte [edi] |
mov eax,esi |
stos dword [edi] |
add esi,16 |
parse_line: |
cmp byte [esi],1Ah |
jne empty_instruction |
push edi |
add esi,2 |
movzx ecx,byte [esi-1] |
cmp byte [esi+ecx],':' |
je simple_label |
cmp byte [esi+ecx],'=' |
je constant_label |
call get_instruction |
jnc main_instruction_identified |
cmp byte [esi+ecx],1Ah |
jne no_data_label |
push esi ecx |
lea esi,[esi+ecx+2] |
movzx ecx,byte [esi-1] |
call get_data_directive |
jnc data_label |
pop ecx esi |
no_data_label: |
call get_data_directive |
jnc main_instruction_identified |
pop edi |
sub esi,2 |
xor bx,bx |
call parse_line_contents |
jmp parse_next_line |
simple_label: |
pop edi |
call identify_label |
mov byte [edi],2 |
inc edi |
stos dword [edi] |
inc esi |
xor al,al |
stos byte [edi] |
jmp parse_line |
constant_label: |
pop edi |
call get_label_id |
mov byte [edi],3 |
inc edi |
stos dword [edi] |
xor al,al |
stos byte [edi] |
inc esi |
xor bx,bx |
call parse_line_contents |
jmp parse_next_line |
data_label: |
pop ecx edx |
pop edi |
push eax ebx esi |
mov esi,edx |
movzx ecx,byte [esi-1] |
call identify_label |
mov byte [edi],2 |
inc edi |
stos dword [edi] |
pop esi ebx eax |
stos byte [edi] |
push edi |
main_instruction_identified: |
pop edi |
mov dl,al |
mov al,1 |
stos byte [edi] |
mov ax,bx |
stos word [edi] |
mov al,dl |
stos byte [edi] |
cmp bx,if_directive-assembler |
je parse_block |
cmp bx,repeat_directive-assembler |
je parse_block |
cmp bx,while_directive-assembler |
je parse_block |
cmp bx,end_directive-assembler |
je parse_end_directive |
cmp bx,else_directive-assembler |
je parse_else |
common_parse: |
call parse_line_contents |
jmp parse_next_line |
empty_instruction: |
lods byte [esi] |
or al,al |
jz parse_next_line |
cmp al,':' |
je invalid_name |
cmp al,3Bh |
je skip_preprocessed_symbol |
dec esi |
call parse_argument |
jmp parse_next_line |
skip_preprocessed_symbol: |
lods byte [esi] |
movzx eax,al |
add esi,eax |
skip_next: |
lods byte [esi] |
or al,al |
jz parse_next_line |
cmp al,1Ah |
je skip_preprocessed_symbol |
cmp al,3Bh |
je skip_preprocessed_symbol |
cmp al,22h |
je skip_preprocessed_string |
jmp skip_next |
skip_preprocessed_string: |
lods dword [esi] |
add esi,eax |
jmp skip_next |
empty_line: |
add esi,17 |
parse_next_line: |
cmp esi,[source_start] |
jb parser_loop |
source_parsed: |
cmp [blocks_stack],0 |
je blocks_stack_ok |
pop eax |
pop [current_line] |
jmp missing_end_directive |
blocks_stack_ok: |
xor al,al |
stos byte [edi] |
mov eax,[error_line] |
mov [current_line],eax |
cmp [anonymous_forward],0 |
jne invalid_value |
add edi,0Fh |
and edi,not 0Fh |
mov [code_start],edi |
ret |
parse_block: |
mov eax,esp |
sub eax,100h |
jc stack_overflow |
cmp eax,[stack_limit] |
jb stack_overflow |
push [current_line] |
mov ax,bx |
shl eax,16 |
push eax |
inc [blocks_stack] |
cmp bx,if_directive-assembler |
je parse_if |
cmp bx,while_directive-assembler |
je parse_while |
call parse_line_contents |
jmp parse_next_line |
parse_end_directive: |
cmp byte [esi],1Ah |
jne common_parse |
push edi |
inc esi |
movzx ecx,byte [esi] |
inc esi |
call get_instruction |
pop edi |
jnc parse_end_block |
sub esi,2 |
jmp common_parse |
parse_end_block: |
mov dl,al |
mov al,1 |
stos byte [edi] |
mov ax,bx |
stos word [edi] |
mov al,dl |
stos byte [edi] |
lods byte [esi] |
or al,al |
jnz extra_characters_on_line |
cmp bx,if_directive-assembler |
je close_parsing_block |
cmp bx,repeat_directive-assembler |
je close_parsing_block |
cmp bx,while_directive-assembler |
je close_parsing_block |
jmp parse_next_line |
close_parsing_block: |
cmp [blocks_stack],0 |
je unexpected_instruction |
cmp bx,[esp+2] |
jne unexpected_instruction |
dec [blocks_stack] |
pop eax edx |
cmp bx,if_directive-assembler |
jne parse_next_line |
test al,1100b |
jz parse_next_line |
test al,10000b |
jnz parse_next_line |
sub edi,8 |
jmp parse_next_line |
parse_if: |
push edi |
call parse_line_contents |
xor al,al |
stos byte [edi] |
xchg esi,[esp] |
mov edi,esi |
call preevaluate_logical_expression |
pop esi |
cmp al,'0' |
je parse_false_condition_block |
cmp al,'1' |
je parse_true_condition_block |
or byte [esp],10000b |
jmp parse_next_line |
parse_while: |
push edi |
call parse_line_contents |
xor al,al |
stos byte [edi] |
xchg esi,[esp] |
mov edi,esi |
call preevaluate_logical_expression |
pop esi |
cmp al,'0' |
je parse_false_condition_block |
cmp al,'1' |
jne parse_next_line |
stos byte [edi] |
jmp parse_next_line |
parse_false_condition_block: |
or byte [esp],1 |
sub edi,4 |
jmp skip_parsing |
parse_true_condition_block: |
or byte [esp],100b |
sub edi,4 |
jmp parse_next_line |
parse_else: |
cmp [blocks_stack],0 |
je unexpected_instruction |
cmp word [esp+2],if_directive-assembler |
jne unexpected_instruction |
lods byte [esi] |
or al,al |
jz parse_pure_else |
cmp al,1Ah |
jne extra_characters_on_line |
push edi |
movzx ecx,byte [esi] |
inc esi |
call get_instruction |
jc extra_characters_on_line |
pop edi |
cmp bx,if_directive-assembler |
jne extra_characters_on_line |
test byte [esp],100b |
jnz skip_true_condition_else |
mov dl,al |
mov al,1 |
stos byte [edi] |
mov ax,bx |
stos word [edi] |
mov al,dl |
stos byte [edi] |
jmp parse_if |
skip_true_condition_else: |
sub edi,4 |
or byte [esp],1 |
jmp skip_parsing_contents |
parse_pure_else: |
bts dword [esp],1 |
jc unexpected_instruction |
test byte [esp],100b |
jz parse_next_line |
sub edi,4 |
or byte [esp],1 |
jmp skip_parsing |
skip_parsing: |
cmp esi,[source_start] |
jae source_parsed |
mov [current_line],esi |
add esi,16 |
skip_parsing_line: |
cmp byte [esi],1Ah |
jne skip_parsing_contents |
inc esi |
movzx ecx,byte [esi] |
inc esi |
cmp byte [esi+ecx],':' |
je skip_parsing_label |
push edi |
call get_instruction |
pop edi |
jnc skip_parsing_instruction |
add esi,ecx |
jmp skip_parsing_contents |
skip_parsing_label: |
lea esi,[esi+ecx+1] |
jmp skip_parsing_line |
skip_parsing_instruction: |
cmp bx,if_directive-assembler |
je skip_parsing_block |
cmp bx,repeat_directive-assembler |
je skip_parsing_block |
cmp bx,while_directive-assembler |
je skip_parsing_block |
cmp bx,end_directive-assembler |
je skip_parsing_end_directive |
cmp bx,else_directive-assembler |
je skip_parsing_else |
skip_parsing_contents: |
lods byte [esi] |
or al,al |
jz skip_parsing |
cmp al,1Ah |
je skip_parsing_symbol |
cmp al,3Bh |
je skip_parsing_symbol |
cmp al,22h |
je skip_parsing_string |
jmp skip_parsing_contents |
skip_parsing_symbol: |
lods byte [esi] |
movzx eax,al |
add esi,eax |
jmp skip_parsing_contents |
skip_parsing_string: |
lods dword [esi] |
add esi,eax |
jmp skip_parsing_contents |
skip_parsing_block: |
mov eax,esp |
sub eax,100h |
jc stack_overflow |
cmp eax,[stack_limit] |
jb stack_overflow |
push [current_line] |
mov ax,bx |
shl eax,16 |
push eax |
inc [blocks_stack] |
jmp skip_parsing_contents |
skip_parsing_end_directive: |
cmp byte [esi],1Ah |
jne skip_parsing_contents |
push edi |
inc esi |
movzx ecx,byte [esi] |
inc esi |
call get_instruction |
pop edi |
jnc skip_parsing_end_block |
add esi,ecx |
jmp skip_parsing_contents |
skip_parsing_end_block: |
lods byte [esi] |
or al,al |
jnz extra_characters_on_line |
cmp bx,if_directive-assembler |
je close_skip_parsing_block |
cmp bx,repeat_directive-assembler |
je close_skip_parsing_block |
cmp bx,while_directive-assembler |
je close_skip_parsing_block |
jmp skip_parsing |
close_skip_parsing_block: |
cmp [blocks_stack],0 |
je unexpected_instruction |
cmp bx,[esp+2] |
jne unexpected_instruction |
dec [blocks_stack] |
pop eax edx |
test al,1 |
jz skip_parsing |
cmp bx,if_directive-assembler |
jne parse_next_line |
test al,10000b |
jz parse_next_line |
mov al,0Fh |
stos byte [edi] |
mov eax,[current_line] |
stos dword [edi] |
mov eax,1 + (end_directive-assembler) shl 8 |
stos dword [edi] |
mov eax,1 + (if_directive-assembler) shl 8 |
stos dword [edi] |
jmp parse_next_line |
skip_parsing_else: |
cmp [blocks_stack],0 |
je unexpected_instruction |
cmp word [esp+2],if_directive-assembler |
jne unexpected_instruction |
lods byte [esi] |
or al,al |
jz skip_parsing_pure_else |
cmp al,1Ah |
jne extra_characters_on_line |
push edi |
movzx ecx,byte [esi] |
inc esi |
call get_instruction |
jc extra_characters_on_line |
pop edi |
cmp bx,if_directive-assembler |
jne extra_characters_on_line |
mov al,[esp] |
test al,1 |
jz skip_parsing_contents |
test al,100b |
jnz skip_parsing_contents |
test al,10000b |
jnz parse_else_if |
xor al,al |
mov [esp],al |
mov al,0Fh |
stos byte [edi] |
mov eax,[current_line] |
stos dword [edi] |
parse_else_if: |
mov eax,1 + (if_directive-assembler) shl 8 |
stos dword [edi] |
jmp parse_if |
skip_parsing_pure_else: |
bts dword [esp],1 |
jc unexpected_instruction |
mov al,[esp] |
test al,1 |
jz skip_parsing |
test al,100b |
jnz skip_parsing |
and al,not 1 |
or al,1000b |
mov [esp],al |
jmp parse_next_line |
parse_line_contents: |
mov [parenthesis_stack],0 |
parse_instruction_arguments: |
cmp bx,prefix_instruction-assembler |
je allow_embedded_instruction |
cmp bx,times_directive-assembler |
je parse_times_directive |
cmp bx,end_directive-assembler |
je allow_embedded_instruction |
cmp bx,label_directive-assembler |
je parse_label_directive |
cmp bx,segment_directive-assembler |
je parse_label_directive |
cmp bx,load_directive-assembler |
je parse_load_directive |
cmp bx,extrn_directive-assembler |
je parse_extrn_directive |
cmp bx,public_directive-assembler |
je parse_public_directive |
parse_argument: |
lea eax,[edi+100h] |
cmp eax,[labels_list] |
jae out_of_memory |
lods byte [esi] |
cmp al,':' |
je instruction_separator |
cmp al,',' |
je separator |
cmp al,'=' |
je separator |
cmp al,'|' |
je separator |
cmp al,'&' |
je separator |
cmp al,'~' |
je separator |
cmp al,'>' |
je greater |
cmp al,'<' |
je less |
cmp al,')' |
je close_parenthesis |
or al,al |
jz contents_parsed |
cmp al,'[' |
je address_argument |
cmp al,']' |
je separator |
cmp al,'{' |
je unallowed_character |
cmp al,'}' |
je unallowed_character |
cmp al,'#' |
je unallowed_character |
cmp al,'`' |
je unallowed_character |
dec esi |
cmp al,1Ah |
jne expression_argument |
push edi |
mov edi,directive_operators |
call get_operator |
or al,al |
jnz operator_argument |
inc esi |
movzx ecx,byte [esi] |
inc esi |
call get_symbol |
jnc symbol_argument |
cmp ecx,1 |
jne check_argument |
cmp byte [esi],'?' |
jne check_argument |
pop edi |
movs byte [edi],[esi] |
jmp argument_parsed |
symbol_argument: |
pop edi |
stos word [edi] |
jmp argument_parsed |
operator_argument: |
pop edi |
cmp al,85h |
je ptr_argument |
stos byte [edi] |
cmp al,80h |
je forced_expression |
cmp al,81h |
je forced_parenthesis |
cmp al,82h |
je parse_from_operator |
cmp al,89h |
je parse_label_operator |
jmp argument_parsed |
allow_embedded_instruction: |
cmp byte [esi],1Ah |
jne parse_argument |
push edi |
inc esi |
movzx ecx,byte [esi] |
inc esi |
call get_instruction |
jnc embedded_instruction |
call get_data_directive |
jnc embedded_instruction |
pop edi |
sub esi,2 |
jmp parse_argument |
embedded_instruction: |
pop edi |
mov dl,al |
mov al,1 |
stos byte [edi] |
mov ax,bx |
stos word [edi] |
mov al,dl |
stos byte [edi] |
jmp parse_instruction_arguments |
parse_times_directive: |
mov al,'(' |
stos byte [edi] |
call convert_expression |
mov al,')' |
stos byte [edi] |
cmp byte [esi],':' |
jne allow_embedded_instruction |
movs byte [edi],[esi] |
jmp allow_embedded_instruction |
parse_label_directive: |
cmp byte [esi],1Ah |
jne argument_parsed |
push esi |
inc esi |
movzx ecx,byte [esi] |
inc esi |
call identify_label |
pop ebx |
cmp eax,0Fh |
je non_label_identified |
mov byte [edi],2 |
inc edi |
stos dword [edi] |
xor al,al |
stos byte [edi] |
jmp argument_parsed |
non_label_identified: |
mov esi,ebx |
jmp argument_parsed |
parse_load_directive: |
cmp byte [esi],1Ah |
jne argument_parsed |
push esi |
inc esi |
movzx ecx,byte [esi] |
inc esi |
call get_label_id |
pop ebx |
cmp eax,0Fh |
je non_label_identified |
mov byte [edi],2 |
inc edi |
stos dword [edi] |
xor al,al |
stos byte [edi] |
jmp argument_parsed |
parse_public_directive: |
cmp byte [esi],1Ah |
jne parse_argument |
inc esi |
push esi |
movzx ecx,byte [esi] |
inc esi |
mov al,2 |
stos byte [edi] |
call get_label_id |
stos dword [edi] |
mov ax,8600h |
stos word [edi] |
pop ebx |
push ebx esi edi |
mov edi,directive_operators |
call get_operator |
pop edi edx ebx |
cmp al,86h |
je argument_parsed |
mov esi,edx |
xchg esi,ebx |
movzx ecx,byte [esi] |
inc esi |
mov ax,'(' |
stos word [edi] |
mov eax,ecx |
stos dword [edi] |
rep movs byte [edi],[esi] |
xor al,al |
stos byte [edi] |
xchg esi,ebx |
jmp argument_parsed |
parse_extrn_directive: |
cmp byte [esi],22h |
je parse_quoted_extrn |
cmp byte [esi],1Ah |
jne parse_argument |
push esi |
movzx ecx,byte [esi+1] |
add esi,2 |
mov ax,'(' |
stos word [edi] |
mov eax,ecx |
stos dword [edi] |
rep movs byte [edi],[esi] |
mov ax,8600h |
stos word [edi] |
pop esi |
parse_label_operator: |
cmp byte [esi],1Ah |
jne argument_parsed |
inc esi |
movzx ecx,byte [esi] |
inc esi |
mov al,2 |
stos byte [edi] |
call get_label_id |
stos dword [edi] |
xor al,al |
stos byte [edi] |
jmp argument_parsed |
parse_from_operator: |
cmp byte [esi],22h |
jne forced_expression |
jmp argument_parsed |
parse_quoted_extrn: |
inc esi |
mov ax,'(' |
stos word [edi] |
lods dword [esi] |
mov ecx,eax |
stos dword [edi] |
rep movs byte [edi],[esi] |
xor al,al |
stos byte [edi] |
push esi edi |
mov edi,directive_operators |
call get_operator |
mov edx,esi |
pop edi esi |
cmp al,86h |
jne argument_parsed |
stos byte [edi] |
mov esi,edx |
jmp parse_label_operator |
ptr_argument: |
call parse_address |
jmp address_parsed |
check_argument: |
push esi ecx |
sub esi,2 |
mov edi,single_operand_operators |
call get_operator |
pop ecx esi |
or al,al |
jnz not_instruction |
call get_instruction |
jnc embedded_instruction |
call get_data_directive |
jnc embedded_instruction |
not_instruction: |
pop edi |
sub esi,2 |
expression_argument: |
cmp byte [esi],22h |
jne not_string |
mov eax,[esi+1] |
lea ebx,[esi+5+eax] |
push ebx ecx esi edi |
mov al,'(' |
stos byte [edi] |
call convert_expression |
mov al,')' |
stos byte [edi] |
pop eax edx ecx ebx |
cmp esi,ebx |
jne expression_parsed |
mov edi,eax |
mov esi,edx |
string_argument: |
inc esi |
mov ax,'(' |
stos word [edi] |
lods dword [esi] |
mov ecx,eax |
stos dword [edi] |
shr ecx,1 |
jnc string_movsb_ok |
movs byte [edi],[esi] |
string_movsb_ok: |
shr ecx,1 |
jnc string_movsw_ok |
movs word [edi],[esi] |
string_movsw_ok: |
rep movs dword [edi],[esi] |
xor al,al |
stos byte [edi] |
jmp expression_parsed |
not_string: |
cmp byte [esi],'(' |
jne expression |
mov eax,esp |
sub eax,100h |
jc stack_overflow |
cmp eax,[stack_limit] |
jb stack_overflow |
push esi edi |
inc esi |
mov al,'{' |
stos byte [edi] |
inc [parenthesis_stack] |
jmp parse_argument |
expression: |
mov al,'(' |
stos byte [edi] |
call convert_expression |
mov al,')' |
stos byte [edi] |
jmp expression_parsed |
forced_expression: |
mov al,'(' |
stos byte [edi] |
call convert_expression |
mov al,')' |
stos byte [edi] |
jmp argument_parsed |
address_argument: |
call parse_address |
lods byte [esi] |
cmp al,']' |
je address_parsed |
dec esi |
mov al,')' |
stos byte [edi] |
jmp argument_parsed |
address_parsed: |
mov al,']' |
stos byte [edi] |
jmp argument_parsed |
parse_address: |
mov al,'[' |
stos byte [edi] |
cmp word [esi],021Ah |
jne convert_address |
push esi |
add esi,4 |
lea ebx,[esi+1] |
cmp byte [esi],':' |
pop esi |
jne convert_address |
add esi,2 |
mov ecx,2 |
push ebx edi |
call get_symbol |
pop edi esi |
jc unknown_segment_prefix |
cmp al,10h |
jne unknown_segment_prefix |
mov al,ah |
and ah,11110000b |
cmp ah,60h |
jne unknown_segment_prefix |
stos byte [edi] |
jmp convert_address |
unknown_segment_prefix: |
sub esi,5 |
convert_address: |
push edi |
mov edi,address_sizes |
call get_operator |
pop edi |
or al,al |
jz convert_expression |
add al,70h |
stos byte [edi] |
jmp convert_expression |
forced_parenthesis: |
cmp byte [esi],'(' |
jne argument_parsed |
inc esi |
mov al,'{' |
jmp separator |
unallowed_character: |
mov al,0FFh |
jmp separator |
close_parenthesis: |
mov al,'}' |
separator: |
stos byte [edi] |
jmp argument_parsed |
instruction_separator: |
stos byte [edi] |
jmp allow_embedded_instruction |
greater: |
cmp byte [esi],'=' |
jne separator |
inc esi |
mov al,0F2h |
jmp separator |
less: |
cmp byte [edi-1],0F6h |
je separator |
cmp byte [esi],'>' |
je not_equal |
cmp byte [esi],'=' |
jne separator |
inc esi |
mov al,0F3h |
jmp separator |
not_equal: |
inc esi |
mov al,0F1h |
jmp separator |
argument_parsed: |
cmp [parenthesis_stack],0 |
je parse_argument |
dec [parenthesis_stack] |
add esp,8 |
jmp argument_parsed |
expression_parsed: |
cmp [parenthesis_stack],0 |
je parse_argument |
cmp byte [esi],')' |
jne argument_parsed |
dec [parenthesis_stack] |
pop edi esi |
jmp expression |
contents_parsed: |
cmp [parenthesis_stack],0 |
jne invalid_expression |
ret |
identify_label: |
cmp byte [esi],'.' |
je local_label_name |
call get_label_id |
cmp eax,10h |
jb label_identified |
or ebx,ebx |
jz anonymous_label_name |
dec ebx |
mov [current_locals_prefix],ebx |
label_identified: |
ret |
anonymous_label_name: |
cmp byte [esi-1],'@' |
je anonymous_label_name_ok |
mov eax,0Fh |
anonymous_label_name_ok: |
ret |
local_label_name: |
call get_label_id |
ret |
get_operator: |
cmp byte [esi],1Ah |
jne get_simple_operator |
mov edx,esi |
push ebp |
inc esi |
lods byte [esi] |
movzx ebp,al |
push edi |
mov ecx,ebp |
call lower_case |
pop edi |
check_operator: |
mov esi,converted |
movzx ecx,byte [edi] |
jecxz no_operator |
inc edi |
mov ebx,edi |
add ebx,ecx |
cmp ecx,ebp |
jne next_operator |
repe cmps byte [esi],[edi] |
je operator_found |
next_operator: |
mov edi,ebx |
inc edi |
jmp check_operator |
no_operator: |
mov esi,edx |
mov ecx,ebp |
pop ebp |
no_simple_operator: |
xor al,al |
ret |
operator_found: |
lea esi,[edx+2+ebp] |
mov ecx,ebp |
pop ebp |
mov al,[edi] |
ret |
get_simple_operator: |
mov al,[esi] |
cmp al,22h |
je no_simple_operator |
simple_operator: |
cmp byte [edi],1 |
jb no_simple_operator |
ja simple_next_operator |
cmp al,[edi+1] |
je simple_operator_found |
simple_next_operator: |
movzx ecx,byte [edi] |
lea edi,[edi+1+ecx+1] |
jmp simple_operator |
simple_operator_found: |
inc esi |
mov al,[edi+2] |
ret |
get_symbol: |
push esi |
mov ebp,ecx |
call lower_case |
mov ecx,ebp |
cmp cl,11 |
ja no_symbol |
sub cl,2 |
jc no_symbol |
movzx ebx,word [symbols+ecx*4] |
add ebx,symbols |
movzx edx,word [symbols+ecx*4+2] |
scan_symbols: |
or edx,edx |
jz no_symbol |
mov eax,edx |
shr eax,1 |
lea edi,[ebp+2] |
imul eax,edi |
lea edi,[ebx+eax] |
mov esi,converted |
mov ecx,ebp |
repe cmps byte [esi],[edi] |
ja symbols_up |
jb symbols_down |
pop esi |
add esi,ebp |
mov ax,[edi] |
clc |
ret |
no_symbol: |
pop esi |
mov ecx,ebp |
stc |
ret |
symbols_down: |
shr edx,1 |
jmp scan_symbols |
symbols_up: |
lea ebx,[edi+ecx+2] |
shr edx,1 |
adc edx,-1 |
jmp scan_symbols |
get_data_directive: |
push esi |
mov ebp,ecx |
call lower_case |
mov ecx,ebp |
cmp cl,4 |
ja no_instruction |
sub cl,2 |
jc no_instruction |
movzx ebx,word [data_directives+ecx*4] |
add ebx,data_directives |
movzx edx,word [data_directives+ecx*4+2] |
jmp scan_instructions |
get_instruction: |
push esi |
mov ebp,ecx |
call lower_case |
mov ecx,ebp |
cmp cl,11 |
ja no_instruction |
sub cl,2 |
jc no_instruction |
movzx ebx,word [instructions+ecx*4] |
add ebx,instructions |
movzx edx,word [instructions+ecx*4+2] |
scan_instructions: |
or edx,edx |
jz no_instruction |
mov eax,edx |
shr eax,1 |
lea edi,[ebp+3] |
imul eax,edi |
lea edi,[ebx+eax] |
mov esi,converted |
mov ecx,ebp |
repe cmps byte [esi],[edi] |
ja instructions_up |
jb instructions_down |
pop esi |
add esi,ebp |
mov al,[edi] |
mov bx,[edi+1] |
clc |
ret |
no_instruction: |
pop esi |
mov ecx,ebp |
stc |
ret |
instructions_down: |
shr edx,1 |
jmp scan_instructions |
instructions_up: |
lea ebx,[edi+ecx+3] |
shr edx,1 |
adc edx,-1 |
jmp scan_instructions |
get_label_id: |
cmp ecx,100h |
jae name_too_long |
cmp byte [esi],'@' |
je anonymous_label |
cmp byte [esi],'.' |
jne standard_label |
cmp byte [esi+1],'.' |
je standard_label |
cmp [current_locals_prefix],0 |
je standard_label |
push edi |
mov edi,[additional_memory_end] |
sub edi,2 |
sub edi,ecx |
push ecx esi |
mov esi,[current_locals_prefix] |
lods byte [esi] |
movzx ecx,al |
sub edi,ecx |
cmp edi,[free_additional_memory] |
jb out_of_memory |
mov word [edi],0 |
add edi,2 |
mov ebx,edi |
rep movs byte [edi],[esi] |
pop esi ecx |
add al,cl |
jc name_too_long |
rep movs byte [edi],[esi] |
pop edi |
push ebx esi |
movzx ecx,al |
mov byte [ebx-1],al |
mov esi,ebx |
call get_label_id |
pop esi ebx |
cmp ebx,[eax+24] |
jne composed_label_id_ok |
lea edx,[ebx-2] |
mov [additional_memory_end],edx |
composed_label_id_ok: |
ret |
anonymous_label: |
cmp ecx,2 |
jne standard_label |
mov al,[esi+1] |
mov ebx,characters |
xlat byte [ebx] |
cmp al,'@' |
je new_anonymous |
cmp al,'b' |
je anonymous_back |
cmp al,'r' |
je anonymous_back |
cmp al,'f' |
jne standard_label |
add esi,2 |
mov eax,[anonymous_forward] |
or eax,eax |
jnz anonymous_ok |
mov eax,[current_line] |
mov [error_line],eax |
call allocate_label |
mov [anonymous_forward],eax |
anonymous_ok: |
xor ebx,ebx |
ret |
anonymous_back: |
add esi,2 |
mov eax,[anonymous_reverse] |
or eax,eax |
jz invalid_value |
jmp anonymous_ok |
new_anonymous: |
add esi,2 |
mov eax,[anonymous_forward] |
or eax,eax |
jnz new_anonymous_ok |
call allocate_label |
new_anonymous_ok: |
mov [anonymous_reverse],eax |
mov [anonymous_forward],0 |
jmp anonymous_ok |
standard_label: |
cmp byte [esi],'%' |
je get_predefined_id |
cmp byte [esi],'$' |
jne find_label |
cmp ecx,2 |
ja find_label |
inc esi |
jb get_current_offset_id |
inc esi |
cmp byte [esi-1],'$' |
je get_org_origin_id |
sub esi,ecx |
jmp find_label |
get_current_offset_id: |
xor eax,eax |
ret |
get_counter_id: |
mov eax,1 |
ret |
get_timestamp_id: |
mov eax,2 |
ret |
get_org_origin_id: |
mov eax,3 |
ret |
get_predefined_id: |
cmp ecx,2 |
ja find_label |
inc esi |
cmp cl,1 |
je get_counter_id |
lods byte [esi] |
mov ebx,characters |
xlat [ebx] |
cmp al,'t' |
je get_timestamp_id |
sub esi,2 |
find_label: |
xor ebx,ebx |
mov eax,2166136261 |
mov ebp,16777619 |
hash_label: |
xor al,[esi+ebx] |
mul ebp |
inc bl |
cmp bl,cl |
jb hash_label |
mov ebp,eax |
shl eax,8 |
and ebp,0FFh shl 24 |
xor ebp,eax |
or ebp,ebx |
mov [label_hash],ebp |
push edi esi |
push ecx |
mov ecx,32 |
mov ebx,hash_tree |
follow_tree: |
mov edx,[ebx] |
or edx,edx |
jz extend_tree |
xor eax,eax |
shl ebp,1 |
adc eax,0 |
lea ebx,[edx+eax*4] |
dec ecx |
jnz follow_tree |
mov [label_leaf],ebx |
pop edx |
mov eax,[ebx] |
or eax,eax |
jz add_label |
mov ebx,esi |
mov ebp,[label_hash] |
compare_labels: |
mov esi,ebx |
mov ecx,edx |
mov edi,[eax+4] |
mov edi,[edi+24] |
repe cmps byte [esi],[edi] |
je label_found |
mov eax,[eax] |
or eax,eax |
jnz compare_labels |
jmp add_label |
label_found: |
add esp,4 |
pop edi |
mov eax,[eax+4] |
ret |
extend_tree: |
mov edx,[free_additional_memory] |
lea eax,[edx+8] |
cmp eax,[additional_memory_end] |
ja out_of_memory |
mov [free_additional_memory],eax |
xor eax,eax |
mov [edx],eax |
mov [edx+4],eax |
shl ebp,1 |
adc eax,0 |
mov [ebx],edx |
lea ebx,[edx+eax*4] |
dec ecx |
jnz extend_tree |
mov [label_leaf],ebx |
pop edx |
add_label: |
mov ecx,edx |
pop esi |
cmp byte [esi-2],0 |
je label_name_ok |
mov al,[esi] |
cmp al,30h |
jb name_first_char_ok |
cmp al,39h |
jbe invalid_name |
name_first_char_ok: |
cmp ecx,1 |
jne check_for_reserved_word |
cmp al,'$' |
je reserved_word |
check_for_reserved_word: |
call get_instruction |
jnc reserved_word |
call get_data_directive |
jnc reserved_word |
call get_symbol |
jnc reserved_word |
sub esi,2 |
mov edi,operators |
call get_operator |
or al,al |
jnz reserved_word |
mov edi,single_operand_operators |
call get_operator |
or al,al |
jnz reserved_word |
mov edi,directive_operators |
call get_operator |
or al,al |
jnz reserved_word |
inc esi |
movzx ecx,byte [esi] |
inc esi |
label_name_ok: |
mov edx,[free_additional_memory] |
lea eax,[edx+8] |
cmp eax,[additional_memory_end] |
ja out_of_memory |
mov [free_additional_memory],eax |
mov ebx,esi |
add esi,ecx |
mov eax,[label_leaf] |
mov edi,[eax] |
mov [edx],edi |
mov [eax],edx |
call allocate_label |
mov [edx+4],eax |
mov [eax+24],ebx |
pop edi |
ret |
reserved_word: |
mov eax,0Fh |
pop edi |
ret |
allocate_label: |
mov eax,[labels_list] |
mov ecx,LABEL_STRUCTURE_SIZE shr 2 |
initialize_label: |
sub eax,4 |
mov dword [eax],0 |
loop initialize_label |
mov [labels_list],eax |
ret |
LABEL_STRUCTURE_SIZE = 32 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/fasm/trunk/preproce.inc |
---|
0,0 → 1,2488 |
; flat assembler core |
; Copyright (c) 1999-2006, Tomasz Grysztar. |
; All rights reserved. |
preprocessor: |
mov edi,characters |
mov ecx,100h |
xor al,al |
make_characters_table: |
stosb |
inc al |
loop make_characters_table |
mov esi,characters+'a' |
mov edi,characters+'A' |
mov ecx,26 |
rep movsb |
mov edi,characters |
mov esi,symbol_characters+1 |
movzx ecx,byte [esi-1] |
xor eax,eax |
mark_symbol_characters: |
lodsb |
mov byte [edi+eax],0 |
loop mark_symbol_characters |
mov edi,locals_counter |
mov al,7 |
stos byte [edi] |
movzx ecx,al |
mov al,'0' |
rep stos byte [edi] |
mov edi,[memory_start] |
mov [include_paths],edi |
mov esi,include_variable |
call get_environment_variable |
xor al,al |
stosb |
mov [memory_start],edi |
mov eax,[additional_memory] |
mov [free_additional_memory],eax |
mov eax,[additional_memory_end] |
mov [labels_list],eax |
xor eax,eax |
mov [display_buffer],eax |
mov [hash_tree],eax |
mov [macro_status],al |
mov esi,[input_file] |
mov edx,esi |
call open |
jc main_file_not_found |
mov edi,[memory_start] |
call preprocess_file |
mov eax,[error_line] |
mov [current_line],eax |
cmp [macro_status],0 |
jne incomplete_macro |
mov [source_start],edi |
ret |
preprocess_file: |
push [memory_end] |
push esi |
mov al,2 |
xor edx,edx |
call lseek |
push eax |
xor al,al |
xor edx,edx |
call lseek |
pop ecx |
mov edx,[memory_end] |
dec edx |
mov byte [edx],1Ah |
sub edx,ecx |
jc out_of_memory |
mov esi,edx |
cmp edx,edi |
jbe out_of_memory |
mov [memory_end],edx |
call read |
call close |
pop edx |
xor ecx,ecx |
mov ebx,esi |
preprocess_source: |
inc ecx |
mov [current_line],edi |
mov eax,edx |
stos dword [edi] |
mov eax,ecx |
stos dword [edi] |
mov eax,esi |
sub eax,ebx |
stos dword [edi] |
xor eax,eax |
stos dword [edi] |
push ebx edx |
call convert_line |
call preprocess_line |
pop edx ebx |
next_line: |
cmp byte [esi-1],1Ah |
jne preprocess_source |
file_end: |
pop [memory_end] |
clc |
ret |
convert_line: |
push ecx |
test [macro_status],0Fh |
jz convert_line_data |
mov ax,3Bh |
stos word [edi] |
convert_line_data: |
cmp edi,[memory_end] |
jae out_of_memory |
lods byte [esi] |
cmp al,20h |
je convert_line_data |
cmp al,9 |
je convert_line_data |
mov ah,al |
mov ebx,characters |
xlat byte [ebx] |
or al,al |
jz convert_separator |
cmp ah,27h |
je convert_string |
cmp ah,22h |
je convert_string |
mov byte [edi],1Ah |
scas word [edi] |
xchg al,ah |
stos byte [edi] |
mov ebx,characters |
xor ecx,ecx |
convert_symbol: |
lods byte [esi] |
stos byte [edi] |
xlat byte [ebx] |
or al,al |
loopnzd convert_symbol |
neg ecx |
cmp ecx,255 |
ja name_too_long |
mov ebx,edi |
sub ebx,ecx |
mov byte [ebx-2],cl |
found_separator: |
dec edi |
mov ah,[esi-1] |
convert_separator: |
xchg al,ah |
cmp al,20h |
jb control_character |
je convert_line_data |
symbol_character: |
cmp al,3Bh |
je ignore_comment |
cmp al,5Ch |
je backslash_character |
stos byte [edi] |
jmp convert_line_data |
control_character: |
cmp al,1Ah |
je line_end |
cmp al,0Dh |
je cr_character |
cmp al,0Ah |
je lf_character |
cmp al,9 |
je convert_line_data |
or al,al |
jnz symbol_character |
jmp line_end |
lf_character: |
lods byte [esi] |
cmp al,0Dh |
je line_end |
dec esi |
jmp line_end |
cr_character: |
lods byte [esi] |
cmp al,0Ah |
je line_end |
dec esi |
jmp line_end |
convert_string: |
mov al,22h |
stos byte [edi] |
scas dword [edi] |
mov ebx,edi |
copy_string: |
lods byte [esi] |
stos byte [edi] |
cmp al,0Ah |
je missing_end_quote |
cmp al,0Dh |
je missing_end_quote |
or al,al |
jz missing_end_quote |
cmp al,1Ah |
je missing_end_quote |
cmp al,ah |
jne copy_string |
lods byte [esi] |
cmp al,ah |
je copy_string |
dec esi |
dec edi |
mov eax,edi |
sub eax,ebx |
mov [ebx-4],eax |
jmp convert_line_data |
backslash_character: |
mov byte [edi],0 |
lods byte [esi] |
cmp al,20h |
je concatenate_lines |
cmp al,9 |
je concatenate_lines |
cmp al,1Ah |
je unexpected_end_of_file |
cmp al,0Ah |
je concatenate_lf |
cmp al,0Dh |
je concatenate_cr |
cmp al,3Bh |
je find_concatenated_line |
mov al,1Ah |
stos byte [edi] |
mov ecx,edi |
mov ax,5C01h |
stos word [edi] |
dec esi |
group_backslashes: |
lods byte [esi] |
cmp al,5Ch |
jne backslashed_symbol |
stos byte [edi] |
inc byte [ecx] |
jmp group_backslashes |
backslashed_symbol: |
cmp al,1Ah |
je unexpected_end_of_file |
cmp al,0Ah |
je extra_characters_on_line |
cmp al,0Dh |
je extra_characters_on_line |
cmp al,20h |
je extra_characters_on_line |
cmp al,9 |
je extra_characters_on_line |
cmp al,22h |
je extra_characters_on_line |
cmp al,27h |
je extra_characters_on_line |
cmp al,3Bh |
je extra_characters_on_line |
mov ah,al |
mov ebx,characters |
xlat byte [ebx] |
or al,al |
jz backslashed_symbol_character |
mov al,ah |
convert_backslashed_symbol: |
stos byte [edi] |
xlat byte [ebx] |
or al,al |
jz found_separator |
inc byte [ecx] |
jz name_too_long |
lods byte [esi] |
jmp convert_backslashed_symbol |
backslashed_symbol_character: |
mov al,ah |
stos byte [edi] |
inc byte [ecx] |
jmp convert_line_data |
concatenate_lines: |
lods byte [esi] |
cmp al,20h |
je concatenate_lines |
cmp al,9 |
je concatenate_lines |
cmp al,1Ah |
je unexpected_end_of_file |
cmp al,0Ah |
je concatenate_lf |
cmp al,0Dh |
je concatenate_cr |
cmp al,3Bh |
jne extra_characters_on_line |
find_concatenated_line: |
lods byte [esi] |
cmp al,0Ah |
je concatenate_lf |
cmp al,0Dh |
je concatenate_cr |
or al,al |
jz concatenate_ok |
cmp al,1Ah |
jne find_concatenated_line |
jmp unexpected_end_of_file |
concatenate_lf: |
lods byte [esi] |
cmp al,0Dh |
je concatenate_ok |
dec esi |
jmp concatenate_ok |
concatenate_cr: |
lods byte [esi] |
cmp al,0Ah |
je concatenate_ok |
dec esi |
concatenate_ok: |
inc dword [esp] |
jmp convert_line_data |
ignore_comment: |
lods byte [esi] |
cmp al,0Ah |
je lf_character |
cmp al,0Dh |
je cr_character |
or al,al |
jz line_end |
cmp al,1Ah |
jne ignore_comment |
line_end: |
xor al,al |
stos byte [edi] |
pop ecx |
ret |
lower_case: |
mov edi,converted |
mov ebx,characters |
convert_case: |
lods byte [esi] |
xlat byte [ebx] |
stos byte [edi] |
loop convert_case |
case_ok: |
ret |
get_directive: |
push edi |
mov edx,esi |
mov ebp,ecx |
call lower_case |
pop edi |
scan_directives: |
mov esi,converted |
movzx eax,byte [edi] |
or al,al |
jz no_directive |
mov ecx,ebp |
inc edi |
mov ebx,edi |
add ebx,eax |
mov ah,[esi] |
cmp ah,[edi] |
jb no_directive |
ja next_directive |
cmp cl,al |
jne next_directive |
repe cmps byte [esi],[edi] |
jb no_directive |
je directive_ok |
next_directive: |
mov edi,ebx |
add edi,2 |
jmp scan_directives |
no_directive: |
mov esi,edx |
mov ecx,ebp |
stc |
ret |
directive_ok: |
lea esi,[edx+ebp] |
movzx eax,word [ebx] |
add eax,preprocessor |
clc |
ret |
preprocess_line: |
mov eax,esp |
sub eax,100h |
jc stack_overflow |
cmp eax,[stack_limit] |
jb stack_overflow |
push ecx esi |
preprocess_current_line: |
mov esi,[current_line] |
add esi,16 |
cmp word [esi],3Bh |
jne line_start_ok |
add esi,2 |
line_start_ok: |
test [macro_status],0F0h |
jnz macro_preprocessing |
cmp byte [esi],1Ah |
jne not_fix_constant |
movzx edx,byte [esi+1] |
lea edx,[esi+2+edx] |
cmp word [edx],031Ah |
jne not_fix_constant |
mov ebx,characters |
movzx eax,byte [edx+2] |
xlat byte [ebx] |
ror eax,8 |
mov al,[edx+3] |
xlat byte [ebx] |
ror eax,8 |
mov al,[edx+4] |
xlat byte [ebx] |
ror eax,16 |
cmp eax,'fix' |
je define_fix_constant |
not_fix_constant: |
call process_fix_constants |
jmp initial_preprocessing_ok |
macro_preprocessing: |
call process_macro_operators |
initial_preprocessing_ok: |
mov esi,[current_line] |
add esi,16 |
mov al,[macro_status] |
test al,2 |
jnz skip_macro_block |
test al,1 |
jnz find_macro_block |
preprocess_instruction: |
mov [current_offset],esi |
lods byte [esi] |
movzx ecx,byte [esi] |
inc esi |
cmp al,1Ah |
jne not_preprocessor_symbol |
cmp cl,3 |
jb not_preprocessor_directive |
push edi |
mov edi,preprocessor_directives |
call get_directive |
pop edi |
jc not_preprocessor_directive |
mov byte [edx-2],3Bh |
jmp near eax |
not_preprocessor_directive: |
xor ch,ch |
call get_preprocessor_symbol |
jc not_macro |
mov byte [ebx-2],3Bh |
mov [struc_name],0 |
jmp use_macro |
not_macro: |
mov [struc_name],esi |
add esi,ecx |
lods byte [esi] |
cmp al,':' |
je preprocess_label |
cmp al,1Ah |
jne not_preprocessor_symbol |
lods byte [esi] |
cmp al,3 |
jne not_symbolic_constant |
mov ebx,characters |
movzx eax,byte [esi] |
xlat byte [ebx] |
ror eax,8 |
mov al,[esi+1] |
xlat byte [ebx] |
ror eax,8 |
mov al,[esi+2] |
xlat byte [ebx] |
ror eax,16 |
cmp eax,'equ' |
je define_equ_constant |
mov al,3 |
not_symbolic_constant: |
mov ch,1 |
mov cl,al |
call get_preprocessor_symbol |
jc not_preprocessor_symbol |
push edx esi |
mov esi,[struc_name] |
mov [struc_label],esi |
sub [struc_label],2 |
mov cl,[esi-1] |
mov ch,10b |
call get_preprocessor_symbol |
jc struc_name_ok |
mov ecx,[edx+12] |
add ecx,3 |
lea ebx,[edi+ecx] |
mov ecx,edi |
sub ecx,[struc_label] |
lea esi,[edi-1] |
lea edi,[ebx-1] |
std |
rep movs byte [edi],[esi] |
cld |
mov edi,[struc_label] |
mov esi,[edx+8] |
mov ecx,[edx+12] |
add [struc_name],ecx |
add [struc_name],3 |
call move_data |
mov al,3Ah |
stos byte [edi] |
mov ax,3Bh |
stos word [edi] |
mov edi,ebx |
pop esi |
add esi,[edx+12] |
add esi,3 |
pop edx |
jmp use_macro |
struc_name_ok: |
mov edx,[struc_name] |
movzx eax,byte [edx-1] |
add edx,eax |
mov al,3Ah |
mov [edx],al |
inc al |
xchg al,[edx+1] |
dec al |
mov [edx+2],al |
pop esi edx |
jmp use_macro |
preprocess_label: |
dec esi |
sub esi,ecx |
lea ebp,[esi-2] |
mov ch,10b |
call get_preprocessor_symbol |
jnc symbolic_constant_in_label |
lea esi,[esi+ecx+1] |
jmp preprocess_instruction |
symbolic_constant_in_label: |
mov ebx,[edx+8] |
mov ecx,[edx+12] |
add ecx,ebx |
check_for_broken_label: |
cmp ebx,ecx |
je label_broken |
cmp byte [ebx],1Ah |
jne label_broken |
movzx eax,byte [ebx+1] |
lea ebx,[ebx+2+eax] |
cmp ebx,ecx |
je label_constant_ok |
cmp byte [ebx],':' |
jne label_broken |
inc ebx |
jmp check_for_broken_label |
label_broken: |
push line_preprocessed |
jmp replace_symbolic_constant |
label_constant_ok: |
mov ecx,edi |
sub ecx,esi |
mov edi,[edx+12] |
add edi,ebp |
push edi |
lea eax,[edi+ecx] |
push eax |
cmp esi,edi |
je replace_label |
jb move_rest_of_line_up |
rep movs byte [edi],[esi] |
jmp replace_label |
move_rest_of_line_up: |
lea esi,[esi+ecx-1] |
lea edi,[edi+ecx-1] |
std |
rep movs byte [edi],[esi] |
cld |
replace_label: |
mov ecx,[edx+12] |
mov edi,[esp+4] |
sub edi,ecx |
mov esi,[edx+8] |
rep movs byte [edi],[esi] |
pop edi esi |
inc esi |
jmp preprocess_instruction |
not_preprocessor_symbol: |
mov esi,[current_offset] |
call process_equ_constants |
line_preprocessed: |
pop esi ecx |
ret |
get_preprocessor_symbol: |
push ebp edi esi |
mov ebp,ecx |
shl ebp,22 |
movzx ecx,cl |
mov ebx,hash_tree |
mov edi,10 |
follow_hashes_roots: |
mov edx,[ebx] |
or edx,edx |
jz preprocessor_symbol_not_found |
xor eax,eax |
shl ebp,1 |
adc eax,0 |
lea ebx,[edx+eax*4] |
dec edi |
jnz follow_hashes_roots |
mov edi,ebx |
call calculate_hash |
mov ebp,eax |
and ebp,3FFh |
shl ebp,10 |
xor ebp,eax |
mov ebx,edi |
mov edi,22 |
follow_hashes_tree: |
mov edx,[ebx] |
or edx,edx |
jz preprocessor_symbol_not_found |
xor eax,eax |
shl ebp,1 |
adc eax,0 |
lea ebx,[edx+eax*4] |
dec edi |
jnz follow_hashes_tree |
mov al,cl |
mov edx,[ebx] |
or edx,edx |
jz preprocessor_symbol_not_found |
compare_with_preprocessor_symbol: |
mov edi,[edx+4] |
cmp edi,1 |
jbe next_equal_hash |
repe cmps byte [esi],[edi] |
je preprocessor_symbol_found |
mov cl,al |
mov esi,[esp] |
next_equal_hash: |
mov edx,[edx] |
or edx,edx |
jnz compare_with_preprocessor_symbol |
preprocessor_symbol_not_found: |
pop esi edi ebp |
stc |
ret |
preprocessor_symbol_found: |
pop ebx edi ebp |
clc |
ret |
calculate_hash: |
xor ebx,ebx |
mov eax,2166136261 |
mov ebp,16777619 |
fnv1a_hash: |
xor al,[esi+ebx] |
mul ebp |
inc bl |
cmp bl,cl |
jb fnv1a_hash |
ret |
add_preprocessor_symbol: |
push edi esi |
call calculate_hash |
mov ebp,eax |
and ebp,3FFh |
shr eax,10 |
xor ebp,eax |
shl ecx,22 |
or ebp,ecx |
mov ebx,hash_tree |
mov ecx,32 |
find_leave_for_symbol: |
mov edx,[ebx] |
or edx,edx |
jz extend_hashes_tree |
xor eax,eax |
rol ebp,1 |
adc eax,0 |
lea ebx,[edx+eax*4] |
dec ecx |
jnz find_leave_for_symbol |
mov edx,[ebx] |
or edx,edx |
jz add_symbol_entry |
shr ebp,30 |
cmp ebp,11b |
je reuse_symbol_entry |
cmp dword [edx+4],0 |
jne add_symbol_entry |
find_entry_to_reuse: |
mov edi,[edx] |
or edi,edi |
jz reuse_symbol_entry |
cmp dword [edi+4],0 |
jne reuse_symbol_entry |
mov edx,edi |
jmp find_entry_to_reuse |
add_symbol_entry: |
mov eax,edx |
mov edx,[labels_list] |
sub edx,16 |
cmp edx,[free_additional_memory] |
jb out_of_memory |
mov [labels_list],edx |
mov [edx],eax |
mov [ebx],edx |
reuse_symbol_entry: |
pop esi edi |
mov [edx+4],esi |
ret |
extend_hashes_tree: |
mov edx,[labels_list] |
sub edx,8 |
cmp edx,[free_additional_memory] |
jb out_of_memory |
mov [labels_list],edx |
xor eax,eax |
mov [edx],eax |
mov [edx+4],eax |
shl ebp,1 |
adc eax,0 |
mov [ebx],edx |
lea ebx,[edx+eax*4] |
dec ecx |
jnz extend_hashes_tree |
mov edx,[labels_list] |
sub edx,16 |
cmp edx,[free_additional_memory] |
jb out_of_memory |
mov [labels_list],edx |
mov dword [edx],0 |
mov [ebx],edx |
pop esi edi |
mov [edx+4],esi |
ret |
define_fix_constant: |
add edx,5 |
add esi,2 |
push edx esi |
mov esi,edx |
call skip_parameters |
xchg esi,[esp] |
mov ch,11b |
jmp define_preprocessor_constant |
define_equ_constant: |
add esi,3 |
push esi |
call process_equ_constants |
push esi |
mov esi,[struc_name] |
mov ch,10b |
define_preprocessor_constant: |
mov byte [esi-2],3Bh |
mov cl,[esi-1] |
call add_preprocessor_symbol |
pop esi ebx |
mov ecx,edi |
dec ecx |
sub ecx,ebx |
mov [edx+8],ebx |
mov [edx+12],ecx |
jmp line_preprocessed |
define_symbolic_constant: |
lods byte [esi] |
cmp al,1Ah |
jne invalid_name |
lods byte [esi] |
mov cl,al |
mov ch,10b |
call add_preprocessor_symbol |
movzx eax,byte [esi-1] |
add esi,eax |
push esi edx |
call skip_parameters |
pop edx ebx |
lea ecx,[esi-1] |
sub ecx,ebx |
mov [edx+8],ebx |
mov [edx+12],ecx |
jmp line_preprocessed |
skip_parameters: |
lods byte [esi] |
or al,al |
jz parameters_skipped |
cmp al,'{' |
je parameters_skipped |
cmp al,22h |
je skip_quoted_parameter |
cmp al,1Ah |
jne skip_parameters |
lods byte [esi] |
movzx eax,al |
add esi,eax |
jmp skip_parameters |
skip_quoted_parameter: |
lods dword [esi] |
add esi,eax |
jmp skip_parameters |
parameters_skipped: |
ret |
define_struc: |
mov ch,1 |
jmp make_macro |
define_macro: |
xor ch,ch |
make_macro: |
lods byte [esi] |
cmp al,1Ah |
jne invalid_name |
lods byte [esi] |
mov cl,al |
call add_preprocessor_symbol |
mov eax,[current_line] |
mov [edx+12],eax |
movzx eax,byte [esi-1] |
add esi,eax |
mov [edx+8],esi |
mov al,[macro_status] |
and al,0F0h |
or al,1 |
mov [macro_status],al |
mov eax,[current_line] |
mov [error_line],eax |
xor bl,bl |
lods byte [esi] |
or al,al |
jz line_preprocessed |
cmp al,'{' |
je found_macro_block |
dec esi |
skip_macro_arguments: |
lods byte [esi] |
cmp al,1Ah |
je skip_macro_argument |
cmp al,'[' |
jne invalid_macro_arguments |
xor bl,-1 |
jz invalid_macro_arguments |
lods byte [esi] |
cmp al,1Ah |
jne invalid_macro_arguments |
skip_macro_argument: |
movzx eax,byte [esi] |
inc esi |
add esi,eax |
lods byte [esi] |
cmp al,'*' |
jne macro_argument_end |
lods byte [esi] |
macro_argument_end: |
cmp al,',' |
je skip_macro_arguments |
cmp al,']' |
jne end_macro_arguments |
lods byte [esi] |
not bl |
end_macro_arguments: |
or bl,bl |
jnz invalid_macro_arguments |
or al,al |
jz line_preprocessed |
cmp al,'{' |
je found_macro_block |
jmp invalid_macro_arguments |
find_macro_block: |
add esi,2 |
lods byte [esi] |
or al,al |
jz line_preprocessed |
cmp al,'{' |
jne unexpected_characters |
found_macro_block: |
or [macro_status],2 |
skip_macro_block: |
lods byte [esi] |
cmp al,1Ah |
je skip_macro_symbol |
cmp al,3Bh |
je skip_macro_symbol |
cmp al,22h |
je skip_macro_string |
or al,al |
jz line_preprocessed |
cmp al,'}' |
jne skip_macro_block |
mov al,[macro_status] |
and [macro_status],0F0h |
test al,8 |
jnz use_instant_macro |
cmp byte [esi],0 |
je line_preprocessed |
mov ecx,edi |
sub ecx,esi |
mov edx,esi |
lea esi,[esi+ecx-1] |
lea edi,[edi+1+16] |
mov ebx,edi |
dec edi |
std |
rep movs byte [edi],[esi] |
cld |
mov edi,edx |
xor al,al |
stos byte [edi] |
mov esi,[current_line] |
mov [current_line],edi |
mov ecx,4 |
rep movs dword [edi],[esi] |
mov edi,ebx |
jmp preprocess_current_line |
skip_macro_symbol: |
movzx eax,byte [esi] |
inc esi |
add esi,eax |
jmp skip_macro_block |
skip_macro_string: |
lods dword [esi] |
add esi,eax |
jmp skip_macro_block |
rept_directive: |
mov [base_code],0 |
jmp define_instant_macro |
irp_directive: |
mov [base_code],1 |
jmp define_instant_macro |
irps_directive: |
mov [base_code],2 |
jmp define_instant_macro |
match_directive: |
mov [base_code],10h |
define_instant_macro: |
mov al,[macro_status] |
and al,0F0h |
or al,8+1 |
mov [macro_status],al |
mov eax,[current_line] |
mov [error_line],eax |
mov [instant_macro_start],esi |
cmp [base_code],10h |
je prepare_match |
call skip_parameters |
instant_macro_parameters_skipped: |
dec esi |
mov [parameters_end],esi |
lods byte [esi] |
cmp al,'{' |
je found_macro_block |
or al,al |
jnz invalid_macro_arguments |
jmp line_preprocessed |
prepare_match: |
call skip_pattern |
mov [value_type],80h+10b |
call process_symbolic_constants |
jmp instant_macro_parameters_skipped |
skip_pattern: |
lods byte [esi] |
or al,al |
jz invalid_macro_arguments |
cmp al,',' |
je pattern_skipped |
cmp al,22h |
je skip_quoted_string_in_pattern |
cmp al,1Ah |
je skip_symbol_in_pattern |
cmp al,'=' |
jne skip_pattern |
mov al,[esi] |
cmp al,1Ah |
je skip_pattern |
cmp al,22h |
je skip_pattern |
inc esi |
jmp skip_pattern |
skip_symbol_in_pattern: |
lods byte [esi] |
movzx eax,al |
add esi,eax |
jmp skip_pattern |
skip_quoted_string_in_pattern: |
lods dword [esi] |
add esi,eax |
jmp skip_pattern |
pattern_skipped: |
ret |
purge_macro: |
xor ch,ch |
jmp restore_preprocessor_symbol |
purge_struc: |
mov ch,1 |
jmp restore_preprocessor_symbol |
restore_equ_constant: |
mov ch,10b |
restore_preprocessor_symbol: |
push ecx |
lods byte [esi] |
cmp al,1Ah |
jne invalid_name |
lods byte [esi] |
mov cl,al |
call get_preprocessor_symbol |
jc no_symbol_to_restore |
mov dword [edx+4],0 |
jmp symbol_restored |
no_symbol_to_restore: |
add esi,ecx |
symbol_restored: |
pop ecx |
lods byte [esi] |
cmp al,',' |
je restore_preprocessor_symbol |
or al,al |
jnz extra_characters_on_line |
jmp line_preprocessed |
process_fix_constants: |
mov [value_type],11b |
jmp process_symbolic_constants |
process_equ_constants: |
mov [value_type],10b |
process_symbolic_constants: |
mov ebp,esi |
lods byte [esi] |
cmp al,1Ah |
je check_symbol |
cmp al,22h |
je ignore_string |
cmp al,'{' |
je check_brace |
or al,al |
jnz process_symbolic_constants |
ret |
ignore_string: |
lods dword [esi] |
add esi,eax |
jmp process_symbolic_constants |
check_brace: |
test [value_type],80h |
jz process_symbolic_constants |
ret |
no_replacing: |
movzx ecx,byte [esi-1] |
add esi,ecx |
jmp process_symbolic_constants |
check_symbol: |
mov cl,[esi] |
inc esi |
mov ch,[value_type] |
call get_preprocessor_symbol |
jc no_replacing |
mov [current_section],edi |
replace_symbolic_constant: |
mov ecx,[edx+12] |
mov edx,[edx+8] |
xchg esi,edx |
call move_data |
mov esi,edx |
process_after_replaced: |
lods byte [esi] |
cmp al,1Ah |
je symbol_after_replaced |
stos byte [edi] |
cmp al,22h |
je string_after_replaced |
cmp al,'{' |
je brace_after_replaced |
or al,al |
jnz process_after_replaced |
mov ecx,edi |
sub ecx,esi |
mov edi,ebp |
call move_data |
mov esi,edi |
ret |
move_data: |
lea eax,[edi+ecx] |
cmp eax,[memory_end] |
jae out_of_memory |
shr ecx,1 |
jnc movsb_ok |
movs byte [edi],[esi] |
movsb_ok: |
shr ecx,1 |
jnc movsw_ok |
movs word [edi],[esi] |
movsw_ok: |
rep movs dword [edi],[esi] |
ret |
string_after_replaced: |
lods dword [esi] |
stos dword [edi] |
mov ecx,eax |
call move_data |
jmp process_after_replaced |
brace_after_replaced: |
test [value_type],80h |
jz process_after_replaced |
mov edx,edi |
mov ecx,[current_section] |
sub edx,ecx |
sub ecx,esi |
rep movs byte [edi],[esi] |
mov ecx,edi |
sub ecx,esi |
mov edi,ebp |
call move_data |
lea esi,[ebp+edx] |
ret |
symbol_after_replaced: |
mov cl,[esi] |
inc esi |
mov ch,[value_type] |
call get_preprocessor_symbol |
jnc replace_symbolic_constant |
movzx ecx,byte [esi-1] |
mov al,1Ah |
mov ah,cl |
stos word [edi] |
call move_data |
jmp process_after_replaced |
process_macro_operators: |
xor dl,dl |
mov ebp,edi |
before_macro_operators: |
mov edi,esi |
lods byte [esi] |
cmp al,'`' |
je symbol_conversion |
cmp al,'#' |
je concatenation |
cmp al,1Ah |
je symbol_before_macro_operators |
cmp al,3Bh |
je no_more_macro_operators |
cmp al,22h |
je string_before_macro_operators |
xor dl,dl |
or al,al |
jnz before_macro_operators |
mov edi,esi |
ret |
no_more_macro_operators: |
mov edi,ebp |
ret |
symbol_before_macro_operators: |
mov dl,1Ah |
mov ebx,esi |
lods byte [esi] |
movzx ecx,al |
jecxz symbol_before_macro_operators_ok |
mov edi,esi |
cmp byte [esi],'\' |
je escaped_symbol |
symbol_before_macro_operators_ok: |
add esi,ecx |
jmp before_macro_operators |
string_before_macro_operators: |
mov dl,22h |
mov ebx,esi |
lods dword [esi] |
add esi,eax |
jmp before_macro_operators |
escaped_symbol: |
dec byte [edi-1] |
dec ecx |
inc esi |
cmp ecx,1 |
rep movs byte [edi],[esi] |
jne after_macro_operators |
mov al,[esi-1] |
mov ecx,ebx |
mov ebx,characters |
xlat byte [ebx] |
mov ebx,ecx |
or al,al |
jnz after_macro_operators |
sub edi,3 |
mov al,[esi-1] |
stos byte [edi] |
xor dl,dl |
jmp after_macro_operators |
reduce_symbol_conversion: |
inc esi |
symbol_conversion: |
mov edx,esi |
mov al,[esi] |
cmp al,1Ah |
jne symbol_character_conversion |
lods word [esi] |
movzx ecx,ah |
lea ebx,[edi+3] |
jmp convert_to_quoted_string |
symbol_character_conversion: |
cmp al,22h |
je after_macro_operators |
cmp al,'`' |
je reduce_symbol_conversion |
lea ebx,[edi+5] |
xor ecx,ecx |
or al,al |
jz convert_to_quoted_string |
cmp al,'#' |
je convert_to_quoted_string |
inc ecx |
convert_to_quoted_string: |
sub ebx,edx |
ja shift_line_data |
mov al,22h |
mov dl,al |
stos byte [edi] |
mov ebx,edi |
mov eax,ecx |
stos dword [edi] |
rep movs byte [edi],[esi] |
cmp edi,esi |
je before_macro_operators |
jmp after_macro_operators |
shift_line_data: |
push ecx |
mov edx,esi |
lea esi,[ebp-1] |
add ebp,ebx |
lea edi,[ebp-1] |
lea ecx,[esi+1] |
sub ecx,edx |
std |
rep movs byte [edi],[esi] |
cld |
pop eax |
sub edi,3 |
mov dl,22h |
mov [edi-1],dl |
mov ebx,edi |
mov [edi],eax |
lea esi,[edi+4+eax] |
jmp before_macro_operators |
concatenation: |
cmp dl,1Ah |
je symbol_concatenation |
cmp dl,22h |
je string_concatenation |
no_concatenation: |
cmp esi,edi |
je before_macro_operators |
jmp after_macro_operators |
symbol_concatenation: |
cmp byte [esi],1Ah |
jne no_concatenation |
inc esi |
lods byte [esi] |
movzx ecx,al |
jecxz do_symbol_concatenation |
cmp byte [esi],'\' |
jne do_symbol_concatenation |
sub esi,2 |
jmp no_concatenation |
do_symbol_concatenation: |
add [ebx],al |
jc name_too_long |
rep movs byte [edi],[esi] |
jmp after_macro_operators |
string_concatenation: |
cmp byte [esi],22h |
je do_string_concatenation |
cmp byte [esi],'`' |
jne no_concatenation |
concatenate_converted_symbol: |
inc esi |
mov al,[esi] |
cmp al,'`' |
je concatenate_converted_symbol |
cmp al,22h |
je do_string_concatenation |
cmp al,1Ah |
jne concatenate_converted_symbol_character |
inc esi |
lods byte [esi] |
movzx ecx,al |
add [ebx],ecx |
rep movs byte [edi],[esi] |
jmp after_macro_operators |
concatenate_converted_symbol_character: |
or al,al |
jz after_macro_operators |
cmp al,'#' |
je after_macro_operators |
inc dword [ebx] |
movs byte [edi],[esi] |
jmp after_macro_operators |
do_string_concatenation: |
inc esi |
lods dword [esi] |
mov ecx,eax |
add [ebx],eax |
rep movs byte [edi],[esi] |
after_macro_operators: |
lods byte [esi] |
cmp al,'`' |
je symbol_conversion |
cmp al,'#' |
je concatenation |
stos byte [edi] |
cmp al,1Ah |
je symbol_after_macro_operators |
cmp al,3Bh |
je no_more_macro_operators |
cmp al,22h |
je string_after_macro_operators |
xor dl,dl |
or al,al |
jnz after_macro_operators |
ret |
symbol_after_macro_operators: |
mov dl,1Ah |
mov ebx,edi |
lods byte [esi] |
stos byte [edi] |
movzx ecx,al |
jecxz symbol_after_macro_operatorss_ok |
cmp byte [esi],'\' |
je escaped_symbol |
symbol_after_macro_operatorss_ok: |
rep movs byte [edi],[esi] |
jmp after_macro_operators |
string_after_macro_operators: |
mov dl,22h |
mov ebx,edi |
lods dword [esi] |
stos dword [edi] |
mov ecx,eax |
rep movs byte [edi],[esi] |
jmp after_macro_operators |
use_macro: |
push [free_additional_memory] |
push [macro_symbols] |
mov [macro_symbols],0 |
push [counter_limit] |
push dword [edx+4] |
mov dword [edx+4],1 |
push edx |
mov ebx,esi |
mov esi,[edx+8] |
mov eax,[edx+12] |
mov [macro_line],eax |
mov [counter_limit],0 |
process_macro_arguments: |
mov al,[esi] |
or al,al |
jz arguments_end |
cmp al,'{' |
je arguments_end |
inc esi |
cmp al,'[' |
jne get_macro_arguments |
mov ebp,esi |
inc esi |
inc [counter_limit] |
get_macro_arguments: |
call get_macro_argument |
lods byte [esi] |
cmp al,',' |
je next_argument |
cmp al,']' |
je next_arguments_group |
dec esi |
jmp arguments_end |
next_argument: |
cmp byte [ebx],',' |
jne process_macro_arguments |
inc ebx |
jmp process_macro_arguments |
next_arguments_group: |
cmp byte [ebx],',' |
jne arguments_end |
inc ebx |
inc [counter_limit] |
mov esi,ebp |
jmp process_macro_arguments |
get_macro_argument: |
lods byte [esi] |
movzx ecx,al |
mov eax,[counter_limit] |
call add_macro_symbol |
add esi,ecx |
xchg esi,ebx |
mov [edx+12],esi |
cmp byte [esi],'<' |
jne simple_argument |
inc esi |
mov [edx+12],esi |
mov ecx,1 |
enclosed_argument: |
lods byte [esi] |
or al,al |
jz invalid_macro_arguments |
cmp al,1Ah |
je enclosed_symbol |
cmp al,22h |
je enclosed_string |
cmp al,'>' |
je enclosed_argument_end |
cmp al,'<' |
jne enclosed_argument |
inc ecx |
jmp enclosed_argument |
enclosed_symbol: |
movzx eax,byte [esi] |
inc esi |
add esi,eax |
jmp enclosed_argument |
enclosed_string: |
lods dword [esi] |
add esi,eax |
jmp enclosed_argument |
enclosed_argument_end: |
loop enclosed_argument |
mov al,[esi] |
or al,al |
jz enclosed_argument_ok |
cmp al,',' |
jne invalid_macro_arguments |
enclosed_argument_ok: |
mov eax,esi |
sub eax,[edx+12] |
dec eax |
or eax,80000000h |
mov [edx+8],eax |
jmp argument_value_ok |
simple_argument: |
lods byte [esi] |
or al,al |
jz argument_value_end |
cmp al,',' |
je argument_value_end |
cmp al,22h |
je argument_string |
cmp al,1Ah |
jne simple_argument |
movzx eax,byte [esi] |
inc esi |
add esi,eax |
jmp simple_argument |
argument_string: |
lods dword [esi] |
add esi,eax |
jmp simple_argument |
argument_value_end: |
dec esi |
mov eax,esi |
sub eax,[edx+12] |
mov [edx+8],eax |
argument_value_ok: |
xchg esi,ebx |
cmp byte [esi],'*' |
jne macro_argument_ok |
cmp dword [edx+8],0 |
je invalid_macro_arguments |
inc esi |
macro_argument_ok: |
ret |
arguments_end: |
cmp byte [ebx],0 |
jne invalid_macro_arguments |
mov eax,[esp+4] |
dec eax |
call process_macro |
pop edx |
pop dword [edx+4] |
pop [counter_limit] |
pop [macro_symbols] |
pop [free_additional_memory] |
jmp line_preprocessed |
use_instant_macro: |
push edi [current_line] esi |
mov eax,[error_line] |
mov [current_line],eax |
mov [macro_line],eax |
mov esi,[instant_macro_start] |
cmp [base_code],10h |
jae do_match |
cmp [base_code],0 |
jne do_irp |
call get_number |
jc invalid_value |
or ebp,ebp |
jnz invalid_value |
cmp dword [edi+4],0 |
jne value_out_of_range |
mov eax,[edi] |
or eax,eax |
jz instant_macro_done |
cmp eax,80000000h |
jae value_out_of_range |
push [free_additional_memory] |
push [macro_symbols] |
mov [macro_symbols],0 |
push [counter_limit] |
mov [struc_name],0 |
mov [counter_limit],eax |
lods byte [esi] |
or al,al |
jz rept_counters_ok |
cmp al,'{' |
je rept_counters_ok |
cmp al,1Ah |
jne invalid_macro_arguments |
add_rept_counter: |
lods byte [esi] |
movzx ecx,al |
xor eax,eax |
call add_macro_symbol |
add esi,ecx |
xor eax,eax |
mov dword [edx+12],eax |
inc eax |
mov dword [edx+8],eax |
lods byte [esi] |
cmp al,':' |
jne rept_counter_added |
push edx |
call get_number |
jc invalid_value |
or ebp,ebp |
jnz invalid_value |
cmp dword [edi+4],0 |
jne value_out_of_range |
mov eax,[edi] |
mov edx,eax |
add edx,[counter_limit] |
jc value_out_of_range |
pop edx |
mov dword [edx+8],eax |
lods byte [esi] |
rept_counter_added: |
cmp al,',' |
jne rept_counters_ok |
lods byte [esi] |
cmp al,1Ah |
jne invalid_macro_arguments |
jmp add_rept_counter |
rept_counters_ok: |
dec esi |
instant_macro_parameters_ok: |
xor eax,eax |
call process_macro |
pop [counter_limit] |
pop [macro_symbols] |
pop [free_additional_memory] |
instant_macro_done: |
pop ebx esi edx |
cmp byte [ebx],0 |
je line_preprocessed |
mov [current_line],edi |
mov ecx,4 |
rep movs dword [edi],[esi] |
test [macro_status],0Fh |
jz instant_macro_attached_line |
mov ax,3Bh |
stos word [edi] |
instant_macro_attached_line: |
mov esi,ebx |
sub edx,ebx |
mov ecx,edx |
call move_data |
jmp preprocess_current_line |
do_irp: |
cmp byte [esi],1Ah |
jne invalid_macro_arguments |
movzx eax,byte [esi+1] |
lea esi,[esi+2+eax] |
lods byte [esi] |
cmp [base_code],1 |
ja irps_name_ok |
cmp al,'*' |
jne irp_name_ok |
lods byte [esi] |
irp_name_ok: |
cmp al,',' |
jne invalid_macro_arguments |
jmp irp_parameters_start |
irps_name_ok: |
cmp al,',' |
jne invalid_macro_arguments |
mov al,[esi] |
or al,al |
jz instant_macro_done |
cmp al,'{' |
je instant_macro_done |
irp_parameters_start: |
xor eax,eax |
push [free_additional_memory] |
push [macro_symbols] |
mov [macro_symbols],eax |
push [counter_limit] |
mov [counter_limit],eax |
mov [struc_name],eax |
mov ebx,esi |
cmp [base_code],1 |
ja get_irps_parameter |
mov edx,[parameters_end] |
mov al,[edx] |
push eax |
mov byte [edx],0 |
get_irp_parameter: |
inc [counter_limit] |
mov esi,[instant_macro_start] |
inc esi |
call get_macro_argument |
cmp byte [ebx],',' |
jne irp_parameters_end |
inc ebx |
jmp get_irp_parameter |
irp_parameters_end: |
mov esi,ebx |
pop eax |
mov [esi],al |
jmp instant_macro_parameters_ok |
get_irps_parameter: |
mov esi,[instant_macro_start] |
inc esi |
lods byte [esi] |
movzx ecx,al |
inc [counter_limit] |
mov eax,[counter_limit] |
call add_macro_symbol |
mov [edx+12],ebx |
cmp byte [ebx],1Ah |
je irps_symbol |
cmp byte [ebx],22h |
je irps_quoted_string |
mov eax,1 |
jmp irps_parameter_ok |
irps_quoted_string: |
mov eax,[ebx+1] |
add eax,1+4 |
jmp irps_parameter_ok |
irps_symbol: |
movzx eax,byte [ebx+1] |
add eax,1+1 |
irps_parameter_ok: |
mov [edx+8],eax |
add ebx,eax |
cmp byte [ebx],0 |
je irps_parameters_end |
cmp byte [ebx],'{' |
jne get_irps_parameter |
irps_parameters_end: |
mov esi,ebx |
jmp instant_macro_parameters_ok |
do_match: |
mov ebx,esi |
call skip_pattern |
call exact_match |
mov edx,edi |
mov al,[ebx] |
cmp al,1Ah |
je free_match |
cmp al,',' |
jne instant_macro_done |
cmp esi,[parameters_end] |
je matched_pattern |
jmp instant_macro_done |
free_match: |
add edx,12 |
cmp edx,[memory_end] |
ja out_of_memory |
mov [edx-12],ebx |
mov [edx-8],esi |
call skip_match_element |
jc try_different_matching |
mov [edx-4],esi |
movzx eax,byte [ebx+1] |
lea ebx,[ebx+2+eax] |
cmp byte [ebx],1Ah |
je free_match |
find_exact_match: |
call exact_match |
cmp esi,[parameters_end] |
je end_matching |
cmp byte [ebx],1Ah |
je free_match |
mov ebx,[edx-12] |
movzx eax,byte [ebx+1] |
lea ebx,[ebx+2+eax] |
mov esi,[edx-4] |
jmp match_more_elements |
try_different_matching: |
sub edx,12 |
cmp edx,edi |
je instant_macro_done |
mov ebx,[edx-12] |
movzx eax,byte [ebx+1] |
lea ebx,[ebx+2+eax] |
cmp byte [ebx],1Ah |
je try_different_matching |
mov esi,[edx-4] |
match_more_elements: |
call skip_match_element |
jc try_different_matching |
mov [edx-4],esi |
jmp find_exact_match |
skip_match_element: |
cmp esi,[parameters_end] |
je cannot_match |
mov al,[esi] |
cmp al,1Ah |
je skip_match_symbol |
cmp al,22h |
je skip_match_quoted_string |
add esi,1 |
ret |
skip_match_quoted_string: |
mov eax,[esi+1] |
add esi,5 |
jmp skip_match_ok |
skip_match_symbol: |
movzx eax,byte [esi+1] |
add esi,2 |
skip_match_ok: |
add esi,eax |
ret |
cannot_match: |
stc |
ret |
exact_match: |
cmp esi,[parameters_end] |
je exact_match_complete |
mov ah,[esi] |
mov al,[ebx] |
cmp al,',' |
je exact_match_complete |
cmp al,1Ah |
je exact_match_complete |
cmp al,'=' |
je match_verbatim |
call match_elements |
je exact_match |
exact_match_complete: |
ret |
match_verbatim: |
inc ebx |
call match_elements |
je exact_match |
dec ebx |
ret |
match_elements: |
mov al,[ebx] |
cmp al,1Ah |
je match_symbols |
cmp al,22h |
je match_quoted_strings |
cmp al,ah |
je symbol_characters_matched |
ret |
symbol_characters_matched: |
lea ebx,[ebx+1] |
lea esi,[esi+1] |
ret |
match_quoted_strings: |
mov ecx,[ebx+1] |
add ecx,5 |
jmp compare_elements |
match_symbols: |
movzx ecx,byte [ebx+1] |
add ecx,2 |
compare_elements: |
mov eax,esi |
mov ebp,edi |
mov edi,ebx |
repe cmps byte [esi],[edi] |
jne elements_mismatch |
mov ebx,edi |
mov edi,ebp |
ret |
elements_mismatch: |
mov esi,eax |
mov edi,ebp |
ret |
end_matching: |
cmp byte [ebx],',' |
jne instant_macro_done |
matched_pattern: |
xor eax,eax |
push [free_additional_memory] |
push [macro_symbols] |
mov [macro_symbols],eax |
push [counter_limit] |
mov [counter_limit],eax |
mov [struc_name],eax |
push esi edi edx |
add_matched_symbol: |
cmp edi,[esp] |
je matched_symbols_ok |
mov esi,[edi] |
inc esi |
lods byte [esi] |
movzx ecx,al |
xor eax,eax |
call add_macro_symbol |
mov eax,[edi+4] |
mov dword [edx+12],eax |
mov ecx,[edi+8] |
sub ecx,eax |
mov dword [edx+8],ecx |
add edi,12 |
jmp add_matched_symbol |
matched_symbols_ok: |
pop edx edi esi |
jmp instant_macro_parameters_ok |
process_macro: |
push dword [macro_status] |
or [macro_status],10h |
push [counter] |
push [macro_block] |
push [macro_block_line] |
push [macro_block_line_number] |
push [struc_label] |
push [struc_name] |
push eax |
push [current_line] |
lods byte [esi] |
cmp al,'{' |
je macro_instructions_start |
or al,al |
jnz unexpected_characters |
find_macro_instructions: |
mov [macro_line],esi |
add esi,16+2 |
lods byte [esi] |
or al,al |
jz find_macro_instructions |
cmp al,'{' |
je macro_instructions_start |
cmp al,3Bh |
jne unexpected_characters |
call skip_foreign_symbol |
jmp find_macro_instructions |
macro_instructions_start: |
mov ecx,80000000h |
mov [macro_block],esi |
mov eax,[macro_line] |
mov [macro_block_line],eax |
mov [macro_block_line_number],ecx |
xor eax,eax |
mov [counter],eax |
cmp [counter_limit],eax |
je process_macro_line |
inc [counter] |
process_macro_line: |
mov [current_line],edi |
lea eax,[edi+10h] |
cmp eax,[memory_end] |
jae out_of_memory |
mov eax,[esp+4] |
or eax,eax |
jz instant_macro_line_header |
stos dword [edi] |
mov eax,ecx |
stos dword [edi] |
mov eax,[esp] |
stos dword [edi] |
mov eax,[macro_line] |
stos dword [edi] |
jmp macro_line_header_ok |
instant_macro_line_header: |
mov edx,[macro_line] |
mov eax,[edx] |
stos dword [edi] |
mov eax,[edx+4] |
stos dword [edi] |
mov eax,[edx+8] |
stos dword [edi] |
mov eax,[edx+12] |
stos dword [edi] |
macro_line_header_ok: |
or [macro_status],20h |
push ebx ecx |
test [macro_status],0Fh |
jz process_macro_line_element |
mov ax,3Bh |
stos word [edi] |
process_macro_line_element: |
lea eax,[edi+100h] |
cmp eax,[memory_end] |
jae out_of_memory |
lods byte [esi] |
cmp al,'}' |
je macro_line_processed |
or al,al |
jz macro_line_processed |
cmp al,1Ah |
je process_macro_symbol |
cmp al,3Bh |
je macro_foreign_line |
and [macro_status],not 20h |
stos byte [edi] |
cmp al,22h |
jne process_macro_line_element |
copy_macro_string: |
mov ecx,[esi] |
add ecx,4 |
call move_data |
jmp process_macro_line_element |
process_macro_symbol: |
push esi edi |
test [macro_status],20h |
jz not_macro_directive |
movzx ecx,byte [esi] |
inc esi |
mov edi,macro_directives |
call get_directive |
jnc process_macro_directive |
dec esi |
jmp not_macro_directive |
process_macro_directive: |
mov edx,eax |
pop edi eax |
mov byte [edi],0 |
inc edi |
pop ecx ebx |
jmp near edx |
not_macro_directive: |
and [macro_status],not 20h |
movzx ecx,byte [esi] |
inc esi |
mov eax,[counter] |
call get_macro_symbol |
jnc group_macro_symbol |
xor eax,eax |
cmp [counter],eax |
je multiple_macro_symbol_values |
call get_macro_symbol |
jc not_macro_symbol |
replace_macro_symbol: |
pop edi eax |
mov ecx,[edx+8] |
and ecx,not 80000000h |
mov edx,[edx+12] |
or edx,edx |
jz replace_macro_counter |
xchg esi,edx |
call move_data |
mov esi,edx |
jmp process_macro_line_element |
group_macro_symbol: |
xor eax,eax |
cmp [counter],eax |
je replace_macro_symbol |
push esi edx |
sub esi,ecx |
call get_macro_symbol |
mov ebx,edx |
pop edx esi |
jc replace_macro_symbol |
cmp edx,ebx |
ja replace_macro_symbol |
mov edx,ebx |
jmp replace_macro_symbol |
multiple_macro_symbol_values: |
inc eax |
push eax |
call get_macro_symbol |
pop eax |
jc not_macro_symbol |
pop edi |
push ecx |
mov ecx,[edx+8] |
mov edx,[edx+12] |
xchg esi,edx |
btr ecx,31 |
jc enclose_macro_symbol_value |
rep movs byte [edi],[esi] |
jmp macro_symbol_value_ok |
enclose_macro_symbol_value: |
mov byte [edi],'<' |
inc edi |
rep movs byte [edi],[esi] |
mov byte [edi],'>' |
inc edi |
macro_symbol_value_ok: |
cmp eax,[counter_limit] |
je multiple_macro_symbol_values_ok |
mov byte [edi],',' |
inc edi |
mov esi,edx |
pop ecx |
push edi |
sub esi,ecx |
jmp multiple_macro_symbol_values |
multiple_macro_symbol_values_ok: |
pop ecx eax |
mov esi,edx |
jmp process_macro_line_element |
replace_macro_counter: |
mov eax,[counter] |
and eax,not 80000000h |
jz group_macro_counter |
add ecx,eax |
dec ecx |
call store_number_symbol |
jmp process_macro_line_element |
group_macro_counter: |
mov edx,ecx |
xor ecx,ecx |
multiple_macro_counter_values: |
push ecx edx |
add ecx,edx |
call store_number_symbol |
pop edx ecx |
inc ecx |
cmp ecx,[counter_limit] |
je process_macro_line_element |
mov byte [edi],',' |
inc edi |
jmp multiple_macro_counter_values |
store_number_symbol: |
mov ax,1Ah |
stos word [edi] |
push edi |
mov eax,ecx |
mov ecx,1000000000 |
xor edx,edx |
xor bl,bl |
store_number_digits: |
div ecx |
push edx |
or bl,bl |
jnz store_number_digit |
cmp ecx,1 |
je store_number_digit |
or al,al |
jz number_digit_ok |
not bl |
store_number_digit: |
add al,30h |
stos byte [edi] |
number_digit_ok: |
mov eax,ecx |
xor edx,edx |
mov ecx,10 |
div ecx |
mov ecx,eax |
pop eax |
or ecx,ecx |
jnz store_number_digits |
pop ebx |
mov eax,edi |
sub eax,ebx |
mov [ebx-1],al |
ret |
not_macro_symbol: |
pop edi esi |
mov al,1Ah |
stos byte [edi] |
mov al,[esi] |
inc esi |
stos byte [edi] |
cmp byte [esi],'.' |
jne copy_raw_symbol |
mov ebx,[esp+8+8] |
or ebx,ebx |
jz copy_raw_symbol |
cmp al,1 |
je copy_struc_name |
xchg esi,ebx |
movzx ecx,byte [esi-1] |
add [edi-1],cl |
jc name_too_long |
rep movs byte [edi],[esi] |
xchg esi,ebx |
copy_raw_symbol: |
movzx ecx,al |
rep movs byte [edi],[esi] |
jmp process_macro_line_element |
copy_struc_name: |
inc esi |
xchg esi,ebx |
movzx ecx,byte [esi-1] |
mov [edi-1],cl |
rep movs byte [edi],[esi] |
xchg esi,ebx |
mov eax,[esp+8+12] |
cmp byte [eax],3Bh |
je process_macro_line_element |
cmp byte [eax],1Ah |
jne disable_replaced_struc_name |
mov byte [eax],3Bh |
jmp process_macro_line_element |
disable_replaced_struc_name: |
mov ebx,[esp+8+8] |
push esi edi |
lea edi,[ebx-3] |
lea esi,[edi-2] |
lea ecx,[esi+1] |
sub ecx,eax |
std |
rep movs byte [edi],[esi] |
cld |
mov word [eax],3Bh |
pop edi esi |
jmp process_macro_line_element |
skip_foreign_symbol: |
lods byte [esi] |
movzx eax,al |
add esi,eax |
skip_foreign_line: |
lods byte [esi] |
cmp al,1Ah |
je skip_foreign_symbol |
cmp al,3Bh |
je skip_foreign_symbol |
cmp al,22h |
je skip_foreign_string |
or al,al |
jnz skip_foreign_line |
ret |
skip_foreign_string: |
lods dword [esi] |
add esi,eax |
jmp skip_foreign_line |
macro_foreign_line: |
call skip_foreign_symbol |
macro_line_processed: |
mov byte [edi],0 |
inc edi |
push eax |
call preprocess_line |
pop eax |
pop ecx ebx |
cmp al,'}' |
je macro_block_processed |
process_next_line: |
inc ecx |
mov [macro_line],esi |
add esi,16+2 |
jmp process_macro_line |
macro_block_processed: |
call close_macro_block |
jc process_macro_line |
pop [current_line] |
add esp,12 |
pop [macro_block_line_number] |
pop [macro_block_line] |
pop [macro_block] |
pop [counter] |
pop eax |
and al,0F0h |
and [macro_status],0Fh |
or [macro_status],al |
ret |
local_symbols: |
lods byte [esi] |
cmp al,1Ah |
jne invalid_argument |
mov byte [edi-1],3Bh |
xor al,al |
stos byte [edi] |
make_local_symbol: |
push ecx |
lods byte [esi] |
movzx ecx,al |
mov eax,[counter] |
call add_macro_symbol |
mov [edx+12],edi |
movzx eax,[locals_counter] |
add eax,ecx |
inc eax |
cmp eax,100h |
jae name_too_long |
lea ebp,[edi+2+eax] |
cmp ebp,[memory_end] |
jae out_of_memory |
mov ah,al |
mov al,1Ah |
stos word [edi] |
rep movs byte [edi],[esi] |
mov al,'?' |
stos byte [edi] |
push esi |
mov esi,locals_counter+1 |
movzx ecx,[locals_counter] |
rep movs byte [edi],[esi] |
pop esi |
mov eax,edi |
sub eax,[edx+12] |
mov [edx+8],eax |
xor al,al |
stos byte [edi] |
mov eax,locals_counter |
movzx ecx,byte [eax] |
counter_loop: |
inc byte [eax+ecx] |
cmp byte [eax+ecx],':' |
jb counter_ok |
jne letter_digit |
mov byte [eax+ecx],'A' |
jmp counter_ok |
letter_digit: |
cmp byte [eax+ecx],'F' |
jbe counter_ok |
mov byte [eax+ecx],'0' |
loop counter_loop |
counter_ok: |
pop ecx |
lods byte [esi] |
cmp al,'}' |
je macro_block_processed |
or al,al |
jz process_next_line |
cmp al,',' |
jne extra_characters_on_line |
dec edi |
lods byte [esi] |
cmp al,1Ah |
je make_local_symbol |
jmp invalid_argument |
common_block: |
call close_macro_block |
jc process_macro_line |
mov [counter],0 |
jmp new_macro_block |
forward_block: |
cmp [counter_limit],0 |
je common_block |
call close_macro_block |
jc process_macro_line |
mov [counter],1 |
jmp new_macro_block |
reverse_block: |
cmp [counter_limit],0 |
je common_block |
call close_macro_block |
jc process_macro_line |
mov eax,[counter_limit] |
or eax,80000000h |
mov [counter],eax |
new_macro_block: |
mov [macro_block],esi |
mov eax,[macro_line] |
mov [macro_block_line],eax |
mov [macro_block_line_number],ecx |
jmp process_macro_line |
close_macro_block: |
cmp [counter],0 |
je block_closed |
jl reverse_counter |
mov eax,[counter] |
cmp eax,[counter_limit] |
je block_closed |
inc [counter] |
jmp continue_block |
reverse_counter: |
mov eax,[counter] |
dec eax |
cmp eax,80000000h |
je block_closed |
mov [counter],eax |
continue_block: |
mov esi,[macro_block] |
mov eax,[macro_block_line] |
mov [macro_line],eax |
mov ecx,[macro_block_line_number] |
stc |
ret |
block_closed: |
clc |
ret |
get_macro_symbol: |
push ecx |
call find_macro_symbol_leaf |
jc macro_symbol_not_found |
mov edx,[ebx] |
mov ebx,esi |
try_macro_symbol: |
or edx,edx |
jz macro_symbol_not_found |
mov ecx,[esp] |
mov edi,[edx+4] |
repe cmps byte [esi],[edi] |
je macro_symbol_found |
mov esi,ebx |
mov edx,[edx] |
jmp try_macro_symbol |
macro_symbol_found: |
pop ecx |
clc |
ret |
macro_symbol_not_found: |
pop ecx |
stc |
ret |
find_macro_symbol_leaf: |
shl eax,8 |
mov al,cl |
mov ebp,eax |
mov ebx,macro_symbols |
follow_macro_symbols_tree: |
mov edx,[ebx] |
or edx,edx |
jz no_such_macro_symbol |
xor eax,eax |
shr ebp,1 |
adc eax,0 |
lea ebx,[edx+eax*4] |
or ebp,ebp |
jnz follow_macro_symbols_tree |
add ebx,8 |
clc |
ret |
no_such_macro_symbol: |
stc |
ret |
add_macro_symbol: |
push ebx ebp |
call find_macro_symbol_leaf |
jc extend_macro_symbol_tree |
mov eax,[ebx] |
make_macro_symbol: |
mov edx,[free_additional_memory] |
add edx,16 |
cmp edx,[labels_list] |
ja out_of_memory |
xchg edx,[free_additional_memory] |
mov [ebx],edx |
mov [edx],eax |
mov [edx+4],esi |
pop ebp ebx |
ret |
extend_macro_symbol_tree: |
mov edx,[free_additional_memory] |
add edx,16 |
cmp edx,[labels_list] |
ja out_of_memory |
xchg edx,[free_additional_memory] |
xor eax,eax |
mov [edx],eax |
mov [edx+4],eax |
mov [edx+8],eax |
mov [edx+12],eax |
shr ebp,1 |
adc eax,0 |
mov [ebx],edx |
lea ebx,[edx+eax*4] |
or ebp,ebp |
jnz extend_macro_symbol_tree |
add ebx,8 |
xor eax,eax |
jmp make_macro_symbol |
include_file: |
lods byte [esi] |
cmp al,22h |
jne invalid_argument |
lods dword [esi] |
cmp byte [esi+eax],0 |
jne extra_characters_on_line |
push esi |
push edi |
mov ebx,[current_line] |
find_current_file_path: |
mov esi,[ebx] |
test byte [ebx+7],80h |
jz copy_current_file_path |
mov ebx,[ebx+8] |
jmp find_current_file_path |
copy_current_file_path: |
lods byte [esi] |
stos byte [edi] |
or al,al |
jnz copy_current_file_path |
cut_current_file_name: |
cmp edi,[esp] |
je current_file_path_ok |
cmp byte [edi-1],'\' |
je current_file_path_ok |
cmp byte [edi-1],'/' |
je current_file_path_ok |
dec edi |
jmp cut_current_file_name |
current_file_path_ok: |
mov esi,[esp+4] |
call preprocess_path |
pop edx |
mov esi,edx |
call open |
jnc include_path_ok |
mov ebp,[include_paths] |
try_include_directories: |
mov edi,esi |
mov esi,ebp |
cmp byte [esi],0 |
je try_in_current_directory |
push ebp |
push edi |
copy_include_directory: |
lods byte [esi] |
cmp al,';' |
je include_directory_ok |
stos byte [edi] |
or al,al |
jnz copy_include_directory |
dec esi |
dec edi |
include_directory_ok: |
cmp byte [edi-1],'/' |
je path_separator_ok |
cmp byte [edi-1],'\' |
je path_separator_ok |
mov al,'/' |
stos byte [edi] |
path_separator_ok: |
mov [esp+4],esi |
mov esi,[esp+8] |
call preprocess_path |
pop edx |
mov esi,edx |
call open |
pop ebp |
jnc include_path_ok |
jmp try_include_directories |
mov edi,esi |
try_in_current_directory: |
mov esi,[esp] |
push edi |
call preprocess_path |
pop edx |
mov esi,edx |
call open |
jc file_not_found |
include_path_ok: |
mov edi,[esp] |
copy_preprocessed_path: |
lods byte [esi] |
stos byte [edi] |
or al,al |
jnz copy_preprocessed_path |
pop esi |
lea ecx,[edi-1] |
sub ecx,esi |
mov [esi-4],ecx |
push dword [macro_status] |
and [macro_status],0Fh |
call preprocess_file |
pop eax |
mov [macro_status],al |
jmp line_preprocessed |
preprocess_path: |
lods byte [esi] |
cmp al,'%' |
je environment_variable |
stos byte [edi] |
or al,al |
jnz preprocess_path |
cmp edi,[memory_end] |
ja out_of_memory |
ret |
environment_variable: |
mov ebx,esi |
find_variable_end: |
lods byte [esi] |
or al,al |
jz not_environment_variable |
cmp al,'%' |
jne find_variable_end |
mov byte [esi-1],0 |
push esi |
mov esi,ebx |
call get_environment_variable |
pop esi |
mov byte [esi-1],'%' |
jmp preprocess_path |
not_environment_variable: |
mov al,'%' |
stos byte [edi] |
mov esi,ebx |
jmp preprocess_path |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/fasm/trunk/variable.inc |
---|
0,0 → 1,119 |
; flat assembler core variables |
; Copyright (c) 1999-2006, Tomasz Grysztar. |
; All rights reserved. |
; Variables which have to be set up by interface: |
memory_start dd ? |
memory_end dd ? |
additional_memory dd ? |
additional_memory_end dd ? |
stack_limit dd ? |
input_file dd ? |
output_file dd ? |
passes_limit dw ? |
; Internal core variables: |
current_pass dw ? |
include_paths dd ? |
free_additional_memory dd ? |
source_start dd ? |
code_start dd ? |
code_size dd ? |
real_code_size dd ? |
written_size dd ? |
headers_size dd ? |
current_line dd ? |
macro_line dd ? |
macro_block dd ? |
macro_block_line dd ? |
macro_block_line_number dd ? |
macro_symbols dd ? |
struc_name dd ? |
struc_label dd ? |
instant_macro_start dd ? |
parameters_end dd ? |
locals_counter rb 8 |
current_locals_prefix dd ? |
anonymous_reverse dd ? |
anonymous_forward dd ? |
labels_list dd ? |
label_hash dd ? |
label_leaf dd ? |
hash_tree dd ? |
org_origin dq ? |
org_registers dd ? |
org_start dd ? |
org_symbol dd ? |
undefined_data_start dd ? |
undefined_data_end dd ? |
counter dd ? |
counter_limit dd ? |
error_line dd ? |
error dd ? |
display_buffer dd ? |
structures_buffer dd ? |
number_start dd ? |
current_offset dd ? |
value dq ? |
fp_value rd 8 |
adjustment dq ? |
symbol_identifier dd ? |
address_symbol dd ? |
address_high dd ? |
format_flags dd ? |
resolver_flags dd ? |
symbols_stream dd ? |
number_of_relocations dd ? |
number_of_sections dd ? |
stub_size dd ? |
stub_file dd ? |
current_section dd ? |
machine dw ? |
subsystem dw ? |
subsystem_version dd ? |
image_base dd ? |
image_base_high dd ? |
resource_data dd ? |
resource_size dd ? |
parenthesis_stack dd ? |
blocks_stack dd ? |
next_pass_needed db ? |
macro_status db ? |
output_format db ? |
code_type db ? |
labels_type db ? |
prefixed_instruction db ? |
virtual_data db ? |
fp_sign db ? |
fp_format db ? |
value_size db ? |
size_override db ? |
address_size db ? |
operand_size db ? |
size_declared db ? |
value_undefined db ? |
value_type db ? |
compare_type db ? |
base_code db ? |
extended_code db ? |
postbyte_register db ? |
segment_register db ? |
mmx_size db ? |
jump_type db ? |
push_size db ? |
operand_prefix db ? |
rex_prefix db ? |
immediate_size db ? |
characters rb 100h |
converted rb 100h |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/fasm/trunk/version.inc |
---|
0,0 → 1,39 |
; flat assembler version 1.67 |
; Copyright (c) 1999-2006, Tomasz Grysztar. |
; All rights reserved. |
; |
; This programs is free for commercial and non-commercial use as long as |
; the following conditions are adhered to. |
; |
; Redistribution and use in source and binary forms, with or without |
; modification, are permitted provided that the following conditions are |
; met: |
; |
; 1. Redistributions of source code must retain the above copyright notice, |
; this list of conditions and the following disclaimer. |
; 2. Redistributions in binary form must reproduce the above copyright |
; notice, this list of conditions and the following disclaimer in the |
; documentation and/or other materials provided with the distribution. |
; |
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
; PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR |
; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
; |
; The licence and distribution terms for any publically available |
; version or derivative of this code cannot be changed. i.e. this code |
; cannot simply be copied and put under another distribution licence |
; (including the GNU Public Licence). |
VERSION_STRING equ "1.67.5" |
VERSION_MAJOR = 1 |
VERSION_MINOR = 67 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/fasm/trunk/x86_64.inc |
---|
0,0 → 1,6495 |
; flat assembler core |
; Copyright (c) 1999-2006, Tomasz Grysztar. |
; All rights reserved. |
simple_instruction_except64: |
cmp [code_type],64 |
je illegal_instruction |
simple_instruction: |
stos byte [edi] |
jmp instruction_assembled |
simple_instruction_only64: |
cmp [code_type],64 |
jne illegal_instruction |
jmp simple_instruction |
simple_instruction_16bit_except64: |
cmp [code_type],64 |
je illegal_instruction |
simple_instruction_16bit: |
cmp [code_type],16 |
jne size_prefix |
stos byte [edi] |
jmp instruction_assembled |
size_prefix: |
mov ah,al |
mov al,66h |
stos word [edi] |
jmp instruction_assembled |
simple_instruction_32bit_except64: |
cmp [code_type],64 |
je illegal_instruction |
simple_instruction_32bit: |
cmp [code_type],16 |
je size_prefix |
stos byte [edi] |
jmp instruction_assembled |
simple_instruction_64bit: |
cmp [code_type],64 |
jne illegal_instruction |
mov ah,al |
mov al,48h |
stos word [edi] |
jmp instruction_assembled |
simple_extended_instruction: |
mov ah,al |
mov al,0Fh |
stos word [edi] |
jmp instruction_assembled |
prefix_instruction: |
stos byte [edi] |
or [prefixed_instruction],-1 |
jmp continue_line |
segment_prefix: |
mov ah,al |
shr ah,4 |
cmp ah,6 |
jne illegal_instruction |
and al,1111b |
mov [segment_register],al |
call store_segment_prefix |
or [prefixed_instruction],-1 |
jmp continue_line |
int_instruction: |
lods byte [esi] |
call get_size_operator |
cmp ah,1 |
ja invalid_operand_size |
cmp al,'(' |
jne invalid_operand |
call get_byte_value |
mov ah,al |
mov al,0CDh |
stos word [edi] |
jmp instruction_assembled |
iret_instruction: |
cmp [code_type],64 |
jne simple_instruction |
call operand_64bit |
jmp simple_instruction |
aa_instruction: |
cmp [code_type],64 |
je illegal_instruction |
push eax |
mov bl,10 |
cmp byte [esi],'(' |
jne aa_store |
inc esi |
xor al,al |
xchg al,[operand_size] |
cmp al,1 |
ja invalid_operand_size |
call get_byte_value |
mov bl,al |
aa_store: |
cmp [operand_size],0 |
jne invalid_operand |
pop eax |
mov ah,bl |
stos word [edi] |
jmp instruction_assembled |
basic_instruction: |
mov [base_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je basic_reg |
cmp al,'[' |
jne invalid_operand |
basic_mem: |
call get_address |
push edx bx cx |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'(' |
je basic_mem_imm |
cmp al,10h |
jne invalid_operand |
basic_mem_reg: |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
pop cx bx edx |
mov al,ah |
cmp al,1 |
je basic_mem_reg_8bit |
call operand_autodetect |
inc [base_code] |
basic_mem_reg_8bit: |
call store_instruction |
jmp instruction_assembled |
basic_mem_imm: |
mov al,[operand_size] |
cmp al,1 |
je basic_mem_imm_8bit |
cmp al,2 |
je basic_mem_imm_16bit |
cmp al,4 |
je basic_mem_imm_32bit |
cmp al,8 |
je basic_mem_imm_64bit |
or al,al |
jnz invalid_operand_size |
cmp [error_line],0 |
jne basic_mem_imm_8bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
basic_mem_imm_8bit: |
call get_byte_value |
mov byte [value],al |
mov al,[base_code] |
shr al,3 |
mov [postbyte_register],al |
pop cx bx edx |
mov [base_code],80h |
call store_instruction_with_imm8 |
jmp instruction_assembled |
basic_mem_imm_16bit: |
call operand_16bit |
call get_word_value |
mov word [value],ax |
mov al,[base_code] |
shr al,3 |
mov [postbyte_register],al |
pop cx bx edx |
cmp [value_type],0 |
jne basic_mem_imm_16bit_store |
cmp [size_declared],0 |
jne basic_mem_imm_16bit_store |
cmp word [value],80h |
jb basic_mem_simm_8bit |
cmp word [value],-80h |
jae basic_mem_simm_8bit |
basic_mem_imm_16bit_store: |
mov [base_code],81h |
call store_instruction_with_imm16 |
jmp instruction_assembled |
basic_mem_simm_8bit: |
mov [base_code],83h |
call store_instruction_with_imm8 |
jmp instruction_assembled |
basic_mem_imm_32bit: |
call operand_32bit |
call get_dword_value |
basic_mem_imm_32bit_ok: |
mov dword [value],eax |
mov al,[base_code] |
shr al,3 |
mov [postbyte_register],al |
pop cx bx edx |
cmp [value_type],0 |
jne basic_mem_imm_32bit_store |
cmp [size_declared],0 |
jne basic_mem_imm_32bit_store |
cmp dword [value],80h |
jb basic_mem_simm_8bit |
cmp dword [value],-80h |
jae basic_mem_simm_8bit |
basic_mem_imm_32bit_store: |
mov [base_code],81h |
call store_instruction_with_imm32 |
jmp instruction_assembled |
basic_mem_imm_64bit: |
cmp [size_declared],0 |
jne long_immediate_not_encodable |
call operand_64bit |
call get_simm32 |
cmp [value_type],4 |
jae long_immediate_not_encodable |
jmp basic_mem_imm_32bit_ok |
get_simm32: |
call get_qword_value |
mov ecx,edx |
cdq |
cmp ecx,edx |
jne value_out_of_range |
ret |
basic_reg: |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je basic_reg_reg |
cmp al,'(' |
je basic_reg_imm |
cmp al,'[' |
jne invalid_operand |
basic_reg_mem: |
call get_address |
mov al,[operand_size] |
cmp al,1 |
je basic_reg_mem_8bit |
call operand_autodetect |
add [base_code],3 |
call store_instruction |
jmp instruction_assembled |
basic_reg_mem_8bit: |
add [base_code],2 |
call store_instruction |
jmp instruction_assembled |
basic_reg_reg: |
lods byte [esi] |
call convert_register |
mov bl,[postbyte_register] |
mov [postbyte_register],al |
mov al,ah |
cmp al,1 |
je basic_reg_reg_8bit |
call operand_autodetect |
inc [base_code] |
basic_reg_reg_8bit: |
call store_nomem_instruction |
jmp instruction_assembled |
basic_reg_imm: |
mov al,[operand_size] |
cmp al,1 |
je basic_reg_imm_8bit |
cmp al,2 |
je basic_reg_imm_16bit |
cmp al,4 |
je basic_reg_imm_32bit |
cmp al,8 |
je basic_reg_imm_64bit |
or al,al |
jnz invalid_operand_size |
cmp [error_line],0 |
jne basic_reg_imm_32bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
jmp basic_reg_imm_32bit |
basic_reg_imm_8bit: |
call get_byte_value |
mov dl,al |
mov bl,[base_code] |
shr bl,3 |
xchg bl,[postbyte_register] |
or bl,bl |
jz basic_al_imm |
mov [base_code],80h |
call store_nomem_instruction |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
basic_al_imm: |
mov al,[base_code] |
add al,4 |
stos byte [edi] |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
basic_reg_imm_16bit: |
call operand_16bit |
call get_word_value |
mov dx,ax |
mov bl,[base_code] |
shr bl,3 |
xchg bl,[postbyte_register] |
cmp [value_type],0 |
jne basic_reg_imm_16bit_store |
cmp [size_declared],0 |
jne basic_reg_imm_16bit_store |
cmp dx,80h |
jb basic_reg_simm_8bit |
cmp dx,-80h |
jae basic_reg_simm_8bit |
basic_reg_imm_16bit_store: |
or bl,bl |
jz basic_ax_imm |
mov [base_code],81h |
call store_nomem_instruction |
mov ax,dx |
call mark_relocation |
stos word [edi] |
jmp instruction_assembled |
basic_reg_simm_8bit: |
mov [base_code],83h |
call store_nomem_instruction |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
basic_ax_imm: |
add [base_code],5 |
call store_instruction_code |
mov ax,dx |
call mark_relocation |
stos word [edi] |
jmp instruction_assembled |
basic_reg_imm_32bit: |
call operand_32bit |
call get_dword_value |
basic_reg_imm_32bit_ok: |
mov edx,eax |
mov bl,[base_code] |
shr bl,3 |
xchg bl,[postbyte_register] |
cmp [value_type],0 |
jne basic_reg_imm_32bit_store |
cmp [size_declared],0 |
jne basic_reg_imm_32bit_store |
cmp edx,80h |
jb basic_reg_simm_8bit |
cmp edx,-80h |
jae basic_reg_simm_8bit |
basic_reg_imm_32bit_store: |
or bl,bl |
jz basic_eax_imm |
mov [base_code],81h |
call store_nomem_instruction |
mov eax,edx |
call mark_relocation |
stos dword [edi] |
jmp instruction_assembled |
basic_eax_imm: |
add [base_code],5 |
call store_instruction_code |
mov eax,edx |
call mark_relocation |
stos dword [edi] |
jmp instruction_assembled |
basic_reg_imm_64bit: |
cmp [size_declared],0 |
jne long_immediate_not_encodable |
call operand_64bit |
call get_simm32 |
cmp [value_type],4 |
jae long_immediate_not_encodable |
jmp basic_reg_imm_32bit_ok |
single_operand_instruction: |
mov [base_code],0F6h |
mov [postbyte_register],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je single_reg |
cmp al,'[' |
jne invalid_operand |
single_mem: |
call get_address |
mov al,[operand_size] |
cmp al,1 |
je single_mem_8bit |
jb single_mem_nosize |
call operand_autodetect |
inc [base_code] |
call store_instruction |
jmp instruction_assembled |
single_mem_nosize: |
cmp [error_line],0 |
jne single_mem_8bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
single_mem_8bit: |
call store_instruction |
jmp instruction_assembled |
single_reg: |
lods byte [esi] |
call convert_register |
mov bl,al |
mov al,ah |
cmp al,1 |
je single_reg_8bit |
call operand_autodetect |
inc [base_code] |
single_reg_8bit: |
call store_nomem_instruction |
jmp instruction_assembled |
mov_instruction: |
mov [base_code],88h |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je mov_reg |
cmp al,'[' |
jne invalid_operand |
mov_mem: |
call get_address |
push edx bx cx |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'(' |
je mov_mem_imm |
cmp al,10h |
jne invalid_operand |
mov_mem_reg: |
lods byte [esi] |
cmp al,60h |
jb mov_mem_general_reg |
cmp al,70h |
jb mov_mem_sreg |
mov_mem_general_reg: |
call convert_register |
mov [postbyte_register],al |
pop cx bx edx |
cmp ah,1 |
je mov_mem_reg_8bit |
mov al,ah |
call operand_autodetect |
mov al,[postbyte_register] |
or al,bl |
or al,bh |
jz mov_mem_ax |
inc [base_code] |
call store_instruction |
jmp instruction_assembled |
mov_mem_reg_8bit: |
or al,bl |
or al,bh |
jz mov_mem_al |
call store_instruction |
jmp instruction_assembled |
mov_mem_al: |
test ch,22h |
jnz mov_mem_address16_al |
test ch,44h |
jnz mov_mem_address32_al |
test ch,88h |
jnz mov_mem_address64_al |
or ch,ch |
jnz invalid_address_size |
cmp [code_type],64 |
je mov_mem_address64_al |
cmp [code_type],32 |
je mov_mem_address32_al |
cmp edx,10000h |
jb mov_mem_address16_al |
mov_mem_address32_al: |
call store_segment_prefix_if_necessary |
call address_32bit_prefix |
mov [base_code],0A2h |
store_mov_address32: |
call store_instruction_code |
push instruction_assembled |
jmp store_address_32bit_value |
mov_mem_address16_al: |
call store_segment_prefix_if_necessary |
call address_16bit_prefix |
mov [base_code],0A2h |
store_mov_address16: |
cmp [code_type],64 |
je invalid_address |
call store_instruction_code |
mov eax,edx |
stos word [edi] |
cmp edx,10000h |
jge value_out_of_range |
jmp instruction_assembled |
mov_mem_address64_al: |
call store_segment_prefix_if_necessary |
mov [base_code],0A2h |
store_mov_address64: |
call store_instruction_code |
push instruction_assembled |
jmp store_address_64bit_value |
mov_mem_ax: |
test ch,22h |
jnz mov_mem_address16_ax |
test ch,44h |
jnz mov_mem_address32_ax |
test ch,88h |
jnz mov_mem_address64_ax |
or ch,ch |
jnz invalid_address_size |
cmp [code_type],64 |
je mov_mem_address64_ax |
cmp [code_type],32 |
je mov_mem_address32_ax |
cmp edx,10000h |
jb mov_mem_address16_ax |
mov_mem_address32_ax: |
call store_segment_prefix_if_necessary |
call address_32bit_prefix |
mov [base_code],0A3h |
jmp store_mov_address32 |
mov_mem_address16_ax: |
call store_segment_prefix_if_necessary |
call address_16bit_prefix |
mov [base_code],0A3h |
jmp store_mov_address16 |
mov_mem_address64_ax: |
call store_segment_prefix_if_necessary |
mov [base_code],0A3h |
jmp store_mov_address64 |
mov_mem_sreg: |
sub al,61h |
mov [postbyte_register],al |
pop cx bx edx |
mov ah,[operand_size] |
or ah,ah |
jz mov_mem_sreg_store |
cmp ah,2 |
jne invalid_operand_size |
mov_mem_sreg_store: |
mov [base_code],8Ch |
call store_instruction |
jmp instruction_assembled |
mov_mem_imm: |
mov al,[operand_size] |
cmp al,1 |
je mov_mem_imm_8bit |
cmp al,2 |
je mov_mem_imm_16bit |
cmp al,4 |
je mov_mem_imm_32bit |
cmp al,8 |
je mov_mem_imm_64bit |
or al,al |
jnz invalid_operand_size |
cmp [error_line],0 |
jne mov_mem_imm_32bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
jmp mov_mem_imm_32bit |
mov_mem_imm_8bit: |
call get_byte_value |
mov byte [value],al |
mov [postbyte_register],0 |
mov [base_code],0C6h |
pop cx bx edx |
call store_instruction_with_imm8 |
jmp instruction_assembled |
mov_mem_imm_16bit: |
call operand_16bit |
call get_word_value |
mov word [value],ax |
mov [postbyte_register],0 |
mov [base_code],0C7h |
pop cx bx edx |
call store_instruction_with_imm16 |
jmp instruction_assembled |
mov_mem_imm_32bit: |
call operand_32bit |
call get_dword_value |
mov_mem_imm_32bit_store: |
mov dword [value],eax |
mov [postbyte_register],0 |
mov [base_code],0C7h |
pop cx bx edx |
call store_instruction_with_imm32 |
jmp instruction_assembled |
mov_mem_imm_64bit: |
cmp [size_declared],0 |
jne long_immediate_not_encodable |
call operand_64bit |
call get_simm32 |
cmp [value_type],4 |
jae long_immediate_not_encodable |
jmp mov_mem_imm_32bit_store |
mov_reg: |
lods byte [esi] |
mov ah,al |
sub ah,10h |
and ah,al |
test ah,0F0h |
jnz mov_sreg |
call convert_register |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
je mov_reg_mem |
cmp al,'(' |
je mov_reg_imm |
cmp al,10h |
jne invalid_operand |
mov_reg_reg: |
lods byte [esi] |
mov ah,al |
sub ah,10h |
and ah,al |
test ah,0F0h |
jnz mov_reg_sreg |
call convert_register |
mov bl,[postbyte_register] |
mov [postbyte_register],al |
mov al,ah |
cmp al,1 |
je mov_reg_reg_8bit |
call operand_autodetect |
inc [base_code] |
mov_reg_reg_8bit: |
call store_nomem_instruction |
jmp instruction_assembled |
mov_reg_sreg: |
mov bl,[postbyte_register] |
mov ah,al |
and al,1111b |
mov [postbyte_register],al |
shr ah,4 |
cmp ah,5 |
je mov_reg_creg |
cmp ah,7 |
je mov_reg_dreg |
ja mov_reg_treg |
dec [postbyte_register] |
cmp [operand_size],8 |
je mov_reg_sreg64 |
cmp [operand_size],4 |
je mov_reg_sreg32 |
cmp [operand_size],2 |
jne invalid_operand_size |
call operand_16bit |
jmp mov_reg_sreg_store |
mov_reg_sreg64: |
call operand_64bit |
jmp mov_reg_sreg_store |
mov_reg_sreg32: |
call operand_32bit |
mov_reg_sreg_store: |
mov [base_code],8Ch |
call store_nomem_instruction |
jmp instruction_assembled |
mov_reg_treg: |
cmp ah,9 |
jne invalid_operand |
mov [extended_code],24h |
jmp mov_reg_xrx |
mov_reg_dreg: |
mov [extended_code],21h |
jmp mov_reg_xrx |
mov_reg_creg: |
mov [extended_code],20h |
mov_reg_xrx: |
mov [base_code],0Fh |
cmp [code_type],64 |
je mov_reg_xrx_64bit |
cmp [operand_size],4 |
jne invalid_operand_size |
cmp [postbyte_register],8 |
jne mov_reg_xrx_store |
cmp [extended_code],20h |
jne mov_reg_xrx_store |
mov al,0F0h |
stos byte [edi] |
mov [postbyte_register],0 |
mov_reg_xrx_store: |
call store_nomem_instruction |
jmp instruction_assembled |
mov_reg_xrx_64bit: |
cmp [operand_size],8 |
jne invalid_operand_size |
call store_nomem_instruction |
jmp instruction_assembled |
mov_reg_mem: |
call get_address |
mov al,[operand_size] |
cmp al,1 |
je mov_reg_mem_8bit |
call operand_autodetect |
mov al,[postbyte_register] |
or al,bl |
or al,bh |
jz mov_ax_mem |
add [base_code],3 |
call store_instruction |
jmp instruction_assembled |
mov_reg_mem_8bit: |
mov al,[postbyte_register] |
or al,bl |
or al,bh |
jz mov_al_mem |
add [base_code],2 |
call store_instruction |
jmp instruction_assembled |
mov_al_mem: |
test ch,22h |
jnz mov_al_mem_address16 |
test ch,44h |
jnz mov_al_mem_address32 |
test ch,88h |
jnz mov_al_mem_address64 |
or ch,ch |
jnz invalid_address_size |
cmp [code_type],64 |
je mov_al_mem_address64 |
cmp [code_type],32 |
je mov_al_mem_address32 |
cmp edx,10000h |
jb mov_al_mem_address16 |
mov_al_mem_address32: |
call store_segment_prefix_if_necessary |
call address_32bit_prefix |
mov [base_code],0A0h |
jmp store_mov_address32 |
mov_al_mem_address16: |
call store_segment_prefix_if_necessary |
call address_16bit_prefix |
mov [base_code],0A0h |
jmp store_mov_address16 |
mov_al_mem_address64: |
call store_segment_prefix_if_necessary |
mov [base_code],0A0h |
jmp store_mov_address64 |
mov_ax_mem: |
test ch,22h |
jnz mov_ax_mem_address16 |
test ch,44h |
jnz mov_ax_mem_address32 |
test ch,88h |
jnz mov_ax_mem_address64 |
or ch,ch |
jnz invalid_address_size |
cmp [code_type],64 |
je mov_ax_mem_address64 |
cmp [code_type],32 |
je mov_ax_mem_address32 |
cmp edx,10000h |
jb mov_ax_mem_address16 |
mov_ax_mem_address32: |
call store_segment_prefix_if_necessary |
call address_32bit_prefix |
mov [base_code],0A1h |
jmp store_mov_address32 |
mov_ax_mem_address16: |
call store_segment_prefix_if_necessary |
call address_16bit_prefix |
mov [base_code],0A1h |
jmp store_mov_address16 |
mov_ax_mem_address64: |
call store_segment_prefix_if_necessary |
mov [base_code],0A1h |
jmp store_mov_address64 |
mov_reg_imm: |
mov al,[operand_size] |
cmp al,1 |
je mov_reg_imm_8bit |
cmp al,2 |
je mov_reg_imm_16bit |
cmp al,4 |
je mov_reg_imm_32bit |
cmp al,8 |
je mov_reg_imm_64bit |
or al,al |
jnz invalid_operand_size |
cmp [error_line],0 |
jne mov_reg_imm_32bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
jmp mov_reg_imm_32bit |
mov_reg_imm_8bit: |
call get_byte_value |
mov dl,al |
mov al,0B0h |
call store_mov_reg_imm_code |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
mov_reg_imm_16bit: |
call get_word_value |
mov dx,ax |
call operand_16bit |
mov al,0B8h |
call store_mov_reg_imm_code |
mov ax,dx |
call mark_relocation |
stos word [edi] |
jmp instruction_assembled |
mov_reg_imm_32bit: |
call operand_32bit |
call get_dword_value |
mov edx,eax |
mov al,0B8h |
call store_mov_reg_imm_code |
mov eax,edx |
call mark_relocation |
stos dword [edi] |
jmp instruction_assembled |
mov_reg_imm_64bit: |
call operand_64bit |
call get_qword_value |
mov ecx,edx |
cmp [size_declared],0 |
jne mov_reg_imm_64bit_store |
cmp [value_type],4 |
jae mov_reg_imm_64bit_store |
cdq |
cmp ecx,edx |
je mov_reg_64bit_imm_32bit |
mov_reg_imm_64bit_store: |
push eax ecx |
mov al,0B8h |
call store_mov_reg_imm_code |
pop edx eax |
call mark_relocation |
stos dword [edi] |
mov eax,edx |
stos dword [edi] |
jmp instruction_assembled |
store_mov_reg_imm_code: |
mov ah,[postbyte_register] |
test ah,1000b |
jz mov_reg_imm_prefix_ok |
or [rex_prefix],41h |
mov_reg_imm_prefix_ok: |
and ah,111b |
add al,ah |
mov [base_code],al |
call store_instruction_code |
ret |
mov_reg_64bit_imm_32bit: |
mov edx,eax |
mov bl,[postbyte_register] |
mov [postbyte_register],0 |
mov [base_code],0C7h |
call store_nomem_instruction |
mov eax,edx |
call mark_relocation |
stos dword [edi] |
jmp instruction_assembled |
mov_sreg: |
mov ah,al |
and al,1111b |
mov [postbyte_register],al |
shr ah,4 |
cmp ah,5 |
je mov_creg |
cmp ah,7 |
je mov_dreg |
ja mov_treg |
cmp al,2 |
je illegal_instruction |
dec [postbyte_register] |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
je mov_sreg_mem |
cmp al,10h |
jne invalid_operand |
mov_sreg_reg: |
lods byte [esi] |
call convert_register |
or ah,ah |
jz mov_sreg_reg_size_ok |
cmp ah,2 |
jne invalid_operand_size |
mov bl,al |
mov_sreg_reg_size_ok: |
mov [base_code],8Eh |
call store_nomem_instruction |
jmp instruction_assembled |
mov_sreg_mem: |
call get_address |
mov al,[operand_size] |
or al,al |
jz mov_sreg_mem_size_ok |
cmp al,2 |
jne invalid_operand_size |
mov_sreg_mem_size_ok: |
mov [base_code],8Eh |
call store_instruction |
jmp instruction_assembled |
mov_treg: |
cmp ah,9 |
jne invalid_operand |
mov [extended_code],26h |
jmp mov_xrx |
mov_dreg: |
mov [extended_code],23h |
jmp mov_xrx |
mov_creg: |
mov [extended_code],22h |
mov_xrx: |
mov [base_code],0Fh |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov bl,al |
cmp [code_type],64 |
je mov_xrx_64bit |
cmp ah,4 |
jne invalid_operand_size |
cmp [postbyte_register],8 |
jne mov_xrx_store |
cmp [extended_code],22h |
jne mov_xrx_store |
mov al,0F0h |
stos byte [edi] |
mov [postbyte_register],0 |
mov_xrx_store: |
call store_nomem_instruction |
jmp instruction_assembled |
mov_xrx_64bit: |
cmp ah,8 |
jne invalid_operand_size |
call store_nomem_instruction |
jmp instruction_assembled |
cmov_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
je cmov_reg_mem |
cmp al,10h |
jne invalid_operand |
cmov_reg_reg: |
lods byte [esi] |
call convert_register |
mov bl,al |
mov al,ah |
call operand_autodetect |
call store_nomem_instruction |
jmp instruction_assembled |
cmov_reg_mem: |
call get_address |
mov al,[operand_size] |
call operand_autodetect |
call store_instruction |
jmp instruction_assembled |
test_instruction: |
mov [base_code],84h |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je test_reg |
cmp al,'[' |
jne invalid_operand |
test_mem: |
call get_address |
push edx bx cx |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'(' |
je test_mem_imm |
cmp al,10h |
jne invalid_operand |
test_mem_reg: |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
pop cx bx edx |
mov al,ah |
cmp al,1 |
je test_mem_reg_8bit |
call operand_autodetect |
inc [base_code] |
test_mem_reg_8bit: |
call store_instruction |
jmp instruction_assembled |
test_mem_imm: |
mov al,[operand_size] |
cmp al,1 |
je test_mem_imm_8bit |
cmp al,2 |
je test_mem_imm_16bit |
cmp al,4 |
je test_mem_imm_32bit |
cmp al,8 |
je test_mem_imm_64bit |
or al,al |
jnz invalid_operand_size |
cmp [error_line],0 |
jne test_mem_imm_32bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
jmp test_mem_imm_32bit |
test_mem_imm_8bit: |
call get_byte_value |
mov byte [value],al |
mov [postbyte_register],0 |
mov [base_code],0F6h |
pop cx bx edx |
call store_instruction_with_imm8 |
jmp instruction_assembled |
test_mem_imm_16bit: |
call operand_16bit |
call get_word_value |
mov word [value],ax |
mov [postbyte_register],0 |
mov [base_code],0F7h |
pop cx bx edx |
call store_instruction_with_imm16 |
jmp instruction_assembled |
test_mem_imm_32bit: |
call operand_32bit |
call get_dword_value |
test_mem_imm_32bit_store: |
mov dword [value],eax |
mov [postbyte_register],0 |
mov [base_code],0F7h |
pop cx bx edx |
call store_instruction_with_imm32 |
jmp instruction_assembled |
test_mem_imm_64bit: |
cmp [size_declared],0 |
jne long_immediate_not_encodable |
call operand_64bit |
call get_simm32 |
cmp [value_type],4 |
jae long_immediate_not_encodable |
jmp test_mem_imm_32bit_store |
test_reg: |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
je test_reg_mem |
cmp al,'(' |
je test_reg_imm |
cmp al,10h |
jne invalid_operand |
test_reg_reg: |
lods byte [esi] |
call convert_register |
mov bl,[postbyte_register] |
mov [postbyte_register],al |
mov al,ah |
cmp al,1 |
je test_reg_reg_8bit |
call operand_autodetect |
inc [base_code] |
test_reg_reg_8bit: |
call store_nomem_instruction |
jmp instruction_assembled |
test_reg_imm: |
mov al,[operand_size] |
cmp al,1 |
je test_reg_imm_8bit |
cmp al,2 |
je test_reg_imm_16bit |
cmp al,4 |
je test_reg_imm_32bit |
cmp al,8 |
je test_reg_imm_64bit |
jmp invalid_operand_size |
test_reg_imm_8bit: |
call get_byte_value |
mov dl,al |
mov bl,[postbyte_register] |
mov [postbyte_register],0 |
mov [base_code],0F6h |
or bl,bl |
jz test_al_imm |
call store_nomem_instruction |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
test_al_imm: |
mov [base_code],0A8h |
call store_instruction_code |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
test_reg_imm_16bit: |
call operand_16bit |
call get_word_value |
mov dx,ax |
mov bl,[postbyte_register] |
mov [postbyte_register],0 |
mov [base_code],0F7h |
or bl,bl |
jz test_ax_imm |
call store_nomem_instruction |
mov ax,dx |
call mark_relocation |
stos word [edi] |
jmp instruction_assembled |
test_ax_imm: |
mov [base_code],0A9h |
call store_instruction_code |
mov ax,dx |
stos word [edi] |
jmp instruction_assembled |
test_reg_imm_32bit: |
call operand_32bit |
call get_dword_value |
test_reg_imm_32bit_store: |
mov edx,eax |
mov bl,[postbyte_register] |
mov [postbyte_register],0 |
mov [base_code],0F7h |
or bl,bl |
jz test_eax_imm |
call store_nomem_instruction |
mov eax,edx |
call mark_relocation |
stos dword [edi] |
jmp instruction_assembled |
test_eax_imm: |
mov [base_code],0A9h |
call store_instruction_code |
mov eax,edx |
stos dword [edi] |
jmp instruction_assembled |
test_reg_imm_64bit: |
cmp [size_declared],0 |
jne long_immediate_not_encodable |
call operand_64bit |
call get_simm32 |
cmp [value_type],4 |
jae long_immediate_not_encodable |
jmp test_reg_imm_32bit_store |
test_reg_mem: |
call get_address |
mov al,[operand_size] |
cmp al,1 |
je test_reg_mem_8bit |
call operand_autodetect |
inc [base_code] |
test_reg_mem_8bit: |
call store_instruction |
jmp instruction_assembled |
xchg_instruction: |
mov [base_code],86h |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je xchg_reg |
cmp al,'[' |
jne invalid_operand |
xchg_mem: |
call get_address |
push edx bx cx |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je test_mem_reg |
jmp invalid_operand |
xchg_reg: |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
je test_reg_mem |
cmp al,10h |
jne invalid_operand |
xchg_reg_reg: |
lods byte [esi] |
call convert_register |
mov bl,al |
mov al,ah |
cmp al,1 |
je xchg_reg_reg_8bit |
call operand_autodetect |
cmp [postbyte_register],0 |
je xchg_ax_reg |
or bl,bl |
jnz xchg_reg_reg_store |
mov bl,[postbyte_register] |
xchg_ax_reg: |
cmp [code_type],64 |
jne xchg_ax_reg_ok |
cmp ah,4 |
jne xchg_ax_reg_ok |
or bl,bl |
jz xchg_reg_reg_store |
xchg_ax_reg_ok: |
test bl,1000b |
jz xchg_ax_reg_store |
or [rex_prefix],41h |
and bl,111b |
xchg_ax_reg_store: |
add bl,90h |
mov [base_code],bl |
call store_instruction_code |
jmp instruction_assembled |
xchg_reg_reg_store: |
inc [base_code] |
xchg_reg_reg_8bit: |
call store_nomem_instruction |
jmp instruction_assembled |
push_instruction: |
mov [push_size],al |
push_next: |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je push_reg |
cmp al,'(' |
je push_imm |
cmp al,'[' |
jne invalid_operand |
push_mem: |
call get_address |
mov al,[operand_size] |
mov ah,[push_size] |
cmp al,2 |
je push_mem_16bit |
cmp al,4 |
je push_mem_32bit |
cmp al,8 |
je push_mem_64bit |
or al,al |
jnz invalid_operand_size |
cmp ah,2 |
je push_mem_16bit |
cmp ah,4 |
je push_mem_32bit |
cmp ah,8 |
je push_mem_64bit |
cmp [error_line],0 |
jne push_mem_store |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
jmp push_mem_store |
push_mem_16bit: |
test ah,not 2 |
jnz invalid_operand_size |
call operand_16bit |
jmp push_mem_store |
push_mem_32bit: |
test ah,not 4 |
jnz invalid_operand_size |
cmp [code_type],64 |
je illegal_instruction |
call operand_32bit |
jmp push_mem_store |
push_mem_64bit: |
test ah,not 8 |
jnz invalid_operand_size |
cmp [code_type],64 |
jne illegal_instruction |
push_mem_store: |
mov [base_code],0FFh |
mov [postbyte_register],110b |
call store_instruction |
jmp push_done |
push_reg: |
lods byte [esi] |
mov ah,al |
sub ah,10h |
and ah,al |
test ah,0F0h |
jnz push_sreg |
call convert_register |
test al,1000b |
jz push_reg_ok |
or [rex_prefix],41h |
and al,111b |
push_reg_ok: |
add al,50h |
mov [base_code],al |
mov al,ah |
mov ah,[push_size] |
cmp al,2 |
je push_reg_16bit |
cmp al,4 |
je push_reg_32bit |
cmp al,8 |
jne invalid_operand_size |
push_reg_64bit: |
test ah,not 8 |
jnz invalid_operand_size |
cmp [code_type],64 |
jne illegal_instruction |
jmp push_reg_store |
push_reg_32bit: |
test ah,not 4 |
jnz invalid_operand_size |
cmp [code_type],64 |
je illegal_instruction |
call operand_32bit |
jmp push_reg_store |
push_reg_16bit: |
test ah,not 2 |
jnz invalid_operand_size |
call operand_16bit |
push_reg_store: |
call store_instruction_code |
jmp push_done |
push_sreg: |
mov bl,al |
mov dl,[operand_size] |
mov dh,[push_size] |
cmp dl,2 |
je push_sreg16 |
cmp dl,4 |
je push_sreg32 |
cmp dl,8 |
je push_sreg64 |
or dl,dl |
jnz invalid_operand_size |
cmp dh,2 |
je push_sreg16 |
cmp dh,4 |
je push_sreg32 |
cmp dh,8 |
je push_sreg64 |
jmp push_sreg_store |
push_sreg16: |
test dh,not 2 |
jnz invalid_operand_size |
call operand_16bit |
jmp push_sreg_store |
push_sreg32: |
test dh,not 4 |
jnz invalid_operand_size |
cmp [code_type],64 |
je illegal_instruction |
call operand_32bit |
jmp push_sreg_store |
push_sreg64: |
test dh,not 8 |
jnz invalid_operand_size |
cmp [code_type],64 |
jne illegal_instruction |
push_sreg_store: |
mov al,bl |
cmp al,70h |
jae invalid_operand |
sub al,61h |
cmp al,4 |
jae push_sreg_386 |
shl al,3 |
add al,6 |
mov [base_code],al |
cmp [code_type],64 |
je illegal_instruction |
jmp push_reg_store |
push_sreg_386: |
sub al,4 |
shl al,3 |
add al,0A0h |
mov [extended_code],al |
mov [base_code],0Fh |
jmp push_reg_store |
push_imm: |
mov al,[operand_size] |
mov ah,[push_size] |
or al,al |
je push_imm_size_ok |
or ah,ah |
je push_imm_size_ok |
cmp al,ah |
jne invalid_operand_size |
push_imm_size_ok: |
cmp al,2 |
je push_imm_16bit |
cmp al,4 |
je push_imm_32bit |
cmp al,8 |
je push_imm_64bit |
cmp ah,2 |
je push_imm_optimized_16bit |
cmp ah,4 |
je push_imm_optimized_32bit |
cmp ah,8 |
je push_imm_optimized_64bit |
or al,al |
jnz invalid_operand_size |
cmp [code_type],16 |
je push_imm_optimized_16bit |
cmp [code_type],32 |
je push_imm_optimized_32bit |
push_imm_optimized_64bit: |
cmp [code_type],64 |
jne illegal_instruction |
call get_simm32 |
mov edx,eax |
cmp [value_type],0 |
jne push_imm_32bit_store |
cmp eax,-80h |
jl push_imm_32bit_store |
cmp eax,80h |
jge push_imm_32bit_store |
jmp push_imm_8bit |
push_imm_optimized_32bit: |
cmp [code_type],64 |
je illegal_instruction |
call get_dword_value |
mov edx,eax |
call operand_32bit |
cmp [value_type],0 |
jne push_imm_32bit_store |
cmp eax,-80h |
jl push_imm_32bit_store |
cmp eax,80h |
jge push_imm_32bit_store |
jmp push_imm_8bit |
push_imm_optimized_16bit: |
call get_word_value |
mov dx,ax |
call operand_16bit |
cmp [value_type],0 |
jne push_imm_16bit_store |
cmp ax,-80h |
jl push_imm_16bit_store |
cmp ax,80h |
jge push_imm_16bit_store |
push_imm_8bit: |
mov ah,al |
mov [base_code],6Ah |
call store_instruction_code |
mov al,ah |
stos byte [edi] |
jmp push_done |
push_imm_16bit: |
call get_word_value |
mov dx,ax |
call operand_16bit |
push_imm_16bit_store: |
mov [base_code],68h |
call store_instruction_code |
mov ax,dx |
call mark_relocation |
stos word [edi] |
jmp push_done |
push_imm_64bit: |
cmp [code_type],64 |
jne illegal_instruction |
call get_simm32 |
mov edx,eax |
jmp push_imm_32bit_store |
push_imm_32bit: |
cmp [code_type],64 |
je illegal_instruction |
call get_dword_value |
mov edx,eax |
call operand_32bit |
push_imm_32bit_store: |
mov [base_code],68h |
call store_instruction_code |
mov eax,edx |
call mark_relocation |
stos dword [edi] |
push_done: |
lods byte [esi] |
dec esi |
cmp al,0Fh |
je instruction_assembled |
or al,al |
jz instruction_assembled |
mov [operand_size],0 |
mov [size_override],0 |
mov [operand_prefix],0 |
mov [rex_prefix],0 |
jmp push_next |
pop_instruction: |
mov [push_size],al |
pop_next: |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je pop_reg |
cmp al,'[' |
jne invalid_operand |
pop_mem: |
call get_address |
mov al,[operand_size] |
mov ah,[push_size] |
cmp al,2 |
je pop_mem_16bit |
cmp al,4 |
je pop_mem_32bit |
cmp al,8 |
je pop_mem_64bit |
or al,al |
jnz invalid_operand_size |
cmp ah,2 |
je pop_mem_16bit |
cmp ah,4 |
je pop_mem_32bit |
cmp ah,8 |
je pop_mem_64bit |
cmp [error_line],0 |
jne pop_mem_store |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
jmp pop_mem_store |
pop_mem_16bit: |
test ah,not 2 |
jnz invalid_operand_size |
call operand_16bit |
jmp pop_mem_store |
pop_mem_32bit: |
test ah,not 4 |
jnz invalid_operand_size |
cmp [code_type],64 |
je illegal_instruction |
call operand_32bit |
jmp pop_mem_store |
pop_mem_64bit: |
test ah,not 8 |
jnz invalid_operand_size |
cmp [code_type],64 |
jne illegal_instruction |
pop_mem_store: |
mov [base_code],08Fh |
mov [postbyte_register],0 |
call store_instruction |
jmp pop_done |
pop_reg: |
lods byte [esi] |
mov ah,al |
sub ah,10h |
and ah,al |
test ah,0F0h |
jnz pop_sreg |
call convert_register |
test al,1000b |
jz pop_reg_ok |
or [rex_prefix],41h |
and al,111b |
pop_reg_ok: |
add al,58h |
mov [base_code],al |
mov al,ah |
mov ah,[push_size] |
cmp al,2 |
je pop_reg_16bit |
cmp al,4 |
je pop_reg_32bit |
cmp al,8 |
je pop_reg_64bit |
jmp invalid_operand_size |
pop_reg_64bit: |
test ah,not 8 |
jnz invalid_operand_size |
cmp [code_type],64 |
jne illegal_instruction |
jmp pop_reg_store |
pop_reg_32bit: |
test ah,not 4 |
jnz invalid_operand_size |
cmp [code_type],64 |
je illegal_instruction |
call operand_32bit |
jmp pop_reg_store |
pop_reg_16bit: |
test ah,not 2 |
jnz invalid_operand_size |
call operand_16bit |
pop_reg_store: |
call store_instruction_code |
pop_done: |
lods byte [esi] |
dec esi |
cmp al,0Fh |
je instruction_assembled |
or al,al |
jz instruction_assembled |
mov [operand_size],0 |
mov [size_override],0 |
mov [operand_prefix],0 |
mov [rex_prefix],0 |
jmp pop_next |
pop_sreg: |
mov dl,[operand_size] |
mov dh,[push_size] |
cmp al,62h |
je pop_cs |
mov bl,al |
cmp dl,2 |
je pop_sreg16 |
cmp dl,4 |
je pop_sreg32 |
cmp dl,8 |
je pop_sreg64 |
or dl,dl |
jnz invalid_operand_size |
cmp dh,2 |
je pop_sreg16 |
cmp dh,4 |
je pop_sreg32 |
cmp dh,8 |
je pop_sreg64 |
jmp pop_sreg_store |
pop_sreg16: |
test dh,not 2 |
jnz invalid_operand_size |
call operand_16bit |
jmp pop_sreg_store |
pop_sreg32: |
test dh,not 4 |
jnz invalid_operand_size |
cmp [code_type],64 |
je illegal_instruction |
call operand_32bit |
jmp pop_sreg_store |
pop_sreg64: |
test dh,not 8 |
jnz invalid_operand_size |
cmp [code_type],64 |
jne illegal_instruction |
pop_sreg_store: |
mov al,bl |
cmp al,70h |
jae invalid_operand |
sub al,61h |
cmp al,4 |
jae pop_sreg_386 |
shl al,3 |
add al,7 |
mov [base_code],al |
cmp [code_type],64 |
je illegal_instruction |
jmp pop_reg_store |
pop_cs: |
cmp [code_type],16 |
jne illegal_instruction |
cmp dl,2 |
je pop_cs_store |
or dl,dl |
jnz invalid_operand_size |
cmp dh,2 |
je pop_cs_store |
or dh,dh |
jnz illegal_instruction |
pop_cs_store: |
test dh,not 2 |
jnz invalid_operand_size |
mov al,0Fh |
stos byte [edi] |
jmp pop_done |
pop_sreg_386: |
sub al,4 |
shl al,3 |
add al,0A1h |
mov [extended_code],al |
mov [base_code],0Fh |
jmp pop_reg_store |
inc_instruction: |
mov [base_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je inc_reg |
cmp al,'[' |
je inc_mem |
jne invalid_operand |
inc_mem: |
call get_address |
mov al,[operand_size] |
cmp al,1 |
je inc_mem_8bit |
jb inc_mem_nosize |
call operand_autodetect |
mov al,0FFh |
xchg al,[base_code] |
mov [postbyte_register],al |
call store_instruction |
jmp instruction_assembled |
inc_mem_nosize: |
cmp [error_line],0 |
jne inc_mem_8bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
inc_mem_8bit: |
mov al,0FEh |
xchg al,[base_code] |
mov [postbyte_register],al |
call store_instruction |
jmp instruction_assembled |
inc_reg: |
lods byte [esi] |
call convert_register |
mov bl,al |
mov al,0FEh |
xchg al,[base_code] |
mov [postbyte_register],al |
mov al,ah |
cmp al,1 |
je inc_reg_8bit |
call operand_autodetect |
cmp [code_type],64 |
je inc_reg_long_form |
mov al,[postbyte_register] |
shl al,3 |
add al,bl |
add al,40h |
mov [base_code],al |
call store_instruction_code |
jmp instruction_assembled |
inc_reg_long_form: |
inc [base_code] |
inc_reg_8bit: |
call store_nomem_instruction |
jmp instruction_assembled |
set_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je set_reg |
cmp al,'[' |
jne invalid_operand |
set_mem: |
call get_address |
cmp [operand_size],1 |
ja invalid_operand_size |
mov [postbyte_register],0 |
call store_instruction |
jmp instruction_assembled |
set_reg: |
lods byte [esi] |
call convert_register |
cmp ah,1 |
jne invalid_operand_size |
mov bl,al |
mov [postbyte_register],0 |
call store_nomem_instruction |
jmp instruction_assembled |
arpl_instruction: |
cmp [code_type],64 |
je illegal_instruction |
mov [base_code],63h |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je arpl_reg |
cmp al,'[' |
jne invalid_operand |
call get_address |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
cmp ah,2 |
jne invalid_operand_size |
call store_instruction |
jmp instruction_assembled |
arpl_reg: |
lods byte [esi] |
call convert_register |
cmp ah,2 |
jne invalid_operand_size |
mov bl,al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
cmp ah,2 |
jne invalid_operand_size |
mov [postbyte_register],al |
call store_nomem_instruction |
jmp instruction_assembled |
bound_instruction: |
cmp [code_type],64 |
je illegal_instruction |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov al,[operand_size] |
cmp al,2 |
je bound_16bit |
cmp al,4 |
je bound_32bit |
jmp invalid_operand_size |
bound_32bit: |
call operand_32bit |
mov [base_code],62h |
call store_instruction |
jmp instruction_assembled |
bound_16bit: |
call operand_16bit |
mov [base_code],62h |
call store_instruction |
jmp instruction_assembled |
enter_instruction: |
lods byte [esi] |
call get_size_operator |
cmp ah,2 |
je enter_imm16_size_ok |
or ah,ah |
jnz invalid_operand_size |
enter_imm16_size_ok: |
cmp al,'(' |
jne invalid_operand |
call get_word_value |
cmp [next_pass_needed],0 |
jne enter_imm16_ok |
cmp [value_type],0 |
jne invalid_use_of_symbol |
enter_imm16_ok: |
push eax |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp ah,1 |
je enter_imm8_size_ok |
or ah,ah |
jnz invalid_operand_size |
enter_imm8_size_ok: |
cmp al,'(' |
jne invalid_operand |
call get_byte_value |
mov dl,al |
pop ebx |
mov al,0C8h |
stos byte [edi] |
mov ax,bx |
stos word [edi] |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
ret_instruction_only64: |
cmp [code_type],64 |
jne illegal_instruction |
jmp ret_instruction |
ret_instruction_32bit_except64: |
cmp [code_type],64 |
je illegal_instruction |
ret_instruction_32bit: |
call operand_32bit |
jmp ret_instruction |
ret_instruction_16bit: |
call operand_16bit |
jmp ret_instruction |
retf_instruction: |
cmp [code_type],64 |
jne ret_instruction |
ret_instruction_64bit: |
call operand_64bit |
ret_instruction: |
mov [base_code],al |
lods byte [esi] |
dec esi |
or al,al |
jz simple_ret |
cmp al,0Fh |
je simple_ret |
lods byte [esi] |
call get_size_operator |
or ah,ah |
jz ret_imm |
cmp ah,2 |
je ret_imm |
jmp invalid_operand_size |
ret_imm: |
cmp al,'(' |
jne invalid_operand |
call get_word_value |
cmp [next_pass_needed],0 |
jne ret_imm_ok |
cmp [value_type],0 |
jne invalid_use_of_symbol |
ret_imm_ok: |
cmp [size_declared],0 |
jne ret_imm_store |
or ax,ax |
jz simple_ret |
ret_imm_store: |
mov dx,ax |
call store_instruction_code |
mov ax,dx |
stos word [edi] |
jmp instruction_assembled |
simple_ret: |
inc [base_code] |
call store_instruction_code |
jmp instruction_assembled |
lea_instruction: |
mov [base_code],8Dh |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
xor al,al |
xchg al,[operand_size] |
push eax |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
mov [size_override],-1 |
call get_address |
pop eax |
mov [operand_size],al |
call operand_autodetect |
call store_instruction |
jmp instruction_assembled |
ls_instruction: |
or al,al |
jz les_instruction |
cmp al,3 |
jz lds_instruction |
add al,0B0h |
mov [extended_code],al |
mov [base_code],0Fh |
jmp ls_code_ok |
les_instruction: |
mov [base_code],0C4h |
jmp ls_short_code |
lds_instruction: |
mov [base_code],0C5h |
ls_short_code: |
cmp [code_type],64 |
je illegal_instruction |
ls_code_ok: |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
add [operand_size],2 |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov al,[operand_size] |
cmp al,4 |
je ls_16bit |
cmp al,6 |
je ls_32bit |
cmp al,10 |
je ls_64bit |
jmp invalid_operand_size |
ls_16bit: |
call operand_16bit |
call store_instruction |
jmp instruction_assembled |
ls_32bit: |
call operand_32bit |
call store_instruction |
jmp instruction_assembled |
ls_64bit: |
call operand_64bit |
call store_instruction |
jmp instruction_assembled |
sh_instruction: |
mov [postbyte_register],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je sh_reg |
cmp al,'[' |
jne invalid_operand |
sh_mem: |
call get_address |
push edx bx cx |
mov al,[operand_size] |
push eax |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'(' |
je sh_mem_imm |
cmp al,10h |
jne invalid_operand |
sh_mem_reg: |
lods byte [esi] |
cmp al,11h |
jne invalid_operand |
pop eax cx bx edx |
cmp al,1 |
je sh_mem_cl_8bit |
jb sh_mem_cl_nosize |
call operand_autodetect |
mov [base_code],0D3h |
call store_instruction |
jmp instruction_assembled |
sh_mem_cl_nosize: |
cmp [error_line],0 |
jne sh_mem_cl_8bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
sh_mem_cl_8bit: |
mov [base_code],0D2h |
call store_instruction |
jmp instruction_assembled |
sh_mem_imm: |
mov al,[operand_size] |
or al,al |
jz sh_mem_imm_size_ok |
cmp al,1 |
jne invalid_operand_size |
sh_mem_imm_size_ok: |
call get_byte_value |
mov byte [value],al |
pop eax cx bx edx |
cmp al,1 |
je sh_mem_imm_8bit |
jb sh_mem_imm_nosize |
call operand_autodetect |
cmp byte [value],1 |
je sh_mem_1 |
mov [base_code],0C1h |
call store_instruction_with_imm8 |
jmp instruction_assembled |
sh_mem_1: |
mov [base_code],0D1h |
call store_instruction |
jmp instruction_assembled |
sh_mem_imm_nosize: |
cmp [error_line],0 |
jne sh_mem_imm_8bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
sh_mem_imm_8bit: |
cmp byte [value],1 |
je sh_mem_1_8bit |
mov [base_code],0C0h |
call store_instruction_with_imm8 |
jmp instruction_assembled |
sh_mem_1_8bit: |
mov [base_code],0D0h |
call store_instruction |
jmp instruction_assembled |
sh_reg: |
lods byte [esi] |
call convert_register |
mov bx,ax |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'(' |
je sh_reg_imm |
cmp al,10h |
jne invalid_operand |
sh_reg_reg: |
lods byte [esi] |
cmp al,11h |
jne invalid_operand |
mov al,bh |
cmp al,1 |
je sh_reg_cl_8bit |
call operand_autodetect |
mov [base_code],0D3h |
call store_nomem_instruction |
jmp instruction_assembled |
sh_reg_cl_8bit: |
mov [base_code],0D2h |
call store_nomem_instruction |
jmp instruction_assembled |
sh_reg_imm: |
mov al,[operand_size] |
or al,al |
jz sh_reg_imm_size_ok |
cmp al,1 |
jne invalid_operand_size |
sh_reg_imm_size_ok: |
push ebx |
call get_byte_value |
mov dl,al |
pop ebx |
mov al,bh |
cmp al,1 |
je sh_reg_imm_8bit |
call operand_autodetect |
cmp dl,1 |
je sh_reg_1 |
mov [base_code],0C1h |
call store_nomem_instruction |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
sh_reg_1: |
mov [base_code],0D1h |
call store_nomem_instruction |
jmp instruction_assembled |
sh_reg_imm_8bit: |
cmp dl,1 |
je sh_reg_1_8bit |
mov [base_code],0C0h |
call store_nomem_instruction |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
sh_reg_1_8bit: |
mov [base_code],0D0h |
call store_nomem_instruction |
jmp instruction_assembled |
shd_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je shd_reg |
cmp al,'[' |
jne invalid_operand |
shd_mem: |
call get_address |
push edx bx cx |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
mov al,ah |
mov [operand_size],0 |
push eax |
lods byte [esi] |
call get_size_operator |
cmp al,'(' |
je shd_mem_reg_imm |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
cmp al,11h |
jne invalid_operand |
pop eax cx bx edx |
call operand_autodetect |
inc [extended_code] |
call store_instruction |
jmp instruction_assembled |
shd_mem_reg_imm: |
mov al,[operand_size] |
or al,al |
jz shd_mem_reg_imm_size_ok |
cmp al,1 |
jne invalid_operand_size |
shd_mem_reg_imm_size_ok: |
call get_byte_value |
mov byte [value],al |
pop eax cx bx edx |
call operand_autodetect |
call store_instruction_with_imm8 |
jmp instruction_assembled |
shd_reg: |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov bl,[postbyte_register] |
mov [postbyte_register],al |
mov al,ah |
push eax ebx |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
mov [operand_size],0 |
lods byte [esi] |
call get_size_operator |
cmp al,'(' |
je shd_reg_reg_imm |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
cmp al,11h |
jne invalid_operand |
pop ebx eax |
call operand_autodetect |
inc [extended_code] |
call store_nomem_instruction |
jmp instruction_assembled |
shd_reg_reg_imm: |
mov al,[operand_size] |
or al,al |
jz shd_reg_reg_imm_size_ok |
cmp al,1 |
jne invalid_operand_size |
shd_reg_reg_imm_size_ok: |
call get_byte_value |
mov dl,al |
pop ebx eax |
call operand_autodetect |
call store_nomem_instruction |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
movx_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
mov al,ah |
push eax |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
mov [operand_size],0 |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je movx_reg |
cmp al,'[' |
jne invalid_operand |
call get_address |
pop eax |
mov ah,[operand_size] |
or ah,ah |
jz movx_unknown_size |
cmp ah,al |
jae invalid_operand_size |
cmp ah,1 |
je movx_mem_8bit |
cmp ah,2 |
jne invalid_operand_size |
movx_mem_16bit: |
inc [extended_code] |
call operand_autodetect |
call store_instruction |
jmp instruction_assembled |
movx_unknown_size: |
cmp [error_line],0 |
jne movx_mem_8bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
movx_mem_8bit: |
call operand_autodetect |
call store_instruction |
jmp instruction_assembled |
movx_reg: |
lods byte [esi] |
call convert_register |
pop ebx |
xchg bl,al |
cmp ah,al |
jae invalid_operand_size |
cmp ah,1 |
je movx_reg_8bit |
cmp ah,2 |
je movx_reg_16bit |
jmp invalid_operand_size |
movx_reg_8bit: |
call operand_autodetect |
call store_nomem_instruction |
jmp instruction_assembled |
movx_reg_16bit: |
call operand_autodetect |
inc [extended_code] |
call store_nomem_instruction |
jmp instruction_assembled |
movsxd_instruction: |
mov [base_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
cmp ah,8 |
jne invalid_operand_size |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
mov [operand_size],0 |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je movsxd_reg |
cmp al,'[' |
jne invalid_operand |
call get_address |
cmp [operand_size],4 |
je movsxd_mem_store |
cmp [operand_size],0 |
jne invalid_operand_size |
movsxd_mem_store: |
call operand_64bit |
call store_instruction |
jmp instruction_assembled |
movsxd_reg: |
lods byte [esi] |
call convert_register |
cmp ah,4 |
jne invalid_operand_size |
mov bl,al |
call operand_64bit |
call store_nomem_instruction |
jmp instruction_assembled |
bt_instruction: |
mov [postbyte_register],al |
shl al,3 |
add al,83h |
mov [extended_code],al |
mov [base_code],0Fh |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je bt_reg |
cmp al,'[' |
jne invalid_operand |
call get_address |
push eax bx cx |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
cmp byte [esi],'(' |
je bt_mem_imm |
cmp byte [esi],11h |
jne bt_mem_reg |
cmp byte [esi+2],'(' |
je bt_mem_imm |
bt_mem_reg: |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
pop cx bx edx |
mov al,ah |
call operand_autodetect |
call store_instruction |
jmp instruction_assembled |
bt_mem_imm: |
xor al,al |
xchg al,[operand_size] |
push eax |
lods byte [esi] |
call get_size_operator |
cmp al,'(' |
jne invalid_operand |
mov al,[operand_size] |
or al,al |
jz bt_mem_imm_size_ok |
cmp al,1 |
jne invalid_operand_size |
bt_mem_imm_size_ok: |
call get_byte_value |
mov byte [value],al |
pop eax |
or al,al |
jz bt_mem_imm_nosize |
call operand_autodetect |
bt_mem_imm_store: |
pop cx bx edx |
mov [extended_code],0BAh |
call store_instruction_with_imm8 |
jmp instruction_assembled |
bt_mem_imm_nosize: |
cmp [error_line],0 |
jne bt_mem_imm_store |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
jmp bt_mem_imm_store |
bt_reg: |
lods byte [esi] |
call convert_register |
mov bl,al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
cmp byte [esi],'(' |
je bt_reg_imm |
cmp byte [esi],11h |
jne bt_reg_reg |
cmp byte [esi+2],'(' |
je bt_reg_imm |
bt_reg_reg: |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
mov al,ah |
call operand_autodetect |
call store_nomem_instruction |
jmp instruction_assembled |
bt_reg_imm: |
xor al,al |
xchg al,[operand_size] |
push eax ebx |
lods byte [esi] |
call get_size_operator |
cmp al,'(' |
jne invalid_operand |
mov al,[operand_size] |
or al,al |
jz bt_reg_imm_size_ok |
cmp al,1 |
jne invalid_operand_size |
bt_reg_imm_size_ok: |
call get_byte_value |
mov byte [value],al |
pop ebx eax |
call operand_autodetect |
bt_reg_imm_store: |
mov [extended_code],0BAh |
call store_nomem_instruction |
mov al,byte [value] |
stos byte [edi] |
jmp instruction_assembled |
bs_instruction: |
mov [extended_code],al |
mov [base_code],0Fh |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je bs_reg_reg |
cmp al,'[' |
jne invalid_argument |
call get_address |
mov al,[operand_size] |
call operand_autodetect |
call store_instruction |
jmp instruction_assembled |
bs_reg_reg: |
lods byte [esi] |
call convert_register |
mov bl,al |
mov al,ah |
call operand_autodetect |
call store_nomem_instruction |
jmp instruction_assembled |
imul_instruction: |
mov [base_code],0F6h |
mov [postbyte_register],5 |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je imul_reg |
cmp al,'[' |
jne invalid_operand |
imul_mem: |
call get_address |
mov al,[operand_size] |
cmp al,1 |
je imul_mem_8bit |
jb imul_mem_nosize |
call operand_autodetect |
inc [base_code] |
call store_instruction |
jmp instruction_assembled |
imul_mem_nosize: |
cmp [error_line],0 |
jne imul_mem_8bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
imul_mem_8bit: |
call store_instruction |
jmp instruction_assembled |
imul_reg: |
lods byte [esi] |
call convert_register |
cmp byte [esi],',' |
je imul_reg_ |
mov bl,al |
mov al,ah |
cmp al,1 |
je imul_reg_8bit |
call operand_autodetect |
inc [base_code] |
call store_nomem_instruction |
jmp instruction_assembled |
imul_reg_8bit: |
call store_nomem_instruction |
jmp instruction_assembled |
imul_reg_: |
mov [postbyte_register],al |
inc esi |
cmp byte [esi],'(' |
je imul_reg_imm |
cmp byte [esi],11h |
jne imul_reg_noimm |
cmp byte [esi+2],'(' |
je imul_reg_imm |
imul_reg_noimm: |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je imul_reg_reg |
cmp al,'[' |
jne invalid_operand |
imul_reg_mem: |
call get_address |
push edx bx cx |
cmp byte [esi],',' |
je imul_reg_mem_imm |
mov al,[operand_size] |
call operand_autodetect |
pop cx bx edx |
mov [base_code],0Fh |
mov [extended_code],0AFh |
call store_instruction |
jmp instruction_assembled |
imul_reg_mem_imm: |
inc esi |
lods byte [esi] |
call get_size_operator |
cmp al,'(' |
jne invalid_operand |
mov al,[operand_size] |
cmp al,2 |
je imul_reg_mem_imm_16bit |
cmp al,4 |
je imul_reg_mem_imm_32bit |
cmp al,8 |
je imul_reg_mem_imm_64bit |
jmp invalid_operand_size |
imul_reg_mem_imm_16bit: |
call operand_16bit |
call get_word_value |
mov word [value],ax |
cmp [value_type],0 |
jne imul_reg_mem_imm_16bit_store |
cmp [size_declared],0 |
jne imul_reg_mem_imm_16bit_store |
cmp ax,-80h |
jl imul_reg_mem_imm_16bit_store |
cmp ax,80h |
jl imul_reg_mem_imm_8bit_store |
imul_reg_mem_imm_16bit_store: |
pop cx bx edx |
mov [base_code],69h |
call store_instruction_with_imm16 |
jmp instruction_assembled |
imul_reg_mem_imm_32bit: |
call operand_32bit |
call get_dword_value |
imul_reg_mem_imm_32bit_ok: |
mov dword [value],eax |
cmp [value_type],0 |
jne imul_reg_mem_imm_32bit_store |
cmp [size_declared],0 |
jne imul_reg_mem_imm_32bit_store |
cmp eax,-80h |
jl imul_reg_mem_imm_32bit_store |
cmp eax,80h |
jl imul_reg_mem_imm_8bit_store |
imul_reg_mem_imm_32bit_store: |
pop cx bx edx |
mov [base_code],69h |
call store_instruction_with_imm32 |
jmp instruction_assembled |
imul_reg_mem_imm_64bit: |
cmp [size_declared],0 |
jne long_immediate_not_encodable |
call operand_64bit |
call get_simm32 |
cmp [value_type],4 |
jae long_immediate_not_encodable |
jmp imul_reg_mem_imm_32bit_ok |
imul_reg_mem_imm_8bit_store: |
pop cx bx edx |
mov [base_code],6Bh |
call store_instruction_with_imm8 |
jmp instruction_assembled |
imul_reg_imm: |
mov bl,[postbyte_register] |
dec esi |
jmp imul_reg_reg_imm |
imul_reg_reg: |
lods byte [esi] |
call convert_register |
mov bl,al |
cmp byte [esi],',' |
je imul_reg_reg_imm |
mov al,ah |
call operand_autodetect |
mov [base_code],0Fh |
mov [extended_code],0AFh |
call store_nomem_instruction |
jmp instruction_assembled |
imul_reg_reg_imm: |
inc esi |
lods byte [esi] |
call get_size_operator |
cmp al,'(' |
jne invalid_operand |
mov al,[operand_size] |
cmp al,2 |
je imul_reg_reg_imm_16bit |
cmp al,4 |
je imul_reg_reg_imm_32bit |
cmp al,8 |
je imul_reg_reg_imm_64bit |
jmp invalid_operand_size |
imul_reg_reg_imm_16bit: |
call operand_16bit |
push ebx |
call get_word_value |
pop ebx |
mov dx,ax |
cmp [value_type],0 |
jne imul_reg_reg_imm_16bit_store |
cmp [size_declared],0 |
jne imul_reg_reg_imm_16bit_store |
cmp ax,-80h |
jl imul_reg_reg_imm_16bit_store |
cmp ax,80h |
jl imul_reg_reg_imm_8bit_store |
imul_reg_reg_imm_16bit_store: |
mov [base_code],69h |
call store_nomem_instruction |
mov ax,dx |
call mark_relocation |
stos word [edi] |
jmp instruction_assembled |
imul_reg_reg_imm_32bit: |
call operand_32bit |
push ebx |
call get_dword_value |
imul_reg_reg_imm_32bit_ok: |
pop ebx |
mov edx,eax |
cmp [value_type],0 |
jne imul_reg_reg_imm_32bit_store |
cmp [size_declared],0 |
jne imul_reg_reg_imm_32bit_store |
cmp eax,-80h |
jl imul_reg_reg_imm_32bit_store |
cmp eax,80h |
jl imul_reg_reg_imm_8bit_store |
imul_reg_reg_imm_32bit_store: |
mov [base_code],69h |
call store_nomem_instruction |
mov eax,edx |
call mark_relocation |
stos dword [edi] |
jmp instruction_assembled |
imul_reg_reg_imm_64bit: |
cmp [size_declared],0 |
jne long_immediate_not_encodable |
call operand_64bit |
push ebx |
call get_simm32 |
cmp [value_type],4 |
jae long_immediate_not_encodable |
jmp imul_reg_reg_imm_32bit_ok |
imul_reg_reg_imm_8bit_store: |
mov [base_code],6Bh |
call store_nomem_instruction |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
in_instruction: |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
or al,al |
jnz invalid_operand |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
mov al,ah |
push eax |
mov [operand_size],0 |
lods byte [esi] |
call get_size_operator |
cmp al,'(' |
je in_imm |
cmp al,10h |
je in_reg |
jmp invalid_operand |
in_reg: |
lods byte [esi] |
cmp al,22h |
jne invalid_operand |
pop eax |
cmp al,1 |
je in_al_dx |
cmp al,2 |
je in_ax_dx |
cmp al,4 |
je in_eax_dx |
jmp invalid_operand_size |
in_al_dx: |
mov al,0ECh |
stos byte [edi] |
jmp instruction_assembled |
in_ax_dx: |
call operand_16bit |
mov [base_code],0EDh |
call store_instruction_code |
jmp instruction_assembled |
in_eax_dx: |
call operand_32bit |
mov [base_code],0EDh |
call store_instruction_code |
jmp instruction_assembled |
in_imm: |
mov al,[operand_size] |
or al,al |
jz in_imm_size_ok |
cmp al,1 |
jne invalid_operand_size |
in_imm_size_ok: |
call get_byte_value |
mov dl,al |
pop eax |
cmp al,1 |
je in_al_imm |
cmp al,2 |
je in_ax_imm |
cmp al,4 |
je in_eax_imm |
jmp invalid_operand_size |
in_al_imm: |
mov al,0E4h |
stos byte [edi] |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
in_ax_imm: |
call operand_16bit |
mov [base_code],0E5h |
call store_instruction_code |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
in_eax_imm: |
call operand_32bit |
mov [base_code],0E5h |
call store_instruction_code |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
out_instruction: |
lods byte [esi] |
call get_size_operator |
cmp al,'(' |
je out_imm |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
cmp al,22h |
jne invalid_operand |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
mov [operand_size],0 |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
or al,al |
jnz invalid_operand |
mov al,ah |
cmp al,1 |
je out_dx_al |
cmp al,2 |
je out_dx_ax |
cmp al,4 |
je out_dx_eax |
jmp invalid_operand_size |
out_dx_al: |
mov al,0EEh |
stos byte [edi] |
jmp instruction_assembled |
out_dx_ax: |
call operand_16bit |
mov [base_code],0EFh |
call store_instruction_code |
jmp instruction_assembled |
out_dx_eax: |
call operand_32bit |
mov [base_code],0EFh |
call store_instruction_code |
jmp instruction_assembled |
out_imm: |
mov al,[operand_size] |
or al,al |
jz out_imm_size_ok |
cmp al,1 |
jne invalid_operand_size |
out_imm_size_ok: |
call get_byte_value |
mov dl,al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
mov [operand_size],0 |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
or al,al |
jnz invalid_operand |
mov al,ah |
cmp al,1 |
je out_imm_al |
cmp al,2 |
je out_imm_ax |
cmp al,4 |
je out_imm_eax |
jmp invalid_operand_size |
out_imm_al: |
mov al,0E6h |
stos byte [edi] |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
out_imm_ax: |
call operand_16bit |
mov [base_code],0E7h |
call store_instruction_code |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
out_imm_eax: |
call operand_32bit |
mov [base_code],0E7h |
call store_instruction_code |
mov al,dl |
stos byte [edi] |
jmp instruction_assembled |
call_instruction: |
mov [postbyte_register],10b |
mov [base_code],0E8h |
mov [extended_code],9Ah |
jmp process_jmp |
jmp_instruction: |
mov [postbyte_register],100b |
mov [base_code],0E9h |
mov [extended_code],0EAh |
process_jmp: |
lods byte [esi] |
call get_jump_operator |
call get_size_operator |
cmp al,'(' |
je jmp_imm |
mov [base_code],0FFh |
cmp al,10h |
je jmp_reg |
cmp al,'[' |
jne invalid_operand |
jmp_mem: |
cmp [jump_type],1 |
je illegal_instruction |
call get_address |
mov edx,eax |
mov al,[operand_size] |
or al,al |
jz jmp_mem_size_not_specified |
cmp al,2 |
je jmp_mem_16bit |
cmp al,4 |
je jmp_mem_32bit |
cmp al,6 |
je jmp_mem_48bit |
cmp al,8 |
je jmp_mem_64bit |
cmp al,10 |
je jmp_mem_80bit |
jmp invalid_operand_size |
jmp_mem_size_not_specified: |
cmp [jump_type],3 |
je jmp_mem_far |
cmp [jump_type],2 |
je jmp_mem_near |
cmp [error_line],0 |
jne jmp_mem_near |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
jmp_mem_near: |
cmp [code_type],16 |
je jmp_mem_16bit |
cmp [code_type],32 |
je jmp_mem_near_32bit |
jmp_mem_64bit: |
cmp [jump_type],3 |
je invalid_operand_size |
cmp [code_type],64 |
jne illegal_instruction |
call store_instruction |
jmp instruction_assembled |
jmp_mem_far: |
cmp [code_type],16 |
je jmp_mem_far_32bit |
jmp_mem_48bit: |
call operand_32bit |
jmp_mem_far_store: |
cmp [jump_type],2 |
je invalid_operand_size |
inc [postbyte_register] |
call store_instruction |
jmp instruction_assembled |
jmp_mem_80bit: |
call operand_64bit |
jmp jmp_mem_far_store |
jmp_mem_far_32bit: |
call operand_16bit |
jmp jmp_mem_far_store |
jmp_mem_32bit: |
cmp [jump_type],3 |
je jmp_mem_far_32bit |
cmp [jump_type],2 |
je jmp_mem_near_32bit |
cmp [code_type],16 |
je jmp_mem_far_32bit |
jmp_mem_near_32bit: |
cmp [code_type],64 |
je illegal_instruction |
call operand_32bit |
call store_instruction |
jmp instruction_assembled |
jmp_mem_16bit: |
cmp [jump_type],3 |
je invalid_operand_size |
call operand_16bit |
call store_instruction |
jmp instruction_assembled |
jmp_reg: |
test [jump_type],1 |
jnz invalid_operand |
lods byte [esi] |
call convert_register |
mov bl,al |
mov al,ah |
cmp al,2 |
je jmp_reg_16bit |
cmp al,4 |
je jmp_reg_32bit |
cmp al,8 |
jne invalid_operand_size |
jmp_reg_64bit: |
cmp [code_type],64 |
jne illegal_instruction |
call store_nomem_instruction |
jmp instruction_assembled |
jmp_reg_32bit: |
cmp [code_type],64 |
je illegal_instruction |
call store_nomem_instruction |
jmp instruction_assembled |
jmp_reg_16bit: |
call operand_16bit |
call store_nomem_instruction |
jmp instruction_assembled |
jmp_imm: |
cmp byte [esi],'.' |
je invalid_value |
mov ebx,esi |
dec esi |
call skip_symbol |
xchg esi,ebx |
cmp byte [ebx],':' |
je jmp_far |
cmp [jump_type],3 |
je invalid_operand |
jmp_near: |
mov al,[operand_size] |
cmp al,2 |
je jmp_imm_16bit |
cmp al,4 |
je jmp_imm_32bit |
cmp al,8 |
je jmp_imm_64bit |
or al,al |
jnz invalid_operand_size |
cmp [code_type],16 |
je jmp_imm_16bit |
cmp [code_type],64 |
je jmp_imm_64bit |
jmp_imm_32bit: |
cmp [code_type],64 |
je invalid_operand_size |
call get_dword_value |
cmp [code_type],16 |
jne jmp_imm_32bit_prefix_ok |
mov byte [edi],66h |
inc edi |
jmp_imm_32bit_prefix_ok: |
call calculate_jump_offset |
cdq |
call check_for_short_jump |
jc jmp_short |
jmp_imm_32bit_store: |
mov edx,eax |
sub edx,3 |
mov al,[base_code] |
stos byte [edi] |
mov eax,edx |
call mark_relocation |
stos dword [edi] |
jmp instruction_assembled |
jmp_imm_64bit: |
cmp [code_type],64 |
jne invalid_operand_size |
call get_qword_value |
call calculate_jump_offset |
mov ecx,edx |
cdq |
cmp edx,ecx |
jne value_out_of_range |
call check_for_short_jump |
jnc jmp_imm_32bit_store |
jmp_short: |
mov ah,al |
mov al,0EBh |
stos word [edi] |
jmp instruction_assembled |
jmp_imm_16bit: |
call get_word_value |
cmp [code_type],16 |
je jmp_imm_16bit_prefix_ok |
mov byte [edi],66h |
inc edi |
jmp_imm_16bit_prefix_ok: |
call calculate_jump_offset |
cwde |
cdq |
call check_for_short_jump |
jc jmp_short |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov edx,eax |
dec edx |
mov al,[base_code] |
stos byte [edi] |
mov eax,edx |
stos word [edi] |
jmp instruction_assembled |
calculate_jump_offset: |
cmp [value_undefined],0 |
jne jump_offset_ok |
add eax,dword [org_origin] |
adc edx,dword [org_origin+4] |
lea ebx,[edi+2] |
sub eax,ebx |
sbb edx,0 |
mov bl,[value_type] |
or bl,bl |
je jump_offset_ok |
test bl,1 |
jnz invalid_use_of_symbol |
cmp bl,[labels_type] |
jne invalid_use_of_symbol |
mov [value_type],0 |
mov ecx,[symbol_identifier] |
cmp ecx,[org_symbol] |
je jump_offset_ok |
mov [value_type],3 |
jump_offset_ok: |
ret |
check_for_short_jump: |
cmp [jump_type],1 |
je forced_short |
ja no_short_jump |
cmp [base_code],0E8h |
je no_short_jump |
cmp [value_type],0 |
jne no_short_jump |
cmp eax,80h |
jb short_jump |
cmp eax,-80h |
jae short_jump |
no_short_jump: |
clc |
ret |
forced_short: |
cmp [base_code],0E8h |
je illegal_instruction |
cmp [next_pass_needed],0 |
jne jmp_short_value_type_ok |
cmp [value_type],0 |
jne invalid_use_of_symbol |
jmp_short_value_type_ok: |
cmp eax,-80h |
jae short_jump |
cmp eax,80h |
jae jump_out_of_range |
short_jump: |
stc |
ret |
jump_out_of_range: |
cmp [error_line],0 |
jne instruction_assembled |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],relative_jump_out_of_range |
jmp instruction_assembled |
jmp_far: |
cmp [jump_type],2 |
je invalid_operand |
cmp [code_type],64 |
je illegal_instruction |
mov al,[extended_code] |
mov [base_code],al |
call get_word_value |
push eax |
inc esi |
lods byte [esi] |
cmp al,'(' |
jne invalid_operand |
mov al,[value_type] |
push eax [symbol_identifier] |
cmp byte [esi],'.' |
je invalid_value |
mov al,[operand_size] |
cmp al,4 |
je jmp_far_16bit |
cmp al,6 |
je jmp_far_32bit |
or al,al |
jnz invalid_operand_size |
cmp [code_type],16 |
jne jmp_far_32bit |
jmp_far_16bit: |
call get_word_value |
mov ebx,eax |
call operand_16bit |
call store_instruction_code |
mov ax,bx |
call mark_relocation |
stos word [edi] |
jmp_far_segment: |
pop [symbol_identifier] eax |
mov [value_type],al |
pop eax |
call mark_relocation |
stos word [edi] |
jmp instruction_assembled |
jmp_far_32bit: |
call get_dword_value |
mov ebx,eax |
call operand_32bit |
call store_instruction_code |
mov eax,ebx |
call mark_relocation |
stos dword [edi] |
jmp jmp_far_segment |
conditional_jump: |
mov [base_code],al |
lods byte [esi] |
call get_jump_operator |
cmp [jump_type],3 |
je invalid_operand |
call get_size_operator |
cmp al,'(' |
jne invalid_operand |
cmp byte [esi],'.' |
je invalid_value |
mov al,[operand_size] |
cmp al,2 |
je conditional_jump_16bit |
cmp al,4 |
je conditional_jump_32bit |
cmp al,8 |
je conditional_jump_64bit |
or al,al |
jnz invalid_operand_size |
cmp [code_type],16 |
je conditional_jump_16bit |
cmp [code_type],64 |
je conditional_jump_64bit |
conditional_jump_32bit: |
cmp [code_type],64 |
je invalid_operand_size |
call get_dword_value |
cmp [code_type],16 |
jne conditional_jump_32bit_prefix_ok |
mov byte [edi],66h |
inc edi |
conditional_jump_32bit_prefix_ok: |
call calculate_jump_offset |
cdq |
call check_for_short_jump |
jc conditional_jump_short |
conditional_jump_32bit_store: |
mov edx,eax |
sub edx,4 |
mov ah,[base_code] |
add ah,10h |
mov al,0Fh |
stos word [edi] |
mov eax,edx |
call mark_relocation |
stos dword [edi] |
jmp instruction_assembled |
conditional_jump_64bit: |
cmp [code_type],64 |
jne invalid_operand_size |
call get_qword_value |
call calculate_jump_offset |
mov ecx,edx |
cdq |
cmp edx,ecx |
jne value_out_of_range |
call check_for_short_jump |
jnc conditional_jump_32bit_store |
conditional_jump_short: |
mov ah,al |
mov al,[base_code] |
stos word [edi] |
jmp instruction_assembled |
conditional_jump_16bit: |
call get_word_value |
cmp [code_type],16 |
je conditional_jump_16bit_prefix_ok |
mov byte [edi],66h |
inc edi |
conditional_jump_16bit_prefix_ok: |
call calculate_jump_offset |
cwde |
cdq |
call check_for_short_jump |
jc conditional_jump_short |
cmp [value_type],0 |
jne invalid_use_of_symbol |
mov edx,eax |
sub edx,2 |
mov ah,[base_code] |
add ah,10h |
mov al,0Fh |
stos word [edi] |
mov eax,edx |
stos word [edi] |
jmp instruction_assembled |
loop_instruction_16bit: |
cmp [code_type],64 |
je illegal_instruction |
mov dl,al |
call address_16bit_prefix |
mov al,dl |
jmp loop_instruction |
loop_instruction_32bit: |
mov dl,al |
call address_32bit_prefix |
mov al,dl |
jmp loop_instruction |
loop_instruction_64bit: |
cmp [code_type],64 |
jne illegal_instruction |
loop_instruction: |
mov [base_code],al |
lods byte [esi] |
call get_jump_operator |
cmp [jump_type],1 |
ja invalid_operand |
call get_size_operator |
cmp al,'(' |
jne invalid_operand |
cmp byte [esi],'.' |
je invalid_value |
mov al,[operand_size] |
cmp al,2 |
je loop_jump_16bit |
cmp al,4 |
je loop_jump_32bit |
cmp al,8 |
je loop_jump_64bit |
or al,al |
jnz invalid_operand_size |
cmp [code_type],16 |
je loop_jump_16bit |
cmp [code_type],64 |
je loop_jump_64bit |
loop_jump_32bit: |
cmp [code_type],64 |
je invalid_operand_size |
call get_dword_value |
cmp [code_type],16 |
jne loop_jump_32bit_prefix_ok |
mov byte [edi],66h |
inc edi |
loop_jump_32bit_prefix_ok: |
call calculate_jump_offset |
cdq |
make_loop_jump: |
call check_for_short_jump |
jc conditional_jump_short |
jmp jump_out_of_range |
loop_jump_64bit: |
cmp [code_type],64 |
jne invalid_operand_size |
call get_qword_value |
call calculate_jump_offset |
mov ecx,edx |
cdq |
cmp edx,ecx |
jne value_out_of_range |
jmp make_loop_jump |
loop_jump_16bit: |
call get_word_value |
cmp [code_type],16 |
je loop_jump_16bit_prefix_ok |
mov byte [edi],66h |
inc edi |
loop_jump_16bit_prefix_ok: |
call calculate_jump_offset |
cwde |
cdq |
jmp make_loop_jump |
movs_instruction: |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
or eax,eax |
jnz invalid_address |
or bl,ch |
jnz invalid_address |
cmp [segment_register],1 |
ja invalid_address |
push ebx |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
pop edx |
or eax,eax |
jnz invalid_address |
or bl,ch |
jnz invalid_address |
mov al,dh |
mov ah,bh |
shr al,4 |
shr ah,4 |
cmp al,ah |
jne address_sizes_do_not_agree |
and bh,111b |
and dh,111b |
cmp bh,6 |
jne invalid_address |
cmp dh,7 |
jne invalid_address |
cmp al,2 |
je movs_address_16bit |
cmp al,4 |
je movs_address_32bit |
cmp [code_type],64 |
jne invalid_address_size |
jmp movs_store |
movs_address_32bit: |
call address_32bit_prefix |
jmp movs_store |
movs_address_16bit: |
cmp [code_type],64 |
je invalid_address_size |
call address_16bit_prefix |
movs_store: |
cmp [segment_register],4 |
je movs_segment_ok |
call store_segment_prefix |
movs_segment_ok: |
mov al,0A4h |
mov bl,[operand_size] |
cmp bl,1 |
je simple_instruction |
inc al |
cmp bl,2 |
je simple_instruction_16bit |
cmp bl,4 |
je simple_instruction_32bit |
cmp bl,8 |
je simple_instruction_64bit |
or bl,bl |
jz operand_size_not_specified |
jmp invalid_operand_size |
lods_instruction: |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
or eax,eax |
jnz invalid_address |
or bl,ch |
jnz invalid_address |
cmp bh,26h |
je lods_address_16bit |
cmp bh,46h |
je lods_address_32bit |
cmp bh,86h |
jne invalid_address |
cmp [code_type],64 |
jne invalid_address_size |
jmp lods_store |
lods_address_32bit: |
call address_32bit_prefix |
jmp lods_store |
lods_address_16bit: |
cmp [code_type],64 |
je invalid_address_size |
call address_16bit_prefix |
lods_store: |
cmp [segment_register],4 |
je lods_segment_ok |
call store_segment_prefix |
lods_segment_ok: |
mov al,0ACh |
mov bl,[operand_size] |
cmp bl,1 |
je simple_instruction |
inc al |
cmp bl,2 |
je simple_instruction_16bit |
cmp bl,4 |
je simple_instruction_32bit |
cmp bl,8 |
je simple_instruction_64bit |
or bl,bl |
jz operand_size_not_specified |
jmp invalid_operand_size |
stos_instruction: |
mov [base_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
or eax,eax |
jnz invalid_address |
or bl,ch |
jnz invalid_address |
cmp bh,27h |
je stos_address_16bit |
cmp bh,47h |
je stos_address_32bit |
cmp bh,87h |
jne invalid_address |
cmp [code_type],64 |
jne invalid_address_size |
jmp stos_store |
stos_address_32bit: |
call address_32bit_prefix |
jmp stos_store |
stos_address_16bit: |
cmp [code_type],64 |
je invalid_address_size |
call address_16bit_prefix |
stos_store: |
cmp [segment_register],1 |
ja invalid_address |
mov al,[base_code] |
mov bl,[operand_size] |
cmp bl,1 |
je simple_instruction |
inc al |
cmp bl,2 |
je simple_instruction_16bit |
cmp bl,4 |
je simple_instruction_32bit |
cmp bl,8 |
je simple_instruction_64bit |
or bl,bl |
jz operand_size_not_specified |
jmp invalid_operand_size |
cmps_instruction: |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
or eax,eax |
jnz invalid_address |
or bl,ch |
jnz invalid_address |
mov al,[segment_register] |
push ax bx |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
or eax,eax |
jnz invalid_address |
or bl,ch |
jnz invalid_address |
pop dx ax |
cmp [segment_register],1 |
ja invalid_address |
mov [segment_register],al |
mov al,dh |
mov ah,bh |
shr al,4 |
shr ah,4 |
cmp al,ah |
jne address_sizes_do_not_agree |
and bh,111b |
and dh,111b |
cmp bh,7 |
jne invalid_address |
cmp dh,6 |
jne invalid_address |
cmp al,2 |
je cmps_address_16bit |
cmp al,4 |
je cmps_address_32bit |
cmp [code_type],64 |
jne invalid_address_size |
jmp cmps_store |
cmps_address_32bit: |
call address_32bit_prefix |
jmp cmps_store |
cmps_address_16bit: |
cmp [code_type],64 |
je invalid_address_size |
call address_16bit_prefix |
cmps_store: |
cmp [segment_register],4 |
je cmps_segment_ok |
call store_segment_prefix |
cmps_segment_ok: |
mov al,0A6h |
mov bl,[operand_size] |
cmp bl,1 |
je simple_instruction |
inc al |
cmp bl,2 |
je simple_instruction_16bit |
cmp bl,4 |
je simple_instruction_32bit |
cmp bl,8 |
je simple_instruction_64bit |
or bl,bl |
jz operand_size_not_specified |
jmp invalid_operand_size |
ins_instruction: |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
or eax,eax |
jnz invalid_address |
or bl,ch |
jnz invalid_address |
cmp bh,27h |
je ins_address_16bit |
cmp bh,47h |
je ins_address_32bit |
cmp bh,87h |
jne invalid_address |
cmp [code_type],64 |
jne invalid_address_size |
jmp ins_store |
ins_address_32bit: |
call address_32bit_prefix |
jmp ins_store |
ins_address_16bit: |
cmp [code_type],64 |
je invalid_address_size |
call address_16bit_prefix |
ins_store: |
cmp [segment_register],1 |
ja invalid_address |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
cmp al,22h |
jne invalid_operand |
mov al,6Ch |
mov bl,[operand_size] |
cmp bl,1 |
je simple_instruction |
inc al |
cmp bl,2 |
je simple_instruction_16bit |
cmp bl,4 |
je simple_instruction_32bit |
or bl,bl |
jz operand_size_not_specified |
jmp invalid_operand_size |
outs_instruction: |
lods byte [esi] |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
cmp al,22h |
jne invalid_operand |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
or eax,eax |
jnz invalid_address |
or bl,ch |
jnz invalid_address |
cmp bh,26h |
je outs_address_16bit |
cmp bh,46h |
je outs_address_32bit |
cmp bh,86h |
jne invalid_address |
cmp [code_type],64 |
jne invalid_address_size |
jmp outs_store |
outs_address_32bit: |
call address_32bit_prefix |
jmp outs_store |
outs_address_16bit: |
cmp [code_type],64 |
je invalid_address_size |
call address_16bit_prefix |
outs_store: |
cmp [segment_register],4 |
je outs_segment_ok |
call store_segment_prefix |
outs_segment_ok: |
mov al,6Eh |
mov bl,[operand_size] |
cmp bl,1 |
je simple_instruction |
inc al |
cmp bl,2 |
je simple_instruction_16bit |
cmp bl,4 |
je simple_instruction_32bit |
or bl,bl |
jz operand_size_not_specified |
jmp invalid_operand_size |
xlat_instruction: |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
or eax,eax |
jnz invalid_address |
or bl,ch |
jnz invalid_address |
cmp bh,23h |
je xlat_address_16bit |
cmp bh,43h |
je xlat_address_32bit |
cmp bh,83h |
jne invalid_address |
cmp [code_type],64 |
jne invalid_address_size |
jmp xlat_store |
xlat_address_32bit: |
call address_32bit_prefix |
jmp xlat_store |
xlat_address_16bit: |
cmp [code_type],64 |
je invalid_address_size |
call address_16bit_prefix |
xlat_store: |
call store_segment_prefix_if_necessary |
mov al,0D7h |
cmp [operand_size],1 |
jbe simple_instruction |
jmp invalid_operand_size |
pm_word_instruction: |
mov ah,al |
shr ah,4 |
and al,111b |
mov [base_code],0Fh |
mov [extended_code],ah |
mov [postbyte_register],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je pm_reg |
pm_mem: |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov al,[operand_size] |
cmp al,2 |
je pm_mem_store |
or al,al |
jnz invalid_operand_size |
pm_mem_store: |
call store_instruction |
jmp instruction_assembled |
pm_reg: |
lods byte [esi] |
call convert_register |
mov bl,al |
cmp ah,2 |
jne invalid_operand_size |
call store_nomem_instruction |
jmp instruction_assembled |
pm_store_word_instruction: |
mov ah,al |
shr ah,4 |
and al,111b |
mov [base_code],0Fh |
mov [extended_code],ah |
mov [postbyte_register],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne pm_mem |
lods byte [esi] |
call convert_register |
mov bl,al |
mov al,ah |
call operand_autodetect |
call store_nomem_instruction |
jmp instruction_assembled |
lgdt_instruction: |
mov [base_code],0Fh |
mov [extended_code],1 |
mov [postbyte_register],al |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov al,[operand_size] |
cmp al,6 |
je lgdt_mem_48bit |
cmp al,10 |
je lgdt_mem_80bit |
or al,al |
jnz invalid_operand_size |
jmp lgdt_mem_store |
lgdt_mem_80bit: |
cmp [code_type],64 |
jne illegal_instruction |
jmp lgdt_mem_store |
lgdt_mem_48bit: |
cmp [code_type],64 |
je illegal_instruction |
cmp [postbyte_register],2 |
jb lgdt_mem_store |
call operand_32bit |
lgdt_mem_store: |
call store_instruction |
jmp instruction_assembled |
lar_instruction: |
mov [extended_code],al |
mov [base_code],0Fh |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
xor al,al |
xchg al,[operand_size] |
call operand_autodetect |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je lar_reg_reg |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov al,[operand_size] |
or al,al |
jz lar_reg_mem |
cmp al,2 |
jne invalid_operand_size |
lar_reg_mem: |
call store_instruction |
jmp instruction_assembled |
lar_reg_reg: |
lods byte [esi] |
call convert_register |
cmp ah,2 |
jne invalid_operand_size |
mov bl,al |
call store_nomem_instruction |
jmp instruction_assembled |
invlpg_instruction: |
mov [base_code],0Fh |
mov [extended_code],1 |
mov [postbyte_register],7 |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
call store_instruction |
jmp instruction_assembled |
swapgs_instruction: |
mov [base_code],0Fh |
mov [extended_code],1 |
mov [postbyte_register],7 |
mov bl,al |
call store_nomem_instruction |
jmp instruction_assembled |
basic_486_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je basic_486_reg |
cmp al,'[' |
jne invalid_operand |
call get_address |
push edx bx cx |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
pop cx bx edx |
mov al,ah |
cmp al,1 |
je basic_486_mem_reg_8bit |
call operand_autodetect |
inc [extended_code] |
basic_486_mem_reg_8bit: |
call store_instruction |
jmp instruction_assembled |
basic_486_reg: |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov bl,[postbyte_register] |
mov [postbyte_register],al |
mov al,ah |
cmp al,1 |
je basic_486_reg_reg_8bit |
call operand_autodetect |
inc [extended_code] |
basic_486_reg_reg_8bit: |
call store_nomem_instruction |
jmp instruction_assembled |
bswap_instruction: |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
test al,1000b |
jz bswap_reg_code_ok |
or [rex_prefix],41h |
and al,111b |
bswap_reg_code_ok: |
add al,0C8h |
mov [extended_code],al |
mov [base_code],0Fh |
cmp ah,8 |
je bswap_reg64 |
cmp ah,4 |
jne invalid_operand_size |
call operand_32bit |
call store_instruction_code |
jmp instruction_assembled |
bswap_reg64: |
call operand_64bit |
call store_instruction_code |
jmp instruction_assembled |
cmpxchgx_instruction: |
mov [base_code],0Fh |
mov [extended_code],0C7h |
mov [postbyte_register],al |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov ah,1 |
xchg [postbyte_register],ah |
mov al,[operand_size] |
or al,al |
jz cmpxchgx_size_ok |
cmp al,ah |
jne invalid_operand_size |
cmpxchgx_size_ok: |
cmp ah,16 |
jne cmpxchgx_store |
call operand_64bit |
cmpxchgx_store: |
call store_instruction |
jmp instruction_assembled |
basic_fpu_instruction: |
mov [postbyte_register],al |
mov [base_code],0D8h |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je basic_fpu_streg |
cmp al,'[' |
je basic_fpu_mem |
dec esi |
mov ah,[postbyte_register] |
cmp ah,2 |
jb invalid_operand |
cmp ah,3 |
ja invalid_operand |
mov bl,1 |
call store_nomem_instruction |
jmp instruction_assembled |
basic_fpu_mem: |
call get_address |
mov al,[operand_size] |
cmp al,4 |
je basic_fpu_mem_32bit |
cmp al,8 |
je basic_fpu_mem_64bit |
or al,al |
jnz invalid_operand_size |
cmp [error_line],0 |
jne basic_fpu_mem_32bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
basic_fpu_mem_32bit: |
call store_instruction |
jmp instruction_assembled |
basic_fpu_mem_64bit: |
mov [base_code],0DCh |
call store_instruction |
jmp instruction_assembled |
basic_fpu_streg: |
lods byte [esi] |
call convert_fpu_register |
mov bl,al |
mov ah,[postbyte_register] |
cmp ah,2 |
je basic_fpu_single_streg |
cmp ah,3 |
je basic_fpu_single_streg |
or al,al |
jz basic_fpu_st0 |
test ah,110b |
jz basic_fpu_streg_st0 |
xor [postbyte_register],1 |
basic_fpu_streg_st0: |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_fpu_register |
or al,al |
jnz invalid_operand |
mov [base_code],0DCh |
call store_nomem_instruction |
jmp instruction_assembled |
basic_fpu_st0: |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_fpu_register |
mov bl,al |
basic_fpu_single_streg: |
mov [base_code],0D8h |
call store_nomem_instruction |
jmp instruction_assembled |
simple_fpu_instruction: |
mov ah,al |
or ah,11000000b |
mov al,0D9h |
stos word [edi] |
jmp instruction_assembled |
fi_instruction: |
mov [postbyte_register],al |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov al,[operand_size] |
cmp al,2 |
je fi_mem_16bit |
cmp al,4 |
je fi_mem_32bit |
or al,al |
jnz invalid_operand_size |
cmp [error_line],0 |
jne fi_mem_32bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
fi_mem_32bit: |
mov [base_code],0DAh |
call store_instruction |
jmp instruction_assembled |
fi_mem_16bit: |
mov [base_code],0DEh |
call store_instruction |
jmp instruction_assembled |
fld_instruction: |
mov [postbyte_register],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je fld_streg |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov al,[operand_size] |
cmp al,4 |
je fld_mem_32bit |
cmp al,8 |
je fld_mem_64bit |
cmp al,10 |
je fld_mem_80bit |
or al,al |
jnz invalid_operand_size |
cmp [error_line],0 |
jne fld_mem_32bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
fld_mem_32bit: |
mov [base_code],0D9h |
call store_instruction |
jmp instruction_assembled |
fld_mem_64bit: |
mov [base_code],0DDh |
call store_instruction |
jmp instruction_assembled |
fld_mem_80bit: |
mov al,[postbyte_register] |
cmp al,0 |
je fld_mem_80bit_store |
dec [postbyte_register] |
cmp al,3 |
je fld_mem_80bit_store |
jmp invalid_operand_size |
fld_mem_80bit_store: |
add [postbyte_register],5 |
mov [base_code],0DBh |
call store_instruction |
jmp instruction_assembled |
fld_streg: |
lods byte [esi] |
call convert_fpu_register |
mov bl,al |
cmp [postbyte_register],2 |
jae fst_streg |
mov [base_code],0D9h |
call store_nomem_instruction |
jmp instruction_assembled |
fst_streg: |
mov [base_code],0DDh |
call store_nomem_instruction |
jmp instruction_assembled |
fild_instruction: |
mov [postbyte_register],al |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov al,[operand_size] |
cmp al,2 |
je fild_mem_16bit |
cmp al,4 |
je fild_mem_32bit |
cmp al,8 |
je fild_mem_64bit |
or al,al |
jnz invalid_operand_size |
cmp [error_line],0 |
jne fild_mem_32bit |
mov eax,[current_line] |
mov [error_line],eax |
mov [error],operand_size_not_specified |
fild_mem_32bit: |
mov [base_code],0DBh |
call store_instruction |
jmp instruction_assembled |
fild_mem_16bit: |
mov [base_code],0DFh |
call store_instruction |
jmp instruction_assembled |
fild_mem_64bit: |
mov al,[postbyte_register] |
cmp al,1 |
je fisttp_64bit_store |
jb fild_mem_64bit_store |
dec [postbyte_register] |
cmp al,3 |
je fild_mem_64bit_store |
jmp invalid_operand_size |
fild_mem_64bit_store: |
add [postbyte_register],5 |
mov [base_code],0DFh |
call store_instruction |
jmp instruction_assembled |
fisttp_64bit_store: |
mov [base_code],0DDh |
call store_instruction |
jmp instruction_assembled |
fbld_instruction: |
mov [postbyte_register],al |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov al,[operand_size] |
or al,al |
jz fbld_mem_80bit |
cmp al,10 |
je fbld_mem_80bit |
jmp invalid_operand_size |
fbld_mem_80bit: |
mov [base_code],0DFh |
call store_instruction |
jmp instruction_assembled |
faddp_instruction: |
mov [postbyte_register],al |
mov [base_code],0DEh |
mov edx,esi |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je faddp_streg |
mov esi,edx |
mov bl,1 |
call store_nomem_instruction |
jmp instruction_assembled |
faddp_streg: |
lods byte [esi] |
call convert_fpu_register |
mov bl,al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_fpu_register |
or al,al |
jnz invalid_operand |
call store_nomem_instruction |
jmp instruction_assembled |
fcompp_instruction: |
mov ax,0D9DEh |
stos word [edi] |
jmp instruction_assembled |
fucompp_instruction: |
mov ax,0E9DAh |
stos word [edi] |
jmp instruction_assembled |
fxch_instruction: |
mov dx,01D9h |
jmp fpu_single_operand |
ffreep_instruction: |
mov dx,00DFh |
jmp fpu_single_operand |
ffree_instruction: |
mov dl,0DDh |
mov dh,al |
fpu_single_operand: |
mov ebx,esi |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je fpu_streg |
or dh,dh |
jz invalid_operand |
mov esi,ebx |
shl dh,3 |
or dh,11000001b |
mov ax,dx |
stos word [edi] |
jmp instruction_assembled |
fpu_streg: |
lods byte [esi] |
call convert_fpu_register |
shl dh,3 |
or dh,al |
or dh,11000000b |
mov ax,dx |
stos word [edi] |
jmp instruction_assembled |
fstenv_instruction: |
mov byte [edi],9Bh |
inc edi |
fldenv_instruction: |
mov [base_code],0D9h |
jmp fpu_mem |
fsave_instruction: |
mov byte [edi],9Bh |
inc edi |
fnsave_instruction: |
mov [base_code],0DDh |
fpu_mem: |
mov [postbyte_register],al |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
cmp [operand_size],0 |
jne invalid_operand_size |
call store_instruction |
jmp instruction_assembled |
fstcw_instruction: |
mov byte [edi],9Bh |
inc edi |
fldcw_instruction: |
mov [postbyte_register],al |
mov [base_code],0D9h |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov al,[operand_size] |
or al,al |
jz fldcw_mem_16bit |
cmp al,2 |
je fldcw_mem_16bit |
jmp invalid_operand_size |
fldcw_mem_16bit: |
call store_instruction |
jmp instruction_assembled |
fstsw_instruction: |
mov al,9Bh |
stos byte [edi] |
fnstsw_instruction: |
mov [base_code],0DDh |
mov [postbyte_register],7 |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je fstsw_reg |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov al,[operand_size] |
or al,al |
jz fstsw_mem_16bit |
cmp al,2 |
je fstsw_mem_16bit |
jmp invalid_operand_size |
fstsw_mem_16bit: |
call store_instruction |
jmp instruction_assembled |
fstsw_reg: |
lods byte [esi] |
call convert_register |
cmp ax,0200h |
jne invalid_operand |
mov ax,0E0DFh |
stos word [edi] |
jmp instruction_assembled |
finit_instruction: |
mov byte [edi],9Bh |
inc edi |
fninit_instruction: |
mov ah,al |
mov al,0DBh |
stos word [edi] |
jmp instruction_assembled |
fcmov_instruction: |
mov dh,0DAh |
jmp fcomi_streg |
fcomi_instruction: |
mov dh,0DBh |
jmp fcomi_streg |
fcomip_instruction: |
mov dh,0DFh |
fcomi_streg: |
mov dl,al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_fpu_register |
mov ah,al |
cmp byte [esi],',' |
je fcomi_st0_streg |
add ah,dl |
mov al,dh |
stos word [edi] |
jmp instruction_assembled |
fcomi_st0_streg: |
or ah,ah |
jnz invalid_operand |
inc esi |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_fpu_register |
mov ah,al |
add ah,dl |
mov al,dh |
stos word [edi] |
jmp instruction_assembled |
mmx_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
call make_mmx_prefix |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je mmx_mmreg_mmreg |
cmp al,'[' |
jne invalid_operand |
mmx_mmreg_mem: |
call get_address |
call store_instruction |
jmp instruction_assembled |
mmx_mmreg_mmreg: |
lods byte [esi] |
call convert_mmx_register |
mov bl,al |
call store_nomem_instruction |
jmp instruction_assembled |
mmx_ps_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
call make_mmx_prefix |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
mov [operand_size],0 |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je mmx_mmreg_mmreg |
cmp al,'(' |
je mmx_ps_mmreg_imm8 |
cmp al,'[' |
je mmx_mmreg_mem |
jmp invalid_operand |
mmx_ps_mmreg_imm8: |
call get_byte_value |
mov byte [value],al |
test [operand_size],not 1 |
jnz invalid_value |
mov bl,[extended_code] |
mov al,bl |
shr bl,4 |
and al,1111b |
add al,70h |
mov [extended_code],al |
sub bl,0Ch |
shl bl,1 |
xchg bl,[postbyte_register] |
call store_nomem_instruction |
mov al,byte [value] |
stos byte [edi] |
jmp instruction_assembled |
pextrw_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
cmp ah,4 |
jnz invalid_operand_size |
mov [postbyte_register],al |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
mov bl,al |
call make_mmx_prefix |
cmp [extended_code],0C5h |
je mmx_nomem_imm8 |
call store_nomem_instruction |
jmp instruction_assembled |
mmx_imm8: |
push bx cx edx |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
test ah,not 1 |
jnz invalid_operand_size |
cmp al,'(' |
jne invalid_operand |
call get_byte_value |
mov byte [value],al |
pop edx cx bx |
call store_instruction_with_imm8 |
jmp instruction_assembled |
mmx_nomem_imm8: |
call store_nomem_instruction |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
test ah,not 1 |
jnz invalid_operand_size |
cmp al,'(' |
jne invalid_operand |
call get_byte_value |
stosb |
jmp instruction_assembled |
pinsrw_instruction: |
mov [extended_code],al |
mov [base_code],0Fh |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
call make_mmx_prefix |
mov [postbyte_register],al |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je pinsrw_mmreg_reg |
cmp al,'[' |
jne invalid_operand |
call get_address |
cmp [operand_size],0 |
je mmx_imm8 |
cmp [operand_size],2 |
jne invalid_operand_size |
jmp mmx_imm8 |
pinsrw_mmreg_reg: |
lods byte [esi] |
call convert_register |
cmp ah,4 |
jne invalid_operand_size |
mov bl,al |
jmp mmx_nomem_imm8 |
pshufw_instruction: |
mov [mmx_size],8 |
mov [operand_prefix],al |
jmp pshuf_instruction |
pshufd_instruction: |
mov [mmx_size],16 |
mov [operand_prefix],al |
pshuf_instruction: |
mov [base_code],0Fh |
mov [extended_code],70h |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,[mmx_size] |
jne invalid_operand_size |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je pshuf_mmreg_mmreg |
cmp al,'[' |
jne invalid_operand |
call get_address |
jmp mmx_imm8 |
pshuf_mmreg_mmreg: |
lods byte [esi] |
call convert_mmx_register |
mov bl,al |
jmp mmx_nomem_imm8 |
movd_instruction: |
mov [base_code],0Fh |
mov [extended_code],7Eh |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je movd_reg |
cmp al,'[' |
jne invalid_operand |
call get_address |
test [operand_size],not 4 |
jnz invalid_operand_size |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
call make_mmx_prefix |
mov [postbyte_register],al |
call store_instruction |
jmp instruction_assembled |
movd_reg: |
lods byte [esi] |
cmp al,0B0h |
jae movd_mmreg |
call convert_register |
cmp ah,4 |
jne invalid_operand_size |
mov [operand_size],0 |
mov bl,al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
mov [postbyte_register],al |
call make_mmx_prefix |
call store_nomem_instruction |
jmp instruction_assembled |
movd_mmreg: |
mov [extended_code],6Eh |
call convert_mmx_register |
call make_mmx_prefix |
mov [postbyte_register],al |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je movd_mmreg_reg |
cmp al,'[' |
jne invalid_operand |
call get_address |
test [operand_size],not 4 |
jnz invalid_operand_size |
call store_instruction |
jmp instruction_assembled |
movd_mmreg_reg: |
lods byte [esi] |
call convert_register |
cmp ah,4 |
jne invalid_operand_size |
mov bl,al |
call store_nomem_instruction |
jmp instruction_assembled |
make_mmx_prefix: |
cmp [operand_size],16 |
jne no_mmx_prefix |
mov [operand_prefix],66h |
no_mmx_prefix: |
ret |
movq_instruction: |
mov [base_code],0Fh |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je movq_reg |
cmp al,'[' |
jne invalid_operand |
call get_address |
test [operand_size],not 8 |
jnz invalid_operand_size |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
mov [postbyte_register],al |
cmp ah,16 |
je movq_mem_xmmreg |
mov [extended_code],7Fh |
call store_instruction |
jmp instruction_assembled |
movq_mem_xmmreg: |
mov [extended_code],0D6h |
mov [operand_prefix],66h |
call store_instruction |
jmp instruction_assembled |
movq_reg: |
lods byte [esi] |
cmp al,0B0h |
jae movq_mmreg |
call convert_register |
cmp ah,8 |
jne invalid_operand_size |
mov bl,al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
mov [postbyte_register],al |
call make_mmx_prefix |
mov [extended_code],7Eh |
call operand_64bit |
call store_nomem_instruction |
jmp instruction_assembled |
movq_mmreg: |
call convert_mmx_register |
mov [postbyte_register],al |
mov [extended_code],6Fh |
mov [mmx_size],ah |
cmp ah,16 |
jne movq_mmreg_ |
mov [extended_code],7Eh |
mov [operand_prefix],0F3h |
movq_mmreg_: |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je movq_mmreg_reg |
call get_address |
test [operand_size],not 8 |
jnz invalid_operand_size |
call store_instruction |
jmp instruction_assembled |
movq_mmreg_reg: |
lods byte [esi] |
cmp al,0B0h |
jae movq_mmreg_mmreg |
mov [operand_size],0 |
call convert_register |
cmp ah,8 |
jne invalid_operand_size |
mov [extended_code],6Eh |
mov [operand_prefix],0 |
mov bl,al |
cmp [mmx_size],16 |
jne movq_mmreg_reg_store |
mov [operand_prefix],66h |
movq_mmreg_reg_store: |
call operand_64bit |
call store_nomem_instruction |
jmp instruction_assembled |
movq_mmreg_mmreg: |
call convert_mmx_register |
mov bl,al |
call store_nomem_instruction |
jmp instruction_assembled |
movdq_instruction: |
mov [operand_prefix],al |
mov [base_code],0Fh |
mov [extended_code],6Fh |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je movdq_mmreg |
cmp al,'[' |
jne invalid_operand |
call get_address |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov [postbyte_register],al |
mov [extended_code],7Fh |
call store_instruction |
jmp instruction_assembled |
movdq_mmreg: |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je movdq_mmreg_mmreg |
cmp al,'[' |
jne invalid_operand |
call get_address |
call store_instruction |
jmp instruction_assembled |
movdq_mmreg_mmreg: |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov bl,al |
call store_nomem_instruction |
jmp instruction_assembled |
lddqu_instruction: |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
push eax |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
pop eax |
mov [postbyte_register],al |
mov [operand_prefix],0F2h |
mov [base_code],0Fh |
mov [extended_code],0F0h |
call store_instruction |
jmp instruction_assembled |
movq2dq_instruction: |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov [postbyte_register],al |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,8 |
jne invalid_operand_size |
mov bl,al |
mov [operand_prefix],0F3h |
mov [base_code],0Fh |
mov [extended_code],0D6h |
call store_nomem_instruction |
jmp instruction_assembled |
movdq2q_instruction: |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,8 |
jne invalid_operand_size |
mov [postbyte_register],al |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov bl,al |
mov [operand_prefix],0F2h |
mov [base_code],0Fh |
mov [extended_code],0D6h |
call store_nomem_instruction |
jmp instruction_assembled |
sse_ps_instruction: |
mov [mmx_size],16 |
jmp sse_instruction |
sse_pd_instruction: |
mov [mmx_size],16 |
mov [operand_prefix],66h |
jmp sse_instruction |
sse_ss_instruction: |
mov [mmx_size],4 |
mov [operand_prefix],0F3h |
jmp sse_instruction |
sse_sd_instruction: |
mov [mmx_size],8 |
mov [operand_prefix],0F2h |
jmp sse_instruction |
comiss_instruction: |
mov [mmx_size],4 |
jmp sse_instruction |
comisd_instruction: |
mov [mmx_size],8 |
mov [operand_prefix],66h |
jmp sse_instruction |
cvtps2pd_instruction: |
mov [mmx_size],8 |
jmp sse_instruction |
cvtpd2dq_instruction: |
mov [mmx_size],16 |
mov [operand_prefix],0F2h |
jmp sse_instruction |
cvtdq2pd_instruction: |
mov [mmx_size],16 |
mov [operand_prefix],0F3h |
sse_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
sse_xmmreg: |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
sse_reg: |
mov [postbyte_register],al |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je sse_xmmreg_xmmreg |
sse_reg_mem: |
cmp al,'[' |
jne invalid_operand |
call get_address |
cmp [operand_size],0 |
je sse_mem_size_ok |
mov al,[mmx_size] |
cmp [operand_size],al |
jne invalid_operand_size |
sse_mem_size_ok: |
cmp [extended_code],0C6h |
je mmx_imm8 |
call store_instruction |
jmp instruction_assembled |
sse_xmmreg_xmmreg: |
cmp [operand_prefix],66h |
jne sse_xmmreg_xmmreg_ok |
cmp [extended_code],12h |
je invalid_operand |
cmp [extended_code],16h |
je invalid_operand |
sse_xmmreg_xmmreg_ok: |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov bl,al |
cmp [extended_code],0C6h |
je mmx_nomem_imm8 |
call store_nomem_instruction |
jmp instruction_assembled |
ps_dq_instruction: |
mov [postbyte_register],al |
mov [operand_prefix],66h |
mov [base_code],0Fh |
mov [extended_code],73h |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov bl,al |
jmp mmx_nomem_imm8 |
movpd_instruction: |
mov [operand_prefix],66h |
movps_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
mov [mmx_size],16 |
jmp sse_mov_instruction |
movss_instruction: |
mov [mmx_size],4 |
mov [operand_prefix],0F3h |
jmp sse_movs |
movsd_instruction: |
mov al,0A5h |
mov ah,[esi] |
or ah,ah |
jz simple_instruction_32bit |
cmp ah,0Fh |
je simple_instruction_32bit |
mov [mmx_size],8 |
mov [operand_prefix],0F2h |
sse_movs: |
mov [base_code],0Fh |
mov [extended_code],10h |
jmp sse_mov_instruction |
sse_mov_instruction: |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je sse_xmmreg |
sse_mem: |
cmp al,'[' |
jne invalid_operand |
inc [extended_code] |
call get_address |
cmp [operand_size],0 |
je sse_mem_xmmreg |
mov al,[mmx_size] |
cmp [operand_size],al |
jne invalid_operand_size |
mov [operand_size],0 |
sse_mem_xmmreg: |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov [postbyte_register],al |
call store_instruction |
jmp instruction_assembled |
movlpd_instruction: |
mov [operand_prefix],66h |
movlps_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
mov [mmx_size],8 |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne sse_mem |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov [postbyte_register],al |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
jmp sse_reg_mem |
movhlps_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
mov [mmx_size],0 |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je sse_xmmreg_xmmreg_ok |
jmp invalid_operand |
maskmovq_instruction: |
mov cl,8 |
jmp maskmov_instruction |
maskmovdqu_instruction: |
mov cl,16 |
mov [operand_prefix],66h |
maskmov_instruction: |
mov [base_code],0Fh |
mov [extended_code],0F7h |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,cl |
jne invalid_operand_size |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
mov bl,al |
call store_nomem_instruction |
jmp instruction_assembled |
movmskpd_instruction: |
mov [operand_prefix],66h |
movmskps_instruction: |
mov [base_code],0Fh |
mov [extended_code],50h |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
cmp ah,4 |
jne invalid_operand_size |
mov [operand_size],0 |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov bl,al |
call store_nomem_instruction |
jmp instruction_assembled |
cmppd_instruction: |
mov [operand_prefix],66h |
cmpps_instruction: |
mov [base_code],0Fh |
mov [extended_code],0C2h |
mov [mmx_size],16 |
mov byte [value],-1 |
jmp sse_cmp_instruction |
cmp_pd_instruction: |
mov [operand_prefix],66h |
cmp_ps_instruction: |
mov [base_code],0Fh |
mov [extended_code],0C2h |
mov [mmx_size],16 |
mov byte [value],al |
jmp sse_cmp_instruction |
cmpss_instruction: |
mov [mmx_size],4 |
mov [operand_prefix],0F3h |
jmp cmpsx_instruction |
cmpsd_instruction: |
mov al,0A7h |
mov ah,[esi] |
or ah,ah |
jz simple_instruction_32bit |
cmp ah,0Fh |
je simple_instruction_32bit |
mov [mmx_size],8 |
mov [operand_prefix],0F2h |
cmpsx_instruction: |
mov [base_code],0Fh |
mov [extended_code],0C2h |
mov byte [value],-1 |
jmp sse_cmp_instruction |
cmp_ss_instruction: |
mov [mmx_size],4 |
mov [operand_prefix],0F3h |
jmp cmp_sx_instruction |
cmp_sd_instruction: |
mov [mmx_size],8 |
mov [operand_prefix],0F2h |
cmp_sx_instruction: |
mov [base_code],0Fh |
mov [extended_code],0C2h |
mov byte [value],al |
sse_cmp_instruction: |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
mov [operand_size],0 |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je sse_cmp_xmmreg_xmmreg |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov al,[operand_size] |
or al,al |
jz sse_cmp_size_ok |
cmp al,[mmx_size] |
jne invalid_operand_size |
sse_cmp_size_ok: |
push bx cx edx |
call get_nextbyte |
pop edx cx bx |
call store_instruction_with_imm8 |
jmp instruction_assembled |
sse_cmp_xmmreg_xmmreg: |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov bl,al |
call store_nomem_instruction |
call get_nextbyte |
mov al,byte [value] |
stos byte [edi] |
jmp instruction_assembled |
get_nextbyte: |
cmp byte [value],-1 |
jne nextbyte_ok |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
test [operand_size],not 1 |
jnz invalid_value |
cmp al,'(' |
jne invalid_operand |
call get_byte_value |
cmp al,7 |
ja invalid_value |
mov byte [value],al |
nextbyte_ok: |
ret |
cvtpi2pd_instruction: |
mov [operand_prefix],66h |
cvtpi2ps_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov [postbyte_register],al |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je cvtpi_xmmreg_xmmreg |
cmp al,'[' |
jne invalid_operand |
call get_address |
cmp [operand_size],0 |
je cvtpi_size_ok |
cmp [operand_size],8 |
jne invalid_operand_size |
cvtpi_size_ok: |
call store_instruction |
jmp instruction_assembled |
cvtpi_xmmreg_xmmreg: |
lods byte [esi] |
call convert_mmx_register |
cmp ah,8 |
jne invalid_operand_size |
mov bl,al |
call store_nomem_instruction |
jmp instruction_assembled |
cvtsi2ss_instruction: |
mov [operand_prefix],0F3h |
jmp cvtsi_instruction |
cvtsi2sd_instruction: |
mov [operand_prefix],0F2h |
cvtsi_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,16 |
jne invalid_operand_size |
mov [postbyte_register],al |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je cvtsi_xmmreg_reg |
cmp al,'[' |
jne invalid_operand |
call get_address |
cmp [operand_size],0 |
je cvtsi_size_ok |
cmp [operand_size],4 |
jne invalid_operand_size |
cvtsi_size_ok: |
call store_instruction |
jmp instruction_assembled |
cvtsi_xmmreg_reg: |
lods byte [esi] |
call convert_register |
cmp ah,4 |
je cvtsi_xmmreg_reg_store |
cmp ah,8 |
jne invalid_operand_size |
call operand_64bit |
cvtsi_xmmreg_reg_store: |
mov bl,al |
call store_nomem_instruction |
jmp instruction_assembled |
cvtps2pi_instruction: |
mov [mmx_size],8 |
jmp cvtpd_instruction |
cvtpd2pi_instruction: |
mov [operand_prefix],66h |
mov [mmx_size],16 |
cvtpd_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,8 |
jne invalid_operand_size |
mov [operand_size],0 |
jmp sse_reg |
cvtss2si_instruction: |
mov [operand_prefix],0F3h |
mov [mmx_size],4 |
jmp cvt2si_instruction |
cvtsd2si_instruction: |
mov [operand_prefix],0F2h |
mov [mmx_size],8 |
cvt2si_instruction: |
mov [extended_code],al |
mov [base_code],0Fh |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [operand_size],0 |
cmp ah,4 |
je sse_reg |
cmp ah,8 |
jne invalid_operand_size |
call operand_64bit |
jmp sse_reg |
amd3dnow_instruction: |
mov [base_code],0Fh |
mov [extended_code],0Fh |
mov byte [value],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,8 |
jne invalid_operand_size |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
je amd3dnow_mmreg_mmreg |
cmp al,'[' |
jne invalid_operand |
call get_address |
call store_instruction_with_imm8 |
jmp instruction_assembled |
amd3dnow_mmreg_mmreg: |
lods byte [esi] |
call convert_mmx_register |
cmp ah,8 |
jne invalid_operand_size |
mov bl,al |
call store_nomem_instruction |
mov al,byte [value] |
stos byte [edi] |
jmp instruction_assembled |
fxsave_instruction: |
mov [extended_code],0AEh |
mov [base_code],0Fh |
mov [postbyte_register],al |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov ah,[operand_size] |
or ah,ah |
jz fxsave_size_ok |
mov al,[postbyte_register] |
cmp al,111b |
je clflush_size_check |
cmp al,10b |
jb invalid_operand_size |
cmp al,11b |
ja invalid_operand_size |
cmp ah,4 |
jne invalid_operand_size |
jmp fxsave_size_ok |
clflush_size_check: |
cmp ah,1 |
jne invalid_operand_size |
fxsave_size_ok: |
call store_instruction |
jmp instruction_assembled |
prefetch_instruction: |
mov [extended_code],18h |
prefetch_mem_8bit: |
mov [base_code],0Fh |
mov [postbyte_register],al |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
or ah,ah |
jz prefetch_size_ok |
cmp ah,1 |
jne invalid_operand_size |
prefetch_size_ok: |
call get_address |
call store_instruction |
jmp instruction_assembled |
amd_prefetch_instruction: |
mov [extended_code],0Dh |
jmp prefetch_mem_8bit |
fence_instruction: |
mov bl,al |
mov ax,0AE0Fh |
stos word [edi] |
mov al,bl |
stos byte [edi] |
jmp instruction_assembled |
pause_instruction: |
mov ax,90F3h |
stos word [edi] |
jmp instruction_assembled |
movntq_instruction: |
mov [mmx_size],8 |
jmp movnt_instruction |
movntps_instruction: |
mov [mmx_size],16 |
jmp movnt_instruction |
movntdq_instruction: |
mov [operand_prefix],66h |
mov [mmx_size],16 |
movnt_instruction: |
mov [extended_code],al |
mov [base_code],0Fh |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_mmx_register |
cmp ah,[mmx_size] |
jne invalid_operand_size |
mov [postbyte_register],al |
call store_instruction |
jmp instruction_assembled |
movnti_instruction: |
mov [base_code],0Fh |
mov [extended_code],al |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
cmp ah,4 |
je movnti_store |
cmp ah,8 |
jne invalid_operand_size |
call operand_64bit |
movnti_store: |
mov [postbyte_register],al |
call store_instruction |
jmp instruction_assembled |
monitor_instruction: |
mov [postbyte_register],al |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
cmp ax,0400h |
jne invalid_operand |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
cmp ax,0401h |
jne invalid_operand |
cmp [postbyte_register],0C8h |
jne monitor_instruction_store |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
cmp ax,0402h |
jne invalid_operand |
monitor_instruction_store: |
mov ax,010Fh |
stos word [edi] |
mov al,[postbyte_register] |
stos byte [edi] |
jmp instruction_assembled |
simple_vmx_instruction: |
mov ah,al |
mov al,0Fh |
stos byte [edi] |
mov al,1 |
stos word [edi] |
jmp instruction_assembled |
vmclear_instruction: |
mov [operand_prefix],66h |
jmp vmx_instruction |
vmxon_instruction: |
mov [operand_prefix],0F3h |
vmx_instruction: |
mov [postbyte_register],al |
mov [extended_code],0C7h |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
mov al,[operand_size] |
or al,al |
jz vmx_size_ok |
cmp al,8 |
jne invalid_operand_size |
vmx_size_ok: |
mov [base_code],0Fh |
call store_instruction |
jmp instruction_assembled |
vmread_instruction: |
mov [extended_code],78h |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
vmread_check_size: |
cmp [code_type],64 |
je vmread_long |
cmp [operand_size],4 |
je vmx_size_ok |
jmp invalid_operand_size |
vmread_long: |
cmp [operand_size],8 |
je vmx_size_ok |
jmp invalid_operand_size |
vmwrite_instruction: |
mov [extended_code],79h |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
mov [postbyte_register],al |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,'[' |
jne invalid_operand |
call get_address |
jmp vmread_check_size |
simple_svm_instruction: |
push eax |
mov [base_code],0Fh |
mov [extended_code],1 |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
or al,al |
jnz invalid_operand |
simple_svm_detect_size: |
cmp ah,2 |
je simple_svm_16bit |
cmp ah,4 |
je simple_svm_32bit |
cmp [code_type],64 |
jne invalid_operand_size |
jmp simple_svm_store |
simple_svm_16bit: |
cmp [code_type],16 |
je simple_svm_store |
cmp [code_type],64 |
je invalid_operand_size |
jmp prefixed_svm_store |
simple_svm_32bit: |
cmp [code_type],32 |
je simple_svm_store |
prefixed_svm_store: |
mov al,67h |
stos byte [edi] |
simple_svm_store: |
call store_instruction_code |
pop eax |
stos byte [edi] |
jmp instruction_assembled |
skinit_instruction: |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
cmp ax,0400h |
jne invalid_operand |
mov al,0DEh |
jmp simple_vmx_instruction |
invlpga_instruction: |
push eax |
mov [base_code],0Fh |
mov [extended_code],1 |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
or al,al |
jnz invalid_operand |
mov bl,ah |
mov [operand_size],0 |
lods byte [esi] |
cmp al,',' |
jne invalid_operand |
lods byte [esi] |
call get_size_operator |
cmp al,10h |
jne invalid_operand |
lods byte [esi] |
call convert_register |
cmp ax,0401h |
jne invalid_operand |
mov ah,bl |
jmp simple_svm_detect_size |
convert_register: |
mov ah,al |
shr ah,4 |
and al,0Fh |
cmp ah,8 |
je match_register_size |
cmp ah,4 |
ja invalid_operand |
cmp ah,1 |
ja match_register_size |
cmp al,4 |
jb match_register_size |
or ah,ah |
jz high_byte_register |
or [rex_prefix],40h |
match_register_size: |
cmp ah,[operand_size] |
je register_size_ok |
cmp [operand_size],0 |
jne operand_sizes_do_not_match |
mov [operand_size],ah |
register_size_ok: |
ret |
high_byte_register: |
mov ah,1 |
or [rex_prefix],80h |
jmp match_register_size |
convert_fpu_register: |
mov ah,al |
shr ah,4 |
and al,111b |
cmp ah,10 |
jne invalid_operand |
jmp match_register_size |
convert_mmx_register: |
mov ah,al |
shr ah,4 |
cmp ah,0Ch |
je xmm_register |
ja invalid_operand |
and al,111b |
cmp ah,0Bh |
jne invalid_operand |
mov ah,8 |
jmp match_register_size |
xmm_register: |
and al,0Fh |
mov ah,16 |
cmp al,8 |
jb match_register_size |
cmp [code_type],64 |
jne invalid_operand |
jmp match_register_size |
get_size_operator: |
xor ah,ah |
cmp al,11h |
jne no_size_operator |
mov [size_declared],1 |
lods word [esi] |
xchg al,ah |
mov [size_override],1 |
cmp ah,[operand_size] |
je size_operator_ok |
cmp [operand_size],0 |
jne operand_sizes_do_not_match |
mov [operand_size],ah |
size_operator_ok: |
ret |
no_size_operator: |
mov [size_declared],0 |
cmp al,'[' |
jne size_operator_ok |
mov [size_override],0 |
ret |
get_jump_operator: |
mov [jump_type],0 |
cmp al,12h |
jne jump_operator_ok |
lods word [esi] |
mov [jump_type],al |
mov al,ah |
jump_operator_ok: |
ret |
get_address: |
mov [segment_register],0 |
mov [address_size],0 |
mov al,[code_type] |
shr al,3 |
mov [value_size],al |
mov al,[esi] |
and al,11110000b |
cmp al,60h |
jne get_size_prefix |
lods byte [esi] |
sub al,60h |
mov [segment_register],al |
mov al,[esi] |
and al,11110000b |
get_size_prefix: |
cmp al,70h |
jne address_size_prefix_ok |
lods byte [esi] |
sub al,70h |
cmp al,2 |
jb invalid_address_size |
cmp al,8 |
ja invalid_address_size |
mov [address_size],al |
mov [value_size],al |
address_size_prefix_ok: |
call calculate_address |
cmp byte [esi-1],']' |
jne invalid_address |
mov [address_high],edx |
mov edx,eax |
cmp [code_type],64 |
jne address_ok |
or bx,bx |
jnz address_ok |
test ch,0Fh |
jnz address_ok |
calculate_relative_address: |
call calculate_relative_offset |
cmp byte [esi-1],']' |
jne invalid_address |
mov [address_high],edx |
mov edx,[symbol_identifier] |
mov [address_symbol],edx |
mov edx,eax |
mov ch,[value_type] |
mov bx,0FF00h |
xor cl,cl |
address_ok: |
ret |
operand_16bit: |
cmp [code_type],16 |
je size_prefix_ok |
mov [operand_prefix],66h |
ret |
operand_32bit: |
cmp [code_type],16 |
jne size_prefix_ok |
mov [operand_prefix],66h |
size_prefix_ok: |
ret |
operand_64bit: |
cmp [code_type],64 |
jne illegal_instruction |
or [rex_prefix],48h |
ret |
operand_autodetect: |
cmp al,2 |
je operand_16bit |
cmp al,4 |
je operand_32bit |
cmp al,8 |
je operand_64bit |
jmp invalid_operand_size |
store_segment_prefix_if_necessary: |
mov al,[segment_register] |
or al,al |
jz segment_prefix_ok |
cmp al,3 |
je ss_prefix |
cmp al,4 |
ja segment_prefix_386 |
jb segment_prefix_86 |
cmp bl,25h |
je segment_prefix_86 |
cmp bh,25h |
je segment_prefix_86 |
cmp bh,45h |
je segment_prefix_86 |
cmp bh,44h |
je segment_prefix_86 |
ret |
ss_prefix: |
cmp bl,25h |
je segment_prefix_ok |
cmp bh,25h |
je segment_prefix_ok |
cmp bh,45h |
je segment_prefix_ok |
cmp bh,44h |
je segment_prefix_ok |
jmp segment_prefix_86 |
store_segment_prefix: |
mov al,[segment_register] |
or al,al |
jz segment_prefix_ok |
cmp al,5 |
jae segment_prefix_386 |
segment_prefix_86: |
dec al |
shl al,3 |
add al,26h |
stos byte [edi] |
jmp segment_prefix_ok |
segment_prefix_386: |
add al,64h-5 |
stos byte [edi] |
segment_prefix_ok: |
ret |
store_instruction_code: |
mov al,[operand_prefix] |
or al,al |
jz operand_prefix_ok |
stos byte [edi] |
operand_prefix_ok: |
mov al,[rex_prefix] |
test al,40h |
jz rex_prefix_ok |
cmp [code_type],64 |
jne invalid_operand |
test al,0B0h |
jnz prefix_conflict |
stos byte [edi] |
rex_prefix_ok: |
mov al,[base_code] |
stos byte [edi] |
cmp al,0Fh |
jne instruction_code_ok |
store_extended_code: |
mov al,[extended_code] |
stos byte [edi] |
instruction_code_ok: |
ret |
store_nomem_instruction: |
test [postbyte_register],1000b |
jz nomem_reg_code_ok |
or [rex_prefix],44h |
and [postbyte_register],111b |
nomem_reg_code_ok: |
test bl,1000b |
jz nomem_rm_code_ok |
or [rex_prefix],41h |
and bl,111b |
nomem_rm_code_ok: |
call store_instruction_code |
mov al,[postbyte_register] |
shl al,3 |
or al,bl |
or al,11000000b |
stos byte [edi] |
ret |
store_instruction: |
mov [current_offset],edi |
test [postbyte_register],1000b |
jz reg_code_ok |
or [rex_prefix],44h |
and [postbyte_register],111b |
reg_code_ok: |
call store_segment_prefix_if_necessary |
or bx,bx |
jz address_immediate |
cmp bx,0F000h |
je address_rip_based |
cmp bx,0FF00h |
je address_relative |
mov al,bl |
or al,bh |
and al,11110000b |
cmp al,80h |
je postbyte_64bit |
cmp al,40h |
je postbyte_32bit |
cmp al,20h |
jne invalid_address |
cmp [code_type],64 |
je invalid_address_size |
call address_16bit_prefix |
call store_instruction_code |
cmp bx,2326h |
je address_bx_si |
cmp bx,2623h |
je address_bx_si |
cmp bx,2327h |
je address_bx_di |
cmp bx,2723h |
je address_bx_di |
cmp bx,2526h |
je address_bp_si |
cmp bx,2625h |
je address_bp_si |
cmp bx,2527h |
je address_bp_di |
cmp bx,2725h |
je address_bp_di |
cmp bx,2600h |
je address_si |
cmp bx,2700h |
je address_di |
cmp bx,2300h |
je address_bx |
cmp bx,2500h |
je address_bp |
jmp invalid_address |
address_bx_si: |
xor al,al |
jmp postbyte_16bit |
address_bx_di: |
mov al,1 |
jmp postbyte_16bit |
address_bp_si: |
mov al,10b |
jmp postbyte_16bit |
address_bp_di: |
mov al,11b |
jmp postbyte_16bit |
address_si: |
mov al,100b |
jmp postbyte_16bit |
address_di: |
mov al,101b |
jmp postbyte_16bit |
address_bx: |
mov al,111b |
jmp postbyte_16bit |
address_bp: |
mov al,110b |
postbyte_16bit: |
test ch,22h |
jnz address_16bit_value |
or ch,ch |
jnz address_sizes_do_not_agree |
cmp edx,10000h |
jge value_out_of_range |
cmp edx,-8000h |
jl value_out_of_range |
or dx,dx |
jz address |
cmp dx,80h |
jb address_8bit_value |
cmp dx,-80h |
jae address_8bit_value |
address_16bit_value: |
or al,10000000b |
mov cl,[postbyte_register] |
shl cl,3 |
or al,cl |
stos byte [edi] |
mov eax,edx |
stos word [edi] |
ret |
address_8bit_value: |
or al,01000000b |
mov cl,[postbyte_register] |
shl cl,3 |
or al,cl |
stos byte [edi] |
mov al,dl |
stos byte [edi] |
cmp dx,80h |
jge value_out_of_range |
cmp dx,-80h |
jl value_out_of_range |
ret |
address: |
cmp al,110b |
je address_8bit_value |
mov cl,[postbyte_register] |
shl cl,3 |
or al,cl |
stos byte [edi] |
ret |
postbyte_32bit: |
call address_32bit_prefix |
jmp address_prefix_ok |
postbyte_64bit: |
cmp [code_type],64 |
jne invalid_address_size |
address_prefix_ok: |
test bh,1000b |
jz base_code_ok |
or [rex_prefix],41h |
base_code_ok: |
test bl,1000b |
jz index_code_ok |
or [rex_prefix],42h |
index_code_ok: |
call store_instruction_code |
cmp bl,44h |
je swap_base_with_index |
cmp bl,84h |
jne base_register_ok |
swap_base_with_index: |
cmp cl,1 |
jne invalid_address |
xchg bl,bh |
cmp bl,44h |
je invalid_address |
cmp bl,84h |
je invalid_address |
base_register_ok: |
or cl,cl |
jz only_base_register |
base_and_index: |
mov al,100b |
xor ah,ah |
cmp cl,1 |
je scale_ok |
cmp cl,2 |
je scale_1 |
cmp cl,4 |
je scale_2 |
or ah,11000000b |
jmp scale_ok |
scale_2: |
or ah,10000000b |
jmp scale_ok |
scale_1: |
or ah,01000000b |
scale_ok: |
or bh,bh |
jz only_index_register |
and bl,111b |
shl bl,3 |
or ah,bl |
and bh,111b |
or ah,bh |
test ch,44h |
jnz sib_address_32bit_value |
test ch,88h |
jnz sib_address_32bit_value |
or ch,ch |
jnz address_sizes_do_not_agree |
cmp bh,5 |
je address_value |
or edx,edx |
jz sib_address |
address_value: |
cmp edx,80h |
jb sib_address_8bit_value |
cmp edx,-80h |
jae sib_address_8bit_value |
sib_address_32bit_value: |
or al,10000000b |
mov cl,[postbyte_register] |
shl cl,3 |
or al,cl |
stos word [edi] |
jmp store_address_32bit_value |
sib_address_8bit_value: |
or al,01000000b |
mov cl,[postbyte_register] |
shl cl,3 |
or al,cl |
stos word [edi] |
mov al,dl |
stos byte [edi] |
cmp edx,80h |
jge value_out_of_range |
cmp edx,-80h |
jl value_out_of_range |
ret |
sib_address: |
mov cl,[postbyte_register] |
shl cl,3 |
or al,cl |
stos word [edi] |
ret |
only_index_register: |
or ah,101b |
and bl,111b |
shl bl,3 |
or ah,bl |
mov cl,[postbyte_register] |
shl cl,3 |
or al,cl |
stos word [edi] |
test ch,44h |
jnz store_address_32bit_value |
or ch,ch |
jnz invalid_address_size |
jmp store_address_32bit_value |
zero_index_register: |
mov bl,4 |
mov cl,1 |
jmp base_and_index |
only_base_register: |
mov al,bh |
and al,111b |
cmp al,4 |
je zero_index_register |
test ch,44h |
jnz simple_address_32bit_value |
test ch,88h |
jnz simple_address_32bit_value |
or ch,ch |
jnz address_sizes_do_not_agree |
or edx,edx |
jz simple_address |
cmp edx,80h |
jb simple_address_8bit_value |
cmp edx,-80h |
jae simple_address_8bit_value |
simple_address_32bit_value: |
or al,10000000b |
mov cl,[postbyte_register] |
shl cl,3 |
or al,cl |
stos byte [edi] |
jmp store_address_32bit_value |
simple_address_8bit_value: |
or al,01000000b |
mov cl,[postbyte_register] |
shl cl,3 |
or al,cl |
stos byte [edi] |
mov al,dl |
stos byte [edi] |
cmp edx,80h |
jge value_out_of_range |
cmp edx,-80h |
jl value_out_of_range |
ret |
simple_address: |
cmp al,5 |
je simple_address_8bit_value |
mov cl,[postbyte_register] |
shl cl,3 |
or al,cl |
stos byte [edi] |
ret |
address_immediate: |
cmp [code_type],64 |
je address_immediate_sib |
test ch,44h |
jnz address_immediate_32bit |
test ch,22h |
jnz address_immediate_16bit |
or ch,ch |
jnz invalid_address_size |
cmp [code_type],16 |
je addressing_16bit |
address_immediate_32bit: |
call address_32bit_prefix |
call store_instruction_code |
store_immediate_address: |
mov al,101b |
mov cl,[postbyte_register] |
shl cl,3 |
or al,cl |
stos byte [edi] |
store_address_32bit_value: |
test ch,0F0h |
jz address_32bit_relocation_ok |
mov al,2 |
xchg [value_type],al |
mov ebx,[address_symbol] |
xchg ebx,[symbol_identifier] |
call mark_relocation |
mov [value_type],al |
mov [symbol_identifier],ebx |
address_32bit_relocation_ok: |
mov eax,edx |
stos dword [edi] |
ret |
store_address_64bit_value: |
test ch,0F0h |
jz address_64bit_relocation_ok |
mov al,4 |
xchg [value_type],al |
mov ebx,[address_symbol] |
xchg ebx,[symbol_identifier] |
call mark_relocation |
mov [value_type],al |
mov [symbol_identifier],ebx |
address_64bit_relocation_ok: |
mov eax,edx |
stos dword [edi] |
mov eax,[address_high] |
stos dword [edi] |
ret |
address_immediate_sib: |
test ch,not 44h |
jnz invalid_address_size |
cmp [value_type],0 |
jne address_immediate_sib_nosignextend |
test edx,80000000h |
jz address_immediate_sib_prefix_ok |
address_immediate_sib_nosignextend: |
call address_32bit_prefix |
address_immediate_sib_prefix_ok: |
call store_instruction_code |
mov al,100b |
mov ah,100101b |
mov cl,[postbyte_register] |
shl cl,3 |
or al,cl |
stos word [edi] |
jmp store_address_32bit_value |
address_rip_based: |
cmp [code_type],64 |
jne invalid_address |
call store_instruction_code |
jmp store_immediate_address |
address_relative: |
call store_instruction_code |
movzx eax,[immediate_size] |
add eax,edi |
sub eax,[current_offset] |
add eax,5 |
sub edx,eax |
jo value_out_of_range |
mov al,101b |
mov cl,[postbyte_register] |
shl cl,3 |
or al,cl |
stos byte [edi] |
xchg [value_type],ch |
mov ebx,[address_symbol] |
xchg ebx,[symbol_identifier] |
mov eax,edx |
call mark_relocation |
mov [value_type],ch |
mov [symbol_identifier],ebx |
stos dword [edi] |
ret |
addressing_16bit: |
cmp edx,10000h |
jge address_immediate_32bit |
cmp edx,-8000h |
jl address_immediate_32bit |
movzx edx,dx |
address_immediate_16bit: |
call address_16bit_prefix |
call store_instruction_code |
mov al,110b |
mov cl,[postbyte_register] |
shl cl,3 |
or al,cl |
stos byte [edi] |
mov eax,edx |
stos word [edi] |
cmp edx,10000h |
jge value_out_of_range |
cmp edx,-8000h |
jl value_out_of_range |
ret |
address_16bit_prefix: |
cmp [code_type],16 |
je instruction_prefix_ok |
mov al,67h |
stos byte [edi] |
ret |
address_32bit_prefix: |
cmp [code_type],32 |
je instruction_prefix_ok |
mov al,67h |
stos byte [edi] |
instruction_prefix_ok: |
ret |
store_instruction_with_imm8: |
mov [immediate_size],1 |
call store_instruction |
mov al,byte [value] |
stos byte [edi] |
ret |
store_instruction_with_imm16: |
mov [immediate_size],2 |
call store_instruction |
mov ax,word [value] |
call mark_relocation |
stos word [edi] |
ret |
store_instruction_with_imm32: |
mov [immediate_size],4 |
call store_instruction |
mov eax,dword [value] |
call mark_relocation |
stos dword [edi] |
ret |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/fasm/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm fasm.asm fasm |
@pause |
/programs/develop/fasm/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm fasm.asm fasm |
@pause |
/programs/develop/fasm/trunk/fasm.inc |
---|
0,0 → 1,147 |
center fix false |
SYSTEMCOLORS fix sc |
PROCESSINFO fix pinfo |
macro get_sys_colors wnd_skin,font_1 { |
mcall 48,3,SYSTEMCOLORS,sizeof.system_colors |
if wnd_skin <> 0 |
or [SYSTEMCOLORS+system_colors.work],0x03000000 |
end if |
if font_1 <> 0 |
or [SYSTEMCOLORS+system_colors.grab_text],0x10000000 |
end if |
} |
macro draw_caption _edx,_esi { |
mov edx,_edx |
mov esi,_esi |
call __draw_caption |
} |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
macro sz name,[data] { |
if used name |
common |
label name |
forward |
db data |
common |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { |
if used name |
common |
label name |
forward |
if lang eq lng |
db data |
end if |
common |
.size = $-name |
end if |
} |
macro mmov reg,a1,a2 { |
mov reg,(a1) shl 16 + (a2) |
} |
macro madd reg,a1,a2 { |
add reg,(a1) shl 16 + (a2) |
} |
macro msub reg,a1,a2 { |
sub reg,(a1) shl 16 + (a2) |
} |
macro jmpe reg,def,[val,lab] { |
forward |
cmp reg,val |
je lab |
common |
if ~def eq |
jmp def |
end if |
} |
macro func name { |
if used name |
name: |
} |
macro endf { |
end if |
} |
@^ fix macro comment { |
^@ fix } |
; structure definition helper |
;include '%fasminc%struct.inc' |
include 'struct.inc' |
; structures used in MeOS |
struct process_information |
cpu_usage dd ? ; +0 |
window_stack_position dw ? ; +4 |
window_stack_value dw ? ; +6 |
not_used1 dw ? ; +8 |
process_name db 12 dup(?) ; +10 |
memory_start dd ? ; +22 |
used_memory dd ? ; +26 |
PID dd ? ; +30 |
x_start dd ? ; +34 |
y_start dd ? ; +38 |
x_size dd ? ; +42 |
y_size dd ? ; +46 |
slot_state dw ? ; +50 |
not_used2 db 1024-52 dup(?) |
ends |
struct system_colors |
frame dd ? |
grab dd ? |
grab_button dd ? |
grab_button_text dd ? |
grab_text dd ? |
work dd ? |
work_button dd ? |
work_button_text dd ? |
work_text dd ? |
work_graph dd ? |
ends |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/fasm/trunk/struct.inc |
---|
0,0 → 1,180 |
; Macroinstructions for defining data structures |
macro struct name |
{ fields@struct equ name |
match child parent, name \{ fields@struct equ child,fields@\#parent \} |
sub@struct equ |
struc db [val] \{ \common fields@struct equ fields@struct,.,db,<val> \} |
struc dw [val] \{ \common fields@struct equ fields@struct,.,dw,<val> \} |
struc du [val] \{ \common fields@struct equ fields@struct,.,du,<val> \} |
struc dd [val] \{ \common fields@struct equ fields@struct,.,dd,<val> \} |
struc dp [val] \{ \common fields@struct equ fields@struct,.,dp,<val> \} |
struc dq [val] \{ \common fields@struct equ fields@struct,.,dq,<val> \} |
struc dt [val] \{ \common fields@struct equ fields@struct,.,dt,<val> \} |
struc rb count \{ fields@struct equ fields@struct,.,db,count dup (?) \} |
struc rw count \{ fields@struct equ fields@struct,.,dw,count dup (?) \} |
struc rd count \{ fields@struct equ fields@struct,.,dd,count dup (?) \} |
struc rp count \{ fields@struct equ fields@struct,.,dp,count dup (?) \} |
struc rq count \{ fields@struct equ fields@struct,.,dq,count dup (?) \} |
struc rt count \{ fields@struct equ fields@struct,.,dt,count dup (?) \} |
macro db [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,db,<val> \} |
macro dw [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dw,<val> \} |
macro du [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,du,<val> \} |
macro dd [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dd,<val> \} |
macro dp [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dp,<val> \} |
macro dq [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dq,<val> \} |
macro dt [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dt,<val> \} |
macro rb count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,db,count dup (?) \} |
macro rw count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dw,count dup (?) \} |
macro rd count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dd,count dup (?) \} |
macro rp count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dp,count dup (?) \} |
macro rq count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dq,count dup (?) \} |
macro rt count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dt,count dup (?) \} |
macro union \{ fields@struct equ fields@struct,,union,< |
sub@struct equ union \} |
macro struct \{ fields@struct equ fields@struct,,substruct,< |
sub@struct equ substruct \} |
virtual at 0 } |
macro ends |
{ match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt |
restruc rb,rw,rd,rp,rq,rt |
purge db,dw,du,dd,dp,dq,dt |
purge rb,rw,rd,rp,rq,rt |
purge union,struct |
match name=,fields,fields@struct \\{ fields@struct equ |
make@struct name,fields |
fields@\\#name equ fields \\} |
end virtual \} |
match any, sub@struct \{ fields@struct equ fields@struct> \} |
restore sub@struct } |
macro make@struct name,[field,type,def] |
{ common |
if $ |
display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah |
err |
end if |
local define |
define equ name |
forward |
local sub |
match , field \{ make@substruct type,name,sub def |
define equ define,.,sub, \} |
match any, field \{ define equ define,.#field,type,<def> \} |
common |
match fields, define \{ define@struct fields \} } |
macro define@struct name,[field,type,def] |
{ common |
local list |
list equ |
forward |
if ~ field eq . |
name#field type def |
sizeof.#name#field = $ - name#field |
else |
rb sizeof.#type |
end if |
local value |
match any, list \{ list equ list, \} |
list equ list <value> |
common |
sizeof.#name = $ |
restruc name |
match values, list \{ |
struc name value \\{ |
match any, fields@struct \\\{ fields@struct equ fields@struct,.,name,<values> \\\} |
match , fields@struct \\\{ label . |
forward |
match , value \\\\{ field type def \\\\} |
match any, value \\\\{ field type value |
if ~ field eq . |
rb sizeof.#name#field - ($-field) |
end if \\\\} |
common \\\} \\} \} } |
macro enable@substruct |
{ macro make@substruct substruct,parent,name,[field,type,def] |
\{ \common |
\local define |
define equ parent,name |
\forward |
\local sub |
match , field \\{ match any, type \\\{ enable@substruct |
make@substruct type,name,sub def |
purge make@substruct |
define equ define,.,sub, \\\} \\} |
match any, field \\{ define equ define,.\#field,type,<def> \\} |
\common |
match fields, define \\{ define@\#substruct fields \\} \} } |
enable@substruct |
macro define@union parent,name,[field,type,def] |
{ common |
virtual at 0 |
forward |
if ~ field eq . |
virtual at 0 |
parent#field type def |
sizeof.#parent#field = $ - parent#field |
end virtual |
if sizeof.#parent#field > $ |
rb sizeof.#parent#field - $ |
end if |
else if sizeof.#type > $ |
rb sizeof.#type - $ |
end if |
common |
sizeof.#name = $ |
end virtual |
struc name [value] \{ \common |
label .\#name |
last@union equ |
forward |
match any, last@union \\{ virtual at .\#name |
field type def |
end virtual \\} |
match , last@union \\{ match , value \\\{ field type def \\\} |
match any, value \\\{ field type value \\\} \\} |
last@union equ field |
common rb sizeof.#name - ($ - .\#name) \} } |
macro define@substruct parent,name,[field,type,def] |
{ common |
virtual at 0 |
forward |
if ~ field eq . |
parent#field type def |
sizeof.#parent#field = $ - parent#field |
else |
rb sizeof.#type |
end if |
local value |
common |
sizeof.#name = $ |
end virtual |
struc name value \{ |
label .\#name |
forward |
match , value \\{ field type def \\} |
match any, value \\{ field type value |
if ~ field eq . |
rb sizeof.#parent#field - ($-field) |
end if \\} |
common \} } |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/fasm/trunk/system.inc |
---|
0,0 → 1,462 |
; flat assembler version 1.60 |
; Copyright (c) 1999-2005, Tomasz Grysztar |
; All rights reserved. |
; |
; MenuetOS system.inc by VT |
file_info_open: dd 0,0,0xffffff,0x20000,0xf0000 |
fullpath_open:; db '/HD/1/EXAMPLE.ASM' |
times MAX_PATH db 0 |
file_info_write: dd 1,0,0,0,0xf0000 |
fullpath_write:; db '/HD/1/EXAMPLE' |
times MAX_PATH db 0 |
file_info_start: dd 16,0,0,0,0xf0000 |
fullpath_start:; db '/HD/1/EXAMPLE' |
times MAX_PATH db 0 |
_ramdisk db '/RD/1/' |
filepos dd 0x0 |
; info by Privalov: starting from FASM 1.51 |
; ~3/8 - additional memory |
; ~5/8 - main memory |
init_memory: |
mov [memory_start],0x100000 |
mov [memory_end],0x100000+(APP_MEMORY-0x100000)/8*5 |
mov [additional_memory],0x100000+(APP_MEMORY-0x100000)/8*5 |
mov [additional_memory_end],APP_MEMORY |
ret |
exit_program: |
cmp [_mode],NORMAL_MODE |
je still |
or eax,-1 |
int 0x40 |
make_timestamp: |
push ebx |
mcall 26,9 |
imul eax,10 |
pop ebx |
ret |
get_environment_variable: |
mov ecx,[memory_end] |
sub ecx,edi |
cmp ecx,7 |
jb out_of_memory |
cmp dword[esi],'INCL' |
jne .finish |
mov esi,_ramdisk |
mov ecx,6 |
cld |
rep movsb |
.finish: |
; stc |
ret |
open: |
call make_fullpaths |
; mov eax,fullpath_open |
; DEBUGF '"%s"\n',eax |
mov dword[file_info_open+8],-1 |
mcall 58,file_info_open |
or eax,eax ; found |
jz @f |
cmp eax,6 |
jne file_error |
@@: mov [filesize],ebx |
clc |
ret |
file_error: |
stc |
ret |
create: |
call make_fullpaths |
ret |
; ebx file handle |
; ecx count of bytes to write |
; edx pointer to buffer |
write: |
pusha |
mov [file_info_write+8],ecx |
mov [file_info_write+12],edx |
mov [filesize],edx |
mov eax,58 |
mov ebx,file_info_write |
int 0x40 |
popa |
ret |
make_fullpaths: |
pusha |
push edx |
mov esi,path ; open |
; DEBUGF " '%s'",esi |
mov edi,fullpath_open |
cld |
newc1: |
movsb |
cmp byte[esi],0;' ' |
jne newc1 |
mov esi,[esp] |
cmp byte[esi],'/' |
jne @f |
mov edi,fullpath_open |
@@: |
lodsb |
stosb |
cmp al,0 |
jne @b |
; mov ecx,12 |
; cld |
; rep movsb |
; mov byte[edi],0 |
mov esi,path ; write |
mov edi,fullpath_write |
cld |
newc2: |
movsb |
cmp byte[esi],0;' ' |
jne newc2 |
mov esi,[esp] |
cmp byte[esi],'/' |
jne @f |
mov edi,fullpath_write |
@@: |
lodsb |
stosb |
cmp al,0 |
jne @b |
; mov ecx,12 |
; cld |
; rep movsb |
; mov byte[edi],0 |
mov esi,path ; start |
mov edi,fullpath_start |
cld |
newc3: |
movsb |
cmp byte[esi],0;' ' |
jne newc3 |
; mov esi,[esp] |
pop esi |
cmp byte[esi],'/' |
jne @f |
mov edi,fullpath_start |
@@: |
lodsb |
stosb |
cmp al,0 |
jne @b |
; mov ecx,12 |
; cld |
; rep movsb |
; mov byte[edi],0 |
; add esp,4 |
popa |
ret |
read: |
pusha |
mov edi,edx |
mov esi,[filepos] |
add esi,0x20000 |
cld |
rep movsb |
popa |
; ret |
close: ret |
lseek: |
cmp al,0 |
jnz @f |
mov [filepos],0 |
@@: cmp al,1 |
jnz @f |
@@: cmp al,2 |
jnz @f |
mov eax,[filesize] |
mov [filepos],eax |
@@: mov eax,[filepos] |
add eax,edx |
mov [filepos],eax |
ret |
display_character: |
pusha |
cmp [_mode],NORMAL_MODE |
jne @f |
cmp dl,13 |
jz dc2 |
cmp dl,0xa |
jnz dc1 |
and [textxy],0x0000FFFF |
add [textxy],OUTPUTXY and 0xFFFF0000 + 10 |
dc2: popa |
ret |
dc1: mov eax,[textxy] |
cmp ax,word[bottom_right] |
ja dc2 |
shr eax,16 |
cmp ax,word[bottom_right+2] |
ja dc2 |
mov [dc],dl |
mcall 4,[textxy],[sc.work_text],dc,1 |
add [textxy],0x00060000 |
popa |
ret |
@@: mov eax,63 |
mov ebx,1 |
mov cl,dl |
int 0x40 |
popa |
ret |
display_string: |
pusha |
@@: cmp byte[esi],0 |
je @f |
mov dl,[esi] |
call display_character |
add esi,1 |
jmp @b |
@@: popa |
ret |
display_number: |
push ebx |
mov ecx,1000000000 |
xor edx,edx |
xor bl,bl |
display_loop: |
div ecx |
push edx |
cmp ecx,1 |
je display_digit |
or bl,bl |
jnz display_digit |
or al,al |
jz digit_ok |
not bl |
display_digit: |
mov dl,al |
add dl,30h |
push ebx ecx |
call display_character |
pop ecx ebx |
digit_ok: |
mov eax,ecx |
xor edx,edx |
mov ecx,10 |
div ecx |
mov ecx,eax |
pop eax |
or ecx,ecx |
jnz display_loop |
pop ebx |
ret |
display_user_messages: |
; push [skinh] |
; pop [textxy] |
; add [textxy],OUTPUTXY |
mov [displayed_count],0 |
call flush_display_buffer |
cmp [displayed_count],1 |
jb line_break_ok |
je make_line_break |
mov ax,word[last_displayed] |
cmp ax,0A0Dh |
je line_break_ok |
cmp ax,0D0Ah |
je line_break_ok |
make_line_break: |
mov esi,lf |
call display_string |
line_break_ok: |
ret |
display_block: |
pusha |
@@: mov dl,[esi] |
call display_character |
inc esi |
loop @b |
popa |
ret |
fatal_error: |
mov esi,error_prefix |
call display_string |
pop esi |
call display_string |
mov esi,error_suffix |
call display_string |
mov esi,lf |
call display_string |
mov al,0FFh |
jmp exit_program |
assembler_error: |
call display_user_messages |
push dword 0 |
mov ebx,[current_line] |
get_error_lines: |
push ebx |
test byte [ebx+7],80h |
jz display_error_line |
mov edx,ebx |
find_definition_origin: |
mov edx,[edx+12] |
test byte [edx+7],80h |
jnz find_definition_origin |
push edx |
mov ebx,[ebx+8] |
jmp get_error_lines |
display_error_line: |
mov esi,[ebx] |
call display_string |
mov esi,line_number_start |
call display_string |
mov eax,[ebx+4] |
and eax,7FFFFFFFh |
call display_number |
mov dl,']' |
call display_character |
pop esi |
cmp ebx,esi |
je line_number_ok |
mov dl,20h |
call display_character |
push esi |
mov esi,[esi] |
movzx ecx,byte [esi] |
inc esi |
call display_block |
mov esi,line_number_start |
call display_string |
pop esi |
mov eax,[esi+4] |
and eax,7FFFFFFFh |
call display_number |
mov dl,']' |
call display_character |
line_number_ok: |
mov esi,line_data_start |
call display_string |
mov esi,ebx |
mov edx,[esi] |
call open |
mov al,2 |
xor edx,edx |
call lseek |
mov edx,[esi+8] |
sub eax,edx |
push eax |
xor al,al |
call lseek |
mov ecx,[esp] |
mov edx,[additional_memory] |
lea eax,[edx+ecx] |
cmp eax,[additional_memory_end] |
ja out_of_memory |
call read |
call close |
pop ecx |
mov esi,[additional_memory] |
get_line_data: |
mov al,[esi] |
cmp al,0Ah |
je display_line_data |
cmp al,0Dh |
je display_line_data |
cmp al,1Ah |
je display_line_data |
or al,al |
jz display_line_data |
inc esi |
loop get_line_data |
display_line_data: |
mov ecx,esi |
mov esi,[additional_memory] |
sub ecx,esi |
call display_block |
mov esi,cr_lf |
call display_string |
pop ebx |
or ebx,ebx |
jnz display_error_line |
mov esi,error_prefix |
call display_string |
pop esi |
call display_string |
mov esi,error_suffix |
call display_string |
jmp exit_program |
__draw_caption: |
; mcall 48,4 |
; mov [skinh],eax |
; mov ebx,eax |
; shr ebx,1 |
; adc ebx,1+0x000A0000-4 |
; mcall 4,,[sc.grab_text],s_title,[s_title.size] |
mcall 48,4 |
mov [skinh],eax |
shr eax,1 |
adc eax,0 |
add eax,1-4 |
push ax |
if center eq true |
mcall 9,PROCESSINFO,-1 |
mov ebx,[PROCESSINFO+process_information.x_size] |
shr ebx,1 |
sub ebx,header.size*6/2 + 8 |
else |
mov ebx,8 |
end if |
shl ebx,16 |
pop bx |
mcall 4,,[SYSTEMCOLORS+system_colors.grab_text] |
ret |
character db ?,0 |
bytes_count dd ? |
textxy dd 0x000500A0 |
dc db 0x0 |
filesize dd 0x0 |
displayed_count dd ? |
last_displayed rb 2 |
error_prefix db 'error: ',0 |
error_suffix db '.',0 |
line_data_start db ':' |
cr_lf db 0Dh,0Ah,0 |
line_number_start db ' [',0 |
macro dm string { db string,0 } |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/h2d2b/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm h2d2b.asm h2d2b |
@pause |
/programs/develop/h2d2b/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm h2d2b.asm h2d2b |
@pause |
/programs/develop/h2d2b/trunk/h2d2b.asm |
---|
0,0 → 1,235 |
use32 ; âêëþ÷èòü 32-áèòíûé ðåæèì àññåìáëåðà |
org 0x0 ; àäðåñàöèÿ ñ íóëÿ |
db 'MENUET01' ; 8-áàéòíûé èäåíòèôèêàòîð MenuetOS |
dd 0x01 ; âåðñèÿ çàãîëîâêà (âñåãäà 1) |
dd START ; àäðåñ ïåðâîé êîìàíäû |
dd I_END ; ðàçìåð ïðîãðàììû |
dd 0x1000 ; êîëè÷åñòâî ïàìÿòè |
dd 0x1000 ; àäðåñ âåðøèíû ñòýêà |
dd 0x0 ; àäðåñ áóôåðà äëÿ ïàðàìåòðîâ (íå èñïîëüçóåòñÿ) |
dd 0x0 ; çàðåçåðâèðîâàíî |
include 'lang.inc' |
include 'macros.inc' ; ìàêðîñû îáëåã÷àþò æèçíü àññåìáëåðùèêîâ! |
START: |
red: |
call draw_window |
still: |
mcall 10 ; ôóíêöèÿ 10 - æäàòü ñîáûòèÿ |
cmp eax,1 ; ïåðåðèñîâàòü îêíî ? |
je red ; åñëè äà - íà ìåòêó red |
cmp eax,2 ; íàæàòà êëàâèøà ? |
je key ; åñëè äà - íà key |
cmp eax,3 ; íàæàòà êíîïêà ? |
je button ; åñëè äà - íà button |
jmp still ; åñëè äðóãîå ñîáûòèå - â íà÷àëî öèêëà |
;--------------------------------------------------------------------- |
key: ; íàæàòà êëàâèøà íà êëàâèàòóðå |
mov eax, 2 |
int 0x40 |
mov edi, [index] |
cmp edi, string1 |
jz no_back |
cmp ah, 8 |
jnz no_back |
dec edi |
mov byte [edi], ' ' |
mov [index], edi |
call Draw_String |
jmp still |
no_back: |
cmp ah, 13 |
jz read_str |
cmp edi, string1_end |
jae still |
mov al, ah |
stosb |
mov [index], edi |
call Draw_String |
jmp still ; âåðíóòüñÿ ê íà÷àëó öèêëà |
read_str: |
dec edi |
mov esi, string1 |
call GetBase |
xor ecx, ecx |
inc ecx ; ecx = 1 |
make_bin: |
xor eax, eax |
next_digit: |
xor edx, edx |
cmp edi, esi |
jb .done |
mov dl, [edi] |
cmp dl, '-' |
jne @f |
neg eax |
jmp .done |
@@: |
cmp dl, 'F' |
jbe @f |
and dl, 11011111b |
@@: |
sub dl, '0' |
cmp dl, 9 |
jbe @f |
sub dl, 'A'-'9'-1 |
@@: |
cmp dl, bl |
jb @f |
; Çäåñü îáðàáîòàòü îøèáêó |
jmp .done |
@@: |
push ecx |
xchg eax, ecx |
mul edx ; edx:eax = eax * edx |
add ecx, eax |
pop eax |
mul ebx |
xchg eax, ecx |
dec edi |
jmp next_digit |
.done: |
mov [num], eax |
jmp red |
;--------------------------------------------------------------------- |
button: |
mcall 17 ; 17 - ïîëó÷èòü èäåíòèôèêàòîð íàæàòîé êíîïêè |
cmp ah, 1 ; åñëè ÍÅ íàæàòà êíîïêà ñ íîìåðîì 1, |
jne still ; âåðíóòüñÿ |
.exit: |
mcall -1 ; èíà÷å êîíåö ïðîãðàììû |
draw_window: |
mcall 12, 1 |
mcall 0, 200*65536+300, 200*65536+120, 0x02AABBCC, 0x805080D0, 0x005080D0 |
mcall 4, 8*65536+8, 0x10DDEEFF, header, header_e - header |
mcall , 15*65536+100, 0, numstr, 7 |
mcall , 15*65536+72, , hexstr, 4 |
mcall , 15*65536+44, , decstr, |
mcall , 15*65536+30, , binstr, |
mcall , 15*65536+58, ,sdecstr, 10 |
mcall 8, (300-19)*65536+ 12, 5*65536+ 12, 1, 0x6688DD |
mov ecx, [num] |
mcall 47, 8*65536+256,,240*65536+72,0 ; 16-íàÿ |
mcall , 10*65536, ,228*65536+44, ; 10-íàÿ |
mcall , 8*65536+512,,240*65536+30, ; 2-íàÿ |
ror ecx, 8 |
mcall , 8*65536+512,,(240-56)*65536+30, |
ror ecx, 8 |
mcall , 8*65536+512,,(240-56*2)*65536+30, |
ror ecx, 8 |
mcall , 8*65536+512,,(240-56*3)*65536+30, |
ror ecx, 8 |
mov byte [minus], '+' |
jnc @f |
mov byte [minus], '-' |
neg ecx |
@@: |
mcall , 10*65536,,228*65536+58, ; 10-íàÿ ñî çíàêîì |
mcall 4, 222*65536+58, 0, minus, 1 |
call Draw_String |
mcall 12, 2 ; ôóíêöèÿ 12: ñîîáùèòü ÎÑ îá îòðèñîâêå îêíà |
ret |
;------------------------------------------------- |
Draw_String: |
;------------------------------------------------- |
mov eax, 13 |
mov ebx, 60*65536+ 6*33 |
mov ecx, 100*65536+ 9 |
mov edx, 0x02AABBCC |
int 0x40 |
mov eax,4 |
mov ebx,60*65536+100 |
mov ecx,0xA40473 |
mov edx,string1 |
mov esi,33 |
int 0x40 |
ret |
;------------------------------------------------- |
GetBase: |
;------------------------------------------------- |
mov ebx, 10 |
cmp edi, esi |
jb .done |
mov al, [edi] |
cmp al, 'H' |
jbe @f |
and al, 11011111b |
@@: |
cmp al, 'H' |
jne @f |
mov ebx, 16 |
dec edi |
jmp .done |
@@: |
cmp al, 'D' |
jne @f |
mov ebx, 10 |
dec edi |
jmp .done |
@@: |
cmp al, 'B' |
jne .done |
mov ebx, 2 |
dec edi |
.done: |
ret |
;------------------------------------------------- |
string1: |
db 34 dup(' ') |
string1_end: |
index dd string1 |
num dd 0 |
header db 'hex2dec2bin' |
header_e: |
minus db '-' |
numstr db 'Number:' |
hexstr db 'hex:' |
binstr db 'bin:' |
decstr db 'dec:' |
sdecstr db 'signed dec:' |
I_END: ; ìåòêà êîíöà ïðîãðàììû |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/h2d2b/trunk/macros.inc |
---|
0,0 → 1,265 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a { ; mike.dld |
if ~a eq |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/heed/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm heed.asm heed |
@pause |
/programs/develop/heed/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm heed.asm heed |
@pause |
/programs/develop/heed/trunk/heed.asm |
---|
0,0 → 1,1375 |
;constants |
;for keys |
KEY_ESC equ 27 |
KEY_PGDN equ 183 |
KEY_PGUP equ 184 |
KEY_LNDN equ 177 |
KEY_LNUP equ 178 |
KEY_RIGHT equ 179 |
KEY_LEFT equ 176 |
KEY_HOME equ 180 |
KEY_END equ 181 |
KEY_HOMETOP equ 251 ;Ctrl + '[' |
KEY_ENDBOTTOM equ 253 ;Ctrl + ']' |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x80000 ; memory for app |
dd 0x80000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
mov eax,40 |
mov ebx,100111b ;event mouse |
int 0x40 |
mov dword [process_info+42],540 |
mov dword [process_info+46],414 |
call draw_window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
dec al ; redraw request ? |
je red |
dec al ; key in buffer ? |
je key |
dec al ; button in buffer ? |
je button |
; mouse event received |
mouse: |
mov eax,37 |
mov ebx,2 |
int 0x40 |
or eax,eax |
jz still |
cmp [menu_opened],1 |
jne still |
mov [menu_opened],0 |
red: ; redraw |
call redraw_window |
jmp still |
key: ; key |
mov eax,2 |
int 0x40 |
; test al,al |
; jnz still |
cmp ah,KEY_ESC |
jz close |
mov al,[o_s_flag] |
and al,8 ;set bit 3? |
jz edit_keys ;not - no output to filename area |
cmp ah,8 ;BACKSPACE |
jnz no_backspace |
dec [name_l] |
cmp [name_l],0 |
mov edx,filename |
je A1 |
jg @f |
mov [name_l],0 |
jmp A1 |
@@: |
add dl,[name_l] |
A1: |
sub [x_cursor],0x60000 |
mov [edx],byte 0 |
cmp [x_cursor],0xb0005 |
jge @f |
mov [x_cursor],0xb0005 |
@@: |
call redraw_window |
jmp still ;END BACKSPACE |
no_backspace: |
cmp ah,0x30 ;'0' |
jl A2 |
cmp ah,0x39 ;'9' |
jle bigsym |
cmp ah,65 ;'A' |
jbe bigsym |
cmp ah,90 ;'Z' |
jle bigsym |
cmp ah,97 ;'a' |
jbe smsym |
cmp ah,122;'z' |
jle smsym |
jmp still |
A2: |
cmp ah,46 ;'.' |
jz bigsym |
cmp ah,0x20 |
jz bigsym |
jmp still |
smsym: |
sub ah,32 |
bigsym: |
cmp [name_l],13 ;yes. filename length <13 |
jl @f |
sub [o_s_flag],8 ;not - disable output to filename area |
mov [x_cursor],0x680005; - set x-base & x-size |
jmp _end_keys |
@@: |
mov edx,filename ; |
add dl,[name_l] |
mov [edx],ah |
inc [name_l] |
add [x_cursor],0x60000 |
_end_keys: |
call redraw_window |
jmp still |
edit_keys: |
cmp ah,KEY_PGDN |
jnz @f |
call PgDn |
jmp still |
@@: |
cmp ah,KEY_PGUP |
jnz @f |
call PgUp |
jmp still |
@@: |
cmp ah,KEY_HOME ;Home |
jnz @f |
call Home |
jmp still |
@@: |
cmp ah,KEY_END ;Home |
jnz @f |
call _End |
jmp still |
@@: |
cmp ah,KEY_HOMETOP |
jnz @f |
call CtrlHome |
jmp still |
@@: |
cmp ah,KEY_ENDBOTTOM |
jnz @f |
call CtrlEnd |
jmp still |
@@: |
cmp ah,KEY_LNDN |
jnz @f |
call LnDn |
jmp still |
@@: |
cmp ah,KEY_LNUP |
jnz @f |
call LnUp |
jmp still |
@@: |
cmp ah,KEY_RIGHT ;Right |
jnz @f |
call Right |
jmp still |
@@: |
cmp ah,KEY_LEFT ;Left |
jnz @f |
call Left |
@@: |
;। ªâ¨à®¢ ¨¥ áâப¨ ¢ hex-¯à¥¤áâ ¢«¥¨¨ |
mov esi,[current] |
mov bl,[posx] |
add esi,0x10000 ;0x80000 |
cmp ah,0x30 |
jl still ;ah<'0' |
cmp ah,0x39 |
jle A23 ;ah='0'...'9' - ¯¥à¥¢®¤ ¨§ ᨬ¢®«®¢ ¢ hex |
;¯à®¢¥àª ª®¤ë áâ àè¨å hex-æ¨äà |
cmp ah,0x61 ;ah<'a' |
jl A27 ;¬®¦¥â ¡ëâì ¢¢®¤ïâáï ¡®«ì訥 ¡ãª¢ë? |
cmp ah,0x66 ;ah>'f' |
jg still |
sub ah,0x20 ;ª®¢¥àâ¨à㥬 ¢ ¡®«ì訥 ¡ãª¢ë |
jmp A24 |
A27: |
cmp ah,0x41 |
jl still ;ah<'A' |
cmp ah,0x46 |
jg still ;ah>'F' |
A24: |
add ah,9 |
A23: |
mov dl,[esi];®à¨£¨ «ìë© ¡ ©â |
and bl,1 ;¥á«¨ ¥ç¥â - । ªâ¨àã¥âáï ¬« ¤è¨© ¯®«ã¡ ©â, ç¥â - áâ à訩 |
jz hi_half_byte |
;¬« ¤è¨© ¯®«ã¡ ©â |
and ah,0x0f ;®¡ã«ï¥¬ áâ à訩 ¯®«ã¡ ©â ¢¢¥¤¥®© æ¨äàë |
;¥á«¨ ah = 0x30...0x39, â® ¢á¥ ®à¬ «ì® |
;¥á«¨ ah = 0x41...0x46, â® ¬¥âª¥ 24 ¯®«ã稬 |
;ah = 0x4A...0x4F ¨ ⮦¥ ¢á¥ ®à¬ «ì® |
and dl,0xf0 ;®¡ã«ï¥¬ ¬« ¤è¨© ¯®«ã¡ ©â 㠮ਣ¨ «ì®£® ¡ ©â |
jmp patch_byte |
hi_half_byte: |
;áâ à訩 ¯®«ã¡ ©â |
shl ah,4 ;®¤®¢à¥¬¥® ᤢ¨£ ¥¬ 㦮¥ § 票¥ ¢ áâ à訩 ¯®«ã¡ ©â |
;¨ ®¡ã«ï¥¬ ¬« ¤è¨© |
and dl,0x0f ;®¡ã«ï¥¬ áâ à訩 ¯®«ã¡ ©â 㠮ਣ¨ «ì®£® ¡ ©â |
patch_byte: |
or ah,dl ;®¡ê¥¤¨ï¥¬ ¯®«ã¡ ©âë |
mov [esi],ah;¯ â稬 ¢ ¯ ¬ï⨠|
mov ebx,0x20100 |
movzx ecx,ah ;¤«ï äãªæ¨¨ ¢ë¢®¤ ç¨á« |
;⥯¥àì ¤® à áç¨â âì ª®®à¤¨ âë ¢ë¢®¤ ¤«ï ç¨á« |
;edx = x shl 16 + y |
mov edx,[x_cursor] |
mov edi,[y_cursor] |
and edx,0xffff0000 |
shr edi,0x10 |
xor esi,esi |
or edx,edi |
mov eax,47 |
add edx,8 |
int 0x40 |
call redraw_window |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
dec ah ;close programm button |
jne @f |
close: |
mov eax,-1 ; close this program |
int 0x40 |
@@: |
dec ah |
jne @f |
call redraw_window |
call menufile |
jmp still |
@@: |
dec ah ;menu 'coding' button |
jne @f |
call redraw_window |
call menucoding |
jmp still |
@@: |
dec ah ;menu 'Help' button |
jne @f |
call redraw_window |
call menuhelp |
jmp still |
@@: |
;now processed low_level menu buttons |
;id m_open = 5 |
;id m_save = 6 |
;id m_exit = 7 |
;id m_win2dos 8 |
;id m_win2koi 9 |
;id m_win2iso 10 |
;id m_dos2win 11 |
;id m_dos2koi 12 |
;id m_dos2iso 13 |
;id m_help 14 |
;id m_about 15 |
dec ah ;open? |
jne @f |
cmp [o_s_flag],0 ;disable 'Open' if flag !=0 |
jnz no_open |
; call redraw_window |
mov [color],0x0072b9fc |
call f2 ;set x_cursor & y_cursor for input filename |
mov [o_s_flag],8 ;for output to filename area |
no_open: |
call redraw_window |
jmp still |
@@: |
dec ah ;save? |
jne @f |
cmp [o_s_flag],1 ;enable save if flag = 1 |
jnz no_save |
movzx ecx,[name_l] ;begin clear filename string |
mov edi,filename |
xor al,al |
jecxz no_clear |
clear: |
mov [edi+ecx],al |
loop clear |
mov [name_l],al ;set filename length = 0 |
no_clear: ;ebd clear |
call f2 ;set x_cursor & y_cursor for input filename |
mov [o_s_flag],9 ;for output to filename area |
no_save: |
call redraw_window |
jmp still |
@@: |
dec ah ;exit? |
jne @f |
jmp close |
@@: |
dec ah ;m_win2dos? |
jne @f |
push dword WIN_TABLE |
push dword DOS_TABLE |
call coding |
call redraw_window |
jmp still |
@@: |
dec ah ;m_win2koi? |
jne @f |
push WIN_TABLE |
push KOI_TABLE |
call coding |
call redraw_window |
jmp still |
@@: |
dec ah ;m_win2iso? |
jne @f |
push WIN_TABLE |
push ISO_TABLE |
call coding |
call redraw_window |
jmp still |
@@: |
dec ah ;m_dos2win? |
jne @f |
push DOS_TABLE |
push WIN_TABLE |
call coding |
call redraw_window |
jmp still |
@@: |
dec ah ;m_dos2koi? |
jne @f |
push DOS_TABLE |
push KOI_TABLE |
call coding |
call redraw_window |
jmp still |
@@: |
dec ah ;dos2iso? |
jne @f |
push DOS_TABLE |
push ISO_TABLE |
call coding |
call redraw_window |
jmp still |
@@: |
dec ah ;m_help? |
jne @f |
;create new thread for output help info |
;parameter: address for entry_point thread |
push help_thread |
call create_process |
call redraw_window |
jmp still |
@@: |
dec ah ;m_about? |
jne @f |
;create new thread for output about info |
;parameter: address for entry_point thread |
push about_thread |
call create_process |
call redraw_window |
jmp still |
@@: |
;button 'Go' |
and [o_s_flag],1 |
jnz _savefile |
;open file |
mov eax,6 |
mov ebx,filename |
xor ecx,ecx |
or edx,-1 |
mov esi,0x10000 |
int 0x40 |
inc [o_s_flag] |
mov [sizefile],eax |
jmp end_Go |
_savefile: |
;save file |
mov ebx,filename |
mov ecx,0x10000 |
mov edx,[sizefile] |
xor esi,esi |
dec edx |
mov eax,33 |
int 0x40 |
end_Go: |
call CtrlHome |
jmp still |
Right: |
pushad |
mov al,[posx] |
inc al |
cmp al,0x20 |
jl @f |
mov [posx],0 |
mov [x_cursor],0x680005 |
mov [text_cursor],0x01200000 |
sub [current],0xf ;because [current] add 0x10 in LnDn |
call LnDn |
popad |
ret |
@@: |
mov [posx],al |
and al,1 |
jnz @f ;not increment [current] |
;increment |
add [x_cursor],0xa0000 |
sub [text_cursor],0x40000 |
inc [current] |
jmp end_r |
@@: |
add [x_cursor],0x60000 |
sub [text_cursor],0x60000 |
end_r: |
call redraw_window |
popad |
ret |
Left: |
pushad |
mov al,[posx] |
dec al |
jge @f |
mov [posx],0x1f |
mov [x_cursor],0x015e0005 |
mov [text_cursor],0x00840000 |
add [current],0x0f |
call LnUp |
popad |
ret |
@@: |
mov [posx],al |
and al,1 |
jnz @f ;decrement [current] |
;not decrement |
sub [x_cursor],0x60000 |
add [text_cursor],0x60000 |
jmp end_l |
@@: |
cmp [current],0 |
jle end_l |
sub [x_cursor],0xa0000 |
add [text_cursor],0x40000 |
dec [current] |
end_l: |
call redraw_window |
popad |
ret |
LnDn: |
pushad |
add [current],0x10 |
movzx ecx,[lines] |
cmp cl,[posy] |
jl @f ;when counter strings >= number strings in window |
add [y_cursor],0xa0000 |
inc [posy] |
call redraw_window |
popad |
ret |
@@: |
mov eax,0x10 |
xor edx,edx |
imul ecx |
sub eax,0x10 |
sub [end_str],eax |
; mov eax,[sizefile] |
; add eax,0x80000 |
; cmp eax,[end_str] |
; jge @f |
; mov [end_str],eax |
; @@: |
call draw_window |
popad |
ret |
LnUp: |
pushad |
sub [current],0x10 |
cmp [current],0 |
jge @f |
mov [current],0 |
@@: |
cmp [posy],3 |
jle @f ;when counter strings < number top string |
sub [y_cursor],0xa0000 |
dec [posy] |
call redraw_window |
popad |
ret |
@@: |
; movzx ecx,[lines] |
; mov eax,0x10 |
; xor edx,edx |
; imul ecx |
; add eax,0x10 |
sub [end_str],0x10 |
cmp [end_str],0x10000 |
jge @f |
mov [end_str],0x10000 |
@@: |
call redraw_window |
popad |
ret |
CtrlEnd: |
pushad |
popad |
ret |
CtrlHome: |
pushad |
mov [x_cursor],0x00680005 ;ãáâ ¢«¨¢ îâáï § 票ï, ª ª ¯à¨ ®âªàë⨨ |
mov [y_cursor],0x00280008 |
mov [text_cursor],0x01200000 |
mov [posx],0 |
mov [posy],3 |
call b_in_screen |
mov [end_str],0x10000 |
mov [current],0 |
call redraw_window |
popad |
ret |
_End: |
pushad |
mov [x_cursor],0x015e0005 |
mov [posx],0x1f |
mov [text_cursor],0x00840000 |
or [current],0xf |
call b_in_screen |
call redraw_window |
popad |
ret |
Home: |
pushad |
mov [x_cursor],0x00680005 ;ãáâ ¢«¨¢ îâáï § ç¥¨ï ¤«ï ç « áâப¨ |
mov [posx],0 |
mov [text_cursor],0x01200000 |
and [current],0xfffffff0 |
call b_in_screen |
call redraw_window |
popad |
ret |
PgDn: |
pushad |
xor edx,edx |
movzx ecx,[lines] |
mov eax,0x10 |
imul ecx |
add [current],eax |
add [end_str],eax |
call redraw_window |
popad |
ret |
PgUp: |
pushad |
xor edx,edx |
movzx ecx,[lines] |
mov eax,0x10 |
imul ecx |
sub [current],eax |
cmp [current],0 |
jge @f |
mov [current],0 |
@@: |
sub [end_str],eax |
cmp [end_str],0x10000 |
jge @f |
; call CtrlHome |
mov [end_str],0x10000 |
@@: |
call redraw_window |
popad |
ret |
b_in_screen: |
pushad |
call get_process_info |
mov eax,[process_info+0x2e] |
mov ebx,0x0a |
sub eax,0x3c |
cmp eax,0x10 ;now |
jg @f ;now |
mov [lines],0 ;now |
jmp C1 ;now |
@@: |
xor edx,edx |
div ebx |
mov [lines],al |
C1: |
popad |
ret |
output_screen: |
pushad |
movzx ecx,[lines] |
jecxz no_out ;now |
cmp [rflag],1 |
jz _redraw |
mov eax,[end_str] |
sub eax,0x80001 |
cmp eax,[sizefile] |
jl @f |
_redraw: |
xor edx,edx |
mov eax,0x10 |
imul ecx |
sub [end_str],eax |
cmp [end_str],0x10000 |
jge A3 |
mov [end_str],0x10000 |
A3: |
mov [rflag],0 |
@@: |
mov eax,0x28 |
@@: |
push ecx |
push eax |
call form_str |
mov ebx,0x01880000 |
add ebx,eax |
mov ecx,0x00ffffff |
add eax,10 |
mov edx,[end_str] |
push eax |
sub edx,0x10 |
mov esi,0x10 |
mov eax,4 |
int 0x40 |
pop eax |
pop ecx |
loop @b |
no_out: |
popad |
ret |
form_str: |
pushad |
mov ebp,[end_str] ;¯®á«¥¤¨© ¢ë¢¥¤¥ë© ¡ ©â |
xor edi,edi ;áç¥â稪 ¡ ©â <= 16 |
;¢ë¢¥á⨠¤à¥á |
mov ecx,ebp |
mov ebx,0x80100 ;8 æ¨äà, 16-à¨çë¥, ç¨á«® ¢ ecx |
sub ecx,0x10000 ;®à¬ «¨§ æ¨ï ¤à¥á |
mov edx,0x80000 ; ç «® ¯® |
add edx,[esp+0x24] ; ç «® ¯® |
mov esi,0x00ffffff ;梥â |
mov eax,47 ;¢ë¢¥á⨠ç¨á«® |
int 0x40 |
add edx,0x600000 ;0x40 - 8chars + 0x20 - space |
mov ebx,0x20100 ;2 æ¨äàë, 16-à¨çë¥, ç¨á«® ¢ ecx |
@@: |
mov ecx,[ebp+edi] ;ç¨á«® ¢ ecx |
inc edi |
and ecx,0xff |
cmp edi,0x11 |
jz endstr |
int 0x40 |
add edx,0x100000 |
jmp @b |
endstr: |
dec edi |
add ebp,edi |
mov [end_str],ebp |
popad |
ret 4 |
draw_cursor: |
pushad |
mov ebx,[x_cursor] |
mov ecx,[esp+0x24] |
mov edx,[color] |
mov eax,13 |
int 0x40 |
movzx edi,[o_s_flag] |
and edi,8 |
jnz @f |
add ebx,[text_cursor] |
int 0x40 |
@@: |
popad |
ret 4 |
f2: |
mov eax,[process_info+46] |
mov [x_cursor],0xb0005 |
sub eax,0x11 |
; mov [text_cursor],-1 |
shl eax,0x10 |
mov [y_filename_area],eax |
ret |
menufile: |
mov [menu_opened],1 |
mov ebx,[xf_menu];x-base+x_size for hi-level menu button |
mov edx,5;first id button for this group |
mov edi,3;counter buttons |
call f1 |
;output text for menu |
shr ecx,0x10 ;y-base button |
and ebx,0xffff0000 |
add ecx,0x6000f ;for y-base text |
mov esi,4 ;length text |
add ebx,ecx ;full base text |
mov edx,m_open |
mov ecx,[sc.work_button_text] |
or ecx,0x10000000 |
sub eax,4 |
int 0x40 |
add ebx,0x0c ;next full base text |
add edx,4 ;next string |
int 0x40 |
add ebx,0x0c |
add edx,4 |
int 0x40 |
ret |
menucoding: |
mov [menu_opened],1 |
mov ebx,[xe_menu] |
mov edx,8 ;first id |
mov edi,6 ;counter |
add ebx,0x10 ;add width buttons |
push edi |
call f1 |
pop edi |
shr ecx,0x10 |
and ebx,0xffff0000 |
add ecx,0x8000f |
mov esi,8 ;length text |
add ebx,ecx |
mov edx,m_win2dos |
mov ecx,[sc.work_button_text] |
or ecx,0x10000000 |
sub eax,4 |
@@: |
int 0x40 |
add ebx,0x0c |
add edx,8 ;next string |
dec edi |
jnz @b |
ret |
menuhelp: |
mov [menu_opened],1 |
mov ebx,[xh_menu] |
mov edx,14 ;first id |
add ebx,6 ;add width buttons |
mov edi,2 ;counter |
call f1 |
shr ecx,0x10 |
and ebx,0xffff0000 |
add ecx,0x8000f |
mov esi,4 ;length text |
add ebx,ecx |
mov edx,m_help |
mov ecx,[sc.work_button_text] |
or ecx,0x10000000 |
sub eax,4 |
int 0x40 |
add ebx,0x0c |
inc esi ;add lebgth output text |
add edx,4 |
int 0x40 |
ret |
f1:;uses for drawing low-level menu buttons |
;counter buttons get into |
;menufile,menucoding,menuhelp funcs. |
mov ecx,[y_menu] ;y-base+y_size for hi-level menu button |
mov esi,[sc.work_button] ;color buttons |
mov eax,8 |
push ecx ;for output text |
@@: |
add ecx,0xc0000 |
int 0x40 |
inc edx ;id |
dec edi ;counter |
jnz @b |
pop ecx ;for output text |
ret |
redraw_window: |
call get_process_info |
mov [rflag],1 |
call draw_window |
ret |
;this is debug func |
debug: |
pushad |
mov ecx,[esp+0x24] |
mov ebx,0x80100 |
mov edx,0x10000a0 |
mov eax,47 |
mov esi,0x00ffffff |
int 0x40 |
popad |
ret 4 |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
pushad |
mov eax,48 |
mov ebx,3 |
mov ecx,sc |
mov edx,sizeof.system_colors |
int 0x40 |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
; [x start] *65536 + [x size] |
mov ebx,[process_info+42] |
; [y start] *65536 + [y size] |
mov ecx,[process_info+46] |
mov edx,0x03000000 ; color of work area RRGGBB,8->color gl |
int 0x40 |
; WINDOW LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
mov ecx,[sc.grab_text] |
or ecx,0x10000000 ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
;check for only header window output |
cmp dword [process_info+46],25 |
jle minimaze_view |
;MENU AREA |
mov eax,[process_info+42] ;x-size window |
mov ecx,[process_info+46] ;y-size window |
push ecx ;for using done |
mov ebx,0x40000 |
sub eax,8 |
mov edi,ecx |
add ebx,eax ;x-base + x-size |
sub edi,22 ;temporary value for menu area |
push ebx ;for drawing buttons area |
sub ecx,edi ;y-base menu area |
mov edx,[sc.work_graph] |
shl ecx,0x10 |
mov eax,13 |
add ecx,0x10 |
int 0x40 |
;MENU BUTTONS |
;now in hi-half ecx register begin Y-coord. menu area |
;in hi-half ebx begin X-coord. |
;menu 'File' |
mov esi,edx ;color |
and ecx,0xffff0000 |
and ebx,0xffff0000 |
add ecx,0x1000c |
add ebx,0x20028 ;40x12 |
mov edx,2 ;menu 'File' id = 2 |
mov [y_menu],ecx ;for low-level menus func. |
mov [xf_menu],ebx;for low-level menus func. |
mov eax,8 |
push ebx ;for output buttons texts |
int 0x40 |
;registers is't change |
;menu 'Coding' |
add ebx,0x290018 ;80x12 |
inc edx ;menu 'coding' id = 3 |
mov [xe_menu],ebx;for low-level menus func. |
int 0x40 |
;menu 'Help' |
add ebx,0x40ffe8 ;+0x280000 - 0x28, 40x12 |
inc edx ;menu 'Help' id = 4 |
mov [xh_menu],ebx;for low-level menus func. |
int 0x40 |
;MENU BUTTONS TEXTS |
;'File' |
pop ebx |
shr ecx,0x10 |
and ebx,0xffff0000 |
add ecx,3 |
mov eax,4 ; function 4 : write text to window |
add ebx,0x80000 |
mov edx,f_menu |
add ebx,ecx ; [x start] *65536 + [y start] |
mov esi,4 |
mov ecx,[sc.work_button_text] |
or ecx,0x10000000 ; font 1 & color ( 0xF0RRGGBB ) |
push esi ;for 'Help' menu text |
int 0x40 |
;'coding' |
;registers is't change |
add ebx,0x2d0000 |
;mov esi,6 |
add esi,2 |
; mov edx,e_menu |
add edx,4 |
int 0x40 |
;'Help' |
add ebx,0x3b0000 |
; mov esi,4 |
pop esi |
; mov edx,h_menu |
add edx,6 |
int 0x40 |
;LOW_LEVEL MENU |
;for every hi-level menu exists one procedure |
;in begin programm they are not calls, |
;but when user click on one item hi-level menu |
;or press hot keys, call one func. and after |
;end work this func. she is redraw window - |
;low-level menu is hide. Functions: |
;menufile,menucoding,menuhelp. |
;Thay uses global virables, top-left corner every |
;hi-level menu buttons: [xf_menu],[xe_menu],[xh_menu],[y_menu] |
;DRAW BUTTONS AREA |
pop ebx ;for push ebx into processed menu area: x-bzse + x-size |
; mov ecx,[process_info+46] |
pop ecx |
push ecx |
sub ecx,24 |
mov edx,[sc.work_graph] |
shl ecx,16 ;y start |
mov eax,13 |
add ecx,20 |
int 0x40 |
;filename input area |
; mov ecx,[process_info+46] |
pop ecx |
push ecx ;for info strings |
mov ebx,0x0008005a |
sub ecx,21 |
xor edx,edx |
shl ecx,16 |
mov [y_filename_area],ecx |
dec edx |
add ecx,16 |
mov eax,13 |
push ecx ;for button 'Go' |
int 0x40 |
;button 'Go', press in case open/save if filename input complete |
;button size = 24x16 |
mov eax,8 |
pop ecx ;y-base+y-size |
mov ebx,0x00680018;x-base+x-size |
dec ecx |
mov edx,0xff ;id |
mov esi,[sc.work_button] |
int 0x40 |
shr ecx,0x10 |
and ebx,0xffff0000 |
add ecx,0x50004 |
mov edx,b_go |
add ebx,ecx |
mov esi,2 |
mov ecx,[sc.work_button_text] |
or ecx,0x10000000 |
sub eax,4 |
int 0x40 |
;where output cursor? |
mov al,[o_s_flag] |
and al,8 |
je @f |
mov ecx,[y_filename_area] |
add ecx,0x40008 |
jmp cursor |
@@: ;o_s_flag<0 - not output cursor into filename area |
mov ecx,[y_cursor] |
cursor: |
push ecx |
call draw_cursor |
mov eax,[y_filename_area] |
mov ebx,0xa0000 |
mov edx,filename |
shr eax,0x10 |
and ebx,0xffff0000 |
add eax,4 |
xor ecx,ecx |
add ebx,eax |
movzx esi,[name_l] |
mov eax,4 |
int 0x40 |
;info strings |
; sizefile text |
; mov eax,[process_info+46] |
pop eax |
mov ebx,0x00840000 |
sub eax,18 |
xor ecx,ecx |
add ebx,eax |
mov edx,sizestr ; pointer to text beginning |
mov eax,4 |
mov esi,5 |
int 0x40 |
add ebx,0x00530000 |
inc esi |
; mov edx,offst |
add edx,5 |
inc esi |
int 0x40 |
;sizefile |
mov ecx,[sizefile] |
mov edx,ebx |
xor esi,esi |
sub edx,0x00350000 |
mov eax,47 |
mov ebx,0x80100 |
int 0x40 |
mov ecx,[current] |
add edx,0x005f0000 |
int 0x40 |
push [text_cursor] ;íâ® ¯®§¨æ¨ï ªãàá®à ¢ ⥪á⮢®© áâப¥ |
call draw_cursor |
mov ecx,[sizefile] |
jecxz minimaze_view |
call output_screen |
minimaze_view: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
popad |
ret |
get_process_info: |
pushad |
mov eax,9 |
mov ebx,process_info |
xor ecx,ecx |
dec ecx |
int 0x40 |
popad |
ret |
coding: |
pushad |
mov ebp,0x10000 ;0x80000 |
mov edi,[esp+0x28] ;source table |
mov esi,[esp+0x24] ;destination table |
xor ecx,ecx ;index in file |
new_char: |
xor ebx,ebx ;index in tables |
not_c: |
mov ah,[ebp+ecx] ;load char |
cmp ah,[edi+ebx] ; |
jz @f |
inc ebx |
cmp ebx,0x40 |
jge end_table |
jmp not_c |
@@: |
mov al,[esi+ebx] |
inc ebx |
mov [ebp+ecx],al |
end_table: |
inc ecx |
cmp ecx,[sizefile] |
jle new_char |
popad |
ret 8 |
create_process: |
pushad |
mov eax,51 |
xor ebx,ebx |
mov ecx,[esp+0x24] |
inc ebx |
mov edx,0x7E000 ;0x1000 |
int 0x40 |
popad |
ret 4 |
help_thread: |
call help_window |
help_still: |
mov eax,10 |
int 0x40 |
dec eax |
jz help_red |
dec eax |
jz help_key |
dec eax |
jz help_button |
jmp help_still |
help_red: |
call help_window |
jmp help_still |
help_key: |
inc eax |
inc eax |
int 0x40 |
jmp help_still |
help_button: |
mov eax,17 |
int 0x40 |
dec ah |
jne help_still |
shr eax,8 |
dec eax |
int 0x40 |
help_window: |
pushad |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,0x500140 ; [x start] *65536 + [x size] |
mov ecx,0x700110 ; [y start] *65536 + [y size] |
mov edx,0x03000000 ; color of work area RRGGBB,8->color gl |
int 0x40 |
; WINDOW LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
mov ecx,0x10ffffff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,help_label ; pointer to text beginning |
mov esi,14 ; text length |
int 0x40 |
; HELP TEXT |
add edx,14 ;help_text addr. |
add esi,37 ; = 51 - length 1 line |
mov ecx,0x00ffffff |
mov edi,15 |
@@: |
add ebx,0x10 |
int 0x40 |
add edx,51 |
dec edi |
jnz @b |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
popad |
ret |
about_thread: |
call about_window |
about_still: |
mov eax,10 |
int 0x40 |
dec eax |
jz about_red |
dec eax |
jz about_key |
dec eax |
jz about_button |
jmp about_still |
about_red: |
call about_window |
jmp about_still |
about_key: |
inc eax |
inc eax |
int 0x40 |
jmp about_still |
about_button: |
mov eax,17 |
int 0x40 |
dec ah |
jne about_still |
shr eax,8 |
dec eax |
int 0x40 |
about_window: |
pushad |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,0x500140 ; [x start] *65536 + [x size] |
mov ecx,0x700110 ; [y start] *65536 + [y size] |
mov edx,0x03000000 ; color of work area RRGGBB,8->color gl |
int 0x40 |
; WINDOW LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
mov ecx,[sc.work_button_text] |
or ecx,0x10000000 ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,about_label ; pointer to text beginning |
mov esi,17 ; text length |
int 0x40 |
; ABOUT TEXT |
add edx,17 ;about_text addr. |
add esi,34 ; = 51 - length 1 line |
mov ecx,0x00ddeeff |
mov edi,15 |
@@: |
add ebx,0x10 |
int 0x40 |
add edx,51 |
dec edi |
jnz @b |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
popad |
ret |
; DATA AREA |
sizefile dd 0 |
current dd 0 ;current offset relative begin file. Uses as offset for patch. |
;Coordinates left hi-level menu buttons |
;Uses into low-level menu output. |
xf_menu dd 0 |
xe_menu dd 0 |
xh_menu dd 0 |
y_menu dd 0 ;top coord. menu |
y_filename_area dd 0 ;top coord. filename input area |
color dd 0 |
y_cursor dd 0x280008 ;y coord. shl 16 + y size for cursor |
x_cursor dd 0x680005 ;x coord. shl 16 + x size for cursor |
name_l db 0 ;counter chars into filename |
o_s_flag db 0 ; |
rflag dd 0; |
posx db 0 |
posy db 3 |
lines db 0 |
end_str dd 0x10000 ;addr. first byte for output |
text_cursor dd 0x01200000 |
filename: rb 13 |
b_go: db 'Go' |
sizestr: db 'SIZE:' |
offst: db 'OFFSET:' |
labelt: db 'HeEd' |
labellen: |
;text for hi-level menu buttons |
f_menu: db 'File' |
e_menu: db 'Coding' |
h_menu: db 'Help' |
;text for low-level menu buttons |
;menu File |
m_open: db 'Open' |
m_save: db 'Save' |
m_exit: db 'Exit' |
;menu coding |
m_win2dos: db 'Win->Dos' |
m_win2koi: db 'Win->Koi' |
m_win2iso: db 'Win->Iso' |
m_dos2win: db 'Dos->Win' |
m_dos2koi: db 'Dos->Koi' |
m_dos2iso: db 'Dos->Iso' |
;menu Help |
m_help: db 'Help' |
m_about: db 'About' |
;tables for coding |
WIN_TABLE: |
db 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9 |
db 0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3 |
db 0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD |
db 0xDE,0xDF,0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7 |
db 0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1 |
db 0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB |
db 0xFC,0xFD,0xFE,0xFF |
DOS_TABLE: |
db 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89 |
db 0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93 |
db 0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D |
db 0x9E,0x9F,0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7 |
db 0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xE0,0xE1 |
db 0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB |
db 0xEC,0xED,0xEE,0xEF |
KOI_TABLE: |
db 0xE1,0xE2,0xF7,0xE7,0xE4,0xE5,0xF6,0xFA,0xE9,0xEA |
db 0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF2,0xF3,0xF4,0xF5 |
db 0xE6,0xE8,0xE3,0xFE,0xFB,0xFD,0xFF,0xF9,0xF8,0xFC |
db 0xE0,0xF1,0xC1,0xC2,0xD7,0xC7,0xC4,0xC5,0xD6,0xDA |
db 0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD2,0xD3 |
db 0xD4,0xD5,0xC6,0xC8,0xC3,0xDE,0xDB,0xDD,0xDF,0xD9 |
db 0xD8,0xDC,0xC0,0xD1 |
ISO_TABLE: |
db 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9 |
db 0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,0xC0,0xC1,0xC2,0xC3 |
db 0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD |
db 0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7 |
db 0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,0xE0,0xE1 |
db 0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB |
db 0xEC,0xED,0xEE,0xEF |
;text for help_window |
help_label: db 'Help for HeEd.' |
help_text: |
db '1.HeEd ¢ á®áâ®ï¨¨ ®âªàëâì ä ©« ⮫쪮 ®¤¨ à § ¨ ' |
db ' 㦮¥ ç¨á«® à § á®åà ¨âì ¥£®. ' |
db '2.ਠ®âªàë⨨ ä ©« ¡¥§ à áè¨à¥¨ï ¤® íâ® à áè¨-' |
db ' è¨à¥¨¥ ¢á¥ à ¢® 㪠§ë¢ âì ª ª âਠ¯à®¡¥« ¯®á«¥' |
db ' â®çª¨. ' |
db '3. ¬® ®âªàë⨥ ä ©« ¯à®¨á室¨â ¯à¨ ¦ ⨨ ª®¯ª¨' |
db ' "Go". ' |
db '4.®§¤ ¨¥ ®¢ëå ä ©«®¢ ¢ ¬¥î ¥ ¯à¥¤ãᬮâ८, ®' |
db ' ¬®¦® ¦¥ । ªâ¨à®¢ âì... ' |
db '5. ä ©« § ¯¨áë¢ ¥âáï ⮫쪮 ª®«¨ç¥á⢮ ¡ ©â, ª®â®-' |
db ' ஥ ¡ë«® à §¬¥à®¬ ä ©« ¤® ®âªàëâ¨ï. ' |
db '6.ਠ¦ ⨨ "Go" á ¯ãáâë¬ ¯®«¥¬ ¨¬¥¨ ä ©« ¢ë¢®-' |
db ' ¤¨âáï ¯ ¬ïâì á ¤à¥á 0å80000, ® à §¬¥à ä ©« ' |
db ' à ¢¥ 0xFFFFFFFF. ' |
db ' (á¬. ¨ä® "About") ' |
help_end: |
;text for about_window |
about_label: db 'About this funny.' |
about_text: |
db '¥ª®â®à ï ¨ä®à¬ æ¨ï ¤«ï â¥å, ªâ® § å®ç¥â ¤®¯¨á âì ' |
db 'áî¤ çâ®-⮠᢮¥: ª®¤ ¯à ªâ¨çªáª¨ ¥ ®¯â¨¬¨§¨à®¢ ,' |
db 'â ª çâ® à §®¡à âìáï ¡ã¤¥â ¥ â ª 㦠᫮¦®. âப¨ ' |
db '¤«ï ª®¯®ª ¬¥î ¤®«¦ë ¨¤â¨ ¯àאַ ¤à㣠§ ¤à㣮¬, ' |
db 'â. ª. ï ¯à¨ ¢ë¢®¤¥ ¨á¯®«ì§ãî ¥ mov esi,à §¬¥à ¨ ' |
db 'mov edx, ¤à¥á ¯à®áâ® ¯à¨¡ ¢«ïî ᬥ饨ï. â® ª -' |
db 'á ¥âáï ª®¤¨à®¢®ª ¨ à §¬¥à®¢ ä ©« ¤«ï á®åà ¥¨ï, ' |
db 'â® ®áâ ¥âáï ⮫쪮 ¤®¡ ¢¨âì ª®¯ª¨ ¬¥î á ⥪á⮬ ' |
db '(¯à¨ ¤®¡ ¢«¥¨¨ ¤® ãç¨âë¢ âì, çâ® ID ª®¯ª¨ ®¯®§-' |
db ' îâáï dec ah, ¥ ª ª cmp ah,ID). ᫨ ¢á¥ ¦¥ ¡ã-' |
db '¤¥â ¥¯à¨ïâ® à §¡¨à âìáï, â® ¬®¦¥â¥ ¯¨á âì ¨ ' |
db 'á¯à®á¨âì. â ¯à®£à ¬¬ ¡ë« ¯¨á ¢ 室¥ à §¡®-' |
db 'ப á GUI MeOS ¨ ¯®í⮬㠥 ¯à¥â¥¤ã¥â çâ®-â® ' |
db '¡®«ì襥, 祬 ¯à¨¬¥à. à®áâ® ¤®¥« íâ ⥬ , ¢ë-' |
db 'ª¨ãâì ¦ «ª®. mailto:babalbes@yandex.ru ' |
about_end: |
I_END: |
sc system_colors |
process_info: |
rb 1024 |
menu_opened db ? |
m_text: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/heed/trunk/macros.inc |
---|
0,0 → 1,265 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a { ; mike.dld |
if ~a eq |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/hexview/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm hexview.asm hexview |
@pause |
/programs/develop/hexview/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm hexview.asm hexview |
@pause |
/programs/develop/hexview/trunk/hexview.asm |
---|
0,0 → 1,219 |
; |
; EXAMPLE APPLICATION |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x8000 ; required amount of memory |
dd 0x8000 ; esp = 0x7FFF0 |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
begin dd 0 |
START: ; start of execution |
call open_file |
red: |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
dec eax ; redraw request ? |
je red |
dec eax ; key in buffer ? |
je key |
dec eax ; button in buffer ? |
je button |
jmp still |
; red: ; redraw |
; call draw_window |
; jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,3 |
jne no_up |
cmp [begin],16 |
jb no_up |
add [begin],-16 |
jmp red |
no_up: |
cmp ah,4 |
jne no_down |
add [begin],16 |
jmp red |
no_down: |
dec ah ; button id=1 ? |
jne still |
xor eax,eax ; close this program |
dec eax |
int 0x40 |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
xor eax,eax ; function 0 : define and draw window |
mov ebx,100*65536+400 ; [x start] *65536 + [x size] |
mov ecx,100*65536+270 ; [y start] *65536 + [y size] |
mov edx,0x03224466 ; color of work area RRGGBB,8->c |
mov esi,0x006688aa ; color of grab bar RRGGBB,8->color gl |
mov edi,0x00ffffff ; color of frames RRGGBB |
int 0x40 |
; WINDOW LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
mov ecx,0x00ffffff ; color of text RRGGBB |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
mov eax,8 |
mov ebx,280*65536+16*6 |
mov ecx,240*65536+14 |
mov edx,2 |
mov esi,0x5599cc |
int 0x40 |
mov ebx,15*65536+125 |
inc edx |
int 0x40 |
add ebx,127*65536 |
inc edx |
int 0x40 |
mov eax,4 |
mov ebx,15*65536+243 |
mov ecx,0xffffff |
mov edx,buttons |
mov esi,blen-buttons |
int 0x40 |
mov ebx,280*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
add edx,[begin] |
mov esi,16 |
mov edi,esi |
newline: |
push ebx ; hext |
push edx |
push edi |
mov edi,16 |
mov ecx,edx |
mov edx,ebx |
add edx,-265*65536 |
mov eax,47 |
mov ebx,0x00020101 |
mov esi,0xffff00 |
newhex: |
; mov ebx,0x00020101 |
; mov esi,0xffff00 |
int 0x40 |
add edx,16*65536 |
inc ecx |
dec edi |
jne newhex |
; popa |
pop edi |
pop edx |
pop ebx |
mov eax,4 ; text |
mov esi,16 |
mov ecx,0xffffff |
int 0x40 |
add ebx,12 |
add edx,16 |
dec edi |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
file_name db 'EXAMPLE.ASM ' |
; db 'EXAMPLE ' |
open_file: |
pusha |
mov eax,6 |
mov ebx,file_name |
xor ecx,ecx |
mov edx,-1 |
mov esi,text |
int 0x40 |
popa |
ret |
; DATA AREA |
labelt: db 'HEXVIEW' |
labellen: |
buttons db ' UP DOWN' |
db ' EXAMPLE ' |
blen: |
text: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/hexview/trunk/macros.inc |
---|
0,0 → 1,265 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a { ; mike.dld |
if ~a eq |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/keyascii/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm keyascii.asm keyascii |
@pause |
/programs/develop/keyascii/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm keyascii.asm keyascii |
@pause |
/programs/develop/keyascii/trunk/keyascii.asm |
---|
0,0 → 1,127 |
; Author: M. Lisovin |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x1000 ; memory for app |
dd 0x1000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
call draw_window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
mov [keyid],ah |
call draw_window |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne noclose |
mov eax,-1 ; close this program |
int 0x40 |
noclose: |
jmp still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+270 ; [x start] *65536 + [x size] |
mov ecx,100*65536+80 ; [y start] *65536 + [y size] |
mov edx,0x83ffffff ; color of work area RRGGBB,8->color gl |
mov esi,0x805080d0 ; color of grab bar RRGGBB,8->color gl |
mov edi,0x005080d0 ; color of frames RRGGBB |
int 0x40 |
mov eax,4 ; function 4 : write text to window |
mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; color of text RRGGBB |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
not ecx |
mov esi,4 |
add ebx,23 |
mov edx,tdec |
int 0x40 |
add ebx,23 |
mov edx,thex |
int 0x40 |
mov ecx,[keyid] |
mov eax,47 |
mov ebx,3*65536 |
mov edx,40*65536+31 |
mov esi,0x224466 |
int 0x40 |
add edx,23 |
mov bh,1 |
int 0x40 |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
; DATA AREA |
tdec: db 'DEC:' |
thex: db 'HEX:' |
labelt: |
db 'KEYBOARD ASCIICODES-PRESS ANY KEY' |
labellen:dd 0 |
keyid:db 0 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/keyascii/trunk/macros.inc |
---|
0,0 → 1,267 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/mhc/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm mhc.asm mhc |
@pause |
/programs/develop/mhc/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm mhc.asm mhc |
@pause |
/programs/develop/mhc/trunk/macros.inc |
---|
0,0 → 1,267 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/mhc/trunk/mhc.asm |
---|
0,0 → 1,977 |
; |
; MHC archiver for MenuetOS - very fast compression tool |
; |
; version 0.09 |
; |
; Written by Nikita Lesnikov (nlo_one@mail.ru, Republic of Belarus, Sluck) |
; |
;============================================================================== |
; |
; Brief file format description: |
; |
; +-----------+------------------------+ |
; File structure: | Method ID | Compressed data | |
; +-----------+------------------------+ |
; |
; Methods list: |
; |
; 0. LZP (order-2 specified specially for *.ASM,*.RAW and MeOS executables) |
; |
; New methods can be easily added without loss of compatibility |
; with older versions |
; |
;============================================================================== |
; SYSTEM HEADER |
use32 |
org 0x0 |
db "MENUET01" |
dd 0x01 |
dd ENTRANCE |
dd MHC_END |
dd 0x300000 ; 3 megs of memory needed |
dd 0x2FF000 |
dd 0x0 |
dd 0x0 |
include 'lang.inc' |
include 'macros.inc' |
; CODE AREA |
ENTRANCE: |
; ======== user interface ========= |
call draw_window ; draw the window |
still: |
mov eax,10 ; wait for event |
int 0x40 |
cmp eax,1 ; redraw? |
jnz no_redraw |
call draw_window |
no_redraw: |
cmp eax,2 ; key pressed? |
jz key |
cmp eax,3 ; button pressed? |
jz button |
jmp still |
; Key handler |
key: |
mov eax,2 ; read it |
int 0x40 |
shr eax,8 |
cmp byte [editstate],0 |
jz still |
cmp al,8 ; backspace |
jnz no_bksp |
cmp byte [editpos],0 |
jz no_del_last |
dec byte [editpos] |
xor ebx,ebx |
mov bl,byte [editpos] |
add ebx,cmfile |
cmp byte [editstate],2 |
jnz no_add_base_1 |
add ebx,12 |
no_add_base_1: |
mov byte [ebx],32 |
no_del_last: |
call draw_info |
jmp still |
no_bksp: |
cmp al,13 ; enter |
jnz no_enter |
mov byte [editstate],0 |
call draw_info |
jmp still |
no_enter: |
cmp eax,dword 31 |
jbe no_lit |
cmp eax,dword 95 |
jb capital |
sub eax,32 |
capital: |
xor ebx,ebx |
mov bl,byte [editpos] |
add ebx,cmfile |
cmp byte [editstate],2 |
jnz no_add_base_2 |
add ebx,12 |
no_add_base_2: |
mov byte [ebx],al |
inc byte [editpos] |
cmp byte [editpos],12 |
jnz no_null_state |
mov byte [editstate],0 |
no_null_state: |
call draw_info |
no_lit: |
jmp still |
; Button handler |
button: |
mov eax,17 |
int 0x40 |
cmp ah,1 |
jnz no_quit |
mov eax,-1 |
int 0x40 |
no_quit: |
cmp ah,4 |
jnz nofirst |
cld |
mov byte [editstate],1 |
mov edi,cmfile |
mov eax,0x20202020 |
mov ecx,3 |
rep stosd |
mov byte [editpos],0 |
mov byte [msgid],0 |
call draw_info |
nofirst: |
cmp ah,5 |
jnz nosecond |
cld |
mov byte [editstate],2 |
mov edi,iofile |
mov eax,0x20202020 |
mov ecx,3 |
rep stosd |
mov byte [editpos],0 |
mov byte [msgid],0 |
call draw_info |
nosecond: |
cmp ah,2 |
jnz no_compress |
call compress |
no_compress: |
cmp ah,3 |
jnz no_decompress |
call decompress |
no_decompress: |
cmp ah,6 |
jnz no_delete_io |
pusha |
mov eax,32 |
mov ebx,iofile |
int 0x40 |
popa |
no_delete_io: |
cmp ah,7 |
jnz no_delete_archive |
pusha |
mov eax,32 |
mov ebx,cmfile |
int 0x40 |
popa |
no_delete_archive: |
jmp still |
; WINDOW DRAW |
draw_window: |
mov eax,12 ; Start redrawing |
mov ebx,1 |
int 0x40 |
xor eax,eax ; Define window |
mov ebx,100*65536+240 |
mov ecx,100*65536+130 |
mov edx,0x02AAAAAA |
mov esi,0x80777777 |
mov edi,0x00777777 |
int 0x40 |
mov eax,4 ; Draw all needed texts |
mov ebx,8*65536+8 |
mov ecx,0x00FFFFFF |
mov edx,title |
mov esi,arclab-title |
int 0x40 |
xor ecx,ecx |
mov edx,arclab |
mov esi,unplab-arclab |
add ebx,10*65536+28 |
int 0x40 |
mov edx,unplab |
mov esi,fin_text-unplab |
add ebx,18 |
int 0x40 |
pusha |
mov eax,8 ; Buttons |
mov ebx,222*65536+10 |
mov ecx,6*65536+10 |
mov edx,1 |
mov esi,0x555555 |
int 0x40 |
mov ebx,15*65536+100 |
mov ecx,70*65536+13 |
inc edx |
int 0x40 |
inc edx |
add ebx,110*65536 |
int 0x40 |
inc edx |
mov ebx,214*65536+11 |
mov ecx,33*65536+11 |
int 0x40 |
inc edx |
add ecx,18*65536 |
int 0x40 |
inc edx |
mov ebx,15*65536+100 |
mov ecx,86*65536+13 |
int 0x40 |
inc edx |
add ebx,110*65536 |
int 0x40 |
popa |
mov ecx,0x00FFFFFF |
mov edx,keylab |
mov esi,dellab-keylab |
add ebx,19 |
int 0x40 |
mov edx,dellab |
mov esi,title-dellab |
add ebx,16 |
int 0x40 |
call draw_info |
mov eax,12 ; Finish redrawing |
mov ebx,2 |
int 0x40 |
ret |
draw_info: ; Draw filenames and compressor state |
activecolor equ 0x00112299 |
pusha ; Save registers |
mov eax,13 ; Clean draw area |
mov ebx,127*65536+85 |
mov ecx,33*65536+33 |
mov edx,0x00AAAAAA |
int 0x40 |
mov eax,4 ; Draw filenames |
mov ebx,134*65536+36 |
mov edx,cmfile |
xor ecx,ecx |
mov esi,12 |
cmp byte [editstate],1 |
jnz no_active_1 |
mov ecx,activecolor |
no_active_1: |
int 0x40 |
xor ecx,ecx |
cmp byte [editstate],2 |
jnz no_active_2 |
mov ecx,activecolor |
no_active_2: |
add ebx,18 |
add edx,12 |
int 0x40 |
mov eax,13 ; Clean info area |
mov ebx,14*65536+210 |
mov ecx,107*65536+14 |
mov edx,0x00AAAAAA |
int 0x40 |
cmp byte [msgid],0 ; Draw info string |
jz notype |
mov ebx,16*65536+110 |
xor ecx,ecx |
mov esi,16 |
mov al, byte [msgid] |
dec al |
shl al,4 |
xor ah,ah |
xor edx,edx |
mov dx,ax |
add edx,msgtable |
mov eax,4 |
int 0x40 |
notype: |
popa ; Restore registers |
ret |
; interface data |
keylab db " COMPRESS DECOMPRESS" |
dellab db " DELETE I/O DELETE *.MHC" |
title db "MHC 0.09" |
arclab db "COMPRESSED FILE:" |
unplab db "INPUT/OUTPUT FILE:" |
fin_text: |
cmfile db "FILENAME.MHC" |
iofile db "FILENAME.XYZ" |
editstate db 0 |
editpos db 0 |
msgid db 0 |
msgtable: |
db "COMPRESSING... " |
db "DECOMPRESSING..." |
db "I/O NOT FOUND! " |
db "*.MHC NOT FOUND!" |
db "INVALID METHOD! " |
; ======== compression/decompression engine ======== |
; Adresses declaration |
hashtable equ MHC_END |
ifile equ hashtable+65536*4 |
ofile equ ifile+1000000 |
compress: ; File compression |
call fill_filebufs |
mov eax,6 |
mov ebx,iofile |
xor ecx,ecx |
mov edx,ecx |
not edx |
mov esi,ifile |
int 0x40 |
cmp eax,0xFFFFFFFF |
jnz compress_filefound ; i/o file not found |
mov byte [msgid],3 |
call draw_info |
ret |
compress_filefound: |
mov byte [msgid],1 |
call draw_info |
jmp lzp_compress ; compress with order-2 LZP |
compress_dumpdata: |
push edx |
mov eax,32 |
mov ebx,cmfile |
int 0x40 |
mov eax,33 |
pop edx |
mov ebx,cmfile |
mov ecx,ofile |
xor esi,esi |
int 0x40 |
mov byte [msgid],0 |
call draw_info |
ret |
decompress: ; File decompression |
call fill_filebufs |
mov eax,6 |
mov ebx,cmfile |
xor ecx,ecx |
mov edx,ecx |
not edx |
mov esi,ofile |
int 0x40 |
cmp eax,0xFFFFFFFF |
jnz decompress_filefound ; *.mhc file not found |
mov byte [msgid],4 |
call draw_info |
ret |
decompress_filefound: |
cmp byte [ofile],0 ; Invalid method! |
jz right_method |
mov byte [msgid],5 |
call draw_info |
ret |
right_method: |
mov byte [msgid],2 |
call draw_info |
jmp lzp_decompress |
decompress_dumpdata: |
push edx |
mov eax,32 |
mov ebx,iofile |
int 0x40 |
mov eax,33 |
pop edx |
mov ebx,iofile |
mov ecx,ifile |
xor esi,esi |
int 0x40 |
mov byte [msgid],0 |
call draw_info |
ret |
fill_filebufs: ; Fill filebufs with garbage to simplify matching |
pusha |
cld |
mov eax,0xF7D9A03F ; <- "magic number" :) just garbage... |
mov ecx,2000000/4 |
mov edi,ifile |
rep stosd |
popa |
ret |
; ==== algorithms section ==== |
; Method 0: LZP compression algorithm |
lzp_compress: ; EDX - how much bytes to dump |
cld ; clear direction flag |
mov esi,ifile ; init pointers |
mov edi,ofile |
push eax ; write header: ID0+4bfilesize => total 5 bytes |
xor eax,eax |
stosb |
pop eax |
stosd |
pusha ; fill hash table |
mov eax,ifile |
mov edi,hashtable |
mov ecx,65536 |
rep stosd |
popa |
add eax,esi ; calculate endpointer |
mov dword [endpointer],eax |
movsw ; copy three bytes |
movsb |
mov dword [controlp],edi |
inc edi |
mov byte [controld],0 |
mov byte [controlb],0 |
c_loop: |
cmp dword [endpointer],esi ; check end of file |
ja c_loop_ok |
jmp finish_c_loop |
c_loop_ok: |
call chash |
call compare |
jz two_match_c |
lodsb |
mov byte [literal],al |
call chash |
call compare |
jz lit_match_c |
mov al,0 |
call putbit |
mov al,byte [literal] |
stosb |
movsb |
jmp end_c_loop |
lit_match_c: |
mov al,1 |
call putbit |
mov al,0 |
call putbit |
mov al,byte [literal] |
stosb |
jmp encode_match |
two_match_c: |
mov al,1 |
call putbit |
call putbit |
encode_match: |
call incpos |
call compare |
jz one_c |
mov al,0 |
call putbit |
jmp end_c_loop |
one_c: |
call incpos |
mov al,1 |
call putbit |
call compare |
jnz ec1 |
call incpos |
call compare |
jnz ec2 |
call incpos |
call compare |
jnz ec3 |
call incpos |
mov al,1 |
call putbit |
call putbit |
call compare |
jnz ec4 |
call incpos |
call compare |
jnz ec5 |
call incpos |
call compare |
jnz ec6 |
call incpos |
call compare |
jnz ec7 |
call incpos |
call compare |
jnz ec8 |
call incpos |
call compare |
jnz ec9 |
call incpos |
call compare |
jnz ec10 |
call incpos |
mov al,1 |
call putbit |
call putbit |
call putbit |
xor ecx,ecx |
match_loop_c: |
cmp esi,dword [endpointer] |
jae out_match_loop_c |
call compare |
jnz out_match_loop_c |
inc ecx |
call incpos |
jmp match_loop_c |
out_match_loop_c: |
mov al,0xFF |
out_lg: |
cmp ecx,255 |
jb out_lg_out |
stosb |
sub ecx,255 |
jmp out_lg |
out_lg_out: |
mov al,cl |
stosb |
jmp end_c_loop |
ec10: |
mov al,1 |
call putbit |
call putbit |
mov al,0 |
call putbit |
jmp end_c_loop |
ec9: |
mov al,1 |
call putbit |
mov al,0 |
call putbit |
mov al,1 |
call putbit |
jmp end_c_loop |
ec8: |
mov al,1 |
call putbit |
mov al,0 |
call putbit |
call putbit |
jmp end_c_loop |
ec7: |
mov al,0 |
call putbit |
mov al,1 |
call putbit |
call putbit |
jmp end_c_loop |
ec6: |
mov al,0 |
call putbit |
mov al,1 |
call putbit |
mov al,0 |
call putbit |
jmp end_c_loop |
ec5: |
mov al,0 |
call putbit |
call putbit |
mov al,1 |
call putbit |
jmp end_c_loop |
ec4: |
mov al,0 |
call putbit |
call putbit |
call putbit |
jmp end_c_loop |
ec3: |
mov al,1 |
call putbit |
mov al,0 |
call putbit |
jmp end_c_loop |
ec2: |
mov al,0 |
call putbit |
mov al,1 |
call putbit |
jmp end_c_loop |
ec1: |
mov al,0 |
call putbit |
call putbit |
end_c_loop: |
jmp c_loop |
finish_c_loop: |
mov eax,dword [controlp] ; store last tagbyte |
mov bl,byte [controld] |
mov [eax], byte bl |
sub edi,ofile ; calculate dump size |
mov edx,edi |
jmp compress_dumpdata |
; LZP decompression algorithm |
lzp_decompress: ; EDX - how much bytes to dump |
cld |
mov edi,ifile |
mov esi,ofile+1 |
pusha ; fill hash table |
mov eax,ifile |
mov edi,hashtable |
mov ecx,65536 |
rep stosd |
popa |
lodsd |
mov ebx,edi |
add ebx,eax |
mov dword [endpointer],ebx |
movsw |
movsb |
lodsb |
mov byte [controld],al |
mov byte [controlb],0 |
d_loop: |
cmp dword [endpointer],edi |
ja d_loop_ok |
jmp finish_d_loop |
d_loop_ok: |
call getbit |
cmp al,0 |
jnz match_d |
call dhash |
movsb |
call dhash |
movsb |
jmp end_d_loop |
match_d: |
call getbit |
cmp al,0 |
jnz no_literal_before_match |
call dhash |
movsb |
no_literal_before_match: |
call dhash |
mov ecx,1 |
call copymatch |
call getbit |
cmp al,0 |
jz end_d_loop |
mov ecx,1 |
call copymatch |
call getbit |
cmp al,0 |
jz dc2 |
mov ecx,2 |
call copymatch |
call getbit |
cmp al,0 |
jz end_d_loop |
mov ecx,1 |
call copymatch |
call getbit |
cmp al,0 |
jz dc4 |
mov ecx,4 |
call copymatch |
call getbit |
cmp al,0 |
jz dc5 |
call getbit |
cmp al,0 |
jz dc6 |
mov ecx,3 |
call copymatch |
do: |
lodsb |
xor ecx,ecx |
mov cl,al |
call copymatch |
cmp al,0xFF |
jnz end_do |
jmp do |
end_do: |
jmp end_d_loop |
dc6: |
mov ecx,2 |
call copymatch |
jmp end_d_loop |
dc5: |
call getbit |
cmp al,0 |
jz ndc5 |
mov ecx,1 |
call copymatch |
ndc5: |
jmp end_d_loop |
dc4: |
call getbit |
cmp al,0 |
jz ndc4 |
call getbit |
mov ecx,3 |
cmp al,1 |
jz ndcc4 |
dec ecx |
ndcc4: |
call copymatch |
jmp end_d_loop |
ndc4: |
call getbit |
cmp al,0 |
jz ndccc4 |
mov ecx,1 |
call copymatch |
ndccc4: |
jmp end_d_loop |
dc2: |
call getbit |
cmp al,0 |
jz ndc2 |
mov ecx,1 |
call copymatch |
ndc2: |
end_d_loop: |
jmp d_loop |
finish_d_loop: |
mov edx, dword [ofile+1] |
jmp decompress_dumpdata |
; LZP subroutines |
putbit: ; bit -> byte tag, AL holds bit for output |
pusha |
mov cl,byte [controlb] |
shl al,cl |
mov bl,byte [controld] |
or bl,al |
mov byte [controld],bl |
inc cl |
cmp cl,8 |
jnz just_increment |
mov byte [controlb],0 |
mov byte [controld],0 |
push edi |
mov edi, dword [controlp] |
mov al,bl |
stosb |
pop edi |
mov dword [controlp],edi |
popa |
inc edi |
ret |
just_increment: |
mov byte [controlb],cl |
popa |
ret |
getbit: ; tag byte -> bit, AL holds input |
push ecx |
mov al,byte [controld] |
mov cl,byte [controlb] |
shr al,cl |
and al,1 |
inc cl |
cmp cl,8 |
jnz just_increment_d |
mov byte [controlb],0 |
push eax |
lodsb |
mov byte [controld],al |
pop eax |
pop ecx |
ret |
just_increment_d: |
mov byte [controlb],cl |
pop ecx |
ret |
chash: ; calculate hash -> mp -> fill position |
pusha |
xor eax,eax |
mov al, byte [esi-1] |
mov ah, byte [esi-2] |
shl eax,2 |
add eax,hashtable |
mov edx,dword [eax] |
mov dword [mp],edx |
mov dword [eax],esi |
popa |
ret |
dhash: ; calculate hash -> mp -> fill position |
pusha |
xor eax,eax |
mov al, byte [edi-1] |
mov ah, byte [edi-2] |
shl eax,2 |
add eax,hashtable |
mov edx,dword [eax] |
mov dword [mp],edx |
mov dword [eax],edi |
popa |
ret |
copymatch: ; ECX bytes from [mp] to [rp] |
push esi |
mov esi,dword [mp] |
rep movsb |
mov dword [mp],esi |
pop esi |
ret |
compare: ; compare [mp] with [cpos] |
push edi |
push esi |
mov edi,dword [mp] |
cmpsb |
pop esi |
pop edi |
ret |
incpos: |
inc dword [mp] |
inc esi |
ret |
; LZP algorithm data |
endpointer dd 0 |
controlp dd 0 |
controlb db 0 |
controld db 0 |
mp dd 0 |
literal db 0 |
MHC_END: ; the end... - Nikita Lesnikov (nlo_one) |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/mview/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm mview.asm mview |
@pause |
/programs/develop/mview/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm mview.asm mview |
@pause |
/programs/develop/mview/trunk/macros.inc |
---|
0,0 → 1,267 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/mview/trunk/mview.asm |
---|
0,0 → 1,1439 |
; CODE VIEWER - Compile with FASM for Menuet |
;B+ System header |
use32 |
org 0x0 |
db 'MENUET00' |
dd 38 |
dd START |
dd I_END |
dd 0x100000 |
dd 0x00000000 |
include 'lang.inc' |
include 'macros.inc' |
;E:. |
;B+ Definitions |
type_begin equ 0 |
type_end_normal equ 2 |
type_not_end equ 4 |
type_end_plus equ 6 |
type_include equ 8 |
type_file_end equ 11 |
; +1, if active jump |
char_end equ 11 |
new_line equ 10 |
win_width equ (496+6*6) |
win_field equ (4+10+6*6) |
win_toptext equ 38+4 |
;B+ Keys |
KEY_UP equ (130+48) |
KEY_DOWN equ (129+48) |
KEY_PGUP equ (136+48) |
KEY_PGDOWN equ (135+48) |
;E:. |
start_data equ (I_END+10+27+16) |
;E:. |
;B+ Execution |
START: |
jmp load_file1 |
;B+ Main cicle |
redr: |
call draw_window |
still: |
mov eax,10 |
int 0x40 |
still_: |
cmp eax,1 |
je redr |
cmp eax,2 |
jne no_key |
mov eax,2 |
int 0x40 |
jmp key |
no_key: |
cmp eax,3 |
jne still |
mov eax,17 |
int 0x40 |
cmp ah,1 |
jne .no_close |
mov eax,-1 |
int 0x40 |
.no_close: |
jmp button |
jmp still |
;E:. |
key: |
;B+ Scroll text |
mov ebx,[top_pos] |
mov [activ_pos],ebx |
mov bx,[top_line] |
mov [activ_line],bx |
mov bx,[top_depth] |
mov [activ_depth],bx |
mov ebx,[top_file] |
mov [activ_file],ebx |
cmp ah,KEY_DOWN ;key_up |
jne .no_down |
call line_down |
jmp .save_shift |
.no_down: |
cmp ah,KEY_UP ;key down |
jne .no_up |
call line_up |
jmp .save_shift |
.no_up: |
cmp ah,KEY_PGUP ;key page up |
jne .no_pgup |
mov edi,35 |
.next_line: |
call line_up |
dec edi |
jnz .next_line |
jmp .save_shift |
.no_pgup: |
cmp ah,KEY_PGDOWN ;key page down |
jne .no_pgdown |
mov edi,35 |
.next_line1: |
call line_down |
dec edi |
jnz .next_line1 |
jmp .save_shift |
.no_pgdown: |
jmp still |
.save_shift: |
mov ebx,[activ_pos] |
mov [top_pos],ebx |
mov bx,[activ_line] |
mov [top_line],bx |
mov bx,[activ_depth] |
mov [top_depth],bx |
mov ebx,[activ_file] |
mov [top_file],ebx |
; Show new text |
mov ebx,1 |
mov eax,12 |
int 0x40 |
call show_text |
mov ebx,2 |
mov eax,12 |
int 0x40 |
jmp still |
;E:. |
button: |
;B+ Distribute button events |
shr eax,8 |
and eax,0xff |
cmp eax,100 |
jge down_buttons |
;B+ Left buttons |
;B+ Find line place |
sub eax,2 |
mov ebx,[top_pos] |
mov [activ_pos],ebx |
mov bx,[top_depth] |
mov [activ_depth],bx |
mov ebx,[top_file] |
mov [activ_file],ebx |
mov bx,[top_line] |
mov [activ_line],bx |
mov ecx,eax |
or ecx,ecx |
jz .line_find |
.next_line: |
push ecx |
call line_down |
pop ecx |
loop .next_line |
.line_find: |
mov ebx,[activ_pos] |
;E:. |
;B+ Switch, if special line |
mov cx,[ebx] |
test cx,not 15 |
jnz still |
cmp cx,type_begin |
je .is_begin_end |
cmp cx,type_begin+1 |
jne .not_begin_end |
.is_begin_end: |
xor [ebx],word 1 |
mov ebx,[ebx+4] |
add ebx,[activ_file] |
xor [ebx],word 1 |
jmp .paint |
.not_begin_end: |
cmp cx,type_include |
je .open_file |
;close file |
cmp cx,type_include+1 |
jne .not_include |
xor [ebx],word 1 |
jmp .paint |
.open_file: |
;Open file |
cmp dword [ebx+4],-1 |
je .load_file |
xor [ebx],word 1 |
jmp .paint |
.paint1: |
pop ebx |
jmp .paint |
.load_file: |
push ebx |
;B+ Prepare file name |
mov ecx,26 |
mov edi,incl_filename |
mov al,' ' |
cld |
rep stosb |
mov cl,[skoba_txt] |
mov ch,[skoba_txt+1] |
add ebx,12 |
.next_char: |
cmp [ebx],cl |
je .begin |
cmp byte [ebx],new_line |
je .paint1 |
inc ebx |
jmp .next_char |
.begin: |
inc ebx |
mov esi,ebx |
.next_char1: |
cmp [ebx],ch |
je .end |
cmp byte [ebx],new_line |
je .paint1 |
inc ebx |
jmp .next_char1 |
.end: |
sub ebx,esi |
mov edi,incl_filename |
mov ecx,ebx |
push ecx |
rep movsb |
; mov al,0 |
; stosb |
;Save in memory |
mov ecx,[esp] |
mov esi,incl_filename |
mov edi,[end_of_file] |
rep movsb |
pop ecx |
mov [edi],ecx |
add ecx,2 |
add [end_of_file],ecx |
mov ebx,[esp] |
;E:. |
mov edi,[top_free_file] |
mov [ebx+4],edi |
mov [activ_pos],ebx |
mov eax,[activ_file] |
sub ebx,eax |
mov [incl_line],ebx |
push eax |
call line_down |
pop eax |
mov ebx,[activ_pos] |
sub ebx,eax |
mov [incl_next],ebx |
pop ebx |
xor [ebx],word 1 |
push eax |
mov eax,[end_of_file] |
add eax,16 |
mov [activ_file],eax |
lea edi,[file_array+4*edi] |
mov [edi],eax |
mov [activ_pos],eax |
mov ebx,[incl_line] |
mov [eax-12],ebx |
mov bx,[activ_line] |
dec bx |
mov word [eax-6],bx |
;B+ Save number for new file |
mov ebx,[esp] |
cmp ebx,[file_array] |
jne .no_root |
mov [eax-8],word 0 |
jmp .parent_ok |
.no_root: |
mov ebx,[esp] |
mov bl,[ebx-2] |
and ebx,0xff |
mov [eax-8],bx |
.parent_ok: |
push eax |
;E:. |
call add_file |
mov edi,[block_pointer] |
mov word [edi+4],char_end |
add [block_pointer],8 |
push edi |
call fresh_file |
pop edi eax |
mov [block_pointer],edi |
;B+ Save newfile line count |
mov edi,[line_] |
mov word [eax-4],di |
;E:. |
pop eax |
mov [activ_file],eax |
inc [top_free_file] |
jmp .paint |
.not_include: |
.paint: |
mov ebx,1 |
mov eax,12 |
int 0x40 |
call show_text |
mov ebx,2 |
mov eax,12 |
int 0x40 |
;E:. |
jmp still |
;E:. |
down_buttons: |
;B+ If down buttons |
cmp eax,101 |
je load_file ;Button 'Load' |
sub eax,100 |
mov edx,[str_table+4*eax] |
mov [str_start],edx |
;B+ Clear old info |
push edx |
;clear text |
mov ecx,0xaa0000 |
call print_str |
pop edx |
;clear memory place |
mov ecx,[edx] |
lea edi,[edx+8] |
mov eax,' ' |
cld |
rep stosb |
;E:. |
mov ebx,[edx] |
mov [max_len],ebx |
mov ebx,[edx+4] |
jmp load_str |
save_str: |
;B+ Save in base place |
;B+ If file convert to upper case |
mov eax,it1 |
cmp eax,[str_start] |
jne .no_file |
mov ecx,0xaa0000 |
mov edx,str_ |
mov esi,[it1] |
mov ebx,[it1+4] |
mov eax,4 |
int 0x40 |
mov edx,edi |
mov eax,str_ |
dec eax |
inc edx |
.next_char: |
inc eax |
dec edx |
jz .no_file |
cmp byte [eax],'a' |
jl .next_char |
cmp byte [eax],'z' |
jg .next_char |
add byte [eax],'A'-'a' |
jmp .next_char |
.no_file: |
;E:. |
mov edx,[str_start] |
add edx,8 |
mov ecx,edi |
add edi,edx |
mov byte [edi],char_end |
mov eax,it1 |
cmp eax,[str_start] |
jne .no_null |
mov byte [edi],' ' ;0 |
.no_null: |
mov esi,str_ |
mov edi,edx |
cld |
rep movsb |
mov ecx,0xffffff |
jmp print_str |
;E:. |
;E:. |
;E:. |
;B+ String tools |
;B+ Data for load string |
curs db '_' |
str_: times 100 db ' ' |
db char_end |
max_len dd 10 |
;E:. |
load_str: |
;B+ Load text field |
xor edi,edi |
mov ecx,0xffaaaa |
mov esi,1 |
.next_char: |
mov edx,curs |
mov eax,4 |
int 0x40 |
;B+ Get key event |
mov eax,10 |
int 0x40 |
push eax |
mov ecx,0xaa0000 |
mov eax,4 |
int 0x40 |
pop eax |
cmp eax,2 |
je .yes_key |
call save_str |
jmp still_ |
.yes_key: |
mov eax,2 |
int 0x40 |
;E:. |
;B+ Test enter |
cmp ah,13 |
jne .no_ok |
call save_str |
jmp still |
.no_ok: |
;E:. |
;B+ Test backspace |
cmp ah,8 |
jne .no_backsp |
or edi,edi |
jz .next_char |
mov byte [str_+edi],' ' |
mov ecx,0xaa0000 |
mov eax,4 |
int 0x40 |
dec edi |
sub ebx,6*65536 |
lea edx,[str_+edi] |
int 0x40 |
mov ecx,0xffaaaa |
jmp .next_char |
.no_backsp: |
;E:. |
;B+ Prin 1 char |
mov [str_+edi],ah |
mov ecx,0xaa0000 |
mov eax,4 |
int 0x40 |
mov ecx,0xffaaaa |
lea edx,[str_+edi] |
cmp [max_len],edi |
je .next_char |
int 0x40 |
add ebx,6*65536 |
inc edi |
;E:. |
jmp .next_char |
;E:. |
print_str: |
;B+ Print select string |
mov ebx,[str_start] |
lea edx,[ebx+8] |
mov esi,[ebx] |
mov ebx,[ebx+4] |
mov eax,4 |
int 0x40 |
;B+ Test special strings |
pusha |
mov eax,[str_start] |
cmp eax,it2 |
jge .is_ok1 |
popa |
ret |
.is_ok1: |
cmp eax,it3 |
jle .is_ok |
popa |
ret |
.is_ok: |
;E:. |
add eax,8 |
.next_char: |
mov esi,1 |
cmp byte [eax],' ' |
jne .no_space |
;B+ Draw special space |
push eax |
mov edx,space |
mov eax,4 |
int 0x40 |
push ebx |
sub ebx,1*65536 |
mov edx,dot |
int 0x40 |
add ebx,3*65536 |
int 0x40 |
pop ebx |
pop eax |
;E:. |
.no_space: |
add ebx,6*65536 |
cmp byte [eax],char_end |
jne .no_ret |
popa |
ret |
.no_ret: |
inc eax |
jmp .next_char |
space db '_' |
dot db '.' |
;E:. |
;E:. |
;B+ Add / remove files |
add_file: |
;B+ Load and link file |
mov eax,[activ_file] |
push eax |
mov ebx,incl_filename |
mov ecx,0 |
mov edx,-1 |
mov esi,eax |
mov eax,6 |
int 0x40 |
mov ebx,[esp] |
inc eax |
mov [ebx-16],eax |
dec eax |
add ebx,eax |
add eax,16+15 +20 ;??? |
add [end_of_file],eax |
mov byte [ebx],new_line |
mov word [ebx+1],char_end |
mov ax,[activ_line] |
mov word [ebx+3],ax |
mov eax,[incl_next] |
mov [ebx+5],eax |
mov dword [ebx+9],new_line |
mov byte [ebx+13],new_line |
pop ebx |
mov eax,[top_free_file] |
mov byte [ebx-2],al ; this file num |
mov byte [ebx-1],new_line |
ret |
;E:. |
;B+ Include file data |
incl_filename db 'KERNEL.ASM' |
if_e: |
times (26+incl_filename-if_e) db ' ' |
incl_line dd 0x0 |
incl_next dd 0x0 |
;E:. |
;E:. |
;E:. |
;B+ Visualization tools |
draw_window: |
;B+ Redraw window |
mov ebx,1 |
mov eax,12 |
int 0x40 |
;B+ Draw window |
mov ebx,((640-win_width)/2)*65536+win_width |
mov ecx,10*65536+win_toptext+35*10+1+2*16 |
mov edx,[color_depth] |
or edx,0x03000000 |
mov esi,0x80aaaaff |
mov edi,0x00009000 |
mov eax,0x0 |
int 0x40 |
;E:. |
;B+ Draw caption |
mov ebx,8*65537 |
mov ecx,0xffffff |
mov edx,caption |
mov esi,caption_end-caption |
mov eax,4 |
int 0x40 |
;E:. |
;B+ Draw first line |
mov ebx,5*65536+win_width-9 |
mov ecx,25*65536+win_toptext-22-4 |
mov edx,0xaa0000 |
mov eax,13 |
int 0x40 |
mov ebx,21*65536+29 |
mov ecx,0xffffff |
mov edx,line1up1 |
mov esi,line1up1_end-line1up1 |
mov eax,4 |
int 0x40 |
mov ebx,(win_field+6)*65536+29 |
mov edx,line1up2 |
mov esi,line1up2_end-line1up2 |
int 0x40 |
;E:. |
;B+ Main text zone |
;B+ Fill text |
;Clear type lines |
mov edi,lines_view |
mov ecx,35 |
mov eax,0 |
cld |
repe stosd |
call show_text |
;E:. |
;B+ Define left buttons |
; mov ebx,5*65536+9 |
; mov ecx,win_toptext*65536+9 |
; mov edx,0 |
; mov esi,0x9000a0 |
; mov eax,8 |
; mov edi,35 |
;.new_button: |
; int 0x40 |
; add ecx,10*65536 |
; inc edx |
; dec edi |
; jnz .new_button |
;E:. |
;B+ Vertical line |
mov ebx,(win_field-1)*65537 |
mov ecx,24*65536+win_toptext+35*10 |
mov edx,0xffffff |
mov eax,38 |
int 0x40 |
;E:. |
;E:. |
;B+ Down controle zone |
mov ebx,5*65536+win_width-9 |
mov ecx,(35*10+win_toptext+1)*65536+28 |
mov edx,0xaa0000 |
mov eax,13 |
int 0x40 |
mov eax,line1down |
mov ebx,filetxt |
mov ecx,filetxt_end |
call ins_button_prep |
mov edx,100 |
mov eax,8 |
int 0x40 |
mov eax,line1down |
mov ebx,loadtxt |
mov ecx,loadtxt_end |
call ins_button_prep |
inc edx |
mov eax,8 |
int 0x40 |
mov eax,line1down |
mov ebx,begintxt |
mov ecx,begintxt_end |
call ins_button_prep |
inc edx |
mov eax,8 |
int 0x40 |
mov eax,line1down |
mov ebx,endtxt |
mov ecx,endtxt_end |
call ins_button_prep |
inc edx |
mov eax,8 |
int 0x40 |
mov eax,line2down |
mov ebx,inctxt |
mov ecx,inctxt_end |
call ins_button_prep |
add ecx,14*65536 |
inc edx |
mov eax,8 |
int 0x40 |
mov eax,line2down |
mov ebx,septxt |
mov ecx,septxt_end |
call ins_button_prep |
add ecx,14*65536 |
inc edx |
mov eax,8 |
int 0x40 |
mov ebx,22*65536+35*10+win_toptext+4 |
mov ecx,0xffffff |
mov edx,line1down |
mov esi,line1down_end-line1down |
mov eax,4 |
int 0x40 |
add ebx,14 |
mov edx,line2down |
mov esi,line2down_end-line2down |
int 0x40 |
;E:. |
;B+ Down controle strings |
mov ecx,0xffffff |
mov eax,it1 |
mov [str_start],eax |
call print_str |
mov eax,it2 |
mov [str_start],eax |
call print_str |
mov eax,it3 |
mov [str_start],eax |
call print_str |
mov eax,it4 |
mov [str_start],eax |
call print_str |
mov eax,it5 |
mov [str_start],eax |
call print_str |
;E:. |
mov ebx,2 |
mov eax,12 |
int 0x40 |
ret |
;E:. |
ins_button_prep: |
;B+ Insert button |
push edx |
push eax |
sub ecx,ebx |
mov eax,6 |
mul ecx |
add eax,6 |
push ax |
mov eax,[esp+2] |
sub ebx,eax |
mov eax,6 |
mul ebx |
add eax,18 |
xchg eax,ebx |
shl ebx,16 |
pop bx |
mov ecx,(35*10+win_toptext+1)*65536+13 |
mov esi,0x00a050 |
pop eax |
pop edx |
ret |
;E:. |
show_text: |
;B+ Show text |
;B+ Show file on top |
mov ebx,(win_field+45)*65536+win_width-(win_field+45+8) |
mov ecx,25*65536+win_toptext-22-4 |
mov edx,0xaa0000 |
mov eax,13 |
int 0x40 |
mov edx,[top_file] |
xor esi,esi |
mov si,[edx-18] |
sub edx,18 |
sub edx,esi |
mov ebx,(win_field+45)*65536+29 |
mov ecx,0xffaaaa |
mov eax,4 |
int 0x40 |
;E:. |
mov ax,[top_line] |
mov [activ_line],ax |
mov ebx,[top_pos] |
mov [activ_pos],ebx |
mov ax,[top_depth] |
mov [activ_depth],ax |
mov eax,[top_file] |
mov [activ_file],eax |
mov ecx,35 |
mov [line_],0 |
.next_line: |
cmp [activ_depth],0 |
jne .next |
cmp byte [ebx],char_end |
je .end_of_file |
.next: |
push ecx |
call show_line |
call line_down |
inc [line_] |
pop ecx |
loop .next_line |
ret |
.end_of_file: |
push ecx |
call clear_line |
inc [activ_pos] |
inc [line_] |
pop ecx |
loop .end_of_file |
ret |
;E:. |
;B+ Button chars |
leftchars db '-','+',' ','H' |
db '?', 0 ,'!','H' |
db '&','x',' ', 0 |
;E:. |
show_line: |
;B+ Show line |
call clear_line |
mov ebx,ecx |
shr ebx,16 |
inc ebx |
or ebx,(win_field+6)*65536 |
push ebx |
push eax |
;B+ Draw left button char |
mov eax,[activ_pos] |
mov ax,[eax] |
test ax,not 15 |
jnz .no_text |
and eax,0xff |
lea edx,[leftchars+eax] |
and ebx,0xffff |
or ebx,8*65536 |
mov ecx,0xffffff |
mov esi,1 |
mov eax,4 |
int 0x40 |
mov ebx,[esp+4] |
.no_text: |
;E:. |
;B+ Draw line number |
xor ecx,ecx |
mov cx,[activ_line] |
mov edx,(10+4+4)*65536 |
mov dx,bx |
mov ebx,5*65536 |
mov esi,0xeeeeee |
mov eax,47 |
int 0x40 |
;E:. |
;B+ Find line length |
xor esi,esi |
mov eax,[activ_pos] |
cmp byte [eax],new_line |
je .len_ok |
test word [eax],not 15 |
jnz .next_char |
add eax,12 ;sckip system zone |
.next_char: |
cmp byte [eax],new_line |
je .len_ok |
inc esi |
inc eax |
jmp .next_char |
.len_ok: |
mov eax,6 |
mul esi |
mov ecx,eax |
add ecx,6 |
pop eax |
mov [eax+2],cx |
;E:. |
mov ecx,[textcolor] |
mov edx,[activ_pos] |
xor edi,edi |
xor ebx,ebx |
mov bx,word [edx] |
cmp bl,new_line |
je .normal_show_line |
test bx,not 15 |
jnz .normal_show_line |
or edi,ebx |
mov ecx,[color_type+4*ebx] |
add edx,12 ;sckip system zone |
.normal_show_line: |
pop ebx |
mov eax,4 |
int 0x40 |
test edi,4 ;bad type close block |
jz .nobad |
add ebx,65536 |
int 0x40 |
.nobad: |
ret |
;E:. |
color_type: |
;B+ Color data |
dd 0x00dddd,0x00ee00 ;0/1 begin 00ee00 |
dd 0x00b5b5,0xffa000 ;2/3 end 00d000 |
dd 0xffffff,-1 ;4 text end |
dd 0x00b5b5,0xffa000 ;6/7 auto end |
dd 0x80ccff,0x80aaff ;8/9 include |
dd -1 ,0xffa000 ;11 file end |
textcolor dd 0xffffff |
;E:. |
clear_line: |
;B+ Clear text in line |
;B+ Find line position |
mov eax,[line_] |
mov ecx,10 |
mul cx |
mov ecx,eax |
add ecx,win_toptext |
;E:. |
;B+ Draw/clear button |
push ecx |
shl ecx,16 |
mov cx,9 |
mov ebx,5*65536+9 |
mov edx,[line_] |
add edx,2 |
mov esi,0x9000a0 |
mov eax,8 |
int 0x40 |
pop ecx |
;E:. |
;B+ Clear zone for line |
shl ecx,16 |
mov cx,10 |
mov ebx,(5+11)*65536+win_field-5-12 |
xor edx,edx |
mov dx,[activ_depth] |
mov edx,[color_depth+4*edx] |
mov eax,13 |
int 0x40 |
;E:. |
;B+ Clear main text zone |
mov ebx,(win_field)*65536+(win_width-win_field-8) |
mov eax,[line_] |
lea eax,[lines_view+4*eax] |
push eax |
mov ax,[eax] |
cmp ax,[activ_depth] |
jne .draw_all_line |
mov eax,[esp] |
cmp bx,[eax+2] |
jle .draw_all_line |
mov bx,[eax+2] |
.draw_all_line: |
mov eax,13 |
int 0x40 |
;E:. |
;B+ Update line type I |
pop eax |
mov bx,[activ_depth] |
mov [eax],bx |
;E:. |
ret |
activ_depth dw 0x0 |
color_depth dd 0x404040,0x606060,0x707070,0x7a7a7a |
dd 0x878787,0x909090,0x9a9a9a,0xa5a5a5 |
dd 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 |
lines_view: times 35 dd 0 |
;E:. |
line_up: |
;B+ Line up |
;B+ Test jumps I |
mov ebx,[activ_pos] |
cmp ebx,[activ_file] |
jne .yes_scroll |
cmp [activ_depth],0 |
jz .top_of_file |
dec [activ_depth] |
xor eax,eax |
mov ax,[ebx-8] |
mov eax,[file_array+4*eax] |
mov [activ_file],eax |
add eax,[ebx-12] |
mov [activ_pos],eax |
mov ax,[ebx-6] |
mov [activ_line],ax |
.top_of_file: |
ret |
;E:. |
.yes_scroll: |
sub ebx,2 |
.normal_line_up1: |
cmp byte [ebx],new_line |
je .line_ok |
dec ebx |
jmp .normal_line_up1 |
.line_ok: |
;B+ Test for special line |
cmp dword [ebx],new_line |
jne .line_ok1 |
sub ebx,9 |
;E:. |
.line_ok1: |
inc ebx |
test word [ebx],not 15 |
jnz .normal_line_up |
test word [ebx],1 |
jz .normal_line_up |
;B+ Test jumps II |
cmp word [ebx],type_end_normal+1 |
je .to_begin |
cmp word [ebx],type_end_plus+1 |
je .to_begin |
cmp word [ebx],type_include+1 |
je .to_incl |
jmp .normal_line_up |
;E:. |
.to_begin: |
mov eax,[ebx+4] |
add eax,[activ_file] |
mov [activ_pos],eax |
mov ax,[ebx+2] |
inc ax |
sub [activ_line],ax |
ret |
.to_incl: |
inc [activ_depth] |
mov eax,[ebx+4] |
mov eax,[file_array+4*eax] |
mov [activ_file],eax |
mov bx,[eax-4] |
mov [activ_line],bx |
add eax,[eax-16] |
mov [activ_pos],eax |
ret |
.normal_line_up: |
mov [activ_pos],ebx |
dec [activ_line] |
ret |
;E:. |
line_down: |
;B+ Line down |
mov ebx,[activ_pos] |
cmp byte [ebx],char_end |
jne .yes_scroll |
cmp [activ_depth],0 |
jne .yes_scroll |
ret |
.yes_scroll: |
cmp byte [ebx],new_line |
je .normal_line_down |
test word [ebx],not 15 |
jnz .normal_line_down |
test word [ebx],1 |
jz .not_activated |
;B+ Test jumps |
cmp word [ebx],type_begin+1 |
jne .no_begin |
mov eax,[ebx+4] |
add eax,[activ_file] |
mov [activ_pos],eax |
mov ax,[ebx+2] |
add [activ_line],ax |
call line_down |
ret |
.no_begin: |
cmp word [ebx],type_end_normal+1 |
je .not_activated |
cmp word [ebx],type_end_plus+1 |
je .not_activated |
;goto include |
cmp word [ebx],type_include+1 |
jne .no_incl |
inc [activ_depth] |
mov eax,[ebx+4] |
mov eax,[file_array+4*eax] |
mov [activ_file],eax |
mov [activ_pos],eax |
mov [activ_line],1 |
ret |
.no_incl: |
;return from include |
cmp word [ebx],type_file_end |
jne .no_end |
;CHECK FOR FIRST |
mov ax,[ebx+2] |
mov [activ_line],ax |
dec [activ_depth] |
mov ecx,[activ_file] |
xor eax,eax |
mov ax,[ecx-8] |
mov eax,[file_array+4*eax] |
mov [activ_file],eax |
add eax,[ebx+4] |
mov [activ_pos],eax |
mov ebx,eax |
ret |
.no_end: |
;E:. |
.not_activated: |
add ebx,12 ;sckip system zone |
.normal_line_down: |
cmp byte [ebx],new_line |
je .line_ok |
cmp byte [ebx],char_end |
inc ebx |
jmp .normal_line_down |
.line_ok: |
inc ebx |
mov [activ_pos],ebx |
inc [activ_line] |
ret |
;E:. |
;B+ File possition var. |
line_ dd 0x0 ;Line on screen |
top_pos dd start_data |
top_line dw 1 |
top_depth dw 0x0 |
activ_pos dd start_data |
activ_line dw 0x0 ;Abs line in file |
;E:. |
;E:. |
;B+ Load file tools |
load_file: |
;B+ Main |
;B+ Init parameters |
mov [top_pos],start_data |
mov [activ_pos],start_data |
mov [top_file],start_data |
mov [activ_file],start_data |
mov [file_array],start_data |
mov [top_free_file],1 |
mov [end_of_file],start_data |
mov [top_line],1 |
mov esi,file_txt |
mov edi,incl_filename |
mov ecx,25 |
cld |
rep movsb |
;E:. |
load_file1: |
;B+ Load and fresh file |
mov eax,[end_of_file] |
push eax |
call add_file |
mov edi,[esp] |
mov esi,incl_filename |
sub edi,16+25+2 |
mov ecx,27 |
cld |
rep movsb |
pop edi |
mov word [edi-18],25 |
mov eax,[top_pos] |
mov [activ_pos],eax |
call fresh_file |
call draw_window |
jmp still |
;E:. |
;E:. |
fresh_file: |
;B+ Fresh file |
mov [line_],0 |
mov [next_],next |
.fresh_next: |
inc [line_] |
;Test open block |
mov eax,[begin_txt] |
mov ebx,[activ_pos] |
cmp [ebx],eax |
je block_begin |
;Test close block |
mov eax,[end_txt] |
cmp [ebx],eax |
je block_end |
;B+ Test include |
mov esi,ebx |
mov edi,include_txt |
mov ecx,20 |
cld |
rep cmpsb |
cmp byte [edi-1],char_end |
je include_file |
;E:. |
next: |
;B+ Go to next line |
mov ebx,[activ_pos] |
.next_char: |
cmp byte [ebx],new_line |
je yes_next |
cmp byte [ebx],char_end |
je file_end |
inc ebx |
jmp .next_char |
yes_next: |
inc ebx |
inc [activ_line] |
mov [activ_pos],ebx |
jmp fresh_file.fresh_next |
;E:. |
file_end: |
;B+ Auto set close block |
mov [next_],.try_fill_next |
sub ebx,5 |
dec [activ_line] |
mov [activ_pos],ebx |
.try_fill_next: |
add [activ_pos],5 |
inc [activ_line] |
mov ebx,[activ_pos] |
mov eax,[end_txt] |
mov ecx,[block_pointer] |
cmp word [ecx-4],char_end |
je .fill_ok |
inc [line_] |
call ins_5_bytes |
mov dword [ebx],eax |
mov byte [ebx+4],new_line |
mov byte [ebx+5],char_end |
mov [activ_pos],ebx |
jmp block_end |
;E:. |
.fill_ok: |
ret |
;E:. |
;B+ Specify line markers |
block_begin: |
;B+ Mark block begin |
;B+ Mark info in stack |
mov eax,[activ_pos] |
mov ebx,[block_pointer] |
push eax |
sub eax,[activ_file] |
mov [ebx],eax |
pop eax |
mov word [ebx+4],0 |
mov cx,[activ_line] |
mov word [ebx+6],cx |
add ebx,8 |
mov [block_pointer],ebx |
;E:. |
call ins_12_bytes |
;line / possition not ready |
mov word [eax],type_begin+1 |
mov dword [eax+8],new_line |
add [activ_pos],12 |
jmp [next_] |
;E:. |
block_end: |
;B+ Mark block end |
;B+ Mark end type I |
mov eax,[activ_pos] |
call ins_12_bytes |
mov ecx,[block_pointer] |
cmp word [ecx-4],char_end |
je .normal_line |
;E:. |
;Pop stack |
sub [block_pointer],8 |
sub ecx,8 |
;B+ Form this (END) line/place to BEGIN |
mov edx,[ecx] |
add edx,[activ_file] |
mov eax,[activ_pos] |
sub eax,[activ_file] |
mov [edx+4],eax |
mov bx,[activ_line] |
sub bx,[ecx+6] |
mov [edx+2],bx |
;E:. |
;B+ From stack line/place to this (END) |
mov eax,[activ_pos] |
mov edx,[ecx] |
mov [eax+4],edx |
mov [eax+2],bx |
;E:. |
;B+ Mark end type II |
mov word [eax],type_end_normal+1 |
mov ecx,[next_] |
cmp ecx,next |
je .yes_normal |
mov word [eax],type_end_plus+1 |
.yes_normal: |
mov dword [eax+8],new_line |
add [activ_pos],12 |
jmp [next_] |
.normal_line: |
mov word [eax],type_not_end |
mov dword [eax+8],new_line |
add [activ_pos],12 |
jmp [next_] |
;E:. |
;E:. |
include_file: |
;B+ Include and attach file |
mov eax,[activ_pos] |
push eax |
call ins_12_bytes |
pop eax |
mov word [eax],type_include |
mov word [eax+2],0 |
mov dword [eax+4],-1 |
mov dword [eax+8],new_line |
dec [line_] |
jmp [next_] |
;E:. |
next_ dd next |
;E:. |
;B+ Additional tools |
ins_12_bytes: |
mov ecx,[end_of_file] |
add [end_of_file],12 |
mov esi,ecx |
add ecx,12 |
mov edi,ecx |
sub ecx,11 |
sub ecx,eax |
std |
rep movsb |
mov ecx,[activ_file] |
add dword [ecx-16],12 |
ret |
ins_5_bytes: |
mov ecx,[end_of_file] |
add [end_of_file],5 |
mov esi,ecx |
add ecx,5 |
mov edi,ecx |
sub ecx,4 |
sub ecx,ebx |
std |
rep movsb |
mov ecx,[activ_file] |
add dword [ecx-16],5 |
ret |
ins_1_byte: |
mov ecx,[end_of_file] |
inc [end_of_file] |
mov esi,ecx |
inc ecx |
mov edx,ecx |
sub ecx,ebx |
std |
rep movsb |
mov ecx,[activ_file] |
inc dword [ecx-16] |
ret |
;E:. |
;E:. |
;B+ Data section |
;B+ View data |
caption db 'CODE VIEWER - ver. 0.2' |
caption_end: |
line1up1 db 'LINE' |
line1up1_end: |
line1up2 db 'FILE:' |
line1up2_end: |
line1down: |
filetxt db 'FILE->' |
filetxt_end: |
times 28 db ' ' |
loadtxt db 'LOAD' |
loadtxt_end: |
db ' BLOCK: ' |
begintxt db 'BEGIN->' |
begintxt_end: |
times 10 db ' ' |
db '...' |
times 10 db ' ' |
endtxt db '<-END' |
endtxt_end: |
line1down_end: |
line2down: |
inctxt db 'INCLUDE KEYWORD->' |
inctxt_end: |
times 46 db ' ' |
septxt db 'SEPARATORS->' |
septxt_end: |
line2down_end: |
;E:. |
;B+ Parameter strings |
str_start dd it1 |
str_table dd it1,0,it2,it3,it4,it5 |
;align |
it1: |
dd 25 |
dd (20+6*7)*65536+35*10+win_toptext+3 |
file_txt: |
db 'KERNEL.ASM ',char_end |
;align 4 |
it2: |
dd 4 |
dd (20+56*6)*65536+35*10+win_toptext+3 |
begin_txt: |
db ';B+ ',char_end |
;align 4 |
it3: |
dd 4 |
dd (20+71*6)*65536+35*10+win_toptext+3 |
end_txt: |
db ';E:.',char_end |
;align 4 |
it4: |
dd 43 |
dd (20+18*6)*65536+35*10+win_toptext+3+14 |
include_txt: |
db 'include ',char_end,' ' |
;align 4 |
it5: |
dd 2 |
dd (20+76*6)*65536+35*10+win_toptext+3+14 |
skoba_txt: |
db '"" ',char_end |
;E:. |
block_pointer dd block_stack+8 |
block_stack dw 0,0,char_end,0 |
times 10*2 dd 0x0 |
; STACK BOX: |
; ÚÄÄÄÄÄÄÄÄÄÂÄÄÄÄÂÄÄÄÄÏ |
; Óabs placeÓ 0 ÓlineÓ |
; ÀÄÄÄÄÄÄÄÄÄÁÄÄÄÄÁÄÄÄÄÙ |
; or 0000 'char_end' 00 - bottom |
top_file dd start_data |
activ_file dd start_data |
top_free_file dd 1 |
file_array dd start_data |
times 50 dd 0x0 |
end_of_file dd start_data |
; TEXT MARKER: |
; ÚÄÄÄÄÂÄÄÄÄÂÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÏ |
; ÓtypeÓn.l.Ónew placeÓ 13 Ó |
; ÀÄÄÄÄÁÄÄÄÄÁÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÙ |
;E:. |
;B+ Program preview |
;ÚÄÄÄÄÄ |
;ÓCODE VIEWER - ver. 0.2 o _ x |
;ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ |
;Ó Line | File: |
;Ó---------+--------------------- |
;Ó[+] | |
;Ó[-] | |
;Ó[ ] | |
;Ó[#] | |
;ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ |
;Ó [FILE->]___________ [LOAD] BLOCK: [BEGIN->];B+ú ... ;E:.[<-END] Ó |
;Ó [INCLUDE KEYWORD->]include [SEPARATORS->]"" |
;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ |
;E:. |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/param/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm param.asm param |
@pause |
/programs/develop/param/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm param.asm param |
@pause |
/programs/develop/param/trunk/cmdipc.inc |
---|
0,0 → 1,221 |
include "macros.inc" |
initipc: |
mov eax,9 |
mov ebx,prc |
mov ecx,-1 |
int 0x40 |
mov ecx,eax |
loop1: |
push ecx |
mov eax,9 |
mov ebx,prc |
int 0x40 |
cmp word [prc+10],'CM' |
jne no_cmd |
cmp byte [prc+12],'D' |
jne no_cmd |
mov ebx,[prc+30] |
mov dword [cmdpid],ebx |
mov dword [cmdnumb],ecx |
no_cmd: |
pop ecx |
loop loop1 |
cmp dword [cmdpid],0 |
jne no_exit |
jmp exit |
no_exit: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,printf |
mov esi,4 |
int 0x40 |
call initcmd |
waitcmdinit: |
mov eax,40 |
mov ebx,01000000b |
int 0x40 |
mov eax,23 |
mov ebx,100 |
int 0x40 |
cmp eax,7 |
je cmd_ok |
jmp exit |
cmd_ok: |
cmp byte [ipcb+16],'.' |
jne exit |
mov eax,18 |
mov ebx,3 |
mov ecx,dword [cmdnumb] |
int 0x40 |
ret |
pause1: |
mov eax,5 |
mov ebx,1 |
int 0x40 |
ret |
exit: |
mov eax,-1 |
int 0x40 |
cls: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipccls |
mov esi,4 |
int 0x40 |
call pause1 |
ret |
print: |
mov ecx,84 |
loopprt: |
mov edi,stripc |
add edi,ecx |
mov esi,fill_symbol |
movsb |
loop loopprt |
cld |
mov ecx,4 |
mov edi,stripc |
mov esi,printf |
rep movsb |
cld |
mov edx,79 |
sub edx,eax |
mov ecx,79 |
sub ecx,edx |
mov edi,stripc+4 |
mov esi,ebx |
rep movsb |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,stripc |
mov esi,84 |
int 0x40 |
call pause1 |
ret |
eol: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipceol |
mov esi,4 |
int 0x40 |
call pause1 |
ret |
initcmd: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipckey |
mov esi,4 |
int 0x40 |
mov eax,60 |
mov ebx,1 |
mov ecx,ipcb |
mov edx,28 |
int 0x40 |
cld |
mov ecx,28 |
mov edi,ipcb |
mov esi,ipcc |
rep movsb |
ret |
getkey: |
call initcmd |
waitagain: |
mov eax,40 |
mov ebx,01000000b |
int 0x40 |
mov eax,10 |
int 0x40 |
cmp eax,7 |
jne waitagain |
mov edi,key |
mov esi,ipcb+16 |
movsb |
ret |
endipc: |
mov eax,60 |
mov ebx,2 |
mov ecx,dword [cmdpid] |
mov edx,ipcend |
mov esi,4 |
int 0x40 |
jmp exit |
cmdpid dd 0 |
cmdnumb dd 0 |
printf db '~ppp' |
ipceol db '~lll' |
ipcend db '~eee' |
ipccls db '~ccc' |
ipckey db '~kkk' |
key db 0 |
ipcb: |
db 0 |
db 0,0,0 |
dd 8 |
times 20 db 0 |
ipcc: |
db 0 |
db 0,0,0 |
dd 8 |
times 20 db 0 |
stripc: times 84 db 0 |
fill_symbol db 0 |
prc: times 52 db 0 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/param/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/param/trunk/param.asm |
---|
0,0 → 1,56 |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd START |
dd I_END |
dd 0x100000 |
dd 0x7fff0 |
dd I_PARAM ; 㪠§ â¥«ì ¯ à ¬¥âàë |
include "lang.inc" |
include "cmdipc.inc" ; ®¤ª«îç¨âì ä ©« CMDIPC.INC |
START: |
call initipc ; ¨¨æ¨ «¨§¨à®¢ âì ¤«ï à ¡®âë á CMD |
mov eax,47 ; ¢ë¢¥á⨠ᮮ¡é¥¨¥ |
mov ebx,mess |
call print |
call eol ; ¯à®¯ãáâ¨âì áâபã |
call eol |
cmp [I_PARAM],byte 0 ; ¯à®¢¥à¨âì, ¥áâì «¨ ¯ à ¬¥âàë |
jz noparam |
mov eax,43 |
mov ebx,mess1 |
call print |
call eol |
mov eax,30 ; ¢ë¢¥á⨠¯ à ¬¥âàë |
mov ebx,I_PARAM |
call print |
jmp end1 ; ¯¥à¥å®¤ ¢ ª®¥æ ¯à®£à ¬¬ë |
noparam: |
mov eax,40 ; ¢ë¢¥á⨠ᮮ¡é¥¨¥ ® ⮬, çâ® ¥â ¯ à ¬¥â஢ |
mov ebx,mess2 |
call print |
end1: |
jmp endipc ; § ¢¥àè¨âì ¯à®£à ¬¬ã |
mess db 'PARAM.ASM - Test params in IPC programs for CMD' |
mess1 db 'This program was started with this params: ' |
mess2 db 'This program was started without params!' |
I_PARAM db 0 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/scancode/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm scancode.asm scancode |
@pause |
/programs/develop/scancode/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm scancode.asm scancode |
@pause |
/programs/develop/scancode/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/scancode/trunk/scancode.asm |
---|
0,0 → 1,336 |
; |
; KEYBOARD SCANCODE EXAMPLE |
; |
; Compile with FASM for Menuet |
; |
include "lang.inc" |
include "macros.inc" |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x1000 ; memory for app |
dd 0x1000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
START: ; start of execution |
mov eax,66 ; keyboard mode definitions |
mov ebx,1 ; set |
mov ecx,1 ; return scancodes |
int 0x40 |
mov eax,26 ; get setup for keyboard |
mov ebx,2 |
mov ecx,1 ; base keymap |
mov edx,keymap |
int 0x40 |
call draw_window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
mov esi,scan_codes+1 |
mov edi,scan_codes+0 |
mov ecx,15 |
cld |
rep movsb |
mov esi,key_codes+12 |
mov edi,key_codes+0 |
mov ecx,15*12 |
cld |
rep movsb |
shr eax,8 ; scancode |
and eax,0xff |
mov [scan_codes+15],al |
mov [key_codes+15*12+8],dword 'Down' |
cmp eax,128 |
jb no_up |
mov [key_codes+15*12+8],dword 'Up ' |
no_up: |
mov ebx,eax |
and ebx,0x7f |
movzx edx,byte [keymap+ebx] ; key from keymap |
mov [key_codes+15*12+0],edx |
mov [key_codes+15*12+4],dword ' ' |
movzx edx,byte [ext] |
shl edx,8 |
add ebx,edx |
mov esi,ext0-10 |
new_ext0: |
add esi,10 |
cmp esi,ext0end |
jg exit_ext0 |
movzx edx,word [esi] |
cmp edx,ebx |
jne new_ext0 |
mov edx,[esi+2] |
mov [key_codes+15*12+0],edx |
mov edx,[esi+6] |
mov [key_codes+15*12+4],edx |
exit_ext0: |
no_ext_off: |
cmp [ext2],0 |
je noext2dec |
dec [ext2] |
jne noext2dec |
mov [key_codes+15*12+0],dword '----' |
mov [key_codes+15*12+4],dword '----' |
noext2dec: |
mov [ext],0 |
cmp eax,224 |
jne no_ext |
mov [key_codes+15*12+0],dword ' ' |
mov [key_codes+15*12+4],dword ' ' |
mov [key_codes+15*12+8],dword 'Ext ' |
mov [ext],1 |
no_ext: |
cmp eax,225 |
jne no_ext2 |
mov [key_codes+15*12+0],dword ' ' |
mov [key_codes+15*12+4],dword ' ' |
mov [key_codes+15*12+8],dword 'Ext2' |
mov [ext],2 |
mov [ext2],2 |
no_ext2: |
call draw_codes |
jmp still |
button: ; button |
or eax, -1 ; close this program |
int 0x40 |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax, 48 ; GET SYSTEM COLORS |
mov ebx, 3 |
mov ecx, sc |
mov edx, sizeof.system_colors |
int 0x40 |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax, 0 ; function 0 : define and draw window |
mov ebx, 100*65536+200 ; [x start] *65536 + [x size] |
mov ecx, 100*65536+275 ; [y start] *65536 + [y size] |
mov edx, [sc.work] ; color of work area RRGGBB,8->color gl |
or edx, 0x03000000 |
mov esi, [sc.grab] ; color of grab bar RRGGBB,8->color gl |
or esi, 0x80000000 |
mov edi, [sc.frame] ; color of frames RRGGBB |
int 0x40 |
; WINDOW LABEL |
mov eax, 4 ; function 4 : write text to window |
mov ebx, 8*65536+8 ; [x start] *65536 + [y start] |
mov ecx, [sc.grab_text] ; font 1 & color ( 0xF0RRGGBB ) |
or ecx, 0x10000000 |
mov edx, header ; pointer to text beginning |
mov esi, header.len ; text length |
int 0x40 |
mov eax, 4 |
mov ebx, 20*65536+35 |
mov ecx, 0 |
mov edx, text |
mov esi, text.len |
int 0x40 |
call draw_codes |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
draw_codes: |
mov eax,47 |
mov ebx,6*65536 |
mov edx,20*65536+60 |
mov edi,0 |
mov esi,0 |
newscan: |
pusha |
mov cx,dx |
shl ecx,16 |
add ecx,10 |
mov eax,13 ; filled rectangle |
mov ebx,20*65536+160 |
mov edx,[sc.work] |
int 0x40 |
popa |
pusha |
mov ebx,edx |
add ebx,70*65536 |
mov eax,4 ; text |
mov ecx,[sc.work_text] |
mov edx,key_codes |
imul edi,12 |
add edx,edi |
mov esi,12 |
int 0x40 |
popa |
movzx ecx,byte [scan_codes+edi] |
int 0x40 ; number |
inc ecx |
add edx,12 |
inc edi |
cmp edi,16 |
jne newscan |
ret |
; DATA AREA |
ext0: |
db 1,0,'Esc ' |
db 28,0,'Enter ' |
db 29,0,'L-Ctrl ' |
db 41,0,'1/2 ' |
db 42,0,'L-Shift ' |
db 54,0,'R-Shift ' |
db 55,0,'Num * ' |
db 56,0,'Alt ' |
db 58,0,'CapsLck ' |
db 59,0,'F1 ' |
db 60,0,'F2 ' |
db 61,0,'F3 ' |
db 62,0,'F4 ' |
db 63,0,'F5 ' |
db 64,0,'F6 ' |
db 65,0,'F7 ' |
db 66,0,'F8 ' |
db 67,0,'F9 ' |
db 68,0,'F10 ' |
db 69,0,'NumLock ' |
db 70,0,'SclLock ' |
db 71,0,'Num 7 ' |
db 72,0,'Num 8 ' |
db 73,0,'Num 9 ' |
db 74,0,'Num - ' |
db 75,0,'Num 4 ' |
db 76,0,'Num 5 ' |
db 77,0,'Num 6 ' |
db 78,0,'Num + ' |
db 79,0,'Num 1 ' |
db 80,0,'Num 2 ' |
db 81,0,'Num 3 ' |
db 82,0,'Num 0 ' |
db 83,0,'Num , ' |
db 87,0,'F11 ' |
db 88,0,'F12 ' |
db 28,1,'Num Ent ' |
db 29,1,'R-Ctrl ' |
db 53,1,'Num / ' |
db 55,1,'PrScr ' |
db 56,1,'Alt Gr ' |
db 71,1,'Home ' |
db 72,1,'Up-A ' |
db 73,1,'PgUp ' |
db 75,1,'Left-A ' |
db 77,1,'Right-A ' |
db 79,1,'End ' |
db 80,1,'Down-A ' |
db 81,1,'PgDown ' |
db 82,1,'Insert ' |
db 83,1,'Delete ' |
db 91,1,'Menu-1 ' |
db 92,1,'Menu-2 ' |
db 93,1,'Menu-3 ' |
db 29,2,'Break ' |
ext0end: |
if lang eq ru |
text: |
db ' ' |
.len = $ - text |
header: |
db ' ' |
.len = $ - header |
else |
text: |
db 'READING RAW SCANCODE DATA' |
.len = $ - text |
header: |
db 'KEYBOARD SCANCODES' |
.len = $ - header |
end if |
ext db 0x0 |
ext2 db 0x0 |
pos dd 0x0 |
I_END: |
sc system_colors |
scan_codes: times 16 db ? |
key_codes: times 16 dd ?,?,? |
keymap: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/tinypad/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm tinypad.asm tinypad |
@pause |
/programs/develop/tinypad/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm tinypad.asm tinypad |
@pause |
/programs/develop/tinypad/trunk/helpwnd.asm |
---|
0,0 → 1,57 |
help_thread_start: |
call draw_help_wnd |
still_hw: |
cmp [main_closed],1 |
je exit_hw |
mcall 10 |
cmp eax,1 |
je help_thread_start |
cmp eax,2 |
je key_hw |
cmp eax,3 |
je button_hw |
jmp still_hw |
key_hw: |
mcall ;2 |
cmp ah, 27 |
jne still_hw |
button_hw: |
mcall 17 |
exit_hw: |
mcall -1 |
func draw_help_wnd |
mcall 12,1 |
mcall 48,3,sc,sizeof.system_colors |
mov ecx,[skinh] |
add ecx,200*65536+(5+10*2+16*10) |
mov edx,[sc.work] |
or edx,0x03000000 |
mcall 0,<200,10+10*2+help_text.maxl*6> |
mov ebx,[skinh] |
shr ebx,1 |
adc ebx,1+0x000A0000-4 |
mcall 4,,[sc.grab_text],help_title,help_title.size |
mov eax,4 |
mov ebx,[skinh] |
add ebx,0x000F000A |
xor ecx,ecx |
mov edx,help_text |
@@: inc edx |
movzx esi,byte[edx-1] |
mcall |
add ebx,10 |
add edx,esi |
cmp byte[edx],0 |
jne @b |
mcall 12,2 |
ret |
endf |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/tinypad/trunk/macros.inc |
---|
0,0 → 1,387 |
; language for programs |
@^ fix macro comment { |
^@ fix } |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
name: |
db data |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
forward |
if lang eq lng |
db data |
end if |
common |
.size = $-name |
end if |
} |
macro szc name,elsz,[data] { ; from MFAR [mike.dld] |
common |
local s,m |
m = 0 |
if used name |
label name |
virtual at 0 |
db data |
s = $ |
end virtual |
d#elsz s |
if m < s |
m = s |
end if |
db data |
.size = $-name |
.maxl = m |
end if |
} |
macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld] |
common |
local s,m |
m = 0 |
if used name |
label name |
forward |
if lang eq lng |
virtual at 0 |
db data |
s = $ |
end virtual |
d#elsz s |
if m < s |
m = s |
end if |
db data |
end if |
common |
.size = $-name |
.maxl = m |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
;macro __mov reg,a { ; mike.dld |
; if ~a eq |
; mov reg,a |
; end if |
;} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; ------------------------- |
macro header a,[b] { |
common |
use32 |
org 0 |
db 'MENUET',a |
forward |
if b eq |
dd 0 |
else |
dd b |
end if } |
macro section name { align 16 |
label name } |
macro func name { |
if ~used name |
display 'FUNC NOT USED: ',`name,13,10 |
else |
align 4 |
name: |
;pushad |
;pushfd |
;dps `name |
;newline |
;mcall 5,1 |
;popfd |
;popad |
} |
macro endf { end if } |
macro diff16 title,l1,l2 |
{ |
local s,d |
s = l2-l1 |
display title,': 0x' |
repeat 8 |
d = '0' + s shr ((8-%) shl 2) and $0F |
if d > '9' |
d = d + 'A'-'9'-1 |
end if |
display d |
end repeat |
display 13,10 |
} |
macro diff10 title,l1,l2 |
{ |
local s,d,z,m |
s = l2-l1 |
z = 0 |
m = 1000000000 |
display title,': ' |
repeat 10 |
d = '0' + s / m |
s = s - (s/m)*m |
m = m / 10 |
if d <> '0' |
z = 1 |
end if |
if z <> 0 |
display d |
end if |
end repeat |
display 13,10 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
struc POINT _t,_dx,_dy { |
.x _t _dx |
.y _t _dy |
} |
; structure definition helper |
;include 'struct.inc' |
macro union [def] |
{ |
common size@union = 0 |
origin@union = $ |
forward virtual |
def |
if $-origin@union > size@union |
size@union = $-origin@union |
end if |
end virtual |
common rb size@union |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
sizeof.process_information=1024 |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
sizeof.system_colors=40 |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/tinypad/trunk/struct.inc |
---|
0,0 → 1,184 |
; Macroinstructions for defining data structures |
macro struct name |
{ fields@struct equ name |
match child parent, name \{ fields@struct equ child,fields@\#parent \} |
sub@struct equ |
struc db [val] \{ \common fields@struct equ fields@struct,.,db,<val> \} |
struc dw [val] \{ \common fields@struct equ fields@struct,.,dw,<val> \} |
struc du [val] \{ \common fields@struct equ fields@struct,.,du,<val> \} |
struc dd [val] \{ \common fields@struct equ fields@struct,.,dd,<val> \} |
struc dp [val] \{ \common fields@struct equ fields@struct,.,dp,<val> \} |
struc dq [val] \{ \common fields@struct equ fields@struct,.,dq,<val> \} |
struc dt [val] \{ \common fields@struct equ fields@struct,.,dt,<val> \} |
struc rb count \{ fields@struct equ fields@struct,.,db,count dup (?) \} |
struc rw count \{ fields@struct equ fields@struct,.,dw,count dup (?) \} |
struc rd count \{ fields@struct equ fields@struct,.,dd,count dup (?) \} |
struc rp count \{ fields@struct equ fields@struct,.,dp,count dup (?) \} |
struc rq count \{ fields@struct equ fields@struct,.,dq,count dup (?) \} |
struc rt count \{ fields@struct equ fields@struct,.,dt,count dup (?) \} |
macro db [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,db,<val> \} |
macro dw [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dw,<val> \} |
macro du [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,du,<val> \} |
macro dd [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dd,<val> \} |
macro dp [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dp,<val> \} |
macro dq [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dq,<val> \} |
macro dt [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dt,<val> \} |
macro rb count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,db,count dup (?) \} |
macro rw count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dw,count dup (?) \} |
macro rd count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dd,count dup (?) \} |
macro rp count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dp,count dup (?) \} |
macro rq count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dq,count dup (?) \} |
macro rt count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dt,count dup (?) \} |
macro union \{ fields@struct equ fields@struct,,union,< |
sub@struct equ union \} |
macro struct \{ fields@struct equ fields@struct,,substruct,< |
sub@struct equ substruct \} |
virtual at 0 } |
macro ends |
{ match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt |
restruc rb,rw,rd,rp,rq,rt |
purge db,dw,du,dd,dp,dq,dt |
purge rb,rw,rd,rp,rq,rt |
purge union,struct |
match name=,fields,fields@struct \\{ fields@struct equ |
make@struct name,fields |
fields@\\#name equ fields \\} |
end virtual \} |
match any, sub@struct \{ fields@struct equ fields@struct> \} |
restore sub@struct } |
macro make@struct name,[field,type,def] |
{ common |
if $ |
display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah |
err |
end if |
local define |
define equ name |
forward |
local sub |
match , field \{ make@substruct type,name,sub def |
define equ define,.,sub, \} |
match any, field \{ define equ define,.#field,type,<def> \} |
common |
match fields, define \{ define@struct fields \} } |
macro define@struct name,[field,type,def] |
{ common |
local list |
list equ |
forward |
if ~ field eq . |
name#field type def |
sizeof.#name#field = $ - name#field |
else |
label name#.#type |
rb sizeof.#type |
end if |
local value |
match any, list \{ list equ list, \} |
list equ list <value> |
common |
sizeof.#name = $ |
restruc name |
match values, list \{ |
struc name value \\{ |
match any, fields@struct \\\{ fields@struct equ fields@struct,.,name,<values> \\\} |
match , fields@struct \\\{ label . |
forward |
match , value \\\\{ field type def \\\\} |
match any, value \\\\{ field type value |
if ~ field eq . |
rb sizeof.#name#field - ($-field) |
end if \\\\} |
common \\\} \\} \} } |
macro enable@substruct |
{ macro make@substruct substruct,parent,name,[field,type,def] |
\{ \common |
\local define |
define equ parent,name |
\forward |
\local sub |
match , field \\{ match any, type \\\{ enable@substruct |
make@substruct type,name,sub def |
purge make@substruct |
define equ define,.,sub, \\\} \\} |
match any, field \\{ define equ define,.\#field,type,<def> \\} |
\common |
match fields, define \\{ define@\#substruct fields \\} \} } |
enable@substruct |
macro define@union parent,name,[field,type,def] |
{ common |
virtual at parent#.#name |
forward |
if ~ field eq . |
virtual at parent#.#name |
parent#field type def |
sizeof.#parent#field = $ - parent#field |
end virtual |
if sizeof.#parent#field > $ - parent#.#name |
rb sizeof.#parent#field - ($ - parent#.#name) |
end if |
else |
label name#.#type at parent#.#name |
if sizeof.#type > $ - parent#.#name |
rb sizeof.#type - ($ - parent#.#name) |
end if |
end if |
common |
sizeof.#name = $ - parent#.#name |
end virtual |
struc name [value] \{ \common |
label .\#name |
last@union equ |
forward |
match any, last@union \\{ virtual at .\#name |
field type def |
end virtual \\} |
match , last@union \\{ match , value \\\{ field type def \\\} |
match any, value \\\{ field type value \\\} \\} |
last@union equ field |
common rb sizeof.#name - ($ - .\#name) \} } |
macro define@substruct parent,name,[field,type,def] |
{ common |
virtual at parent#.#name |
forward |
if ~ field eq . |
parent#field type def |
sizeof.#parent#field = $ - parent#field |
else |
label name#.#type |
rb sizeof.#type |
end if |
common |
sizeof.#name = $ - parent#.#name |
end virtual |
struc name value \{ |
label .\#name |
forward |
match , value \\{ field type def \\} |
match any, value \\{ field type value |
if ~ field eq . |
rb sizeof.#parent#field - ($-field) |
end if \\} |
common \} } |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/tinypad/trunk/tinypad.asm |
---|
0,0 → 1,2946 |
;****************************************************************************** |
; project name: TINYPAD |
; compiler: flat assembler 1.60 |
; memory to compile: 2 Mbytes + |
; version: 3.78a |
; last update: 13/05/2005 |
; maintained by: Ivan Poddubny, Mike Semenyako (aka mike.dld) |
; e-mail: ivan-yar@bk.ru, mike.dld@tut.by |
;****************************************************************************** |
; HISTORY: |
; 3.79 (just some ideas for further releases) |
; optimize drawing (reduce flickering) |
; optimize memory usage (allocate only needed amount, not static 3 Mbytes) |
; improve keyboard handling (use 66th function) |
; introduce real selection capabilities (including block selection) |
; and of course other small speed and size optimizations ;) |
; 3.78a (mike.dld) |
; fixed termination while typing in x positions higher than (line_length+10) |
; improved drawing on small heights |
; don't draw window while its height equals 0 |
; 3.78 (mike.dld) |
; now lines may be of ANY length; |
; optimized memory usage (less memory for internal file representation) |
; after loading file, it's internal size equals to its real size |
; plus 14 bytes for each line (4 bytes for line length |
; and 10 spaced to the end - to reduce data relocations) |
; completely rewritten keyboard handling; |
; added horizontal scrollbar; |
; all line feed formats are supported: WIN(CRLF),*NIX(LF),MAC(CR); |
; etc. |
; 3.77 (mike.dld) |
; changed save_string to collapse SPACEs into TABs; |
; rewrote drawfile from scratch (speed++) |
; through some drawing improvements still needed |
; (some checkups to reduce flickering); |
; writepos (size--); |
; fixed drawing window while height < 100px, and for non-asm files; |
; several small fixes; speed/size optimizations |
; 3.76 (mike.dld) |
; changed loadfile/loadhdfile to expand TABs into SPACEs; |
; changed TAB,ENTER,DELETE,BSPACE keys behaviour (rewritten from scratch); |
; vertical scrollbar; |
; extra window resizing capabilities (added a couple of constants); |
; completely new text cursor management & moving text cursor with mouse; |
; improved search function, moving cursor to beginning of text found; |
; adjustable max line width (change LINE_WIDTH & recompile) // (obsolete) |
; 3.75a |
; fixed converting char to upper case in read_string |
; 3.75 |
; rewrote save_file from scratch; bugfix in loadfile; |
; 3.74 |
; optimisation |
; 3.73 |
; completly new load_file function |
; 3.72 |
; speed++ |
; 3.71 |
; error beep |
; 3.6,3.7: |
; many bugs fixed |
; simple toolbar |
; compile, run applications from TINYPAD, all fasm output is in debug board |
; TAB button |
; auto-indent |
; Ctrl+L - insert comment string |
;****************************************************************************** |
; Memory 0x300000: |
; stack 0x00eff0 - áâíª |
; stack for help 0x00fff0 - |
; load position 0x010000 + ¤à¥á § £à㧪¨ ä ©« |
; screen comp 0x078000 + ᮤ¥à¦¨¬®¥ íªà (obsolete) |
; edit area 0x080000 + ¤®ªã¬¥â |
; copy/paste area 0x2f0000 + ®¡« áâì ¤«ï ª®¯¨à®¢ ¨ï/¢áâ ¢ª¨ |
;****************************************************************************** |
include 'lang.inc' |
include 'macros.inc' ; useful stuff |
purge mov ; SPEED |
macro mov op1,op2 { |
if (op1 in __regs) & (op2 eq -1) |
or op1,-1 |
else |
mov op1,op2 |
end if |
} |
header '01',1,@CODE,TINYPAD_END,0x300000,0xeff0,@PARAMS,0 |
ASEPC = '-' |
RBTNW = rstr.size*6/3 |
LBTNW = lstr.size*6/2 |
ABTNH = 16 |
ATOPH = 24 |
OLEFT = 5+1 |
SCRLW = 16 |
ATABW = 8 |
PATHL = 260 |
AMINS = 8 |
;----------------------------------------------------------------------------- |
section @CODE ;/////////////////////////////////////////////////////////////// |
;----------------------------------------------------------------------------- |
;****************************************************************************** |
; INITIALIZING |
cld |
mov esi,s_example |
mov edi,s_fname |
mov ecx,s_example.size |
mov [s_fname.size],ecx |
rep movsb |
mov esi,s_still |
mov edi,s_search |
mov ecx,s_still.size |
mov [s_search.size],ecx |
rep movsb |
cmp byte[@PARAMS],0 |
jz no_params |
; parameters are at @PARAMS |
mov esi,@PARAMS |
mov edi,s_fname |
mov ecx,PATHL |
rep movsb |
mov edi,s_fname |
mov ecx,PATHL |
xor al,al |
repne scasb |
sub edi,s_fname+1 |
mov [s_fname.size],edi |
no_params: |
mcall 40,00100111b |
jmp do_load_file |
;****************************************************************************** |
; MAIN LOOP |
still: |
call writepos ; write current position & number of strings |
.skip_write: |
mcall 10;23,50; wait here until event |
dec eax ; redraw ? |
jz red |
dec eax ; key ? |
jz key |
dec eax ; button ? |
jz button |
sub eax,3 ; mouse ? |
jz mouse |
;d |
jmp still.skip_write |
;****************************************************************************** |
mouse: |
mcall 9,p_info,-1 |
cmp ax,[p_info.window_stack_position] |
jne still |
mcall 37,2 |
test al,1 |
jz .capture_off |
mcall 37,1 |
mov ebx,eax |
and ebx,0x0000FFFF |
shr eax,16 |
mov ecx,[top_ofs] |
inc ecx |
pushd OLEFT ecx [p_info.x_size] ecx |
popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0] |
sub [__rc+0x8],SCRLW+5+3 |
imul ecx,[slines],10 |
dec ecx |
add [__rc+0xC],ecx |
mov ecx,__rc |
call pt_in_rect |
jnc .check_vscroll |
sub eax,OLEFT |
sub ebx,[__rc+0x4] |
push eax |
mov eax,ebx |
xor edx,edx |
mov ecx,10 |
div ecx |
@@: add eax,[top_line] |
mov ebx,eax |
pop eax |
xor edx,edx |
mov ecx,6 |
div ecx |
@@: add eax,[left_col] |
cmp eax,[columns] |
jb @f |
mov eax,[columns] |
@@: cmp ebx,[lines] |
jb @f |
mov ebx,[lines] |
dec ebx |
@@: |
cmp [posx],eax |
jne .change_cur_pos |
cmp [posy],ebx |
je still.skip_write |
.change_cur_pos: |
mov [posx],eax |
mov eax,[posy] |
pushd ebx |
popd [posy] |
cmp eax,ebx |
je @f |
push ebx |
mov ebx,eax |
call drawfile.ex |
pop eax |
@@: mov ebx,eax |
call drawfile.ex |
jmp still |
.check_vscroll: |
mov ecx,[p_info.x_size] |
sub ecx,SCRLW+5-2 |
pushd ecx [top_ofs] ecx [bot_ofs] |
popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0] |
add [__rc+0x8],SCRLW-2 |
add [__rc+0x4],SCRLW+1 |
sub [__rc+0xC],SCRLW*2+3 |
mov ecx,__rc |
call pt_in_rect |
jnc .check_hscroll |
sub ebx,[__rc+0x4] |
cmp [vscrl_capt],0 |
jge .vcaptured |
mov eax,[vscrl_top] |
cmp ebx,eax |
jb .center_vcapture |
add eax,[vscrl_size] |
cmp ebx,eax |
jae .center_vcapture |
mov eax,ebx |
sub eax,[vscrl_top] |
dec eax |
mov [vscrl_capt],eax |
dec ebx |
jmp .vcaptured |
.center_vcapture: |
mov eax,[vscrl_size] |
shr eax,1 |
mov [vscrl_capt],eax |
.vcaptured: |
sub ebx,[vscrl_capt] |
jns @f |
xor ebx,ebx |
@@: |
mov [vscrl_top],ebx |
mov eax,[lines] |
sub eax,[slines] |
mul ebx |
mov ebx,[bot_ofs] |
sub ebx,[top_ofs] |
sub ebx,SCRLW*3+2+2 ;** |
sub ebx,[vscrl_size] |
div ebx |
cmp eax,[top_line] |
je still.skip_write |
mov [top_line],eax |
call check_bottom_right |
call drawfile |
jmp still.skip_write |
.check_hscroll: |
pushd (OLEFT+SCRLW+1) [bot_ofs] [p_info.x_size] [bot_ofs] |
popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0] |
add [__rc+0x8],-SCRLW*2-10-1 |
add [__rc+0x4],-SCRLW |
add [__rc+0xC],-2 |
mov ecx,__rc |
call pt_in_rect |
jnc .capture_off |
mov ebx,eax |
sub ebx,[__rc+0x0] |
cmp [hscrl_capt],0 |
jge .hcaptured |
mov eax,[hscrl_top] |
cmp ebx,eax |
jb .center_hcapture |
add eax,[hscrl_size] |
cmp ebx,eax |
jae .center_hcapture |
mov eax,ebx |
sub eax,[hscrl_top] |
dec eax |
mov [hscrl_capt],eax |
dec ebx |
jmp .hcaptured |
.center_hcapture: |
mov eax,[hscrl_size] |
shr eax,1 |
mov [hscrl_capt],eax |
.hcaptured: |
sub ebx,[hscrl_capt] |
jns @f |
xor ebx,ebx |
@@: |
mov [hscrl_top],ebx |
mov eax,[columns] |
sub eax,[scolumns] |
mul ebx |
mov ebx,[p_info.x_size] |
sub ebx,SCRLW*3+10+2 ;** |
sub ebx,[hscrl_size] |
div ebx |
cmp eax,[left_col] |
je still.skip_write |
mov [left_col],eax |
call check_bottom_right |
call drawfile |
jmp still.skip_write |
.capture_off: |
or [vscrl_capt],-1 |
or [hscrl_capt],-1 |
jmp still.skip_write |
func pt_in_rect |
cmp eax,[ecx+0x0] |
jl @f |
cmp ebx,[ecx+0x4] |
jl @f |
cmp eax,[ecx+0x8] |
jg @f |
cmp ebx,[ecx+0xC] |
jg @f |
stc |
ret |
@@: clc |
ret |
endf |
func check_bottom_right |
push eax |
mov eax,[top_line] |
add eax,[slines] |
cmp eax,[lines] |
jbe .lp1 |
mov eax,[lines] |
sub eax,[slines] |
jns @f |
xor eax,eax |
@@: mov [top_line],eax |
.lp1: mov eax,[left_col] |
add eax,[scolumns] |
cmp eax,[columns] |
jbe .exit |
mov eax,[columns] |
sub eax,[scolumns] |
jns @f |
xor eax,eax |
@@: mov [left_col],eax |
.exit: |
pop eax |
ret |
endf |
; ********************************* |
; * BUTTON HANDLER * |
; ********************************* |
button: |
mcall 17 |
shr eax,8 |
cmp eax,'UP' |
jne not_up |
dec [top_line] |
jns check_inv_all.skip_check |
mov [top_line],0 |
jmp still.skip_write |
not_up: |
cmp eax,'DN' |
jne not_down |
inc [top_line] |
mov eax,[lines] |
sub eax,[slines] |
cmp eax,[top_line] |
jae check_inv_all.skip_check |
dec eax |
mov [top_line],eax |
jmp still.skip_write |
not_down: |
cmp eax,'LT' |
jne not_left |
dec [left_col] |
jns check_inv_all.skip_check |
mov [left_col],0 |
jmp still.skip_write |
not_left: |
cmp eax,'RT' |
jne not_right |
inc [left_col] |
mov eax,[columns] |
sub eax,[scolumns] |
cmp eax,[left_col] |
jae check_inv_all.skip_check |
dec eax |
mov [left_col],eax |
jmp still.skip_write |
not_right: |
; SEARCH { |
search: |
cmp al,50 |
jne no_search |
.skip_check: |
cld |
mov ecx,[posy] |
mov edx,ecx |
call get_line_offset |
cmp dword[esi],0 |
je still |
call get_real_length |
add esi,4 |
or eax,eax |
jz .end_line.2 |
mov ecx,eax |
sub ecx,[posx] |
push esi |
add esi,[posx] |
dec ecx |
inc esi |
jmp @f |
.next_line: |
push esi |
@@: |
sub ecx,[s_search.size] |
inc ecx |
.next_char: |
dec ecx |
js .end_line |
xor edi,edi |
.next_ok: |
movzx eax,byte[edi+esi] |
movzx ebx,byte[edi+s_search] |
cmp al,$61 |
jb @f |
add al,[eax+add_table-$61] |
@@: cmp bl,$61 |
jb @f |
add bl,[ebx+add_table-$61] |
@@: |
cmp al,bl |
je @f |
inc esi |
jmp .next_char |
@@: |
inc edi |
cmp edi,[s_search.size] |
jne .next_ok |
.found: |
add esp,4 |
mov [posy],edx |
mov ecx,edx |
lea eax,[esi-4] |
call get_line_offset |
sub eax,esi |
mov [posx],eax |
jmp check_inv_all |
.end_line: |
pop esi |
.end_line.2: |
add esi,[esi-4] |
inc edx |
call get_real_length |
mov ecx,eax |
lodsd |
or eax,eax |
jnz .next_line |
jmp still |
; SEARCH } |
no_search: |
; TOOLBAR { |
cmp eax,10000 |
jb no_toolbar |
add eax,-10000 |
jnz @f |
mov bl,0;[run_outfile],0 |
call start_fasm |
jmp still |
@@: dec eax |
jnz @f |
mov bl,1;[run_outfile],1 |
call start_fasm |
jmp still |
@@: dec eax |
jnz @f |
call open_debug_board |
jmp still |
@@: dec eax |
jnz still |
call open_sysfuncs_txt |
jmp still |
; TOOLBAR } |
no_toolbar: |
cmp al,4 |
jne noid4 |
; LOAD_FILE { |
do_load_file: |
cmp [s_fname],'/' |
jne @f |
call loadhdfile |
jmp .restorecursor |
@@: call loadfile |
.restorecursor: |
xor eax,eax |
mov [top_line],eax |
mov [posx],eax |
mov [posy],eax |
; enable color syntax for ASM and INC files: |
mov [asm_mode],al |
mov eax,[s_fname.size] |
add eax,s_fname |
mov byte[eax],0 |
cmp dword[eax-3],'ASM' |
jne @f |
inc [asm_mode] |
jmp .nocol |
@@: cmp dword[eax-3],'INC' |
jne .nocol |
inc [asm_mode] |
.nocol: |
; if the header is the same as previous, |
; just redraw the text area |
; else redraw the window |
mov ecx, [s_fname.size] |
add ecx, 10 ; strlen(" - TINYPAD"); |
cmp ecx, [s_title.size] |
jne @f |
add ecx, -10 |
mov esi, s_fname ; strcmp(s_fname,header); |
mov edi, s_title |
rep cmpsb |
jne @f |
call drawfile |
jmp still |
@@: |
; set window title: |
mov esi,s_fname |
mov edi,s_title |
mov ecx,[s_fname.size] |
lea eax,[ecx+10] |
mov [s_title.size],eax |
cld |
rep movsb |
mov dword[edi],' - ' |
add edi,3 |
mov esi,htext |
mov ecx,htext.size |
rep movsb |
call drawwindow |
jmp still |
; LOAD_FILE } |
noid4: |
cmp al, 2 |
jz yessave |
dec al ; close if butid == 1 |
jnz nosave |
; EXIT: |
mov [main_closed],1 |
mcall -1 |
; SAVE_FILE { |
yessave: |
call save_file |
jmp still |
; SAVE_FILE } |
nosave: |
inc al |
call read_string |
jmp still |
;********************************** |
;* REDRAW HANDLER * |
;********************************** |
func red |
; ¯¥à¥à¨á®¢ª ®ª |
call drawwindow |
jmp check_inv_all.skip_check |
endf |
;********************************** |
;* KEY HANDLER * |
;********************************** |
key: |
mcall 2 ; GET KEY |
cmp al,1 |
je still |
shr eax,8 |
; HELP_WND { |
cmp al,0xD2;210 ; Ctrl + F1 |
jne no_help_text |
mcall 51,1,help_thread_start,0xfff0 |
jmp still |
; HELP_WND } |
no_help_text: |
; LOAD_FILE { |
cmp al,211 ; Ctrl + F2 |
je do_load_file |
; LOAD_FILE } |
; SEARCH { |
cmp al,212 ; Ctrl + F3 |
je search.skip_check |
; SEARCH } |
; SAVE_FILE { |
cmp al,213 ; Ctrl + F4 |
je yessave |
; SAVE_FILE } |
; ENTER_FILENAME { |
cmp al,214 ; Ctrl + F5 |
jne @f |
mov al,5 |
call read_string |
jmp still |
@@: |
; ENTER_FILENAME } |
; ENTER_SEARCH { |
cmp al,215 ; Ctrl + F6 |
jne @f |
mov al,51 |
call read_string |
jmp still |
@@: |
; ENTER_SEARCH } |
; CHANGE_LANG_LAYOUT { |
cmp al,217 ; Ctrl + F8 |
jne @f |
call layout |
jmp still |
@@: |
; CHANGE_LANG_LAYOUT } |
; 3 times english -> àãá᪨© |
; 2 times àãá᪨© -> english |
; COPY START { |
cmp al,19 |
jne no_copy_start |
push [posy] |
pop [copy_start] |
jmp still |
; COPY START } |
no_copy_start: |
; COPY END { |
cmp al,5 |
jne no_copy_end |
mov eax,[posy] |
cmp eax,[copy_start] |
jae @f |
xchg eax,[copy_start] |
@@: sub eax,[copy_start] |
inc eax |
mov [copy_count],eax |
mov ecx,[copy_start] |
call get_line_offset |
push esi |
mov ecx,eax |
@@: lodsd |
add esi,eax |
loop @b |
mov ecx,esi |
pop esi |
sub ecx,esi |
mov [copy_size],ecx |
mov edi,0x2f0000 |
cld |
rep movsb |
jmp still |
; COPY END } |
no_copy_end: |
; PASTE { |
cmp al,16 |
jne no_copy_paste |
mov ebx,[copy_count] |
or ebx,ebx |
jz still |
add [lines],ebx |
mov ecx,[posy] |
call get_line_offset |
mov ebx,esi |
mov edi,0x2E0000 |
mov esi,edi |
mov ecx,[copy_size] |
sub esi,ecx |
lea ecx,[esi+4] |
sub ecx,ebx |
std |
rep movsb |
mov edi,ebx |
mov esi,0x2F0000 |
mov ecx,[copy_size] |
cld |
rep movsb |
jmp check_inv_all |
; PASTE } |
no_copy_paste: |
; INSERT_SEPARATOR { |
cmp al,0x0C ; Ctrl+L |
jne no_insert_separator |
mov ecx,[posy] |
call get_line_offset |
mov ebx,esi |
mov ecx,[lines] |
call get_line_offset |
lea edi,[esi+90+4] |
lea ecx,[esi+4] |
sub ecx,ebx |
std |
rep movsb |
lea edi,[ebx+5] |
mov dword[ebx],90 |
mov al,ASEPC |
mov ecx,79 |
cld |
rep stosb |
mov al,' ' |
mov ecx,10 |
rep stosb |
mov byte[ebx+4],';' |
inc [lines] |
inc [posy] |
jmp check_inv_all |
; INSERT_SEPARATOR } |
no_insert_separator: |
; DEL_LINE { |
cmp al,4 |
jne no_delete_line |
mov eax,[posy] |
inc eax |
cmp eax,[lines] |
jge still |
mov ecx,[posy] |
call get_line_offset |
mov edi,esi |
lodsd |
add esi,eax |
dec [lines] |
mov ecx,0x2e0000 |
sub ecx,esi |
shr ecx,2 ;// fixed (was 4) |
cld |
rep movsd |
jmp check_inv_all |
; DEL_LINE } |
no_delete_line: |
; ENTER { |
cmp al,13 |
jnz noenter |
mov ecx,[posy] |
call get_line_offset |
mov ebx,[posx] |
cmp ebx,[esi] |
jb @f |
mov ebx,[esi] |
dec ebx |
jns @f |
xor ebx,ebx |
@@: |
cld |
mov edi,0x10000 |
mov ebp,esi |
mov ecx,ebx |
inc ecx |
@@: dec ecx |
jz @f |
cmp byte[esi+ecx+4-1],' ' |
je @b |
@@: lea eax,[ecx+10] |
stosd |
jecxz @f |
push esi |
add esi,4 |
rep movsb |
pop esi |
@@: mov al,' ' |
mov ecx,10 |
rep stosb |
mov ecx,[esi] |
sub ecx,ebx;[posx] |
add esi,ebx;[posx] |
add esi,4 |
inc ecx |
@@: dec ecx |
jz @f |
cmp byte[esi+ecx-1],' ' |
je @b |
@@: jz .lp1 |
@@: cmp byte[esi],' ' |
jne .lp1 |
inc esi |
loop @b |
.lp1: push edi ecx |
mov ecx,[ebp] |
lea edi,[ebp+4] |
mov al,' ' |
repe scasb |
mov eax,ecx |
pop ecx edi |
je .lp2 |
neg eax |
add eax,[ebp] |
dec eax |
jmp @f |
.lp2: xor eax,eax |
@@: mov edx,edi |
add edi,4 |
mov [posx],eax |
jecxz @f |
push ecx |
mov ecx,eax |
mov al,' ' |
rep stosb |
pop ecx |
@@: jecxz @f |
rep movsb |
@@: mov ecx,10 |
mov al,' ' |
rep stosb |
lea eax,[edi-4] |
sub eax,edx |
mov [edx],eax |
lea ecx,[edi-0x10000] |
push ecx |
mov edi,0x2E0000 |
lea esi,[edi+4] |
sub esi,ecx |
add esi,[ebp] |
lea ecx,[esi-4] |
sub ecx,ebp |
std |
cmp esi,edi |
jb @f |
je .lp3 |
lea esi,[ebp+4] |
mov eax,[esp] |
lea edi,[esi+eax-4] |
add esi,[ebp] |
mov ecx,0x2E0000 |
sub ecx,esi |
cld |
@@: rep movsb |
.lp3: pop ecx |
mov esi,0x10000 |
mov edi,ebp |
cld |
rep movsb |
inc [posy] |
inc [lines] |
jmp check_inv_all |
; ENTER } |
noenter: |
; UP { |
cmp al,130+48 |
jnz noup |
mov eax,[posy] |
dec eax |
jns @f |
xor eax,eax |
@@: mov ecx,[top_line] |
cmp eax,ecx |
jae @f |
dec ecx |
jns @f |
xor ecx,ecx |
@@: jmp check_inv_all.skip_init |
; UP } |
noup: |
; DOWN { |
cmp al,129+48 |
jnz nodown |
mov eax,[posy] |
inc eax |
cmp eax,[lines] |
jb @f |
dec eax |
@@: mov ecx,[top_line] |
mov edx,eax |
sub edx,ecx |
cmp edx,[slines] |
jb @f |
inc ecx |
@@: jmp check_inv_all.skip_init |
; DOWN } |
nodown: |
; LEFT { |
cmp al,128+48 |
jnz noleft |
mov eax,[posx] |
dec eax |
jns @f |
inc eax |
@@: mov [posx],eax |
jmp check_inv_all |
; LEFT } |
noleft: |
; RIGHT { |
cmp al,131+48 |
jnz noright |
mov eax,[posx] |
inc eax |
cmp eax,[columns] |
jbe @f |
dec eax |
@@: mov [posx],eax |
jmp check_inv_all |
; RIGHT } |
noright: |
; PAGE_UP { |
page_up: |
cmp al,136+48 |
jnz nopu |
mov edx,[slines] |
dec edx |
mov eax,[posy] |
mov ecx,[top_line] |
sub eax,edx |
jns @f |
xor eax,eax |
@@: sub ecx,edx |
jns @f |
xor ecx,ecx |
@@: jmp check_inv_all.skip_init |
; PAGE_UP } |
nopu: |
; PAGE_DOWN { |
page_down: |
cmp al,135+48 |
jnz nopd |
mov edx,[slines] |
dec edx |
mov eax,[posy] |
mov ecx,[top_line] |
add eax,edx |
add ecx,edx |
cmp eax,[lines] |
jb @f |
mov eax,[lines] |
dec eax |
@@: jmp check_inv_all.skip_init |
; PAGE_DOWN } |
nopd: |
; HOME { |
cmp al,132+48 |
jnz nohome |
mov [posx],0 |
jmp check_inv_all |
; HOME } |
nohome: |
; END { |
end_key: |
cmp al,133+48 |
jnz noend |
mov ecx,[posy] |
call get_line_offset |
call get_real_length |
mov [posx],eax |
jmp check_inv_all |
; END } |
noend: |
; GO_START { |
cmp al,251 ; Ctrl + [ |
jnz no_go_to_start |
xor eax,eax |
mov [top_line],eax |
mov [posy],eax |
jmp check_inv_all.skip_check |
; GO_START } |
no_go_to_start: |
; GO_END { |
cmp al,253 ; Ctrl + ] |
jnz no_go_to_end |
mov eax,[lines] ; eax = lines in the file |
mov [posy],eax |
sub eax,[slines] ; eax -= lines on the screen |
jns @f |
xor eax,eax |
@@: mov [top_line],eax |
dec [posy] |
jmp check_inv_all.skip_check |
; GO_END } |
no_go_to_end: |
; DELETE { |
__key_delete: |
cmp al,134+48 |
jne nodel |
mov ecx,[posy] |
call get_line_offset |
lea ebx,[esi+4] |
mov ebp,esi |
call get_real_length |
or eax,eax |
je .line_up |
mov ecx,[posx] |
cmp ecx,eax |
jae .line_up |
lea edi,[ebx+ecx] |
neg ecx |
add ecx,[ebp] |
repe scasb |
je .line_up |
mov edi,ebx |
mov ecx,[posx] |
add edi,ecx |
lea esi,[edi+1] |
neg ecx |
add ecx,[ebp] |
dec ecx |
rep movsb |
mov byte[edi],' ' |
jmp check_inv_all |
.line_up: |
mov eax,[lines] |
dec eax |
cmp eax,[posy] |
je still;.ok |
mov edi,0x10004 |
mov esi,ebx |
mov ecx,[posx] |
rep movsb |
mov ecx,[posx] |
mov [0x10000],ecx |
cmp ecx,[ebp] |
jbe @f |
sub ecx,[ebp] |
sub edi,ecx |
mov al,' ' |
rep stosb |
@@: lea esi,[ebx+4] |
add esi,[ebp] |
mov ecx,[esi-4] |
add [0x10000],ecx |
rep movsb |
lea ecx,[edi-0x10000] |
mov esi,0x10000 |
call get_real_length |
cmp eax,[columns] |
jbe @f |
mov [columns],eax |
@@: |
push ecx |
mov edi,0x2E0000 |
lea esi,[edi+8] |
sub esi,ecx |
add esi,[ebp] |
lea eax,[ebp+4] |
add eax,[ebp] |
add esi,[eax] |
lea ecx,[esi-4] |
sub ecx,ebp |
std |
cmp esi,edi |
jb @f |
jz .lp1 |
mov edi,ebp |
add edi,[esp] |
lea esi,[ebp+8] |
add esi,[esi-8] |
add esi,[esi-4] |
mov ecx,0x2E0000 |
sub ecx,esi |
cld |
@@: rep movsb |
.lp1: pop ecx |
mov esi,0x10000 |
mov edi,ebp |
cld |
rep movsb |
.ok.dec.lines: |
dec [lines] |
mov eax,[lines] |
cmp [posy],eax |
jb check_inv_all |
dec eax |
mov [posy],eax |
jmp check_inv_all |
; DELETE } |
nodel: |
; INSERT { |
cmp al,137+48 |
jnz noins |
;// ... toggle insert/overwrite mode here ... |
jmp still;check_inv_str |
; INSERT } |
noins: |
; BACKSPACE { |
cmp al,8 |
jnz nobs |
mov eax,[posx] |
dec eax |
js .line_up |
dec [posx] |
mov ecx,[posy] |
call get_line_offset |
mov ebx,eax |
call get_real_length |
cmp eax,[posx] |
jb check_inv_all |
lea edi,[esi+4+ebx] |
mov ecx,ebx |
neg ecx |
add ecx,[esi] |
dec ecx |
lea esi,[edi+1] |
cld |
rep movsb |
mov byte[edi],' ' |
jmp check_inv_str |
.line_up: |
cmp [posy],0 |
je still |
mov ecx,[posy] |
dec ecx |
call get_line_offset |
mov ebp,esi |
lea ebx,[esi+4] |
mov ecx,[ebp] |
@@: cmp byte[ebx+ecx-1],' ' |
jne @f |
dec ecx |
jg @b |
@@: mov [posx],ecx |
dec [posy] |
cld |
jmp __key_delete.line_up |
; BACKSPACE } |
nobs: |
; TAB { |
__key_tab: |
cmp eax,9 ; Tab |
jne notab |
mov eax,[posx] |
mov ecx,eax |
add eax,ATABW |
and eax,not(ATABW-1) |
push eax ' ' |
sub eax,ecx |
.direct: |
mov ecx,[posy] |
call get_line_offset |
xchg eax,ecx |
call get_real_length |
cmp eax,[posx] |
jae @f |
mov eax,[posx] |
@@: mov edx,[esi] |
sub edx,eax |
cmp ecx,edx |
jl @f |
pushad; esi ecx eax |
mov ecx,0x2E0000-10+1 |
lea eax,[esi+4] |
add eax,[esi] |
sub ecx,eax |
mov edi,0x2E0000 |
mov esi,0x2E0000-10 |
std |
rep movsb |
mov ecx,10 |
mov al,' ' |
rep stosb |
popad; eax ecx esi |
add dword[esi],10 |
jmp @b |
@@: lea ebx,[esi+4] |
push ecx |
lea edi,[ebx-1] |
add edi,[esi] |
mov esi,edi |
sub esi,ecx |
lea ecx,[esi+1] |
sub ecx,ebx |
sub ecx,[posx] |
std |
rep movsb |
.ok: pop ecx |
pop eax |
rep stosb |
cld |
pop [posx] |
lea esi,[ebx-4] |
call get_real_length |
cmp eax,[posx] |
jae @f |
mov eax,[posx] |
@@: cmp eax,[columns] |
jbe @f |
mov [columns],eax |
@@: |
jmp check_inv_all |
; TAB } |
notab: |
; ADD_KEY { |
push [posx] eax |
inc dword[esp+4] |
mov eax,1 |
jmp __key_tab.direct |
; ADD_KEY } |
check_inv_str = check_inv_all |
@^ |
func check_inv_str |
mov eax,[posy] |
mov ecx,[top_line] |
.skip_init: |
call check_cur_vis |
mov [posy],eax |
mov [top_line],ecx |
.skip_check: |
; call invalidate_string |
call drawfile |
jmp still |
endf |
^@ |
func check_inv_all |
mov eax,[posy] |
mov ecx,[top_line] |
.skip_init: |
call check_cur_vis |
mov [posy],eax |
mov [top_line],ecx |
.skip_check: |
; call clear_screen |
call drawfile |
jmp still |
endf |
func check_cur_vis |
cmp eax,ecx |
jb .low |
mov edx,ecx |
add edx,[slines] |
cmp edx,[lines] |
jbe @f |
mov edx,[lines] |
@@: cmp eax,edx |
jb @f |
lea ecx,[eax+1] |
sub ecx,[slines] |
jns @f |
xor ecx,ecx |
jmp @f |
.low: mov ecx,eax |
@@: |
mov edx,ecx |
add edx,[slines] |
cmp edx,[lines] |
jbe @f |
mov ecx,[lines] |
sub ecx,[slines] |
jns @f |
xor ecx,ecx |
@@:;mov [top_line],eax |
pushad |
mov eax,[posx] |
mov ebx,[left_col] |
mov ecx,ebx |
add ecx,[scolumns] |
cmp eax,ebx |
jb .lp1 |
cmp eax,ecx |
jb .exit.2 |
lea ebx,[eax] |
sub ebx,[scolumns] |
jmp @f |
.lp1: mov ebx,eax |
@@: mov [left_col],ebx |
.exit.2: |
mov [posx],eax |
popad |
ret |
endf |
func get_real_length |
mov eax,[esi] |
@@: cmp byte[esi+eax+4-1],' ' |
jne @f |
dec eax |
jnz @b |
@@: ret |
endf |
;****************************************************************************** |
;---------------------------------------------------------------------------- |
func start_fasm ;//////////////////////////////////////////////////////////// |
;---------------------------------------------------------------------------- |
; BL = run after compile |
;---------------------------------------------------------------------------- |
cmp [asm_mode],0 |
jne @f |
ret |
@@: mov esi,s_fname |
mov edi,fasm_parameters |
cmp byte[esi],'/' |
je .yes_systree |
mov ecx,[s_fname.size] |
rep movsb |
mov al,',' |
stosb |
mov ecx,[s_fname.size] |
add ecx,-4 |
mov esi,s_fname |
rep movsb |
mov al,',' |
stosb |
mov dword[edi],'/RD/' |
mov word[edi+4],'1/' |
add edi,6 |
mov al,0 |
stosb |
jmp .run |
.yes_systree: |
add esi,[s_fname.size] |
dec esi |
xor ecx,ecx |
mov al,'/' |
@@: cmp [esi],al |
je @f |
dec esi |
inc ecx |
jmp @b |
@@: inc esi |
push esi esi ecx |
rep movsb |
mov al,',' |
stosb |
pop ecx esi |
add ecx,-4 |
rep movsb |
mov al,',' |
stosb |
pop ecx |
sub ecx,s_fname |
mov esi,s_fname |
rep movsb |
mov al,0 |
stosb |
.run: |
cmp bl,0 ; run outfile ? |
je @f |
mov dword[edi-1],',run' |
mov byte[edi+3],0 |
@@: mcall 19,fasm_filename,fasm_parameters |
ret |
endf |
func open_debug_board |
mcall 19,debug_filename,0 |
ret |
endf |
func open_sysfuncs_txt |
mcall 19,tinypad_filename,sysfuncs_filename |
ret |
endf |
func layout |
; ᬥ¨âì à ᪫ ¤ªã ª« ¢¨ âãàë |
mcall 19,setup,param_setup |
mcall 5,eax |
; call activate_me |
; ret |
;endf |
;func activate_me |
mcall 9,p_info,-1 |
inc eax |
inc eax |
mov ecx,eax |
mov edi,[p_info.PID] |
mov ebx,p_info |
@@: dec ecx |
jz @f ; counter=0 => not found? => return |
mcall 9 |
cmp edi,[p_info.PID] |
jne @b |
mcall 18,3 |
mcall 5,eax |
@@: ret |
endf |
; ******************************************************************* |
; ************************** DRAW WINDOW ************************** |
; ******************************************************************* |
func drawwindow |
mcall 48,3,sc,sizeof.system_colors |
mcall 12,1 |
push [color_tbl+4*5] |
pop [sc.work] |
mov edx,[sc.work] |
add edx,0x03000000 |
mov esi,[sc.grab] |
or esi,0x80000000 |
mcall 0,<100,6*80+6+OLEFT+SCRLW>,<75,402>,,,[sc.frame] |
mcall 48,4 |
mov [skinh],eax |
push eax |
mcall 9,p_info,-1 |
pop eax |
cmp [p_info.y_size],0 |
je .exit.2 |
mov [top_ofs],eax |
dec [top_ofs] |
cmp [asm_mode],0 |
je @f |
add [top_ofs],ATOPH+1 |
@@: |
; header string |
mov ebx,eax |
shr ebx,1 |
adc ebx,1+0x000A0000-4 |
mcall 4,,[sc.grab_text],s_title,[s_title.size] |
mov eax,[p_info.x_size] |
sub eax,5*2+SCRLW+2 |
cdq |
mov ebx,6 |
div ebx |
mov [scolumns],eax |
mov eax,[p_info.y_size] ; calculate buttons position |
add eax,-5-ABTNH*3-2-2 |
mov [bot_ofs],eax |
; mov eax,[procinfo.y_size] |
mov [do_not_draw],1 ; do_not_draw = true |
mov ebx,eax |
sub ebx,[skinh] |
sub ebx,ATOPH+SCRLW*3+AMINS+5 |
js .no_draw |
; cmp eax,100 |
; jb .no_draw ; do not draw text & buttons if height < 100 |
mov [do_not_draw],0 ; do_not_draw = false |
sub eax,SCRLW+2+2 |
sub eax,[top_ofs] |
cdq |
mov ebx,10 |
div ebx |
mov [slines],eax |
mov ebx,[p_info.x_size] |
add ebx,5*65536-5 |
mov ecx,[top_ofs-2] |
mov cx,word[top_ofs] |
mcall 38,,,[sc.work_text] |
mov ecx,[bot_ofs-2] |
mov cx,word[bot_ofs] |
sub ecx,0x00010001 |
push ecx |
mcall |
add ecx,(ABTNH+2)*65536+ABTNH+2 |
mcall |
add ecx,(ABTNH+2)*65536+ABTNH+2 |
mcall |
pop ecx |
add cx,(ABTNH+2)*3 |
mov ebx,[p_info.x_size] |
sub ebx,RBTNW+5+1 |
push bx |
shl ebx,16 |
pop bx |
mcall |
mov ebx,(5+LBTNW+1)*65536+(5+LBTNW+1) |
add ecx,(ABTNH+2)*65536 |
mcall |
inc [top_ofs] |
mov ebx,5*65536 |
mov bx,word[p_info.x_size] |
sub bx,9 |
push bx |
sub bx,RBTNW+2 |
mov ecx,[bot_ofs-2] |
mov cx,ABTNH+1 |
mcall 13,,,[sc.work_graph] ; BAR STRIPE |
pop bx |
cmp [asm_mode],0 |
je .skip_top_btns |
mov ecx,[skinh-2] |
mov cx,ATOPH |
mcall ; UPPER BAR |
mov eax,8 |
mov ebx,6*65536+52 |
mov ecx,[skinh] |
inc ecx |
shl ecx,16 |
add ecx,ATOPH-3 |
mov edx,10000 |
mov esi,[sc.work_button] |
@@: |
mcall ; TOOLBAR BUTTONS |
add ebx,54*65536 |
inc edx |
cmp edx,10004 |
jb @b |
.skip_top_btns: |
mov ebx,5*65536+LBTNW |
mov ecx,[bot_ofs] |
shl ecx,16 |
add ecx,(ABTNH+2)*65536+ABTNH |
mcall 8,,,5,[sc.work_button] ; FILE BUTTON |
add ecx,(ABTNH+2)*65536 |
mcall ,,,51 ; STRING BUTTON |
push ebx ecx |
mov ebx,[p_info.x_size] |
shl ebx,16 |
add ebx,(-5-RBTNW)*65536+RBTNW |
mov ecx,[bot_ofs] |
shl ecx,16 |
add ecx,ABTNH |
mov edx,2 |
mcall ,,,2 ; SAVE BUTTON |
add ecx,(ABTNH+2)*65536 |
mcall ,,,4 ; FILE BUTTON |
add ecx,(ABTNH+2)*65536 |
mcall ,,,50 ; SEARCH BUTTON |
shr ecx,16 |
mov bx,cx |
add ebx,-ABTNH-2-ABTNH/2-2-3 |
mcall 4,,[sc.work_button_text],rstr,rstr.size/3 |
add ebx,ABTNH+2 |
add edx,rstr.size/3 |
mcall |
add ebx,ABTNH+2 |
add edx,rstr.size/3 |
mcall |
pop edi ebx |
shr edi,16 |
mov bx,di |
add ebx,-1-ABTNH/2-2-2 |
mcall ,,,lstr,lstr.size/2 |
add ebx,ABTNH+2 |
add edx,lstr.size/2 |
mcall |
cmp [asm_mode],0 |
je @f |
mov ebx,[skinh] |
add ebx,0x000C0000+ATOPH/2-4 |
mcall ,,,toolbar_btn_text,toolbar_btn_text.size |
@@: |
mov eax,[bot_ofs] |
add eax,ABTNH+2 |
mov [ya],eax |
mov [addr],s_fname |
call print_text |
add eax,ABTNH+2 |
mov [ya],eax |
mov [addr],s_search |
call print_text |
jmp .exit |
.no_draw: |
mov ebx,[skinh] |
mov [top_ofs],ebx |
mov eax,[p_info.y_size] |
add eax,-3 |
mov [bot_ofs],eax |
sub eax,ebx |
push eax |
add eax,-2-SCRLW |
cdq |
mov ebx,10 |
idiv ebx |
mov [slines],eax |
pop eax |
mov ebx,[p_info.y_size] |
sub ebx,[skinh] |
sub ebx,SCRLW*3++AMINS+7 |
jns @f |
inc [do_not_draw] |
add eax,-2 |
cdq |
mov ebx,10 |
idiv ebx |
mov [slines],eax |
mov eax,[p_info.x_size] |
sub eax,5*2 |
cdq |
mov ebx,6 |
idiv ebx |
mov [scolumns],eax |
@@: |
.exit: |
call drawfile |
.exit.2: |
mcall 12,2 |
ret |
endf |
;-------------------------------------------- |
func get_line_offset |
;-------------------------------------------- |
; Input: |
; ECX = line number |
; Output: |
; ESI = line data offset |
;-------------------------------------------- |
push eax |
mov esi,0x80000 |
jecxz .exit |
@@: lodsd |
add esi,eax |
loop @b |
.exit: |
pop eax |
ret |
endf |
; ********************************** |
; *********** DRAWFILE *********** |
; ********************************** |
;--------------------------------------------------- |
func drawfile.ex |
;--------------------------------------------------- |
; Input: |
; EAX = start line |
; EBX = end line |
;--------------------------------------------------- |
cmp [p_info.y_size],0 |
jne @f |
ret |
@@: |
call check_bottom_right |
pushad |
cmp [slines],0 |
jle drawfile.exit |
cmp eax,ebx |
jae @f |
xchg eax,ebx |
@@: cmp eax,[top_line] |
jae @f |
mov eax,[top_line] |
@@: mov ecx,[top_line] |
add ecx,[slines] |
cmp ebx,ecx |
jb @f |
dec ecx |
mov ebx,ecx |
@@: cmp eax,ebx |
ja drawfile.exit |
mov ecx,eax |
call get_line_offset |
.start: |
mov ecx,ebx |
sub ecx,eax |
mov ebx,[top_ofs] |
add ebx,OLEFT*65536+1 |
sub eax,[top_line] |
imul eax,10 |
add ebx,eax |
imul ebp,[left_col],6*65536 |
jmp drawfile.next_line |
endf |
func drawfile |
cmp [p_info.y_size],0 |
jne @f |
ret |
@@: |
call check_bottom_right |
pushad |
mov ebx,[top_ofs] |
add ebx,OLEFT*65536+1 |
mov ecx,[top_line] |
call get_line_offset |
.start: |
mov ecx,[slines] |
or ecx,ecx |
jle .exit |
imul ebp,[left_col],6*65536 |
.next_line: |
push ecx ebx |
mov ecx,ebx |
shl ecx,16 |
mov cl,10 |
mov ebx,[p_info.x_size] |
add ebx,(OLEFT-1)*65536-10-SCRLW ; <OLEFT-1,LINE_WIDTH*6+2> |
mcall 13,,,[color_tbl+4*5] |
xor ecx,ecx |
lodsd |
mov [cur_line_len],eax |
or eax,eax |
ja .next_block |
add esp,4*2 |
jmp .draw_cursor |
.next_block: |
push esi |
push ecx |
call get_next_part |
pop ebx |
push ecx |
mov ecx,eax |
push esi ebx |
mov eax,ebx |
sub ebx,[left_col] |
cmp ebx,[scolumns] |
jge @f |
add ebx,esi |
jle @f |
mov ebx,[esp+8+4*2] ;// 4*2=esi+ebx |
sub eax,[left_col] |
jge .qqq |
sub edx,eax |
add esi,eax |
mov eax,OLEFT*65536 |
jmp .qqq2 |
.qqq: |
inc eax |
imul eax,6*65536 |
.qqq2: |
and ebx,0x0000FFFF |
add ebx,eax |
mov eax,[esp] |
add eax,[esp+4];esi |
sub eax,[left_col] |
sub eax,[scolumns] |
jle .qweqwe |
sub esi,eax |
.qweqwe: |
mcall 4;[esp+8] |
@@: |
pop eax eax ; ebx esi |
imul eax,6 |
add [esp+10],ax |
pop ecx esi |
cmp ecx,[cur_line_len];LINE_WIDTH |
jl .next_block |
pop ebx ecx |
and ebx,0x0000FFFF |
add ebx,OLEFT*65536+10 |
add esi,[cur_line_len];LINE_WIDTH |
dec ecx |
jg .next_line |
;-------------------------------------------------------------------------- |
.draw_cursor: |
mov eax,[posy] |
sub eax,[top_line] |
js @f |
mov ecx,[slines] |
sub ecx,eax |
jle @f |
imul eax,10 |
add eax,[top_ofs] |
inc eax |
shl eax,16 |
add eax,10-1 |
mov ecx,eax |
mov ebx,[posx] |
sub ebx,[left_col] |
js @f |
cmp ebx,[scolumns] |
ja @f |
imul ebx,6 |
add ebx,OLEFT-1 |
shl ebx,16 |
inc ebx |
inc ebx |
mov edx,[color_tbl+4*5] |
not edx |
and edx,0x00FFFFFF |
mcall 13 |
@@: |
;-------------------------------------------------------------------------- |
cmp [do_not_draw],2 |
je .exit |
mov ebx,[p_info.x_size] |
shl ebx,16 |
add ebx,(-SCRLW-5+2)*65536+SCRLW-2 |
mov ecx,[top_ofs-2] |
mov cx,SCRLW-1 |
mcall 8,,,'UP',[sc.work_button] |
pushad |
push 0x18 |
shr ecx,16 |
mov bx,cx |
add ebx,(SCRLW/2-3)*65536+SCRLW/2-4 |
mcall 4,,[sc.work_button_text],esp,1 |
add esp,4 |
popad |
mov ecx,[bot_ofs] |
shl ecx,16 |
add ecx,(-SCRLW*2-1)*65536+SCRLW-1 |
mcall ,,,'DN' |
pushad |
push 0x19 |
shr ecx,16 |
mov bx,cx |
add ebx,(SCRLW/2-3)*65536+SCRLW/2-4 |
mcall 4,,[sc.work_button_text],esp,1 |
add esp,4 |
popad |
sub ebx,1*65536-2 |
push ebx |
mov eax,[lines] |
mov ebx,[slines] |
mov ecx,[top_line] |
mov edx,[bot_ofs] |
sub edx,[top_ofs] |
add edx,-(SCRLW*3+2) |
call get_scroll_vars |
mov [vscrl_top],eax |
mov [vscrl_size],ebx |
pop ebx |
mov ecx,eax |
add ecx,[top_ofs] |
shl ecx,16 |
mov cx,word[vscrl_size] |
add ecx,(SCRLW+1)*65536 |
mcall 13,,,[sc.work_button] |
mov ecx,[top_ofs-2] |
mov cx,word[vscrl_top] |
add ecx,(SCRLW+1)*65536 |
mov edx,[color_tbl+4*5] |
or cx,cx |
jle @f |
mcall |
@@: |
mov ecx,[top_ofs] |
add ecx,[vscrl_top] |
add ecx,[vscrl_size] |
add ecx,SCRLW+1 |
mov di,cx |
shl ecx,16 |
mov cx,word[bot_ofs] |
sub cx,di |
sub cx,(SCRLW+1)*2 |
jle @f |
mcall |
@@: |
;------------------------------- |
@^ |
pushad |
mov eax,ebx |
shr eax,16 |
mov bx,ax |
add ebx,0x00010001 |
mov ecx,[top_ofs] |
add ecx,[vscrl_top] |
add ecx,SCRLW+1 |
mov eax,ecx |
shl ecx,16 |
add eax,[vscrl_size] |
dec eax |
add ecx,eax |
mov edx,[sc.work_button] |
add edx,0x00202020 |
mcall 38 |
add ebx,(SCRLW-2)*65536+(SCRLW-2) |
mov edx,[sc.work_button] |
sub edx,0x00202020 |
mcall 38 |
sub ebx,(SCRLW-2)*65536 |
mov ax,cx |
shl ecx,16 |
mov cx,ax |
mcall 38 |
mov eax,[vscrl_size-2] |
mov ax,word[vscrl_size] |
sub eax,0x00010001 |
sub ecx,eax |
mov edx,[sc.work_button] |
add edx,0x00202020 |
mcall 38 |
popad |
^@ |
;------------------------------- |
mov eax,ebx |
shr eax,16 |
add bx,ax |
mov ecx,[top_ofs-2] |
mov cx,word[top_ofs] |
add ecx,SCRLW*65536+SCRLW |
mcall 38,,,[sc.work_text] |
mov ecx,[bot_ofs-2] |
mov cx,word[bot_ofs] |
sub ecx,(SCRLW*2+2)*65536+(SCRLW*2+2) |
mcall |
rol ebx,16 |
push bx |
rol ebx,16 |
pop bx |
mov ecx,[top_ofs-2] |
mov cx,word[bot_ofs] |
add ecx,-2 |
mcall |
;-------------------------------------------------------------------------- |
mov ebx,5*65536+SCRLW-1 |
mov ecx,[bot_ofs] |
shl ecx,16 |
add ecx,(-SCRLW)*65536+SCRLW-2 |
mcall 8,,,'LT',[sc.work_button] |
pushad |
push 0x1B |
shr ecx,16 |
mov bx,cx |
add ebx,(SCRLW/2-3)*65536+SCRLW/2-4 |
mcall 4,,[sc.work_button_text],esp,1 |
add esp,4 |
popad |
mov ebx,[p_info.x_size] |
shl ebx,16 |
add ebx,(-SCRLW*2-5)*65536+SCRLW |
mcall ,,,'RT' |
pushad |
push 0x1A |
shr ecx,16 |
mov bx,cx |
add ebx,(SCRLW/2-2)*65536+SCRLW/2-4 |
mcall 4,,[sc.work_button_text],esp,1 |
add esp,4 |
popad |
inc ecx |
push ecx |
mov eax,[columns] |
mov ebx,[scolumns] |
mov ecx,[left_col] |
mov edx,[p_info.x_size] |
add edx,-(SCRLW*3+10) |
call get_scroll_vars |
mov [hscrl_top],eax |
mov [hscrl_size],ebx |
pop ecx |
mov ebx,eax |
add ebx,OLEFT+SCRLW |
shl ebx,16 |
mov bx,word[hscrl_size] |
mcall 13,,,[sc.work_button] |
mov ebx,(OLEFT+SCRLW)*65536 |
mov bx,word[hscrl_top] |
mcall ,,,[color_tbl+4*5] |
mov ebx,OLEFT+SCRLW-1 |
add ebx,[hscrl_top] |
add ebx,[hscrl_size] |
mov di,bx |
shl ebx,16 |
mov bx,word[p_info.x_size] |
sub bx,di |
sub bx,SCRLW*2+6 |
jle @f |
mcall |
@@: |
mov eax,ebx |
shr eax,16 |
add bx,ax |
mov ecx,[bot_ofs-2] |
mov cx,word[bot_ofs] |
sub ecx,SCRLW*65536+2 |
mcall 38,<OLEFT+SCRLW-1,OLEFT+SCRLW-1>,,[sc.work_text] |
mov ebx,[p_info.x_size-2] |
mov bx,word[p_info.x_size] |
sub ebx,(SCRLW*2+6)*65536+(SCRLW*2+6) |
mcall |
mov ebx,[p_info.x_size] |
add ebx,5*65536-5 |
mov ecx,[bot_ofs-2] |
mov cx,word[bot_ofs] |
sub ecx,(SCRLW+1)*65536+(SCRLW+1) |
mcall |
;-------------------------------------------------------------------------- |
.exit: |
popad |
ret |
endf |
;-------------------------------------------- |
func get_scroll_vars |
;-------------------------------------------- |
; Input: |
; EAX = maximum data size (units) |
; EBX = visible data size (units) |
; ECX = current data position (units) |
; EDX = scrolling area size (pixels) |
; Output: |
; EAX = srcoller offset (pixels) |
; EBX = scroller size (pixels) |
;-------------------------------------------- |
push eax ebx ecx edx |
; sub eax,ebx |
mov esi,eax |
mov eax,edx |
mul ebx |
idiv esi |
cmp eax,[esp] |
jae .null |
cmp eax,AMINS |
jae @f |
neg eax |
add eax,AMINS |
sub [esp],eax |
mov eax,AMINS |
@@: mov [esp+8],eax ; scroller size |
mov eax,[esp] |
mul ecx |
idiv esi |
mov [esp+12],eax ; scroller offset |
add eax,[esp+8] |
cmp eax,[esp] |
jbe @f |
dec dword[esp+12] |
@@: |
pop edx ecx ebx eax |
ret |
.null: |
mov dword[esp+8],0 |
mov dword[esp+12],0 |
jmp @b |
endf |
;-------------------------------------------- |
func get_next_part |
;-------------------------------------------- |
; Input: |
; ECX = current letter |
; ESI = string |
; Output: |
; ECX = color |
; EDX = string |
; ESI = length |
;-------------------------------------------- |
cmp [asm_mode],0 |
je .plain.text |
xor ebx,ebx |
mov edx,ecx |
add esi,ecx |
mov edi,symbols |
mov al,[esi] |
cmp al,';' |
je .comment |
mov ecx,symbols.size |
repne scasb |
je .symbol |
cmp al,'$' |
jne @f |
mov edi,symbols |
mov al,[esi+1] |
mov ecx,symbols.size |
repne scasb |
je .not_symbol |
jmp .number |
@@: cmp al,'0' |
jb @f |
cmp al,'9' |
jbe .number |
@@: cmp al,"'" |
je .string |
cmp al,'"' |
je .string |
.not_symbol: |
inc ebx |
inc edx |
cmp edx,[cur_line_len];LINE_WIDTH |
jge @f |
mov edi,symbols |
mov al,[esi+ebx] |
cmp al,';' |
je @f |
mov ecx,symbols.size |
repne scasb |
jne .not_symbol |
@@: mov ecx,edx |
mov edx,esi |
mov esi,ebx |
mov eax,[color_tbl+4*0] |
ret |
.symbol: |
inc ebx |
inc edx |
cmp edx,[cur_line_len];LINE_WIDTH |
jge @f |
mov edi,symbols |
mov al,[esi+ebx] |
mov ecx,symbols.size |
repne scasb |
je .symbol |
@@: mov ecx,edx |
mov edx,esi |
mov esi,ebx |
mov eax,[color_tbl+4*4] |
ret |
.comment: |
neg edx |
add edx,[cur_line_len];LINE_WIDTH |
xchg edx,esi |
mov ecx,[cur_line_len];LINE_WIDTH |
mov eax,[color_tbl+4*3] |
ret |
.number: |
inc ebx |
inc edx |
cmp edx,[cur_line_len];LINE_WIDTH |
jge @f |
mov edi,symbols |
mov al,[esi+ebx] |
cmp al,';' |
je @f |
mov ecx,symbols.size |
repne scasb |
jne .number |
@@: mov ecx,edx |
mov edx,esi |
mov esi,ebx |
mov eax,[color_tbl+4*1] |
ret |
.string: |
inc ebx |
inc edx |
cmp edx,[cur_line_len];LINE_WIDTH |
jge @f |
cmp [esi+ebx],al |
jne .string |
inc ebx |
inc edx |
@@: |
mov ecx,edx |
mov edx,esi |
mov esi,ebx |
mov eax,[color_tbl+4*2] |
ret |
.plain.text: |
mov edx,[cur_line_len];LINE_WIDTH |
xchg edx,esi |
mov ecx,[cur_line_len];LINE_WIDTH |
mov eax,[color_tbl+4*0] |
ret |
endf |
; ******************************************** |
; **************** SAVEFILE **************** |
; ******************************************** |
func save_file |
mov esi,0x80000 ; 0x70000 = 448 Kbytes (maximum) |
mov edi,0x10000 |
.new_string: |
call save_string |
cmp dword[esi],0 |
jne .new_string |
sub edi,0x10000+2 ; minus last CRLF |
;! mov [filelen],edi |
cmp byte[s_fname],'/' |
je .systree_save |
mcall 33,s_fname,0x10000,edi,0;[filelen],0 |
test eax,eax |
je .exit |
call file_not_found |
jmp .exit |
.systree_save: |
;! mov eax,[filelen] |
mov [f_info+8],edi ;! eax |
mov [f_info+0],1 |
mov esi,s_fname |
mov edi,f_info.path |
mov ecx,PATHL |
cld |
rep movsb |
mcall 58,f_info |
.exit: |
ret |
endf |
func save_string |
lodsd |
mov ecx,eax |
@@: cmp byte[esi+ecx-1],' ' |
jne @f |
loop @b |
@@: jecxz .endcopy |
xor edx,edx |
mov ebx,edx |
mov ah,dl |
.next_char: |
mov al,[esi+ebx] |
inc ebx |
test ah,00000001b |
jnz .char |
cmp al,'"' |
jne @f |
xor ah,00000100b |
jmp .char |
@@: cmp al,"'" |
jne @f |
xor ah,00000010b |
jmp .char |
@@: test ah,00000110b |
jnz .char |
cmp al,';' |
jne @f |
test ah,00000001b |
jnz .char |
xor ah,00000001b |
jmp .char |
@@: cmp al,' ' |
jne .char |
inc edx |
test ebx,ATABW-1 |
jnz @f |
dec edx |
jle .put |
mov al,9 |
xor edx,edx |
jmp .put |
.char: |
or edx,edx |
jz .put |
push ecx eax |
mov ecx,edx |
mov al,' ' |
rep stosb |
pop eax ecx |
xor edx,edx |
.put: |
stosb |
@@: loop .next_char |
.endcopy: |
mov eax,0x0A0D |
stosw |
add esi,[esi-4] |
ret |
endf |
; ******************************************** |
; **************** LOADFILE **************** |
; ******************************************** |
func loadhdfile |
mov [f_info+0],0 |
mov [f_info+8],300000/512 |
mov esi,s_fname |
mov edi,f_info.path;pathfile_read |
mov ecx,PATHL |
cld |
rep movsb |
mcall 58,f_info ; fileinfo_read |
xchg eax,ebx |
inc eax |
test ebx,ebx |
je file_found |
cmp ebx,6 ;// ATV driver fix (6 instead of 5) |
je file_found |
call file_not_found |
ret |
endf |
func loadfile |
mcall 6,s_fname,0,16800,0x10000 ; 6 = open file |
inc eax ; eax = -1 -> file not found |
jnz file_found |
call file_not_found |
ret |
file_found: |
dec eax |
mov [filesize],eax |
mov [lines],1 |
mov [columns],0 |
mov esi,0x10000 |
mov edi,0x80000 |
mov edx,eax |
.next_line: |
mov ebx,edi |
add edi,4 |
.next_char: |
or edx,edx |
jle .exit |
lodsb |
dec edx |
cmp al,13 |
je .CR |
cmp al,10 |
je .LF |
cmp al,9 |
je .TB |
cmp al,0 |
je .exit |
stosb |
jmp .next_char |
.exit: |
mov ecx,10 |
mov al,' ' |
rep stosb |
lea eax,[edi-4] |
sub eax,ebx |
mov [ebx],eax |
mov dword[ebx+eax+4],0 |
sub eax,10 |
jnz @f |
inc eax |
@@: cmp eax,[columns] |
jbe @f |
mov [columns],eax |
@@: ret |
.CR: cmp byte[esi],10 |
jne .LF |
lodsb |
dec edx |
.LF: mov ecx,10 |
mov al,' ' |
rep stosb |
lea eax,[edi-4] |
sub eax,ebx |
mov [ebx],eax |
inc [lines] |
add eax,-10 |
cmp eax,[columns] |
jbe .next_line |
mov [columns],eax |
jmp .next_line |
.TB: lea eax,[edi-4] |
sub eax,ebx |
mov ecx,eax |
add ecx,ATABW |
and ecx,not(ATABW-1) |
sub ecx,eax |
mov al,' ' |
rep stosb |
jmp .next_char |
file_not_found: |
mcall 55,eax,error_beep ; beep |
mov [lines],1 ; open empty document |
mov [columns],1 |
xor eax,eax |
mov [top_line],eax |
mov [posx],eax |
mov [posy],eax |
mov edi,0x80000+4 |
mov ecx,10 |
mov [edi-4],ecx |
mov [edi+10],eax |
mov al,' ' |
cld |
rep stosb |
ret |
endf |
; ***************************** |
; ****** WRITE POSITION ****** |
; ***************************** |
func writepos |
cmp [do_not_draw],1 ; return if drawing is not permitted |
jae .exit |
pusha |
mov eax,[posx] |
inc eax |
mov ebx,5 |
mov ecx,10 |
mov edi,htext2.pos1 |
cld |
call uint2strz |
mov eax,[posy] |
inc eax |
mov ebx,5 |
mov edi,htext2.pos2 |
call uint2strz |
mov eax,[lines] ; number of lines |
mov ebx,5 |
mov edi,htext2.pos3 |
call uint2strz |
mov ebx,5*65536+htext2.size*6 |
mov ecx,[bot_ofs] |
shl ecx,16 |
add ecx,ABTNH |
mcall 13,,,[sc.work_graph] ; draw bar |
mov ebx,12*65536 |
mov bx,word[bot_ofs] |
add ebx,(ABTNH+2)/2-4 |
mcall 4,,[sc.work_button_text],htext2,htext2.size ; write position |
popa |
.exit: |
ret |
endf |
;----------------------------------------------------------------------------- |
func uint2strz ;////////////////////////////////////////////////////////////// |
;----------------------------------------------------------------------------- |
dec ebx |
jz @f |
xor edx,edx |
div ecx |
push edx |
call uint2strz |
pop eax |
@@: cmp al,10 |
sbb al,$69 |
das |
stosb |
ret |
endf |
; **************************** |
; ******* READ STRING ******** |
; **************************** |
func read_string |
cmp al,5 |
jz .f1 |
cmp al,51 |
jz .f2 |
ret |
.f1: mov [addr],s_fname |
mov eax,[bot_ofs] |
add eax,ABTNH+2 |
mov [ya],eax |
push 0 ; case insensitive |
jmp .rk |
.f2: mov [addr],s_search |
mov eax,[bot_ofs] |
add eax,(ABTNH+2)*2 |
mov [ya],eax |
push 1 ; case sensitive |
.rk: |
mov edi,[addr] |
mov ecx,PATHL |
sub ecx,[edi-4] |
add edi,[edi-4] |
mov al,$1C |
cld |
rep stosb |
mov edi,[addr] |
mov eax,[edi-4] |
mov [temp],eax |
add edi,eax |
call print_text |
mcall 40,00000111b |
.waitev: |
mcall 10 |
cmp eax,2 |
jne .read_done |
mcall ;2 |
shr eax,8 |
cmp al,13 |
je .read_done |
cmp al,8 |
jne .nobs |
cmp edi,[addr] |
je .waitev |
dec [temp] |
mov eax,[addr] |
dec dword[eax-4] |
sub edi,1 |
mov byte[edi],$1C |
call print_text |
jmp .waitev |
.nobs: |
movzx ebx,al |
sub ebx,$20 |
jle .waitev |
cmp byte[esp],0 |
jne .keyok |
sub ebx,$40 |
jl .keyok |
add al,[ebx+add_table] |
.keyok: |
mov ecx,[addr] |
add ecx,PATHL |
cmp edi,ecx |
jae .waitev |
mov [edi],al |
inc [temp] |
mov eax,[addr] |
inc dword[eax-4] |
call print_text |
inc edi |
jmp .waitev |
.read_done: |
add esp,4 |
mov ecx,PATHL |
sub ecx,[temp] |
mov edi,[addr] |
add edi,[temp] |
mov al,' ' |
cld |
rep stosb |
mov [temp],987 |
call print_text |
mcall 40,00100111b |
ret |
endf |
func print_text |
pusha |
mov ebx,(LBTNW+5+2)*65536 |
mov bx,word[p_info.x_size] |
sub bx,LBTNW+RBTNW+10+3 |
mov ecx,[ya-2] |
mov cx,ABTNH+1 |
mcall 13,,,[sc.work] |
mov ebx,(LBTNW+5+2+4)*65536+ABTNH/2-3 |
add ebx,[ya] |
mov eax,[p_info.x_size] |
sub eax,LBTNW+RBTNW+10+8 |
push eax |
cdq |
mov ecx,6 |
div ecx |
cmp eax,PATHL |
jbe @f |
mov eax,PATHL |
@@: mov esi,eax |
mcall 4,,[color_tbl+0],[addr] |
mov eax,[ya] |
mov ebx,eax |
add eax,ABTNH/2-6 |
shl eax,16 |
add eax,ebx |
add eax,ABTNH/2-6+11 |
mov ecx,eax |
imul eax,[temp],6 |
pop ebx |
cmp eax,ebx |
jae @f |
add eax,LBTNW+5+2+4 |
mov ebx,eax |
shl eax,16 |
add ebx,eax |
mcall 38,,,[color_tbl+0] |
@@: popa |
ret |
endf |
include 'helpwnd.asm' |
;----------------------------------------------------------------------------- |
section @DATA ;/////////////////////////////////////////////////////////////// |
;----------------------------------------------------------------------------- |
addr dd s_fname ; address of input string |
temp dd 0xabc ; used in read_string |
vscrl_capt dd -1 |
hscrl_capt dd -1 |
label color_tbl dword |
dd 0x00000000 ;0x00FFFF00 ; text |
dd 0x00009000 ;0x0000FF00 ; numbers |
dd 0x00A00000 ;0x0000FFFF ; strings |
dd 0x00909090 ;0x00C0C0C0 ; comments |
dd 0x003030f0 ;0x00FFFFFF ; symbols |
dd 0x00E0E0E0 ;0x00000080 ; background |
add_table: |
; times $61 db -$00 |
times $1A db -$20 |
times $25 db -$00 |
times $10 db -$20 |
times $30 db -$00 |
times $10 db -$50 |
times $04 db -$00,-$01 |
times $08 db -$00 |
error_beep db 0xA0,0x30,0 |
sz s_example,'README.TXT' |
sz s_still ,'still' |
;sz param_setup,<'LANG',0> ; parameter for SETUP |
param_setup db 'LANG',0 |
sz fasm_filename ,'FASM ' |
sz debug_filename ,'BOARD ' |
sz tinypad_filename,'TINYPAD ' |
sz setup ,'SETUP ' ; to change keyboard layout |
lsz sysfuncs_filename,\ |
ru,<'SYSFUNCR.TXT',0>,\ |
en,<'SYSFUNCS.TXT',0> |
sz htext,'TINYPAD' |
sz toolbar_btn_text,'COMPILE RUN BOARD SYSFUNC' |
lsz lstr,\ |
ru,<' > ',' > '>,\ |
en,<' FILE > ',' STRING > '> |
lsz rstr,\ |
ru,<' ',' ',' '>,\ |
en,<' SAVE ' ,' LOAD ' ,' SEARCH ' > |
lsz htext2,\ |
ru,' 00000:00000 00000 ',\ |
en,'POSITION 00000:00000 LENGTH 00000 LINES' |
if lang eq ru |
htext2.pos1 = htext2+8 |
htext2.pos2 = htext2+14 |
htext2.pos3 = htext2+28 |
else |
htext2.pos1 = htext2+9 |
htext2.pos2 = htext2+15 |
htext2.pos3 = htext2+30 |
end if |
lszc help_text,b,\ |
ru,':',\ |
ru,' ',\ |
ru,' CTRL+F1 : â® ®ª®',\ |
ru,' CTRL+S : ¥à¢ ï áâப ¤«ï ª®¯¨à®¢ ¨ï',\ |
ru,' CTRL+E : ®á«¥¤ïï áâப ¤«ï ª®¯¨à®¢ ¨ï',\ |
ru,' CTRL+P : áâ ¢¨âì ¢ë¡à ®¥ ⥪ãéãî ¯®§¨æ¨î',\ |
ru,' CTRL+D : ¤ «¨âì áâபã',\ |
ru,' CTRL+L : áâ ¢¨âì áâபã-à §¤¥«¨â¥«ì',\ |
ru,' CTRL+[ : ¥à¥©â¨ ¢ ç «® ä ©« ',\ |
ru,' CTRL+] : ¥à¥©â¨ ¢ ª®¥æ ä ©« ',\ |
ru,' CTRL+F2 : £à㧨âì ä ©«',\ |
ru,' CTRL+F3 : ®¨áª',\ |
ru,' CTRL+F4 : ®åà ¨âì ä ©«',\ |
ru,' CTRL+F5 : ¢¥á⨠¨¬ï ä ©« ',\ |
ru,' CTRL+F6 : ¢¥á⨠áâப㠤«ï ¯®¨áª ',\ |
ru,' CTRL+F8 : ¬¥¨âì à ᪫ ¤ªã ª« ¢¨ âãàë',\ |
ru,'',\ |
en,'COMMANDS:',\ |
en,' ',\ |
en,' CTRL+F1 : SHOW THIS WINDOW',\ |
en,' CTRL+S : SELECT FIRST STRING TO COPY',\ |
en,' CTRL+E : SELECT LAST STRING TO COPY',\ |
en,' CTRL+P : PASTE SELECTED TO CURRENT POSITION',\ |
en,' CTRL+D : DELETE CURRENT LINE',\ |
en,' CTRL+L : INSERT SEPARATOR LINE',\ |
en,' CTRL+[ : GO TO THE BEGINNING OF FILE',\ |
en,' CTRL+] : GO TO THE END OF FILE',\ |
en,' CTRL+F2 : LOAD FILE',\ |
en,' CTRL+F3 : SEARCH',\ |
en,' CTRL+F4 : SAVE FILE',\ |
en,' CTRL+F5 : ENTER FILENAME',\ |
en,' CTRL+F6 : ENTER SEARCH STRING',\ |
en,' CTRL+F8 : CHANGE KEYBOARD LAYOUT',\ |
en,'' |
lsz help_title,\ |
ru,'',\ |
en,'TINYPAD HELP' |
sz symbols,'#&*\:/<>|{}()[]=+-, '; %.' |
align 4 |
label f_info dword |
dd ? |
dd 0 |
dd ? |
dd 0x10000 |
dd 0x70000 |
.path: |
times PATHL+1 db ? |
TINYPAD_END: ; end of file |
;----------------------------------------------------------------------------- |
section @UDATA ;////////////////////////////////////////////////////////////// |
;----------------------------------------------------------------------------- |
posx dd ? ; global X position (text cursor) |
posy dd ? ; global Y position (text cursor) |
lines dd ? ; number of lines in file |
slines dd ? ; number of lines on the screen |
columns dd ? ; number of columns in file |
scolumns dd ? ; number of columns on the screen |
top_ofs dd ? ; height occupied by top buttons |
bot_ofs dd ? ; height occupied by bottom buttons |
top_line dd ? ; topmost visible line on screen |
left_col dd ? ; leftmost visible char on line |
vscrl_top dd ? |
vscrl_size dd ? |
hscrl_top dd ? |
hscrl_size dd ? |
skinh dd ? ; skin height |
__rc dd ?,?,?,? |
;filelen dd ? ; file size (on save) ??? |
filesize dd ? ; file size (on load) ??? |
ya dd ? ; for read_string |
copy_start dd ? ; first line for copying (Ctrl+S) |
copy_count dd ? ; number of lines for copying (Ctrl+E) |
copy_size dd ? ; size of data to copy |
s_title.size dd ? ; caption length |
cur_line_len dd ? |
asm_mode db ? ; ASM highlight? |
do_not_draw db ? ; draw top and bottom buttons? |
main_closed db ? ; main window closed? (to close help window) |
align 4 |
s_fname.size dd ? |
s_fname rb PATHL+1 |
align 4 |
s_search.size dd ? |
s_search rb PATHL+1 |
s_title rb 256 ; window caption |
;----------------------------------------------------------------------------- |
section @PARAMS ;///////////////////////////////////////////////////////////// |
;----------------------------------------------------------------------------- |
fasm_parameters: |
p_info process_information |
sc system_colors |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |