我开始学习汇编语言。我只想澄清一件事:
通过调试改变数据会导致我的操作系统/应用程序失败吗?
我已经通过cmd运行调试并完成了E命令
E 100
在这里,我使用space
来查看存储在这些位置的内存中的内容:
0B79:0100 BE. 90. 02. ... etc
覆盖这些内存空间会导致当前正在运行的系统出错吗?
启动时,Debug将65k字节的内存分配为工作空间,前100个字节为PSP。我的问题可能更直接:
我正在查看未分配内存的工作空间,或os /应用程序正在使用的内存。
再次请原谅我的新手,这毕竟是我对汇编语言的看法。
答案 0 :(得分:0)
我认为它是64 KB未分配的内存段。 通过调试,我们可以简单地构建* .com应用程序,但通常不是* .exe。
使用汇编程序,我们可以构建* .exe应用程序。 在* .exe中,我们可以以固体形式保留一个代码段,一个数据段和一个堆栈段。 如果DOS应用程序正在启动,那么DOS会将所有可用内存提供给应用程序,但是我们不知道有多少内存段是免费的,并且位于该地址上。 为了分配更多内存,我们可以在第一步中释放所有未使用的内存,在第二步中我们可以分配更多的内存。
SETFREE: mov bx, ss ; Using for *.exe:
mov ax, es ; calculating the number of paragraps from
sub bx, ax ; the PSP to the beginning of the stack
mov ax, sp ; + adding the length of the stack
add ax, 0Fh
shr ax, 4
add bx, ax
mov ah, 4Ah
int 21h
ret
;---------------------------------------------------------------------------
GETSPACE: mov ah, 48h ; BX = number of paragraphs
int 21h
ret ; Return: AX = segment
RBIL-> inter61b.zip-> INTERRUP.G
--------D-2148-------------------------------
INT 21 - DOS 2+ - ALLOCATE MEMORY
AH = 48h
BX = number of paragraphs to allocate
Return: CF clear if successful
AX = segment of allocated block
CF set on error
AX = error code (07h,08h) (see #01680 at AH=59h/BX=0000h)
BX = size of largest available block
Notes: DOS 2.1-6.0 coalesces free blocks while scanning for a block to
allocate
.COM programs are initially allocated the largest available memory
block, and should free some memory with AH=49h before attempting any
allocations
under the FlashTek X-32 DOS extender, EBX contains a protected-mode
near pointer to the allocated block on a successful return
SeeAlso: AH=49h,AH=4Ah,AH=58h,AH=83h
--------D-2149-------------------------------
INT 21 - DOS 2+ - FREE MEMORY
AH = 49h
ES = segment of block to free
Return: CF clear if successful
CF set on error
AX = error code (07h,09h) (see #01680 at AH=59h/BX=0000h)
Notes: apparently never returns an error 07h, despite official docs; DOS 2.1+
code contains only an error 09h exit
DOS 2.1-6.0 does not coalesce adjacent free blocks when a block is
freed, only when a block is allocated or resized
the code for this function is identical in DOS 2.1-6.0 except for
calls to start/end a critical section in DOS 3.0+
SeeAlso: AH=48h,AH=4Ah
--------D-214A-------------------------------
INT 21 - DOS 2+ - RESIZE MEMORY BLOCK
AH = 4Ah
BX = new size in paragraphs
ES = segment of block to resize
Return: CF clear if successful
CF set on error
AX = error code (07h,08h,09h) (see #01680 at AH=59h/BX=0000h)
BX = maximum paragraphs available for specified memory block
Notes: under DOS 2.1-6.0, if there is insufficient memory to expand the block
as much as requested, the block will be made as large as possible
DOS 2.1-6.0 coalesces any free blocks immediately following the block
to be resized
SeeAlso: AH=48h,AH=49h,AH=83h