flat assembler
Message board for the users of flat assembler.

Index > DOS > stdcall for dos via fasmg, is there any error in the code

Author
Thread Post new topic Reply to topic
uor99



Joined: 04 Dec 2014
Posts: 42
uor99 03 Oct 2016, 06:06
Code:
Dear pals,i need 8086 codes. Thanks to the two below replies,i can use the stdcall well.
But is there any error in the codes ?

include '8086.inc'
include 'format/mz.inc'
macro stdcall proc,args&
        iterate arg, args
                indx 1+%%-%
                mov bx,arg
                push bx
        end iterate
        call proc
end macro
entry code:start        ; program entry point
stack 100h      ; stack size
        segment code
start:
        push cs
        pop ds
        call main
        MOV AH,4CH
        INT 21H
main:
        push bp
        mov bp,sp
        sub sp,2
        ;
        mov bx,[-2+bp]
        mov byte[bx],10
        mov byte[bx+1],'1'
        mov byte[bx+2],'2'
        mov byte[bx+3],10
        mov byte[bx+4],'$'
        stdcall ok,9,[-2+bp]
        add sp,4
        ;
        mov sp,bp
        pop bp
        ret
ok:
        push bp
        mov bp,sp
        mov bx,[bp+6]
        mov byte[bx+2],'h'
        mov dx,bx
        mov ah,9
        int 21h
        ;
        mov dx,[bp+4]
        add dx,30h
        mov ah,2
        int 21h
        ;
        mov sp,bp
        pop bp
        ret

    


Last edited by uor99 on 04 Oct 2016, 23:39; edited 3 times in total
Post 03 Oct 2016, 06:06
View user's profile Send private message ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20401
Location: In your JS exploiting you and your system
revolution 03 Oct 2016, 08:37
Are you sure you want only 8086 instructions? 'pushd' is not an 8086 instruction. Neither is 'push imm'. Perhaps you want to select a more capable CPU? You need 80386 at least to get pushd, and/or 80186 to get push imm.
Post 03 Oct 2016, 08:37
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 03 Oct 2016, 08:42
Judging from the rest of code I suspect that 16-bit PUSH is needed here. Just replace "pushd" with "push".

PS. You also need to pop the right number of bytes off stack with RET.
Post 03 Oct 2016, 08:42
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:  


< 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.