100 likes | 237 Vues
Names. Here's the general format of a statement: indentifier - operation - operand(s) - comment
E N D
Names Here's the general format of a statement: indentifier - operation - operand(s) - comment The identifier is the name as explained above.The operation is an instruction like MOV.The operands provide information for the Operation to act on. Like MOV (operation) AX,BX (operands).The comment is a line of text you can add as a comment, everything the assembler sees after a ";“ E.g. MOVINSTRUCTION: MOV AX,BX ;this is a MOV instruction
Jump statements • Simplest form of Jump statement • “jmp Lable” • Equivalent to GOTO • Simply says: Jump to Label
Equality Comparison • CMP leftOp, rightOP • Compares the leftOperand to the rightOperand • Jumps based on Equality: • JE (jump if equal) • JNE (jump if not equal) • JCXZ (jump if CX = 0) • JECXZ (jump if ECX = 0)
start TRUE FALSE expression Statement List 1 Statement list 2 end IF ELSE’s If (Expression) Statement List 1 Else Statement List 2
IF ELSE’s Initial code here If (OP1 == OP2){ X = 1; Y = 2; } Else { Z = 1; } Cmp op1 op2 Je L1 L1: Mov X,1 Mov Y,2 Jmp L3 L2: Mov Z, 1 Jmp L3 L3:
Branching • Conditional jump
start Expression FALSE TRUE Statement List End While Loops While (Expression) Statement List
Loops [continue] • .code stack100h • jmp start • start: mov cx, 10 ; The counter is in CX • mov ax, 0 ; I use AX as a sum holder • myloop: • add ax, cx ; ax = ax + cx • loop myloop • quit: ; here ax will hold the value of 1+2+...+10 • mov ax, 4c00h • int 21h • end
Prac 3 • Write an Assembly Program that: • prompts the user for a System Administrator pin (PIN). • prompts the user for an Iteration Limit (LIMIT). • prints "---THE SYSTEM IS NOW RUNNING---" • Loop until counter = LIMIT • prompt user for pin • if pin == PIN, jump to CORRECT PIN handling code • else print error message and increment counter • jump back to beginning of loop. Save as your program as “access.asm” Correction email: mashudun@gmail.com