flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
MaurĂcio Pezzotta 27 Oct 2006, 10:05
I think that in a .com file you'd have to jump to the code offset+256, not just the offset.
|
|||
![]() |
|
Sebastian R. 27 Oct 2006, 10:14
Thanks, I am using the followin code.
Code: .model tiny .data ByteCode db 61440 DUP (?) Buffer db 0 Filename db "TEST.COM", "$" hFile dw ? .code org 100h start: mov ah, 3Dh mov al, 0 lea dx, Filename int 21h mov hFile, bx ReadCode: mov ah, 3Fh mov bx, hFile mov cx, 1 lea dx, ByteCode int 21h cmp ax, 0h je GoOn jmp ReadCode GoOn: lea dx, ByteCode+256 jmp dx mov ah, 4ch int 21h end start (still TASM syntax) But it doesn't work. Any suggestions? |
|||
![]() |
|
Goplat 27 Oct 2006, 16:48
Every byte you read will just overwrite the last one, since you always write to [ByteCode]. But even if you fixed that it would not work. A .COM program expects to start at offset 100h so you would have to do some funky segment munging to make that so. Moreover, all DOS programs need to have a PSP in the first 256 bytes of their memory, and setting one up manually would be annoying.
The easiest way to execute another program is with int 21/AH=4B. (You'll have to shrink your own program's memory block with int 21/AH=4A first.) |
|||
![]() |
|
Dex4u 27 Oct 2006, 17:04
Here: is the code (tasm need converting)
Code: ;; COM file loader;; David Lindauer, March 25, 1997;; This should run MOST com files, if not all of them. The only; especially tricky part is marking the newly allocated memory; segments with an appropriate owner so that the memory will be; released properly when the program exits.;; Note: there are some aspects of DOS compatability I haven't taken; care of here; for example the program name should show up right after; the environment with a fully qualified path; and it should show up; again right after the command line without the path. I may have missed; other stuff as well...;; .model tiny .386 .code org 100hstart: jmp go db 0C4h ; word aligning the stack;_____________________________________________________________________;; Internal stack; dw 128 DUP ('?')tos:;_____________________________________________________________________;; Internal variables;query db 10,13,"Please enter name of file to execute: ",'$'response db 40,0,40 DUP (?);_____________________________________________________________________;; Failure comes here;errmsg db 10,13,"failed.",10,13,'$'failure: push cs ; print a message if something fails pop ds mov dx,offset errmsg mov ah,9 int 21h mov ax,4c01h int 21h;_____________________________________________________________________;; Prepare an empty environment. COMMAND.COM copies the environment of; the parent to a new hunk of memory and throws some data in after it;; We just make an empty environment;prepare_env: mov bx,1 ; need one paragraph mov ah,48h int 21h jc failure mov es,ax ; Zero it out sub di,di sub ax,ax mov cx,8 rep stosw ret;_____________________________________________________________________;; Allocate all useable memory to our new prog; Actually not 100% compatible with what DOS does but close enough; for IBM PC computers.;allocate_allmem: mov bx,-1 ; find out how much mem mov ah,48h int 21h cmp bx,1000h ; At least 64K? jc failure push bx ; Allocate it mov ah,48h int 21h mov es,ax pop bx ; returning size of block jc failure ret;_____________________________________________________________________;; Initialize the new PSP;; Note: this should handle most DOS .COM files. Of course it; makes little sense to go to all this trouble if we aren't running DOS; programs Ps: I also have a exe ver if you interestard. If you do not want to use Dos, i have some code for that too (eg: own OS) |
|||
![]() |
|
rugxulo 28 Oct 2006, 03:58
Link to the above-mentioned .COM and .EXE loaders by David Lindauer: http://ladsoft.tripod.com/demos.htm
|
|||
![]() |
|
sylwek32 28 Oct 2006, 22:17
has somebody already converted it to fasm syntax?
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.