flat assembler
Message board for the users of flat assembler.

Index > Main > Colorful Character Display

Author
Thread Post new topic Reply to topic
maeha



Joined: 14 Feb 2004
Posts: 6
Location: Japan
maeha
Hello,

This is my first program by means of fasm.
Can somebody do same thing in the Linux console?
I can not yet.
Code:
; 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
Post 05 Apr 2004, 02:06
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.