flat assembler
Message board for the users of flat assembler.

Index > IDE Development > Please set the inital values of AX and BX registers to zero

Author
Thread Post new topic Reply to topic
TomCat



Joined: 28 May 2017
Posts: 11
Location: Hungary
TomCat 31 May 2017, 18:18
FASMD is the ideal tool for a sizecoder. It's great, it's fast and easy to code with it.

The only pain for me, that I have to exit after every compile (CTRL+F9) and than run the compiled code from DOS prompt.

Because if I use compile and run (F9) the inital values of AX and BX registers are 65535 (instead of 0).

It would be a great help, if you could fix this in the next release.
Many 256 byte sizecoder from the demoscene would be happy with it.

Thank you for your effort in advance.

Best regards,
Tamas Kaproncai
Post 31 May 2017, 18:18
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8367
Location: Kraków, Poland
Tomasz Grysztar 31 May 2017, 20:22
I'm not sure if I could have any control over what initial register values DOS passes to the program when I use function 4Bh of int 21h to execute one. This may also depend on a DOS version/variant.
Post 31 May 2017, 20:22
View user's profile Send private message Visit poster's website Reply with quote
TomCat



Joined: 28 May 2017
Posts: 11
Location: Hungary
TomCat 04 Jun 2017, 09:37
I use FreeDOS btw. From a bootable USB drive made by Rufus (https://rufus.akeo.ie).
Post 04 Jun 2017, 09:37
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 04 Jun 2017, 10:11
Hmm I don't get how initial register values can affect your program. Do you depend on AX/BX = 0 on exec start? If yes, then it's not correct, I suppose. Anyway, Ralph Brown gives some info an registers usage, so it seems to work as expected http://www.ctyme.com/intr/rb-2939.htm. You probably could hook the vector and clear registers yourself before exiting, but not sure if this would be the correct approach
Post 04 Jun 2017, 10:11
View user's profile Send private message Reply with quote
TomCat



Joined: 28 May 2017
Posts: 11
Location: Hungary
TomCat 23 Jul 2017, 21:13
Tomasz,
Acording to RalfBrown you could control the inital value of AX register by the ES:BX parameter block. You should give a valid drive letter in first FCB and second FCB.
Then AX will be zero instead of 0FFFFh. And who knows... maybe BX allways has the same value as AX.
Post 23 Jul 2017, 21:13
View user's profile Send private message Reply with quote
TomCat



Joined: 28 May 2017
Posts: 11
Location: Hungary
TomCat 23 Jul 2017, 21:16
oh, and i'm compiling a .com file
Post 23 Jul 2017, 21:16
View user's profile Send private message Reply with quote
TomCat



Joined: 28 May 2017
Posts: 11
Location: Hungary
TomCat 11 Sep 2017, 00:02
I've done it. FASMD.ASM: after mov ax,0D00h and stosw you need this: stosb mov al, ' ' mov ecx,14 rep stosb. And instead of stosd and xor eax,eax you need this: stosd and inc eax inc eax. It works like a charm Smile
Post 11 Sep 2017, 00:02
View user's profile Send private message Reply with quote
TomCat



Joined: 28 May 2017
Posts: 11
Location: Hungary
TomCat 11 Sep 2017, 00:06
sry. misstyped .. mov ecx,15
Post 11 Sep 2017, 00:06
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8367
Location: Kraków, Poland
Tomasz Grysztar 11 Sep 2017, 14:57
TomCat wrote:
sry. misstyped .. mov ecx,15
Perhaps you could just quote the entire block of code?
Post 11 Sep 2017, 14:57
View user's profile Send private message Visit poster's website Reply with quote
TomCat



Joined: 28 May 2017
Posts: 11
Location: Hungary
TomCat 11 Sep 2017, 19:18
Code:
        mov     edi,buffer+200h
        lea     edx,[edi-buffer]
        mov     ax,0D00h
        stosw
        stosb
        mov     al,' '
        mov     ecx,15
        rep     stosb
        lea     ebx,[edi-buffer]
        xor     eax,eax
        stosw
        mov     ax,buffer_segment
        shl     eax,16
        mov     ax,dx
        stosd
        inc     eax
        inc     eax
        stosd
        stosd
        mov     ax,4B00h
        xor     dx,dx
        call    dos_int    
Edit by revolution: Added code tags.
Post 11 Sep 2017, 19:18
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8367
Location: Kraków, Poland
Tomasz Grysztar 11 Sep 2017, 21:03
This doesn't look safe enough in my opinion. I'm going to test this on MS-DOS at least, and I may try to fill FCB a bit better.
Post 11 Sep 2017, 21:03
View user's profile Send private message Visit poster's website Reply with quote
TomCat



Joined: 28 May 2017
Posts: 11
Location: Hungary
TomCat 12 Sep 2017, 06:31
Much more safer than it was before Smile But yes, test it on MS-DOS too! Under FreeDOS an empty FCB looks like this: one byte zero and 15 spaces (the zero is critical, we need it for the right inital values of AX and BX).
Post 12 Sep 2017, 06:31
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8367
Location: Kraków, Poland
Tomasz Grysztar 12 Sep 2017, 07:04
TomCat wrote:
Much more safer than it was before Smile
You're right, I checked the old docs once again and turns out that something I thought was there really wasn't. Only the environment pointer can be zeroed to have it copied from the parent process. But zeroing the pointers to FCBs does not cause parent's FCB to be used instead. In fact, the zeroed pointers are probably used literally and it tries to interpret the interrupt table as FCB and copy it to the child's PSP.

Funny how I seemed to remembers something from the docs that was never there. I must have contracted the rules about environment segment with the ones concerning FCBs and created a false memory.

TomCat wrote:
But yes, test it on MS-DOS too! Under FreeDOS an empty FCB looks like this: one byte zero and 15 spaces (the zero is critical, we need it for the right inital values of AX and BX).
RBIL suggests that "an unopened FCB has the drive, filename, and extension fields filled in and all other bytes cleared". This would mean a zero byte, then 8+3 (11) spaces, and 25 zeroed bytes.
Post 12 Sep 2017, 07:04
View user's profile Send private message Visit poster's website Reply with quote
TomCat



Joined: 28 May 2017
Posts: 11
Location: Hungary
TomCat 12 Sep 2017, 08:49
Can FCB be larger than 16 bytes? Normally FCB1 starts at 5Ch and FCB2 starts at 6Ch when executing a .com file.
Post 12 Sep 2017, 08:49
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8367
Location: Kraków, Poland
Tomasz Grysztar 12 Sep 2017, 09:14
TomCat wrote:
Can FCB be larger than 16 bytes? Normally FCB1 starts at 5Ch and FCB2 starts at 6Ch when executing a .com file.
The old docs mention that FCB1 overlays parts of FCB2, and FCB2 in turn may overwrite parts of command line if opened. This strongly suggests that the content of further fields is not considered important until the FCB is opened, so perhaps 4 zeroed bytes after the file extension might be enough. But it costs me nothing to create a full zeroed FCB anyway and let the DOS handle this however it wishes. There are many different flavors of DOS out there.

BTW, under MS-DOS even with current version of FASMD the AX register is zeroed at the entry of the assembled program.
Post 12 Sep 2017, 09:14
View user's profile Send private message Visit poster's website Reply with quote
TomCat



Joined: 28 May 2017
Posts: 11
Location: Hungary
TomCat 12 Sep 2017, 09:26
Ok.

BTW, You should test it with COM file also! Smile
Post 12 Sep 2017, 09:26
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8367
Location: Kraków, Poland
Tomasz Grysztar 12 Sep 2017, 10:00
I tested exclusively with .COM files.
Post 12 Sep 2017, 10:00
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8367
Location: Kraków, Poland
Tomasz Grysztar 12 Sep 2017, 10:13
I tested the update on my DOS machines and gave it a green light. Please try the version from the updated DOS package and let me know if it does the job on your system.
Post 12 Sep 2017, 10:13
View user's profile Send private message Visit poster's website Reply with quote
TomCat



Joined: 28 May 2017
Posts: 11
Location: Hungary
TomCat 12 Sep 2017, 11:33
I've tested your code under FreeDOS - It's WORKING! Laughing
Post 12 Sep 2017, 11:33
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.