x86-16

Converting decimal to binary in assembler

不打扰是莪最后的温柔 提交于 2021-02-05 12:16:31
问题 I need help with my first program in assembler. I have to convert values entered by user from decimal to binary. I have no idea how can I show values as a decimal, and what should I do next. could anyone instruct me step by step what do next. .model small .stack 100h` .data txt1 db "Enter binary value:" ,10,13, "$" txt2 db "BIN: " ,10,13, "$" .code main proc mov ax, @data mov ds, ax ;clear screen mov ah,0fh int 10h mov ah,0 int 10h ;show first text mov ah, 9 mov dx, offset txt1 int 21h call

Computing the factorial of 10 using 8086 assembly

寵の児 提交于 2021-02-05 10:43:06
问题 I have been trying to solve this using assembly language. The thing is I cannot store the 10! In al and my code works for finding factorial of 5. How do I store my result of 10! In a register? When I find factorial of 5 I can see the result clearly in al because 120 can be stored in al . Any help would be appreciated. Here's my code for 5! org 100h .DATA ANS DB ? .CODE MAIN PROC MOV AX,@DATA MOV DS,AX MOV AL,5 MOV CL,4 MOV BL,AL SUB BL,1 L: MUL BL SUB BL,1 LOOP L MOV ANS,AL END MAIN ret 回答1:

x86 NASM Indirect Far Jump In Real Mode

拈花ヽ惹草 提交于 2021-02-05 08:51:15
问题 I have been messing around with a multi-stage bootloader and I have got all of my code to work, except for the last part: The Jump . I have gotten this code to work out before now but I wanted to make it more modular by replacing this line: jmp 0x7E0:0 With this one: jmp far [Stage2Read + SectorReadParam.bufoff] Instead of hard coding where the code will load in, I wanted to do an indirect jump to it. Here's the rest of my code: ; This is stage 1 of a multi-stage bootloader bits 16 org 0x7C00

Why is the variable name “name” not allowed in assembly 8086?

China☆狼群 提交于 2021-02-05 06:04:22
问题 When I try to declare a variable with the name "name" it doesn't work, it gives me an error, this one there are errors. with the following explanation (22) wrong parameters: MOV BL, name (22) probably no zero prefix for hex; or no 'h' suffix; or wrong addressing; or undefined var: name here is my code ; multi-segment executable file template. data segment ; add your data here! pkey db "press any key...$" name db "myname" ends stack segment dw 128 dup(0) ends code segment start: ; set segment

Converting bin to hex in assembly

▼魔方 西西 提交于 2021-02-02 03:42:30
问题 I'm beginner and I need help with converting 16-bit binary number to hex. I have done most of the code, but I need help with a couple of things. How to make it only accept 0 and 1 in input and ignore the rest of numbers and letters? After conversion process I'm getting wrong number in hex. What did I do wrong? Example input: 1010101111001101 Expected output: ABCD Current output: AAAC Here's my code: .MODEL SMALL .STACK 1000h .DATA title db 'Convert BIN to HEX:.',13,10,'$' HEX_Map DB '0','1',

Coverting String Decimal to Binary and Hexa in Assembly 8086

陌路散爱 提交于 2021-01-29 16:14:29
问题 I'm trying to convert a string I read with this code to binary and hexa. READ_STRING: MOV DX, offset buffer MOV AH, 0Ah INT 21h MOV SI, 1d MOV AX, 0 XOR CX, CX MOV CL, buffer[SI] INC SI LOOP_1: MOV DX, 10 MUL DX MOV DL, buffer[SI] SUB DL, 30h MOV DH, 0 ADD AX, DX INC SI LOOP LOOP_1 RET So far I have this code for binary output but it always prints "1001" (9 in decimal): NEXT: XOR AX, AX XOR BX, BX XOR CX, CX MOV CL, 2 MOV AL, byte ptr[nombre] MOV DI, offset binaire ; DIV : divide AX by CL.

finding index of the array in tasm assembly language and printing it

倖福魔咒の 提交于 2021-01-29 09:23:55
问题 I have made a tasm assembly language program, which finds the minimum in the user-inputted array. I want to find the index of the element of the minimum value which the program is finding. I want to find the index of the element which the program finds. For example: input array is [1,2,3,4,5,6]. It should return 1 as minimum value and 0 as index. Here is the code. Data Segment msg db 0dh,0ah,"Please enter the length of the array: $" msg1 db 0dh,0ah,"Enter a number: $" newl db 0dh,0ah," $" res

assembly concatenate two strings

感情迁移 提交于 2021-01-29 04:02:04
问题 I want to concatenate two strings but in my output instead of getting the final concatenated string, I get a line of weird characters and spaces, maybe someone could help me a bit. I want to save the result in s3. Here is the code DATA SEGMENT STR1 DB "ENTER FIRST STRING HERE ->$" STR2 DB "ENTER SECOND STRING HERE ->$" STR3 DB "CONCATEnatedD STRING :->$" STR11 DB "FIRST STRING : ->$" STR22 DB "SECOND STRING: ->$" s1 DB 20 DUP("$") s2 DB 20 DUP("$") s3 db 40 dup(?) NEWLINE DB 10,13,"$" DATA

argument to operation or instruction has illegal size 8086 subroutine

房东的猫 提交于 2021-01-29 03:17:34
问题 I started programming in assembler for microprocessor 8086. I try to draw a tree on the screen, sending a subroutine, row, column, amount (collected from the stack), the error I present is argument to operation or instruction has Illegal size on line 21, ie when performing the push count,column,row. DATOS SEGMENT row DB 1 colum DB 39 carac DB 2AH count DB 1 ENDS PILA SEGMENT STACK DB 100 DUP(?) PILA ENDS CODIGO SEGMENT ASSUME CS:CODIGO , DS:DATOS,SS:PILA INICIO : MOV AX,DATOS MOV DS,AX MOV AH

Difference between (sp) and [sp] in assembly

房东的猫 提交于 2021-01-28 11:00:52
问题 I was experimenting with the NASM assembler, when I came across a problem: mov (sp),bx mov [sp],bx The first instruction is assembled properly while the second one is not, and gives me the error: error: invalid effective address Why is this? What's the difference between the two? 回答1: (%sp) would be an AT&T syntax addressing mode. (Invalid because 16-bit addressing modes can't use SP directly, only BP|BX + SI|DI NASM x86 16-bit addressing modes; that's also the reason mov [sp], bx is invalid.