x86-16

Print decimal in 8086 emulator

佐手、 提交于 2019-11-26 22:27:46
问题 I implemented the multiplication of two big integer in emu8086 with code as below : ; MULTIPLY N1 * N2 = RES MULTIPLY PROC MOV BH, 0H MOV CH, 0H MOV CL, L1; initial counter of first loop ( L1 -> length of N1 ) DEC CX MUL_1: MOV COUNTER, CL ; store counter of first loop MOV CL, L2 ; initial counter of second loop ( L2 -> length of N2 ) MUL_2: MOV BH, 0H MOV BL, COUNTER DEC BL MOV AL, N1[BX] ; get BX th byte of N1 MOV BL, CL DEC BL MUL N2[BX] ; multiple N1 and N2 's bytes MOV BH, 0H MOV BL,

Reading a number using INT 21h (DOS) & 8086 assmebly

我们两清 提交于 2019-11-26 21:58:48
问题 I need to prompt to user a msg that tells him to write a number , then I store this number and do some operation on it After searching in INT 21h I found this : INT 21h / AH=1 - read character from standard input, with echo, result is stored in AL. if there is no character in the keyboard buffer, the function waits until any key is pressed. example: mov ah, 1 int 21h The main problem that this only reads one character and represent it as ASCII so If I need to write the number "357" I will

Displaying Time in Assembly

北战南征 提交于 2019-11-26 17:52:23
问题 Hello im trying to display the actual time hours/minutes/seconds this is my code sample: MOV AH, 2Ch INT 21h MOV AH, 0Eh MOV AL, CH INT 10h MOV AL, 3Ah INT 10h MOV AL, CL INT 10h MOV AL, 3Ah INT 10h MOV AL, DH INT 10h ret Here you can se what the console is displaying 回答1: See the x86 tag wiki for the instruction set reference manual, and many good links to reference material and tutorials. It takes enough code to split up an integer into ASCII digits that you should factor it out into a

Jump out of range solutions and how different instructions affect range

萝らか妹 提交于 2019-11-26 17:21:00
问题 I've been struggling a lot with the error "jmp out of range", a lot of times I need to run a subrutine from different parts of my code as I would a function in C++. I got to a point that both ends on my code need to jump to the same place and there is just no way for both to get there. What is the solution for this? Also I noticed that PRINT 'something' Seems to occupy more "space" than using: CALL PTHIS DB 13, 10, 'something', 0 (If I put a PRINT between two jumps I get jump out of range but

What are near, far and huge pointers?

久未见 提交于 2019-11-26 15:46:26
问题 Can anyone explain to me these pointers with a suitable example ... and when these pointers are used? 回答1: In the old days, according to the Turbo C manual, a near pointer was merely 16 bits when your entire code and data fit in the one segment. A far pointer was composed of a segment as well as an offset but no normalisation was performed. And a huge pointer was automatically normalised. Two far pointers could conceivably point to the same location in memory but be different whereas the

Assembly, printing ascii number

耗尽温柔 提交于 2019-11-26 15:33:44
I have a problem with my assembly code. I want to print number stored in register cx, but when i tried to print it, it printed ascii character instead of ascii number, so I decided to write a procedure to convert ascii char to ascii value. Problem is, that when I try to call that procedure, the program freezes and I have to restart dosbox. Does anyone know whats wrong with this code? Thanks. P4 PROC MOV AX,CX ;CX = VALUE THAT I WANT TO CONVERT MOV BX,10 ASC2: DIV BX ;DIV AX/10 ADD DX,48 ;ADD 48 TO REMAINDER TO GET ASCII CHARACTER OF NUMBER PUSH AX ;SAVE AX MOV AH,2 ;PRINT REMAINDER STORED IN

Displaying numbers with DOS

只愿长相守 提交于 2019-11-26 14:47:53
I was tasked to write a program that displays the linear address of my program's PSP. I wrote the following: ORG 256 mov dx,Msg mov ah,09h ;DOS.WriteStringToStandardOutput int 21h mov ax,ds mov dx,16 mul dx ; -> Linear address is now in DX:AX ??? mov ax,4C00h ;DOS.TerminateWithExitCode int 21h ; ------------------------------ Msg: db 'PSP is at linear address $' I searched the DOS api (using Ralph Brown's interrupt list ) and didn't find a single function to output a number! Did I miss it, and what can I do? I want to display the number in DX:AX in decimal. Sep Roland It's true that DOS doesn

BIOS int 10h printing garbage on QEMU

风格不统一 提交于 2019-11-26 14:47:27
问题 I have a problem while writing an x86 real mode assembly program that runs as a bootloader in QEMU . I'm trying to print text through BIOS interrupt 0x10. My code is: print: pusha .loop: mov AL, [SI] cmp AL, 0 je .end call printChar inc SI jmp .loop .end: popa ret printChar: pusha mov AH, 0x0E mov BH, 0 mov BL, 0x0F int 0x10 popa ret I'm using [ORG 0x7c00] as an origin point. I tested the printChar label and calling it with some letter in AL and it works fine. When I try to load a memory

Enable the boot loader to load the second sector of a USB

巧了我就是萌 提交于 2019-11-26 14:34:36
问题 I am learning the assembly language. I wrote a simple bootloader. After testing it out, it didn't work. Here is my code: [bits 16] [org 0x7c00] jmp start data: wolf_wel_msg db 'Welcome to Bootloader!!!',0x0D,0x0A,0 wolf_kernel_load db 'Loading kernel....',0x0D,0x0A,0 wolf_error_msg db 'Kernel.bin not found!',0x0D,0x0A,0 wolf_error_msg1 db 'Press any key to restart..',0 start: mov si, wolf_wel_msg call wolf_print mov si, wolf_kernel_load call wolf_print pushf stc mov ah,00 mov dl,00 int 13h

Looking for 16-bit x86 compiler

风格不统一 提交于 2019-11-26 13:53:05
问题 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