Recent Posts

Pages: 1 [2] 3 4 ... 10
11
Sorry, but I do not understand. Can you explain me why it is so. The subtraction realized by addition to twos complement value. Isn't it?
12
Hi Danny,

Welcome to the forum.

Hello. I try to compare the next expressions:

1)
    mov al, 4
    mov bl, 12
    sub al, bl ; CF == 1

    0000 0100 (4)
   +
    1111 0100 (-12)

But that isn't what you're doing.

0000 1100 (12)

Subtracting that sets the carry flag. Adding -12 does not.

Best,
Frank

.




13
Programming with NASM / What is the difference between “4 - 12” and “4 + (-12)”?
« Last post by danny on November 20, 2020, 11:33:45 PM »
Hello. I try to compare the next expressions:

1)
    mov al, 4
    mov bl, 12
    sub al, bl ; CF == 1

    0000 0100 (4)
   +
    1111 0100 (-12)
   =
    1111 1000 (-8 == 248)

2)
    mov al, 4
    mov bl, -12
    add al, bl ; CF == 0

    0000 0100 (4)
   +
    1111 0100 (-12)
   =
    1111 1000 (-8 == 248)

The results are identical, but carry flags are not. Why? The subtraction realized by addition to twos complement value.
14
Using NASM / Re: How to combine two bin files together into single bin file on windows ?
« Last post by gomi on November 20, 2020, 11:33:43 PM »
Oh of course, I found "type" command on windows for this purpose and got my floppy.bin as a result.

15
It is not NASM's job to combine files. Do it with an editor or OS utility. I seriously doubt if this is what you want to do! Let's discuss this further... or try it and see what happens...

Best,
Frank

16
Do you mean boot sector or first stage OS loader when you say boot loader? If you mean boot sector, it's simpler to to load the other file from you boot sector.
17
Using NASM / How to combine two bin files together into single bin file on windows ?
« Last post by gomi on November 20, 2020, 10:44:58 PM »
I want to combine my first boot loader and second stage loader into one file, how can I achieve it with NASM winx64 ?
18
Using NASM / Re: Error message on windows: fatal: unable to open output file (?)
« Last post by debs3759 on November 20, 2020, 07:44:54 PM »
If/when you want to expand on your bootsector, you might find my sample boot sector useful. It can be found at https://forum.nasm.us/index.php?topic=2265.0 and is FAT12 only (should be simpler to write one that can read your OS loader off other file systems). It can read whatever loader you code into it, and if your loader sets up 32 or 64 bit modes it can be any size. It can even cope with fragmented code :)
19
Using NASM / Re: Error message on windows: fatal: unable to open output file (?)
« Last post by gomi on November 20, 2020, 07:19:15 PM »
Alright I found an answer for myself, compiler needs a compatible code for itself, I searched and found the compatible code

Source: https://medium.com/@g33konaut/writing-an-x86-hello-world-boot-loader-with-assembly-3e4c5bdd96cf

nasm compatible code:

Code: [Select]
[bits 16] ; use 16 bits
[org 0x7c00] ; sets the start address
init:
  mov si, msg ; loads the address of "msg" into SI register
  mov ah, 0x0e ; sets AH to 0xe (function teletype)
print_char:
  lodsb ; loads the current byte from SI into AL and increments the address in SI
  cmp al, 0 ; compares AL to zero
  je done ; if AL == 0, jump to "done"
  int 0x10 ; print to screen using function 0xe of interrupt 0x10
  jmp print_char ; repeat with next byte
done:
  hlt ; stop execution
msg: db "Hello world!", 0 ; we need to explicitely put the zero byte here
times 510-($-$$) db 0 ; fill the output file with zeroes until 510 bytes are full
dw 0xaa55 ; magic number that tells the BIOS this is bootable

I got my boot.bin without error now.

Thanks.
20
Using NASM / Re: Error message on windows: fatal: unable to open output file (?)
« Last post by gomi on November 20, 2020, 06:50:55 PM »
Thank you, I changed my path to desktop and run command line as Admin. Now I got another issue  ;D ===> "boot.asm:18: error: parser: instruction expected"

Here is my code which is an example code I got:

Code: [Select]
;org 0x7C00                      ; BIOS loads our programm at this address
;bits 16                         ; We're working at 16-bit mode here

start:
cli                     ; Disable the interrupts
mov si, msg             ; SI now points to our message
mov ah, 0x0E            ; Indicate BIOS we're going to print chars
.loop lodsb                   ; Loads SI into AL and increments SI [next char]
or al, al               ; Checks if the end of the string
jz halt                 ; Jump to halt if the end
int 0x10                ; Otherwise, call interrupt for printing the char
jmp .loop               ; Next iteration of the loop

halt: hlt                     ; CPU command to halt the execution
msg: db "Hello, World!", 0   ; Our actual message to print

;; Magic numbers
times 510 – ($ – $$) db 0
dw 0xAA55
Pages: 1 [2] 3 4 ... 10