程序为运行汇编时创建数据
Create data when the program is running assembly
嗯,问题很简单:如何在代码中为数据分配space。
我尝试执行以下操作:
ReadArrayLength PROC
pusha
messageArrayLength db "Enter the number of the bytes in array: $"
mov dx, OFFSET messageArrayLength
mov ah, 09h
int 21h
popa
ret
ENDP
但是当我调试程序并调用这个过程时,我的涡轮汇编器卡住了。有什么方法可以创建新的数据字段并对其进行操作吗?
这里最简单的解决方案似乎是跳过数据:
ReadArrayLength PROC
pusha
jmp @@1
messageArrayLength db "Enter the number of the bytes in array: $"
@@1:
mov dx, OFFSET messageArrayLength
mov ah, 09h
int 21h
popa
ret
ENDP
在汇编代码中嵌入数据的标准方式是:
some_proc proc near
call @after_data ; <-- store on the stack the return address
@return_address: ; it will point exactly here
db 'String',0 ; a string
db 0FFh,0FEh ; array of bytes
dd 0ABBAh ; DWORD
@after_data:
pop dx ; pop the return address from the CALL
; dx = offset @return_address
...
some_proc endp
这也会创建与偏移量无关的代码。
嗯,问题很简单:如何在代码中为数据分配space。
我尝试执行以下操作:
ReadArrayLength PROC
pusha
messageArrayLength db "Enter the number of the bytes in array: $"
mov dx, OFFSET messageArrayLength
mov ah, 09h
int 21h
popa
ret
ENDP
但是当我调试程序并调用这个过程时,我的涡轮汇编器卡住了。有什么方法可以创建新的数据字段并对其进行操作吗?
这里最简单的解决方案似乎是跳过数据:
ReadArrayLength PROC
pusha
jmp @@1
messageArrayLength db "Enter the number of the bytes in array: $"
@@1:
mov dx, OFFSET messageArrayLength
mov ah, 09h
int 21h
popa
ret
ENDP
在汇编代码中嵌入数据的标准方式是:
some_proc proc near
call @after_data ; <-- store on the stack the return address
@return_address: ; it will point exactly here
db 'String',0 ; a string
db 0FFh,0FEh ; array of bytes
dd 0ABBAh ; DWORD
@after_data:
pop dx ; pop the return address from the CALL
; dx = offset @return_address
...
some_proc endp
这也会创建与偏移量无关的代码。