Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!willett!ForthNet From: ForthNet@willett.UUCP (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: forth eng./68hc11 new micros Message-ID: <596.UUL1.3#5129@willett.UUCP> Date: 2 Mar 90 03:56:28 GMT Organization: Latest link in the ForthNet chain. (Pgh, PA) Lines: 87 Date: 02-28-90 (13:20) Number: 395 (Echo) To: ALL Refer#: NONE From: JACK BROWN Read: (N/A) Subj: PROBLEM 1A MEM CLEAR Status: PUBLIC MESSAGE ( 68hc11 Assembly Language Programming Course ) ( Problem 1a ) ( Write a 68HC11 assembly language program which will fill memory ) ( locations from $C100 to $C1FF with 00 ) ( Solution 1a ) ( Since we have no memory at $C000 we will use memory at $2000 ) ( instead. ) HEX 2100 CONSTANT DATA ( Start of memory to be filled with 0 ) 0100 CONSTANT DCOUNT ( Number of memory bytes to be filled ) ( High level Forth solution: ) ( : MCLEAR ( -- ) ( DATA DCOUNT OVER + SWAP ) ( DO 0 I C! LOOP ; ) ( High level Forth solution using Forth primitive FILL ) ( FILL ( adr n byte -- ) ( : MCLEAR DATA DCOUNT 0 FILL ; ) ( Actually... most Forth's have a primitive called ERASE which ) ( takes the address, adr, and count, n, on the stack. ) ( ERASE ( adr n -- ) ( : MCLEAR DATA DCOUNT ERASE ; ) ( Typical assembly language solution using Forth Assembler ) CODE MCLEAR ( -- ) XGDY, ( Save parameter stack pointer. ) DATA #, LDX, ( Load start address ) DCOUNT #, LDY, ( Set count to clear in Y ) BEGIN, 0 ,X CLR, ( Clear one byte ) INX, ( Increment address ) DEY, ( Decrement count ) 0=, ( Repeat until finished ) UNTIL, XGDY, ( Restore parameter stack ptr ) NEXT ( Jump to address interpreter ) END-CODE ( Forth CODE definition for ERASE ) ( ****** WARNING WARNING ***** ) ( When uploading to Max Forth using the line feed as the pace ) ( character the linefeed from a compiler warning or error may ) ( trigger the premature sending of the next line. The blank ) ( lines following ERASE are to allow the upload to get back ) ( in sync after the compiler warning: ) ( ERA__ NOT UNIQUE produced by creating the header for ERASE ) CODE ERASE ( adr n -- ) 0 ,Y LDD, ( Fetch n from stack into D register ) 2 ,Y LDX, ( Fetch adr from stack to X register ) XGDY, ( Swap parameter stack pointer for n ) BEGIN, 0 ,X CLR, ( Clear one byte ) INX, ( Increment address ) DEY, ( Decrement count ) 0=, ( Repeat until finished ) UNTIL, XGDY, ( Restore parameter stack ptr ) POPTWO: JMP, ( Pop adr and n from stack and ) ( Jump to address interpreter ) END-CODE DECIMAL NET/Mail : British Columbia Forth Board - Burnaby BC - (604)434-5886 ----- This message came from GEnie via willett through a semi-automated process. Report problems to: 'uunet!willett!dwp' or 'willett!dwp@gateway.sei.cmu.edu'