x86-16

Print numbers diagonally in assembly

做~自己de王妃 提交于 2019-11-28 11:46:40
问题 I'm trying to display 0-9 diagonally in assembly, but the output puts my diagonally printed numbers in the middle of the window. Here is the code: start: mov ah, 02h mov cl, 0Ah ;counter (10) mov dx, 02h ;mov bx, 02h mov dl, 30h ;start printing 0-9 mov dh, 02h ;start row mov al, 02h int 21h again: int 10h int 21h ;add dx, 01h inc dh inc dx inc al loop again mov ax, 4c00h int 21h The output should be: 0 1 2 3 4 5 6 7 8 9 The current output prints that, but on the middle of the window. I've

The controls of my game freeze after the first keypress with int 16h / ah=1

旧街凉风 提交于 2019-11-28 09:21:39
问题 I am coding a game in assembly 8086. I fixed the issue when the game didn't open, but I can't fix the controls. The ESC key works. When I press it, it goes to _QUIT function, but if any other key was pressed before that, the controls freeze and don't react on any key. Is there something wrong with my function? I tried to change the AL register to AH , but it didn't work. _KEYCHECK: mov ah,01h int 16h cmp al,1Bh ;ESC je _QUIT cmp al,48h ;UP je _PLAYER.UP cmp al,50h ;DOWN je _PLAYER.DOWN cmp al

X86 IDIV sign of remainder depends on sign of dividend for 8/-3 and -8/3?

主宰稳场 提交于 2019-11-28 08:49:13
问题 Can anyone explain for me why the sign of the remainder is different in these cases? Is this an emulator bug or do real CPUs do this, too? 8 / -3 : quotient(AL) = -2 remainder(AH) = 2 -8 / 3 : quotient(AL) = -2 remainder(AH) = -2 回答1: It is supposed to work that way, though it is tricky to find out by reading the documentation: Non-integral results are truncated (chopped) towards 0. Combined with the "division law" X = dq + r (the dividend is the divisor times the quotient plus the remainder)

A2004 Problem With MASM32

烈酒焚心 提交于 2019-11-28 06:38:17
问题 I have a problem with the MASM32 assembler The following code is a Hello World example that I copied from the MASM32 tutorial: .model small .stack .data message db "Hello world!", "$" .code _main proc mov ax,seg message mov ds,ax mov ah,09 lea dx,message int 21h mov ax,4c00h int 21h _main endp end _main On attempt to assemble, MASM32 throws A2004 error with the following comment: C:\masm32\console.asm(11) : error A2004: symbol type conflict Can anyone help me with that? This code worked

Bootloader works in emulators but not on real hardware

烈酒焚心 提交于 2019-11-28 05:56:29
问题 I am writing a bootloader in assembly and it seems to work fine on qemu, bochs and virtualbox. However, it is not loading the kernel on real hardware (it seems). The bootloader starts off by writing a character to the video memory (for debugging), it then reads sector 2 off the drive and far jumps to the kernel. The kernel is then writing some characters to video memory. On a real machine, I see the character from the bootloader on the screen, and there it hangs (blinking caret). I have tried

divide emu 8086 assembly error [duplicate]

情到浓时终转凉″ 提交于 2019-11-28 05:41:20
问题 Possible Duplicate: ASM x86 integer overflow I get a divide error- overflow and am not sure why. Here is the complete code that reproduces the error include emu8086.inc org 100h mov ax, 2 mov bx, 10 div bx mov ax, 2 mov bx, 2 div bx ret 回答1: Try adding xor dx, dx before each div and see if that doesn't help. Since you're specifying a 16-bit target, div divides dx:ax by that target. If dx starts out containing a large number (more accurately, anything but quite a small number), the result will

How can linux boot code be written in C?

不打扰是莪最后的温柔 提交于 2019-11-28 03:22:59
问题 I'm a newbie to learning OS development. From the book I read, it said that boot loader will copy first MBR into 0x7c00, and starts from there in real mode. And, example starts with 16 bit assembly code. But, when I looked at today's linux kernel, arch/x86/boot has 'header.S' and 'boot.h', but actual code is implemented in main.c. This seems to be useful by "not writing assembly." But, how is this done specifically in Linux? I can roughly imagine that there might be special gcc options and

Is it possible to manipulate the instruction pointer in 8086 assembly?

六眼飞鱼酱① 提交于 2019-11-28 02:29:44
I want to know if I can manipulate (read and change the value of) the instruction pointer (IP) in 8086 assembly. For example, Say IP is currently storing 0200h . I would like to read this value and change it to something else, say 4020h . How could I do that? If you wanted to set the instruction pointer to a known value, say hex value 4020h, you could jump directly to that address: jmp 4020h Or if some memory location, myVariable , held the value you wanted to store in IP you could do an indirect jump: jmp [myVariable] The result of a jmp (indirect or direct) modifies the instruction pointer.

Random number in assembly

落爺英雄遲暮 提交于 2019-11-28 02:07:05
I am new to assembly and would like to know how to write a program in EMU8086 that prints a different random number in every run of it. Is it possible to do it without using interrupts? If you were using a real version of DOS (not EMU8086) @fuz method is the way you can do it, and it doesn't require interrupts. You just read the lower 16-bits of the 32-bit value at memory address 0x46c (0x00040:0x006c) in the BIOS Data Area (BDA). The value at that location is a 32-bit value representing the number of timer ticks since midnight. Unfortunately EMU8086 doesn't support this method. To get a

Calculating padding length with GAS AT&T directives for a boot sector?

♀尐吖头ヾ 提交于 2019-11-28 02:03:36
So I want to add padding in the bootsector. Let's say, there is currently just an endless loop in there: jmp . . The sector needs to be 512 bytes long. Also, the magic num 0xaa55 is needed which is added at the end. jmp . .skip 508, 0 .word 0xaa55 But what if I want to print something but don't want to count all the bytes to pad it into the right size? In Intel/NASM syntax would it be: ; print something times 510-($-$$) db 0 dw 0xaa55 But in AT&T syntax? Well a loop ( .rept ) doesn't work here because . doesn't give an absolute value which is needed here. We have the same problem with .skip /