SHARE
TWEET

First ASM (FASM) test- output all chars loop

MaKiPL Nov 21st, 2015 (edited) 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; By MaKiPL
  2. ; My first ASM algorithm (finally!)
  3. ; It writes down all ASCII 8 bit characters and ends program
  4. ; As soon as index hits ~252 (due to some logic and datatypes problems I have)
  5. ; FASM for Windows!
  6.  
  7. include '%fasminc%/win32ax.inc'
  8.  
  9. .data
  10.  
  11.   inchar     DB ? ; null
  12.   numwritten DD ?
  13.   numread    DD ?
  14.   outhandle  DD ?
  15.   inhandle   DD ?
  16.   string1    DB 00h
  17.   stop           DB 00h
  18.  
  19.  
  20. .code
  21.  
  22.   start:
  23.                 invoke  AllocConsole
  24.                 invoke  GetStdHandle,STD_OUTPUT_HANDLE
  25.         mov [outhandle],eax
  26.         invoke  GetStdHandle,STD_INPUT_HANDLE
  27.         mov [inhandle],eax
  28.                 jmp begin
  29.   begin:
  30.                 mov bl, [string1]
  31.                 add bl, 1
  32.                 mov [string1], bl
  33.         invoke  WriteConsole,[outhandle],string1,1,numwritten,0
  34.         invoke  ReadConsole,[inhandle],inchar,1,numread,0
  35.                
  36.                 mov dl, [stop]
  37.                 add dl, 1
  38.                 mov [stop], dl
  39.                
  40.                 cmp [stop], 252
  41.                 jb begin ;CF ! ZF is for signed
  42.                 jna ending
  43.         ending:
  44.         invoke  ExitProcess,0
  45.  
  46. .end start
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top