Académique Documents
Professionnel Documents
Culture Documents
DEBUG
A software that is classifies as debugger which is used for testing and debugging executable programs
Advantages
It is Free
It is universally available
It is simple to use
It requires relatively little memory
DEBUG COMMANDS
E (Enter)
-enable you to key in data or machine instruction into memory beginning at a specific location address.
E.g -E 0200
D (Display or Dump)
Displays the contents of a portion memory ni hex and ASCII forms starting with the given address
E.g. -D 0200
A (Assemble)
Allows you to create a program in mnemonic or symbolic code.
E.g. -A 0100
T (Trace)
Runs he program in single-step mode. It also displays the new values of the registers and the next
instruction to be executed.
E.g -T
G (Go)
Runs the program as a whole in memory an displays the output
E.g. -G
U (Unassemble)
Lists all the instructions contained in the program beginning at the given address. You can also specify the
last address location.
E.g. -U 0100
-U 0100 0109
N (Name)
Gives a name to your program, coded as N <path> <filename>
Extention nae is .COM
E.g. -N A:SAMPLE.COM
W (Write)
Saves the program onto disk storage
E.g. -W
Comment
Reserved Words
Words in which the assembler assigns a special meaning and it cannot be used as identifiers
Using reserved words for a wrong purpose causes the assembler to generate an error message
Categories of reserved words
Instructions
Statements that will be translated into machine language and executed by the computer.
Examples:
MOV ADD SUB
MUL DIV INC
DEC LOOP CMP
Directives
Statements that give information to the assembler
Sometimes called pseudo-ops
Examples:
TITLE DOSSEG .MODEL
.STACK .DATA .CODE
It must use letters (A...Z, az), number (09) and/or special characters like underscore (_), question mark
(?) and at sign (@).
It must always start with a letter
It must not use reserved words
It must not exceed to 31 character.
Examples of valid identifiers:
neym r2d2
num_1 msg8
Examples of invalid identifiers:
title num-1
4ever
Statement
May begin anywhere on the line
Each line can only contain one statement
Assembly is not case sensitive
Examples:
ADD AX, BX ; uses 2 operands
DEC CX ; uses
RET ; no operand
TITLE
.MODEL
It specifies and initializes the memory model before defining any segment
Format:
.MODEL <memory-model>
Examples:
.MODEL TINY
.MODEL SMALL
.MODEL MEDIUM
.STACK
It defines the size of the attack. The default stack size is 1,024 bytes which you can overrule.
Format:
.STACK <size>
Example:
.STACK 0100h
.DATA
.CODE
It defines and marks the code segment which consists of a set of instructions.
Format:
.CODE
Example:
.CODE
START:
END
STRING
Numeric Constant
Screen Processing
The monitor
A typical video screen has 80 columns numbered form 0 to 79 and 25 rows numbered from 0 to 24.
Clearing the screen in Assembly Approach
Interrupt 10h and function 06h handles the process of clearing the screen and scrolling
Clear all or part of display beginning at any screen location and ending at any higher-numbered location.
Interrupt 10h is the BIOS operation for screen handling and function 02h tells the operation to set the cursor
Its position determines where the next character is to be displayed.
jcprotearia
11th Oct 2012, 17:41
sir pano loop na pababa??
dba sa C programming gotoxy tapos horizontal point ay X
tapos sa vertical point ay Y.
pano loopings sa TASM
plss help.:praise:
:thanks:
serasamall
12th Oct 2012, 12:44
sir nice thread :thumbsup:
benightedsherwinko19
10th Dec 2012, 13:09
hehe patulong dn po..
sino po ang meron
ng assembly language programming codes?
aamh game codes po..
please hehe..
kelangan kasi para sa project eeh..
yung simple lang ba bsta .ASM file type cya
please hehe..
kelangan kasi para sa project eeh..
yung simple lang ba bsta .ASM file type cya
.486
.model flat, stdcall
option casemap :none
;===============standard headers=============
include \masm32\include\windows.inc
include \masm32\macros\macros.asm
;===============minimal headers===============
include \masm32\include\masm32.inc
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc
include \masm32\include\kernel32.inc
;============minimal libarys===============
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\kernel32.lib
main proc
LOCAL liczba:DWORD
LOCAL str1:DWORD
LOCAL wynik:DWORD
print chr$("where gonna play a game -->;;; guess the number!!!", 13, 10)
game:
print chr$(" ",13,10)
mov str1, input("please enter a positive number below 200: ") ;ask for input
mov liczba, sdword$(str1) ;convert from string to unsigned int
equel:
print chr$(" CORRECT!!!!",13,10)
jmp done
greater:
print chr$(" Your guess was to high", 13, 10)
jmp game
lesser:
print chr$(" Your guess was to low", 13, 10)
jmp game
done:
ret
main endp
end start
Ito try mo na lang ala akung Tasm di ko ma run napulot ko lang din yan.:thumbsup:
benightedsherwinko19
10th Dec 2012, 19:50
.486
.model flat, stdcall
option casemap :none
;===============standard headers=============
include \masm32\include\windows.inc
include \masm32\macros\macros.asm
;===============minimal headers===============
include \masm32\include\masm32.inc
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc
include \masm32\include\kernel32.inc
;============minimal libarys===============
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\kernel32.lib
main proc
LOCAL liczba:DWORD
LOCAL str1:DWORD
LOCAL wynik:DWORD
print chr$("where gonna play a game -->;;; guess the number!!!", 13, 10)
game:
print chr$(" ",13,10)
mov str1, input("please enter a positive number below 200: ") ;ask for input
mov liczba, sdword$(str1) ;convert from string to unsigned int
equel:
print chr$(" CORRECT!!!!",13,10)
jmp done
greater:
print chr$(" Your guess was to high", 13, 10)
jmp game
lesser:
print chr$(" Your guess was to low", 13, 10)
jmp game
done:
ret
main endp
end start
Ito try mo na lang ala akung Tasm di ko ma run napulot ko lang din yan.:thumbsup:
iconic091
11th Dec 2012, 19:02
aah sir..meron kpa po b?
saan m po npulot?
Bakit po di mo ba yan gusto games din aman yan diba hanap ka po kay Mr.Google andami nyang ganyan
ano po ba ang output nyang codes na yan na run mo na ba?
:xmas::newyear:
benedik
11th Dec 2012, 19:23
nice padi ..:)
jellyx
11th Dec 2012, 20:34
aah sir..meron kpa po b?
saan m po npulot?
BTW, that would need a different type of Assembler (MASM) so di yan pwedeng i-assemble sa TASM.
Another note is that it's Windows, so kung TASM gamit mo malamang na DOS programming kayo.
benightedsherwinko19
12th Dec 2012, 19:32
BTW, that would need a different type of Assembler (MASM) so di yan pwedeng i-assemble sa TASM.
Another note is that it's Windows, so kung TASM gamit mo malamang na DOS programming kayo.
sir..games dn po b to?dko pa po matry eeh..64bit kc laptop ko so dko cya magagamit..pang 32bit lang kc
ang tasm assembler
benightedsherwinko19
12th Dec 2012, 19:35
Bakit po di mo ba yan gusto games din aman yan diba hanap ka po kay Mr.Google andami nyang ganyan
ano po ba ang output nyang codes na yan na run mo na ba?
:xmas::newyear:
iconic091
14th Dec 2012, 19:40
Snake
include '%fasmi%\win32ax.inc'
applefile db 'apple.bmp',0
struc _rect
{
.left dd 0
.top dd 0
.right dd 0
.bottom dd 0
}
rect _rect
startbonus dd 0
;invoke CreateCompatibleDC,0
;push eax
;invoke CreateCompatibleBitmap,eax,250,30
;pop ecx
;push ecx
;invoke SelectObject,ecx,eax
;pop eax
;mov [mtext],eax
;invoke SetBkMode,[mdc],TRANSPARENT
;invoke SetTextColor,[mdc],0FFFFFFh
invoke CreateSolidBrush,0FFFFFFh
mov [clblack],eax
invoke CreateSolidBrush,0208820h
mov [clgray],eax
invoke CreateThread,0,0,createwin,0,0,0
invoke CreateThread,0,0,mainmenuproc,0,0,0
invoke GetAsyncKeyState,VK_RETURN
_main_menu:
invoke GetAsyncKeyState,VK_RETURN
test eax,eax
jz notenter
mov eax,[zmenuitem]
cmp eax,0
jne @f
call _zeroall
mov [startbonus],3
mov [gamespeed],60
call _game
jmp notenter
@@:
cmp eax,1
jne @f
call _zeroall
mov [startbonus],6
mov [gamespeed],50
call _game
jmp notenter
@@:
cmp eax,2
jne @f
call _zeroall
mov [startbonus],24
mov [gamespeed],30
call _game
jmp notenter
@@:
cmp eax,3
jne @f
call _zeroall
mov [startbonus],30
mov [gamespeed],20
call _game
jmp notenter
@@:
cmp eax,4
jne @f
call _zeroall
mov [startbonus],10
mov [gamespeed],33
mov [haswalls],1
call _game
jmp notenter
@@:
cmp eax,5
jne @f
call _zeroall
mov [startbonus],8
mov [gamespeed],25
mov [haswalls],1
call _game
jmp notenter
@@:
cmp eax,6
jne @f
mov [exitgameflag],1
@@:
notenter:
invoke Sleep,10
mov eax,[exitgameflag]
test eax,eax
jz _main_menu
;call _zeroall
;call _game ;Start main game engine
invoke ExitProcess,0DEADh
exitgameflag dd 0
isgaming dd 0
retn ; Return of main program, this should not change at all...
;################################################# #############
createwin:
invoke GetModuleHandle,0
invoke DialogBoxParam,eax,37,HWND_DESKTOP,nullproc,0
retn
;################################################# #############
;################################################# #############
_game:
mov [isgaming],1
mov [snakesize],0
mov [applex],0ffffh
mov [appley],0ffffh
invoke VirtualAlloc,0,500h,MEM_COMMIT,PAGE_READWRITE
mov [snakebody],eax
mov ecx,[startbonus]
@@:
push ecx
call incsnake
pop ecx
loop @b
mov eax,[snakebody]
mov dword [eax],012c0190h
mov [speedx],20
mov [hasapple],0
mov [myscore],0
mov [dead],0
invoke CreateThread,0,0,dprocedure,0,0,0
_gameloop:
mov al,[ispause]
test al,al
jnz @f
call advsnake
call fixrect ;Is our snake in place o.o"?
call makeapple ;We need an apple, dont?
call gotapple ;Did he got the damn apple?
call isdead ;Am i dead lol?
mov al,[dead]
test al,al
jz @f
mov [hasend],1
@@:
dprocedure:
call dbackground ;First, we draw the BACKGROUND!
invoke inttohex,[myscore]
invoke TextOutA,[mdc],2,2,scorestr,32
;invoke BitBlt,[mdc],0,0,250,30,[mtext],0,0,SRCCOPY
invoke BitBlt,[mdc],[applex],[appley],20,20,[mapple],0,0,SRCCOPY
call dsnake
mov al,[ispause]
test al,al
jz @f
invoke TextOutA,[mdc],335,30,'GAME PAUSED',11
@@:
;invoke BitBlt,[mdc],0,0,20,20,[mapple],0,0,SRCCOPY
;Write to OUR screen... lol
invoke GetDC,0
push eax
invoke BitBlt,eax,0,0,800,600,[mdc],0,0,SRCCOPY
pop eax
invoke DeleteDC,eax
call hotkeys ;My hotkeys are set here =P
invoke Sleep,8 ; "60 fps"? should be 16, but 12 is ok dont?
mov al,[hasend]
test al,al
jz dprocedure
retn
dbackground:
mov [rect.left],0
mov [rect.top],0
mov [rect.right],800
mov [rect.bottom],600
invoke FillRect,[mdc],rect,[clblack]
retn
dbackground2:
mov [rect.left],0
mov [rect.top],0
mov [rect.right],800
mov [rect.bottom],600
invoke CreateSolidBrush,0h
invoke FillRect,[mdc],rect,eax
retn
dsnake:
mov eax,[snakesize]
test eax,eax
jz _dsnakeend
mov ecx,eax
@@:
mov eax,4
mul ecx
add eax,[snakebody]
sub eax,4
mov dx,[eax]
add eax,2
mov ax,[eax]
xchg ax,dx
; AX = Right word ; DX = Left word ; Y,X respectivamente
movzx esi,ax
mov [rect.left],esi
add esi,20
mov [rect.right],esi
movzx esi,dx
mov [rect.top],esi
add esi,20
mov [rect.bottom],esi
push ecx
invoke FillRect,[mdc],rect,[clgray]
pop ecx
loop @b
_dsnakeend:
retn
hotkeys:
invoke GetAsyncKeyState,VK_ESCAPE
test eax,eax
jz @f
mov [hasend],1
@@:
invoke GetAsyncKeyState,VK_RIGHT
test eax,eax
jz @f
mov ax,[speedy]
test ax,ax
jz @f
mov [speedy],0
mov [speedx],20
@@:
invoke GetAsyncKeyState,VK_LEFT
test eax,eax
jz @f
mov ax,[speedy]
test ax,ax
jz @f
mov [speedy],0
mov [speedx],-20
@@:
invoke GetAsyncKeyState,VK_UP
test eax,eax
jz @f
mov ax,[speedx]
test ax,ax
jz @f
mov [speedx],0
mov [speedy],-20
@@:
invoke GetAsyncKeyState,VK_DOWN
test eax,eax
jz @f
mov ax,[speedx]
test ax,ax
jz @f
mov [speedx],0
mov [speedy],20
@@:
push 'P'
call [GetAsyncKeyState]
test eax,eax
jz @f
_not01:
push 'P'
call [GetAsyncKeyState]
test eax,eax
jnz _not01
xor [ispause],1
@@:
retn
incsnake:
mov eax,[snakesize]
inc eax
mov ecx,4
mul ecx
sub eax,4
add eax,[snakebody]
mov dword [eax],0ffffffffh
inc [snakesize]
retn
advsnake:
mov ecx,[snakesize]
mov eax,[snakebody]
@@:
mov eax,4
mul ecx
sub eax,4 ;Reach our spot
test eax,eax
jz @f ;if our spot is 0, we dont need it anymore
add eax,[snakebody]
mov edx,eax
sub edx,4 ;Lower body
mov edx,dword [edx]
mov dword [eax],edx
loop @b
@@:
mov eax,[snakebody]
mov dx,[speedx]
add word [eax],dx
add eax,2
mov dx,[speedy]
add word [eax],dx
retn
fixrect:
mov eax,[haswalls]
test eax,eax
jnz _haswall
mov eax,[snakebody]
mov dx,[eax]
add eax,2
mov ax,[eax]
;DX = X ; AX = Y
cmp dx,800
jne @f
mov ecx,[snakebody]
mov word [ecx],0
jmp _endfixrect
@@:
cmp dx,-20
jne @f
mov ecx,[snakebody]
mov word [ecx],800
jmp _endfixrect
@@:
cmp ax,600
jne @f
mov ecx,[snakebody]
add ecx,2
mov word [ecx],0
jmp _endfixrect
@@:
cmp ax,-20
jne @f
mov ecx,[snakebody]
add ecx,2
mov word [ecx],600
jmp _endfixrect
@@:
_endfixrect:
retn
_haswall:
mov eax,[snakebody]
mov dx,[eax];X
add eax,2
mov ax,[eax];Y
cmp dx,800
jne @f
mov [dead],1
@@:
cmp ax,600
jne @f
mov [dead],1
@@:
cmp dx,-20
jne @f
mov [dead],1
@@:
cmp ax,-20
jne @f
mov [dead],1
@@:
retn
makeapple:
mov al,[hasapple]
test al,al
jnz @f
mov ebx,20
mov [hasapple],1
call [GetTickCount]
and eax,39
mul ebx
mov [applex],eax
call [GetTickCount]
and eax,29
mul ebx
mov [appley],eax
@@:
retn
gotapple:
xor edx,edx
mov eax,[snakebody]
mov dx,[eax]
add eax,2
mov ax,[eax]
and eax,0ffffh
cmp edx,[applex]
jne @f
cmp eax,[appley]
jne @f
mov [hasapple],0
mov [applex],0ffffh
call incsnake
mov eax,70
sub eax,[gamespeed]
mul eax
mov ecx,5
;mul ecx
mov ecx,[snakesize]
mul ecx
mov ecx,[haswalls]
inc ecx
mul ecx
add [myscore],eax
@@:
retn
isdead:
mov ecx,[snakesize]
mov eax,[snakebody]
xor edx,edx
mov dx,[eax]
add eax,2
mov ax,[eax]
and eax,0ffffh
mov edi,edx
mov ebx,eax ;At this rate, DI = X; BX = Y
@@:
mov eax,4
mul ecx
sub eax,4
test eax,eax
jz @f
add eax,[snakebody]
cmp di,[eax]
jne _continue01
add eax,2
cmp bx,[eax]
jne _continue01
mov [dead],1
_continue01:
loop @b
@@:
retn
_zeroall:
mov ecx,_zend-_zstart-1
@@:
mov eax,_zstart
add eax,ecx
mov byte [eax],0
loop @b
retn
createmydc:
invoke GetDC,0
invoke CreateCompatibleDC,eax
mov [mdc],eax
invoke GetDC,0
invoke CreateCompatibleBitmap,eax,800,600
mov [mbmp],eax
invoke SelectObject,[mdc],[mbmp]
invoke SetBkMode,[mdc],TRANSPARENT
invoke SetTextColor,[mdc],0050588h
retn
zmenuitem dd 0
mainmenuproc:
mov eax,[isgaming]
test eax,eax
jnz _do023
invoke GetAsyncKeyState,VK_ESCAPE
test eax,eax
jz @f
invoke ExitProcess,0DEADh
@@:
invoke GetAsyncKeyState,VK_DOWN
test eax,eax
jz @f
mov eax,[zmenuitem]
cmp eax,6
je @f
inc [zmenuitem]
_001:
invoke GetAsyncKeyState,VK_DOWN
test eax,eax
jnz _001
@@:
invoke GetAsyncKeyState,VK_UP
test eax,eax
jz @f
mov eax,[zmenuitem]
test eax,eax
jz @f
dec [zmenuitem]
_002:
invoke GetAsyncKeyState,VK_UP
test eax,eax
jnz _002
@@:
call dbackground2
invoke TextOutA,[mdc],150,50,'Snake from HELL III [ASM with COLORS = TOTAL WIN!]',50
mov [rect.left],270
mov eax,[zmenuitem]
mov ecx,50
mul ecx
add eax,200-30
mov [rect.top],eax
mov [rect.right],285
add eax,15
mov [rect.bottom],eax
invoke CreateSolidBrush,0FFh
invoke FillRect,[mdc],rect,eax
invoke GetDC,0
push eax
invoke BitBlt,eax,0,0,800,600,[mdc],0,0,SRCCOPY
pop eax
invoke DeleteDC,eax
_do023:
invoke Sleep,16
jmp mainmenuproc
scorescreen:
call dbackground2
invoke inttohex,[myscore]
invoke TextOutA,[mdc],300,200,scorestr,32
invoke TextOutA,[mdc],300,400,'Press [ENTER] to go back to main menu, you asshole...',53
mov eax,[gamespeed]
cmp eax,20
jne @f
mov eax,[myscore]
cmp eax,0500000h
jng @f
invoke TextOutA,[mdc],300,200,'Lol, you ate satan''s balls 4 breakfast...',42
@@:
invoke GetDC,0
push eax
invoke BitBlt,eax,0,0,800,600,[mdc],0,0,SRCCOPY
pop eax
invoke DeleteDC,eax
invoke Sleep,25
invoke GetAsyncKeyState,VK_RETURN
test eax,eax
jz scorescreen
@@:
invoke GetAsyncKeyState,VK_RETURN
test eax,eax
jnz @b
retn
nullproc:
xor eax,eax
ret
jmp nullproc
inttohex dd _inttohex
_inttohex:
jmp @f
scorestr db 'Your stupid score is: 0x'
holder dd 0,0,0 ;We should need 6 bytes to make it true
@@:
xor ebx,ebx
mov edx,[esp+4] ;This will hold the parametter
mov eax,edx
and eax,0ff000000h ;Lets get our first byte
shr eax,4*6 ;Moving to AL
call getbits
cmp al,0ah
jge @f
sub al,7
@@:
add al,55
cmp bl,0ah
jge @f
sub bl,7
@@:
add bl,55
push 0
call setbits ;Here we set the results in the result buffer
mov eax,edx
and eax,0ff0000h ;Lets get our first byte
shr eax,4*4 ;Moving to AL
call getbits
cmp al,0ah
jge @f
sub al,7
@@:
add al,55
cmp bl,0ah
jge @f
sub bl,7
@@:
add bl,55
push 2
call setbits ;Here we set the results in the result buffer
mov eax,edx
and eax,0ff00h ;Lets get our first byte
shr eax,4*2 ;Moving to AL
call getbits
cmp al,0ah
jge @f
sub al,7
@@:
add al,55
cmp bl,0ah
jge @f
sub bl,7
@@:
add bl,55
push 4
call setbits ;Here we set the results in the result buffer
mov eax,edx
and eax,0ffh
call getbits
cmp al,0ah
jge @f
sub al,7
@@:
add al,55
cmp bl,0ah
jge @f
sub bl,7
@@:
add bl,55
push 6
call setbits
setbits:
lea ecx,[holder]
add ecx,[esp+4]
mov byte [ecx],bl
inc ecx
mov byte [ecx],al
retn 4
directory RT_DIALOG,dialogs,\
RT_BITMAP,bitmaps
;resource imag,\
; 1,LANG_ENGLISH+SUBLANG_DEFAULT,'apple.bmp'
;directory RT_DIALOG,dialogs
resource dialogs,\
37,LANG_ENGLISH+SUBLANG_DEFAULT,demonstration
;directory RT_BITMAP,bitmap
resource bitmaps,\
10,LANG_ENGLISH+SUBLANG_DEFAULT,apple
bitmap apple,'apple.bmp'
mdc dd ?
mtext dd ?
mbmp dd ?
mapple dd ?
clblack dd ?
clgray dd ?
hasapple db ?
applex dd ?
appley dd ?
_zstart:
snakesize dd ?
snakebody dd ?
myscore dd ?
haswalls dd ?
dead db ?
ispause db ?
hasend db ?
speedx dw ?
speedy dw ?
_zend:
:thumbsup::thumbsup:
BlackRain105
25th Feb 2013, 01:48
Patulong naman po, paano po ba maglagay ng numerical input sa Assembly language? Kapag al po kasi
ginagamit operand types do not match daw. Or kung meron pong marunong mag convert ng ascii input into
numerical. Kelangan po kasi para sa looping. Sana po may makatulong!!
:pray::pray::pray:
jellyx
26th Feb 2013, 22:06
Patulong naman po, paano po ba maglagay ng numerical input sa Assembly language? Kapag al po kasi
ginagamit operand types do not match daw. Or kung meron pong marunong mag convert ng ascii input into
numerical. Kelangan po kasi para sa looping. Sana po may makatulong!!
:pray::pray::pray:
; Jellyx/Relminator
.model small ; data segment < 64k, code segment < 64k
.stack 200h ; set up 512 bytes of stack space
.386
; ==================================================
=========================
.data
;Constants
cr equ 13 ;carriage return
lf equ 10 ;line feed
MAXINPUT equ 5 ;max char for input
;the prompts
Prompt db "Type first number:$" ;addend
Prompt2 db "Type second number:$" ;addend
Prompt3 db " The sum is:$"
;1234567
;1234567890123456789012345678901234567890123456789 0123456789012345678901234567890"
mess1 db "Program to add 2 values"
mess2 db "****ADDITION****"
mess3 db "Continue? y/n"
;1234567
;1234567890123456789012345678901234567890123456789 0123456789012345678901234567890"
name1 db " Submitted by... "
name2 db " xxxxxxxxxxxxxx "
name3 db " xxxxxxxxxxxxxx "
name4 db " xxxxxxxxxxxxxx "
name5 db " Press any key..."
;1234
;1234567890123456789012345678901234567890123456789 0
star db "* @ $ * @ $ * @ $ * @ $ * @ $ * @ $ * @ $ * @ $ *"
maxstar db 40
attrib db 0
.code
;************************************************* ****************
;Prints a string on the screen
Print Macro Message
pusha
xor ax,ax
mov ah, 09h ;print interrupt 21, 9
lea dx, message ;Load Effective Address(offset)
int 21h ;print it
popa
EndM Print
;************************************************* ****************
CursorOFF Macro
pusha
mov ah, 01 ;disable cursor
mov cx, 2000h
int 10h ;disable it baby
popa
EndM CursorOFF
;************************************************* ****************
CursorON Macro
pusha
mov ah, 01 ;enable cursor
mov cx, 0005h
int 10h ;enable it baby
popa
EndM CursorON
;************************************************* ****************
;sets the cursor at row col
Locate Macro row, col
pusha
mov ah, 02h ;int 10, 2
xor bx, bx ;bx should be zero
mov dh, row ;dh=row, dl = column
mov dl, col
int 10h ;do it
popa
EndM Locate
;************************************************* ****************
;reads the keyboad buffer
Input Macro
;needs ax to be unused
;returns in AH the scancode
;returns in AL the asciicode
mov ah, 10h ; check for input
int 16h
EndM Input
;************************************************* ****************
PrintChar Macro aschar
pusha
mov al, aschar
mov ah, 0ah
mov bh, 00
mov cx, 1
int 10h
popa
EndM PrintChar
;************************************************* ****************
;needs: ES:BP >>> Pointer to string
;cx >> numchars
PrintString macro row, col,attrib, numchars
pusha
mov ax, 1301h ;request display
mov bl, attrib ;attrib
mov bh, 0 ;page
mov dh, row
mov dl, col
mov cx, numchars
int 10h
popa
endm printstring
;************************************************* ****************
draw_box Macro
local x_loop
pusha
mov attrib,00110100b
lea bp, topline
PrintString 0,0,attrib, 40
lea bp, midline
mov cx, 22
xor ch,ch
x_loop:
PrintString cl,0,attrib,40
loop x_loop
lea bp, botline
PrintString 23,0,attrib, 40
popa
endm draw_box
;************************************************* ****************
;note:
;ascval = ascii string of asclen
;asclen = length of string
;binval = binary value to convert
;needs ax(or any free word register) to be equal to asclen
;ie: type "movzx, ax asclen" before calling the macro
;************************************************* ****************
;note:
;ascval = ascii string of asclen
;asclen = length of string
;binval = binary value to convert (dw)
;needs ax(or any free word register) to be equal to asclen
;ie: type "movzx, ax asclen" before calling the macro
;************************************************* ****************
;this waits for screen retrace/refresh or our demo being in ASM
;would as fast as an x-wing on steroids. :*)
waitretrace proc
mov dx,03dah ;0x3da9 vertical retrace port
wret:
in al,dx
and al,08h ; is vga in retrace?
jnz wret
wref:
in al,dx
and al,08h ;is retrace finished?
jz wref
ret
waitretrace endp
;************************************************* ****************
textmode proc
mov ah, 00h ;set video mode
mov al, 01h ;mode 40*25
int 10h ;enter 80x25x16 mode
ret
textmode endp
;************************************************* ****************
ClearScreen Proc
pusha ;preserve general regs
mov ax, 0600h ;int 10, 6(scroll screen)
mov bh, 0Fh ;color white on Black
mov cx, 0000 ;row0,col0
mov dx, 1828h ;25,80
int 10h ;scroll(clear it)
popa ;restore regs
ret
ClearScreen Endp
;************************************************* ****************
;destroys ax, dx
Getinput proc
pusha
mov ah, 0ah ;int 20, a (buffered input)
lea dx, paralist ;load parlist
int 21h ;do it
popa
ret
Getinput Endp
;************************************************* ****************
Sumformat proc
pusha
;************************************************* ****************
;************************************************* ****************
;************************************************* ****************
;************************************************* ****************
;************************************************* ****************
;************************************************* ****************
;Main proggie
start:
mov ax, @data ;use the @ operator
mov ds, ax ;ds now points to the data segment.
mov es, ax ;es now points to the data segment.
call textmode ;set to textmode
CursorOff
draw_box
l_again:
mov attrib, 11001010b
lea bp, mess3 ;
PrintString 22, 13,attrib, 13 ;print "again?"
quit_loop:
input
cmp al, 79h ;"y"
je start
cmp al, 59h ;"Y"
je start
cmp al, 6eh ;"n"
je end_it
cmp al, 4eh ;"N"
je end_it
jmp quit_loop
end_it:
CursorOff
call clearScreen
xor bx, bx
star_loop:
call waitretrace
call waitretrace
call waitretrace
call waitretrace
call waitretrace
call waitretrace
call waitretrace
call waitretrace
itchy
6th Sep 2013, 10:32
gumamit ka po ng virtual boX
para marun mo yung tasm sa 32bit.. tested and proven nayan
freydeasis
3rd Oct 2013, 23:32
Sir wala po bang crossword puzzle sa tasm? codes po thx :):pray:
haroldsam_5599
9th Oct 2013, 22:16
sir pahelp naman eto user must enter a number the print out the size of the inputed number
sample run:
enter number: 5
1
2
3
4
5
i cocount nya po ung number hangang sa ininput nung user.hangang 9 lang po pwede iinput..
help po sir..
raindeer23
10th Oct 2013, 10:14
sir pahelp naman eto user must enter a number the print out the size of the inputed number
sample run:
enter number: 5
1
2
3
4
5
i cocount nya po ung number hangang sa ininput nung user.hangang 9 lang po pwede iinput..
help po sir..
Brad mag increment ka, tapos kada increment ng number ipprint nya yung number. basta yung AH laging 0
para hindi hex ang maprint kundi whole number. ayan ah may logic ka na. Wag lang puro spoonfeed. Lahat
tayo pinag aaral. Wag mo sana mamasamain yung sinabi ko. Study hard dre.
radhiyoussef
4th May 2015, 22:58
Introduction to Machine Language
DEBUG
A software that is classifies as debugger which is used for testing and debugging executable programs
Advantages
It is Free
It is universally available
It is simple to use
It requires relatively little memory
DEBUG COMMANDS
E (Enter)
-enable you to key in data or machine instruction into memory beginning at a specific location address.
E.g -E 0200
D (Display or Dump)
Displays the contents of a portion memory ni hex and ASCII forms starting with the given address
E.g. -D 0200
A (Assemble)
Allows you to create a program in mnemonic or symbolic code.
E.g. -A 0100
T (Trace)
Runs he program in single-step mode. It also displays the new values of the registers and the next
instruction to be executed.
E.g -T
G (Go)
Runs the program as a whole in memory an displays the output
E.g. -G
U (Unassemble)
Lists all the instructions contained in the program beginning at the given address. You can also specify the
last address location.
E.g. -U 0100
-U 0100 0109
N (Name)
Gives a name to your program, coded as N <path> <filename>
Extention nae is .COM
E.g. -N A:SAMPLE.COM
W (Write)
Saves the program onto disk storage
E.g. -W
Comment
Reserved Words
Words in which the assembler assigns a special meaning and it cannot be used as identifiers
Using reserved words for a wrong purpose causes the assembler to generate an error message
Instructions
Statements that will be translated into machine language and executed by the computer.
Examples:
MOV ADD SUB
MUL DIV INC
DEC LOOP CMP
Directives
Statements that give information to the assembler
Sometimes called pseudo-ops
Examples:
TITLE DOSSEG .MODEL
.STACK .DATA .CODE
It must use letters (A...Z, az), number (09) and/or special characters like underscore (_), question mark
(?) and at sign (@).
It must always start with a letter
It must not use reserved words
It must not exceed to 31 character.
Examples of valid identifiers:
neym r2d2
num_1 msg8
Examples of invalid identifiers:
title num-1
4ever
Statement
May begin anywhere on the line
Each line can only contain one statement
Assembly is not case sensitive
Examples:
ADD AX, BX ; uses 2 operands
DEC CX ; uses
RET ; no operand
TITLE
.MODEL
It specifies and initializes the memory model before defining any segment
Format:
.MODEL <memory-model>
Examples:
.MODEL TINY
.MODEL SMALL
.MODEL MEDIUM
.STACK
It defines the size of the attack. The default stack size is 1,024 bytes which you can overrule.
Format:
.STACK <size>
Example:
.STACK 0100h
.DATA
.CODE
It defines and marks the code segment which consists of a set of instructions.
Format:
.CODE
Example:
.CODE
START:
END
It is placed at the last line of the source code
Format:
END
Example:
END START
STRING
Numeric Constant
Screen Processing
The monitor
A typical video screen has 80 columns numbered form 0 to 79 and 25 rows numbered from 0 to 24.
Interrupt 10h and function 06h handles the process of clearing the screen and scrolling
Clear all or part of display beginning at any screen location and ending at any higher-numbered location.
Interrupt 10h is the BIOS operation for screen handling and function 02h tells the operation to set the cursor
Its position determines where the next character is to be displayed.
Maraming Thanks dito... :thumbsup: makakatulong ito para sa review ko sa exam... :reading:
:more:
nad101
6th May 2015, 13:26
meron ba kayong PDF full tutorial...;)
bryan12
9th May 2015, 18:12
anu po yung tasm.? sounds unfamiliar ?
hanamichi1
9th May 2015, 19:07
medyo kaya naman to eh wag lang malilito masyado sa coding ....
bryan12
12th May 2015, 10:45
Anu po ba yang assembly language ? di ko po talaga yan magets ? PAti yung tasm ? tnx sa makakatulong.
by the way i'm just a newbie here guys. respect please. :yipee:
Tokzict
12th May 2015, 16:21
Anu po ba yang assembly language ? di ko po talaga yan magets ? PAti yung tasm ? tnx sa makakatulong.
by the way i'm just a newbie here guys. respect please. :yipee:
Matanong ko lang sa mga nagbabasa ng thread na to kun gusto nyo bang matuto ng Assembly Language.
Gagawa ako ng bagong post para jan if interested kayo. I quote nyo yung reply ko nato para malaman ko na
interesado kayo. I need 20 replies. Salamat.
jimsrics
19th Jun 2015, 10:11
pwede b mgcode ng assembly online ?at online mo din eh run to check the output?
naksjc
13th Mar 2016, 07:59
sir may tools po ba kayo ng assembly language?