Language Assembler x86 (TASM Flavour)
(Demonstration of metaprogramming in TASM)
Date: | 07/05/06 |
Author: | Vladimir V. Kalashnikov |
URL: | http://www.admin.ksue.edu.ua/ |
Comments: | 6 |
Info: | http://info.borland.com/borlandcpp/cppcomp/tasmfact.html |
Score: | (3.07 in 29 votes) |
; ; "99 Stanzas on how to drink beer ;-)" TASM v3.0 (x86 assembler) ; .model tiny .code org 100h start: call print stanza macro howmany,what db '&howmany','&what',13,10 display '&howmany&&what' endm bottles = 99 rept 99 stanza %bottles,< bottles of beer on the wall> stanza %bottles,< bottles of beer> stanza ,<take one down, pass it around> bottles = bottles-1 stanza %bottles,< bottles of beer on the wall> endm stanza 0,< bottles of beer> stanza ,<go to the store and buy some more> db '$' print: pop dx mov ah,9 int 21h ret end start
Download Source | Write Comment
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!
Comments
toss said on 07/09/06 03:16:59
very clean and pretty code!
SinisterBen said on 08/22/07 02:14:28
Very nice sire. I couldn't have done better myself! Great stuff.
hell0g said on 04/13/09 15:16:36
it's fake. code is not asm, it's macros
mix_mix said on 02/26/10 19:46:41
Nice. But in fact it's just a macro which creates a very long string contains the song's lyrics. So it looks like 'print("99 bottles of beer on the wall...."' in C.
Vladimir V. Kalashnikov said on 08/24/10 13:59:46
hell0g and mix_mix - It's not fake.
The prime reason to write this code was to demonstrate Tasm metaprogramming abilities. You should review the code and take notice on this: the stanzas are printed twice. First one during the compilation and second one during the usual run from the command prompt.
So, yes, this program is macros. The result is one big string. But this string is displayed during the compilation! That was the reason and intended one!
You are neglectful, guys.
barrym said on 08/25/10 06:06:00
@vladimir: While I agree with you that hell0g and mix_mix are being slightly harsh,
the fact remains that your code (IMO it's legitimate code) doesn't handle the
singular case of "1 bottle" correctly and should be revised accordingly. Good luck!