x86-16

NASM: operation size not specified

只谈情不闲聊 提交于 2019-12-17 17:18:01
问题 I wrote this code in emu8086 and it goes well in the emulator but when I'm trying to compile it with NASM it's throwing me up the error: "operation size not specified", help someone? add bx,[3565] sub bx,0xcc mov [bx],0CCh 回答1: NASM can't figure out what you meant by a line like mov [bx],0CCh . Clearly, this sets something to 0CCh. But do you want to have bx pointing to a single byte , short, long, ...? This will manifest itself as the fairly self-explanatory error: operation size not

swapping 2 registers in 8086 assembly language(16 bits)

元气小坏坏 提交于 2019-12-17 17:15:18
问题 Does someone know how to swap the values of 2 registers without using another variable, register, stack, or any other storage location? thanks! Like swapping AX, BX. 回答1: You can do it using some mathematical operation. I can give you an idea. Hope it helps! I have followed this C code: int i=10; j=20 i=i+j; j=i-j; i=i-j; mov ax,10 mov bx,20 add ax,bx //mov command to copy data from accumulator to ax, I forgot the statement, now ax=30 sub bx,ax //accumulator vil b 10 //mov command to copy

Random number in assembly

牧云@^-^@ 提交于 2019-12-17 17:01:27
问题 I am new to assembly and would like to know how to write a program in EMU8086 that prints a different random number in every run of it. Is it possible to do it without using interrupts? 回答1: If you were using a real version of DOS (not EMU8086) @fuz method is the way you can do it, and it doesn't require interrupts. You just read the lower 16-bits of the 32-bit value at memory address 0x46c (0x00040:0x006c) in the BIOS Data Area(BDA). The value at that location is a 32-bit value representing

TASM running LED animation with specific time of stop

和自甴很熟 提交于 2019-12-17 10:04:43
问题 Im very new in this assembly language can you guys help me .model small .stack .code org 100h start: main proc mov cx,1; how many times to loop here:mov al,00000001b mov dx,378h out dx,al call delay mov al,00000010b mov dx,378h out dx,al call delay mov al,00000100b mov dx,378h out dx,al call delay mov al,00001000b mov dx,378h out dx,al call delay mov al,00010000b mov dx,378h out dx,al call delay mov al,00100000b mov dx,378h out dx,al call delay mov al,01000000b mov dx,378h out dx,al call

How buffered input works

你说的曾经没有我的故事 提交于 2019-12-17 04:36:13
问题 The input in next program works OK, but when I ask to display the output, DOS doesn't display anything at all! How is this possible? ORG 256 mov dx, msg1 mov ah, 09h ;DOS.WriteString int 21h mov dx, buf mov ah, 0Ah ;DOS.BufferedInput int 21h mov dx, msg2 mov ah, 09h ;DOS.WriteString int 21h mov dx, buf mov ah, 09h ;DOS.WriteString int 21h mov ax, 4C00h ;DOS.TerminateWithExitcode int 21h ; -------------------------------------- msg1: db 'Input : ', '$' buf: db 20 dup ('$') msg2: db 13, 10,

Assembly, printing ascii number

那年仲夏 提交于 2019-12-17 03:22:06
问题 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

What is the best way to move an object on the screen?

北慕城南 提交于 2019-12-17 02:32:26
问题 I wanted to know what is the best way for moving an object on the screen- for expample: if some kind of shape presented on the screen(on graphic mode), I would like to move it left and right using the keyboard's arrows keys. I know how to read the keyboard buffer. The important thing is that I would like to know is how to move something smooth on the screen. I'm using DOS-Box, with 8086 architecture. And the movment must be on graphic mode (320X200). 回答1: OK finally got TASM+TLINK to work

Want to save value from a variable into register

妖精的绣舞 提交于 2019-12-14 04:14:17
问题 I m using MASM compilor and DOSBOX. I want to Want to save value from a variable into register. i want to save num1 value into cx register. How can i do that? .MODEL SMALL .STACK 50H .DATA num1 db '5' NL DB 0DH, 0AH, '$' msg db ?,0AH,0DH,"Enter an odd number between 0 to 10:$" nxtline db 0Ah,0DH,"$" .CODE MAIN PROC MOV AX, @DATA MOV DS, AX LEA DX,msg mov ah,9 int 21H LEA DX,nxtline mov ah,9 int 21H MOV AH,1 INT 21H LEA DX,nxtline mov ah,9 int 21H mov bl,al ;save the value from input mov num1

How to count the occurence of specific characters in a string in emu8086

痴心易碎 提交于 2019-12-14 03:36:15
问题 Please. .kindly help me on this problem. . Output: Enter string: already A - 2 B - 0 C - 0 D - 1 E - 1 回答1: Write a procedure that loops over the entire string in search of a specific character. For each match increment a counter. Upon return display the result as character DL occurs DH times : e.g. "A - 2". mov dl, "A" call CountChar ... print result ... mov dl, "B" call CountChar ... print result ... CountChar: mov dh, 0 mov cx, ... length of the input string ... jcxz Ready mov bx, ...

How to print text in color with interrupts?

纵然是瞬间 提交于 2019-12-14 03:22:09
问题 This is my code it print in white color which is the default one. I know how to print in color without interrupts, but I don't want to do that. I want to print it in any other color using interrupts.How can I do that?? Any Idea? Thanks in advance I am using emu8086 as an assembler data segment wellcome db 'Wellcome User !',13, 10 ,'$' how db 'how are you',13,10,'$' ends stack segment dw 64 dup(0) ends code segment start: push ax mov ax,data mov ds,ax mov es,ax pop ax lea si, wellcome call