flat assembler
Message board for the users of flat assembler.

Index > DOS > [solved] comcall.com

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 01 Jun 2011, 12:34
for the compo, i use a function to execute an other org100h program

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; comcall.inc, .com that calls a .com.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 100h
        mov ax,cs
        add ax,10h
        mov word[@f+2],ax
        call far [@f]
        ret
        align 4
@@:     dd 0:0
        align 100h
        org 0
psp:
        push ds cs
        pop ds
        call .com
        pop ds
        retf
        align 100h
.com:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; here starts org 100h children code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; use it like this, at the first line of your code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;include 'comcall.inc'
;        org 100h
;        your code
;        ret

    


this little code relocates the code segment to next section, 100h bytes after the first one, it works, if i include this file at the first line of any org100h stuff i have, it calls it, no problem. but after, when it is time to exit, crash boom.

and as the goal is to be able to switch many org 100h codes, it is a real problem.


Last edited by edfed on 15 Jun 2011, 12:20; edited 1 time in total
Post 01 Jun 2011, 12:34
View user's profile Send private message Visit poster's website Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 01 Jun 2011, 17:43
Im not sure what youre trying to do, put a com inside a com?
This works but i have no debugger here to prove its solid or not...
Code:

use16
org 0100h

        push    cs      ;so we have somewhere to return to without trashing PSP
        push    exit

        mov     ax,cs
        add     ax,10h  ;256 bytes ahead is next demo segment

        push    ax      ;new cs
        push    0100h   ;new ip
        retf            ;start next demo

rb 256-($-$$)
if $ <> $$+256
display 'crap',0
end if

org 0100h

        mov     al,'x'  ;print something to show we made it here
        mov     ah,0eh
        mov     bh,0
        int     10h

        mov     ah,0    ;wait for keystroke
        int     16h

        retf    ;cs = old cs, ip = exit, ret to DOS

exit:
    
Post 01 Jun 2011, 17:43
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 01 Jun 2011, 18:27
Or maybe something like this?
Code:

use16
org 0100h


        mov     ax,cs   ;parent code segment
        add     ax,10h  ;256 bytes ahead is next demo segment
        push    cs      ;old cs
        push    ret1    ;ret ip
        push    ax      ;new cs
        push    0100h   ;new ip
        retf
ret1:
        mov     ax,cs
        add     ax,20h  ;512 bytes ahead is next demo segment
        push    cs
        push    ret2
        push    ax
        push    0100h
        retf
ret2:
        mov     ax,cs
        add     ax,30h  ;768 bytes ahead is next demo segment
        push    cs
        push    ret3
        push    ax
        push    0100h
        retf
ret3:
        mov     al,'x'  ;print something to show we made it here
        mov     ah,0eh
        mov     bh,0
        int     10h
        mov     ah,0    ;wait for keystroke
        int     16h
        int     20h
        jmp     $       ;paranoid?

rb 256-($-$$)
org 0100h

        mov     al,'1'  ;print something to show we made it here
        mov     ah,0eh
        mov     bh,0
        int     10h
        mov     ah,0    ;wait for keystroke
        int     16h
        retf

rb 256-($-$$)
org 0100h

        mov     al,'2'  ;print something to show we made it here
        mov     ah,0eh
        mov     bh,0
        int     10h
        mov     ah,0    ;wait for keystroke
        int     16h
        retf

rb 256-($-$$)
org 0100h

        mov     al,'3'  ;print something to show we made it here
        mov     ah,0eh
        mov     bh,0
        int     10h
        mov     ah,0    ;wait for keystroke
        int     16h
        retf
    


And like i said before, i am not at home and have no way to test this crap...
Post 01 Jun 2011, 18:27
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 02 Jun 2011, 11:59
i try to give the .com the possibility to be called with a near, and exit with a single ret using a pseudo psp at org 0.

Code:

@@:
call the psp at segment:0 with a far call
the psp calls the org 100h code with a near call
the org 100h exit with a ret
the psp exits with a retf
next org 100h code
loop @b
    


for the moment, i want to call and exit just one code, but after, i will call them sequentially, and after, randomlly with a menu in the main code.
Post 02 Jun 2011, 11:59
View user's profile Send private message Visit poster's website Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 02 Jun 2011, 19:38
Today i came home and test my second example in debug.exe
It traced as expected without any visible problems.
Does this not do what you wanted?
(I didnt debug the first example because i thought it sucks)

PS: Sure you could use near call and ret but you would have to muck with cs:ip anyway,
so why not let the far instructions do all the work for us.
Post 02 Jun 2011, 19:38
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 02 Jun 2011, 21:34
bitshifter, it is harder than that, just change your "something to show" parts with Int21/09h using a string stored in their own "org 100h segment", that simply won't work. Additionally, I think edfed wants other .com files to be included with file directive, and if one of them includes undefined data at the end, then any write will destroy the programs coming after it.

The correct procedure would be to allocate 64K of memory, and when transferring control, make sure that CS=DS=SS=ES. Bonus points would be to also create a correct PSP and change the handler of Int20 and Int21/4C to transfer control back to the main program/loader.

I understood your problem right edfed?

PS: The 256 byte alignment is not needed, only 16 bytes is enough and then adjusting CS appropriately. But this is only if you transfer control directly instead of copying to a separate 64K memory region first, but not copying first is only asking for trouble.
Post 02 Jun 2011, 21:34
View user's profile Send private message Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239 03 Jun 2011, 01:27
would relocatable code help?
Post 03 Jun 2011, 01:27
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 03 Jun 2011, 13:10
bitshifter, i don't want this solution of far call, far ret.

i'd like the one used by everybody in org100h coding that is mov ax,3 \ int10h \ ret.

for the first 256 bytes alignment, it is an arbitrary value.

the others are because i first focus on the call farcall retf ret part before to make the extrasegment relocation.

the psp and the demo code will be relocated somewhere in a segment.

about the CS=DS=SS=ES, i don't think ES should be equal. i will try to make ss = cs, and if it still don't works, test with es=cs
if it still don't work, do it another way. Sad

this code, i remember, worked on a floppy boot sector, it executed a org100h code, and on return via psp, it reloded the bootsector of C:/, and then, started windows. but there were the SS segment initialised i think, to the same as CS or a very different value. i don't remember.
Post 03 Jun 2011, 13:10
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 03 Jun 2011, 18:48
this code is what i'd like to have at the end of the project, the execution of successive and separated binary codes.

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; comcall.inc, .com that calls a .com.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 100h
        xor di,di

@@:
        mov ax,cs
        add ax,10h
        call comcall
        mov ax,cs
        add ax,30h
        call comcall
        mov ax,cs
        add ax,50h
        call comcall
;loop it indefinitelly.
        jmp @b          ;comment this line to see the crash!!!!
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
comcall:
;ax=segment
        mov word[.fptr+2],ax
        call far dword[.fptr]
        ret
        align 4
.fptr:  dd 0:0
        align 100h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+100h  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 0
psp1:
        push ds cs
        pop ds
        call .com
        pop ds
        retf
        align 100h
.com:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+200h  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 100h
        push es word 0b800h
        pop es
        mov si,.message
        mov ah,4fh
@@:
        lodsb
        or al,al
        je .end
        stosw
        jmp @b
.end:
        pop es
@@:
        in al,60h
        cmp al,1
        jne @b
        ret
.message:
        db 'hello ',0
        align 100h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+300h  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 0
psp2:
        push ds cs
        pop ds
        call .com
        pop ds
        retf
        align 100h
.com:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+400h  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 100h
        push es word 0b800h
        pop es
        mov si,.message
        mov ah,0f4h
@@:
        lodsb
        or al,al
        je .end
        stosw
        jmp @b
.end:
        pop es
@@:
        in al,60h
        cmp al,1
        jne @b
        ret
.message:
        db 'world! ',0
        align 100h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+500h  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 0
psp3:
        push ds cs
        pop ds
        call .com
        pop ds
        retf
        align 100h
.com:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+600h  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 100h
        push es word 0b800h
        pop es
        mov si,.message
        mov ah,37h
@@:
        lodsb
        or al,al
        je .end
        stosw
        jmp @b
.end:
        pop es
@@:
        in al,60h
        cmp al,1
        jne @b
        ret
.message:
        db 'how are you? ',0
        align 100h
    

this gives an interresting result.
but the problem is to return to DOS now!
how to do it?

i tested with ret, int 20h and int21h,9, it always crashes.

i tested with ss = es = ds = cs, it crashes.

but it can loop indefinitelly without bug, just to return to dos it seems to be a problem... but where in the mistake?

the psp and the org100h code will be relocated, but for the moment, it should be able to return to dos without crash. Sad
Post 03 Jun 2011, 18:48
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Jun 2011, 20:14
I solved it in the following way:
* In all the "add ax, imm", I've added $10 to every imm
* Commented the last "call comcall", because the program is buggy and makes everything crash.
* Commented "jmp @b" so now the program can exit gracefully

Surprisingly, with the original code every "call far dword[.fptr]" was re-entering the main program (first instruction executed was "XOR DI, DI"), but for some reason the programs managed to get executed anyway (but at the expense of serious stack misaligment when returning to the main program and having CS still with the value of the child program and an IP of less than $100). Interesting puzzle this was, I was starting to think DEBUG was broken before realizing what the error was.
Post 03 Jun 2011, 20:14
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 03 Jun 2011, 20:36
thanks for tests.

effectivelly, i had a case where the bug didn't occur, but it wasn't the wanted effect.

intead of relooping before the first mov ax,cs, i relooped before the first call comcall, and it worked fine. but why? it wasn't the desired effect at all.
this problem is really a strange problem.

and it leaded me to write some debugging info code around.
but no more evidence for the cause of the bug...

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; comcall.inc, .com that calls a .com.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 100h
        push cs
        pop ds
        xor di,di
        call dispcsds
;        push ds cs
;        pop ds
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        call dispsssp
        mov al,'='
        call putc
        mov al,'['
        call putc
        pop ax
        push ax
        call disp16
        mov al,']'
        call putc
        mov al,' '
        call putc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        mov ax,cs
        add ax,10h
        call comcall
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        call dispsssp
        mov al,'='
        call putc
        mov al,'['
        call putc
        pop ax
        push ax
        call disp16
        mov al,']'
        call putc
        mov al,' '
        call putc
        call dispcsds

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@:
        in al,60h
        cmp al,1
        jne @b
;        pop ds
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dispsssp:
        mov al,' '
        call putc
        mov ax,ss
        call disp16
        mov al,':'
        call putc
        mov ax,sp
        call disp16
        ret
dispcsds:
        mov al,' '
        call putc
        mov ax,cs
        call disp16
        mov al,':'
        call putc
        mov ax,ds
        call disp16
        ret
disp16:
;ax=value
        push ax
        ror ax,8
        call @f
        pop ax
@@:
        call b2h
        call putc
        ror ax,8
        call putc
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
include 'b2h.inc'
include 'putc.inc'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
comcall:
;ax=segment
        mov word[.fptr+2],ax
        mov word[.fptr],0
        call far [.fptr]
        ret
        align 4
.fptr:  dd 0:0
        align 100h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+100h  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 0
psp1:
        push ds cs
        pop ds
        call .com
        pop ds
        retf
        align 100h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+200h  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.com: 
;include 'org100h.inc'
        org 100h
        push es word 0b800h
        pop es
        mov si,.message
        mov ah,4fh
@@:
        lodsb
        or al,al
        je .end
        stosw
        jmp @b
.end:
        pop es
        ret
.message:
        db 'hello',0
        align 100h
    

finally, i am sure the error is a very simple mistake, but so simple that it cannot be found...
Post 03 Jun 2011, 20:36
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 04 Jun 2011, 00:34
LocoDelAssembly wrote:
I solved it in the following way:
* In all the "add ax, imm", I've added $10 to every imm
* Commented the last "call comcall", because the program is buggy and makes everything crash.
* Commented "jmp @b" so now the program can exit gracefully

Surprisingly, with the original code every "call far dword[.fptr]" was re-entering the main program (first instruction executed was "XOR DI, DI"), but for some reason the programs managed to get executed anyway (but at the expense of serious stack misaligment when returning to the main program and having CS still with the value of the child program and an IP of less than $100). Interesting puzzle this was, I was starting to think DEBUG was broken before realizing what the error was.


ok, i got it now! lol, effectivelly, it was really a dumb mistake, so dumb that i didn't understood the first time you evoqued the solution.

as main org 100h is 100h bytes after the main psp, means that i the next psp (100h bytes after main org 100h), means it is 200h after main psp, and then, segment +20h instead of 10h.

no need of any extra fix at all.
no ss, nothing more than +20h.

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; comcall.inc, .com that calls a .com.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 100h
        xor di,di
@@:
        mov ax,cs
        add ax,20h
        call comcall
        mov ax,cs
        add ax,40h
        call comcall
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
comcall:
        mov word[.fptr+2],ax
        call far dword[.fptr]
        ret
        align 4
.fptr:  dd 0:0
        align 100h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;org 100h +100h ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 0
psp1:
        push ds cs
        pop ds
        call .com
        pop ds
        retf
        align 100h
.com:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+200h  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 100h
        push es word 0b800h
        pop es
        mov si,.message
        mov ah,4fh
@@:
        lodsb
        or al,al
        je .end
        stosw
        jmp @b
.end:
        pop es
@@:
        in al,60h
        cmp al,1
        jne @b
        ret
.message:
        db 'hello ',0
        align 100h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+300h  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 0
psp2:
        push ds cs
        pop ds
        call .com
        pop ds
        retf
        align 100h
.com:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+400h  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 100h
        push es word 0b800h
        pop es
        mov si,.message
        mov ah,0f4h
@@:
        lodsb
        or al,al
        je .end
        stosw
        jmp @b
.end:
        pop es
@@:
        in al,60h
        cmp al,1
        jne @b
        ret
.message:
        db 'world! ',0
        align 100h    


Laughing and now, let's go to the code relocation part.
Post 04 Jun 2011, 00:34
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 05 Jun 2011, 15:15
hem...

there is still a big bug, some demos from 256b archive crashes the system.

i think it is due to the initial conditions prior to .com execution.

Code:
comcall:
        mov [.sssp],sp
        mov [.sssp+2],ss
        mov word[.fptr+2],ax
        mov word[.fptr],0
        cli
        mov ss,[.fptr+2]       ;set stack as a standard .com stack
        mov sp,0               ;ss:sp = cs:0, first pushed value at ss:0FFFEh
        sti
        mov ax,3
        int 10h
        mov ax,0               ; init all gp registers
        mov bx,0               ;
        mov cx,0               ;
        mov dx,0               ;
        mov si,0               ;
        mov di,0               ;
        mov bp,0               ;
        call far dword[.fptr]
        mov ax,3
        int 10h
        cli
        mov sp,[.sssp]
        mov ss,[.sssp+2]
        sti
        ret
        align 4
.fptr:  dd 0:0
.sssp:  dd 0:0
        align 100h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 0
        push ds es cs cs
        pop es ds
        call @f
        pop es ds
        retf
        align 100h
@@:
    

then, before to crash my hdd, i post a backup.


Description: the first demo (budu) works, the second (bumpgeci) crashes. maybe due to...?
Download
Filename: comcall.zip
Filesize: 3.62 KB
Downloaded: 578 Time(s)

Post 05 Jun 2011, 15:15
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 11 Jun 2011, 03:09
the demo manager source starts to look like it should be at the end.

the list and select interface loop should be implemented, each time a demo is ended (with a single ret), it should returns to the interface. i tested with a simulation of menu selection, it is ok, now, need the menu, and the list of demos.

for the moment, the interface don't loop, but it is not a problem, i tested an infinite loop with just one demo, always the same, it is ok, the demo restarts very fast.

the demo bumpgeci.com is still buging the manager... need some fixes.

and now the code:
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; comcall.inc, .com that calls a .com.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 100h
        mov ah,2fh
        mov si,message
        call puts
        jmp main
message db 'xxxxxxxxxx',0
main:
        mov si,fichier
        call .comcall
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.comcall:
;.fptr = child program memory
;.sssp = parent stack save
        call .comload
        mov [.sssp],sp
        mov [.sssp+2],ss
        cli
        mov ss,[.fptr+2]
        mov sp,0
        sti
        call far dword[.fptr]
        mov ax,3
        int 10h
        cli
        mov sp,[.sssp]
        mov ss,[.sssp+2]
        sti
        ret
        align 4
.fptr:  dd 1000h:0
.sssp:  dd 0:0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.comload:
;si = fichier
;        push cx es di si
        mov cx,100h
        mov es,[.fptr+2]
        mov di,100h
;        mov si,fichier
        rep movsb
;        pop si di es cx
        call .pspload
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.pspload:
;.fptr
;        push cx es di si
        mov cx,100h
        mov es,[.fptr+2]
        mov di,0
        mov si,.psp
        rep movsb
;        pop si di es cx
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.psp:
        push ds es word @f-.psp word 100h cs cs
        pop es ds
        xor ax,ax
        xor bx,bx
        xor cx,cx
        xor dx,dx
        xor si,si
        xor di,di
        xor bp,bp
        ret
@@:
        pop es ds
        retf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
puts:
;si=input
        push es di ax word 0b800h
        pop es
        mov di,[.y]
        shl di,2    ;y*4
        add di,[.y] ;y*5
        shl di,4    ;y*80
        add di,[.x] ;+x
        shl di,2
@@:
        lodsb
        cmp al,0
        je .end
        stosw
        jmp @b
.end:
        pop ax di es
        ret
.x      dw 0
.y      dw 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
fichier:  file 'budu.com'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
Post 11 Jun 2011, 03:09
View user's profile Send private message Visit poster's website Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239 11 Jun 2011, 04:01
Hey quick question. Have you thought of just using DOS to allocate a new spot for it, moving it to the new segment, and then executing? It seems more efficient than just decreasing the size of the current spot.
Post 11 Jun 2011, 04:01
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 11 Jun 2011, 15:38
me239 wrote:
Hey quick question. Have you thought of just using DOS to allocate a new spot for it, moving it to the new segment, and then executing? It seems more efficient than just decreasing the size of the current spot.

i don't really understand this sentence. what do you mean by "decresing the size of the current spot"?

i don't need to allocate memory at all, just tell the .comcall routine that it should load psp and com at some far pointer, and that's all. no DOS.

and now, the code reduced a lot:
Code:
        org 100h
main:
        mov si,.file
        call .comcall
        ret
.comcall:
        mov cx,100h      ;comload
        mov es,[.fptr+2]
        mov di,100h
        rep movsb
        mov cx,100h      ;pspload
        mov es,[.fptr+2]
        mov di,0
        mov si,.psp
        rep movsb
        mov [.sssp],sp   ;comcall
        mov [.sssp+2],ss
        cli
        mov ss,[.fptr+2]
        mov sp,0
        sti
        call far dword[.fptr]
        mov ax,3
        int 10h
        cli
        mov sp,[.sssp]
        mov ss,[.sssp+2]
        sti
        ret
        align 4
.fptr:  dd 2000h:0
.sssp:  dd 0:0
.psp:
        push ds es @f-.psp 100h 0 0 0 0 0 0 0 cs cs
        pop es ds ax bx cx dx si di bp
        ret
@@:
        pop es ds
        retf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.file:  file 'budu.com'
    


you can see here that i can't use call 100h, then, use ret.

i constated that GP registers should be set to 0 in order to let the demo work convenientlly.

the function comcall is now strong enough to be used as is.

i will test with some other demos, and hope it will not crash the machine with random code.

in finallity, every compo for the contest will have the constraint to be executable by this comcall routine, because the goal is to provide an application with a big set of demos.

the limit of 65000 bytes (~65536-psp-stack) will induce that the manager will be very little, and it will let enter up to an hundred demos with file directive.

the demo list will be part of the manager, as a data structure, will contain the name of the author, the name of the demo, the size in bytes of the demo, and the demo itself.

pointer to the first byte of the demo will be used, no spare bytes will exist between demos. even if a demo is just 33 bytes lengh, the next demo will be just after in the global list.

the list itsleft will just be a string of "4 words" entries, each entry will be a descriptor, with first pointer to be the pointer to the demo, second to be the byte count, third to be the pointer to author name, and fourth to be the pointer to demo name.

then, the browsing will beas simple as showing a list of names, point and choose the desired name, hit enter, and lets the demo execute.

i don't see where dos memory allocation have something to do.

it would be better (and simpler) at the end to be able to just use dos file system routine.
put the manager in the demo folder, and it will display the list of files in this folder, but i don't want, because every demo included in the manager will be tested, and approved before to be broadcasted.
it is a serious limitation like apple app store, but seems to be an excellent way to do something not broken.

see later for the next step. and soon, fix the definitive rules of the contest.
Post 11 Jun 2011, 15:38
View user's profile Send private message Visit poster's website Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239 11 Jun 2011, 18:36
I'm asking why don't you use DOS to create a new psp, allocate a new memory block, read the file into the new memory block. From there on just jump into the new block.
Post 11 Jun 2011, 18:36
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 12 Jun 2011, 11:28
i don't ask dos because i want to implement it from scratch, and for a bootable implementation.
Post 12 Jun 2011, 11:28
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 12 Jun 2011, 16:25
edfed wrote:
i don't ask dos because i want to implement it from scratch, and for a bootable implementation.


Why not use MiniDos or bootprog ?.
Post 12 Jun 2011, 16:25
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 12 Jun 2011, 19:36
i have something cool now, with a menu, choose an application, hit enter or echap.

there are 6 apps, the structure to implement them is cool:
Code:
list:
.size=0
.sel=2
.item=4
        dw @f-$-4
        dw 0
        dw .0,.1,.2,.3
        dw user,user1,user2
;insert your pointer here
;like:
;        dw yourpointer
        @@:
.0:     dw demo.0       ,demo.1-demo.0          ,name.budu0             ,author.256b
.1:     dw demo.1       ,demo.2-demo.1          ,name.testit            ,author.me
.2:     dw demo.2       ,demo.3-demo.2          ,name.chaos             ,author.256b
.3:     dw demo.3       ,demo.x-demo.3          ,name.chaos2            ,author.256b
.x:
demo:
.0:     file 'budu.com'
.1:     ret
.2:     file 'chaos.com'
.3:     file '256isnth.com'
.x:
name:
.budu0:  db 'budu.com',0
.fastver: db 'fastver.com',0
.test:   db 'testsize',0
.chaos:  db 'chaos.com',0
.chaos2: db '256isnth.com',0
author:
.256b:  db '256bytes demo archive',0
.me:    db 'edfed',0

;how to include your demo in the file is here, and don't forget to add your pointer in the list

user:   dw .demo,.name-.demo,.name,.author
.demo:  file 'fountain.com'
.name:  db 'fountain.com',0
.author:db '256b demo',0

user1:  dw .demo,.name-.demo,.name,.author
.demo:  file 'hoftu.com'
.name:  db 'hoftu.com',0
.author:db '256b demo',0

user2:  dw .demo,.name-.demo,.name,.author
.demo:  file 'anapurna.com'
.name:  db 'anapurna.com',0
.author:db '256b demo',0
    


the result on the text mode screen is like this:
Code:
choose a file with arrows, hit enter to run, or echap to exit
 file name           author                           size

>budu.com            256bytes demo archive         00FF bytes
 testit.com          edfed                         0001 bytes
 chaos.com           256bytes demo archive         00FD bytes
 256isnth.com        256bytes demo archive         00FE bytes
 fountain.com        256b demo                     0100 bytes
 hoftu.com           256b demo                     0100 bytes
 anapurna.com        256b demo                     0100 bytes
    


enjoy it, and don't hesitate to talk about bugs.

bumpgeci.com still bugs, but all other demos executes and exit very well on my machine.

enjoy, and please report any bug you can see.

[edit]
i will be very vicious because this manager will have something very very cool for demos.

i will put an int8 and int9 over handler to implement a timer and an escape during demo running. then, if you let run the comcall program, it will execute every demo, one by one, and let exit with hiting escape or by waiting for the end of the system delay.

if you are one of the rare personns to test and download it, test it while playing some electro dub music it will give you more enjoyement.


Description: here is the archive, comcall is the main application, others are just some various codes.
Download
Filename: comcall.zip
Filesize: 14.18 KB
Downloaded: 576 Time(s)

Post 12 Jun 2011, 19:36
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.