[Nasm-devel] Times With a Negative Value Resulted With an Error

Harvey Li haimo.li at icloud.com
Sat Jun 10 19:24:44 PDT 2023


I am using NASM to compile a bootloader that I wrote on a Mac with Ventura 13.5. The compilation resulted the following:

`nasm boot.asm -f bin -o bootsect.bin
boot.asm:58: error: TIMES value -4 is negative`

$ nasm —version
NASM version 2.16.01 compiled on Feb 24 2023

Where the original code is as follows:

`[org 0x7c00] 

KERNEL_OFFSET equ 0x1000

; Enter 8 bits real mode
    mov [BOOT_DRIVE], dl

    mov bp, 0x9000

    mov sp, bp

    mov bx, WELCOME

    call print
    call print_nl

    call load_kernel

%include "8_bits_funcs.asm"
%include "32_bits_funcs.asm"
%include "32_bits_switch.asm"
%include "boot_disk_utils.asm"

[bits 16]

load_kernel:
    mov bx, LOADING_KERNEL
    call print
    call print_nl

    mov bx, KERNEL_OFFSET
    mov dh, 2
    mov dl, [BOOT_DRIVE]
    call disk_load

    ret

[bits 32]
BEGIN_PM:
    mov ebx, ENTER_32_BITS
    call print_str
    call KERNEL_OFFSET
    jmp $


BOOT_DRIVE:
    db 0

WELCOME:
    db 'WELCOME', 0

LOADING_KERNEL:
    db 'Loading BeaconOS Kernel into memory', 0

ENTER_32_BITS:
    db 'Entering 32 Bits Protected Mode...', 0

times 510 - ($ - $$) db 0
dw 0xaa55`

Is there something that I wrote in the code which resulted this error or it is an instruction that is not typically used in NASM anymore?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.nasm.us/archives/nasm-devel/attachments/20230611/30a008fd/attachment.htm>


More information about the Nasm-devel mailing list