x86-16

What does OFFSET in 16 bit assembly code mean?

做~自己de王妃 提交于 2019-11-30 01:31:54
问题 I am going through some example assembly code for 16-bit real mode. I've come across the lines: mov bx, cs mov ds, bx mov si, OFFSET value1 pop es mov di, OFFSET value2 what is this doing? What does having 'OFFSET' there do? 回答1: As some of the other answers say, the offset keyword refers to the offset from the segment in which it is defined. Note, however, that segments may overlap and the offset in one segment may be different in another segment. For instance, suppose you have the following

How many ways to set a register to zero?

风流意气都作罢 提交于 2019-11-29 22:17:43
I'm curious how many ways are there to set a register to zero in x86 assembly. Using one instruction. Someone told me that he managed to find at least 10 ways to do it. The ones I can think of are: xor ax,ax mov ax, 0 and ax, 0 There are a lot of possibility how to mov 0 in to ax under IA32... lea eax, [0] mov eax, 0FFFF0000h //All constants form 0..0FFFFh << 16 shr eax, 16 //All constants form 16..31 shl eax, 16 //All constants form 16..31 And perhaps the most strange... :) @movzx: movzx eax, byte ptr[@movzx + 6] //Because the last byte of this instruction is 0 and... @movzx: movzx ax, byte

Print numbers diagonally in assembly

梦想与她 提交于 2019-11-29 18:40:15
I'm trying to display 0-9 diagonally in assembly, but the output puts my diagonally printed numbers in the middle of the window. Here is the code: start: mov ah, 02h mov cl, 0Ah ;counter (10) mov dx, 02h ;mov bx, 02h mov dl, 30h ;start printing 0-9 mov dh, 02h ;start row mov al, 02h int 21h again: int 10h int 21h ;add dx, 01h inc dh inc dx inc al loop again mov ax, 4c00h int 21h The output should be: 0 1 2 3 4 5 6 7 8 9 The current output prints that, but on the middle of the window. I've tried adding a new register bh and use it to put my cursor on my current position when I execute the file.

emu8086 change case of the entered string and reverse it [closed]

陌路散爱 提交于 2019-11-29 18:28:33
I am totally new in assembly language programming and I am stuck with a problem in which I need to change case of the entered string plus reverse the string as well. I am using emu8086. I the following code I am either able to change case or reverse the string. but I need to perform both the operations simultaneously. .MODEL CASECHANGE .DATA MSG1 DB 0DH,0AH, 'Enter string:$' MSG2 DB 0DH,0AH, 'String in reverse case:$' STR1 DB 255 DUP(?) .CODE START: MOV AX,@DATA MOV DS,AX LEA DX,MSG1 MOV AH,09H INT 21H LEA SI,STR1 MOV AH,01H jz offsets GET: INT 21H MOV BL,AL CMP AL,0DH JE SET XOR AL,20H MOV

DOSBox: debug.exe reads file - processes commands incorrectly

ε祈祈猫儿з 提交于 2019-11-29 18:16:35
I'm trying to use DOSBox with debug.exe on a 64-bit system. It works perfectly fine if I enter the commands manually. When I redirect input from a file with: debug < [file] it doesn't work. On every line except for the first it displays an error similar to this: DOSBox will eventually hang and crash. Is there any way to fix this? The input file I am trying to process as commands is: a 100 jmp 145 db 'Hello, World!', 0D, 0A, 'Press any key to continue . . .$' a 145 mov ah, 09 mov dx, 102 int 21 mov ah, 08 int 21 int 20 rcx 100 n hello.com w q Michael Petch I can reproduce the behavior you are

NASM: operation size not specified

*爱你&永不变心* 提交于 2019-11-29 17:51:38
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 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 specified in NASM. You could avoid the error specifying the type, as shown below: SECTION .text global start start:

INT 13, 2 hanging on x86 real mode when trying to read sectors from floppy drive

天大地大妈咪最大 提交于 2019-11-29 15:18:32
I'm writing a DOS clone for a school project and I'm trying to read some sectors from a floppy drive (mainly the root directory of a FAT12 file system, sector 19) using BIOS INT 13, 2. I set the parameters right - or at least I think I do so - and then call INT 0x13 with AH = 2. Then, though, the system hangs. I can't figure why. I'm using the following code to call the interrupt: mov ah, 0x2 ;Read sectors function mov al, 1 ;I want to read one sector mov ch, 0 ;From track 0 mov cl, 2 ;Sector 2 mov dh, 1 ;Head 1 mov dl, [device_number] ;Obtained from BIOS during boot mov bx, 0x7C0 ;Buffer

The controls of my game freeze after the first keypress with int 16h / ah=1

倖福魔咒の 提交于 2019-11-29 15:15:20
I am coding a game in assembly 8086. I fixed the issue when the game didn't open, but I can't fix the controls. The ESC key works. When I press it, it goes to _QUIT function, but if any other key was pressed before that, the controls freeze and don't react on any key. Is there something wrong with my function? I tried to change the AL register to AH , but it didn't work. _KEYCHECK: mov ah,01h int 16h cmp al,1Bh ;ESC je _QUIT cmp al,48h ;UP je _PLAYER.UP cmp al,50h ;DOWN je _PLAYER.DOWN cmp al,4Bh ;LEFT je _PLAYER.LEFT cmp al,4Dh ;RIGHT je _PLAYER.RIGHT ret Your _KEYCHECK function is using the

A2004 Problem With MASM32

别说谁变了你拦得住时间么 提交于 2019-11-29 12:48:14
I have a problem with the MASM32 assembler The following code is a Hello World example that I copied from the MASM32 tutorial: .model small .stack .data message db "Hello world!", "$" .code _main proc mov ax,seg message mov ds,ax mov ah,09 lea dx,message int 21h mov ax,4c00h int 21h _main endp end _main On attempt to assemble, MASM32 throws A2004 error with the following comment: C:\masm32\console.asm(11) : error A2004: symbol type conflict Can anyone help me with that? This code worked perfectly fine with the TASM assembler, but now I have to use MASM32 and I am having this A2004 error for

divide emu 8086 assembly error [duplicate]

谁说胖子不能爱 提交于 2019-11-29 12:25:44
Possible Duplicate: ASM x86 integer overflow I get a divide error- overflow and am not sure why. Here is the complete code that reproduces the error include emu8086.inc org 100h mov ax, 2 mov bx, 10 div bx mov ax, 2 mov bx, 2 div bx ret Try adding xor dx, dx before each div and see if that doesn't help. Since you're specifying a 16-bit target, div divides dx:ax by that target. If dx starts out containing a large number (more accurately, anything but quite a small number), the result will overflow. Even if it doesn't overflow, your result won't just be ax / bx as you apparently intend. 来源: