News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Different Proc Styles

Started by Robert Collins, February 23, 2005, 05:43:24 AM

Previous topic - Next topic

Robert Collins

In all the assembly code I have seen thus far I usually see the first syntax for defining a proc.
I just happen to come accross two others which I have never seen before. Are all three styles accepted in MASM?


proc_name proc
  '
  '
  '
proc_name endp


BeginProc proc_name, PUBLIC
  '
  '
  .
proc_name EndP


BeginProc proc_name
  .
  .
  .
EndProc proc_name

Vortex

Only the fist syntax is valid but I remember that you can introduce the PUBLIC statement before proc.

Robert Collins

Well, that's what I thought. Maybe the other two are for some other assembler or they are macros

Kestrel

http://www.arl.wustl.edu/~lockwood/class/cs306/books/artofasm/Chapter_8/CH08-1.html#HEADING1-311

Assembly Syntax Standard

Label       Mnemonic    Operand,..,Operand  [;Comments]

ProcName    proc    ...     ; so MASM Syntax near Assembly Standard

donkey

Since when is a document titled "MASM: DIRECTIVES & PSEUDO-OPCODES (Part 1)" the assembly standard syntax ??? MASM is only one syntax among many, albeit the most popular. There is no syntax that is recognized by Intel as the standard for the x86. I wrote Intel once and basically got the reply that since they no longer make an assembler they have no opinion or preference as to the syntax, their only concern is that the assembler get the opcodes right. But just for fun why not say that Intel's assembler,which was developped by the chip maker, should be the standard ?

; *** FUNCTION Directive ***
AREA example, CODE, READONLY

label1
squaref FUNCTION ; start of function
squaref EXPORT squaref ; make it accessable to external calls
STMFD SP!,{r4-r6, lr} ; save selected registers onto stack
FRAME PUSH{r4-r6, lr} ; inform frame of these registers
; used immediately after they were saved

; function( procedure) code ; goes here
;
;
LDMFD SP!,{r4-r6, pc} ; retrieve original register values off stack
ENDFUNC ; end the function
END


BTW this is from the new ARM* syntax for the XScale Architecture, the only one that Intel actually supports and acknowledges as "the" Intel Standard Syntax.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Randall Hyde

Quote from: Robert Collins on February 23, 2005, 05:43:24 AM
In all the assembly code I have seen thus far I usually see the first syntax for defining a proc.
I just happen to come accross two others which I have never seen before. Are all three styles accepted in MASM?


proc_name proc
  '
  '
  '
proc_name endp


BeginProc proc_name, PUBLIC
  '
  '
  .
proc_name EndP


BeginProc proc_name
  .
  .
  .
EndProc proc_name


Items two and three are macros that Microsoft has created. This appears in various drivers, IIRC.
Cheers,
Randy Hyde

tekhead009

I hope that it's not too much of a problem if I deviate from the topic, but 1) I was curious about the the post by donkey. The posted intel example code for an ARM processor: are you actually able to compile and run assembly code written for that processor? I thought only the .net, and eVB/eVC were able to write programs for it. The example code doesn't look like it is C based, but it doesn't look like any kind of asm I've ever seen either.

2) Randall Hyde; seriously?

tenkey

If you define an assembly language for a processor, you can build an assembler for it.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

donkey

Quote from: tekhead009 on February 25, 2005, 02:45:15 PM
I hope that it's not too much of a problem if I deviate from the topic, but 1) I was curious about the the post by donkey. The posted intel example code for an ARM processor: are you actually able to compile and run assembly code written for that processor? I thought only the .net, and eVB/eVC were able to write programs for it. The example code doesn't look like it is C based, but it doesn't look like any kind of asm I've ever seen either.

2) Randall Hyde; seriously?

Hi,

No, I do not write for the ARM, I have the manuals for it though I have not read them yet. I was once thinking about an assembler for the x86 that followed the general ARM syntax but I perused the manuals and found it too cumbersome to consider coding in. I was hoping that Intel would have some interesting syntactical variations that might be applicable to our little world but after a quick look I gave up.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Mark Jones

Hmm, maybe a little OT but here is a short Microchip-brand PIC program; perhaps this looks a little more familiar than ARM code.


;--------------------------------------
CBLOCK NNh ; depends on the PICmicro free register area
minutes
hours
date
month
year
ENDC
;--------------------------------------
; Real Time Clock with leap year correction - call this routine once a minute
;--------------------------------------
rtcupdate    incf minutes,same ; increment MINUTES register
movlw .60 ; is it 60 ?
subwf minutes,w
btfss status,zero
retlw 00h ; return if not 60
clrf minutes ; make MINUTES zero
;-----------
incf hours,same ; increment HOURS register
movlw .24      ; is it 24 ?
subwf hours,w 
btfss status,zero
retlw 00h      ; return if not 24
clrf hours      ; make HOURS zero
;-----------                
; The MONTH starts from 01, before you increment the MONTH, check if FEBRUARY
call checkmonth
subwf date,w
btfsc status,zero
goto $+3
incf date,same ; increment DATE register
retlw 00h
movlw 01 ; reset DATE counter
movwf date
;-----------
incf month,same ; increment MONTH register
movlw .13      ; is it 13 ?
subwf month,w 
btfss status,zero
retlw 00h      ; return if not 13
movlw 01        ; make MONTH 01 - January
movwf month
;-----------
; No checking implemented
incf year,same ; increment YEAR register
retlw 0     
;-----------
checkmonth movlw HIGH $
movwf pclath
movlw 02 ; is it FEBRUARY ?
subwf month,w
btfsc status,zero
goto checkyear ; if FEBRUARY, check for leap year
movf month,w ; if other months load the date to
addwf pcl,same ; reset the DATE counter
retlw 00
retlw .31 ; Jan
retlw .28 ; Feb
retlw .31 ; Mar
retlw .30 ; Apl
retlw .31 ; May
retlw .30 ; Jun
retlw .31 ; Jul
retlw .31 ; Aug
retlw .30 ; Sep
retlw .31 ; Oct
retlw .30 ; Nov
retlw .31 ; Dec
; The year 1999 is zero and 2000 is 01. If FEBRUARY, load the number of days for that year
checkyear movf year,w
addwf pcl,same
retlw .28 ; 1999
retlw .29 ; 2000
retlw .28 ; 2001
retlw .28 ; 2002
retlw .28 ; 2003
retlw .29 ; 2004
retlw .28 ; 2005
retlw .28 ; 2006
retlw .28 ; 2007
retlw .29 ; 2008
retlw .28 ; 2009
retlw .28 ; 2010
retlw .28 ; 2011
retlw .29 ; 2012
;-------------------------------------------
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08