flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
FAlter 11 Jun 2004, 17:40
Has anybody understood what I mean? If yes, is there anyone who can help me?
|
|||
![]() |
|
vid 11 Jun 2004, 18:30
maybe you could describe what you want without using that terms like "MOPS" which are not very well known...
|
|||
![]() |
|
madmatt 11 Jun 2004, 18:49
What do you mean "it should go with all os's"?
|
|||
![]() |
|
FAlter 13 Jun 2004, 10:28
vid wrote:
I need procedures like GetMem/FreeMem (Delphi) or in C malloc and mfree (?), but in Assembler. madmatt wrote:
Well, there should be a method for Windows, one for DOS, and maybe one for Linux. But it is better if the procedure for Windows is the same like the one for Linux and DOS (32-Bit, I know that 16-Bit-DOS needs an own procedure). me wrote:
I meant the Pointer to the Pointer, so the procedure can update it. |
|||
![]() |
|
f0dder 13 Jun 2004, 12:11
There is no thing such as a "universal memory allocation thing". Under dos it's one thing, under windows another, and linux a third... or, well, you could link with libc, then it's going to be a call to malloc on all platforms. On most 32bit OSes, the same calling convention is used - eax,ecx,edx trashable, ebx,esi,edi,ebp must be preserved, and function return values are put in EAX, not EBX.
Btw, I would suggest that you drop dos support, 16bit anyway... you can write dos apps as win32 console instead, and use a dos extender with limited win32 emulation, like Michael Tippach's WDOSX. |
|||
![]() |
|
FAlter 13 Jun 2004, 14:32
There is NO Returnvalue. MOPS puts Returnvalues in AH/AX/EAX (depending on 8/16/32 Bit). A Procedure or Function should save bx before using it. But the programmer can tell the compiler that the Parameter is in bx, and in this way it may be faster in some cases.
|
|||
![]() |
|
f0dder 13 Jun 2004, 15:29
What *IS* that MOPS thing you keep talking about?
If it's some system you're writing yourself, you might want to go with the standard FASTCALL convention rather than inventing your own, see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_core___fastcall.asp |
|||
![]() |
|
FAlter 13 Jun 2004, 17:34
Actually, I'm creating MOPS. You can test the MOPS alphaversion, but I think you won't because it's only in german...
And I want to allocate memory, but how? I have got some Ideas with self-created tables, but I think it's very slow and so I'm looking for the traditional way doing it. |
|||
![]() |
|
f0dder 13 Jun 2004, 18:31
Okay, so it's a programming language/environment/something of your own? Better stick to standard calling conventions, including FASTCALL
![]() The traditional way to allocate memory is to either use libc (since it's available on almost every platform, and every platform that matters anyway) - the other would be to use whatever the OS gives you (HeapAlloc or VirtualAlloc on win32, sbrk/syscalls on *u*x) - or, if you're writing an OS or embedded code, you could manage the memory yourself. Or, in some very peculiar situations, you could have a large static array (ie, "whole bunch of zeroes") in your executable file, and only use that memory... |
|||
![]() |
|
Custodian 15 Jun 2004, 07:50
I have trouble with such code...
Code: handle dw ? ... mov bx,[handle] mov ax, word [bx] ; <--- This works perfectly mov dx, word [bx+2] ... ; <--- I don't change anything at bx & handle mov word [bx], dx ;\<--- here, VDM of Windows 2000 make an error mov word [bx+2], ax ;/ ... ![]() ![]() I post hex bytes of error in VDM later.... today at 16.00-18.00. thx... |
|||
![]() |
|
f0dder 15 Jun 2004, 11:32
What do you do inbetween those lines, though? Any INT calls perhaps?
|
|||
![]() |
|
Custodian 15 Jun 2004, 13:31
No... no any int calls, not any modification of bx register...
here is a full code of nearest operations This is a COM program, using 16-bit dos Code: start: ... mov cx,254 @1: push cx mov cx,254 @@: xor ax,ax mov al,cl shl ax,1 mov bx,c_table add bx,ax mov ax,word [bx];levoe mov dx,word [bx+2];pravoe cmp ax,dx jae next ;start of part 1 ---- mov word [bx+2],ax mov word [bx],dx ;end of part 1 ---- mov bx,c_table add bx,cx xor ax,ax mov al,byte [bx] mov ah,byte [bx+1] mov byte [bx+1],al mov byte [bx],ah next: loop @r pop cx loop @1 ;start of part 2 ---- mov byte [path],'~' mov dx,path mov ax,5b00h mov cx,0 int 21h jc error ;end of part 2 ---- There is an error, if both part a in my code... if I comment one of them, code works... c_table & p_table is two arrays of 256 & 512 bytes Errors in VDM of Windows 2000 (SP4) OP:63 06 94 00 00 or OP:fe fd 00 00 fe Undefined instruction ![]() thx... |
|||
![]() |
|
FAlter 15 Jun 2004, 14:14
Quote:
Code: ;start of part 1 ---- mov word [bx+2],ax mov word [bx],dx ;end of part 1 ---- mov bx,c_table ;REALLY??? add bx,cx ;NO modification??? But why are you posting here if you have an other problem than me and you can't help me? |
|||
![]() |
|
Custodian 15 Jun 2004, 17:20
FAlter wrote:
You don't quite understand... There is no modification at befour part 1. And it doesn't work fine with addressation using BX register ![]() _________________ --- Line of Cut --- |
|||
![]() |
|
FAlter 16 Jun 2004, 18:56
Sorry. I thought you ment modifications of bx between a"part 1" and "part 2", but if I compare it with your code above, you're right.
But you have ignodes another Question: me wrote:
|
|||
![]() |
|
Custodian 17 Jun 2004, 08:38
I thought that the theme of this theard is pointers, so I post here my program with error (as I think) in poniters...
|
|||
![]() |
|
FAlter 18 Jun 2004, 12:31
But if you had read the text above, you had seen that the topic is simething more special than only pointers (the title). My problem is how to allocate or free memory. And of course, you should use pointers for this action.
I changed the title now. I think that's better. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.