Merry Christmas
TECHNOLOGICAL INNOVATION FOR HUMANITY

Classic Knowledge on 8086 Addressing Modes

written by Antonius - roboticist, hardware hacker & low level hacker based in Indonesia
robohax.com - technological innovation for humanity
date : 11-09-2014
https://sw0rdm4n.wordpress.com/2014/09/11/classic-knowledge-on-x86-addressing-modes/

8086 Addressing Modes

It’s very important to understand addressing mode before understanding instruction sets. Here we provide several data addressing mode examples.
What we given here is not a complete list, since the purpose is just for understanding x86 instruction syntaxs:

Immediate Addressing Mode

Using immediate addressing mode means the data or operand immediately included in instruction. Examples:

mov ax,0h
mov al, 1b 
mov ah, 1b  
 

For example “mov ax, 11b” will move immediate value : 11 binary to ax register, those 2 bit will be moved to al register. So basically  it’s the same instruction as “mov al, 11b”.
Before mov on 8 bit register al, when ah = 0h and al = 0h, before mov ax,11b :

al 8 bit register:
[0][0][0][0][0][0][0][0]

After mov ax,11b:

al 8 bit register:
[0][0][0][0][0][0][1][1]

Another example when ah = 0h and al=0h : “mov ax, 100h”. Since 100h in binary is “100000000b” it will overflow 8 bit register al, hence the first bit : “1b” will be placed on ah register.
Before mov ax,100h:

al (accumulator low) 8 bit register :
[0][0][0][0][0][0][0][0]

ah (accumulator high) 8 bit register:
[0][0][0][0][0][0][0][0]

After “mov ax, 100h” :

al (accumulator low) 8 bit register :
[0][0][0][0][0][0][0][0]

ah (accumulator high) 8 bit register:
[0][0][0][0][0][0][0][1]
 

Direct Offset / Displacement Addressing Mode

Using direct addressing, we directly load an offset address of variable to a register.

Example:

mov dx, ds:[10ah]
mov dx, offset variable

For example:

.model tiny
.data
    hax db 'h4x0r$'
.code
org 100h 
start:
    mov dx, offset hax; -> direct offset address addressing
    mov ah, 9h
    int 21h
    int 20h
end start

Using direct offset addressing, we directly put offset address of string hax to dx register.
The rule is that if no segment register specified, default segment register that will be used is ds, and as any other transfer instruction operand’ maximal size is size of destination.

 

We can see we directly transfer offset address of hax string which at offset address 10ah to dx register, if we dump 10ah about 5 bytes we can see it contains string “h4x0r” which
previously defined before.
We can also use memory address as displacement (on masm we use disp keyword, in this example we use tasm without disp keyword):

;displacement mode sample
;simple code by : Antonius (sw0rdm4n)
;www.ringlayer.net
.model tiny
.data
	binx db 41h
.code
org 100h
start:
	mov ah,2h
	mov dx, ds:[10ah]
	int 21h
	int 20h
end start	
 

“mov dx, ds:[10ah]” will move byte at address ds:10ah to register dx.

Register Direct Addressing Mode

Direct register addressing mode will use directly content of an operand register. Examples:

mov ax, bx; move bytes content of bx register to ax register
mov dl,al; move bytes content of al register to dl register

The rule is register size must be the same. If source is 8 bit regsiter, destination must be also 8 bit register. You won’t put operand size larger than destination register.

Register Indirect Data Addressing Mode

Using register indirect addressing to access data means we use a register as a pointer to a memory address contains specific bytes.
Examples:

    mov dx, [bx]
    mov dx, cs:[bx] ; for different code segment

For example once instruction “mov dx, [bx]” executed, what happens is microprocessor will check offset address that is in bx register, for example bx register contains : “10e”.
Microprocessor will suppose it as an offset address, Microprocessor then will fetch 2 bytes on offset 10eh and move it to dx register.

Example code:

;indirect register example
;made by sw0rdm4n
;www.ringlayer.net
.model tiny
.data
	hax db 01000001b
.code
org 100h
start:
	mov bx, 10eh
	mov dx, [bx]
	mov ah,02h
	int 21h
	mov dx, offset hax
	int 20h    
end start

Actually instruction “mov dx, offset hax” is a junk, this is just for debugging purpose, just like printf(on user space c codes) and printk (on kernel space c codes).
At first “mov bx, 10eh” this instruction will move 10eh. 10eh will be supposed as offset address of variable hax.
mov dx, [bx], in this instruction, processor will assume bx as offset address pointer. Next, microprocessor will check offset address that recorded on bx register, within next sequece,
microprocessor will get 2 bytes from 10eh and move it to dx register.

Indexed Addressing Mode

This mode uses special purpose index register such as si and di.

Examples:

     call cs:[di]
     add byte ptr cs:[di], 1b  
     mov bx, cs:[si]
     mov al, byte ptr cs:[di]
     mov byte ptr cs:[di], al   
     mov byte ptr cs:[di], 1b  
     and byte ptr cs:[si], 11111111b     

The possible combinations :

cs:  | 
ds:  |    si / di
ss:  |
es:  |

If no segment register specified, by default ds will be used.

Example code:

;simple index addresing mode example
;made by Antonius (@sw0rdm4n)
;http://ringlayer.net
;compile with tasm 2.0 and tlink 3.0
.model tiny 
.data
	sayhawatpu db 73h,61h,79h,68h,61h,77h,61h,74h,70h,75h ; string sayhawatpu
	indexme db 10  dup (?) 
 .code 
 org 100h
 main:    
	mov si, offset sayhawatpu
	xor cx, cx
	call _setvid
looper:
	mov bl, byte ptr cs:[si]; indexed addressing mode example
	mov byte ptr[indexme], bl
	mov dl, byte ptr[indexme]
	call _printout
	inc cx
	inc si
	cmp cx, 1010b
	jl looper
	int 20h
_printout proc near
	mov ah, 2h
	int 21h
	ret
_printout endp
_setvid proc near
	mov al, 0h
	mov ah,00h
	int 10h
	ret
_setvid endp
end main
 

On routine : “mov bl, byte ptr cs:[si]” it will move byte that pointed by offset address which recorded in source index.

What above codes did is simple, just print string “sayhawatpu” in vga video mode.

Base Indexed Addressing Mode

This addressing to access data uses combination of base register (bx and bp) and index register (si and di) to acquire data in memory.

Examples:

and cs:[bx+di], bx 
jmp cs:[bx+di] 
add byte ptr cs:[bx+di],1h     
mov cs: [bx+di],100h     
mov cs: [bp+si],bx
mov bx, cs: [bp+di]
mov bl, byte ptr cs:[bp+di]

The possible combinations :

cs:    |                |
ds:    |   bx+ / bp+    | si / di
ss:    |                |
es:    |                |
 
 
 

Example code:

;simple base and index addresing mode example
;made by Antonius (@sw0rdm4n)
;http://ringlayer.net
;compile with tasm 2.0 and tlink 3.0
.model tiny 
.data
	ibmbio db 73h,75h,64h,61h,68h,20h,61h,64h,61h,20h,76h,61h,6bh,73h,69h,6eh ; sudah ada vaksin
	indexme db 16  dup (?) 
 .code 
 org 100h
 main:    
	mov si, offset ibmbio
	xor cx, cx
	call _setvid
looper:
	mov bp, 0h
	mov bl, byte ptr cs:[bp + si]; base and indexed addressing mode example
	mov byte ptr[indexme], bl
	mov dl, byte ptr[indexme]
	call _printout
	inc cx
	inc si
	cmp cx, 10000b
	jl looper
	int 20h
_printout proc near
	mov ah, 2h
	int 21h
	ret
_printout endp
_setvid proc near
	mov al, 13h
	mov ah,00h
	int 10h
	ret
_setvid endp
end main
 
 
 

On routine “mov bl, byte ptr cs:[bp + si]”, we see base and indexed addressing mode example. What it does is moving a byte that pointed by offset address which
a result of calculation of bp + si into bl register.
bl register.

And again, what it does is simply print string in vga mode : “sudah ada vaksin”

Base Index and Displacement Data Addressing Mode

This mode is combination of indexed, base and displacement data addressing mode. Displacement can be 8 bit or 16 bit depends on the size of destination and purpose of routine.
The possible combinations :

cs:  |       |           |
ds:  | bx+ / | si+ / di+ | displacement
ss:  | bp+   |           |
es:  |       |           |

Examples:

mov dl, [bp + si + 1] 
mov dx, [bx + si + 10h] 
 
 
 

Example code:

;simple base and index addresing with displacement example
;made by Antonius (@sw0rdm4n)
;http://ringlayer.net
;compile with tasm 2.0 and tlink 3.0
.model tiny 
.data
	ibmbio db 68h,61h,78h ; hax
	indexme db 3  dup (?) 
 .code 
 org 100h
 main:    
	mov si, offset ibmbio
	call _setvid

	mov bp, 0h
	mov bl, byte ptr cs:[bp + si + 0h]; base indexed + displacement example
	mov byte ptr[indexme], bl
	mov dl, byte ptr[indexme]
	call _printout

	mov bp, 1h
	mov bl, byte ptr cs:[bp + si + 0h]; base indexed + displacement example
	mov byte ptr[indexme], bl
	mov dl, byte ptr[indexme]
	call _printout

	mov bp, 0h
	mov bl, byte ptr cs:[bp + si + 2h]; base indexed + displacement example
	mov byte ptr[indexme], bl
	mov dl, byte ptr[indexme]
	call _printout
	int 20h
_printout proc near
	mov ah, 2h
	int 21h
	ret
_printout endp
_setvid proc near
	mov al, 13h
	mov ah,00h
	int 10h
	ret
_setvid endp
end main

For example on this routine :”mov bl, byte ptr cs:[bp + si + 2h]” , this means to move a byte that’s located from offset address calculation of bp + si + 2h

Productions (Total : 5)

Inventions Robots Electronics Gadgets Circuit Design AI IOT Electrical
RoboMall - A Teleoperated Mall Robot by Robotsoft
inventions
RoboMall - A Teleoperated Mall Robot by Robotsoft

RoboMall was developed by Antonius (w1sdom) in 2023, The robot was designed to be operated in a mall. The purpose is that mall visitors doesn't need to visit mall directly, instead, they can use this robot to stroll in a mall and if they deposit in RoboMall wallet system they can buy things on mall, then the goods will be delivered by couriers.

iot
Robotsoft LightBox - IOT Lightning

Robotsoft LightBox is a solar powered outdoor lighting. Features : water proof, controlled by voice & android application. This product was created by Antonius (w1sdom). This product was created for his startup Robotsoft in 2020.

iot
Robotsoft FloorLight - IOT Lightning

Robotsoft FloorLight is a solar powered outdoor lighting. Features : water proof, controlled by voice & android application. This product was created by Antonius (w1sdom). This product was created for his startup Robotsoft in 2020.

iot
Robotsoft Torch - IOT Lightning

Robotsoft Torch is a solar powered outdoor lighting. Features : water proof, controlled by voice & android application. This product was created by Antonius (w1sdom). This product was created for his startup Robotsoft in 2020.

electrical
Robotsoft Solar - Solar Powered Electrical Generator

Solar Powered Electrical Generator. This generator created by Antonius (w1sdom). This product created for his startup Robotsoft in 2020.

Show All

Prototypes (Total : 6)

Inventions Robots Electronics Gadgets Circuit Design AI IOT Electrical
INVENTIONS PROTOTYPE
Haxtronic - My First Generation Hacker Robot - Developed in 2014

The first hacker robot that I created. This robot was developed in 2014. Some demo videos were posted in Youtube around 2016. This robot can explains about low level exploitation techniques. Robot skills : can hack wifi (wpa cracking using aircrack), evil twin, wifi deauth, arp cache poisoning. My old video channel --> https://www.youtube.com/@antoniusringlayer/videos

ROBOTS PROTOTYPE
Inem Robot

I planned to develop a spy robot, but this robot was too big. The chassis was created using metals. Developed in 2017, posted in youtube around 2019. Developed by Antonius (w1sdom)

Airhax Wireless Network Auditor Device
HACKER GADGET PROTOTYPE
Airhax Wireless Network Auditor Device

Airhax is a wireless network auditor gadget. This device was created in 2015. This gadget functions : wifi cracking, evil twin, wifi deauth, arp poisoning. Developed by Antonius (w1sdom / sw0rdm4n / ev1lut10n / robotsoft)

ROBOTS PROTOTYPE
Ultrasonic Robot

I built this robot in 2014. It is a shy robot that is afraid of humans. I used 3 ultrasonic sensors.

ROBOTS PROTOTYPE
Giant Robot

A large-scale prototype robot powered by a mini PC and an Arduino, built as a personal project rather than a commercial product. At first, I planned to equip it with high-torque servos and an airsoft gun, but I realized that could be dangerous, so I scrapped the idea. Real hacking should be harmless. Build 2017 - by Prof. Antonius Robotsoft

Various Robots (finished and unfinished)
ROBOTS PROTOTYPE
Various Robots (finished and unfinished)

Various Robots (finished and unfinished) - build by Antonius Robotsoft (w1sdom).

Show All

Videos (Total : 0)

Show All

Blog (Total : 25)

Inventions Robotics Electronics Math & Physics Artificial Intelligence Electrical Computer >> more
ELECTRONICS
Identifying Resistor Value

A short guide on identifying resistor value. This post was taken from my old blog post : https://sw0rdm4n.wordpress.com/2014/12/06/identifying-resistor-value/

ELECTRONICS
Controlling Many Servo(s) Using IC TLC5940

Tlc5940 is a 16 channel led driver. Since this IC has pwm control ability we can use this IC for controlling up to 16 servo(s).

MATHEMATICS-PHYSICS
Forward Kinematics Calculation for Robotic Arm

Kinematics is a branch of mathematics, physics and classic mechanical engineering. There are 2 mostly used kinematics in robotic field, they are : forward kinematics and inverse kinematics. Forward kinematics is frequently used to calculate the position of end effector when we know the degree value of each joint, meanwhile inverse kinematics is used to compute the degree of each joint when we know the position of the end effector.

ROBOTICS
Haxtronic Robot Development in 2013-2015

This post was taken from my old blog post in 2015. Haxtronic was my first generation hacker robot that I built from 2013-2015

MATHEMATICS-PHYSICS
Matrix Determinant - Laplace and Sarrus Method

An introduction to matrix determinants in linear algebra, explaining how to calculate determinants using Sarrus' rule and Laplace expansion through step-by-step mathematical examples.

MATHEMATICS-PHYSICS
Regular Matrix Inverse and Pseudoinverse Using Singular Value Decomposition (SVD)

A step-by-step guide to calculating matrix inverses and Moore-Penrose pseudoinverses using the adjugate method and Singular Value Decomposition (SVD), with manual calculations, Python NumPy implementations, and applications in robotic inverse kinematics.

MATHEMATICS-PHYSICS
Calculus 3 - First Order Partial Derivatives

An introduction to first-order partial derivatives in multivariable calculus, featuring step-by-step calculations for functions of two and three variables and their relevance to Jacobian matrices and robotic inverse kinematics.

ARTIFICIAL INTELLIGENCE
Convolutional Neural Network for Object Recognition and Detection

An exploration of Convolutional Neural Networks (CNNs) for object recognition and detection, covering mathematical foundations, feature extraction, activation functions, and popular deep learning architectures such as LeNet, VGG16, ResNet, and RetinaNet, with practical Python and Keras examples.

ARTIFICIAL INTELLIGENCE
Cardboard Box Detection and Localization using RetinaNet (Keras)

In this guide, we are going to train a model using keras retinanet to detect and localize a custom object : “cardboard box” from the image.

ARTIFICIAL INTELLIGENCE
Convolutional Operation in Convolutional Neural Network

Technical guide on convolutional operations behind convolutional neural network.

ELECTRONICS
Switch Based on Contact (SPST, SPDT, DPST, DPDT)

An introduction to four common types of electrical switches (SPST, SPDT, DPST, and DPDT), explaining their contact configurations, operating principles, and practical applications through simple diagrams and real-world examples.

ELECTRONICS
Motor DC Control (1 direction only) Using ULN2803 (Darlington Array Transistor)

This tutorial is about motor dc control using uln2803 ic. Taken from my old blog post.

Show All
ABOUT
Technological Innovation for Humanity

Robohax is dedicated to provide creative, innovative technological innovations that benefits humanity.

Our projects range from autonomous robots, electronic devices and IoT devices for commercial / business to custom robots & hacking gadgets for physical penetration testing.

DISCIPLINES
What We Do
  • Robotics for Business
  • Technology inventions
  • IoT Devices
  • Electronics Prototyping
  • Robotics for Penetration Testing
  • Robotics for Exploitation
  • Custom Hacking Gadgets
  • Hardware Reverse Engineering
THE FOUNDER

Robohax was founded by Antonius. Antonius (w1sdom) is a roboticist, technology inventor, hardware hacker, low level hacker & electronic engineer based in Indonesia.

INVENTIONS

Robomall (2023)
RoboHax is a teleoperated robot that allows shoppers to visit shopping malls without having to be there in person. Users can remotely navigate the mall, browse storefronts, explore products, and shop as if they were physically there. To make purchases, users can add funds to their RoboWallet, and their purchases will be delivered to their doorstep through an on-demand courier service.

Haxtronic (2014)
The concept behind the world's first hacking robot, designed to perform WPA cracking, Evil Twin Wi-Fi attacks, and Wi-Fi deauthentication. The robot is also equipped with Artificial Narrow Intelligence (ANI) specialized in cybersecurity, enabling it to explain low-level exploitation concepts and techniques. Natural language processing is powered by the Natural Language Toolkit (NLTK).

NOTABLE RECORDS

The first hacker from Indonesia who confirmed to have written a paper for Phrack.
Paper : UAF Exploitation in The Sheaves Era

This paper presents a novel heap-based use-after-free exploitation technique for the Linux 7.0 kernel, developed by Antonius (w1sdom).

Sitemap

PRODUCTIONS
Finished Projects

Completed robots, electronics, hacking gadgets and other hardware projects.

PROTOTYPES
Work in Progress

Prototypes and experimental builds currently in development.

VIDEOS
Video Content

Demos, tutorials and project walkthroughs.

BLOG
Articles & Write-ups

Technical write-ups on robotics, electronics, hacking gadgets and more.

ABOUT
About RoboHax

Profile, disciplines and links.

Contact

Pm me on
My Linkedin

Order

You want a custom robot or gadget ?
Pm me on
My Linkedin

Home Productions Prototypes Videos Blog Order About Contact
RoboHax ScorpioGuard BlueDragonSec