8086我与大会阵列/ O [英] 8086 Assembly Arrays with I/O

查看:94
本文介绍了8086我与大会阵列/ O的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想,如果有可能的redifine数组的大小或者简单地说,创建一个新的通过code段。这是我到目前为止有:

  .DATA
PROMPT1 DB请输入一个数字,这将ressemble数组的N,13,10,$
值分贝?。code
DisplayIO PROC
LEA DX,PROMPT1
MOV AH,09H
INT 21H
MOV AH,08H
INT 21H
RET
DisplayIO ENDP
调用DisplayIO
子AL,30H
MOV价值,AH

我试图做的,基本上是创建一个值的大小的数组


解决方案

在DOS下可以使用系统调用(的 INT 21H啊= 0x48 )保留所选大小的段(所有段是16字节的倍数)。还记得释放与INT 21H块啊= 0x49。


  

INT 21,48 - 分配内存结果
      AH = 48小时结果
      BX =内存段数量要求


 的回报:
分配的内存块的AX =段地址(MCB + 1para)
   =错误code如果CF集(见DOS ERROR codeS)
在可用的最大内存块的第BX =大小
     如果CF设置和AX = 08(没有足够的存储器)
CF = 0,如果成功
   = 1,如果错误
- 返回分配的内存块的AX段地址:0000
- 每个分配需要用于MCB一个16字节的开销
- 返回最大块大小可如果错误

或者你也可以静态分配从code /数据的最大长度的缓冲区,并建立自己的malloc。

I was wondering if it's possible to redifine the size of an array or simply, create a new one through the Code Segment. Here's what I have so far:

.DATA
prompt1 db "Please enter a number which will ressemble the N of the array",13,10,'$'
value db ?

.CODE
DisplayIO proc
lea DX, prompt1
mov AH, 09h
int 21h
mov AH, 08h
int 21h
ret
DisplayIO endP
call DisplayIO
sub AL, 30h
mov value, AH

What I'm trying to do, is basically create an array with the size of value

解决方案

In DOS you can use a system call (int 21h, ah = 0x48) to reserve a segment of your selected size (all segments are multiples of 16 bytes). Also remember to free the block with int 21h, ah=0x49.

INT 21,48 - Allocate Memory
AH = 48h
BX = number of memory paragraphs requested

on return:
AX = segment address of allocated memory block (MCB + 1para)
   = error code if CF set  (see DOS ERROR CODES)
BX = size in paras of the largest block of memory available
     if CF set, and AX = 08 (Not Enough Mem)
CF = 0 if successful
   = 1 if error


- returns segment address of allocated memory block AX:0000
- each allocation requires a 16 byte overhead for the MCB
- returns maximum block size available if error

Or you can statically allocate the maximum length buffer from code/data and build your own malloc.

这篇关于8086我与大会阵列/ O的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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