Why mov/cmp instead of cmp with two memory operands? [duplicate]

You cannot write cmp low_, high_. For such questions, always refer to the official instruction description, e.g. at https://www.felixcloutier.com/x86/cmp. Note that cmp has forms cmp r/m16, r16, for which the first operand can be either register or memory, and the second must be a register; as well as cmp r16, r/m16 which is the reverse. … Read more

Assembly with %include at the top – Printing Outputs Unexpected Result: just an ” S”

You included stuff at the top of your bootloader, where it will executes first. Instead include extra functions where they aren’t in the main path of execution and are only reached by call. This should work, placing the %include directives where it’s safe to put extra function or data, just like if you were writing … Read more

Jump out of range solutions and how different instructions affect range

The problem with the conditional jump instructions in 16-bit assembler is that they’re limited to +127 or -128 bytes for the offset. 386 introduced the jcc rel16 encoding that is available in 16-bit mode, but only on 386 and later. Different assemblers have different options for enabling 386 instructions in 16-bit code Some also have … Read more

Displaying characters with DOS or BIOS

All of the forementioned functions are unique in what they accomplish, but at first the abundance does seem somewhat exagerated. Int 21h AH=02h Write Character To Standard Output This function interprets the character codes 7 (Beep), 8 (Backspace), 9 (Tab), 10 (Linefeed), and 13 (Carriage return). All other character codes are displayed. Backspace is nondestructive … Read more

8086 random number generator (not just using the system time)?

One simple pseudo random number generator multiplies the current number by 25173, then adds 13849 to it. This value now becomes the new random number. If you started from the system timer like you did (this is called seeding the random number generator), this series of numbers will be random enough for simple tasks! MOV … Read more

What are the segment and offset in real mode memory addressing?

When Intel was building the 8086, there was a valid case for having more than 64KB in a machine, but there was no way it’d ever use a 32-bit address space. Back then, even a megabyte was a whole lot of memory. (Remember the infamous quote “640K ought to be enough for anybody”? It’s essentially … Read more

tech