Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!willett!ForthNet From: ForthNet@willett.UUCP (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: forth eng./68hc11 new micros Message-ID: <597.UUL1.3#5129@willett.UUCP> Date: 2 Mar 90 03:56:32 GMT Organization: Latest link in the ForthNet chain. (Pgh, PA) Lines: 70 Date: 02-28-90 (13:24) Number: 396 (Echo) To: ALL Refer#: NONE From: JACK BROWN Read: (N/A) Subj: PROBLEM 1B MEM MOVE Status: PUBLIC MESSAGE ( 68hc11 Assembly Language Programming Course ) ( Problem 1b ) ( Write a 68HC11 assembly language program which will move ten ) ( bytes of data stored at memory locations $0010 -$0019 to ) ( locations $C101 - $C10A ) ( Solution 2a ) ( Since we have no memory at $C000 we will use memory at $2000 ) ( instead. Also the EVB board has free memory from $0000 - $0035 ) ( where as the Max Forth board does not, it has some free direct ) ( page ram starting at $0083 so we will modify the question to: ) ( Move ten bytes of data stored at memory locations $0090 - $0099 ) ( to locations $2101 - $210A ) HEX 0090 CONSTANT SOURCE 2101 CONSTANT DEST_START 210A CONSTANT DEST_END ( High level Forth Solution: ) ( : DMOVE ( -- ) ( DEST_END DEST_START - 1+ 0 ( DO SOURCE I + C@ DEST_START I + C! LOOP ; ) ( High level Forth solution using Forth primitive CMOVE ) ( CMOVE ( adr1 adr2 u -- ) ( Moves u bytes from adr1 to adr2 starting at low memory ) ( : DMOVE ( -- ) ( SOURCE DEST_START DEST_END ) ( OVER - 1+ CMOVE ; ) ( Typical assembly language solution to the problem of ) ( moving ten bytes from direct page to extended memory ) CODE DMOVE ( -- ) PSHY, ( Save parameter stack pointer ) DEST_END #, LDX, ( We will move from high mem to low mem ) DEST_END DEST_START ( Compute byte count to move on the fly ) - 1+ #, LDY, ( and load into Y register ) BEGIN, ( Y counts A 9 8 7 6 5 4 3 2 1 0 ) SOURCE 1- ,Y LDAA, ( we need 1- since loop exits on Y = 0 ) 0 ,X STAA, ( Fetch and store one byte ) DEX, ( Decrement destination address ) DEY, ( Decrement byte counter ) 0=, ( Leave loop on 0 count ) UNTIL, PULY, ( Restore parameter stack pointer ) NEXT ( Jump to inner interpreter. ) END-CODE ( Follow up exercise for Forth assemblers... ) ( Write 68HC11 CODE definitons for CMOVE and CMOVE> ) ( Look at my definition of ERASE for some hints on how) ( to fetch the adr1 adr2 and u arguments from the ) ( parameter stack. ) 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'