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: | ![]() |
; ; "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
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.
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!