x86-16

How to convert String to Number in 8086 assembly?

家住魔仙堡 提交于 2019-11-27 08:38:43
问题 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

Printing a string without OS

落爺英雄遲暮 提交于 2019-11-27 08:06:35
问题 I have a simple program in x86 assembly language. It should print a string directly to the video memory without OS. [bits 16] [org 0x7c00] mov ax, 0x3 int 0x10 sdl mov ax, 0xb800 mov es,ax mov si, msg xor di, di repnz movsw jmp $ msg db 'Hello' times 510 - ($ - $$) db 0 dw 0xaa55 But it doesn't work. Can you help me? 回答1: There are some issues: There is no such instruction as sdl . To copy data, you should use rep movsw , not repnz movsw . You need to set cx before rep movsw . You need to

Looking for 16-bit x86 compiler

孤者浪人 提交于 2019-11-27 07:53:58
I am working on an embedded systems project and have run into an issue of the compiler being programatically embedded in the Paradigm C++ IDE. I would like to be able to automate building. The processor is the AMD186ES. I am not working with the OS - just baremetal stuff. I need to generate real-mode 16-bit 8086 machine code from C++. My googling indicates that G++ can build such code. My questions are: Can g++ be configured to build this machine code? Are there other C++ compilers that can do it as well? Hawken I am currently using gnu as (part of binutils and the assembler used for gcc) and

Interrupts, Instruction Pointer, and Instruction Queue in 8086

青春壹個敷衍的年華 提交于 2019-11-27 07:12:24
问题 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

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

为君一笑 提交于 2019-11-27 07:08:42
问题 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

8086- why can't we move an immediate data into segment register?

我怕爱的太早我们不能终老 提交于 2019-11-27 01:51:48
问题 In 8086 assembly programming, we can only load a data into a segment register by, first loading it into a general purpose register and then we have to move it from this general register to the segment register. Why can't we load it directly? Is there any special reason for not being allowed? What is the difference between mov ax,5000H and mov ax,[5000H] ? Does [5000h] mean content in memory location 5000h? 回答1: Remember that the syntax of assembly language (any assembly) is just a human

Is it possible to manipulate the instruction pointer in 8086 assembly?

北慕城南 提交于 2019-11-26 23:44:36
问题 I want to know if I can manipulate (read and change the value of) the instruction pointer (IP) in 8086 assembly. For example, Say IP is currently storing 0200h . I would like to read this value and change it to something else, say 4020h . How could I do that? 回答1: If you wanted to set the instruction pointer to a known value, say hex value 4020h, you could jump directly to that address: jmp 4020h Or if some memory location, myVariable , held the value you wanted to store in IP you could do an

Cannot move 8 bit address to 16 bit register

北慕城南 提交于 2019-11-26 23:24:18
问题 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

Is there a C compiler that targets the 8086?

我只是一个虾纸丫 提交于 2019-11-26 23:20:16
问题 I have an 8086 CPU emulator. It emulates only 8086 instructions. I am searching now for a C compiler to target this emulator with. Is there any C compiler out there that can do this? Also, having a usable libc and such is not important to me. The emulator uses custom(ie, non-PC) hardware and therefor any libc or even ctr0 would probably have to be rewritten anyway 回答1: bcc - Bruce's C compiler From bcc(1) - Linux man page: Description Bcc is a simple C compiler that produces 8086 assembler,

Why can't MOV have both operands as memory locations? [closed]

十年热恋 提交于 2019-11-26 23:15:51
I read that MOV instruction cannot have memory locations for both its operands. Like : MOV [0012H], [0016H] is not allowed. Why so? And can other instructions have memory locations for both its operands? It's was a design decision when they created the CPU. More addressing modes you have and more instructions, larger (in terms of number of bits required to represent instruction) the instructions get. And larger instruction take longer to fetch from memory. In other words, x86's instruction set is not orthogonal . It is not necessarily bad, at least not now, that only very limited amount of