x86-16

Using BIOS int 13h to access sectors in different heads

夙愿已清 提交于 2019-12-24 05:37:26
问题 I have a disk with 63 sectors per track. (I assume, based on my observations) I want to read sectors on a 16 bit bootloader using int 13h. For example, if I want to read sector number 63, I would do the following: mov dl,0x80;Drive number mov dh,0 ;This is head number/platter number mov ch,0 ;This is cylinder number mov cl,63 ;Sector number mov ah,0x02 ;interrupt function mov al,1 ;Number of sectors to be read xor bx,bx mov es,bx ;Making es=0 mov bx,0x8000 ;Any random buffer address int 0x13

Write to address without segment register

ぃ、小莉子 提交于 2019-12-24 00:32:36
问题 I know this code will actually write data to ds:[100h] mov [100h], ax But how can I write to linear address 100H directly without using any segment register for a segment base? 回答1: There is no way to get around segment register; every memory access is relative to some segment register. If you want to write to an absolute address, first load a segment register with an appropriate segment: xor cx, cx mov es, cx ; es = 0000 mov [es:100h], ax ; [0000:0100] = ax To load a linear address larger

NASM: Disk read timeout

拈花ヽ惹草 提交于 2019-12-24 00:02:50
问题 Trying to read data from disk (from the same file), loading 2 additional 512-byte sectors into memory. Disk read function as is: ; read DH sectors to ES:BX from drive DL disk_read: push dx push bx ; Tried to check if disk is ready first, this code runs without errors mov ah, 0x10 int 0x13 jc disk_not_ready mov bx , DISK_CURRENT_STATUS_MSG call print_string mov bx, 0 mov bl , ah call print_hex pop bx mov ah , 0x42 ; BIOS read sector function mov al , dh ; Read DH sectors mov ch , 0x00 ; Select

how to seed a random number generator in assembly?

别来无恙 提交于 2019-12-23 13:33:06
问题 I'm trying to create a complete random number in assembly but it's every time I start the program it gives me the same numbers, in the same order. If the numbers are 12, 132, 4113 or something, it'll repeat them every time I start the code. The program I'm trying to make is something like a guessing game. IDEAL MODEL small STACK 100h DATASEG ;vars here RNG_Seed dw ? CODESEG ; Generates a pseudo-random 15-bit number. ; Parameters: <none> ; Clobbers: AX, DX ; Returns: AX contains the random

Custom keyboard interrupt handler

别来无恙 提交于 2019-12-23 13:09:51
问题 I'm trying to write a simple program that will replace standard keyboard interrupt with a custom one that will decrement a variable. However, it won't work without a call to the old handler. Here is my interrupt handler: handler proc push ax push di dec EF ;pushf ;when these to instructions commented keyboard interrupts handling hangs ;call [OLD] mov al,20h out 20h,al pop di pop ax iret handler endp What actions I should also execute in my handler to make it works without calling the old

Assembly: dynamic memory allocation without malloc and syscalls? [FreeDOS application]

强颜欢笑 提交于 2019-12-23 12:53:55
问题 My question is about the logic of dynamic memory allocation in assembly (particularly, MASM). There are lot of articles on this topic and all of them rely on the use of malloc or brk. However, according to my understanding, malloc as a part of C language must (or could) be certainly written on assembly. Idem for brk, because it's a part of the operating system, thus also written on C which can be replaced 1 to 1 by assembly. Very very long time ago I have seen an article in PCMag about

Newline in 8086 assembly language: my text prints stair-stepped

眉间皱痕 提交于 2019-12-23 09:32:13
问题 I'm getting stair-step output like this My program works correctly, except that when I print a new line, and then print something in the current line, it shows on the next line but with some space before it. The program is this: (print a table of multiple numbers from 0 to 9): data_seg segment I DB 0D J DB 0D R DB ? DIVER DB 10D data_seg ends stack_seg segment stack_seg ends code_seg segment MAIN proc far assume cs:code_seg, ds:data_seg, ss:stack_seg MOV AX,data_seg MOV DS,AX FOR1: MOV J,0D

Assembler switch lower case for upper case and vice versa

空扰寡人 提交于 2019-12-23 06:21:22
问题 im trying to do an Assembler program, that change the upper cases for lower cases and vice versa, all at the same time. For example: the input would be: Hello, this is AN EXAMPLE. And i want the output to be: hELLO, THIS IS an example. all i have get is to change the string to Uppercase only, im using Assembler 8086 and Microsoft Macro Assembler (MASM) as far i know. Thanks! This is my code stackseg segment para stack 'stack' db 32 dup (' ') stackseg ends datasgmt segment para 'data' show db

NASM: how to access ssd drive correctly?

。_饼干妹妹 提交于 2019-12-23 04:49:06
问题 I need to access SSD drive with NASM 16-bit code. When accessing regular hard drive, need to set registers AX, DX, CX to choose Cylinder/Track/Sector/Number of sectors ( AH - to choose read sector function, DL - to choose drive number, CH - to choose cylinder, DH - to choose side on disk, CL - to choose sector on track, AL - to choose number of sectors). However, I suppose SSD disk has some other structure, so how to access them correctly? 回答1: Assuming translation of fake geometry into LBA

Reading a Keypad and displaying it using Microprocessor

不羁的心 提交于 2019-12-23 04:46:01
问题 MTS-88.C and I/O BOARD -08 has 8 (Eight) 7-segment displays and 20 key-pads on board. The displays are numbered from 7-SEG.1 to 7-SEG.8 and are connected to Port B’s PB7 to PB0 lines respectively. To display a character on a 7-segment display a byte has to be written to port B. The MSB 4 bits are the address of the 7-segment display and LSB 4 bits are the data. So if we write 58 H to port B then the 6th 7-segment display will show data 8. 20 key-pads are numbered from P01 to P20 and are