我正在编写一个二级引导程序 这是我的boot.asm
import json
features = data["features"]
point_handle_text = {
i["properties"]["EntityHandle"]: i["properties"]["Text"]
for i in features
if i["geometry"]["type"] == "Point"
}
combine_features = []
for i in features:
if i["geometry"]["type"] == "LineString":
i["properties"]["Text"] = point_handle_text.get(i["properties"]["EntityHandle"])
combine_features.append(i)
data["features"] = combine_features
print(data)
{
'type': 'FeatureCollection',
'name': 'entities',
'features': [{
'type': 'Feature',
'properties': {
'Layer': '0',
'SubClasses': 'AcDbEntity:AcDbBlockReference',
'EntityHandle': '33C',
'Text': 'HouseID: B6G31; Area: 143'
},
'geometry': {
'type': 'LineString',
'coordinates': [
[128.30069876369856, 19.589569788550868],
[122.21045961023306, 19.589569886701838],
[91.72173671060479, 50.1930739634195],
[92.27371017252334, 50.74297719953902],
[84.75859656427339, 58.28638302549696],
[77.21519073831544, 50.77126941724701],
[77.76711130961861, 50.22141886736856],
[47.2501493852178, 19.589569788550868],
[44.19358734894194, 22.63466787268287],
[79.04684685278335, 57.61913923559142],
[79.04684685278335, 59.23260037240937],
[84.75166060397453, 64.91601778815193],
[90.41376187014976, 59.23260037240937],
[90.41376187014976, 57.61913923559142],
[128.30069876369856, 19.589569788550868]
]
}
},
{
'type': 'Feature',
'properties': {
'Layer': '0',
'SubClasses': 'AcDbEntity:AcDbBlockReference',
'EntityHandle': '33D',
'Text': 'HouseID: B622; Area: 31; Type: B'
},
'geometry': {
'type': 'LineString',
'coordinates': [
[74.6823103587667, 53.238171737765796],
[79.04684685278335, 57.61913923559142],
[79.04684685278335, 59.23260037240937],
[81.6956604878942, 61.8913860732074],
[75.42085500169195, 68.1426574998851],
[67.60077999639907, 60.29314230022384],
[74.6823103587667, 53.238171737765796]
]
}
}
]
}
和boot2.asm
[org 0x7c00]
[bits 16]
xor ax, ax
mov ds, ax
mov es, ax
xor bx, bx
mov ah, 0x0E
mov al, 'A'
int 0x10
jmp 0x8000
cli
hlt
times 510 - ($-$$) db 0
dw 0xAA55
我使用
进行编译[org 0x8000]
[bits 16]
xor ax, ax
mov ds, ax
mov es, ax
xor bx, bx
mov ah, 0x0E
mov al, 'B'
int 0x10
它编译时没有任何错误或警告。 但是如何将阶段2设置为0x8000,并链接阶段1和阶段2以便一起工作?
答案 0 :(得分:1)
但是我如何将阶段2设置为0x8000 ...
不幸的是,我没有使用“ masm”而是其他汇编程序。但我希望您必须将[org 0x7e00]
更改为[org 0x8000]
。
...并链接stage1和stage2一起工作?
那并不像您想的那么容易:
BIOS将在0x7C00处将一个扇区(510字节加2字节0xAA55
)加载到内存中。使用普通的BIOS,不可能加载更多数据!
这510个字节(“阶段1”)中的代码必须将“状态2”加载到内存中:它可以使用ah=2
的功能ah=0x42
或int 0x13
这样。
如果您有自己的软盘格式,这很简单:
您将“ stage 2”存储在软盘的第二个扇区中,并加载第二个扇区。
如果您要从文件系统(例如,从FAT格式的磁盘中的文件)中加载“阶段2”,则比较棘手。
答案 1 :(得分:1)
您可能正在询问如何将第一阶段和第二阶段合并到一个文件中。如果是这样的话:
上
Linux:
cat boot.bin boot2.bin > final_file.file_format
开启 Windows:
copy /b boot.bin+boot2.bin final_file.file_format
要从引导加载程序加载第二阶段,可以使用以下代码:
mov ah, 0x02 ; Read disk BIOS call
mov cl, 0x02 ; sector to start reading from
mov al, 1 ; number of sectors that will be read (modify if your second stage grows)
mov ch, 0x00 ; cylinder number
mov dh, 0x00 ; head number
xor bx, bx
mov es, bx ; ES=0x0000
mov bx, 0x8000 ; ES:BX(0x0000:0x8000) forms complete address to read sectors to
; DL should contain the boot disk number passed to the bootloader by the BIOS
int 0x13 ; Make BIOS disk services call (Int 0x13/AH=2) to read sectors
; For simplicity assume the disk read was successful
jmp 0x0000:0x8000 ; FAR JMP to second stage and ensure CS=0x0000
; since CS is not guaranteed to be 0x0000 when control is transferred
; to our bootloader