x86-16

Reading a number using INT 21h (DOS) & 8086 assmebly

南笙酒味 提交于 2019-11-28 01:31:03
I need to prompt to user a msg that tells him to write a number , then I store this number and do some operation on it After searching in INT 21h I found this : INT 21h / AH=1 - read character from standard input, with echo, result is stored in AL. if there is no character in the keyboard buffer, the function waits until any key is pressed. example: mov ah, 1 int 21h The main problem that this only reads one character and represent it as ASCII so If I need to write the number "357" I will read it as 3 , 5 , 7 and this is not my goal . any ideas ? When you managed to get the user input , put

Why doesn't MS-DOS initialize the DS and ES registers?

依然范特西╮ 提交于 2019-11-28 00:24:35
问题 Why does the initialization of the DS and ES registers has to be done manually by the programmer? For example: MOV AX, DTSEG MOV DS, AX On the other hand, the CS and SS registers are initialized by the operating system (in MS-DOS ). Why is this so? 回答1: Because CS and SS registers are essential for program execution in contrast to DS and ES registers which point to user-defined data segments. By default no data is present in the executing program this nothing to initialize the DS and ES with.

Cannot move 8 bit address to 16 bit register

馋奶兔 提交于 2019-11-28 00:22:16
I am trying to assign variable to register here is the code: ORG 100h var1 DB 10 ; var2 DB 20 ; MOV BX,var1 ; error : operands do not match: 16 bit register and 8 bit address RET END But if swap the 4th line with: MOV BL, var1; it works. So my question is why can’t I move 8 bit variable into much larger 16 bit register ? I have already referred this , this and this OP but it does not answer my question. NOTE: I am using emu8086 assembler I am new to assembly language so I apologise if it's a stupid question. why can’t I move 8 bit variable into much larger 16 bit register? Becase the machine

Difference between SHL and SAL in 80x86

余生颓废 提交于 2019-11-27 23:00:40
问题 I have learned how to work with 80x86 assembler, so in bit-wise shift operation, I faced a problem with SAL and SHL usage. I means the difference between lines of code as follow : MOV X, 0AAH SAL X, 4 MOV X, 0AAH SHL X, 4 When we should use SHL and when use SAL? What is the difference of them? 回答1: According to this, they are the same: The shift arithmetic left (SAL) and shift logical left (SHL) instructions perform the same operation; they shift the bits in the destination operand to the

What is the purpose of CS and IP registers in Intel 8086 assembly?

帅比萌擦擦* 提交于 2019-11-27 19:51:54
问题 So, as the question states, what is the purpose of CS and IP registers in intel's 8086 I found this explanation: Code segment (CS) is a 16-bit register containing address of 64 KB segment with processor instructions. The processor uses CS segment for all accesses to instructions referenced by instruction pointer (IP) register. CS register cannot be changed directly. The CS register is automatically updated during far jump, far call and far return instructions. and this for IP: Instruction

How to check keys status in x86 assembly?

半城伤御伤魂 提交于 2019-11-27 19:29:24
问题 I took x86 assembly as a hobby this past january so I could make games that would work on old 8086-powered computers like the PCj and Tandy 1000, but the books I found don't exactly teach much on that specific topic. While some dos and bios interrupts kind of do the job, they're far from perfect. My main issue is reading the keyboard status for pressed keys without halting the program. I found a few methods, but they're very limited. INT 21h, AH 0Ch reads the last pressed key, but in a text

Print decimal in 8086 emulator

て烟熏妆下的殇ゞ 提交于 2019-11-27 16:29:59
I implemented the multiplication of two big integer in emu8086 with code as below : ; MULTIPLY N1 * N2 = RES MULTIPLY PROC MOV BH, 0H MOV CH, 0H MOV CL, L1; initial counter of first loop ( L1 -> length of N1 ) DEC CX MUL_1: MOV COUNTER, CL ; store counter of first loop MOV CL, L2 ; initial counter of second loop ( L2 -> length of N2 ) MUL_2: MOV BH, 0H MOV BL, COUNTER DEC BL MOV AL, N1[BX] ; get BX th byte of N1 MOV BL, CL DEC BL MUL N2[BX] ; multiple N1 and N2 's bytes MOV BH, 0H MOV BL, COUNTER ADD BX, CX DEC BX ADD RES[BX], AL ; AL should be add into RES[loop1_counter + loop2_counter - 1]

Jump out of range solutions and how different instructions affect range

我们两清 提交于 2019-11-27 15:48:57
I've been struggling a lot with the error "jmp out of range", a lot of times I need to run a subrutine from different parts of my code as I would a function in C++. I got to a point that both ends on my code need to jump to the same place and there is just no way for both to get there. What is the solution for this? Also I noticed that PRINT 'something' Seems to occupy more "space" than using: CALL PTHIS DB 13, 10, 'something', 0 (If I put a PRINT between two jumps I get jump out of range but if I replace it with a PTHIS there is no problem) Why is this? Jim Mischel The problem with the

How to set 1 second time delay at assembly language 8086

北城余情 提交于 2019-11-27 15:10:36
My problem is that I have written a code that is supposed to output a result into a set of LEDs connected to the parallel port. When I ran the code it pretty much did nothing. My instructor told me that the code ran too fast that my eyes did not see what happened. I have found that there are a couple of ways to do a time delay, I have tried to loop the NOP but I think I cannot really determine what is going on. Is there any better way? I have here a part of the code where I have to add a time delay into: org 100h mov ax, 0 mov dx, 378 out dx, ax mov ax, 1 ; 1st mov cx, 1ah start1st: mov ax, 1

What are near, far and huge pointers?

╄→гoц情女王★ 提交于 2019-11-27 11:48:59
Can anyone explain to me these pointers with a suitable example ... and when these pointers are used? In the old days, according to the Turbo C manual, a near pointer was merely 16 bits when your entire code and data fit in the one segment. A far pointer was composed of a segment as well as an offset but no normalisation was performed. And a huge pointer was automatically normalised. Two far pointers could conceivably point to the same location in memory but be different whereas the normalised huge pointers pointing to the same memory location would always be equal. The primary example is the