x86-16

Converting from lower case to upper case

≡放荡痞女 提交于 2019-12-01 07:24:09
问题 I am trying to convert from lower case to upper case. I know it can easily be done by, SUB AL, 20H But I am have been given another solution which is, AND AL, 0DFH Please help me understand this. Thanks 回答1: Look at the bit patterns: A (0x41): 0100 0001 a (0x61): 0110 0001 M (0x4d): 0100 1101 m (0x6d): 0110 1101 Z (0x5a): 0101 1010 z (0x7a): 0111 1010 Lower case ASCII is upper case ASCII + 0x20 ( 0010 0000 ) - i.e. the same bit pattern with the sixth bit set . 0xdf is 1101 1111 in binary. AND

Assembler passes issue

寵の児 提交于 2019-12-01 06:19:05
问题 I have an issue with my 8086 assembler I am writing. The problem is with the assembler passes. During pass 1 you calculate the position relative to the segment for each label. Now to do this the size of each instruction must be calculated and added to the offset. Some instructions in the 8086 should be smaller if the position of the label is within a range. For example "jmp _label" would choose a short jump if it could and if it couldn't it would a near jump. Now the problem is in pass 1 the

Parity of a number (Assembly 8086)

早过忘川 提交于 2019-12-01 04:16:26
问题 Im trying to give a one digit number, and know if the parity is odd or even, for example, give 9 and print that is an odd number. This is what I have: assume cs:cseg,ds:dseg,ss:sseg cseg segment start: mov ax, dseg mov ds, ax mov ah, 01h ; Here, im adding a number int 21h jp even jnp odd even: mov ah,09 lea dx,par int 21h jmp exit odd: mov ah,09 lea dx,odd1 int 21h jmp salir salir: mov ax,4C00h int 21h cseg ends dseg segment byte even Db 'Even number$' odd11 Db 'Odd number$' dseg ends sseg

Importance of Hexadecimal numbers in Computer Science [closed]

不羁岁月 提交于 2019-12-01 01:06:55
When studying programming 8085, 8086 and microporcessors in general we always have hexadecimal representation. Its ok that binary numbers are important in computers. But how these hexadecimal numbers are important? Any historical importance? It would be nice if someone point to some historical papers also. EDIT: How computers handle hexadecimal numbers? For example what happens in 8085 when a hexadecimal number is given as input? Hexadecimal has a closer visual mapping to the various bytes used to store a number than decimal does. For example, you can tell from the hexadecimal number

How is a physical address generated in 8086?

∥☆過路亽.° 提交于 2019-11-30 22:02:49
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 Address translation is done internally by a special unit without using the registers available to user code to store intermediate results - it just fetches 16-bit values and does the translation inside - it is not reflected anywhere where the

What does OFFSET in 16 bit assembly code mean?

a 夏天 提交于 2019-11-30 17:28:21
I am going through some example assembly code for 16-bit real mode. I've come across the lines: mov bx, cs mov ds, bx mov si, OFFSET value1 pop es mov di, OFFSET value2 what is this doing? What does having 'OFFSET' there do? Nathan Fellman As some of the other answers say, the offset keyword refers to the offset from the segment in which it is defined. Note, however, that segments may overlap and the offset in one segment may be different in another segment. For instance, suppose you have the following segment in real mode data SEGMENT USE16 ;# at segment 0200h, linear address 2000h org 0100h

Reading from memory in 8086 real mode while using 'ORG 0x0000'

[亡魂溺海] 提交于 2019-11-30 16:35:25
I've been messing around with x86-16 assembly and running it with VirtualBox. For some reason when I read from memory and try to print it as a character, I get completely different results from what I was expecting. However when I hard-code the character as part of the instruction, it works fine. Here's the code: ORG 0 BITS 16 push word 0xB800 ; Address of text screen video memory in real mode for colored monitors push cs pop ds ; ds = cs pop es ; es = 0xB800 jmp start ; input = di (position*2), ax (character and attributes) putchar: stosw ret ; input = si (NUL-terminated string) print: cli

How to tell GCC to generate 16-bit code for real mode

允我心安 提交于 2019-11-30 14:02:06
问题 I am writing real mode function, which should be normal function with stackframes and so, but it should use %sp instead of %esp. Is there some way to do it? 回答1: GCC 5.2.0 (and possible earlier versions) support 16-bit code generation with the -m16 flag. However, the code will almost certainly rely on 32-bit processor features (such as 32-bit wide registers), so you should check the generated assembly carefully. From the man pages: The -m16 option is the same as -m32, except for that it

How many ways to set a register to zero?

一个人想着一个人 提交于 2019-11-30 10:46:40
问题 I'm curious how many ways are there to set a register to zero in x86 assembly. Using one instruction. Someone told me that he managed to find at least 10 ways to do it. The ones I can think of are: xor ax,ax mov ax, 0 and ax, 0 回答1: There are a lot of possibility how to mov 0 in to ax under IA32... lea eax, [0] mov eax, 0FFFF0000h //All constants form 0..0FFFFh << 16 shr eax, 16 //All constants form 16..31 shl eax, 16 //All constants form 16..31 And perhaps the most strange... :) @movzx:

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

情到浓时终转凉″ 提交于 2019-11-30 07:39:05
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 real mode. I use these commands to generate my kernel.bin : gcc -ffreestanding -c -m16 kernel.c -o