x86-16

Linking a file using ld to output a binary file gives error in OS development

吃可爱长大的小学妹 提交于 2019-12-04 13:09:40
I am learning Operating system tutorials. I created 2 files. boot.asm kernel.c The kernel.c is as follows : int main() { char *src = (char *)0xB8000000L; *src = 'M'; src += 2; *src = 'D'; return 0; } The kernel is used to write a character to the text mode video display area. The kernel was compiled using Windows version of GCC with: gcc -ffreestanding -c -m16 kernel.c -o kernel.o I link the kernel object to a binary file using LD : ld -Ttext 0x10000 --oformat binary -o kernel.bin kernel.o The error I get is: ld : cannot link the file which is not PE executable type Can anybody solve this

8086 Assembly (TASM): Displaying an ASCII character value as HEX

北慕城南 提交于 2019-12-04 08:46:32
问题 ** Edited for clarification and "cleaner" code. I'm trying to accept a character from the keyboard (any character) and convert it's ASCII value to hex, then display it. I know how to convert from base 10 to hex, but just to make sure I'm not using incorrect terminology: If I enter "c" in as my ASCII value, it's decimal value is 63. 63 divided by 16 (hex is base 16) = 3.9375. Save the quotient of 3 for later. Remainder * base (.9375 * 16) = 15. 15 is Hex character "F". Quotient divided by base

How to type hexadecimal into binary using DOS Interrupt in Assembly?

谁都会走 提交于 2019-12-04 07:11:18
问题 following code is including a hexadecimal number (relevant to ASCII code assume that it is obtained from keyboard), I want to print this hex number to the screen but in "binary" using DOS Interrupt. NUMLOCK is 45h. [org 0x0100] mov AL, 45 ;moving NUMLOCK hexadecimal(ASCII code) to AX ~~How to display its binary relevant to screen using DOS Interrupt? 回答1: DOS Interrupt has only these services outputting to screen: AH = 02h -WRITE CHARACTER TO STANDARD OUTPUT AH = 06h - DIRECT CONSOLE OUTPUT

Adding two numbers to make a two digit number

女生的网名这么多〃 提交于 2019-12-04 07:07:29
问题 I want to add two predetermined values together and produce the result. What my code is doing at the moment is it is adding 16 and 6 together which should print out 22. However it is printing out 2... I'm not really sure how to correct this... Here is the code: data segment ; data segment. Keyword db means define byte. You can also define word (dw) numA db 16 ;Define first variable numB db 06 ;Define second variable StrMsg db 'The answer is $' ;return message to the user leng db 1 ;length of

Explain how the AF flag works in an x86 instructions?

。_饼干妹妹 提交于 2019-12-04 05:57:00
I have a little 8086 emulator and I've had a long standing bug for like 2 years now that AF does not behave properly inside of sub and add instructions. My current way of computing its value is this for 8 bit numbers and subtraction: uint8_t base=... , subt=... base=base&0xF; subt=subt&0xF; //isolate bottom nibble if((int16_t)base-subt>7 || (int16_t)base-subt<-7){ flags.af=1; }else{ flags.af=0; } (assuming an instruction like sub base,subt ) And for adding it's like this: uint8_t base=... , adder=... base=base&0xF; adder=adder&0xF; //isolate bottom nibble if(base+adder>7 || base+adder<-7){

Converting 16-bit DOS .com assembly for use on 64-bit

家住魔仙堡 提交于 2019-12-04 05:41:20
问题 I wrote few programs in assembly in flat assembler for 32bit windows xp. But now that I have 64bit windows 8 I can't run the .com files, as they appear to be incompatible with 64bit version (the programs are 32bit). How do I convert it so I can run it in win8 as well? Maybe use a different assembler? I'd like to avoid the need for emulators and virtual machines. 回答1: A .com file is 16-bit. You can use 32-bit instructions and registers, but it's 16-bit code. A 64-bit CPU, once it's put in

ADC instruction in ASM 8086

被刻印的时光 ゝ 提交于 2019-12-04 01:48:44
When I use ADC for exmaple: AL = 01 and BL = 02, and CF = 1 when I make this: ADC AL,BL Will AL be 3 or 4 ? (with the CF addition or without?) Few things about the 8086 ADC instruction: Syntax: adc dest, src dest: memory or register src: memory, register, or immediate Action: dest = dest + src + CF Clearly the action says the Carry Flag ( CF ) will be included in the addition so the result will be 4 not 3 . It is no different than adding in base 10. 99 +11 9+1 is zero carry the 1 9+1+carry is 1 carry the 1 The result of the above decimal math is 10 with a carry of 1, or 110 if you want to

Assembly 8086 - copy one buffer to another

末鹿安然 提交于 2019-12-03 21:19:02
im working on a assembly program that reads the whole text file into a buffer then displays it in the console. It displays 24 lines (each line has a max lenght of 80, because im using a 80 wide * 25 height dossbox ) at once then waits for user input so the user can scroll through the text. I wanted to add the number of line to the beginning of each line, so figured i could make a second buffer and copy chars 1by1 from the first one and when i find a newline i would call a procedure which would add the line number to the buffer, then continue till i proceed thru the whole buffer. But my way of

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

限于喜欢 提交于 2019-12-03 20:33:27
问题 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

How to pass/retrieve DOS command-line parameters in a 16-bit assembly program?

不问归期 提交于 2019-12-03 08:07:13
I am writing some little tools for MS-DOS. Now I'm writing a Shutdown.com , like for Windows XP and greater. I have already written the entire code, now I just need to pass the argument from DOS. I need to pass the parameters "-r" to reboot and "-s" to shutdown. How can I do it? I'm using TASM(Turbo Assembler 4.1) on Windows 98 to link and compile. I'm looking for a very simple way to do it, and if possible, still a .COM program. I'm looking exactly like the ARGV and ARGC from C language, but for Assembly 16-bits... shutdown -r will reboot shutdown -s will shutdown Remember that I already know