Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › Programming Tutorials › Object-oriented assembly <FASM>

CoolObject-oriented assembly <FASM>

Posts 1–4 of 4 · Page 1 of 1
TR
TrollerCoaster
Object-oriented assembly <FASM>
I used FASM Struct libs to demonstrate this and 16-bit assembly. This will also work for 32 bit assembly and it is possible to do this without struct libraries, which I show later.
Code:
use16
org 100h ;ew, DOS

include "MACRO\STRUCT.INC"

jmp start

struct Enemy ;new class/object
  hp dd 22
  name db 'Zombie$'
  getName dw Enemy_getName ;You can put functions, variables, whatever you'd like!
  size db 0
ends

Enemy_getName:
  mov ax,bx ;We can assume bx is the instance pointer since function new returns it that way. Register ES may also be a good choice.
  add ax,Enemy.name ;Enemy.name is an offset to the name variable, so add it
  ret

enemy Enemy ;use this as your default instance for copying

start:
  mov ax,enemy ;push the default instance
  mov bx,Enemy.size ;push the STRUCT's .size
  call new

  ;new returns the instance pointer in bx, so do what you need to do with it

  call [bx+Enemy.getName] ;We could just directly get the pointer as well with mov ax,[bx+Enemy.name]
  mov dx,ax ;we'll use a DOS interrupt to print the new enemy's name. mov dx,[bx+Enemy.name] would've been more efficient.
  mov ah,09 ;DOS print-string
  int 21h ;DOS interrupt. I usually don't use them, but it's for demonstration purposes
  ret

new: ;makes a new instance of an object. Could also be used to clone an instance.
        ;ax - Instance/object to copy
        ;bx - Size of class
        ;returns: bx - pointer to instance
        ;This could be modified to use pushes instead of registers, but I made an interrupt that pointed to this function.
  pusha
  mov si,ax ;What to copy
  mov ax,[new_obj_ptr]
  mov di,ax ;Where to paste
  mov cx,bx ;Size of object
  rep movsb ;very easy to copy the object.
  popa

  push ax
  mov ax,[new_obj_ptr]
  push ax
  add ax,bx
  mov [new_obj_ptr],ax
  pop ax
  mov bx,ax
  pop ax
  ret

  new_obj_ptr dw _objects ;This will point to where to copy a new instance

_objects:
;This space is reserved for instances. Do not add anything after this. Optionally define 0s so no other memory is loaded here
times 0x400 db 0 ;allocate 1,024 bytes for instances
Just a reminder that if you are using 32-bit assembly, you may have to adjust the registers accordingly. You need to change pointer-style variables to 4 bytes too.

This simply creates an instance of Enemy and shows it's name. I'm not sure if it's 100% working on DOS, but the instance part definitely is.
A limitation of this system is that you cannot use destructors. If you want to use destructors, you could make a space reserved for only one class, and then manage the memory that way.

If you don't have structs, you can use raw pointers, but it'll be very awkward and inconvenient to use. Here's an example:

Code:
define Enemy.hp 0 ;if periods don't work, use underscores
define Enemy.name 4
define Enemy.getName 11
define Enemy.size 13

jmp start

Enemy: ;default instance
  dd 24
  db 'Zombie$'
  dw Enemy_getName

Enemy_getName: ;You can technically put it inside the object, but why calculate the size of that and have to copy it?
  mov ax,bx
  add ax,Enemy.name
  ret

start:
  mov ax,Enemy
  mov bx,Enemy.size
  call new
  ;And you can do what you want with it normally
  ret
With some extra work, you can probably also include parent and child classes.

Hope you liked the tutorial
#1 · edited 13y ago · 13y ago
♪~ ᕕ(ᐛ)ᕗ
♪~ ᕕ(ᐛ)ᕗ
TBH I find assembly really hard to learn, but I love seeing tuts like this
#2 · 13y ago
abuckau907
abuckau907
same here. Even though my brain slows down when I try to think about assembly, I *know* I don't understand it as well as I should. It's still nice to see tuts like this, even if I can't actually apply them to my own knowledge/projects yet. very interesting concept. thanks.
#3 · 13y ago
Psychotic
[MPGH]Psychotic
I once tried learning ASM. I couldn't even find a compiler for it. I remember getting this one program and I don't even know what to do with it. Nonetheless, nice tutorial.
#4 · 13y ago
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

  • [TUT] How to add Oriental/Korean FontsBy W$t$5TA34TYTHSETH5Y5 in WarRock Korea Hacks
    2Last post 19y ago
  • HTML Settings in SWF ActX ObjectBy arunforce in C++/C Programming
    2Last post 19y ago
  • In What Do you Code Assembly ?By apezwijn in Assembly
    5Last post 18y ago
  • Converting Assembly Into BytesBy radnomguywfq3 in Visual Basic Programming
    0Last post 19y ago
  • I wanne start learning Assembly plz read.!By Niratsio in Visual Basic Programming
    14Last post 18y ago

Tags for this Thread

None