Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
172 views
in Technique[技术] by (71.8m points)

assembly - How to Solve 'bootloader.asm:30: error: TIMES value -44 is negative' Problem in NASM

I'm developing a Hello World kernel and bootloader...I wrote this code but when I try to compile it via NASM It says : "bootloader.asm:30: error: TIMES value -44 is negative".

bootloader.asm:

    [BITS 16]
[ORG 0x7C00]

MOV DL, 0x80
MOV DH, 0x0 
MOV CH, 0x0 
MOV CL, 0x02 
MOV BX, 0x1000 
MOV ES, BX 
MOV BX, 0x0 

ReadFloppy:
MOV AH, 0x02
MOV AL, 0x01
INT 0x13
JC ReadFloppy 


MOV AX, 0x1000
MOV DS, AX
MOV ES, AX
MOV FS, AX
MOV GS, AX
MOV SS, AX

JMP 0x1000:0x0



TIMES 510 - ($ - $$) db 0 
DW 0xAA55

kernel.asm:

MOV AH, 0x0E 
MOV BH, 0x00 
MOV BL, 0x07 

MOV SI, msg 
CALL PrintString 

JMP $ 

PrintString:
nextch:
MOV AL, [SI] 
OR AL, AL
JZ exit 
INT 0x10 
INC SI 
JMP nextch
RET

exit:
RET

msg db 'Hello world from the kernel!', 13, 10, 0

TIMES 512 - ($ - $$) db 0 

I used; nasm -f bin bootloader.asm -o bootloader.bin -p kernel.asm

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...