如何在我的Turbo Basic程序中包含ASM程序? [英] How can I include a ASM program into my Turbo Basic Program?

查看:54
本文介绍了如何在我的Turbo Basic程序中包含ASM程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了这个ASM例程来按下键.

非常感谢以下迈克尔·佩奇先生的回答.此外,我可以看到该ASM例程也是解决方案

您可以使用 DEBUG.COM 输入汇编代码,然后执行十六进制转储以获取机器代码.

它看起来像这样:

  D:\>调试-A 1000ABD:0100 IN AL,600ABD:0102 XCHG DX,AX0ABD:0103 XOR AX,AX0ABD:0105测试DL,800ABD:0108 JNZ 10C0ABD:010A MOV AL,DL0ABD:010C RET0ABD:010D-R CXCX 0000:D-N KEY.COM-W写入000D字节-QD:\>十六进制KEY.COM00000000 E4 60 92 31 C0 F6 C2 80 75 02 88 D0 C3 ..1 .... u ....D:\> 

因此,现在您可以使用 $ INLINE 封装每个机器代码.

  $ INLINE& HE4,& H60,& H92,& H31,& HC0,& HF6,& HC2,& H80,& H75,& H02,&H88和HD0 

如@Michael Petch所建议,请勿在您的 $ INLINE 元陈述中包括最后一个机器代码(& HC3 ).

注意:虽然 HEXDUMP.EXE 是我自己的程序,但您可以轻松地在Internet上找到任何可用的十六进制编辑器来查看二进制文件的内容.

I found this ASM routine to get the key pressed. ASM routine to get key pressed Now I would like to include it to a Turbo Basic routine, but do not know how to do this. Can anyone here tell me how it is be done? THanks

EDIT: I found a way: $INLINE, but How can I convert my asm code to Machine Language, that I can inline it into my basic program?

EDIT: I had no success in putting this QBASIC with Asm Code in it into an TURBO BASIC Program. I would be thankful for any help how to do it:

DECLARE FUNCTION GetKeyH% ()

CLS
DO
  LOCATE 10, 10
  PRINT "Key = "; HEX$(GetKeyH%); "    "
LOOP UNTIL INKEY$ = CHR$(27)
END

and the ASM PART:

Dosseg
.model medium, basic
.286
.stack
.code
Even
           public    getkeyh            ; make getkeyh public
getkeyh    proc far basic uses bp dx    ; save registers

           in   al,60h
           xchg dx,ax
           xor  ax,ax                   ; assume no key
           test dl,10000000b
           jnz  short getkeyhD
           mov  al,dl
getkeyhD:  ret
getkeyh    endp                         ; end of procedure
           end                          ; end of assembly code

EDIT: THANKS a lot to the Answer of Mr Michael Petch below. Moreover I could see that this ASM routine is also a solution to CTL and ALT KEYS pressed

解决方案

You can use DEBUG.COM to enter the Assembly code, then perform a hexadecimal dump to get the machine code.

It looks like this:

D:\>DEBUG
-A 100
0ABD:0100 IN AL,60
0ABD:0102 XCHG DX,AX
0ABD:0103 XOR AX,AX
0ABD:0105 TEST DL,80
0ABD:0108 JNZ 10C
0ABD:010A MOV AL,DL
0ABD:010C RET
0ABD:010D
-R CX
CX 0000  :D
-N KEY.COM
-W
Writing 000D bytes
-Q

D:\>HEXDUMP KEY.COM
00000000    E4  60  92  31  C0  F6  C2  80  75  02  88  D0  C3                  .`.1....u....

D:\>

So that now you can encapsulate each machine code with $INLINE.

$INLINE &HE4, &H60, &H92, &H31, &HC0, &HF6, &HC2, &H80, &H75, &H02, &H88, &HD0 

As suggested by @Michael Petch, do not include the last machine code (&HC3) in your $INLINE metastatement.

Note: While HEXDUMP.EXE is my own program, you can easily find any hex editor available on the Internet to view the content of a binary file.

这篇关于如何在我的Turbo Basic程序中包含ASM程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆