Hello,
This is my first program by means of fasm.
Can somebody do same thing in the Linux console?
I can not yet.
; Colorful Character Display in Windows console
; Try Alt+Enter in the DOS Box.
format PE console
entry start
macro stdcall proc,[arg]
{
reverse push arg
common call proc
}
macro invoke proc,[arg]
{ common stdcall [proc],arg }
STD_OUTPUT_HANDLE EQU -11
section '.code' code readable executable
start:
invoke GetStdHandle,STD_OUTPUT_HANDLE ; Standard output handle
mov [hStdOut], eax
invoke SetConsoleWindowInfo,[hStdOut],1,Sml_Rct
mov edi,00080000h
mov [LPctr],250h
L1:
invoke WriteConsoleOutputCharacterA,[hStdOut],\
Char,1,edi,written
invoke WriteConsoleOutputAttribute,[hStdOut],\
Attr,1,edi,written
inc edi
inc [Char]
dec [Attr]
mov eax,edi
cmp al,50h
jne L2
and edi,0FFFF0000h
add edi, 00010000h
L2: dec [LPctr]
jnz L1
mov eax,000e0000h ;Y=0eh,X=0h
invoke SetConsoleCursorPosition,[hStdOut],eax
invoke ExitProcess,0
section '.data' data readable writeable
written DD 0
hStdOut DD 0
LPctr DW 0
Char DB 0
Attr DB 0
Sml_Rct DW 0h ; Left
DW 0h ; Top
DW 4Fh ; Right
DW 18h ; Bottom
section '.idata' import data readable writeable
dd 0,0,0,RVA kernel_name,RVA kernel_table
dd 0,0,0,0,0
kernel_table:
WriteConsoleOutputCharacterA dd rva _WriteConsoleOutputCharacterA
WriteConsoleOutputAttribute dd rva _WriteConsoleOutputAttribute
SetConsoleWindowInfo dd rva _SetConsoleWindowInfo
SetConsoleCursorPosition dd rva _SetConsoleCursorPosition
GetStdHandle dd rva _GetStdHandle
ExitProcess dd RVA _ExitProcess
dd 0
kernel_name db 'KERNEL32.DLL',0
_WriteConsoleOutputCharacterA dw 0
db 'WriteConsoleOutputCharacterA',0
_WriteConsoleOutputAttribute dw 0
db 'WriteConsoleOutputAttribute',0
_SetConsoleWindowInfo dw 0
db 'SetConsoleWindowInfo',0
_SetConsoleCursorPosition dw 0
db 'SetConsoleCursorPosition',0
_GetStdHandle dw 0
db 'GetStdHandle',0
_ExitProcess dw 0
db 'ExitProcess',0
section '.reloc' fixups data readable discardable
---------------- cut ----------------
; Colorful Character Display
; Try in real DOS only!
format MZ
start:
mov di,0B800h
mov es,di
mov di,500h
mov ax,0
mov cx,200h
cld
L1: stosw
inc al
dec ah
loop L1
mov ax,4c00h
int 21h
Regards,
maeha