Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 程序集从扇区加载程序并返回_Assembly_X86_Dos - Fatal编程技术网

Assembly 程序集从扇区加载程序并返回

Assembly 程序集从扇区加载程序并返回,assembly,x86,dos,Assembly,X86,Dos,我正在做一个系统编程作业,但面临一个小问题 我已经设法写了我的引导扇区,并且能够调用另一个扇区,我已经使用INT13读取了该扇区。执行所有指令,代码返回引导扇区 但我无法访问在第二个扇区中声明的变量,以便在第二个扇区中使用 这是密码 [bits 16] [org 0x7c00] mov ah,2 mov al,1 ;Number of sectors to read mov ch,0 ;Cylinder number (10 bit value; upper 2 bits in

我正在做一个系统编程作业,但面临一个小问题

我已经设法写了我的引导扇区,并且能够调用另一个扇区,我已经使用INT13读取了该扇区。执行所有指令,代码返回引导扇区

但我无法访问在第二个扇区中声明的变量,以便在第二个扇区中使用

这是密码

[bits 16]
[org 0x7c00]

mov ah,2  
mov al,1    ;Number of sectors to read
mov ch,0    ;Cylinder number (10 bit value; upper 2 bits in CL)
mov cl,2    ;Starting sector number
mov dh,0    ;Head number
mov dl,0    ;Drive number

mov bx,cs
mov es,bx
mov bx,here

int 13h

jc error

call here


error:
 mov ah,0eh
 mov al,'E'
 mov bl,7
 mov bh,0
 int 10h
 jmp $

exit:
 mov ah,0eh
 mov al,'F'
 mov bl,7
 mov bh,0
 int 10h
 jmp $

here:


jmp $




times 510 - ($-$$) db 0
dw 0xaa55
Sector2.asm

[bits 16]

mov bx,cs
mov ds,bx

jmp start

msg db "Welcome to my OSD",0

start:

mov si,0
mov si,msg

mov ah,0eh
mov al,':'
int 10h

mov ah,0eh
mov al,[si] ;; HERE IS THE PROBLEM IT PRINTS GARBAGE 
int 10h
inc si
mov ah,0eh
mov al,[si]  ;; HERE IS THE PROBLEM IT PRINTS GARBAGE 
int 10h
inc si
mov ah,0eh
mov al,[si]  ;; HERE IS THE PROBLEM IT PRINTS GARBAGE 
int 10h


ret





times 510-($-$$) db 0
dw 0x0055

为了让Nasm计算
msg
的正确地址,需要告诉它一个
org
,对应于代码实际加载的位置。您似乎正在将其加载到“同一段”(假定为0)和偏移量
<代码>此处
将随着代码的更改而变化。如果你把
放在这里:
标签放在最末端,在启动信号之后,怎么样?然后它将位于一个已知的偏移量0x7E00,您可以
org
将第二个文件添加到该偏移量。我想那会管用的。如果您真的需要在“工作代码”之后加载第二个扇区,则必须计算该偏移量,并将
org
第二个文件加载到该扇区