x86-16

assembly 8086 cursor placement

丶灬走出姿态 提交于 2019-12-19 21:42:08
问题 I want to place the cursor after the "paper:" wait until an ENTER is given and then place it after "author(s):". both sentences are defined variables that are printed. insert db "******* Insert new paper *******",0,0Ah,0Ah,0Ah, 0Dh, "$" inserttitle db " Title of paper: ",0Dh,0Ah,0Ah, " Name of author(s): ",0Dh ,"$" mainext db ,0Ah,0Ah,0Ah,0Ah,0Ah,0Ah,0Ah,0Ah," <<Main>> <<Next>>","$" INSERT NEW PAPER newpaper proc call clrscr mov dx, offset insert call printf mov dx, offset inserttitle call

How to generate a random number in 8086 assembly?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 11:27:27
问题 I want to know if there a routine or an instruction to generate a random number using assembly on 8086. any help will be appreciated. 回答1: The most common way is to use the timestamp. In 32 bit mode it can be done by rdtsc instruction, in 16 bit mode: by using function 0 of BIOS interrupt 1A. Because it's a timestamp, avoid using it frequently (because of lack of proper dispersion), and use it as seed for an pseudo-random number generator. When you need just one random value, you can use the

Why do x86 jump/call instructions use relative displacements instead of absolute destinations?

为君一笑 提交于 2019-12-19 10:16:32
问题 I am learning 8086 and there is one particular question which is bothering me and I have not been able to find any satisfactory answer yet. I understand that CPU executes the code sequentially and if want to change the code flow we would like the IP to point to the new/old address where the code of our interest is sitting. Now, my question is why we(I mean CPU) don't just go and update the IP with the address corresponding to the label when we encounter jump instruction? What is the need to

Why does 20 address space with on a 16 bit machine give access to 1 Megabyte and not 2 Megabytes?

走远了吗. 提交于 2019-12-19 09:59:39
问题 OK, this question sounds simple but I am taken by surprise. In the ancient days when 1 Megabyte was a huge amount of memory, Intel was trying to figure out how to use 16 bits to access 1 Megabyte of memory. They came up with the idea of using segment and offset address values to generate a 20 bit address. Now, 20 bits gives 2^20 = 1,048,576 locations that can be addressed. Now assuming that we access 1 byte per address location we get 1,048,576/(1024*1024) = 2^20/2^20 Megabytes = 1 Megabyte.

Why does 20 address space with on a 16 bit machine give access to 1 Megabyte and not 2 Megabytes?

让人想犯罪 __ 提交于 2019-12-19 09:59:11
问题 OK, this question sounds simple but I am taken by surprise. In the ancient days when 1 Megabyte was a huge amount of memory, Intel was trying to figure out how to use 16 bits to access 1 Megabyte of memory. They came up with the idea of using segment and offset address values to generate a 20 bit address. Now, 20 bits gives 2^20 = 1,048,576 locations that can be addressed. Now assuming that we access 1 byte per address location we get 1,048,576/(1024*1024) = 2^20/2^20 Megabytes = 1 Megabyte.

How to prevent duplicate chars when I press keys on the keyboard

江枫思渺然 提交于 2019-12-19 03:53:33
问题 I am trying to learn how to prevent the keyboard sending multiple chars to the screen and to scanf under DOS. I am using Turbo-C with inline assembly. If the characters entered on the keyboard are: mmmmmmmmyyyyy nnnnnaaaaammmmmmeeeeee iiiiiissss HHHHaaaaiiiimmmm The characters seen on the console and processed by scanf would be: my name is Haim The basic output comes from the code in C which I am not allowed to touch. I must implement eliminate_multiple_press and uneliminate_multiple_press

How is a physical address generated in 8086?

霸气de小男生 提交于 2019-12-19 03:53:11
问题 In the 8086 architecture, the memory space is 1 MiB in size and divided into logical segments of up to 64 KiB each. i.e. it has 20 address lines thus the following method is used: That the data segment register is shifted left 4 bits then added to the offset register My question is: How we do the shift operation although all the registers are only 16 bits 回答1: Address translation is done internally by a special unit without using the registers available to user code to store intermediate

When Will the Code Under DATA SEGMENT execute in this code?

岁酱吖の 提交于 2019-12-19 03:13:25
问题 I am a beginner of Assembly Programming... I surfed a lot in google. There is a lot of information, but I still do not understand the following code. I would be grateful if someone could explain MOV AX,DATA I also don't understand when the code that is present in data segment would be executed in this program. ASSUME CS:CODE,DS:DATA CODE SEGMENT MOV AX,@DATA mov DS,AX ... ... CODE ENDS DATA SEGMENT ... ... ... //SOMECODE DATA ENDS Also, can someone explain to me what the following

Displaying text video memory at 0xb8000 without using the C library

故事扮演 提交于 2019-12-18 12:38:44
问题 I have been writing kernel in C. I've been using the GCC cross-compiler, writing on a Windows system and targeting 16bit Real Mode. I don't have the C library available to write the kernel. I have started with some code which is suppose to print a character directly to the screen. Here is a function from kernel.c : int main() { char *src = (char *)0xB8000000L; *src = 'M'; src += 2; *src = 'D'; return 0; } I compiled my code using GCC with the parameter -m16 to generate code that will run in

What would happen if the CS segment register is changed? (And how would you do so?)

女生的网名这么多〃 提交于 2019-12-18 04:17:28
问题 I read this article: http://static.patater.com/gbaguy/day3pc.htm It includes the sentence DON'T EVER CHANGE CS!! But what exactly would happen if you did modify the CS segment register? Why is it so dangerous? 回答1: cs is the code segment. cs:ip , which means cs together with ip (instruction pointer) points to the location of the next instruction. So any change to cs or ip or to both changes the address from where the next instruction will be fetched and executed. Usually you change cs with a