|
-
Feb 19th, 2003, 12:06 PM
#1
Thread Starter
Hyperactive Member
What is the Assembly language?
Last edited by raladin; Mar 29th, 2014 at 11:11 PM.
-
Feb 23rd, 2003, 10:15 AM
#2
This has already been answered, but anyway...
Assembly is the second most lowlevel you can get. It's a string representation of the CPU op-codes and thus only a small step away from machine code.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 27th, 2003, 06:06 PM
#3
New Member
Assembly Language Program Sample
Here's a small assembly language program that will shutdown the system. This works on all win-32 platforms. The program needs to be compiled with MASM32.
Code:
;
;
; Quick Shutdown utility program for Windows 32-bit platforms.
;
;
; FreeWare by Summit Computer Networks June 4, 2002
;
.486
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\advapi32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\advapi32.lib
;=================
; Structures
;=================
OSVINFO STRUCT
dwOSVersionInfoSize DWORD ?
dwMajorVersion DWORD ?
dwMinorVersion DWORD ?
dwBuildNumber DWORD ?
dwPlatformId DWORD ?
szCSDVersion BYTE 128 dup (?)
OSVINFO ENDS
LUIDCUST STRUCT
usedpart DWORD ?
ignorehigh32bitpart DWORD ?
LUIDCUST ENDS
TOKEN_PRIVS STRUCT
privilegecount DWORD ?
theluid LUIDCUST <>
attributes DWORD ?
TOKEN_PRIVS ENDS
IsWinNt PROTO
AdjustToken PROTO
; ---------------------
; literal string MACRO
; ---------------------
literal MACRO quoted_text:VARARG
LOCAL local_text
.data
local_text db quoted_text,0
.code
EXITM <local_text>
ENDM
; --------------------------------
; string address in INVOKE format
; --------------------------------
SADD MACRO quoted_text:VARARG
EXITM <ADDR literal(quoted_text)>
ENDM
.data
Msg DB "Shutdown the system now ?",0
Cap DB "Shutdown",0
.code
start:
mov eax, MB_ICONQUESTION ; exclamation dialog
xor eax, MB_YESNO ; with a Yes/No Prompt
xor eax, MB_DEFBUTTON2 ; No is the default
push eax ; parameter 4 onto stack
lea eax, Cap ; address of caption into eax
push eax ; caption onto stack
lea eax, Msg ; address of message into eax
push eax ; prompt onto stack
xor eax, eax ; zero dialog parent handle ID
push eax ; pass it to the stack
call MessageBoxA ; show the message box
cmp eax, IDNO ; see if the user pressed "NO"
je BypassBoot ; if so, bypass the shutdown
call AdjustToken ; Get rights to restart on NT platforms
mov eax, 00FFFFh ; -1 (INT)
push eax ; last parameter onto stack
mov eax , 5 ; 5 (4 or 1) Force and ShutDown
push eax ; first parameter
call ExitWindowsEx ; initiate shutdown proceedure
BypassBoot:
xor eax, eax ; setup zero return value
push eax ; pass it to the stack
call ExitProcess ; terminate this process
; *************************************************************************
; Return 1 if the OS is an NT Based Platform, othrwise return 0
IsWinNt proc
LOCAL vi:OSVINFO ; Version Info Struct
LOCAL pvi:DWORD ; Pointer To vi
lea eax, vi ; vi's address into eax
mov ecx, SizeOf vi ; sizeof vi struct into ecx
mov (OSVINFO PTR [eax]).dwOSVersionInfoSize, ecx ; copy size to element
mov pvi, eax ; ptr to vi into pvi
invoke GetVersionEx,pvi ; get version API call
cmp eax, 0 ; See if we got an error
je IsWinNtError
mov eax, pvi ; address back into eax
mov ecx, (OSVINFO PTR [eax]).dwPlatformId ; Platform ID into ecx
cmp ecx, VER_PLATFORM_WIN32_NT ; see if its an NT platform
je IsWinNtTrue
mov eax, 0 ; Return a Zero since its NOT NT
ret
IsWinNtTrue:
mov eax, 1 ; Return 1 since it IS NT
ret
IsWinNtError:
mov eax, 2 ; Return 2 indicating an Error
ret
IsWinNt endp
; *************************************************************************
; For NT Type Platforms get the privilege for a Shutdown/Restart.
AdjustToken proc
LOCAL hdlProcessHandle:DWORD
LOCAL hdlTokenHandle:DWORD
LOCAL tmpLuid:LUIDCUST
LOCAL tkp:TOKEN_PRIVS
LOCAL tkpNewButIgnored:TOKEN_PRIVS
LOCAL lBufferNeeded:DWORD
LOCAL tBuff[32]:BYTE
LOCAL ptBuff:DWORD
invoke IsWinNt ; see if we're on an NT platform
cmp eax, 1 ; a return of 1 means NT platform.
jne AdjTokDone
invoke GetCurrentProcess ; get the current process handle
mov hdlProcessHandle,eax ; save it to hdlProcessHandle
lea eax, tBuff ; address of temp buffer into eax
mov ptBuff, eax ; set pointer to temp buffer
mov BYTE PTR [eax], 0 ; initialize the buffer
invoke OpenProcessToken,hdlProcessHandle,40,ADDR hdlTokenHandle
invoke LookupPrivilegeValue,ptBuff,SADD("SeShutdownPrivilege"),ADDR tmpLuid
lea eax, tmpLuid ; address of tmpLuid into eax
; Contents of tmpLuid into ecx:edx
mov ecx, (LUIDCUST PTR [eax]).usedpart
mov edx, (LUIDCUST PTR [eax]).ignorehigh32bitpart
lea eax, tkp ; address of tkp into eax
mov (TOKEN_PRIVS PTR [eax]).privilegecount, 1
mov (TOKEN_PRIVS PTR [eax]).theluid.usedpart, ecx
mov (TOKEN_PRIVS PTR [eax]).theluid.ignorehigh32bitpart, edx
mov (TOKEN_PRIVS PTR [eax]).attributes, 2
invoke AdjustTokenPrivileges,hdlTokenHandle,0,ADDR tkp,\
SizeOf tkpNewButIgnored,ADDR tkpNewButIgnored,ADDR lBufferNeeded
AdjTokDone:
ret
AdjustToken endp
end start
Enjoy!
-
Feb 28th, 2003, 05:36 AM
#4
Although it will work this way, this part
Code:
mov eax, MB_ICONQUESTION ; exclamation dialog
xor eax, MB_YESNO ; with a Yes/No Prompt
xor eax, MB_DEFBUTTON2 ; No is the default
should actually be
Code:
mov eax, MB_ICONQUESTION ; exclamation dialog
or eax, MB_YESNO ; with a Yes/No Prompt
or eax, MB_DEFBUTTON2 ; No is the default
using ors instead of xors.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 28th, 2003, 03:08 PM
#5
New Member
Oops!
You are correct! I must have been asleep at the wheel when I was doing that part.
-
Apr 25th, 2003, 07:51 PM
#6
Lively Member
How to turn computer off in DOS.
Requires APM 1.2.
Code:
MOV AX,5301
XOR BX,BX
INT 15 ; Connect APM interface
MOV AX,530E
XOR BX,BX
MOV CH,01
MOV CL,02
INT 15 ; Enable APM 1.2
MOV AX,5307
MOV BX,0001
MOV CX,0003
INT 15 ; Turn power off to all BIOS-controlled devices (i.e., turn the PSU off)
MOV AX,5304
XOR BX,BX
INT 15 ; If that failed (not APM 1.2?), then disconnect interface
XOR AX,AX
XOR BX,BX ; Clear AX and BX
NOP
NOP
INT 20 ; Go back to DOS
(I think those comments are right.)
I made it in DEBUG. Works fine. I also have one for Suspend, although it won't put the monitor in low-power mode or turn the hard drive back on on my computer... 
And to reboot:
Code:
JMP FFFF:0000 ; Reboot NOW!
-AndySoft
[email protected]
[email protected] (Use the other one first!)
I use: NASM, HTML, Perl, PHP, JavaScript, Batch, TI-Basic (TI-83+), QBasic 1.1, QuickBASIC 4.5, QuickBASIC Extended 7.1, VB-WIN 6 Ent., and the rest of Visual Studio 6 Ent.  And who knows what else!
-
Jun 6th, 2003, 01:24 PM
#7
Fanatic Member
But (unless I am mistaken) all of those are examples of the 80x86 instruction set.
How bout Z80 and 68000?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|