flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Picnic 30 Aug 2007, 20:13
Congrats Mikor
![]() |
|||
![]() |
|
vid 30 Aug 2007, 21:19
well done.
go on, and hurry to learn 32bit stuff, that is the real thing these days |
|||
![]() |
|
Tomasz Grysztar 30 Aug 2007, 21:36
I may have missed something, but how does that program exit?
|
|||
![]() |
|
Mikor 30 Aug 2007, 21:49
Tomasz Grysztar wrote: I may have missed something, but how does that program exit? It just seems to terminate when it's done. |
|||
![]() |
|
UCM 30 Aug 2007, 22:14
Quote:
You should always have an explicit ending to your code. Luckily, it's ending properly right now, (you are probably using a version of DOS in Windows like the Windows XP DOS), but "real" DOS is likely to crash/otherwise mess up here. Oh, and I would recommend that you start 32-bit programming as soon as you think that you can. You can read the source code of the "official" FASM examples, they should help quite a bit. |
|||
![]() |
|
eek 31 Aug 2007, 01:10
Tomasz Grysztar wrote: I may have missed something, but how does that program exit? ![]() It goes boom. |
|||
![]() |
|
DOS386 31 Aug 2007, 04:16
> It just seems to terminate when it's done.
Bug ![]() Code: mov ax,$4C00 int $21 vid wrote: > go on, and hurry to learn 32bit stuff, that is the real thing these days YES. See FAQ at top of thread how to do "the real thing" in DOS ![]() |
|||
![]() |
|
rugxulo 31 Aug 2007, 05:16
<sarcasm>
32-bit? That's OLD, you should be working on 64-bits exclusively! It's all the rage these days! </sarcasm> (BTW, there's some stuff you won't understand if you can't do 16-bit. But anyways, just start with and learn whatever is most interesting and fun.) |
|||
![]() |
|
vid 31 Aug 2007, 06:56
Quote: (BTW, there's some stuff you won't understand if you can't do 16-bit. But anyways, just start with and learn whatever is most interesting and fun.) agree. starting with the 16 bit stuff is of course better because it gives you better understanding. but it takes years, and is almost not used, so it could be very little rewarding to one who learns. ![]() |
|||
![]() |
|
f0dder 31 Aug 2007, 09:23
int20 or ret is fine for ending a .com program, no need for the big int21/4c :]
|
|||
![]() |
|
Mikor 31 Aug 2007, 09:46
So, is this better then?
Code: org 100h mov ah, 06h sub al, al mov dl, 41h cloop: int 21h inc dl cmp dl, 5Ah jle cloop mov ax, 4C00h int 21h |
|||
![]() |
|
f0dder 31 Aug 2007, 10:11
Mikor: yes, although you can use "ret" or "int 20h" to end the program since it's a .com file.
The reason your original code did exit is that, by chance, there was a byte sequence of either "0xC3" or "0xCD 0x20" present in memory "somewhere" after your own code... but there's no telling how many other instructions executed before that. (Although perhaps windows puts a ret or int20 when loading com files, dunno). |
|||
![]() |
|
DOS386 31 Aug 2007, 10:14
Quote: So, is this better then? YES ![]() Code: mov ah, 06h sub al, al AH=2 is used more ... but 6 seems to be fine as well. Also, MOV AX,$0600 or MOV AH,6 only would do the job. Code: jle cloop You have a pitfall here ![]() _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
![]() |
|
DOS386 31 Aug 2007, 10:21
> although you can use "ret" or "int 20h" to end the program since it's a .com file.
True, but INT $21/$4C00 is safer when you change to EXE or to DPMI32 one day. BTW, Under DPMI there are many additional funny ways how to exit your code, like jmp far 0:$FFFFFFFF, ud2, division by 0, lgdt [ebx], ... just anything (<- almost) illegal will (usually) safely exit your program too ![]() |
|||
![]() |
|
f0dder 31 Aug 2007, 10:26
You should know whether you're doing a .com or .exe file... but okay, it's not like the size of the exit method matters much.
I wouldn't advise on using those "funny methods" to exit DPMI code though, since you'll be causing a crash - I dunno if all DPMI handlers will be very graceful about this, and a register dump certainly doesn't look too pretty to an end-user ^_^ |
|||
![]() |
|
Mikor 31 Aug 2007, 11:24
Just edited my code again, and annotated it.
Code: ;Tell the OS that this is a COM. org 100h mov ax, 0600h mov dl, 41h cloop: int 21h inc dl cmp dl, 5Ah ;JLE is signed, we want JBE (Jump if Below or Equal) jbe cloop ;RET should be ok for COMs ret ;However, use the following when making EXEs ;mov ax, 4C00h ;int 21h I'll try EXEs later, when i'm more used to assembly. |
|||
![]() |
|
Mac2004 02 Sep 2007, 17:55
Mikor: Welcome to the asm world
![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.