![]() |
| | #1 |
| Guest
Posts: n/a
| Inline ASM and Screen Clearing They use inline asm to print messages and also clear the screen in one line with system("cls") There are no header files needed ie no <stdio.h> stuff /* test01.c Shows using _asm to print message ( See Test02.c for arrays */ main() { char *namer = "Hello, world pointers! $"; system("cls"); //Clear Screen _asm { mov dx, namer ; ";" is for comments mov ah,09h int 21h ;A DOS interrupt } } /* test02.c Access contents of an array using _asm */ main() { char name[20] = "Hello, double pointers! $"; char *dummy = name; /* So dummy contains the address of pointer */ _asm { mov dx, byte ptr dummy ;The above is tricky - it moves the address ;of dummy into dx for the DOS interrupt mov ah,09h int 21h } } THE FOLLOWING DOES NOT WORK /* DOES NOT WORK ( See Test 01 & Test02 for ones that work ) */ main() { char name[30] = "Hello, world fails! $"; _asm { mov dx, name mov ah,09h int 21h } } I think it fails because although "name" is the pointer to name[30] it is a kind of hybrid as far as asm is concerned ( or something ) If you run this program you will find it ploughs through huge amounts of memory and finally prints garbage ending with Hello, world fails! So it sort of works ... |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ASM With C Programming | peckitt99 | C Programming | 11 | 10-28-2006 01:40 PM |
| How Can I.....(OpenGL) | Shamino | Game Programming | 33 | 06-01-2005 06:31 AM |
| Inline ASM with SDL Graphics (Not same as C/C++ coding result) ... :( | SyntaxBubble | Game Programming | 6 | 10-15-2003 09:00 PM |
| Calling Class Functions in ASM? | SyntaxBubble | Windows Programming | 2 | 10-14-2003 12:48 AM |
| need help in making graphics in C++ | Unregistered | A Brief History of Cprogramming.com | 10 | 10-21-2001 12:14 PM |