x86-16

8086 listen to keyboard while drawing

半世苍凉 提交于 2019-12-14 02:29:30
问题 I'm familiar with INT 16h that waits for keyboard input, but I'm developing a game and I would like there to be a game loop, that animates things on the screen, and whenever there is a keyboard hit, the 8086 should go to my interrupt handler and tell me which key has been pressed to update my data accordingly. How could I do so ? 回答1: You can also poll for input with 1 in AH instead of 0, when calling INT 16. INT 16h / AH = 01h - check for keystroke in the keyboard buffer. return: ZF = 1 if

Error while reversing string in 8086

自作多情 提交于 2019-12-13 21:19:57
问题 I have this code to reverse a string using 8086 ALP. But the code does not work as intended and gets into a infinite loop or prints some random charecter. .model small .stack 100h .data String1 DB "Assembly Language Program$" Length dw $-String1-1 .code Main proc MOV AX, @data MOV DS, AX MOV SI, Offset String1 MOV CX, Length ADD SI, CX Back: MOV DL, [SI] MOV AH, 02H INT 21H DEC SI LOOP Back MOV AH, 4CH INT 21H Main endp End main 回答1: You code has 2 issues: $ stands for "the offset of the

Large binary shifts in 8086 assembly?

六月ゝ 毕业季﹏ 提交于 2019-12-13 16:07:05
问题 I have a binary chunk of data 512 bytes long, I was wondering what the most efficient way would be if I wanted to shift it once to the right. My best guess right now (very new to assembly) would be that I would have to first check a chunk (probably int) to see what it would shift out, shift, then carry in whatever the previous int would have shifted out and proceed carrying this shift down the data. Is there an easier way? If I have to use this carry technique, what's the largest chunk I can

How to copy 9th sector to 1st sector?

北城余情 提交于 2019-12-13 16:05:39
问题 I'm creating custom mbr, something like mbr-lovenote and i can't create code that will copy 9th sector - (there is located original mbr) to 1st sector, i already tried take some code from mbr-lovenote and modify it, but i find out that code only load sector in memory and jump to it, but i have to copy it. I write my code, the code will be loaded from fist sector on PhysicalDrive0 , but i don't know why it doesn't works. ;---create buffer buffer db 512 ;---read sector - 9th mov ax, buffer ;ES:

DIV instruction jumping to random location?

安稳与你 提交于 2019-12-13 15:17:45
问题 So I am having this exact problem. The solution given is to zero out DX , but in my case it already is! My program is to simply divide a 16 bit number by an 8 bit number. My code is: data segment num1 dw 0204h num2 db 02h quotient db ? remainder db ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,num1 div num2 mov quotient,al mov remainder,ah mov ah,4ch int 21h code ends end start Any solution? 回答1: You badly need to start using whitespace to separate your

Multiply two unsigned 16 bit values, without using multiply or divide instructions [8086 Assembly]

独自空忆成欢 提交于 2019-12-13 14:23:15
问题 I'm currently working on an assignment, where I write a subroutine where 2 unsigned numbers get multiplied and yield a result in the DX:AX pair. But i cannot use the instructions mul, imul, div, and idiv. When i run my code, the bottom half (the AX register) is always correct, but the DX register is not. Can anyone point me in the right direction as to what I am doing wrong? ;----------------------------------------------------------- ; ; Program: MULTIPLY ; ; Function: Multiplies two 16 bit

I don't understand why my program isn't working

坚强是说给别人听的谎言 提交于 2019-12-13 11:24:22
问题 I am trying to write a code that read and write text file with interrupt 21h. here is my code: IDEAL MODEL small STACK 100h DATASEG filename db 'testfile.txt',0 filehandle dw ? Message db 'Hello world!' ErrorMsg db 'Error', 10, 13,'$' CODESEG proc OpenFile ; Open file for reading and writing mov ah, 3Dh mov al, 2 mov dx, offset filename int 21h jc openerror mov [filehandle], ax ret openerror: mov dx, offset ErrorMsg mov ah, 9h int 21h ret endp OpenFile proc WriteToFile ; Write message to file

16-bit Assembly: cannot deref some registers

核能气质少年 提交于 2019-12-13 10:36:39
问题 I'm trying the following Intel 16 bit instruction: mov si, word [reg] where reg is some register. It compiles fine if reg is bx , but does not when it is ax , cx or dx . I'm using NASM as my assembler. I'm sure this due to some restrictions in the instruction set. Can some one please explain the restriction and the rationale behind it? 回答1: Only the following index registers can be used with 16 bit addressing modes: bx si di bp bx + si bx + di bp + si bp + di Likewise, SIB addressing is not

Assembly equation, Divide to get float value

∥☆過路亽.° 提交于 2019-12-13 09:23:12
问题 I have to do this equation in assembly (3*a-b/a)*(d+3) and i have with problem dividing b/a (10/20) the result should be 0.5 but I get 0. I really don't know how I could do it. My assignment is to fix the syntactical and logical errors in this given code: ;=============================================================================; ; ; ; File : arch1-2e.asm ; ; Format : EXE ; ; Assignment : Compilation, consolidation and debugging of assembly ; ; language programs ; ; Comments : The program

Compact implementation of logical AND in x86 assembly [closed]

橙三吉。 提交于 2019-12-13 09:15:10
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . Hi , x86 assembler geeks! I have an interesting problem to test your assembler programming skills. I'm the author of this problem, so I know the correct answer. Your task is to implement logical AND in x86 assembly and satisfy the following 5 conditions: Condition #1 Boolean values are encoded in 16-bit words in