Road of Learn asm¶
This document is about some records of progress of learn asm. In Examples directory, there are many asm programs(IBM PC x86 asm) from simple- to difficult-level and in Exercises directory will contains some asm code segment for improve asm reading ability.
Build Environment¶
In Windows, we use assembly, linker tools tools compile and link assembly code file and you may need tools resources here. It contains masm, linker, debug and dosbox install executions, they all can run in Windows_x86 enviroment.
In Linux, you can use corresponding package-manager install dosbox tools or use virtual machine to build Windows enviroment.
Examples¶
Compare String¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | ;PROGRAM TITLE GOES HERE--Compare string
;**********************************************************
datarea segment ;define data segment
string1 db 'Move the cursor backword.'
string2 db 'Move the cursor backword.'
;
mess1 db 'Match.',13,10,'$'
mess2 db 'No Match!',13,10,'$'
datarea ends
;*********************************************************
prognam segment ;define code segment
;---------------------------------------------------------
main proc far
assume cs:prognam,ds:datarea,es:datarea
start: ;starting execution address
;set up stack for return
push ds ;save old data segment
sub ax,ax ;put zero in AX
push ax ;save it on stack
;set DS register to current data segment
mov ax,datarea ;datarea segment addr
mov ds,ax ; into DS register
mov es,ax ; into ES register
;MAIN PART OF PROGRAM GOES HERE
lea si,string1
lea di,string2
cld
mov cx,25
repz cmpsb
jz match
lea dx,mess2
jmp short disp
match:
lea dx,mess1
disp:
mov ah,09
int 21h
ret ;return to DOS
main endp ;end of main part of program
;----------------------------------------------------------
prognam ends ;end of code segment
;**********************************************************
end start ;end assembly
|