x86-16

How can linux boot code be written in C?

自作多情 提交于 2019-11-29 10:27:39
I'm a newbie to learning OS development. From the book I read, it said that boot loader will copy first MBR into 0x7c00, and starts from there in real mode. And, example starts with 16 bit assembly code. But, when I looked at today's linux kernel, arch/x86/boot has 'header.S' and 'boot.h', but actual code is implemented in main.c. This seems to be useful by "not writing assembly." But, how is this done specifically in Linux? I can roughly imagine that there might be special gcc options and link strategy, but I can't see the detail. I'm reading this question more as an X-Y problem. It seems to

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

六眼飞鱼酱① 提交于 2019-11-29 06:52:15
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? 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. As a program writer you can specify where your data is by setting the data segments registers. Edit : as

Difference between SHL and SAL in 80x86

烂漫一生 提交于 2019-11-29 05:28:00
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? 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 left (toward more significant bit locations). For each shift count, the most significant bit of the

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

北战南征 提交于 2019-11-28 16:14:47
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 Pointer (IP) is a 16-bit register. I don't really understand what this basically means, so if someone

How to convert String to Number in 8086 assembly?

吃可爱长大的小学妹 提交于 2019-11-28 14:38:04
I have to build a Base Converter in 8086 assembly . The user has to choose his based and then put a number, after then , the program will show him his number in 3 more bases[he bring a decimal number, and after this he will see his number in hex, oct, and bin. This first question is, how can I convert the number he gave me, from string, to a number? the sec question is, how can i convert? by RCR, and then adc some variable? Here is my code: data segment N=8 ERROR_STRING_BASE DB ,10,13, " THIS IS NOT A BASE!",10,13, " TRY AGINE" ,10,13," $" OPENSTRING DB " Welcome, to the Base Convertor",10,13,

emu8086 change case of the entered string and reverse it [closed]

别说谁变了你拦得住时间么 提交于 2019-11-28 13:04:13
问题 I am totally new in assembly language programming and I am stuck with a problem in which I need to change case of the entered string plus reverse the string as well. I am using emu8086. I the following code I am either able to change case or reverse the string. but I need to perform both the operations simultaneously. .MODEL CASECHANGE .DATA MSG1 DB 0DH,0AH, 'Enter string:$' MSG2 DB 0DH,0AH, 'String in reverse case:$' STR1 DB 255 DUP(?) .CODE START: MOV AX,@DATA MOV DS,AX LEA DX,MSG1 MOV AH

Interrupts, Instruction Pointer, and Instruction Queue in 8086

二次信任 提交于 2019-11-28 12:44:47
Suppose an external interrupt request is made to 8086. Processor will handle the interrupt after completing the current instruction being executed (if any). Before handling of the interrupt, the state of the program will also be saved (PSW flag, registers etc.) by pushing data onto the stack segment. Now, most tutorials/documents describe that instruction pointer is also pushed onto the stack segment, which is okay because it was pointing to the next byte of instruction in the code segment (just before interrupt request was made). But what happens to the instruction queue? Is it also pushed

weird behaviour of code (corrupted draw) when using own keyboard interrupt `int 09h` handler

房东的猫 提交于 2019-11-28 12:35:03
I'm working on an assignment for the univesity, we need to create a simple breakout/arkanoid clone, it is going pretty well but I found a bug that would delete everything on the screen, this bug is random but I suspect its related to my DrawPaddle function. Maybe you can spot the bug or have the knowledge about why is the video memory doing that. The game has to be done with 16 bit ms-dos assembly, I'm using NASM + VAL + Dosbox to create it, I compile it with: nasm -f obj test.asm val test.obj The game justs moves the paddle in a fixed screen using the keyboard arrows, you can also quit the

DOSBox: debug.exe reads file - processes commands incorrectly

僤鯓⒐⒋嵵緔 提交于 2019-11-28 12:06:17
问题 I'm trying to use DOSBox with debug.exe on a 64-bit system. It works perfectly fine if I enter the commands manually. When I redirect input from a file with: debug < [file] it doesn't work. On every line except for the first it displays an error similar to this: DOSBox will eventually hang and crash. Is there any way to fix this? The input file I am trying to process as commands is: a 100 jmp 145 db 'Hello, World!', 0D, 0A, 'Press any key to continue . . .$' a 145 mov ah, 09 mov dx, 102 int

Playing .wav files on DOSBox's Sound Blaster device

廉价感情. 提交于 2019-11-28 11:50:20
I want to make a program in assembly/8086/masm/dosbox that turns the keyboard into various musical instruments so i need to be able to play some .wav files to produce the required sounds.I am aware of beep char and producing sound via sending frequencies to pc speaker (ports 41h,42h and 61h) but both ways are clearly not going to get me there. I searched around and found that I need to use int 21h for opening files, knowledge of .wav format and knowledge of sound programming using Sound Blaster . Unfortunately I couldn't find any helpful documentation on how to use the Sound Blaster in Dosbox