1. More input on c_func() in DOS
- Posted by The AfterBeat <afterbeat at GEOCITIES.COM> Jan 14, 1999
- 477 views
Heh.. Well, I was thinking it would be pretty cool to have a c_func() or similar function for DOS. But then, I thought some more (heheh), and, if it was implemented, it would be hard to make a non-crappy form of it (assuming the code will be retrieved from .OBJ or .O files). But, I thought it would be nice to have some routines to load assembly language procedures from binary files, for example, open_asm_bin(), define_asm_proc(), define_asm_func(), asm_proc(), asm_func(), and asm_variable(). Hahaha, I bet you all are asking what the format of the file should be... Well, I hope this assembly source helps. (I'm using Turbo Assembler syntax) ; Assembly language routines for Euphoria ; Assembler stuff IDEAL ; Force TASM syntax P386 ; Tell assembler we're using 386 protected-mode instructions MODEL flat ; I haven't used TASM in so long.. Is flat a valid TASM ; memory model? ; Code segment CODESEG ; Some segment assumptions ASSUME cs:@code, ds:@code, es:@code, ss:@code ASSUME fs:@code, gs:@code ; Begin at offset 0 ORG 0 ; I'll just throw a tag in here. You can decide if it should be here. ; I'm just using this as a lame mechanism to see if this is a binary ; file containing ASM routines for Euphoria. DB 'EuASM' ; This is the number of symbols in the file. NumberOfSymbols DD 2 ; The names of the symbols (i.e. the routines and variables) DB 'outportd' DD OFFSET _outportd DB 'miscvar' DD OFFSET _miscvar ; I guess the C-calling method should be used. PROC _outportd ARG portID:WORD, value:DWORD ; Set up the stack push ebp mov ebp, esp ; Assign the port ID to DX, and the value to EAX mov dx, [portID] mov eax, [value] ; Send the value out dx, eax ; Restore the stack and return pop ebp ret ENDP _outportd ; That miscellaneous variable miscvar DD 0 ; End of file END Heh.. Excuse the programming, but I haven't used TASM in quite a while. Well, I hope you all think this is a good idea.. If not, I won't care.. Heh. The AfterBeat