Presentation is loading. Please wait.

Presentation is loading. Please wait.

Assembly Microprocessors session 4 ing. Ernst E. Mak MSc.

Similar presentations


Presentation on theme: "Assembly Microprocessors session 4 ing. Ernst E. Mak MSc."— Presentation transcript:

1 Assembly Microprocessors session 4 ing. Ernst E. Mak MSc

2 Generic Instructions Taxonomy input/output data load a value(register) into a register arithmetic jumping / subroutine control bitwise operators : Boolean, Register shifts interrupt handling stacking

3 Subtract SUBTRACT, Mnemonic is SUB syntax: SUB source destination (not shown): –A register source –value –register –memory by index As a result of a SUBtract, the destination is overwritten by the accumulator (a-register) minus the source.

4 subtraction examples SUB B SUB C SUB 15h SUB (HL)

5 BORROW decimal subtraction: 861-162 8 6 1 1 6 2 - 6 9 9 10

6 subtraction with carry subtraction include the carry(bit); Mnemonic: sbc, syntax sbc a, source or sbc HL,source2 Purpose: to calculate the effect of the carry while subtracting SOURCE: single register a,b,c,d,e if sbc a,... double register HL,DE,BC if sbc HL,... Effect: after for example: sbc a,b the a register will be: a:=a-b-1 if the carry was set a:=a-b if the carry was reset Example: HL:=515-245 (= (2*256+3)-245) ldhl,515d ldc,245 lda,l subc lde,a lda,h sbca,0 ldd,a halt

7 Increment increment, Mnemonic is inc syntax: inc destination destination: –register –memory by index as a result of an INCrement, the destination is increased by 1 flags are set and reset accordingly, EXCEPT the CARRY

8 Decrement increment, Mnemonic is dec syntax: dec destination destination: –register –memory by index as a result of an DECrement, the destination is decreased by 1 flags are set and reset accordingly, EXCEPT the CARRY

9 LOOPING backward loop init:ld a,2 label:inc a cp 150d jp nz,label halt

10 LOOPING forward loopinit:lda,2 label:cp0C3h jp z,end inca jplabel end:halt


Download ppt "Assembly Microprocessors session 4 ing. Ernst E. Mak MSc."

Similar presentations


Ads by Google