flat assembler
Message board for the users of flat assembler.

Index > Main > Error when using PROC in flat assembler.


What assembler do you use?
Flat Assembler
95%
 95%  [ 20 ]
Turbo Assembler
4%
 4%  [ 1 ]
Macro Assembler
0%
 0%  [ 0 ]
Netwide Assembler
0%
 0%  [ 0 ]
Other Assembler
0%
 0%  [ 0 ]
Total Votes : 21

Author
Thread Post new topic Reply to topic
Adam Kachwalla



Joined: 01 Apr 2006
Posts: 150
Adam Kachwalla 10 Jun 2006, 08:08
I was looking into the examples, and it seems that the first line of this code produces an "illegal instruction" error:

Code:
PROC PRINTOUT MSGPTR:WORD
     MOV DX, [MSGPTR]
     MOV AH, 9
     INT 0x21
     RET
ENDP    


How can I rectify this problem in FASM? I have searched a lot of places and I have not been able to find a solution.
Post 10 Jun 2006, 08:08
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20289
Location: In your JS exploiting you and your system
revolution 10 Jun 2006, 09:37
Put this at the head of your file.
Code:
include 'proc32.inc'    
And make PROC and ENDP lower case.
Also try 'win32ax.inc' instead to include all the other macros.
Post 10 Jun 2006, 09:37
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
Tomasz Grysztar 10 Jun 2006, 11:14
It appears that here more like PROC16.INC would be needed.
Post 10 Jun 2006, 11:14
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20289
Location: In your JS exploiting you and your system
revolution 10 Jun 2006, 13:34
Quote:
It appears that here more like PROC16.INC would be needed
Yeah, you are right, I never spotted that int 0x21 etc. there.

Try this instead:
Code:
PRINTOUT:
  label MSGPTR WORD at bp+4
     push bp
     mov bp,sp
     MOV DX, [MSGPTR]
     MOV AH, 9
     INT 0x21
     leave
     RET
    


Last edited by revolution on 10 Jun 2006, 14:57; edited 1 time in total
Post 10 Jun 2006, 13:34
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 10 Jun 2006, 14:49
Hi, I ported PROC32 to PROC16, works fine with the example but I don't fully tested it. Please someone try it and tell me if it's works fine.

Regards


Description: PROC16 fully based on PROC32 by Tomasz Grysztar
Download
Filename: PROC16.zip
Filesize: 2.08 KB
Downloaded: 1290 Time(s)

Post 10 Jun 2006, 14:49
View user's profile Send private message Reply with quote
Adam Kachwalla



Joined: 01 Apr 2006
Posts: 150
Adam Kachwalla 11 Jun 2006, 00:00
Tomasz, I reckon this should be integrated in FASM (You did mention it was similar to TASM syntax). Also, what is the difference between PROC16 and PROC32?
Post 11 Jun 2006, 00:00
View user's profile Send private message Reply with quote
Adam Kachwalla



Joined: 01 Apr 2006
Posts: 150
Adam Kachwalla 11 Jun 2006, 00:06
Locodelassembly, your PROC16 module works fine, but I still cannot get the TASM syntax advantage (I only had 1 argument in the proc, though)
Post 11 Jun 2006, 00:06
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 11 Jun 2006, 00:06
I just replaced EBP and ESP with BP and SP respectively and changed the representation of args with dw instead of dd and some other adjustments but it's practically the same.

Regards

PS: There is a PROC16 already? I forgot to check that Razz (but, I'm sure that it's not present in standard package)
Post 11 Jun 2006, 00:06
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 11 Jun 2006, 00:22
Give an example of what thing you can't do with PROC16.

Ah, please note this which I realised some minutes ago
Code:
proc PRINTOUT MSGPTR:WORD
     MOV DX, [MSGPTR] 
     MOV AH, 9 
     INT 0x21 
     ret ; <- lowercase because this way the apropiate leave/ret 2 sequence will be assembled while with RET only the RET instruction will be assembled
endp    


Note that "proc" defines the macro "ret" which assembles the appropiate return sequence and since macros are case sensitive it's important to write ret in lowercase.

Regards

PS: You can also add "RET fix ret" at the beginning of the source code to solve this problem too
Post 11 Jun 2006, 00:22
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.