Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language FASM

(assembly programming language for x86 an)

Date:04/07/06
Author:Peter Kuscsik
URL:158.197.33.240/~kuscsikp
Comments:2
Info:http://flatassembler.net/index.php
Score: (3.00 in 11 votes)
;----------------------------
;  Programmed by:
;  Peter Kuscsik
;----------------------------

format	PE console

start:
	mov	ah, 9
	mov	al, 9
	mov	[val], 3939h		;'99'
	mov	ebx, val
loop_:

	push	eax
	mov	esi, ebx
	call	display_string
	mov	esi, txt1
	call	display_string
	mov	esi, ebx
	call	display_string
	mov	esi, txt2
	call	display_string
	mov	esi, txt3
	call	display_string		

	pop	eax
	cmp	al, 2
	jnz	skip1

	cmp	ah, 0
	jz	finish			
skip1:
	dec	al
	dec	[val+1]
	cmp	al, 255 		
	jnz	text

	dec	ah
	dec	[val]			
	mov	byte [val+1], 39h
	mov	al, 9
	cmp	ah, 0
	jnz	text
	inc	ebx			
text:
	push	eax			
	mov	esi, ebx
	call	display_string
	mov	esi, txt4
	call	display_string
	mov	esi, newline
	call	display_string
	pop	eax
	jmp	loop_

finish:

	mov	esi, fin0		
	call	display_string
	mov	esi, newline
	call	display_string
	mov	esi, fin1
	call	display_string
	mov	esi, fin2
	call	display_string
	mov	esi, newline
	call	display_string
	mov	esi, fin3
	call	display_string
	mov	esi, fin4
	call	display_string

	xor	eax, eax
	call	[ExitProcess]		;Exit

display_string:
	push	esi
	push	0FFFFFFF5h		;STD_OUTPUT_HANDLE
	call	[GetStdHandle]
	mov	ebp, eax
	pop	esi
	mov	edi, esi
	or	ecx, -1
	xor	al, al
	repne	scasb
	neg	ecx
	sub	ecx, 2
	push	0
	push	bytes_count
	push	ecx
	push	esi
	push	ebp
	call	[WriteFile]
	ret

val dw ?
zero db 0
newline db 0Dh,0Ah,0
txt1 db ' bottles of beer on the wall, ',0
txt2 db ' bottles of beer.',0Dh,0Ah,0
txt3 db 'Take one down, pass it around, ',0
txt4 db ' bottles of beer on the wall.',0Dh,0Ah,0
fin0 db '1 bottle of beer on the wall,',0Dh,0Ah,0
fin1 db '1 bottle of beer on the wall, one bottle of beer.',0Dh,0Ah,0
fin2 db 'Take one down, pass it around, no more bottles of beer on the wall',0Dh,0Ah,0
fin3 db 'No more bottles of beer on the wall, no more bottles of beer.',0Dh,0Ah,0
fin4 db 'Go to the store and buy some more, 99 bottles of beer on the wall.',0Dh,0Ah,0

bytes_count dd ?

section '.idata' import data readable writeable

  dd 0,0,0,rva kernel_name,rva kernel_table
  dd 0,0,0,0,0

  kernel_table:
    ExitProcess dd rva _ExitProcess
    WriteFile dd rva _WriteFile
    GetStdHandle dd rva _GetStdHandle

   dd 0

  kernel_name db 'KERNEL32.DLL',0

  _ExitProcess dw 0
    db 'ExitProcess',0
  _WriteFile dw 0
    db 'WriteFile',0
  _GetStdHandle dw 0
    db 'GetStdHandle',0

section '.reloc' fixups data readable discardable

;SZSV :) , JFH!

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
x86-64 Windows console versionQuiveror01/27/070

Comments

>>  Rugxulo said on 10/08/06 05:38:53

Rugxulo There's another FASM one (written by revolution in one line!) that only uses the preprocessor:

http://board.flatassembler.net/topic.php?p=43906

>>  TameraCOOKE said on 05/26/10 01:59:26

TameraCOOKE Do you acknowledge that it is correct time to get the <a href="http://lowest-rate-loans.com">loan</a>, which would make you dreams real.

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: