flat assembler
Message board for the users of flat assembler.
Index
> DOS > I'm new and I have a question. Goto page 1, 2 Next |
Author |
|
Octavio 26 Sep 2006, 08:30
Put the data after the code.
|
|||
26 Sep 2006, 08:30 |
|
vid 26 Sep 2006, 08:55
and use "[code]" blocks when posting code here
|
|||
26 Sep 2006, 08:55 |
|
2 26 Sep 2006, 21:21
Thanks a lot! I feel like such an idiot! I am supposed to put the data after the code! My new program does the first 256 powers of 2 and
doesn't have trailing 0s. Code: macro cout char{mov ah,2 mov dl,char int 33} org 256 mov [a],byte 1 mov cx,0 main: inc cx mov bx,0 shift: shl byte[a+bx],1 inc bx cmp bx,[d] jle shift mov bx,[d] cmp byte[a+bx],10 jl dig inc [d] dig: mov bx,0 carry: cmp [a+bx],byte 10 jl weird sub byte[a+bx],10 inc byte[a+bx+1] weird: inc bx cmp bx,[d] jle carry mov bx,[d] ;dec bx loopc: mov dl,[a+bx] add dl,48 cout dl dec bx cmp bx,0 jge loopc cout 10 cmp cx,256 jl main int 32 a db 80 dup 0 d dw 0 |
|||
26 Sep 2006, 21:21 |
|
vid 26 Sep 2006, 23:32
next step: write your macros in readable manner:
Code: macro cout char { mov ah, 2 mov dl, char int 33 } next step: write your CODE in readable manner. This is most widespread standard of formatting asm code: Code: mov [a],byte 1 mov cx,0 main: inc cx mov bx,0 shift: shl byte[a+bx],1 inc bx cmp bx,[d] jle shift mov bx,[d] ...etc... |
|||
26 Sep 2006, 23:32 |
|
2 27 Sep 2006, 02:37
vid,I am a freak about small size. It's why I don't include those extra
spaces or new lines when I don't have to. If a file is 2 bytes smaller and yet hard to read,I still find it worth the tradeoff. For the most part,my code is for my personal use and it's not really meant to be read. I thought that good coders can read it. If the compiler reads it then I consider it acceptable. Many times I've had to take the time to read other people's code. |
|||
27 Sep 2006, 02:37 |
|
HyperVista 27 Sep 2006, 03:10
@2 - spaces and formating don't add to the size of your executable. readability is not just for freshly coded routines, but for six months from now. without good coding style and practices, you won't be able to make heads nor tails from your code six months from now. in fact, i'd get into the habit of adding comments to your code as well if i were you. i don't think you'd be happy with what "good coders" think when they read your source as written.
vid is taking the time out of his busy schedule to show you good style for a reason. i wouldn't discount it out-of-hand as too much trouble, or assume your skills are beyond it. others less skilled than you can benefit from well styled and commented code from you. and you will benefit too. don't worry, i received the "wrath of vid" a while back on my code style... he said it was "hackish" and "spaghetti code". he was right. his advice helped me very much. you've found the best assembler and asm community there is, make your code style created with it and within it worthy |
|||
27 Sep 2006, 03:10 |
|
2 27 Sep 2006, 04:42
Yes,I shall. Just so you know,I was also trying 2 keep my source size
small,but then,if I was after small source,I wouldn't even be doing ASM now would I? LOL BTW@vid,thanks 4 your advice,I'm just a little paranoid from past bad forum experiences. |
|||
27 Sep 2006, 04:42 |
|
rugxulo 27 Sep 2006, 04:46
2, that's true, ASM is not for small source size. Heck, check out the IOCCC, it's got a chess program in 64 lines of C.
|
|||
27 Sep 2006, 04:46 |
|
HyperVista 27 Sep 2006, 10:30
Quote: I'm just a little paranoid from past bad @2 - you don't need to worry about that here. you have a good attitude, eager to learn, and a great sense of wanting to exeriment and learn. you'll fit in well here. |
|||
27 Sep 2006, 10:30 |
|
2 29 Sep 2006, 02:46
Quote:
Thanks alot. You know,I'm kind of help back in my assembly. I kinda wish I had a small standard library that could do console input and output like you can with printf and scanf in C. Is there a good standard library for DOS? |
|||
29 Sep 2006, 02:46 |
|
vid 29 Sep 2006, 04:45
not really "standard", but there are some on programmers heaven. however i don't know if/how they can be used with FASM
|
|||
29 Sep 2006, 04:45 |
|
2 29 Sep 2006, 04:56
Right,there is nothing standard about it. I have used the FASM version
of HLA,but it was a Windows thing. I like my com files cause they are DOS compatible. I may seem silly how I like DOS,but I have some very interesting reasons behind it. |
|||
29 Sep 2006, 04:56 |
|
rhyno_dagreat 01 Oct 2006, 19:35
@2 (the "@"s seem to be the trend nowadays in this thread ) - That's not silly at all, that you want things to be DOS compatible! If you look in the OS Developers section of the forum, you'll notice that a lot of the OS's are actually meant to run over DOS (DOS based, per se).
|
|||
01 Oct 2006, 19:35 |
|
2 01 Oct 2006, 19:45
Quote:
Thanks. Although I run WinXP,I like things about DOS EXEs. First of all,they run in DOS. LOL. I test them with DOSBOX. Second,those Windows compilers do strange things and have such a dependency on DLLs. That is something I don't like. That why I program things in DJGPP. Here is something good I made. http://darkchandler.50webs.com/bitfun.zip |
|||
01 Oct 2006, 19:45 |
|
rhyno_dagreat 03 Oct 2006, 00:18
Ah, and I totally understand your point of view about it. One of my favorite things about DOS executables is their simple file format (IIRC, all you need for the .COM filetype is the address in memory where the executable loads, though the odd thing is that I've made .COM files where they load up without that, so it's like a flat binary.)
|
|||
03 Oct 2006, 00:18 |
|
Madis731 03 Oct 2006, 08:24
erm, and the bitfun executable thinks that all the World is about US-keyboard. We have like 194 countries and at least as many different variations of keyboards. ++ there are also laptops. Don't you think it would be better to make it key-based not code-based?
The second thing that disturbs and doesn't make it any funnier is that the 1-0 are the last bits. They should be the first as the highest order bits or if it is REALLY necessary then at least reverse them. Hmm, actually another problem - in 32-bit world 1-8, Q-I, A-K, Z-('<'; ','; the key after M) would be more logical - one row of keys for every byte. The most trivial problem is porting to ASM I think - I might do it myself after the lunchbrake if others haven't beaten me to it. PS. 53KB program is maybe too much for a size-freak |
|||
03 Oct 2006, 08:24 |
|
rugxulo 04 Oct 2006, 04:21
First of all, I'm no C programmer, BUT:
P.S. DOS 4ever! |
|||
04 Oct 2006, 04:21 |
|
2 05 Oct 2006, 07:22
Quote:
I don't know HOW 2 combine the printfs. I only can do C based on the few things I've read. BTW,I updated that program recently,it should be at the same link. |
|||
05 Oct 2006, 07:22 |
|
rugxulo 07 Oct 2006, 22:57
Okay, well, I'm no C coder (like I said), but here's my (GNU unified) diff of your Oct. 4th version, so use these fixes if you want:
P.S. gcc -s -Wall -Wextra bitfun.c -o bitfun.exe is now silent (tested w/ GCC/DJGPP 4.1.0).
Code: --- bitfun.c 2006-10-04 17:07:08 +0000 +++ bitfun-tweak.c 2006-10-07 17:47:44 +0000 @@ -1,21 +1,32 @@ #include<stdio.h> #include<string.h> #include<conio.h> +#include<pc.h> long int a,b,d,x; char c,s[32]; -main() +int main() { +clrscr(); _setcursortype(_NOCURSOR); ScreenSetCursor(0,36);printf("bin"); ScreenSetCursor(1,36);printf("hex"); ScreenSetCursor(2,36);printf("dec unsigned"); ScreenSetCursor(3,36);printf("dec signed"); ScreenSetCursor(5,0); -printf("This is my long int toy!\nIt lets you mess with each bit!\n"); -printf("All 32 of the bits are assigned to a keyboard key. Here they are.\n"); -printf("12345678qwertyuiasdfghjkzxcvbnm,"); -printf("\nThere are also 3 special controls!\n"); -printf("0 resets all bits to 0,9 inverts them,and / exits.\n"); + +//printf("This is my long int toy!\nIt lets you mess with each bit!\n"); +//printf("All 32 of the bits are assigned to a keyboard key. Here they are.\n"); +//printf("12345678qwertyuiasdfghjkzxcvbnm,"); +//printf("\nThere are also 3 special controls!\n"); +//printf("0 resets all bits to 0,9 inverts them,and / exits.\n"); + +printf("This is my long int toy!\nIt lets you mess with each bit!\n\ +All 32 of the bits are assigned to a keyboard key. Here they are.\n\ +12345678qwertyuiasdfghjkzxcvbnm\ +\nThere are also 3 special controls!\n\ +0 resets all bits to 0,9 inverts them,and / exits.\n"); + + x=1; while(x){ ScreenSetCursor(0,0); @@ -23,9 +34,14 @@ for(b=31;b>=0;b--){s[b]=d&1;s[b]+=48;d>>=1;} printf("%s",s);printf("\n"); ScreenSetCursor(1,24); -printf("%08X\n",a); -printf("%32u\n",a); -printf("%32d\n",a); + +//printf("%08X\n",a); +//printf("%32u\n",a); +//printf("%32d\n",a); + +printf("%08lX\n%32lu\n%32ld\n",a,a,a); + + c=getch(); switch(c){ case ',':a^=1;break; @@ -65,4 +81,5 @@ case '/':x=0;break; } } +return 0; } |
|||
07 Oct 2006, 22:57 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.