I am interested in understanding a little about Assembly

Code: Select all
MOV AH, 09
MOV DX, 0108
INT 21
RET
DB "Hello World!$"
Code: Select all
;Machine code 'Hello World'
;djes 2010
;http://www.purebasic.fr/french/viewtopic.php?f=4&t=10283
If CreateFile(0, "C:\hello.com")
WriteByte(0, $B4) : WriteByte(0,$09) : WriteByte(0,$BA) : WriteByte(0,$08)
WriteByte(0, $01) : WriteByte(0,$CD) : WriteByte(0,$21) : WriteByte(0,$C3)
WriteString(0, "Hello World!$")
EndIf
CloseFile(0)
End
Well, then learn PureBasic itself first?!Nituvious wrote:I am a complete newbie at programming
Code: Select all
org 100h ; code starts at offset 100h(256 bytes)
mov ah,9 ; number of DOS-function display_text = 9
mov dx,hello
int 21h
ret
hello db 'Hello world!',24h
Code: Select all
hw.s=programparameter(0)
if not hw.s
hw.s="Hello World!"
endif
ProcedureDLL ConsoleWrite(t.s)
stdout=GetStdHandle_(#STD_OUTPUT_HANDLE)
written.l
msg.s=t.s+Chr(13)+Chr(10)
size.l=Len(msg.s)
res=WriteFile_(stdout,@msg.s,size, @written, #Null)
res=FreeConsole_()
EndProcedure
EnableASM
!Extrn _strstr
Procedure StringAddress(s1)
Shared s2
p.l
s2=s1
PUSH s2
PUSH s2
CALL _strstr
ADD esp, 8
MOV p, eax
ProcedureReturn p
EndProcedure
ConsoleWrite(peekS(StringAddress(@hw.s)))
Declare.l aadd()
Declare.l asub()
Declare.l amul()
Declare.l adiv()
Procedure.l aadd()
MOV ebx,dword [v_a]
MOV eax,dword [v_b]
ADD eax,ebx
ProcedureReturn
EndProcedure
Procedure.l asub()
MOV ebx,dword [v_a]
MOV eax,dword [v_b]
SUB eax,ebx
NEG eax
ProcedureReturn
EndProcedure
Procedure.l amul()
MOV ebx,dword [v_a]
IMUL ebx,dword [v_b]
MOV eax,ebx
ProcedureReturn
EndProcedure
Procedure.l adiv()
MOV ebx,dword [v_a]
PUSH dword [v_b]
MOV eax,ebx
POP ecx
CDQ
IDIV ecx
MOV ebx,eax
MOV eax,ebx
ProcedureReturn
EndProcedure
a.l=val(programparameter(1))
b.l=val(programparameter(2))
if a=-1
a=10
b= 2:endif
if b>0
ConsoleWrite(str(a)+"+"+str(b)+"="+str(aadd()))
ConsoleWrite(str(a)+"-"+str(b)+"="+str(asub()))
ConsoleWrite(str(a)+"*"+str(b)+"="+str(amul()))
ConsoleWrite(str(a)+"/"+str(b)+"="+str(adiv()))
endif
Code: Select all
@echo off
cmd /c hello.exe
cmd /c hello.exe "and then some..."
cmd /c hello.exe "add/sub/mul/div" 1234 2
cmd /c hello.exe "add/sub/mul/div" -1
pause
exit
Code: Select all
@echo off
cmd /c hello.exe > hello.txt
cmd /c hello.exe "and then some..." >> hello.txt
cmd /c hello.exe "add/sub/mul/div" 1234 2 >> hello.txt
cmd /c hello.exe "add/sub/mul/div" -1 >> hello.txt
echo ------------------------------------------- >> hello.txt
echo CommandLine=%CmdCmdLine% >> hello.txt
echo FullPath =%~fn0 >> hello.txt
echo CmdParams =%*there are none >> hello.txt
echo FileDir =%~dp0 >> hello.txt
echo FileName =%~nn0 >> hello.txt
echo FileExt =%~x0 >> hello.txt
echo ------------------------------------------- >> hello.txt
@hostname >> hello.txt
echo %date% %time% >> hello.txt
WHOAMI >> hello.txt
echo ------------------------------------------- >> hello.txt
SYSTEMINFO >> hello.txt
echo ------------------------------------------- >> hello.txt
DRIVERQUERY >> hello.txt
echo ------------------------------------------- >> hello.txt
REG QUERY HKCU\Software >> hello.txt
REG QUERY HKLM\SYSTEM\MountedDevices >> hello.txt
REG QUERY HKLM\SYSTEM\CurrentControlSet\services >> hello.txt
REG QUERY HKLM\SYSTEM\CurrentControlSet\Enum\STORAGE\Volume >> hello.txt
REG QUERY HKLM\SYSTEM\CurrentControlSet\Enum\SCSI >> hello.txt
REG QUERY HKLM\SYSTEM\CurrentControlSet\Enum\IDE >> hello.txt
REG QUERY HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers >> hello.txt
cmd /c start /max notepad.exe hello.txt
exit