x86-16

How to print an integer stored in a variable

偶尔善良 提交于 2019-12-11 07:46:42
问题 So I have a program in 8086 assembly that allows the user to enter 2 digits, store them in a variable and then print out the number: data segment broj db ? ends stack segment dw 128 dup(0) ends code segment mov ax, data mov ds, ax mov es, ax mov ah, 1h int 21h sub al, 48d mov bl, 10d mul bl mov broj, al mov ah, 1h int 21h sub al, 48d add broj, al mov dl, broj sub dl, 48d mov ah, 2h int 21h mov ax, 4c00h int 21h ends However whenever I enter a number for example 21 it doesn't give me the

Assembly program that finds second largest value in array

天大地大妈咪最大 提交于 2019-12-11 07:29:09
问题 I wrote a assembly program that finds the max value in an array, but now I would like it to find the second largest number in the array. How would I modify my program to do this? This is the program I wrote and it does work. The program prints all the values in the array and then finds the max value of the array. Now I want it to find the second largest value. %include "io.mac" .STACK 100H .DATA Numbers DW 3,4,5,2,6,0 msg0 db "Printing values in array",0 msg1 db "Max",0 msg2 db "Min",0 .CODE

Unable to display negative numbers using array in the following 8086 assembly code

穿精又带淫゛_ 提交于 2019-12-11 06:02:49
问题 What i am trying to do I am trying to print a series of negative and positive numbers using array. What is the problem I am not able to print negative numbers. Input: 2,-3,-4,5,2,9 Output: 2-,529 My 8086 Assembly Code: .model small .stack 100h .data elements db 2,-3,-4,5,2,9,'#' .code mov ax, @data mov ds, ax mov al, 03h mov ah, 0 int 10h mov si, 0 ;lea si, elements dis: cmp elements[si], '#' je exit mov dl, elements[si] add dl, 48 mov ah, 02h int 21h inc si loop dis exit: mov ah, 04ch int

Infinite LOOP - Assembly 8086

旧城冷巷雨未停 提交于 2019-12-11 05:49:11
问题 The program returns an infinite number of r (they should be just 6), so I think the problem is the LOOP istruction, but I don't know how to solve it. section .text global _start _start: mov ecx, [x] ;x is a constant (5) _cicloStampa: push ecx call _outputsingolocarattere pop ecx LOOP _cicloStampa jmp _esci _outputsingolocarattere: mov ecx, stringa mov edx, 1 mov ebx, 1 mov eax, 4 int 0x80 ret _esci: mov eax, 1 mov ebx, 0 int 0x80 section .data x db 6 stringa dw "r" len equ $ - stringa 来源:

Why do multiple strings overlap/overwrite in my output in assembly?

两盒软妹~` 提交于 2019-12-11 05:31:53
问题 I'm having a problem displaying 4 different strings in only one line in assembly 8086. The output should be "You are", "first name", "middle name", and "last name". It works fine with the first two, but the last two overlaps with the first one, meaning, "You are" ends up being rewritten by "middle name", and further gets rewritten by "last name". If I use next line before both of the last two, it prints out fine, but I want to display all 4 strings in one line, not display it in 3 lines. I

Assembler 8086 divide 32 bit number in 16 bit number

故事扮演 提交于 2019-12-11 04:58:32
问题 I try to divide 32 bit number in 16 bit number. For example 10000000h divide by 2000h.According the desgin I try to do I divide 4 right digits with the divisor and then the 4 left digit by the divisor. This is my code : .DATA num dd 10000000h divisor dw 2000h result dd ? remainder dw ? .CODE main: mov ax,@DATA mov ds,ax xor dx,dx mov cx ,word ptr divisor mov bx,offset num mov ax,[bx] div cx mov bx,offset result mov [bx],ax mov bx,offset num mov ax,[bx+2] mov ax,[bx+2] div cx mov bx,offset

How to make timer works? Call int 4ah 5 seconds after start

自闭症网瘾萝莉.ら 提交于 2019-12-11 04:49:57
问题 I'm creating a program, that should print "Hello from handler" five seconds after start. At first I created interrupt 4ah by proc called create_interrupt . This interrupt causes int_handler , that prints string "Hello from handler". Then proc "alarm" get curent time, add 5 second to it and set alarm by func 06h of int 1ah. This alarm should call int 4ah after 5 seconds from start, but it doesn't works and I don't know why. If I call 4ah "by hand", just by adding "int 4ah" it works, it means

Assembly 8086 listening keyboard interrupt

邮差的信 提交于 2019-12-11 04:36:09
问题 I have exactly the same question as this: Listen to keyboard while drawing But the first answer (accepted one) listens keyboard for exactly once. So how can I modify my code so that I can listen keyboard interrupt for more then once. This is my code: .model small draw_row Macro x Local l1 ; draws a line in row x from col 10 to col 300 MOV AH, 0CH MOV AL, 4 MOV CX, 0 MOV DX, x L1: INT 10h INC CX CMP CX, 320 JL L1 EndM .stack 100h .data height1 dw 51 width1 dw 65 v1 dw ? v2 dw ? CUR_POSX_USER

why must we initialize DS And ES registers in MS-DOS? [duplicate]

泄露秘密 提交于 2019-12-11 04:03:55
问题 This question already has answers here : Why doesn't MS-DOS initialize the DS and ES registers? (2 answers) Closed 5 years ago . in MS-DOS ,Why the initialization of the DS and ES registers must be done manually by the programmer, although it's operating system responsibility to initialize these registers. why mustn't we do this for CS and SS registers ? Which feature of MS-dos Leads into this? 回答1: It's just a choice of the OS designer. DOS is a minimal OS, so it does the minimum possible.

What's the purpose of PUSH CS / POP DS before a REP MOVSW?

萝らか妹 提交于 2019-12-11 03:09:38
问题 Why in below code we push code segment (PUSH CS) and then popping it into the data segment (POP DS)? I am giving these lines explicitly as line1 and line2. Please let me know how MOVSW is working here. IF HIGHMEMORY PUSH DS MOV BX, DS ADD BX, 10H MOV ES, BX PUSH CS. ;line1 POP DS. ;line2 XOR SI, SI MOV DI, SI MOV CX, OFFSET SYSSIZE + 1 SHR CX, 1 REP MOVSW. ;line3 POP DS PUSH ES MOV AX, OFFSET SECONDRELOCATION PUSH AX AAA PROC FAR RET AAA ENDP SECONDRELOCATION: more code here.............. 回答1