40 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for ShiftLeft

For those interested in operating system development, this snippet tests status of A20. It is the line that allows memory beyond 1 meg to be addressed, otherwise it will just wrap around which some applications and versions of DOS depend on. My bootloader **MBR1_44** has switched system to protected (*32 …

0
285
Member Avatar for BustACode

I, and many others, desired a "switch" keyword in Python. For me it was to a desire to make some of my code more compact and readable, as I often have many user selected options for the code to weed through. So I set off on a journey to figure …

Member Avatar for Mark_37
0
579
Member Avatar for ShiftLeft

This will take a value in EAX or AX, convert to ASCII hex with optional padding and upper or lower case This example would yield "---fc103a" push word 0x222d ; 32 bit conversion, padd output with '-' push word ASCPntr ; Pointer to end of conversion buffer push 0xfc103a call …

0
401
Member Avatar for ShiftLeft

This is a special purpose boot loader for a system I've called Proto-Sys. Eventually it is going to become a 64 bit application that will encompass all the resources to hook into drivers, benchmark code and optomize algorithms. Synopsis: * Preserve registers as they were passed by BIOS * Create …

0
318
Member Avatar for Dani

This is a program I wrote for my x86 assembly class which is basically the Spade Invaders game in all its glory. It uses Irvine32.inc which came with the textbook.

Member Avatar for Dani
2
2K
Member Avatar for Schol-R-LEA

One of the more common functions in any language is conversion of an integer to a string. This implementation, which demonstrates not only the common function activation record format but also a simple recursive function, was written in response to a recent question in which the OP posted an incomplete …

Member Avatar for Kiệt
0
7K
Member Avatar for Dani

This is a program I wrote for my x86 assembly class which generates matrices, multiplies them, and computes how long the arithmetic took. It uses Irvine32.inc which came with the textbook.

Member Avatar for ESLAMIKA
1
5K
Member Avatar for Assembly Guy

**NOTE** This code won't work at the application level. It directly addresses memory at 0xB8000 which will result in a segfault at the application level. This code must be part of an OS or an application in a not-so-secure operating system like DOS, where applications can directly address any part …

Member Avatar for Assembly Guy
0
450
Member Avatar for awuja

Hey guys.. need some help with this; I'm pulling my hair out.. i've trawled these boards but can't find anything that answers my question. I, like many others before me (so it seems!) am trying to create a program to check for a palindrome.. this is what I have so …

Member Avatar for robertospartan
0
606
Member Avatar for ShiftLeft

This code will not work on EMU8086 or any processor prior to 80286. Line 40 would need to be changed.

Member Avatar for mathematician
0
538
Member Avatar for zeroliken

I bet all Computer Science related courses would learn low level or machine level languanges in due time and in our university we used the portable 80x86 assembler NASM for our Assembly code So here's my experimentation on how to use "functions" and recursion using a Fibonacci Solver as a …

0
1K
Member Avatar for lxXTaCoXxl

Figured I've been working on material for a while and would throw these up for everyone that needs them in the future to use. It's very simple implementation; if I get enough people asking me to, I will write the methods for each of the instructions so you don't have …

Member Avatar for skatamatic
0
277
Member Avatar for Fabii23

An integer is loaded in from memory. ran through two loops to determine the tens place and the ones place. Integer is stored back to memory and displayed. Example #98 Tens place -->9 Ones place -->8 :)

0
401
Member Avatar for Jreynolds3

Hey people. What I'm trying to do is get a String input from the user. And then displaying that string. I have no idea how to do it. I have most of the code figured out except that one part. Any help will be greatly appreciated! Thanks!! (By the way …

Member Avatar for vhan
0
6K
Member Avatar for saqib_604

Aslam o Alikum to all, here is my code to get and change the attributes of a txt file. I want to change the hidden attribute of file. In this code, when i get attribute of file, the number 20 (100000) is returned in cx. I changed this number to …

Member Avatar for muslimgirl
0
297
Member Avatar for NotNull
Member Avatar for low_coder

this code was written by me for my projects. all it does is increments by 1 the string which is passed to the function. if you have any improvements to my code ill be glad to hear from you ;)

Member Avatar for low_coder
0
674
Member Avatar for Goalatio

Compile this with NASM16 (Must be compiled in .COM format!) It will display all 256 colors usable by the BIOS in a neat rectangle that contains 16 columns, 17 rows (Just counted, it may be different). KNOWN BUGS: If you enter FULLSCREEN or run this program from a DOS operating …

0
554
Member Avatar for Tight_Coder_Ex

This procedure dispatches application defined event handlers and alternately executes default process for both standard or sub/super classed windows. Map is defined as follows. In most cases I define this table in .data, but in can be in .const also. I choose writeable memory as application can redefine characteristics. [code] …

0
702
Member Avatar for Dani

This is a program I wrote for my x86 assembly class which computes the sum of n numbers. It uses Irvine32.inc which came with the textbook.

Member Avatar for unimo
0
4K
Member Avatar for mostafadotnet

This is somewhat a simple project I wrote by getting help from google groups I always recommend. assemble this code using this command: [QUOTE]nasm -o 1.com 1.asm[/QUOTE]

Member Avatar for wildgoose
0
418
Member Avatar for jhouns

compile using A86 assembler however you can adapt it for any other one easily... It just draws out a 3D like shape. It was annoying to get the angles right but suggestions on improvement to code is appreciated. :) Adequately commented so it is understandable not fully as it is …

Member Avatar for jhouns
0
2K
Member Avatar for gsbr

First it is in RosAsm style. Sorry I am addicted to its simplicity of use. The Proc is called from Dialog initiation [CODE] [Counter:D$ 0] ; Call for the first ToolTip Call SetTTip D$hdlg, ; H Dialog Handle of Dialog or Window 1, ; Tool tip number ID 1, ; …

Member Avatar for gsbr
0
237
Member Avatar for bad_dreams99

This is a very simple program that uses text mode to display a boucing "ball." The ball is just a character that moves across the screen, erasing all in its path. It is coded to work like a screensaver, so the program ends when any key is hit. NOTE: I …

0
376
Member Avatar for Tight_Coder_Ex

I use GetTickCount in a lot of my applications, so I built this snippet to convert to hours minutes and seconds. Leading extraneous data is excluded from output.

0
211
Member Avatar for Tight_Coder_Ex

User can enter an ascii string of up to 48 characters consisting of 1's or 0's, with randomly interspersed whitespace. IE: [B]1011111001011110 [/B]will be evaulated equally to [B][1011][111....cc001cccx01 111hhhh0 [/B]Algorithm parses from right to left so will be truncated at 16 position Purpose is to give all those still programming …

0
428
Member Avatar for Dani

[LEFT]This is a program I wrote for my x86 assembly class which revolves a "roulette wheel" around. Wait about a minute and it will eventually slow down to a stop. It uses Irvine32.inc which came with the textbook.[/LEFT]

Member Avatar for holmes008
0
353
Member Avatar for Dani

This is a program I wrote for my x86 assembly class which bounces an ASCII ball across the screen. It uses Irvine32.inc which came with the textbook.

0
2K
Member Avatar for Narue

FASM can output an executable PE directly, but sometimes you want to output an object file for linking with modules in other languages. The following program can be used to link with the C library of the GCC compiler with the following commands: C:\>fasm hello.asm hello.obj C:\>gcc hello.obj -o hello.exe …

0
275
Member Avatar for Narue

Some languages are hard to get started in. FASM appears to be one of these languages because the documentation is not detailed enough for a beginner. That's a shame because FASM is (in my opinion) one of the better assemblers. The following snippet is a simple Hello, world! program which …

0
1K

The End.