;color box
model small.stack 256h
.dataa1 db" linat-ang BAKA$" a2 db" Bulalo$"a3 db" Tinulang manok$"a4 db" Linat-ang Baboy$"a5 db" 1 serve PANSIT$"a6 db" 1 serve Humba$"a7 db" 1 serve Halang2x$"converges db " GRAND ROYAL RESTAURANT$";----------------------------------------------------------------------------msg db"[1]VIEW ALL [0] exit $"
hot_soap_sub1 db " HOT SOUP 1 serve" db 0Dh,0Ah,0Ah," [a]Linat-ang BAKA=25 [c]Tinulang manok=20" db 0Dh,0Ah,0Ah," [b]Bulalo=30 [d]Linat-ang Baboy=13" db 0Dh,0Ah,0Ah," ----------------------------------------$",0Ah
more_foods_sub1 db " MORE FOODS" db 0Dh,0Ah,0Ah," [e]1 serve Pancit=8 [g]1 serve Halang2x=20" db 0Dh,0Ah,0Ah," [f]1 serve Humba=25" db 0Dh,0Ah,0Ah," ----------------------------------------$",0Ah ;-----------------------------------------------------------------------------sub2 db "[a] VIEW AWARDS" db 0Dh,0Ah,0Ah," ----------------------------------------$",0Ah ;----------------------------------------------------------------------------detail db " Awards" db 0Dh,0Ah,0Ah," DATE Rewarded Rewards" db 0Dh,0Ah,0Ah," jan 6,2008 Best Sugbahan" db 0Dh,0Ah,0Ah," jun 13,205 Most outstanding Sugbahan" db 0Dh,0Ah,0Ah," dec 25,2006 Best FastFood" db 0Dh,0Ah,0Ah," feb 6,2001 Best Foods" db 0Dh,0Ah,0Ah," ----------------------------------------" db 0Dh,0Ah,0Ah," press any key to back to main menu$",0Ah ;----------------------------------------------------------------------------- addition db'[A]dd','$' subtraction db'[S]ub','$' multiplication db'[M]ul','$' divide db'[D]iv','$' mssg db'Enter your choice[(a)-(g)]:','$' msg1 db'Pila ra man imo paliton: PESOS ','$' msg2 db'Pila man kabuok serve?:','$' ur_money db "your money:$" sum db'Your changes is:','$' diff db'Your changes is:','$' mult db'The total is:','$' dive db'The answer is:','$'
wrong db' Invalid Input!','$' again db'Do you want to buy again[Y/N]?','$' rem db'remainder:','$'
num1 dw ? num2 dw ?subt1 db "akong bayad:$"minus db "kuhaan sa total:$" ;-------------------------------------------computations----------------------code db "MY FAVORITE LETTER IS:$"
;----------------------------------------------------------------------------
input db "Enter your choice:$";---------------------------
pawala db "error input$";--------------------------.codestart:
;--------------------clear screenmov ax, 0600hmov bh,07hmov cx,0000hmov dx,184fhint 10h;-------------------first box colorcall box_color;---------------------------
mov ax,@datamov ds,ax
mov dh,14mov dl,30mov ah,02hxor bh,bhint 10hmov dx,offset codemov ah,09hint 21h
;----------------------inputmov ah, 01hint 21hmov dl,al
;----------------------enterxor ah,ahint 16h ;----------------akong if elsecmp dl, 'A'je ada
jne startstarttt:call clrcall startfive55:call clrxor ah,ahint 16h call fivecall clr;----------location sa boxada:call clrcall box_colormov dh,4mov dl,26mov ah,02hxor bh,bhint 10hmov dx,offset msgmov ah,09hint 21h
mov dx, offset sub2mov ah, 09hint 21h
mov dh,15mov dl,28mov ah,02hxor bh,bhint 10hmov dx,offset inputmov ah,09hint 21h
;----------------------inputmov ah, 01hint 21hmov dl,al
;----------------------enterxor ah,ahint 16h
;----------------akong if elsecmp dl, '1'je five5cmp dl, '0'je humanncmp dl, 'a'je detalyeejne startt;---------------------------startt:call startdetalyee:call detailsfive5:call fivehumann:call human;--------------------------------------------details:call clrcall box_colorcall detalyecall input_key;----------------------------------------five:call clrcall box_color
mov dh,3mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset converges mov ah, 09hint 21h
mov dh,6mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset hot_soap_sub1 mov ah, 09hint 21h
mov dh,14mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset more_foods_sub1 mov ah, 09hint 21h
mov ax, @data mov ds, axchoice:mov dh,23mov dl,26mov ah,02hxor bh,bhint 10h mov ax, offset mssg call put_string
mov ah,1h int 21h
mov bl,al;--------------------------------------------------------------------------- cmp bl,'a' je aa1 cmp bl,'b' je aa2 cmp bl,'c' je aa3 cmp bl,'d' je aa4 cmp bl,'e' je aa5 cmp bl,'f' je aa6 cmp bl,'g' jne aa77jne fiveefivee:call five
aa77:call aa7 aa1:call lokmov dx, offset a1 call linka equ 25call multingmov num1, acall multiaa2:call lokmov dx, offset a2 call linkb equ 30call multingmov num1, bcall multiaa3:call lokmov dx, offset a3 call linkcc equ 20call multingmov num1, cccall multiaa4:call lokmov dx, offset a4 call linkd equ 13call multingmov num1, dcall multiaa5:call lokmov dx, offset a5 call linke equ 8call multingmov num1, ecall multiaa6:call lokmov dx, offset a6 call linkf equ 25call multingmov num1, fcall multi aa7:call lokmov dx, offset a7 call linkg equ 20call multingmov num1, gcall multilink:mov ah, 09hint 21h ret;------------------------------------------------------------ lok: mov dh,25 mov dl,26 mov ah,02h xor bh,bh int 10hret multing: mov dh,34 mov dl,26 mov ah,02h xor bh,bh int 10h ;mov ax, offset msg1 ;call put_string ;call get_numret ;mov num1, axmulti: mov dh,27 mov dl,26 mov ah,02h xor bh,bh int 10h mov ax, offset msg2 call put_string call get_num
mov num2, ax
mov dh,29 mov dl,26 mov ah,02h xor bh,bh int 10h mov ax, offset mult call put_string
mov cx, num2 mov ax, num1 mul cx
call put_num
jmp finish
;jmp finishfinish:
mov dh,31 mov dl,26 mov ah,02h xor bh,bh int 10h mov ax,offset again call put_string
call get_char
mov bl,al
cmp bl,'Y' je choicee cmp bl,'y' je choicee
cmp bl,'N' je subing cmp bl,'n' je subing
mov ax,offset wrong call put_string jmp finish;-------------------------------------------------subtracting
subing: mov dh,33 mov dl,26 mov ah,02h xor bh,bh int 10h mov ax, offset subt1 call put_string call get_num
mov num1, ax
mov dh,35 mov dl,26 mov ah,02h xor bh,bh int 10h mov ax, offset minus call put_string call get_num
mov num2, ax mov dh,37 mov dl,26 mov ah,02h xor bh,bh int 10h mov ax, offset diff call put_string
mov ax, num1 sub ax, num2 call put_num
jmp human
;------------------------------------------------------------- choicee:call fivecall choice mij: cmp ax,num2 jb micher
sub ax,num2 inc cx jmp mij
micher: mov bx,ax
mov ax,cx call put_num
cmp bx,0 ; je finish
; mov ax,offset rem ; call put_string
mov ax,bx call put_numcho: end_else: mov ax, 4c00h int 21h
put_string: mov dx, ax mov ah, 9h int 21h ret
get_char: mov ah, 1h int 21h ret
put_char: mov dl,al mov ah, 2h int 21h ret
get_num: push bx push cx push dx
mov dx, 1 mov bx, 0 mov cx, 0 call get_char cmp al, ' ' jne newline mov dx, -1 call get_char
newline: push dx cmp al, 13 je fin_read sub al, '0' mov bl, al mov ax, 10 mul cx mov cx, ax add cx, bx call get_char read_loop: cmp al, 13 je fin_read sub al, '0' mov bl, al mov ax, 10 mul cx mov cx, ax add cx, bx call get_char jmp read_loop
fin_read: mov ax, cx pop dx cmp dx, 1 je fin_getn neg ax
fin_getn: pop dx pop cx pop bx ret
put_num: push bx push cx push dx
mov dx, 0 push dx mov cx,10 cmp ax, 0 jge calc_digits neg ax push ax mov al, ' ' call put_char pop ax
calc_digits:
div cx add dx, '0' push dx mov dx, 0 cmp ax, 0 jne calc_digits
display_loop: pop ax cmp ax, 0 je end_display_loop call put_char jmp display_loop
end_display_loop: pop dx pop cx pop bx ret;--------------------------input charmov ah, 01hint 21hmov dl,al
xor ah,ahint 16h
mov dl,al
cmp dl,'Y' je fives cmp dl,'y' je fives
cmp dl,'N' je human cmp dl,'n' je humanretfives:call five
;--------------------------------------------exit:call clrcall box_colormov dh,2mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset pawalamov ah, 09hint 21hcall human
;-----------------sa clear screenclr: mov ax, 0600hmov bh,07hmov cx,0000hmov dx,184fhint 10hret
cr_loc:;----------cursor location ;sa boxmov dh,20mov dl,26mov ah,02hxor bh,bhint 10hret
input_key:;----------------------inputmov ah, 01hint 21hmov dl,alcall start
box_color:;-----------------box color
mov ax, 0700h ;constant 6 pataas ok ra na cyamov bh, 35h ;-------- color first color/ mov cx,0010h ;sinugdan size left sizemov dx,3544h ;--------size sa first color/main color sa right side ra ni------ ang 2c15h= ang 2 ky x2 ang pic boxint 10hret
;-----mov dx,1043h
;mov ax, 0600h;mov bh, 34h;mov cx,0010h;mov dx,3544h;int 10h;ret;----------------------------detalye:mov dh,0mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset detailmov ah, 09hint 21hret
;---------------sa terminatehuman: mov ax, 4c00hint 21h
end start
My final project in Assembly
0 commentsPosted by acas arnel m. at 11:21 PM
Labels: Assembly Codes
sample undone sub menu w/ color txt, color box in assembly
0 commentsmodel small.stack 100h.data
cr equ 13lf equ 10msg db cr,lf,"enter ur choice: [1-5]$"una db cr,lf,"one$"duha db cr,lf,"two$"tulo db cr,lf,"three$"upat db cr,lf,"four$"lima db cr,lf,"five$"pawala db cr,lf,"error input$".codestart:human: mov ax,@data mov ds,ax
mov dx,offset msg mov ah,09h int 21h
mov ax,0600hmov bh,00hmov cx, 221bhmov dx,1e33hint 10h
mov ax, 0600hmov bh, 42hmov cx,1019hmov dx,1c31hint 10h
;input mov ah, 01h int 21h mov dl,al
;enter xor ah,ah int 16h
cmp dl, '1' je one
cmp dl, '2' je two
cmp dl, '3' je three
cmp dl, '4' je four
cmp dl, '5' je five
jne exit
one: mov dx, offset una mov ah, 09h int 21h je human
two: mov dx, offset duha mov ah, 09h int 21h je human three: mov dx, offset tulo mov ah, 09h int 21h je human
four: mov dx, offset upat mov ah, 09h int 21h je human
five: mov dx, offset lima mov ah, 09h int 21h je human
exit: mov dx, offset pawala mov ah, 09h int 21h je human
mov ax, 4c00h int 21h
end start
Posted by acas arnel m. at 10:46 PM
Labels: Assembly Codes
cd rental/cellphone repair in w/ sub menu, txt color, box color assembly code
0 comments.model small.stack.datadesserts db 0Ah," cd rental/cellphone repair" db 0Dh,0Ah,0Ah," 1.Movie 2.Music" db 0Dh,0Ah," 3. cellphone accesories$",0Ah,0Ahmovie db 0Ah," cd rental/cellphone accesories" db 0Dh,0Ah,0Ah," 1.Action 2.comedy$",0Ah,0Ahmusic db 0Ah," cd rental/cellphone accesories" db 0Dh,0Ah,0Ah," 1.Audio 2.videoke$",0Ah,0Ahphone db 0Ah," cd rental/cellphone accesories" db 0Dh,0Ah,0Ah," 1. Nokia $" db 0Dh,0Ah," 2.Apple$"say db 0Ah," cd rental/cellphone repair " db 0Dh,0Ah,0Ah," Sorry You Input " db 0Dh,0Ah," A Wrong Choice.$"kuha db 0Dh,0Ah," cd rental/cellphone repair" db 0Dh,0Ah,0Ah," 1.Abang 2.Uli" db 0Dh,0Ah," 3.Repair$"choice db 0Dh,0Ah," Enter Your Choice:$"choice1 db 0Dh,0Ah," Enter Your Choice:$"choice2 db 0Dh,0Ah," Enter Your Choice:$"choice3 db 0Dh,0Ah," Enter Your Choice:$"
.codestart:mov ax,@datamov ds,ax
call menmov dx, offset dessertscall osmov dx, offset choicecall oscall iscmp bl,'1'je usacmp bl,'2'je duhacmp bl,'3'je tulojne inv
usa:call men1mov dx,offset moviecall osmov dx, offset choice1call oscall iscmp bl,'1'je pilicmp bl,'2'je pilijne inv
duha:call men1mov dx,offset musiccall osmov dx, offset choice1call oscall iscmp bl,'1'je pilicmp bl,'2'je pilijne inv
tulo:call men1mov dx,offset phonecall osmov dx, offset choice2call oscall iscmp bl,'1'je pilicmp bl,'2'je pilijne inv
pili:call men2mov dx,offset kuhacall osmov dx,offset choice3call oscall isjmp exit
inv:call men1mov dx,offset saycall osjmp exit
os:mov ah,09hint 21hret
is:mov ah,01hint 21hmov bl,alret
men:mov ax,0600hmov bh,45h;dmov cx,0303hmov dx,0B1Fh;Aint 10h
mov ah,02hmov bh,0ahmov cx,0505hmov dx,0505hint 10hret
men1:mov ax,0600hmov bh,5Dhmov cx,0A0Ahmov dx,1027hint 10h
mov ah,02hmov bh,00hmov cx,0A0Ahmov dx,0A0Ahint 10hret
men2:mov ax,0600hmov bh,7Dhmov cx,0F40hmov dx,1725hint 10hmov ah,02hmov bh,00hmov cx,0F40hmov dx,0F40hint 10hret
exit:mov ax,4c00hint 21hend start
Posted by acas arnel m. at 10:44 PM
Labels: Assembly Codes
sample sub menu of assembly w/ colors, color box, color txt,sub menu. etc.
0 comments;color box
model small.stack 100h.data
;----------------------------------------------------------------------------msg db " STORE INVENTORY" db 0Dh,0Ah,0Ah," [1]can goods [2]softdrinks" db 0Dh,0Ah,0Ah," [3]rices [4]noodles" db 0Dh,0Ah,0Ah," [0] exit $",0Ah cangoods_sub1 db " CAN GOODS" db 0Dh,0Ah,0Ah," 555 TUNA CENTURY TUNA" db 0Dh,0Ah,0Ah," CORNBEEF FAMILY BRAND SARDINES" db 0Dh,0Ah,0Ah," ----------------------------------------$",0Ah softdrinks_sub1 db " SOFTDRINKS" db 0Dh,0Ah,0Ah," COKE 7 UP" db 0Dh,0Ah,0Ah," PEPSI SPRITE" db 0Dh,0Ah,0Ah," ----------------------------------------$",0Ah rices_sub1 db " RICES" db 0Dh,0Ah,0Ah," BALIKATAN WHITE CORN" db 0Dh,0Ah,0Ah," NFA YELLOW CORN" db 0Dh,0Ah,0Ah," ----------------------------------------$",0Ah noodles_sub1 db " NOODLES" db 0Dh,0Ah,0Ah," LUCKY ME MAMI MAGGI" db 0Dh,0Ah,0Ah," PANCIT CANTON LOMI NOODLES" db 0Dh,0Ah,0Ah," ----------------------------------------$",0Ah ;-----------------------------------------------------------------------------sub2 db " [1] BACK TO MAIN MENU [2] DETAILS" db 0Dh,0Ah,0Ah," ----------------------------------------$",0Ah ;----------------------------------------------------------------------------detail db " EXPIRATION" db 0Dh,0Ah,0Ah," DATE EXPIRE ITEM" db 0Dh,0Ah,0Ah," jan 6,2010 LOMI NOODLES" db 0Dh,0Ah,0Ah," jun 13,2012 555 TUNA" db 0Dh,0Ah,0Ah," dec 25,2009 7 UP" db 0Dh,0Ah,0Ah," feb 6,2029 CENTURY TUNA" db 0Dh,0Ah,0Ah," ----------------------------------------" db 0Dh,0Ah,0Ah," press any key to back to main menu$",0Ah ;-----------------------------------------------------------------------------input db "Enter your choice:$";---------------------------
pawala db "error input$";--------------------------.codestart:
;--------------------clear screenmov ax, 0600hmov bh,07hmov cx,0000hmov dx,184fhint 10h;-------------------first box colorcall box_color;---------------------------
mov ax,@datamov ds,ax
;----------cursor location sa box
mov dh,2mov dl,26mov ah,02hxor bh,bhint 10hmov dx,offset msgmov ah,09hint 21h
mov dh,13mov dl,28mov ah,02hxor bh,bhint 10hmov dx,offset inputmov ah,09hint 21h
;----------cursor location sa txtmov dh,13mov dl,46mov ah,02hxor bh,bhint 10h
;----------------------inputmov ah, 01hint 21hmov dl,al
;----------------------enterxor ah,ahint 16h
;----------------akong if elsecmp dl, '1'je one1
cmp dl, '2'je two2
cmp dl, '3'je three3
cmp dl, '4'je four4cmp dl, '0'je humann
cmp dl, '0'jne start;---------------------------one1:call onetwo2:call twothree3:call threefour4:call fourhumann:call human;---------------------------one:call clrcall box_colormov dh,2mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset cangoods_sub1mov ah, 09hint 21hmov dh,9mov dl,20mov ah,02hxor bh,bhint 10hmov dx, offset sub2mov ah, 09hint 21hmov dh,13mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset inputmov ah, 09hint 21h
;--------------------------input charmov ah, 01hint 21hmov dl,al
xor ah,ahint 16h;------------------------------------ if elsecmp dl, '1'je back2cmp dl, '2'je detaill2jne one;---------------------------------back2:call startdetaill2:call clrcall box_colorcall detalyecall input_key;------------------------------
two:call clrcall box_colormov dh,2mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset softdrinks_sub1mov ah, 09hint 21hmov dh,9mov dl,20mov ah,02hxor bh,bhint 10hmov dx, offset sub2mov ah, 09hint 21hmov dh,13mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset inputmov ah, 09hint 21h;--------------------------input charmov ah, 01hint 21hmov dl,alxor ah,ahint 16h;------------------------------------ if elsecmp dl, '1'je back3cmp dl, '2'je detaill3jne two;---------------------------------back3:call startdetaill3:call clrcall box_colorcall detalyecall input_key;----------------------------------three:call clrcall box_colormov dh,2mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset rices_sub1mov ah, 09hint 21hmov dh,9mov dl,20mov ah,02hxor bh,bhint 10hmov dx, offset sub2mov ah, 09hint 21hmov dh,13mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset inputmov ah, 09hint 21h;--------------------------input charmov ah, 01hint 21hmov dl,al
xor ah,ahint 16h;------------------------------------ if elsecmp dl, '1'je back4cmp dl, '2'je detaill4jne three;---------------------------------back4:call startdetaill4:call clrcall box_colorcall detalyecall input_key;---------------------------------------four:call clrcall box_colormov dh,2mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset noodles_sub1mov ah, 09hint 21hmov dh,9mov dl,20mov ah,02hxor bh,bhint 10hmov dx, offset sub2mov ah, 09hint 21hmov dh,13mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset inputmov ah, 09hint 21h;--------------------------input charmov ah, 01hint 21hmov dl,al
xor ah,ahint 16h;------------------------------------ if elsecmp dl, '1'je back5cmp dl, '2'je detaill5jne four;---------------------------------back5:call startdetaill5:call clrcall box_colorcall detalyecall input_key;--------------------------------------------exit:call clrcall box_colormov dh,2mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset pawalamov ah, 09hint 21hcall human
;-----------------sa clear screenclr: mov ax, 0600hmov bh,07hmov cx,0000hmov dx,184fhint 10hret
cr_loc:;----------cursor location ;sa boxmov dh,20mov dl,26mov ah,02hxor bh,bhint 10hret
input_key:;----------------------inputmov ah, 01hint 21hmov dl,alcall start
box_color:;-----------------box color
mov ax, 0600h ;constantmov bh, 34h ;-------- color first color/ mov cx,0010h ;sinugdan size left sizemov dx,1043h ;--------size sa first color/main color sa right side ra ni------ ang 2c15h= ang 2 ky x2 ang pic boxint 10hret
;mov ax, 0600h;mov bh, 34h;mov cx,1019h;mov dx,1c25h;int 10h;ret;----------------------------detalye:mov dh,2mov dl,26mov ah,02hxor bh,bhint 10hmov dx, offset detailmov ah, 09hint 21hret;---------------sa terminatehuman: mov ax, 4c00hint 21h
end start
Posted by acas arnel m. at 10:37 PM
Labels: Assembly Codes
Functions
0 commentsCS Code Segment 16-bit number that points to the active code-segment
DS Data Segment 16-bit number that points to the active data-segment
SS Stack Segment 16-bit number that points to the active stack-segment
ES Extra Segment 16-bit number that points to the active extra-segment
Pointer Registers
IP Instruction Pointer 16-bit number that points to the offset of the next instruction
SP Stack Pointer 16-bit number that points to the offset that the stack is using
BP Base Pointer used to pass data to and from the stack
General-Purpose Registers
AX Accumulator Register mostly used for calculations and for input/output
BX Base Register Only register that can be used as an index
CX Count Register register used for the loop instruction
DX Data Register input/output and used by multiply and divide
Index Registers
SI Source Index used by string operations as source
DI Destination Index used by string operations as destination
Flags Register Abr. Name bit nº Description
OF Overflow Flag 11 indicates an overflow when set
DF Direction Flag 10 used for string operations to check direction
IF Interrupt Flag 9 if set, interrupt are enabled, else disabled
TF Trap Flag 8 if set, CPU can work in single step mode
SF Sign Flag 7 if set, resulting number of calculation is negative
ZF Zero Flag 6 if set, resulting number of calculation is zero
AF Auxiliary Carry 4 some sort of second carry flag
PF Parity Flag 2 indicates even or odd parity
CF Carry Flag 0 contains the left-most bit after calculations
Posted by acas arnel m. at 9:21 PM
Labels: Assembly Codes
Input Output
1 commentsmodel small
.stack 100h
.data
msg db "enter ur choice: [1-5]$"
una db "one$"
duha db "two$"
tulo db "three$"
upat db "four$"
lima db "five$"
pawala db "error input$"
.code
start:
mov ax,@data
mov ds,ax
mov dx,offset msg
mov ah,09h
int 21h
;input
mov ah, 01h
int 21h
mov dl,al
;enter
xor ah,ah
int 16h
cmp dl, '1'
je one
cmp dl, '2'
je two
cmp dl, '3'
je three
cmp dl, '4'
je four
cmp dl, '5'
je five
jne exit
one:
mov dx, offset una
mov ah, 09h
int 21h
je human
two:
mov dx, offset duha
mov ah, 09h
int 21h
je human
three:
mov dx, offset tulo
mov ah, 09h
int 21h
je human
four:
mov dx, offset upat
mov ah, 09h
int 21h
je human
five:
mov dx, offset lima
mov ah, 09h
int 21h
je human
exit:
mov dx, offset pawala
mov ah, 09h
int 21h
je human
human:
mov ax, 4c00h
int 21h
end start
Posted by acas arnel m. at 9:16 PM
Labels: Assembly Codes
Assembly sourse code
33 commentsAssembly Language Source Codes
Assembler Source Code for emu8086 microprocessor emulator and compatible assemblers (16 bit)To copy codes to a text editor just press Ctrl+A (simultaneously), then press Ctrl+C and in the editor press Ctrl+V
Input 8 bit binary number and print out its decimal equivalent.
(source with tutorial)
This is a very basic example of a tiny OS. Your own Operating System that runs from floppy drive - easy!
This example shows how to add huge unpacked BCD numbers
And this program draws a tiny geometrical figure in VGA mode.
Another "Hello World!" example
This example prints out "HELLO WORLD!" by writing directly to the video memory.
Simple Add/Subtract
Calculate the sum
Calculate the sum of elements in V1 array, store result in V2.
How CMP instruction sets the flags.
Usually CMP instruction is followed by any relative jump instruction such as: JE, JA, JL, JAE... It is recommended to open: "Lexical Flag Analyzer" and "Flags" from emulator's "View" menu before running this code.
Octal, Binary and Decimal
See how to operate with Octal, Binary and Decimal values.
This example calculates the sum of one array with another and saves result in third array. In emu8086 you can see the result in "View" -> "Variables" menu. (set Elements for SEG1, SEG2 and SEG3 to 4 and Show as "SIGNED"). Not only variables but arrays can be seen in memory. It's required to set correct data type (size) and number of elements in that array:
Learn how to set and get file attributes, in other words how to make file Read Only or Hidden.
BCD - AAA instruction example - bcd_aaa.asm
This example shows the use of AAA instruction (ASCII Adjust after Addition). It is used to add huge BCD numbers.
BCD - AAS instruction example - bcd_aas.asm
This is an example of AAS instruction, it is used to subtract huge BCD numbers.
Bin file - bintest.asm
This is an example of how to make a ".BIN" file.
Simple Calculator - calc.asm
This sample gets two numbers from the user, calculates the sum of these numbers, and prints it out.
Command prompt based simple calculator (+,-,*,/) for 8086.
How to use CMPSB instruction - cmpsb.asm
This sample shows how to use CMPSB instruction to compare strings.
How to use CMPSW instruction - cmpsw.asm
This sample shows how to use CMPSW instruction to compare strings.
16x16 color map example - color.asm
This sample prints 16x16 color map, it uses all possible colors.
This program written in 8086 Assembly Language to convert string value to binary form. When I run this program on emu8086 it proves that '-1234' is actually 0FB2Eh in hexadecimal (or binary: 1111101100101110b). This code supports both positive and negative numbers as input. Based on original (much more complicated) input routine taken from emu8086.inc
This program uses a subroutine written in 8086 assembly language that can be used for converting a string of number (Max of 4 ASCII digit) to equivalent packed BCD digits. (BCD is "Binary Coded Decimal Numbers"). As seen in emu8086 variables window:
This is a program in 8086 assembly language that accepts a character string from keyboard input stores it in an array. The program then converts all the lower case characters in the string to upper case. If the string is empty (null), it does not do anything. Done as part of my school assignment.
counter_chars.asm
This source code shows how we can count the number of letters in some statment without using string instructions, that means by using the loop and READING ONE CHARACTER in each time of loop ...
Count number of key presses - Count_Key_Presses.asm
Counts number of key presses, and stores the result is in BX register. You need to open "User Screen" to type.
Make your own interrupts - Custom_Interrupt.asm
This examples shows how to modify Interrupt Vector and create your own custom interrupts.
This code prints out current date and time and saves it to a file.
Emulator saves this file to emulated file system.
Encryption in Assembly Language
8086 subroutine to encrypt only lower case alphabets of a string using XLAT and also decrypt the same. The main principle behind this algorithm is because tables are precoded manually to decode one another. for example if first table sets letter 'a' to be 'k', the second table does the reverse, it sets letter 'k' to be 'a'... etc.... only lower case letters are encoded (but this program can be improved to convert full abc if required).
Another "Hello, World!" example - exetest.asm
"Hello World", this time as an EXE file.
Factorial - factorial.asm
This sample gets the number from the user, and calculates factorial for it. Supported input from 0 to 8 inclusive!
Centigrade (Celsius) to Fahrenheit calculation and vice-versa. - fahrenheit.asm
Not very accurate, since using integer divide, it may not work for some values as well.... This program has no input/output from the user, so in order to see the result it maybe useful to select "Variables" from "View" menu of the emulator. Another way to see the output is to use PRINT_NUM procedure from "emu8086.inc", see "Part 5" in tutorials. (since we get result in AL, you should use CBW instruction before printing out, because PRINT_NUM prints a signed number in AX register).
Call a procedure from another segment or interrupt.
A more detailed example, it's interesting to see what happens with the stack when it runs slowly. If you run it to fast you may not see anything.
A far procedure that prints out "hello" using a very tricky way. It knows where to search for characters because it knows who called it. It gets all the information from the stack.
See how file system operates. Open existing file, create file and subdirectory, rename subdirectory, delete file and subdirectory. You can run it in step-by-step mode and explore the virtual file system.
C:\emu8086\vdrive\C
C:\emu8086\MyBuild
This little program does some mess by creating subdirectory and file, and then it cleans for itself by deleting everything. If it runs fast you won't even notice a thing. If you stop the program in the middle you shall notice that it writes into C:\emu8086\vdrive\C\test1\ this text "lazy dog jumps over red fox", then it renames the file, creates another files, does some more things, and deletes everything very quickly.
Float on 8086! - float.asm
This program calculates linear equation: ax + b = 0 The result is printed with floating point.
For example: a = 7, b = 2
x = -0.28571428....
Yet another, "Hello World" example - hello.asm
This example prints "Hello, World!" into the screen, char by char using INT 10h.
Basic "Hello World!" example in Assembly Language
This example prints out The easiest and the fastest way to print "Hello World!" using DOS INT 21h (still works under Windows XP in Dos prompt).
This example converts 2 digit Hex value into numeric value and decimal string representation (so that it can be easily printed if required).
How to use emu8086.inc lib - include.asm
This sample shows the correct use of "emu8086.inc" library of predefined macros and procedures.
Print "Hello world" in color - int10_13.asm
This is an example of INT 10h / AH=13h function.
example of int 21h functions.
Keyboard example - keybrd.asm
This sample shows the use of keyboard functions. Try typing something to "User Screen". When "step delay" is too long, keyboard buffer is used. Try setting "step delay" to 1, for more realistic emulation. This code will loop until you press ESC key, other keys will be printed.
This sample shows how to access virtual ports (000F to FFFF). This new technology allows to make external add-on devices for emu8086, such as led displays, thermostat, stepper-motor, etc... "DEVICES" folder contains sample device that works with this sample.
just a few simple loops
Matrix - matrix.asm
Matrix transpose sample (reverse rows with columns).
OS Kernel module - micro-os_kernel.asm
This is a very basic example of a tiny operating system. This is Kernel module! It is assumed that this machine code is loaded by 'micro-os_loader.asm' from floppy drive from: cylinder: 0 sector: 2 head: 0
OS loader example - micro-os_loader.asm
This is a very basic example of a tiny Operating System. This is an OS loader only!
simple mouse code
drawing program
windows users may need it.
Video buffering example - pages.asm
This example demonstrates the use of pages (double-buffering). This program uses first 4 pages of video memory by setting some data on them, and waits for any key, pressing any key will show all pages one after another.
Palindrome - palindrome.asm
This sample checks if string is a palindrome.
Command line parameters example - param.asm
This sample prints out the command line parameters. In DOS you simply add this line after an executable: param.com my parameters In emulator you should set them by selecting "Set command line paramters" from "File" menu of emulator window.
Command line parameters for EXE file - paramexe.asm
This sample prints out the command line parameters. In DOS you simply add this line after an executable: paramexe.exe my parameters
How to show single pixel on screen using assembly language.
Everything that you see on screen is actually a lot of single dots called pixels, all high level languages and DirectX eventually use this or similar method to draw anything on the screen. 13h video mode is just 320x200 pixels, but it does not require any special graphics card and works on all computers and VGA compatible graphic cards (even the very old ones).
Cool Print Method - print.asm
This sample shows how to print string defined just after the CALL instruction without using 'emu8086.inc' library.
the code prints out a decimal value out of AL
the code prints out as many chars from top to bottom as you enter from left to right.
Print HEX digit - print_hex_digit.asm
This sample prints out a hex value of DL register.
Printer Demo - PrinterDemo.asm
PrinterDemo.asm - Andrew Nelis. Simple demonstration of the printer.
8086 assembly language program to reverse a string.
Robot example - robot.asm
This is an example of controlling the robot attached to a computer. This code randomly moves the robot and makes it to switch on/off the lamps. Keep in mind that robot is a mechanical creature and it takes some time for it to complete a task.
SCASB example - scasb.asm
This sample shows how to use SCASB instruction to find a symbol.
SCASW example - scasw.asm
This sample shows how to use SCASW instruction to find a WORD (2 bytes).
Scroll Example - scroll.asm
This example shows the used of scrolling functions. It prints some test strings, and scrolls up/down the window at (1,1)-(8,5).
Simple I/O - simple_io.asm
This sample shows how to access virtual ports (00000Fh to 0FFFFh).
Demonstration of a virtual device in assembly language.
Snake game in Assembler - snake.asm
This is the snake game... It's better to set the "step delay" to "0" before running, it requires fast processing. You can control the snake using arrow keys on your keyboard. All other keys will stop the snake. Press ESC to exit.
Simple Sort - sort.asm
This program inputs 3 numbers and sorts them from largest to smallest.
Stack - stack.asm
This sample shows how the stack works. Click "Stack" button in emulator to see the contents of the stack.
Stepper Motor - stepper_motor.asm
This is a sample of OUT instruction. It writes values to virtual I/O port that controls the stepper-motor. Try using datCCW, datCW_FS or datCCW_FS instead of datCW to get different behavior of the motor.
Input and output string - string.asm
This sample shows the use of input and output string functions of emu8086.inc
Temperature Control - This short program for emu8086 shows how to keep constant temperature using heater and thermometer (between 60 F to 80 F), it is assumed that air temperature is lower 60 F. the emulator is required to run this example.
Timer - timer.asm>
This sample shows the use of a timer function (INT 15h / 86h) This code prints some chars with 1 second delay.
Convert to bin - ToBin.asm
This program inputs a decimal number and prints out its binary equivalent. Convertion is done by CONVERT_TO_BIN procedure, all other stuff is just for input/output.
Traffic Lights Intersection - traffic_lights.asm
This is a sample of OUT instruction. It writes values to virtual I/O port of Traffic Lights Intersection, by setting bits we can turn all the lights on and off.
Semaphores.... demonstration of turning the lights only. Unlike the previous example this code is the cause of far more traffic accidents.
A very handy code that can be assembled into a very tiny utility to make floppy boot records and tiny operating systems.
This file is an open source include library that allows to print and input strings and numbers using simple predefined macro functions for 8086 assembler. Procedures to input and output numeric values and strings, clear screen. All macros and procedures avoid using MS-DOS interrupts (it is useful for designing your own independent operating systems).
Compatibility issues of MASM/TASM (emu8086) and FASM assembler syntax.
Posted by acas arnel m. at 9:05 PM
Labels: Assembly Codes