12.07.2015 Views

MAXQ Core Assembly Guide - Maxim

MAXQ Core Assembly Guide - Maxim

MAXQ Core Assembly Guide - Maxim

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>MAXQ</strong> <strong>Core</strong> <strong>Assembly</strong> <strong>Guide</strong>callcallsub1sub2sub1:move LC[1], #10.loopA:add #1djnz LC[1], .loopA ; Jumps to .loopA within sub1retsub2:move LC[1], #10.loopA:add #1djnz LC[1], .loopA ; Jumps to .loopA within sub2retnext:nopIn the example code shown here, the .loopA label is only accessible to code between global labels sub1 andsub2 (in which case .loopA refers to sub1.loopA) or to code between global labels sub2 and next (in whichcase .loopA refers to sub2.loopA). Attempting to reference .loopA from elsewhere in the project will result inan assembler error.Local labels are an optional feature, but they help in keeping code cleaner and enforcing defined entry points forsubroutines. Another potential use lies in declaring variables in data space whose labels are only visible to certainsubroutines or blocks of code.segment codesub1:move LC[1], #10move DP[0], #.data1 ; Points to sub1.data1.loopA:add #1djnz LC[1], .loopAretsegment data.data1:dw 0segment codesub2:move LC[1], #10move DP[0], #.data1 ; Points to sub2.data1.loopA:add #1djnz LC[1], .loopAretsegment data.data1:dw 0Version 1.2 8 of 43 March 7, 2007

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!