flat assembler
Message board for the users of flat assembler.
Index
> DOS > [solved] Problem with procedure |
Author |
|
Crumbler 05 Mar 2020, 15:09
I'm trying to write a simple .com program.
The following code works with no issues: Code: org 100h Start: mov ah, 09h mov dx, strHello int 21h mov ax, 0c08h ; clear input buffer and wait to close window on key press int 21h test al, al jnz .RegularChar ; if extended char, get it's code mov ah, 08h int 21h .RegularChar: ret strHello: db 'Hello, world!', 13, 10, '$' I decided to put the last block of instructions in a procedure: Code: org 100h include 'MACRO/proc16.inc' proc AwaitKey uses ax mov ax, 0c08h ; clear input buffer wait to close window on key press int 21h test al, al jnz .RegularChar ; if extended char, get it's code mov ah, 08h int 21h .RegularChar: ret endp Start: mov ah, 09h mov dx, strHello int 21h stdcall AwaitKey ret strHello: db 'Hello, world!', 13, 10, '$' However this time nothing was written to the console. Everything that was written to the console gets cleared after calling AwaitKey for some reason. Using a procedure(called via call) written like this works fine though: Code: AwaitKey: mov ax, 0c08h ; clear input buffer wait to close window on key press int 21h test al, al jnz .RegularChar ; if extended char, get it's code mov ah, 08h int 21h .RegularChar: ret Why does this happen? The program is assembled and run on a 32-bit Windows XP virtual machine. Here are the docs for the DOS functions used in my code. |
|||
05 Mar 2020, 15:09 |
|
Crumbler 05 Mar 2020, 15:20
Thanks. This was a really stupid mistake on my part.
|
|||
05 Mar 2020, 15:20 |
|
ProMiNick 05 Mar 2020, 15:43
Where did thou get proc16.inc?
It is one of that I publicate? or some other? much of time file named proc16.inc presented in my package but only in last time there appear code related to 16 bit, all time before there was just a copy of proc32.inc with fragments related to 16bit and much of 32bit rudiments. |
|||
05 Mar 2020, 15:43 |
|
Picnic 06 Mar 2020, 06:25
I remember of a proc16.inc implementation by LocoDelAssembly.
|
|||
06 Mar 2020, 06:25 |
|
ProMiNick 06 Mar 2020, 08:31
locals could make stack misaligned on 2 byte boundary (maybe it is problem or maybe not).
callbacks couldn`t be realized this way because they use retf as return not ret. calling conventions are too modern (windows native calling convention for 16 bit is pascal, not cdecl or stdcall) - reserving params don`t looks like a problem. nice date of publishing - far 2006. |
|||
06 Mar 2020, 08:31 |
|
DimonSoft 06 Mar 2020, 11:09
The author’s proc16.inc file must be fine. As far as I can guess, seems to be one of my university students as the program closely resembles the example I use in my lectures and TechHelp version is the one I share. As well as proc16.inc. Triple-checked in multiple pet projects.
Nice to see some students try to move further themselves. Hope to see a cool demo at the end of the year |
|||
06 Mar 2020, 11:09 |
|
ProMiNick 06 Mar 2020, 17:36
DimonSoft, I'm a bit jealous that thou have thour own students and they are interested in assembler.
As thou I glad every time when I founding interesting demo. Hope It would be demonstration of one more technology never presented on forum before. |
|||
06 Mar 2020, 17:36 |
|
DimonSoft 07 Mar 2020, 09:27
I wouldn’t expect too much since it’s a starter’s course. But the goal set up is pretty ambitious.
|
|||
07 Mar 2020, 09:27 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.